~ubuntu-branches/ubuntu/oneiric/gquilt/oneiric

« back to all changes in this revision

Viewing changes to gquilt_gtk.py

  • Committer: Bazaar Package Importer
  • Author(s): Christine Spang
  • Date: 2007-12-03 00:37:05 UTC
  • mfrom: (3.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20071203003705-w1tzw2v9uhvv4inp
Tags: 0.20-2
* Change my maintainer e-mail address.
* Added debian/watch.
* Updated gquilt.menu to new menu policy.
* Fix .desktop file for freedesktop compliance.
* Refreshed patches to remove fuzz. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import gtk, os, pango, gquilt_utils, time
19
19
 
20
 
def _read_fs_entity_name(flag, prompt, startdir, ok_button_label):
 
20
def _read_fs_entity_name(flag, prompt, startdir, ok_button_label, sugg=""):
21
21
    dialog = gtk.FileChooserDialog(prompt, None, flag,
22
22
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, ok_button_label, gtk.RESPONSE_OK))
23
23
    dialog.set_default_response(gtk.RESPONSE_OK)
24
24
    dialog.set_position(gtk.WIN_POS_MOUSE)
 
25
    if flag == gtk.FILE_CHOOSER_ACTION_SAVE:
 
26
        dialog.set_current_name(sugg)
25
27
    if startdir != None:
26
28
        dialog.set_current_folder(startdir)
27
29
    response = dialog.run()
29
31
        res = (True, dialog.get_filename())
30
32
    elif response == gtk.RESPONSE_CANCEL:
31
33
        res = (False, None)
 
34
    else:
 
35
        res = (True, os.getcwd())
32
36
    dialog.destroy()
33
37
    return res
34
38
 
35
 
def read_new_file_name(prompt="New file ...", startdir=None, ok_button_label=gtk.STOCK_OPEN):
36
 
    return _read_fs_entity_name(gtk.FILE_CHOOSER_ACTION_SAVE, prompt, startdir, ok_button_label)
 
39
def read_new_file_name(prompt="New file ...", startdir=None, ok_button_label=gtk.STOCK_OK, sugg=""):
 
40
    return _read_fs_entity_name(gtk.FILE_CHOOSER_ACTION_SAVE, prompt, startdir, ok_button_label, sugg)
37
41
 
38
42
def read_file_name(prompt="File ...", startdir=None, ok_button_label=gtk.STOCK_OPEN):
39
43
    return _read_fs_entity_name(gtk.FILE_CHOOSER_ACTION_OPEN, prompt, startdir, ok_button_label)
81
85
 
82
86
FORCE = 1
83
87
REFRESH_AND_RETRY = 2
 
88
SKIP = 3
84
89
CANCEL = gtk.RESPONSE_CANCEL
85
90
 
86
91
class info_force_dialog(_info_dialog):
96
101
        self.destroy()
97
102
        return res == FORCE
98
103
 
 
104
class info_force_or_skip_dialog(_info_dialog):
 
105
    def __init__(self, msg=None, parent=None):
 
106
        _info_dialog.__init__(self, "FYI", parent,
 
107
                              gtk.DIALOG_DESTROY_WITH_PARENT,
 
108
                              (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
 
109
                               "_Skip", SKIP,
 
110
                               "_Force", FORCE))
 
111
        if msg != None:
 
112
            self.set_message(msg)
 
113
    def ask(self):
 
114
        res = self.run()
 
115
        self.destroy()
 
116
        return res
 
117
 
99
118
class info_refresh_dialog(_info_dialog):
100
119
    def __init__(self, msg=None, parent=None):
