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 () {
73 this.el.set_deletable(true);
74 this.el.set_gravity(Gdk.Gravity.NORTH);
75 this.el.move((Gdk.Screen.width() / 2 ) - (int.min(1280,Gdk.Screen.width()) / 2) ,0);
76 this.el.set_keep_above(true);
77 this.el.set_default_size(
78 int.min(1280,Gdk.Screen.width()),
79 int.max(500,Gdk.Screen.height() - 200)
83 this.toolbar.el.hide();
84 this.scrolled.el.hide();
85 this.spinner.el.show();
86 this.spinner.el.start();
88 GitRepo.updateAllAsync("show_clones");
96 this.el.set_deletable(true);
97 this.el.set_gravity(Gdk.Gravity.NORTH);
98 this.el.move((Gdk.Screen.width() / 2 ) - (int.max(1280,Gdk.Screen.width()) / 2) ,0);
99 this.el.set_keep_above(true);
100 this.el.set_default_size(
101 int.max(1280,Gdk.Screen.width()),
102 int.max(500,Gdk.Screen.height() - 100)
105 this.spinner.el.stop();
106 this.spinner.el.hide();
107 this.toolbar.el.show();
108 this.scrolled.el.show();
113 this.reposStore.load();
115 GLib.debug("show clones = run?");
118 // this.get('/reposStore').load();
120 //this.get('/ok_button').el.set_sensitive(false);
122 // block until we return.
123 // var run_ret = this.el.run();
124 // if (run_ret < 1 ) {
127 // print("RUN RETURN : " + run_ret);
129 //print(JSON.stringify(this.get('bug').getValue()));
130 // return this.get('bug').getValue();
131 //this.success = c.success;
133 public class Xcls_Box2 : Object
136 private Clones _this;
142 public Xcls_Box2(Clones _owner )
145 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
149 // set gobject values
150 var child_0 = new Xcls_spinner( _this );
152 this.el.add ( child_0.el );
153 var child_1 = new Xcls_toolbar( _this );
155 this.el.pack_start ( child_1.el , false,false,0 );
156 var child_2 = new Xcls_scrolled( _this );
158 this.el.pack_end ( child_2.el , true,true,0 );
161 // user defined functions
163 public class Xcls_spinner : Object
165 public Gtk.Spinner el;
166 private Clones _this;
172 public Xcls_spinner(Clones _owner )
175 _this.spinner = this;
176 this.el = new Gtk.Spinner();
180 // set gobject values
181 this.el.hexpand = true;
182 this.el.vexpand = true;
185 // user defined functions
188 public class Xcls_toolbar : Object
191 private Clones _this;
197 public Xcls_toolbar(Clones _owner )
200 _this.toolbar = this;
201 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
205 // set gobject values
206 this.el.homogeneous = true;
207 var child_0 = new Xcls_Button5( _this );
209 this.el.add ( child_0.el );
212 // user defined functions
214 public class Xcls_Button5 : Object
216 public Gtk.Button el;
217 private Clones _this;
223 public Xcls_Button5(Clones _owner )
226 this.el = new Gtk.Button();
230 // set gobject values
231 this.el.label = "Add Repository";
236 this.el.get_style_context().add_class("suggested-action");
240 this.el.clicked.connect( () => {
241 Clone.singleton().show(this.el);
248 // user defined functions
252 public class Xcls_scrolled : Object
254 public Gtk.ScrolledWindow el;
255 private Clones _this;
261 public Xcls_scrolled(Clones _owner )
264 _this.scrolled = this;
265 this.el = new Gtk.ScrolledWindow( null, null );
269 // set gobject values
270 this.el.expand = true;
271 this.el.hexpand = true;
272 this.el.shadow_type = Gtk.ShadowType.IN;
273 var child_0 = new Xcls_reposView( _this );
275 this.el.add ( child_0.el );
281 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
285 // user defined functions
287 public class Xcls_reposView : Object
289 public Gtk.TreeView el;
290 private Clones _this;
296 public Xcls_reposView(Clones _owner )
299 _this.reposView = this;
300 this.el = new Gtk.TreeView();
304 // set gobject values
305 this.el.search_column = 0;
306 this.el.activate_on_single_click = true;
307 this.el.enable_grid_lines = Gtk.TreeViewGridLines.HORIZONTAL;
308 var child_0 = new Xcls_reposStore( _this );
310 this.el.set_model ( child_0.el );
311 var child_1 = new Xcls_tv_autocommit( _this );
313 this.el.append_column ( child_1.el );
314 var child_2 = new Xcls_tv_autopush( _this );
316 this.el.append_column ( child_2.el );
317 var child_3 = new Xcls_tv_autobranch( _this );
319 this.el.append_column ( child_3.el );
320 var child_4 = new Xcls_tv_repo( _this );
322 this.el.append_column ( child_4.el );
323 var child_5 = new Xcls_tv_active_ticket( _this );
325 this.el.append_column ( child_5.el );
326 var child_6 = new Xcls_tv_current_branch( _this );
328 this.el.append_column ( child_6.el );
329 var child_7 = new Xcls_tv_last_updated( _this );
331 this.el.append_column ( child_7.el );
332 var child_8 = new Xcls_tv_all_branches( _this );
334 this.el.append_column ( child_8.el );
339 var selection = this.el.get_selection();
340 selection.set_mode( Gtk.SelectionMode.SINGLE);
343 var description = new Pango.FontDescription();
344 description.set_size(10000);
345 this.el.override_font(description);
350 this.el.row_activated.connect( (path, col) => {
352 if (col.title == "Auto Commit" || col.title == "Auto Push" || col.title == "Auto Branch") {
359 _this.reposStore.el.get_iter(out iter, path);
361 _this.reposStore.el.get_value(iter, 6, out val);
362 var git_working_dir = (string)val;
364 var repo = GitRepo.singleton().get_sync(git_working_dir);
367 _this.reposView.el.get_cell_area(path, col, out rect);
368 RepoStatusPopover.singleton().show(this.el, rect, repo);
373 this.el.cursor_changed.connect( () => {
374 // SEE SELECTION.CHANGED
379 if (this.el.get_selection().count_selected_rows() < 1) {
380 //nothing? - clea it?
384 var model = this.get('/changedFilesStore');
386 var s = this.el.get_selection();
388 s.selected_foreach(function(model,p,iter) {
390 files.push( model.get_value(iter, 0).value.get_string());
393 this.get('/patchview').showDiff(files);
394 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
395 //print("OUT?" + value);// id..
396 // load the list in the right grid..
403 // user defined functions
405 public class Xcls_reposStore : Object
407 public Gtk.ListStore el;
408 private Clones _this;
414 public Xcls_reposStore(Clones _owner )
417 _this.reposStore = this;
418 this.el = new Gtk.ListStore( 10, typeof(string), // 0 repo
419 typeof(string), // 1 current branch
420 typeof(string), // 2 all branch
421 typeof(string), // 3 updated
422 typeof(bool), // 4 auto commit
423 typeof(bool), // 5 auto push
424 typeof(string), // 6 repopath
425 typeof(string), // 7 color highlighting?
426 typeof(bool), // 8 auto branch,
427 typeof(string) // 9 active Ticket
432 // set gobject values
435 // user defined functions
438 //this.insert(citer,iter,0);
439 print("getting list");
440 var tr = GitRepo.list();
444 // fixme .. sort by last updated ...
447 for(var i =0 ; i < tr.length; i++) {
448 var repo = tr.index(i);
449 // this is done before we display stuff...
450 //repo.loadBranches();
454 this.el.append(out iter);
456 //print(JSON.stringify(ret,null,4));
457 //tr[i].getBranches();
462 // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
463 // print(JSON.stringify(hi,null,4));
464 // } catch(e) { print(e);}
466 this.el.set_value(iter, 0, repo.name );
467 this.el.set_value( iter, 1, repo.getCurrentBranch().name );
468 this.el.set_value( iter, 2, repo.branchesToString() );
469 // this.el.set_value(ret.iter, 2, '' + repo.branches.map(
470 // function(e) { return e.name;
473 // this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw));
474 this.el.set_value(iter, 4, repo.is_autocommit() );
475 this.el.set_value(iter, 5, repo.is_autopush() );
476 this.el.set_value(iter, 6, repo.git_working_dir );
478 var cb = repo.getCurrentBranch();
479 //print(JSON.stringify(cb,null,4));
482 if (cb.lastrev != cb.remoterev) {
484 this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\n" +
485 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote")
489 if (repo.has_local_changes) {
491 this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\nHas uncommitted changes" );
493 if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) {
495 this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\n" +
496 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") +
497 "\nHas uncommitted changes" );
500 this.el.set_value(iter, 7, col );
501 var ticket = repo.activeTicket;
503 this.el.set_value(iter, 8, repo.is_auto_branch() );
504 this.el.set_value(iter, 9, ticket == null ? "" : ticket.id );
508 this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);
512 public class Xcls_tv_autocommit : Object
514 public Gtk.TreeViewColumn el;
515 private Clones _this;
521 public Xcls_tv_autocommit(Clones _owner )
524 _this.tv_autocommit = this;
525 this.el = new Gtk.TreeViewColumn();
529 // set gobject values
530 this.el.title = "Auto Commit";
531 this.el.min_width = 50;
532 var child_0 = new Xcls_cr_autocommit( _this );
534 this.el.pack_start ( child_0.el , false );
538 // this.items[0].el.set_activatable(true);
539 this.el.add_attribute(_this.cr_autocommit.el , "active", 4 );
542 // user defined functions
544 public class Xcls_cr_autocommit : Object
546 public Gtk.CellRendererToggle el;
547 private Clones _this;
553 public Xcls_cr_autocommit(Clones _owner )
556 _this.cr_autocommit = this;
557 this.el = new Gtk.CellRendererToggle();
561 // set gobject values
562 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
565 this.el.toggled.connect( (self, path) => {
568 _this.reposStore.el.get_iter_from_string(out iter, path);
572 _this.reposStore.el.get_value(iter, 4, out val);
573 _this.reposStore.el.get_value(iter, 6, out rval);
575 var repopath = (string)rval;
576 var bval = (bool)val;
577 _this.reposStore.el.set_value(iter, 4, !bval);
578 GLib.debug("got repopath? %s", repopath);
580 var repo = GitRepo.get_sync(repopath);
581 repo.set_autocommit(!bval);
587 // user defined functions
591 public class Xcls_tv_autopush : Object
593 public Gtk.TreeViewColumn el;
594 private Clones _this;
600 public Xcls_tv_autopush(Clones _owner )
603 _this.tv_autopush = this;
604 this.el = new Gtk.TreeViewColumn();
608 // set gobject values
609 this.el.title = "Auto Push";
610 this.el.min_width = 50;
611 var child_0 = new Xcls_cr_autopush( _this );
613 this.el.pack_start ( child_0.el , false );
617 this.el.add_attribute(_this.cr_autopush.el , "active", 5 );
618 // this.items[0].el.set_activatable(true);
621 // user defined functions
623 public class Xcls_cr_autopush : Object
625 public Gtk.CellRendererToggle el;
626 private Clones _this;
632 public Xcls_cr_autopush(Clones _owner )
635 _this.cr_autopush = this;
636 this.el = new Gtk.CellRendererToggle();
640 // set gobject values
641 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
644 this.el.toggled.connect( (self, path) => {
647 _this.reposStore.el.get_iter_from_string(out iter, path);
651 _this.reposStore.el.get_value(iter, 5, out val);
652 _this.reposStore.el.get_value(iter, 6, out rval);
654 var repopath = (string)rval;
655 var bval = (bool)val;
656 _this.reposStore.el.set_value(iter, 5, !bval);
657 var repo = GitRepo.get_sync(repopath);
658 repo.set_autopush(!bval);
666 // user defined functions
670 public class Xcls_tv_autobranch : Object
672 public Gtk.TreeViewColumn el;
673 private Clones _this;
679 public Xcls_tv_autobranch(Clones _owner )
682 _this.tv_autobranch = this;
683 this.el = new Gtk.TreeViewColumn();
687 // set gobject values
688 this.el.title = "Auto Branch";
689 this.el.min_width = 50;
690 var child_0 = new Xcls_cr_autobranch( _this );
692 this.el.pack_start ( child_0.el , false );
696 this.el.add_attribute(_this.cr_autobranch.el , "active", 8 );
697 // this.items[0].el.set_activatable(true);
700 // user defined functions
702 public class Xcls_cr_autobranch : Object
704 public Gtk.CellRendererToggle el;
705 private Clones _this;
711 public Xcls_cr_autobranch(Clones _owner )
714 _this.cr_autobranch = this;
715 this.el = new Gtk.CellRendererToggle();
719 // set gobject values
720 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
723 this.el.toggled.connect( (self, path) => {
726 _this.reposStore.el.get_iter_from_string(out iter, path);
730 _this.reposStore.el.get_value(iter, 8, out val);
731 _this.reposStore.el.get_value(iter, 6, out rval);
733 var repopath = (string)rval;
734 var bval = (bool)val;
735 _this.reposStore.el.set_value(iter, 8, !bval);
736 var repo = GitRepo.get_sync(repopath);
737 repo.set_auto_branch(!bval);
745 // user defined functions
749 public class Xcls_tv_repo : Object
751 public Gtk.TreeViewColumn el;
752 private Clones _this;
758 public Xcls_tv_repo(Clones _owner )
761 _this.tv_repo = this;
762 this.el = new Gtk.TreeViewColumn();
766 // set gobject values
767 this.el.sort_column_id = 0;
768 this.el.title = "Repo";
769 this.el.min_width = 200;
770 this.el.sort_order = Gtk.SortType.ASCENDING;
771 this.el.resizable = true;
772 var child_0 = new Xcls_cr_repo( _this );
774 this.el.pack_start ( child_0.el , false );
778 this.el.add_attribute(_this.cr_repo.el , "markup", 0 );
781 // user defined functions
783 public class Xcls_cr_repo : Object
785 public Gtk.CellRendererText el;
786 private Clones _this;
792 public Xcls_cr_repo(Clones _owner )
795 _this.cr_repo = this;
796 this.el = new Gtk.CellRendererText();
800 // set gobject values
803 // user defined functions
807 public class Xcls_tv_active_ticket : Object
809 public Gtk.TreeViewColumn el;
810 private Clones _this;
816 public Xcls_tv_active_ticket(Clones _owner )
819 _this.tv_active_ticket = this;
820 this.el = new Gtk.TreeViewColumn();
824 // set gobject values
825 this.el.title = "Active Ticket";
826 this.el.min_width = 50;
827 var child_0 = new Xcls_cr_active_ticket( _this );
829 this.el.pack_start ( child_0.el , false );
833 this.el.add_attribute(_this.cr_active_ticket.el , "markup", 9 );
836 // user defined functions
838 public class Xcls_cr_active_ticket : Object
840 public Gtk.CellRendererText el;
841 private Clones _this;
847 public Xcls_cr_active_ticket(Clones _owner )
850 _this.cr_active_ticket = this;
851 this.el = new Gtk.CellRendererText();
855 // set gobject values
858 // user defined functions
862 public class Xcls_tv_current_branch : Object
864 public Gtk.TreeViewColumn el;
865 private Clones _this;
871 public Xcls_tv_current_branch(Clones _owner )
874 _this.tv_current_branch = this;
875 this.el = new Gtk.TreeViewColumn();
879 // set gobject values
880 this.el.title = "Current Branch";
881 this.el.min_width = 50;
882 var child_0 = new Xcls_cr_current_branch( _this );
884 this.el.pack_start ( child_0.el , false );
888 this.el.add_attribute(_this.cr_current_branch.el , "markup", 1 );
889 this.el.add_attribute(_this.cr_current_branch.el, "cell-background", 7 );
892 // user defined functions
894 public class Xcls_cr_current_branch : Object
896 public Gtk.CellRendererText el;
897 private Clones _this;
903 public Xcls_cr_current_branch(Clones _owner )
906 _this.cr_current_branch = this;
907 this.el = new Gtk.CellRendererText();
911 // set gobject values
914 // user defined functions
918 public class Xcls_tv_last_updated : Object
920 public Gtk.TreeViewColumn el;
921 private Clones _this;
927 public Xcls_tv_last_updated(Clones _owner )
930 _this.tv_last_updated = this;
931 this.el = new Gtk.TreeViewColumn();
935 // set gobject values
936 this.el.title = "Last updated";
937 this.el.min_width = 50;
938 var child_0 = new Xcls_cr_last_updated( _this );
940 this.el.pack_start ( child_0.el , false );
944 this.el.add_attribute(_this.cr_last_updated.el , "markup", 3 );
947 // user defined functions
949 public class Xcls_cr_last_updated : Object
951 public Gtk.CellRendererText el;
952 private Clones _this;
958 public Xcls_cr_last_updated(Clones _owner )
961 _this.cr_last_updated = this;
962 this.el = new Gtk.CellRendererText();
966 // set gobject values
969 // user defined functions
973 public class Xcls_tv_all_branches : Object
975 public Gtk.TreeViewColumn el;
976 private Clones _this;
982 public Xcls_tv_all_branches(Clones _owner )
985 _this.tv_all_branches = this;
986 this.el = new Gtk.TreeViewColumn();
990 // set gobject values
991 this.el.title = "All Branches";
992 this.el.min_width = 50;
993 this.el.resizable = false;
994 var child_0 = new Xcls_cr_all_branches( _this );
996 this.el.pack_start ( child_0.el , false );
1000 this.el.add_attribute(_this.cr_all_branches.el , "markup", 2 );
1003 // user defined functions
1005 public class Xcls_cr_all_branches : Object
1007 public Gtk.CellRendererText el;
1008 private Clones _this;
1014 public Xcls_cr_all_branches(Clones _owner )
1017 _this.cr_all_branches = this;
1018 this.el = new Gtk.CellRendererText();
1022 // set gobject values
1025 // user defined functions