Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

thgconfig: rework UI design

Closes #924

Changeset bb87fd7b0e86

Parent 867bd8fc7a68

by Yuki KODAMA

Changes to one file · Browse files at bb87fd7b0e86 Showing diff from parent 867bd8fc7a68 Diff from another changeset...

 
525
526
527
 
528
529
530
 
563
564
565
566
 
567
568
569
 
573
574
575
576
 
577
578
 
579
580
581
582
583
 
 
584
585
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
587
588
 
 
589
590
591
 
592
593
594
 
595
596
597
 
605
606
607
608
609
610
611
612
613
614
615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
617
618
 
621
622
623
 
 
 
 
624
625
626
 
695
696
697
 
 
 
 
 
 
 
 
698
699
700
701
 
 
702
703
704
 
705
706
707
 
845
846
847
 
 
 
 
848
849
850
851
852
 
870
871
872
873
874
875
876
 
 
 
877
878
 
 
 
 
 
 
 
 
 
 
879
880
881
882
 
883
884
885
886
887
 
888
889
890
891
892
 
893
894
895
896
897
 
898
899
900
901
902
 
903
904
905
906
 
907
908
 
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
 
924
925
926
927
928
929
930
931
 
 
 
 
 
 
 
932
933
934
935
936
937
938
 
939
940
 
941
942
943
944
945
946
947
948
949
950
951
952
 
 
953
954
955
 
956
957
958
 
959
960
961
 
1001
1002
1003
1004
 
 
1005
1006
1007
1008
1009
 
1010
1011
1012
1013
1014
 
 
 
 
 
 
 
 
1015
1016
1017
 
1120
1121
1122
1123
1124
1125
 
 
 
1126
1127
1128
 
1142
1143
1144
1145
 
1146
1147
 
525
526
527
528
529
530
531
 
564
565
566
 
567
568
569
570
 
574
575
576
 
577
578
 
579
580
581
582
 
 
583
584
585
 
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
 
 
622
623
624
 
 
625
626
627
 
628
629
630
631
 
639
640
641
 
 
 
 
 
 
 
 
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
 
672
673
674
675
676
677
678
679
680
681
 
750
751
752
753
754
755
756
757
758
759
760
761
762
 
 
763
764
765
766
 
767
768
769
770
 
908
909
910
911
912
913
914
915
 
916
917
918
 
936
937
938
 
 
 
 
939
940
941
942
 
943
944
945
946
947
948
949
950
951
952
953
954
955
 
956
957
958
959
960
 
961
962
963
964
965
 
966
967
968
969
970
 
971
972
973
974
975
 
976
977
 
 
 
978
979
 
980
981
982
983
984
 
 
 
 
 
 
 
 
 
 
 
985
986
987
 
 
 
 
 
 
988
989
990
991
992
993
994
995
996
997
998
999
 
 
1000
1001
 
1002
1003
1004
1005
1006
 
 
 
 
 
 
 
 
1007
1008
1009
 
 
1010
1011
1012
 
1013
1014
1015
1016
 
1056
1057
1058
 
1059
1060
1061
 
1062
1063
 
1064
1065
1066
1067
 
 
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
 
1181
1182
1183
 
 
 
1184
1185
1186
1187
1188
1189
 
1203
1204
1205
 
