3 public class Clones : Object
8 public static Clones singleton()
10 if (_Clones == null) {
11 _Clones= new Clones();
15 public Xcls_spinner spinner;
16 public Xcls_toolbar toolbar;
17 public Xcls_scrolled scrolled;
18 public Xcls_reposView reposView;
19 public Xcls_reposStore reposStore;
20 public Xcls_tv_autocommit tv_autocommit;
21 public Xcls_cr_autocommit cr_autocommit;
22 public Xcls_tv_autopush tv_autopush;
23 public Xcls_cr_autopush cr_autopush;
24 public Xcls_tv_autobranch tv_autobranch;
25 public Xcls_cr_autobranch cr_autobranch;
26 public Xcls_tv_repo tv_repo;
27 public Xcls_cr_repo cr_repo;
28 public Xcls_tv_active_ticket tv_active_ticket;
29 public Xcls_cr_active_ticket cr_active_ticket;
30 public Xcls_tv_current_branch tv_current_branch;
31 public Xcls_cr_current_branch cr_current_branch;
32 public Xcls_tv_last_updated tv_last_updated;
33 public Xcls_cr_last_updated cr_last_updated;
34 public Xcls_tv_all_branches tv_all_branches;
35 public Xcls_cr_all_branches cr_all_branches;
43 this.el = new Gtk.Dialog();
48 this.el.title = "Manage Clones";
49 this.el.border_width = 3;
50 this.el.default_height = 500;
51 this.el.default_width = 1024;
52 this.el.deletable = true;
54 var child_0 = new Xcls_Box2( _this );
56 this.el.get_content_area().add ( child_0.el );
59 this.el.delete_event.connect( (self, event) => {
64 this.el.response.connect( (self, response_id) => {
71 // user defined functions
72 public void loadAndShow () {
76 _this.toolbar.el.hide();
77 _this.scrolled.el.hide();
78 _this.spinner.el.show();
79 _this.spinner.el.start();
81 GitRepo.updateAll("show_clones");
89 _this.spinner.el.stop();
90 _this.spinner.el.hide();
91 _this.toolbar.el.show();
92 _this.scrolled.el.show();
94 GLib.debug("show clones?");
95 this.el.set_deletable(true);
96 this.el.set_gravity(Gdk.Gravity.NORTH);
97 this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);
99 this.el.set_default_size(
100 int.min(1024,Gdk.Screen.width()),
101 int.max(500,Gdk.Screen.height() - 300)
105 _this.reposStore.load();
106 this.el.set_keep_above(true);
107 GLib.debug("show clones = run?");
110 // this.get('/reposStore').load();
112 //this.get('/ok_button').el.set_sensitive(false);
114 // block until we return.
115 // var run_ret = this.el.run();
116 // if (run_ret < 1 ) {
119 // print("RUN RETURN : " + run_ret);
121 //print(JSON.stringify(this.get('bug').getValue()));
122 // return this.get('bug').getValue();
123 //this.success = c.success;
125 public class Xcls_Box2 : Object
128 private Clones _this;
134 public Xcls_Box2(Clones _owner )
137 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
141 // set gobject values
142 var child_0 = new Xcls_spinner( _this );
144 this.el.pack_start ( child_0.el , false,false,0 );
145 var child_1 = new Xcls_toolbar( _this );
147 this.el.pack_start ( child_1.el , false,false,0 );
148 var child_2 = new Xcls_scrolled( _this );
150 this.el.pack_end ( child_2.el , true,true,0 );
153 // user defined functions
155 public class Xcls_spinner : Object
157 public Gtk.Spinner el;
158 private Clones _this;
164 public Xcls_spinner(Clones _owner )
167 _this.spinner = this;
168 this.el = new Gtk.Spinner();
172 // set gobject values
175 // user defined functions
178 public class Xcls_toolbar : Object
181 private Clones _this;
187 public Xcls_toolbar(Clones _owner )
190 _this.toolbar = this;
191 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
195 // set gobject values
196 this.el.homogeneous = true;
197 var child_0 = new Xcls_Button5( _this );
199 this.el.add ( child_0.el );
202 // user defined functions
204 public class Xcls_Button5 : Object
206 public Gtk.Button el;
207 private Clones _this;
213 public Xcls_Button5(Clones _owner )
216 this.el = new Gtk.Button();
220 // set gobject values
221 this.el.label = "Add Repository";
226 this.el.get_style_context().add_class("suggested-action");
230 this.el.clicked.connect( () => {
231 Clone.singleton().show(this.el);
238 // user defined functions
242 public class Xcls_scrolled : Object
244 public Gtk.ScrolledWindow el;
245 private Clones _this;
251 public Xcls_scrolled(Clones _owner )
254 _this.scrolled = this;
255 this.el = new Gtk.ScrolledWindow( null, null );
259 // set gobject values
260 this.el.expand = true;
261 this.el.hexpand = true;
262 this.el.shadow_type = Gtk.ShadowType.IN;
263 var child_0 = new Xcls_reposView( _this );
265 this.el.add ( child_0.el );
271 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
275 // user defined functions
277 public class Xcls_reposView : Object
279 public Gtk.TreeView el;
280 private Clones _this;
286 public Xcls_reposView(Clones _owner )
289 _this.reposView = this;
290 this.el = new Gtk.TreeView();
294 // set gobject values
295 this.el.search_column = 0;
296 this.el.activate_on_single_click = true;
297 this.el.enable_grid_lines = Gtk.TreeViewGridLines.HORIZONTAL;
298 var child_0 = new Xcls_reposStore( _this );
300 this.el.set_model ( child_0.el );
301 var child_1 = new Xcls_tv_autocommit( _this );
303 this.el.append_column ( child_1.el );
304 var child_2 = new Xcls_tv_autopush( _this );
306 this.el.append_column ( child_2.el );
307 var child_3 = new Xcls_tv_autobranch( _this );
309 this.el.append_column ( child_3.el );
310 var child_4 = new Xcls_tv_repo( _this );
312 this.el.append_column ( child_4.el );
313 var child_5 = new Xcls_tv_active_ticket( _this );
315 this.el.append_column ( child_5.el );
316 var child_6 = new Xcls_tv_current_branch( _this );
318 this.el.append_column ( child_6.el );
319 var child_7 = new Xcls_tv_last_updated( _this );
321 this.el.append_column ( child_7.el );
322 var child_8 = new Xcls_tv_all_branches( _this );
324 this.el.append_column ( child_8.el );
329 var selection = this.el.get_selection();
330 selection.set_mode( Gtk.SelectionMode.SINGLE);
333 var description = new Pango.FontDescription();
334 description.set_size(10000);
335 this.el.override_font(description);
340 this.el.row_activated.connect( (path, col) => {
342 if (col.title != "Current Branch") {
349 _this.reposStore.el.get_iter(out iter, path);
351 _this.reposStore.el.get_value(iter, 6, out val);
352 var git_working_dir = (string)val;
354 var repo = GitRepo.singleton().get(git_working_dir);
357 _this.reposView.el.get_cell_area(path, col, out rect);
358 RepoStatusPopover.singleton().show(this.el, rect, repo);
363 this.el.cursor_changed.connect( () => {
364 // SEE SELECTION.CHANGED
369 if (this.el.get_selection().count_selected_rows() < 1) {
370 //nothing? - clea it?
374 var model = this.get('/changedFilesStore');
376 var s = this.el.get_selection();
378 s.selected_foreach(function(model,p,iter) {
380 files.push( model.get_value(iter, 0).value.get_string());
383 this.get('/patchview').showDiff(files);
384 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
385 //print("OUT?" + value);// id..
386 // load the list in the right grid..
393 // user defined functions
395 public class Xcls_reposStore : Object
397 public Gtk.ListStore el;
398 private Clones _this;
404 public Xcls_reposStore(Clones _owner )
407 _this.reposStore = this;
408 this.el = new Gtk.ListStore( 10, typeof(string), // 0 repo
409 typeof(string), // 1 current branch
410 typeof(string), // 2 all branch
411 typeof(string), // 3 updated
412 typeof(bool), // 4 auto commit
413 typeof(bool), // 5 auto push
414 typeof(string), // 6 repopath
415 typeof(string), // 7 color highlighting?
416 typeof(bool), // 8 auto branch,
417 typeof(string) // 9 active Ticket
422 // set gobject values
425 // user defined functions
428 //this.insert(citer,iter,0);
429 print("getting list");
430 var tr = GitRepo.list();
434 // fixme .. sort by last updated ...
437 for(var i =0 ; i < tr.length; i++) {
438 var repo = tr.index(i);
439 // this is done before we display stuff...
440 //repo.loadBranches();
444 this.el.append(out iter);
446 //print(JSON.stringify(ret,null,4));
447 //tr[i].getBranches();
452 // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
453 // print(JSON.stringify(hi,null,4));
454 // } catch(e) { print(e);}
456 this.el.set_value(iter, 0, repo.name );
457 this.el.set_value( iter, 1, repo.currentBranch.name );
458 this.el.set_value( iter, 2, repo.branchesToString() );
459 // this.el.set_value(ret.iter, 2, '' + repo.branches.map(
460 // function(e) { return e.name;
463 // this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw));
464 this.el.set_value(iter, 4, repo.is_autocommit() );
465 this.el.set_value(iter, 5, repo.is_autopush() );
466 this.el.set_value(iter, 6, repo.git_working_dir );
468 var cb = repo.currentBranch;
469 //print(JSON.stringify(cb,null,4));
472 if (cb.lastrev != cb.remoterev) {
474 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
475 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote")
479 if (repo.has_local_changes) {
481 this.el.set_value( iter, 1, repo.currentBranch.name +"\nHas uncommitted changes" );
483 if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) {
485 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
486 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") +
487 "\nHas uncommitted changes" );
490 this.el.set_value(iter, 7, col );
491 var ticket = repo.activeTicket;
493 this.el.set_value(iter, 8, repo.is_auto_branch() );
494 this.el.set_value(iter, 9, ticket == null ? "" : ticket.id );
498 this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);
502 public class Xcls_tv_autocommit : Object
504 public Gtk.TreeViewColumn el;
505 private Clones _this;
511 public Xcls_tv_autocommit(Clones _owner )
514 _this.tv_autocommit = this;
515 this.el = new Gtk.TreeViewColumn();
519 // set gobject values
520 this.el.title = "Auto Commit";
521 this.el.min_width = 50;
522 var child_0 = new Xcls_cr_autocommit( _this );
524 this.el.pack_start ( child_0.el , false );
528 // this.items[0].el.set_activatable(true);
529 this.el.add_attribute(_this.cr_autocommit.el , "active", 4 );
532 // user defined functions
534 public class Xcls_cr_autocommit : Object
536 public Gtk.CellRendererToggle el;
537 private Clones _this;
543 public Xcls_cr_autocommit(Clones _owner )
546 _this.cr_autocommit = this;
547 this.el = new Gtk.CellRendererToggle();
551 // set gobject values
552 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
555 this.el.toggled.connect( (self, path) => {
558 _this.reposStore.el.get_iter_from_string(out iter, path);
562 _this.reposStore.el.get_value(iter, 4, out val);
563 _this.reposStore.el.get_value(iter, 6, out rval);
565 var repopath = (string)rval;
566 var bval = (bool)val;
567 _this.reposStore.el.set_value(iter, 4, !bval);
568 GLib.debug("got repopath? %s", repopath);
570 var repo = GitRepo.get(repopath);
571 repo.set_autocommit(!bval);
579 // user defined functions
583 public class Xcls_tv_autopush : Object
585 public Gtk.TreeViewColumn el;
586 private Clones _this;
592 public Xcls_tv_autopush(Clones _owner )
595 _this.tv_autopush = this;
596 this.el = new Gtk.TreeViewColumn();
600 // set gobject values
601 this.el.title = "Auto Push";
602 this.el.min_width = 50;
603 var child_0 = new Xcls_cr_autopush( _this );
605 this.el.pack_start ( child_0.el , false );
609 this.el.add_attribute(_this.cr_autopush.el , "active", 5 );
610 // this.items[0].el.set_activatable(true);
613 // user defined functions
615 public class Xcls_cr_autopush : Object
617 public Gtk.CellRendererToggle el;
618 private Clones _this;
624 public Xcls_cr_autopush(Clones _owner )
627 _this.cr_autopush = this;
628 this.el = new Gtk.CellRendererToggle();
632 // set gobject values
633 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
636 this.el.toggled.connect( (self, path) => {
639 _this.reposStore.el.get_iter_from_string(out iter, path);
643 _this.reposStore.el.get_value(iter, 5, out val);
644 _this.reposStore.el.get_value(iter, 6, out rval);
646 var repopath = (string)rval;
647 var bval = (bool)val;
648 _this.reposStore.el.set_value(iter, 5, !bval);
649 var repo = GitRepo.get(repopath);
650 repo.set_autopush(!bval);
658 // user defined functions
662 public class Xcls_tv_autobranch : Object
664 public Gtk.TreeViewColumn el;
665 private Clones _this;
671 public Xcls_tv_autobranch(Clones _owner )
674 _this.tv_autobranch = this;
675 this.el = new Gtk.TreeViewColumn();
679 // set gobject values
680 this.el.title = "Auto Branch";
681 this.el.min_width = 50;
682 var child_0 = new Xcls_cr_autobranch( _this );
684 this.el.pack_start ( child_0.el , false );
688 this.el.add_attribute(_this.cr_autobranch.el , "active", 8 );
689 // this.items[0].el.set_activatable(true);
692 // user defined functions
694 public class Xcls_cr_autobranch : Object
696 public Gtk.CellRendererToggle el;
697 private Clones _this;
703 public Xcls_cr_autobranch(Clones _owner )
706 _this.cr_autobranch = this;
707 this.el = new Gtk.CellRendererToggle();
711 // set gobject values
712 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
715 this.el.toggled.connect( (self, path) => {
718 _this.reposStore.el.get_iter_from_string(out iter, path);
722 _this.reposStore.el.get_value(iter, 8, out val);
723 _this.reposStore.el.get_value(iter, 6, out rval);
725 var repopath = (string)rval;
726 var bval = (bool)val;
727 _this.reposStore.el.set_value(iter, 8, !bval);
728 var repo = GitRepo.get(repopath);
729 repo.set_auto_branch(!bval);
737 // user defined functions
741 public class Xcls_tv_repo : Object
743 public Gtk.TreeViewColumn el;
744 private Clones _this;
750 public Xcls_tv_repo(Clones _owner )
753 _this.tv_repo = this;
754 this.el = new Gtk.TreeViewColumn();
758 // set gobject values
759 this.el.sort_column_id = 0;
760 this.el.title = "Repo";
761 this.el.min_width = 200;
762 this.el.sort_order = Gtk.SortType.ASCENDING;
763 this.el.resizable = true;
764 var child_0 = new Xcls_cr_repo( _this );
766 this.el.pack_start ( child_0.el , false );
770 this.el.add_attribute(_this.cr_repo.el , "markup", 0 );
773 // user defined functions
775 public class Xcls_cr_repo : Object
777 public Gtk.CellRendererText el;
778 private Clones _this;
784 public Xcls_cr_repo(Clones _owner )
787 _this.cr_repo = this;
788 this.el = new Gtk.CellRendererText();
792 // set gobject values
795 // user defined functions
799 public class Xcls_tv_active_ticket : Object
801 public Gtk.TreeViewColumn el;
802 private Clones _this;
808 public Xcls_tv_active_ticket(Clones _owner )
811 _this.tv_active_ticket = this;
812 this.el = new Gtk.TreeViewColumn();
816 // set gobject values
817 this.el.title = "Active Ticket";
818 this.el.min_width = 50;
819 var child_0 = new Xcls_cr_active_ticket( _this );
821 this.el.pack_start ( child_0.el , false );
825 this.el.add_attribute(_this.cr_active_ticket.el , "markup", 9 );
828 // user defined functions
830 public class Xcls_cr_active_ticket : Object
832 public Gtk.CellRendererText el;
833 private Clones _this;
839 public Xcls_cr_active_ticket(Clones _owner )
842 _this.cr_active_ticket = this;
843 this.el = new Gtk.CellRendererText();
847 // set gobject values
850 // user defined functions
854 public class Xcls_tv_current_branch : Object
856 public Gtk.TreeViewColumn el;
857 private Clones _this;
863 public Xcls_tv_current_branch(Clones _owner )
866 _this.tv_current_branch = this;
867 this.el = new Gtk.TreeViewColumn();
871 // set gobject values
872 this.el.title = "Current Branch";
873 this.el.min_width = 50;
874 var child_0 = new Xcls_cr_current_branch( _this );
876 this.el.pack_start ( child_0.el , false );
880 this.el.add_attribute(_this.cr_current_branch.el , "markup", 1 );
881 this.el.add_attribute(_this.cr_current_branch.el, "cell-background", 7 );
884 // user defined functions
886 public class Xcls_cr_current_branch : Object
888 public Gtk.CellRendererText el;
889 private Clones _this;
895 public Xcls_cr_current_branch(Clones _owner )
898 _this.cr_current_branch = this;
899 this.el = new Gtk.CellRendererText();
903 // set gobject values
906 // user defined functions
910 public class Xcls_tv_last_updated : Object
912 public Gtk.TreeViewColumn el;
913 private Clones _this;
919 public Xcls_tv_last_updated(Clones _owner )
922 _this.tv_last_updated = this;
923 this.el = new Gtk.TreeViewColumn();
927 // set gobject values
928 this.el.title = "Last updated";
929 this.el.min_width = 50;
930 var child_0 = new Xcls_cr_last_updated( _this );
932 this.el.pack_start ( child_0.el , false );
936 this.el.add_attribute(_this.cr_last_updated.el , "markup", 3 );
939 // user defined functions
941 public class Xcls_cr_last_updated : Object
943 public Gtk.CellRendererText el;
944 private Clones _this;
950 public Xcls_cr_last_updated(Clones _owner )
953 _this.cr_last_updated = this;
954 this.el = new Gtk.CellRendererText();
958 // set gobject values
961 // user defined functions
965 public class Xcls_tv_all_branches : Object
967 public Gtk.TreeViewColumn el;
968 private Clones _this;
974 public Xcls_tv_all_branches(Clones _owner )
977 _this.tv_all_branches = this;
978 this.el = new Gtk.TreeViewColumn();
982 // set gobject values
983 this.el.title = "All Branches";
984 this.el.min_width = 50;
985 this.el.resizable = false;
986 var child_0 = new Xcls_cr_all_branches( _this );
988 this.el.pack_start ( child_0.el , false );
992 this.el.add_attribute(_this.cr_all_branches.el , "markup", 2 );
995 // user defined functions
997 public class Xcls_cr_all_branches : Object
999 public Gtk.CellRendererText el;
1000 private Clones _this;
1006 public Xcls_cr_all_branches(Clones _owner )
1009 _this.cr_all_branches = this;
1010 this.el = new Gtk.CellRendererText();
1014 // set gobject values
1017 // user defined functions