/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/frontend/gtk/push.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-09 17:43:44 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060809174344-61ca8dac23ebe7cb
Main window preferences (size, position) are stored.

2006-08-09  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * olive/frontend/gtk/__init__.py: simplified preference handling
    * olive/frontend/gtk/handler.py: window preferences are stored on quit

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
34
 
35
35
class OlivePush:
36
36
    """ Display Push dialog and perform the needed actions. """
37
 
    def __init__(self, gladefile, comm, dialog):
 
37
    def __init__(self, gladefile, comm):
38
38
        """ Initialize the Push dialog. """
39
39
        self.gladefile = gladefile
40
40
        self.glade = gtk.glade.XML(self.gladefile, 'window_push')
41
41
        
42
 
        # Communication object
43
42
        self.comm = comm
44
 
        # Dialog object
45
 
        self.dialog = dialog
46
43
        
47
44
        self.window = self.glade.get_widget('window_push')
48
45
        
63
60
        self.check_create = self.glade.get_widget('checkbutton_push_create')
64
61
        
65
62
        # Get stored location
66
 
        self.notbranch = False
67
 
        try:
68
 
            loc = info.get_push_location(self.comm.get_path())
69
 
        except errors.NotBranchError:
70
 
            self.notbranch = True
71
 
            return
72
 
 
73
 
        if loc is not None:
 
63
        loc = info.get_push_location(self.comm.get_path())
 
64
        if loc != '':
74
65
            self.entry_stored.set_text(loc)
75
66
    
76
67
    def display(self):
77
68
        """ Display the Push dialog. """
78
 
        if self.notbranch:
79
 
            self.dialog.error_dialog(_('Directory is not a branch'),
80
 
                                     _('You can perform this action only in a branch.'))
81
 
            self.close()
82
 
        else:
83
 
            self.window.show()
84
 
            self.width, self.height = self.window.get_size()
 
69
        self.window.show()
 
70
        self.width, self.height = self.window.get_size()
85
71
    
86
72
    def stored_toggled(self, widget):
87
73
        if widget.get_active():
109
95
            self.check_create.hide()
110
96
    
111
97
    def push(self, widget):
 
98
        from dialog import OliveDialog
 
99
        dialog = OliveDialog(self.gladefile)
 
100
        
112
101
        radio_stored = self.glade.get_widget('radiobutton_push_stored')
113
102
        radio_specific = self.glade.get_widget('radiobutton_push_specific')
114
103
        
119
108
                revs = commit.push(self.comm.get_path(),
120
109
                                   overwrite=self.check_overwrite.get_active())
121
110
            except errors.NotBranchError:
122
 
                self.dialog.error_dialog(_('Directory is not a branch'),
123
 
                                         _('You can perform this action only in a branch.'))
 
111
                dialog.error_dialog('Directory is not a branch.')
124
112
                return
125
113
            except errors.NoLocationKnown:
126
 
                self.dialog.error_dialog(_('Push location is unknown'),
127
 
                                         _('Please specify a location manually.'))
 
114
                dialog.error_dialog('No location known.')
128
115
                return
129
116
            except errors.NonExistingParent, errmsg:
130
 
                self.dialog.error_dialog(_('Non existing parent directory'),
131
 
                                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
 
117
                dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
132
118
                return
133
119
            except errors.DivergedBranchesError:
134
 
                self.dialog.error_dialog(_('Branches have been diverged'),
135
 
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
120
                dialog.error_dialog('Branches have been diverged.')
136
121
                return
137
122
            except:
138
123
                raise
139
124
        elif radio_specific.get_active():
140
125
            location = self.entry_location.get_text()
141
126
            if location == '':
142
 
                self.dialog.error_dialog(_('No location specified'),
143
 
                                         _('Please specify a location or use the default.'))
 
127
                dialog.error_dialog('No location specified.')
144
128
                return
145
129
            
146
130
            try:
149
133
                                   self.check_overwrite.get_active(),
150
134
                                   self.check_create.get_active())
151
135
            except errors.NotBranchError:
152
 
                self.dialog.error_dialog(_('Directory is not a branch'),
153
 
                                         _('You can perform this action only in a branch.'))
 
136
                dialog.error_dialog('Directory is not a branch.')
154
137
                self.comm.set_busy(self.window, False)
155
138
                return
156
139
            except errors.NonExistingParent, errmsg:
157
 
                self.dialog.error_dialog(_('Non existing parent directory'),
158
 
                                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
 
140
                dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
159
141
                self.comm.set_busy(self.window, False)
160
142
                return
161
143
            except errors.DivergedBranchesError:
162
 
                self.dialog.error_dialog(_('Branches have been diverged'),
163
 
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
144
                dialog.error_dialog('Branches have been diverged.')
164
145
                self.comm.set_busy(self.window, False)
165
146
                return
166
147
            except errors.PathPrefixNotCreated:
167
 
                self.dialog.error_dialog(_('Path prefix not created'),
168
 
                                         _("The path leading up to the specified location couldn't\nbe created."))
 
148
                dialog.error_dialog('Path prefix couldn\'t be created.')
169
149
                self.comm.set_busy(self.window, False)
170
150
                return
171
151
            except:
175
155
            pass
176
156
        
177
157
        self.close()
178
 
        self.dialog.info_dialog(_('Push successful'),
179
 
                                _('%d revision(s) pushed.') % revs)
 
158
        dialog.info_dialog('%d revision(s) pushed.' % revs)
180
159
    
181
160
    def close(self, widget=None):
182
161
        self.window.destroy()