101
120
        _info_dialog.__init__(self, "FYI", parent,
136
155
        self.destroy()
137
156
        return res == gtk.RESPONSE_OK
138
157
 
 
158
class info_yes_no_dialog(_info_dialog):
 
159
    def __init__(self, msg=None, parent=None):
 
160
        _info_dialog.__init__(self, "FYI", parent,
 
161
                              gtk.DIALOG_DESTROY_WITH_PARENT,
 
162
                              (gtk.STOCK_NO, gtk.RESPONSE_NO,
 
163
                               gtk.STOCK_YES, gtk.RESPONSE_YES))
 
164
        if msg != None:
 
165
            self.set_message(msg)
 
166
    def ask(self):
 
167
        res = self.run()
 
168
        self.destroy()
 
169
        return res == gtk.RESPONSE_YES
 
170
 
139
171
class text_entry_dialog(gtk.Dialog):
140
172
    def __init__(self, prompt="Enter text:", parent=None):
141
173
        gtk.Dialog.__init__(self, "Text Entry", parent,
170
202
    def set_text(self, text):
171
203
        self.te.set_text(text)
172
204
 
 
205
class select_from_list_dialog(gtk.Dialog):
 
206
    def __init__(self, list=[], title="Select from list", parent=None):
 
207
        gtk.Dialog.__init__(self, title, parent,
 
208
                            gtk.DIALOG_DESTROY_WITH_PARENT,
 
209
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
 
210
                             gtk.STOCK_OK, gtk.RESPONSE_OK)
 
211
                           )
 
212
        if parent is None:
 
213
            self.set_position(gtk.WIN_POS_MOUSE)
 
214
        else:
 
215
            self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
 
216
        self.cbox = gtk.combo_box_new_text()
 
217
        for i in list:
 
218
            self.cbox.append_text(i)
 
219
        self.vbox.add(self.cbox)
 
220
        self.cbox.show()
 
221
    def make_selection(self):
 
222
        res = self.run()
 
223
        str = self.cbox.get_active_text()
 
224
        self.destroy()
 
225
        return (res == gtk.RESPONSE_OK and str is not None, str)
 
226
 
173
227
class update_dialog(gtk.Dialog):
174
228
    def __init__(self, title):
175
229
        gtk.Dialog.__init__(self, title, None,
308
362
        self._conditional_mi_list = []
309
363
    def set_tooltips(self, tooltips):
310
364
        self.tooltips = tooltips
 
365
    def _popup_ok(self):
 
366
        return True
311
367
    def _handle_button_press(self, widget, event):
312
368
        if event.type == gtk.gdk.BUTTON_PRESS:
313
369
            if event.button == 3:
 
370
                if not self._popup_ok():
 
371
                    return False
314
372
                sel_sz = self.view.get_selection().count_selected_rows()
315
373
                unique = sel_sz == 1
316
374
                selmade = sel_sz > 0
355
413
    def append_conditional_menu_item(self, label, tooltip, stock_id, action, cond, arg=None, condarg=None):
356
414
        mi = self.append_menu_item(label, tooltip, stock_id, action, arg)
357
415
        self._conditional_mi_list.append((mi, cond, condarg))
 
416
    def _show_busy(self):
 
417
        self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
 
418
        while gtk.events_pending():
 
419
            gtk.main_iteration()
 
420
    def _unshow_busy(self):
 
421
        self.window.set_cursor(None)
358
422
 
359
423
class file_tree(scrolled_treeview_with_popup):
360
424
    def __init__(self, view_title="Files", tooltips=None, frame_title=None):
367
431
        tvcolumn.set_attributes(text_cell, text=0, style=2, foreground=3)
368
432
        tvcolumn.set_attributes(icon_cell, stock_id=4)
369
433
        self.view.append_column(tvcolumn)
 
434
        self.console = None
 
435
    def set_console(self, console):
 
436
        self.console = console
370
437
    def _get_selected_files_cb(self, store, path, iter, list):
371
438
        list.append(store.fs_path(iter))
372
439
    def get_selected_files(self):
379
446
        store = view.get_model()
380
447
        ci = store.iter_children(iter)
381
448
        if store.get_value(ci, 0) is None:
 
449
            # This was the place holder row put in unpopulated directories
 
450
            # to make them display properly so we need to remove it
382
451
            store.remove(ci)
383
452
            self._populate(self.store.fs_path(iter), iter)
384
453
        else: