3 public class Clones : Object
8 public static Clones singleton()
10 if (_Clones == null) {
11 _Clones= new Clones();
15 public Xcls_toolbar toolbar;
16 public Xcls_scrolled scrolled;
17 public Xcls_reposView reposView;
18 public Xcls_reposStore reposStore;
19 public Xcls_tv_autocommit tv_autocommit;
20 public Xcls_cr_autocommit cr_autocommit;
21 public Xcls_tv_autopush tv_autopush;
22 public Xcls_cr_autopush cr_autopush;
23 public Xcls_tv_autobranch tv_autobranch;
24 public Xcls_cr_autobranch cr_autobranch;
25 public Xcls_tv_repo tv_repo;
26 public Xcls_cr_repo cr_repo;
27 public Xcls_tv_active_ticket tv_active_ticket;
28 public Xcls_cr_active_ticket cr_active_ticket;
29 public Xcls_tv_current_branch tv_current_branch;
30 public Xcls_cr_current_branch cr_current_branch;
31 public Xcls_tv_last_updated tv_last_updated;
32 public Xcls_cr_last_updated cr_last_updated;
33 public Xcls_tv_all_branches tv_all_branches;
34 public Xcls_cr_all_branches cr_all_branches;
42 this.el = new Gtk.Dialog();
47 this.el.title = "Manage Clones";
48 this.el.border_width = 3;
49 this.el.default_height = 500;
50 this.el.default_width = 1024;
51 this.el.deletable = true;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.get_content_area().add ( child_0.el );
58 this.el.delete_event.connect( (self, event) => {
63 this.el.response.connect( (self, response_id) => {
70 // user defined functions
71 public void loadAndShow () {
72 _this.toolbar.el.hide();
73 _this.scrolled.el.hide();
74 _this.progress.el.show();
75 GitRepo.updateAll("show_clones");
82 GLib.debug("show clones?");
83 this.el.set_deletable(true);
84 this.el.set_gravity(Gdk.Gravity.NORTH);
85 this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);
87 this.el.set_default_size(
88 int.min(1024,Gdk.Screen.width()),
89 int.max(500,Gdk.Screen.height() - 300)
93 _this.reposStore.load();
94 this.el.set_keep_above(true);
95 GLib.debug("show clones = run?");
98 // this.get('/reposStore').load();
100 //this.get('/ok_button').el.set_sensitive(false);
102 // block until we return.
103 // var run_ret = this.el.run();
104 // if (run_ret < 1 ) {
107 // print("RUN RETURN : " + run_ret);
109 //print(JSON.stringify(this.get('bug').getValue()));
110 // return this.get('bug').getValue();
111 //this.success = c.success;
113 public class Xcls_Box2 : Object
116 private Clones _this;
122 public Xcls_Box2(Clones _owner )
125 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
129 // set gobject values
130 var child_0 = new Xcls_toolbar( _this );
132 this.el.pack_start ( child_0.el , false,false,0 );
133 var child_1 = new Xcls_scrolled( _this );
135 this.el.pack_end ( child_1.el , true,true,0 );
138 // user defined functions
140 public class Xcls_toolbar : Object
143 private Clones _this;
149 public Xcls_toolbar(Clones _owner )
152 _this.toolbar = this;
153 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
157 // set gobject values
158 this.el.homogeneous = true;
159 var child_0 = new Xcls_Button4( _this );
161 this.el.add ( child_0.el );
164 // user defined functions
166 public class Xcls_Button4 : Object
168 public Gtk.Button el;
169 private Clones _this;
175 public Xcls_Button4(Clones _owner )
178 this.el = new Gtk.Button();
182 // set gobject values
183 this.el.label = "Add Repository";
188 this.el.get_style_context().add_class("suggested-action");
192 this.el.clicked.connect( () => {
193 Clone.singleton().show(this.el);
200 // user defined functions
204 public class Xcls_scrolled : Object
206 public Gtk.ScrolledWindow el;
207 private Clones _this;
213 public Xcls_scrolled(Clones _owner )
216 _this.scrolled = this;
217 this.el = new Gtk.ScrolledWindow( null, null );
221 // set gobject values
222 this.el.expand = true;
223 this.el.hexpand = true;
224 this.el.shadow_type = Gtk.ShadowType.IN;
225 var child_0 = new Xcls_reposView( _this );
227 this.el.add ( child_0.el );
233 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
237 // user defined functions
239 public class Xcls_reposView : Object
241 public Gtk.TreeView el;
242 private Clones _this;
248 public Xcls_reposView(Clones _owner )
251 _this.reposView = this;
252 this.el = new Gtk.TreeView();
256 // set gobject values
257 this.el.search_column = 0;
258 this.el.activate_on_single_click = true;
259 this.el.enable_grid_lines = Gtk.TreeViewGridLines.HORIZONTAL;
260 var child_0 = new Xcls_reposStore( _this );
262 this.el.set_model ( child_0.el );
263 var child_1 = new Xcls_tv_autocommit( _this );
265 this.el.append_column ( child_1.el );
266 var child_2 = new Xcls_tv_autopush( _this );
268 this.el.append_column ( child_2.el );
269 var child_3 = new Xcls_tv_autobranch( _this );
271 this.el.append_column ( child_3.el );
272 var child_4 = new Xcls_tv_repo( _this );
274 this.el.append_column ( child_4.el );
275 var child_5 = new Xcls_tv_active_ticket( _this );
277 this.el.append_column ( child_5.el );
278 var child_6 = new Xcls_tv_current_branch( _this );
280 this.el.append_column ( child_6.el );
281 var child_7 = new Xcls_tv_last_updated( _this );
283 this.el.append_column ( child_7.el );
284 var child_8 = new Xcls_tv_all_branches( _this );
286 this.el.append_column ( child_8.el );
291 var selection = this.el.get_selection();
292 selection.set_mode( Gtk.SelectionMode.SINGLE);
295 var description = new Pango.FontDescription();
296 description.set_size(10000);
297 this.el.override_font(description);
302 this.el.row_activated.connect( (path, col) => {
304 if (col.title != "Current Branch") {
311 _this.reposStore.el.get_iter(out iter, path);
313 _this.reposStore.el.get_value(iter, 6, out val);
314 var git_working_dir = (string)val;
316 var repo = GitRepo.singleton().get(git_working_dir);
319 _this.reposView.el.get_cell_area(path, col, out rect);
320 RepoStatusPopover.singleton().show(this.el, rect, repo);
325 this.el.cursor_changed.connect( () => {
326 // SEE SELECTION.CHANGED
331 if (this.el.get_selection().count_selected_rows() < 1) {
332 //nothing? - clea it?
336 var model = this.get('/changedFilesStore');
338 var s = this.el.get_selection();
340 s.selected_foreach(function(model,p,iter) {
342 files.push( model.get_value(iter, 0).value.get_string());
345 this.get('/patchview').showDiff(files);
346 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
347 //print("OUT?" + value);// id..
348 // load the list in the right grid..
355 // user defined functions
357 public class Xcls_reposStore : Object
359 public Gtk.ListStore el;
360 private Clones _this;
366 public Xcls_reposStore(Clones _owner )
369 _this.reposStore = this;
370 this.el = new Gtk.ListStore( 10, typeof(string), // 0 repo
371 typeof(string), // 1 current branch
372 typeof(string), // 2 all branch
373 typeof(string), // 3 updated
374 typeof(bool), // 4 auto commit
375 typeof(bool), // 5 auto push
376 typeof(string), // 6 repopath
377 typeof(string), // 7 color highlighting?
378 typeof(bool), // 8 auto branch,
379 typeof(string) // 9 active Ticket
384 // set gobject values
387 // user defined functions
390 //this.insert(citer,iter,0);
391 print("getting list");
392 var tr = GitRepo.list();
396 // fixme .. sort by last updated ...
399 for(var i =0 ; i < tr.length; i++) {
400 var repo = tr.index(i);
401 // this is done before we display stuff...
402 //repo.loadBranches();
406 this.el.append(out iter);
408 //print(JSON.stringify(ret,null,4));
409 //tr[i].getBranches();
414 // hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
415 // print(JSON.stringify(hi,null,4));
416 // } catch(e) { print(e);}
418 this.el.set_value(iter, 0, repo.name );
419 this.el.set_value( iter, 1, repo.currentBranch.name );
420 this.el.set_value( iter, 2, repo.branchesToString() );
421 // this.el.set_value(ret.iter, 2, '' + repo.branches.map(
422 // function(e) { return e.name;
425 // this.el.set_value(iter, 3, '' + (!hi ? '??' : hi[0].changed_raw));
426 this.el.set_value(iter, 4, repo.is_autocommit() );
427 this.el.set_value(iter, 5, repo.is_autopush() );
428 this.el.set_value(iter, 6, repo.git_working_dir );
430 var cb = repo.currentBranch;
431 //print(JSON.stringify(cb,null,4));
434 if (cb.lastrev != cb.remoterev) {
436 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
437 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote")
441 if (repo.has_local_changes) {
443 this.el.set_value( iter, 1, repo.currentBranch.name +"\nHas uncommitted changes" );
445 if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) {
447 this.el.set_value( iter, 1, repo.currentBranch.name +"\n" +
448 (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") +
449 "\nHas uncommitted changes" );
452 this.el.set_value(iter, 7, col );
453 var ticket = repo.activeTicket;
455 this.el.set_value(iter, 8, repo.is_auto_branch() );
456 this.el.set_value(iter, 9, ticket == null ? "" : ticket.id );
460 this.el.set_sort_column_id (0, Gtk.SortType.ASCENDING);
464 public class Xcls_tv_autocommit : Object
466 public Gtk.TreeViewColumn el;
467 private Clones _this;
473 public Xcls_tv_autocommit(Clones _owner )
476 _this.tv_autocommit = this;
477 this.el = new Gtk.TreeViewColumn();
481 // set gobject values
482 this.el.title = "Auto Commit";
483 this.el.min_width = 50;
484 var child_0 = new Xcls_cr_autocommit( _this );
486 this.el.pack_start ( child_0.el , false );
490 // this.items[0].el.set_activatable(true);
491 this.el.add_attribute(_this.cr_autocommit.el , "active", 4 );
494 // user defined functions
496 public class Xcls_cr_autocommit : Object
498 public Gtk.CellRendererToggle el;
499 private Clones _this;
505 public Xcls_cr_autocommit(Clones _owner )
508 _this.cr_autocommit = this;
509 this.el = new Gtk.CellRendererToggle();
513 // set gobject values
514 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
517 this.el.toggled.connect( (self, path) => {
520 _this.reposStore.el.get_iter_from_string(out iter, path);
524 _this.reposStore.el.get_value(iter, 4, out val);
525 _this.reposStore.el.get_value(iter, 6, out rval);
527 var repopath = (string)rval;
528 var bval = (bool)val;
529 _this.reposStore.el.set_value(iter, 4, !bval);
530 GLib.debug("got repopath? %s", repopath);
532 var repo = GitRepo.get(repopath);
533 repo.set_autocommit(!bval);
541 // user defined functions
545 public class Xcls_tv_autopush : Object
547 public Gtk.TreeViewColumn el;
548 private Clones _this;
554 public Xcls_tv_autopush(Clones _owner )
557 _this.tv_autopush = this;
558 this.el = new Gtk.TreeViewColumn();
562 // set gobject values
563 this.el.title = "Auto Push";
564 this.el.min_width = 50;
565 var child_0 = new Xcls_cr_autopush( _this );
567 this.el.pack_start ( child_0.el , false );
571 this.el.add_attribute(_this.cr_autopush.el , "active", 5 );
572 // this.items[0].el.set_activatable(true);
575 // user defined functions
577 public class Xcls_cr_autopush : Object
579 public Gtk.CellRendererToggle el;
580 private Clones _this;
586 public Xcls_cr_autopush(Clones _owner )
589 _this.cr_autopush = this;
590 this.el = new Gtk.CellRendererToggle();
594 // set gobject values
595 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
598 this.el.toggled.connect( (self, path) => {
601 _this.reposStore.el.get_iter_from_string(out iter, path);
605 _this.reposStore.el.get_value(iter, 5, out val);
606 _this.reposStore.el.get_value(iter, 6, out rval);
608 var repopath = (string)rval;
609 var bval = (bool)val;
610 _this.reposStore.el.set_value(iter, 5, !bval);
611 var repo = GitRepo.get(repopath);
612 repo.set_autopush(!bval);
620 // user defined functions
624 public class Xcls_tv_autobranch : Object
626 public Gtk.TreeViewColumn el;
627 private Clones _this;
633 public Xcls_tv_autobranch(Clones _owner )
636 _this.tv_autobranch = this;
637 this.el = new Gtk.TreeViewColumn();
641 // set gobject values
642 this.el.title = "Auto Branch";
643 this.el.min_width = 50;
644 var child_0 = new Xcls_cr_autobranch( _this );
646 this.el.pack_start ( child_0.el , false );
650 this.el.add_attribute(_this.cr_autobranch.el , "active", 8 );
651 // this.items[0].el.set_activatable(true);
654 // user defined functions
656 public class Xcls_cr_autobranch : Object
658 public Gtk.CellRendererToggle el;
659 private Clones _this;
665 public Xcls_cr_autobranch(Clones _owner )
668 _this.cr_autobranch = this;
669 this.el = new Gtk.CellRendererToggle();
673 // set gobject values
674 this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
677 this.el.toggled.connect( (self, path) => {
680 _this.reposStore.el.get_iter_from_string(out iter, path);
684 _this.reposStore.el.get_value(iter, 8, out val);
685 _this.reposStore.el.get_value(iter, 6, out rval);
687 var repopath = (string)rval;
688 var bval = (bool)val;
689 _this.reposStore.el.set_value(iter, 8, !bval);
690 var repo = GitRepo.get(repopath);
691 repo.set_auto_branch(!bval);
699 // user defined functions
703 public class Xcls_tv_repo : Object
705 public Gtk.TreeViewColumn el;
706 private Clones _this;
712 public Xcls_tv_repo(Clones _owner )
715 _this.tv_repo = this;
716 this.el = new Gtk.TreeViewColumn();
720 // set gobject values
721 this.el.sort_column_id = 0;
722 this.el.title = "Repo";
723 this.el.min_width = 200;
724 this.el.sort_order = Gtk.SortType.ASCENDING;
725 this.el.resizable = true;
726 var child_0 = new Xcls_cr_repo( _this );
728 this.el.pack_start ( child_0.el , false );
732 this.el.add_attribute(_this.cr_repo.el , "markup", 0 );
735 // user defined functions
737 public class Xcls_cr_repo : Object
739 public Gtk.CellRendererText el;
740 private Clones _this;
746 public Xcls_cr_repo(Clones _owner )
749 _this.cr_repo = this;
750 this.el = new Gtk.CellRendererText();
754 // set gobject values
757 // user defined functions
761 public class Xcls_tv_active_ticket : Object
763 public Gtk.TreeViewColumn el;
764 private Clones _this;
770 public Xcls_tv_active_ticket(Clones _owner )
773 _this.tv_active_ticket = this;
774 this.el = new Gtk.TreeViewColumn();
778 // set gobject values
779 this.el.title = "Active Ticket";
780 this.el.min_width = 50;
781 var child_0 = new Xcls_cr_active_ticket( _this );
783 this.el.pack_start ( child_0.el , false );
787 this.el.add_attribute(_this.cr_active_ticket.el , "markup", 9 );
790 // user defined functions
792 public class Xcls_cr_active_ticket : Object
794 public Gtk.CellRendererText el;
795 private Clones _this;
801 public Xcls_cr_active_ticket(Clones _owner )
804 _this.cr_active_ticket = this;
805 this.el = new Gtk.CellRendererText();
809 // set gobject values
812 // user defined functions
816 public class Xcls_tv_current_branch : Object
818 public Gtk.TreeViewColumn el;
819 private Clones _this;
825 public Xcls_tv_current_branch(Clones _owner )
828 _this.tv_current_branch = this;
829 this.el = new Gtk.TreeViewColumn();
833 // set gobject values
834 this.el.title = "Current Branch";
835 this.el.min_width = 50;
836 var child_0 = new Xcls_cr_current_branch( _this );
838 this.el.pack_start ( child_0.el , false );
842 this.el.add_attribute(_this.cr_current_branch.el , "markup", 1 );
843 this.el.add_attribute(_this.cr_current_branch.el, "cell-background", 7 );
846 // user defined functions
848 public class Xcls_cr_current_branch : Object
850 public Gtk.CellRendererText el;
851 private Clones _this;
857 public Xcls_cr_current_branch(Clones _owner )
860 _this.cr_current_branch = this;
861 this.el = new Gtk.CellRendererText();
865 // set gobject values
868 // user defined functions
872 public class Xcls_tv_last_updated : Object
874 public Gtk.TreeViewColumn el;
875 private Clones _this;
881 public Xcls_tv_last_updated(Clones _owner )
884 _this.tv_last_updated = this;
885 this.el = new Gtk.TreeViewColumn();
889 // set gobject values
890 this.el.title = "Last updated";
891 this.el.min_width = 50;
892 var child_0 = new Xcls_cr_last_updated( _this );
894 this.el.pack_start ( child_0.el , false );
898 this.el.add_attribute(_this.cr_last_updated.el , "markup", 3 );
901 // user defined functions
903 public class Xcls_cr_last_updated : Object
905 public Gtk.CellRendererText el;
906 private Clones _this;
912 public Xcls_cr_last_updated(Clones _owner )
915 _this.cr_last_updated = this;
916 this.el = new Gtk.CellRendererText();
920 // set gobject values
923 // user defined functions
927 public class Xcls_tv_all_branches : Object
929 public Gtk.TreeViewColumn el;
930 private Clones _this;
936 public Xcls_tv_all_branches(Clones _owner )
939 _this.tv_all_branches = this;
940 this.el = new Gtk.TreeViewColumn();
944 // set gobject values
945 this.el.title = "All Branches";
946 this.el.min_width = 50;
947 this.el.resizable = false;
948 var child_0 = new Xcls_cr_all_branches( _this );
950 this.el.pack_start ( child_0.el , false );
954 this.el.add_attribute(_this.cr_all_branches.el , "markup", 2 );
957 // user defined functions
959 public class Xcls_cr_all_branches : Object
961 public Gtk.CellRendererText el;
962 private Clones _this;
968 public Xcls_cr_all_branches(Clones _owner )
971 _this.cr_all_branches = this;
972 this.el = new Gtk.CellRendererText();
976 // set gobject values
979 // user defined functions