Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

init: improve the layout of init dialog

Changeset f14a7ca1d803

Parent bb75991fa45a

by Yuki KODAMA

Changes to one file · Browse files at f14a7ca1d803 Showing diff from parent bb75991fa45a Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​hginit.py Stacked
 
15
16
17
18
 
19
20
21
22
 
 
23
24
 
 
25
26
 
 
 
 
 
27
28
29
30
31
32
 
33
34
35
36
37
38
39
40
41
42
43
 
 
 
 
 
 
 
 
 
 
 
 
 
44
45
 
 
46
47
48
49
50
 
 
51
52
 
 
 
 
53
54
55
56
 
57
58
59
60
 
61
62
63
64
65
66
67
68
69
70
 
 
71
72
73
 
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
15
16
17
 
18
19
20
21
 
22
23
24
25
26
27
28
 
29
30
31
32
33
34
 
 
35
36
 
37
38
 
 
 
 
 
 
 
 
 
 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
 
 
57
58
59
60
 
61
62
63
64
65
66
67
 
68
69
 
 
 
70
71
72
 
73
74
75
76
 
 
 
77
78
79
80
81
 
85
86
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89
90
@@ -15,59 +15,67 @@
   from hggtk import dialog, gtklib   -class InitDialog(gtk.Window): +class InitDialog(gtk.Dialog):   """ Dialog to initialize a Mercurial repo """   def __init__(self, repos=[]):   """ Initialize the Dialog """ - gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + gtk.Dialog.__init__(self, title=_('Create a new repository'), + buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))   gtklib.set_tortoise_icon(self, 'menucreaterepos.ico')   gtklib.set_tortoise_keys(self) + self.set_resizable(False) + self.set_has_separator(False)   - # set dialog title and icon + # add create button + createbutton = gtk.Button(_('Create')) + createbutton.connect('clicked', self._btn_init_clicked) + self.action_area.pack_end(createbutton) +   self.cwd = os.getcwd() - title = 'hg init - %s' % hglib.toutf(self.cwd) - self.set_title(title)     # preconditioning info - self._dest_path = os.path.abspath(repos and repos[0] or os.getcwd()) + self._dest_path = os.path.abspath(repos and repos[0] or self.cwd)   - # build dialog - self._create() - - - def _create(self): - self.set_default_size(350, 130) - self.set_title(_('Create a new repository')) - - vbox = gtk.VBox() - self.add(vbox) + # copy from 'thgconfig.py' + table = gtk.Table(1, 2) + self.vbox.pack_start(table, True, True, 2) + def addrow(*widgets): + row = table.get_property('n-rows') + table.set_property('n-rows', row + 1) + if len(widgets) == 1: + col = table.get_property('n-columns') + table.attach(widgets[0], 0, col, row, row + 1, gtk.FILL|gtk.EXPAND, 0, 2, 2) + else: + for col, widget in enumerate(widgets): + flag = gtk.FILL if col == 0 else gtk.FILL|gtk.EXPAND + table.attach(widget, col, col + 1, row, row + 1, flag, 0, 4, 2)     # init destination + lbl = gtk.Label(_('Destination:')) +   srcbox = gtk.HBox() - lbl = gtk.Label(_('Destination:')) - srcbox.pack_start(lbl, False, False, 2) -   self._dest_input = gtk.Entry() + self._dest_input.set_size_request(260, -1) + self._dest_input.size_request()   self._dest_input.set_text(hglib.toutf(self._dest_path)) - srcbox.pack_start(self._dest_input, True, True) + self._dest_input.grab_focus() + self._dest_input.set_position(-1) + self._dest_input.connect('activate', self._entry_dest_activated, createbutton) + srcbox.pack_start(self._dest_input, True, True, 2)     self._btn_dest_browse = gtk.Button("...")   self._btn_dest_browse.connect('clicked', self._btn_dest_clicked) - srcbox.pack_end(self._btn_dest_browse, False, False, 5) + srcbox.pack_start(self._btn_dest_browse, False, False, 2)   - vbox.pack_start(srcbox, False, False, 2) - self._dest_input.grab_focus() - self._dest_input.set_position(-1) + addrow(lbl, srcbox)     # options - option_box = gtk.VBox()   self._opt_specialfiles = gtk.CheckButton(   _('Add special files (.hgignore, ...)'))   self._opt_oldrepoformat = gtk.CheckButton(   _('Make repo compatible with Mercurial 1.0')) - option_box.pack_start(self._opt_specialfiles, False, False) - option_box.pack_start(self._opt_oldrepoformat, False, False) - vbox.pack_start(option_box, False, False, 15) + addrow(self._opt_specialfiles) + addrow(self._opt_oldrepoformat)     # set option states   self._opt_specialfiles.set_active(True) @@ -77,30 +85,6 @@
  except:   pass   - # buttons at bottom - hbbox = gtk.HButtonBox() - hbbox.set_layout(gtk.BUTTONBOX_END) - vbox.pack_start(hbbox, False, False, 2) - - close = gtk.Button(_('Close')) - close.connect('clicked', lambda x: self.destroy()) - accelgroup = gtk.AccelGroup() - self.add_accel_group(accelgroup) - key, modifier = gtk.accelerator_parse('Escape') - close.add_accelerator('clicked', accelgroup, key, 0, - gtk.ACCEL_VISIBLE) - hbbox.add(close) - - create = gtk.Button(_('Create')) - create.connect('clicked', self._btn_init_clicked) - mod = gtklib.get_thg_modifier() - key, modifier = gtk.accelerator_parse(mod+'Return') - create.add_accelerator('clicked', accelgroup, key, modifier, - gtk.ACCEL_VISIBLE) - hbbox.add(create) - - self._dest_input.connect('activate', self._entry_dest_activated, create) -   def _entry_dest_activated(self, entry, button):   self._btn_init_clicked(button)