1206
1207
1208
@@ -525,6 +525,7 @@
  gtklib.set_tortoise_keys(self)   self._btn_apply = self.action_area.get_children()[0]   self.set_has_separator(False) + self.set_default_size(-1, 500)     self.ui = ui.ui()   try: @@ -563,7 +564,7 @@
  # wrapper box for padding   wrapbox = gtk.VBox()   wrapbox.set_border_width(5) - self.vbox.pack_start(wrapbox, False, False) + self.vbox.pack_start(wrapbox)     # create combo to select the target   combo = gtk.combo_box_new_text() @@ -573,25 +574,58 @@
  combo.connect('changed', self.fileselect)     hbox = gtk.HBox() - hbox.pack_start(combo, False, False, 2) + hbox.pack_start(combo, False, False)   edit = gtk.Button(_('Edit File')) - hbox.pack_start(edit, False, False, 2) + hbox.pack_start(edit, False, False, 6)   edit.connect('clicked', self.edit_clicked)   wrapbox.pack_start(hbox, False, False, 1)   - # insert padding of between combo and notebook - wrapbox.pack_start(gtk.VBox(), False, False, 3) + # insert padding of between combo and middle pane + wrapbox.pack_start(gtk.VBox(), False, False, 4)   - # Create a new notebook, place the position of the tabs + # hbox for splitting treeview and main pane (notebook + desc) + sidebox = gtk.HBox() + wrapbox.pack_start(sidebox) + + # create treeview for selecting configuration page + self.confmodel = gtk.ListStore(gtk.gdk.Pixbuf, # icon + str, # label text + str) # page id + self.confview = gtk.TreeView(self.confmodel) + self.confview.set_headers_visible(False) + self.confview.set_size_request(140, -1) + self.confview.connect('cursor-changed', self.cursor_changed) + + tvframe = gtk.Frame() + sidebox.pack_start(tvframe, False, False) + tvframe.set_shadow_type(gtk.SHADOW_IN) + tvframe.add(self.confview) + + col = gtk.TreeViewColumn() + self.confview.append_column(col) + cell = gtk.CellRendererPixbuf() + col.pack_start(cell, True) + col.add_attribute(cell, 'pixbuf', 0) + + col = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=1) + self.confview.append_column(col) + + # insert padding of between treeview and main pane + sidebox.pack_start(gtk.HBox(), False, False, 4) + + # vbox for splitting notebook and desc frame + mainbox = gtk.VBox() + sidebox.pack_start(mainbox) + + # create a new notebook, place the position of the tabs   self.notebook = notebook = gtk.Notebook() - notebook.set_tab_pos(gtk.POS_TOP) - wrapbox.pack_start(notebook, True, True) + notebook.set_show_tabs(False) + notebook.set_show_border(False)   notebook.show() - self.show_tabs = True - self.show_border = True + mainbox.pack_start(notebook)     self.dirty = False - self.pages = [] + self.pages = {}   self.tooltips = gtk.Tooltips()   self.history = settings.Settings('thgconfig')   @@ -605,14 +639,31 @@
  'Examples: en, en_GB, en_US')),)     # create pages for each section of configuration file - self.add_page('TortoiseHg', tortoise_info) - self.add_page(_('Commit'), _commit_info) - self.add_page(_('Changelog'), _log_info) - self.add_page(_('Sync'), _paths_info, path=True) - self.add_page(_('Web'), _web_info) - self.add_page(_('Proxy'), _proxy_info) - self.add_page(_('Email'), _email_info) - self.add_page(_('Diff'), _diff_info) + self.add_page('TortoiseHg', 'general', tortoise_info, 'thg_logo.ico') + self.add_page(_('Commit'), 'commit', _commit_info, 'menucommit.ico') + self.add_page(_('Changelog'), 'log', _log_info, 'menulog.ico') + self.add_page(_('Sync'), 'sync', _paths_info, 'menusynch.ico', True) + self.add_page(_('Web'), 'web', _web_info, 'proxy.ico') + self.add_page(_('Proxy'), 'proxy', _proxy_info, 'general.ico') + self.add_page(_('Email'), 'email', _email_info, gtk.STOCK_GOTO_LAST) + self.add_page(_('Diff'), 'diff', _diff_info, gtk.STOCK_JUSTIFY_FILL) + + # insert padding of between notebook and common desc frame + mainbox.pack_start(gtk.VBox(), False, False, 2) + + # common description frame + descframe = gtk.Frame(_('Description')) + mainbox.pack_start(descframe, False, False) + desctext = gtk.TextView() + desctext.set_wrap_mode(gtk.WRAP_WORD) + desctext.set_editable(False) + desctext.set_sensitive(False) + scrolled = gtk.ScrolledWindow() + scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scrolled.set_border_width(4) + scrolled.add(desctext) + descframe.add(scrolled) + self.descbuffer = desctext.get_buffer()     self.configrepo = configrepo   @@ -621,6 +672,10 @@
  self.dirty = False   combo.set_active(configrepo and 1 or 0)   + # activate first config page + self.confview.set_cursor(self.confmodel[0].path) + self.confview.grab_focus() +   def fileselect(self, combo):   'select another hgrc file'   if self.dirty: @@ -695,13 +750,21 @@
  self._apply_clicked()   return False   + def cursor_changed(self, treeview): + path, focus = self.confview.get_cursor() + if not path: + return + name = self.confmodel[path][2] + page_num, info, vbox, widgets = self.pages[name] + self.notebook.set_current_page(page_num) +   def focus_field(self, focusfield):   '''Set page and focus to requested datum''' - for page_num, (vbox, info, widgets) in enumerate(self.pages): - for w, (label, cpath, values, tip) in enumerate(info): + for page_num, info, vbox, widgets in self.pages.values(): + for n, (label, cpath, values, tip) in enumerate(info):   if cpath == focusfield:   self.notebook.set_current_page(page_num) - widgets[w].grab_focus() + widgets[n].grab_focus()   return     def new_path(self, newpath, alias='new'): @@ -845,8 +908,11 @@
  self._defaultpathbutton.set_sensitive(not default_path and path_selected)     def fill_path_frame(self, frvbox): + # insert padding + frvbox.pack_start(gtk.VBox(), False, False, 2) + + # paths frame   frame = gtk.Frame(_('Remote repository paths')) - frame.set_border_width(4)   frvbox.pack_start(frame, True, True, 2)   vbox = gtk.VBox()   vbox.set_border_width(4) @@ -870,92 +936,81 @@
  column = gtk.TreeViewColumn(_('Repository Path'), renderer, text=1)   self.pathtree.append_column(column)   - scrolledwindow = gtk.ScrolledWindow() - scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolledwindow.add(self.pathtree) - vbox.add(scrolledwindow) + scrolled = gtk.ScrolledWindow() + scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scrolled.add(self.pathtree)   - buttonbox = gtk.HBox() + treeframe = gtk.Frame() + treeframe.set_border_width(2) + treeframe.set_shadow_type(gtk.SHADOW_IN) + treeframe.add(scrolled) + vbox.add(treeframe) + + # bottom command buttons + bottombox = gtk.HBox() + vbox.pack_start(bottombox, False, False, 4) +   self.addButton = gtk.Button(_('_Add'))   self.addButton.set_use_underline(True)   self.addButton.connect('clicked', self._add_path) - buttonbox.pack_start(self.addButton, True, True, 2) + bottombox.pack_start(self.addButton, True, True, 2)     self._editpathbutton = gtk.Button(_('_Edit'))   self._editpathbutton.set_use_underline(True)   self._editpathbutton.connect('clicked', self._edit_path) - buttonbox.pack_start(self._editpathbutton, True, True, 2) + bottombox.pack_start(self._editpathbutton, True, True, 2)     self._delpathbutton = gtk.Button(_('_Remove'))   self._delpathbutton.set_use_underline(True)   self._delpathbutton.connect('clicked', self._remove_path) - buttonbox.pack_start(self._delpathbutton, True, True, 2) + bottombox.pack_start(self._delpathbutton, True, True, 2)     self._testpathbutton = gtk.Button(_('_Test'))   self._testpathbutton.set_use_underline(True)   self._testpathbutton.connect('clicked', self._test_path) - buttonbox.pack_start(self._testpathbutton, True, True, 2) + bottombox.pack_start(self._testpathbutton, True, True, 2)     self._defaultpathbutton = gtk.Button(_('Set as _default'))   self._defaultpathbutton.set_use_underline(True)   self._defaultpathbutton.connect('clicked', self._default_path) - buttonbox.pack_start(self._defaultpathbutton, True, True, 2) + bottombox.pack_start(self._defaultpathbutton, True, True, 2)   - vbox.pack_start(buttonbox, False, False, 4) - - def set_help(self, widget, event, buffer, tooltip): + def set_help(self, widget, event, tooltip):   text = ' '.join(tooltip.splitlines()) - buffer.set_text(text) + self.descbuffer.set_text(text)     def fill_frame(self, frame, info):   widgets = []   - descframe = gtk.Frame(_('Description')) - descframe.set_border_width(4) - desctext = gtk.TextView() - desctext.set_wrap_mode(gtk.WRAP_WORD) - desctext.set_editable(False) - desctext.set_sensitive(False) - scrolledwindow = gtk.ScrolledWindow() - scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolledwindow.add(desctext) - scrolledwindow.set_border_width(4) - descframe.add(scrolledwindow) + table = gtklib.LayoutTable()     vbox = gtk.VBox() - table = gtk.Table(len(info), 2, False) - vbox.pack_start(table, False, False, 2) - if info != _paths_info: - vbox.pack_start(gtk.Label(), True, True, 0) - vbox.pack_start(descframe, False, False, 2) - frame.add(vbox) + vbox.pack_start(table, False, False) + + scrolled = gtk.ScrolledWindow() + scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + scrolled.add_with_viewport(vbox) + scrolled.child.set_shadow_type(gtk.SHADOW_NONE) + frame.pack_start(scrolled)     for row, (label, cpath, values, tooltip) in enumerate(info):   vlist = gtk.ListStore(str, bool)   combo = gtk.ComboBoxEntry(vlist, 0)   combo.connect('changed', self.dirty_event) - combo.child.connect('focus-in-event', self.set_help, - desctext.get_buffer(), tooltip) + combo.child.connect('focus-in-event', self.set_help, tooltip)   combo.set_row_separator_func(lambda model, path: model[path][1]) - combo.child.set_width_chars(40) + combo.child.set_width_chars(32)   if cpath in _pwfields:   combo.child.set_visibility(False)   widgets.append(combo)   - lbl = gtk.Label(label + ':') - lbl.set_alignment(1.0, 0.0) - eventbox = gtk.EventBox() - eventbox.set_visible_window(False) - eventbox.add(lbl) - table.attach(eventbox, 0, 1, row, row+1, gtk.FILL, 0, 4, 2) - table.attach(combo, 1, 2, row, row+1, gtk.FILL|gtk.EXPAND, 0, 4, 2) - self.tooltips.set_tip(eventbox, tooltip) + table.add_row(label + ':', combo, padding=False) + self.tooltips.set_tip(combo, tooltip)   - self.pages.append((vbox, info, widgets)) - return vbox + return vbox, widgets     def refresh_vlist(self): - for vbox, info, widgets in self.pages: + for page_num, info, vbox, widgets in self.pages.values():   for row, (label, cpath, values, tooltip) in enumerate(info):   ispw = cpath in _pwfields   combo = widgets[row] @@ -1001,17 +1056,23 @@
  elif currow:   combo.set_active(currow)   - def add_page(self, tab, info, path=False): + def add_page(self, label, name, info, icon=None, path=False): + # setup page   frame = gtk.VBox() - frame.set_border_width(4)   frame.show()   - vbox = self.fill_frame(frame, info) + vbox, widgets = self.fill_frame(frame, info)   if path:   self.fill_path_frame(vbox)   - label = gtk.Label(tab) - self.notebook.append_page(frame, label) + # add to notebook + pagenum = self.notebook.append_page(frame) + self.pages[name] = (pagenum, info, vbox, widgets) + + # add treeview item + pixbuf = gtklib.get_icon_pixbuf(icon, gtk.ICON_SIZE_LARGE_TOOLBAR) + self.confmodel.append((pixbuf, label, name)) +   return frame     def get_ini_config(self, cpath): @@ -1120,9 +1181,9 @@
  del self.ini['paths'][name]     # Flush changes on all pages - for vbox, info, widgets in self.pages: - for w, (label, cpath, values, tip) in enumerate(info): - newvalue = hglib.fromutf(widgets[w].child.get_text()) + for page_num, info, vbox, widgets in self.pages.values(): + for n, (label, cpath, values, tip) in enumerate(info): + newvalue = hglib.fromutf(widgets[n].child.get_text())   self.record_new_value(cpath, newvalue)     self.history.write() @@ -1142,6 +1203,6 @@
   def run(ui, *pats, **opts):   dlg = ConfigDialog(opts.get('alias') == 'repoconfig') - if opts.get('focus', ''): + if opts.get('focus'):   dlg.focus_field(opts['focus'])   return dlg