3 public class Clones : Object
8 public static Clones singleton()
10 if (_Clones == null) {
11 _Clones= new Clones();
15 public Xcls_reposView reposView;
16 public Xcls_reposStore reposStore;
17 public Xcls_tv_autocommit tv_autocommit;
18 public Xcls_cr_autocommit cr_autocommit;
19 public Xcls_tv_autopush tv_autopush;
20 public Xcls_cr_autopush cr_autopush;
21 public Xcls_tv_autobranch tv_autobranch;
22 public Xcls_cr_autobranch cr_autobranch;
23 public Xcls_tv_repo tv_repo;
24 public Xcls_cr_repo cr_repo;
25 public Xcls_tv_active_ticket tv_active_ticket;
26 public Xcls_cr_active_ticket cr_active_ticket;
27 public Xcls_tv_current_branch tv_current_branch;
28 public Xcls_cr_current_branch cr_current_branch;
29 public Xcls_tv_last_updated tv_last_updated;
30 public Xcls_cr_last_updated cr_last_updated;
31 public Xcls_tv_all_branches tv_all_branches;
32 public Xcls_cr_all_branches cr_all_branches;
40 this.el = new Gtk.Dialog();
45 this.el.title = "Manage Clones";
46 this.el.border_width = 3;
47 this.el.default_height = 500;
48 this.el.default_width = 1024;
49 this.el.deletable = true;
51 var child_0 = new Xcls_Box2( _this );
53 this.el.get_content_area().add ( child_0.el );
56 this.el.delete_event.connect( (self, event) => {
61 this.el.response.connect( (self, response_id) => {
68 // user defined functions
69 public void loadAndShow () {
70 _this.toolbar.el.hide();
71 _this.scrolled.el.hide();
72 _this.progress.el.show();
73 GitRepo.updateAll("show_clones");
80 GLib.debug("show clones?");
81 this.el.set_deletable(true);
82 this.el.set_gravity(Gdk.Gravity.NORTH);
83 this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);
85 this.el.set_default_size(
86 int.min(1024,Gdk.Screen.width()),
87 int.max(500,Gdk.Screen.height() - 300)
91 _this.reposStore.load();
92 this.el.set_keep_above(true);
93 GLib.debug("show clones = run?");
96 // this.get('/reposStore').load();
98 //this.get('/ok_button').el.set_sensitive(false);
100 // block until we return.
101 // var run_ret = this.el.run();
102 // if (run_ret < 1 ) {
105 // print("RUN RETURN : " + run_ret);
107 //print(JSON.stringify(this.get('bug').getValue()));
108 // return this.get('bug').getValue();
109 //this.success = c.success;
111 public class Xcls_Box2 : Object
114 private Clones _this;
120 public Xcls_Box2(Clones _owner )
123 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
127 // set gobject values
128 var child_0 = new Xcls_Box3( _this );
130 this.el.pack_start ( child_0.el , false,false,0 );
131 var child_1 = new Xcls_ScrolledWindow5( _this );
133 this.el.pack_end ( child_1.el , true,true,0 );
136 // user defined functions
138 public class Xcls_Box3 : Object
141 private Clones _this;
147 public Xcls_Box3(Clones _owner )
150 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
154 // set gobject values
155 this.el.homogeneous = true;
156 var child_0 = new Xcls_Button4( _this );
158 this.el.add ( child_0.el );
161 // user defined functions
163 public class Xcls_Button4 : Object
165 public Gtk.Button el;
166 private Clones _this;
172 public Xcls_Button4(Clones _owner )
175 this.el = new Gtk.Button();
179 // set gobject values
180 this.el.label = "Add Repository";
185 this.el.get_style_context().add_class("suggested-action");
189 this.el.clicked.connect( () => {
190 Clone.singleton().show(this.el);
197 // user defined functions
201 public class Xcls_ScrolledWindow5 : Object
203 public Gtk.ScrolledWindow el;
204 private Clones _this;
210 public Xcls_ScrolledWindow5(Clones _owner )
213 this.el = new Gtk.ScrolledWindow( null, null );
217 // set gobject values
218 this.el.expand = true;
219 this.el.hexpand = true;
220 this.el.shadow_type = Gtk.ShadowType.IN;
221 var child_0 = new Xcls_reposView( _this );
223 this.el.add ( child_0.el );
229 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
233 // user defined functions
235 public class Xcls_reposView : Object
237 public Gtk.TreeView el;
238 private Clones _this;
244 public Xcls_reposView(Clones _owner )
247 _this.reposView = this;
248 this.el = new Gtk.TreeView();
252 // set gobject values
253 this.el.search_column = 0;
254 this.el.activate_on_single_click = true;
255 this.el.enable_grid_lines = Gtk.TreeViewGridLines.HORIZONTAL;
256 var child_0 = new Xcls_reposStore( _this );
258 this.el.set_model ( child_0.el );
259 var child_1 = new Xcls_tv_autocommit( _this );
261 this.el.append_column ( child_1.el );
262 var child_2 = new Xcls_tv_autopush( _this );
264 this.el.append_column ( child_2.el );
265 var child_3 = new Xcls_tv_autobranch( _this );
267 this.el.append_column ( child_3.el );
268 var child_4 = new Xcls_tv_repo( _this );
270 this.el.append_column ( child_4.el );
271 var child_5 = new Xcls_tv_active_ticket( _this );
273 this.el.append_column ( child_5.el );
274 var child_6 = new Xcls_tv_current_branch( _this );
276 this.el.append_column ( child_6.el );
277 var child_7 = new Xcls_tv_last_updated( _this );
279 this.el.append_column ( child_7.el );
280 var child_8 = new Xcls_tv_all_branches( _this );
282 this.el.append_column ( child_8.el );
287 var selection = this.el.get_selection();
288 selection.set_mode( Gtk.SelectionMode.SINGLE);
291 var description = new Pango.FontDescription();
292 description.set_size(10000);
293 this.el.override_font(description);
298 this.el.row_activated.connect( (path, col) => {
300 if (col.title != "Current Branch") {
307 _this.reposStore.el.get_iter(out iter, path);
309 _this.reposStore.el.get_value(iter, 6, out val);
310 var git_working_dir = (string)val;
312 var repo = GitRepo.singleton().get(git_working_dir);
315 _this.reposView.el.get_cell_area(path, col, out rect);
316 RepoStatusPopover.singleton().show(this.el, rect, repo);
321 this.el.cursor_changed.connect( () => {
322 // SEE SELECTION.CHANGED
327 if (this.el.get_selection().count_selected_rows() < 1) {
328 //nothing? - clea it?
332 var model = this.get('/changedFilesStore');
334 var s = this.el.get_selection();
336 s.selected_foreach(function(model,p,iter) {
338 files.push( model.get_value(iter, 0).value.get_string());
341 this.get('/patchview').showDiff(files);
342 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
343 //print("OUT?" + value);// id..
344 // load the list in the right grid..
351 // user defined functions
353 public class Xcls_reposStore : Object
355 public Gtk.ListStore el;
356 private Clones _this;
362 public Xcls_reposStore(Clones _owner )
365 _this.reposStore = this;
366 this.el = new Gtk.ListStore( 10, typeof(string), // 0 repo
367 typeof(string), // 1 current branch
368 typeof(string), // 2 all branch
369 typeof(string), // 3 updated
370 typeof(bool), // 4 auto commit
371 typeof(bool), // 5 auto push
372 typeof(string), // 6 repopath
373 typeof(string), // 7 color highlighting?
374 typeof(bool), // 8 auto branch,
375 typeof(string) // 9 active Ticket
380 // set gobject values
383 // user defined functions
386 //this.insert(citer,iter,0);
387 print("getting list");
388 var tr = GitRepo.list();
392 // fixme .. sort by last updated ...
395 for(var i =0 ; i < tr.length; i++) {
396 var repo = tr.index(i);
397 // this is done before we display stuff...
398 //repo.loadBranches();
402 this.el.append(out iter);
404 //print(JSON.stringify(ret,null,4));
405 //tr[i].getBranches();
410 // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
411 // print(JSON.stringify(hi,null,4));
412 // } catch(e) { print(e);}
414 this.el.set_value(iter, 0, repo.name );
415 this.el.set_value( iter, 1, repo.currentBranch.name );
416 this.el.set_value( iter, 2, repo.branchesToString() );
417 // this.el.set_value(ret.iter, 2, '' + repo.branches.map(
418 // function(e) { return e.name;
421 // this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw));
422 this.el.set_value(iter, 4, repo.is_autocommit() );
423 this.el.set_value(iter, 5, repo.is_autopush() );
424 this.el.set_value(iter, 6, repo.git_working_dir );
426 var cb = repo.currentBranch;
427 //print(JSON.stringify(cb,null,4));
430 if (cb.lastrev != cb.remoterev) {
432 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
433 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote")
437 if (repo.has_local_changes) {
439 this.el.set_value( iter, 1, repo.currentBranch.name +"\nHas uncommitted changes" );
441 if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) {
443 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
444 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") +
445 "\nHas uncommitted changes" );
448 this.el.set_value(iter, 7, col );
449 var ticket = repo.activeTicket;
451 this.el.set_value(iter, 8, repo.is_auto_branch() );
452 this.el.set_value(iter, 9, ticket == null ? "" : ticket.id );
456 this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);
460 public class Xcls_tv_autocommit : Object
462 public Gtk.TreeViewColumn el;
463 private Clones _this;
469 public Xcls_tv_autocommit(Clones _owner )
472 _this.tv_autocommit = this;
473 this.el = new Gtk.TreeViewColumn();
477 // set gobject values
478 this.el.title = "Auto Commit";
479 this.el.min_width = 50;
480 var child_0 = new Xcls_cr_autocommit( _this );
482 this.el.pack_start ( child_0.el , false );
486 // this.items[0].el.set_activatable(true);
487 this.el.add_attribute(_this.cr_autocommit.el , "active", 4 );
490 // user defined functions
492 public class Xcls_cr_autocommit : Object
494 public Gtk.CellRendererToggle el;
495 private Clones _this;
501 public Xcls_cr_autocommit(Clones _owner )
504 _this.cr_autocommit = this;
505 this.el = new Gtk.CellRendererToggle();
509 // set gobject values
510 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
513 this.el.toggled.connect( (self, path) => {
516 _this.reposStore.el.get_iter_from_string(out iter, path);
520 _this.reposStore.el.get_value(iter, 4, out val);
521 _this.reposStore.el.get_value(iter, 6, out rval);
523 var repopath = (string)rval;
524 var bval = (bool)val;
525 _this.reposStore.el.set_value(iter, 4, !bval);
526 GLib.debug("got repopath? %s", repopath);
528 var repo = GitRepo.get(repopath);
529 repo.set_autocommit(!bval);
537 // user defined functions
541 public class Xcls_tv_autopush : Object
543 public Gtk.TreeViewColumn el;
544 private Clones _this;
550 public Xcls_tv_autopush(Clones _owner )
553 _this.tv_autopush = this;
554 this.el = new Gtk.TreeViewColumn();
558 // set gobject values
559 this.el.title = "Auto Push";
560 this.el.min_width = 50;
561 var child_0 = new Xcls_cr_autopush( _this );
563 this.el.pack_start ( child_0.el , false );
567 this.el.add_attribute(_this.cr_autopush.el , "active", 5 );
568 // this.items[0].el.set_activatable(true);
571 // user defined functions
573 public class Xcls_cr_autopush : Object
575 public Gtk.CellRendererToggle el;
576 private Clones _this;
582 public Xcls_cr_autopush(Clones _owner )
585 _this.cr_autopush = this;
586 this.el = new Gtk.CellRendererToggle();
590 // set gobject values
591 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
594 this.el.toggled.connect( (self, path) => {
597 _this.reposStore.el.get_iter_from_string(out iter, path);
601 _this.reposStore.el.get_value(iter, 5, out val);
602 _this.reposStore.el.get_value(iter, 6, out rval);
604 var repopath = (string)rval;
605 var bval = (bool)val;
606 _this.reposStore.el.set_value(iter, 5, !bval);
607 var repo = GitRepo.get(repopath);
608 repo.set_autopush(!bval);
616 // user defined functions
620 public class Xcls_tv_autobranch : Object
622 public Gtk.TreeViewColumn el;
623 private Clones _this;
629 public Xcls_tv_autobranch(Clones _owner )
632 _this.tv_autobranch = this;
633 this.el = new Gtk.TreeViewColumn();
637 // set gobject values
638 this.el.title = "Auto Branch";
639 this.el.min_width = 50;
640 var child_0 = new Xcls_cr_autobranch( _this );
642 this.el.pack_start ( child_0.el , false );
646 this.el.add_attribute(_this.cr_autobranch.el , "active", 8 );
647 // this.items[0].el.set_activatable(true);
650 // user defined functions
652 public class Xcls_cr_autobranch : Object
654 public Gtk.CellRendererToggle el;
655 private Clones _this;
661 public Xcls_cr_autobranch(Clones _owner )
664 _this.cr_autobranch = this;
665 this.el = new Gtk.CellRendererToggle();
669 // set gobject values
670 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
673 this.el.toggled.connect( (self, path) => {
676 _this.reposStore.el.get_iter_from_string(out iter, path);
680 _this.reposStore.el.get_value(iter, 8, out val);
681 _this.reposStore.el.get_value(iter, 6, out rval);
683 var repopath = (string)rval;
684 var bval = (bool)val;
685 _this.reposStore.el.set_value(iter, 8, !bval);
686 var repo = GitRepo.get(repopath);
687 repo.set_auto_branch(!bval);
695 // user defined functions
699 public class Xcls_tv_repo : Object
701 public Gtk.TreeViewColumn el;
702 private Clones _this;
708 public Xcls_tv_repo(Clones _owner )
711 _this.tv_repo = this;
712 this.el = new Gtk.TreeViewColumn();
716 // set gobject values
717 this.el.sort_column_id = 0;
718 this.el.title = "Repo";
719 this.el.min_width = 200;
720 this.el.sort_order = Gtk.SortType.ASCENDING;
721 this.el.resizable = true;
722 var child_0 = new Xcls_cr_repo( _this );
724 this.el.pack_start ( child_0.el , false );
728 this.el.add_attribute(_this.cr_repo.el , "markup", 0 );
731 // user defined functions
733 public class Xcls_cr_repo : Object
735 public Gtk.CellRendererText el;
736 private Clones _this;
742 public Xcls_cr_repo(Clones _owner )
745 _this.cr_repo = this;
746 this.el = new Gtk.CellRendererText();
750 // set gobject values
753 // user defined functions
757 public class Xcls_tv_active_ticket : Object
759 public Gtk.TreeViewColumn el;
760 private Clones _this;
766 public Xcls_tv_active_ticket(Clones _owner )
769 _this.tv_active_ticket = this;
770 this.el = new Gtk.TreeViewColumn();
774 // set gobject values
775 this.el.title = "Active Ticket";
776 this.el.min_width = 50;
777 var child_0 = new Xcls_cr_active_ticket( _this );
779 this.el.pack_start ( child_0.el , false );
783 this.el.add_attribute(_this.cr_active_ticket.el , "markup", 9 );
786 // user defined functions
788 public class Xcls_cr_active_ticket : Object
790 public Gtk.CellRendererText el;
791 private Clones _this;
797 public Xcls_cr_active_ticket(Clones _owner )
800 _this.cr_active_ticket = this;
801 this.el = new Gtk.CellRendererText();
805 // set gobject values
808 // user defined functions
812 public class Xcls_tv_current_branch : Object
814 public Gtk.TreeViewColumn el;
815 private Clones _this;
821 public Xcls_tv_current_branch(Clones _owner )
824 _this.tv_current_branch = this;
825 this.el = new Gtk.TreeViewColumn();
829 // set gobject values
830 this.el.title = "Current Branch";
831 this.el.min_width = 50;
832 var child_0 = new Xcls_cr_current_branch( _this );
834 this.el.pack_start ( child_0.el , false );
838 this.el.add_attribute(_this.cr_current_branch.el , "markup", 1 );
839 this.el.add_attribute(_this.cr_current_branch.el, "cell-background", 7 );
842 // user defined functions
844 public class Xcls_cr_current_branch : Object
846 public Gtk.CellRendererText el;
847 private Clones _this;
853 public Xcls_cr_current_branch(Clones _owner )
856 _this.cr_current_branch = this;
857 this.el = new Gtk.CellRendererText();
861 // set gobject values
864 // user defined functions
868 public class Xcls_tv_last_updated : Object
870 public Gtk.TreeViewColumn el;
871 private Clones _this;
877 public Xcls_tv_last_updated(Clones _owner )
880 _this.tv_last_updated = this;
881 this.el = new Gtk.TreeViewColumn();
885 // set gobject values
886 this.el.title = "Last updated";
887 this.el.min_width = 50;
888 var child_0 = new Xcls_cr_last_updated( _this );
890 this.el.pack_start ( child_0.el , false );
894 this.el.add_attribute(_this.cr_last_updated.el , "markup", 3 );
897 // user defined functions
899 public class Xcls_cr_last_updated : Object
901 public Gtk.CellRendererText el;
902 private Clones _this;
908 public Xcls_cr_last_updated(Clones _owner )
911 _this.cr_last_updated = this;
912 this.el = new Gtk.CellRendererText();
916 // set gobject values
919 // user defined functions
923 public class Xcls_tv_all_branches : Object
925 public Gtk.TreeViewColumn el;
926 private Clones _this;
932 public Xcls_tv_all_branches(Clones _owner )
935 _this.tv_all_branches = this;
936 this.el = new Gtk.TreeViewColumn();
940 // set gobject values
941 this.el.title = "All Branches";
942 this.el.min_width = 50;
943 this.el.resizable = false;
944 var child_0 = new Xcls_cr_all_branches( _this );
946 this.el.pack_start ( child_0.el , false );
950 this.el.add_attribute(_this.cr_all_branches.el , "markup", 2 );
953 // user defined functions
955 public class Xcls_cr_all_branches : Object
957 public Gtk.CellRendererText el;
958 private Clones _this;
964 public Xcls_cr_all_branches(Clones _owner )
967 _this.cr_all_branches = this;
968 this.el = new Gtk.CellRendererText();
972 // set gobject values
975 // user defined functions