author | Steve Borho <steve@borho.org> |
Sun, 20 Jan 2008 21:58:12 -0600 | |
changeset 782 | 8693e12e923e |
parent 759 | ec14d2ae0b79 |
child 790 | dff3ff17be57 |
permissions | -rw-r--r-- |
594
5a5f8058a65a
hggtk/gdialog: revise comments
TK Soh <teekaysoh@yahoo.com>
parents:
537
diff
changeset
|
1 |
# gdialog.py - base dialog for gtools |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
2 |
# |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
3 |
# Copyright 2007 Brad Schick, brad at gmail . com |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
4 |
# |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
7 |
# |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
8 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
9 |
import mercurial.demandimport; mercurial.demandimport.disable() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
10 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
11 |
import os |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
12 |
import threading |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
13 |
import StringIO |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
14 |
import sys |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
15 |
import shutil |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
16 |
import tempfile |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
17 |
import datetime |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
18 |
import cPickle |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
19 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
20 |
import pygtk |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
21 |
pygtk.require('2.0') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
22 |
import gtk |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
23 |
import gobject |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
24 |
import pango |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
25 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
26 |
from mercurial.i18n import _ |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
27 |
from mercurial.node import * |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
28 |
from mercurial import cmdutil, util, ui, hg, commands, patch |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
29 |
from hgext import extdiff |
466 | 30 |
from shlib import shell_notify, set_tortoise_icon |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
31 |
from thgconfig import ConfigDialog |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
32 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
33 |
class SimpleMessage(gtk.MessageDialog): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
34 |
def run(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
35 |
response = gtk.MessageDialog.run(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
36 |
self.destroy() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
37 |
return response |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
38 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
39 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
40 |
class Prompt(SimpleMessage): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
41 |
def __init__(self, title, message, parent): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
42 |
gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
43 |
gtk.BUTTONS_CLOSE) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
44 |
self.set_title(title) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
45 |
self.set_markup('<b>' + message + '</b>') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
46 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
47 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
48 |
class Confirm(SimpleMessage): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
49 |
"""Dialog returns gtk.RESPONSE_YES or gtk.RESPONSE_NO |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
50 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
51 |
def __init__(self, title, files, parent, primary=None): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
52 |
gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
53 |
gtk.BUTTONS_YES_NO) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
54 |
self.set_title('Confirm ' + title) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
55 |
if primary is None: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
56 |
primary = title + ' file' + ((len(files) > 1 and 's') or '') + '?' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
57 |
primary = '<b>' + primary + '</b>' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
58 |
self.set_markup(primary) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
59 |
message = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
60 |
for i, file in enumerate(files): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
61 |
message += ' ' + file + '\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
62 |
if i == 9: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
63 |
message += ' ...\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
64 |
break |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
65 |
self.format_secondary_text(message) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
66 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
67 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
68 |
class GDialog(gtk.Window): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
69 |
"""GTK+ based dialog for displaying mercurial information |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
70 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
71 |
The following methods are meant to be overridden by subclasses. At this |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
72 |
point GCommit is really the only intended subclass. |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
73 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
74 |
parse_opts(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
75 |
get_title(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
76 |
get_minsize(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
77 |
get_defsize(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
78 |
get_tbbuttons(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
79 |
get_body(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
80 |
get_extras(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
81 |
prepare_display(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
82 |
should_live(self, widget, event) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
83 |
save_settings(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
84 |
load_settings(self, settings) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
85 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
86 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
87 |
# "Constants" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
88 |
settings_version = 1 |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
89 |
|
537
fafc720c937e
hggtk: pass cwd to all gtools dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
474
diff
changeset
|
90 |
def __init__(self, ui, repo, cwd, pats, opts, main): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
91 |
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) |
537
fafc720c937e
hggtk: pass cwd to all gtools dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
474
diff
changeset
|
92 |
self.cwd = cwd |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
93 |
self.ui = ui |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
94 |
self.ui.interactive=False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
95 |
self.repo = repo |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
96 |
self.pats = pats |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
97 |
self.opts = opts |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
98 |
self.main = main |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
99 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
100 |
### Following methods are meant to be overridden by subclasses ### |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
101 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
102 |
def parse_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
103 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
104 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
105 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
106 |
def get_title(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
107 |
return '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
108 |
|
466 | 109 |
def get_icon(self): |
110 |
return '' |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
111 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
112 |
def get_minsize(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
113 |
return (395, 200) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
114 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
115 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
116 |
def get_defsize(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
117 |
return self._setting_defsize |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
118 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
119 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
120 |
def get_tbbuttons(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
121 |
return [] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
122 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
123 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
124 |
def get_body(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
125 |
return None |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
126 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
127 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
128 |
def get_extras(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
129 |
return None |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
130 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
131 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
132 |
def prepare_display(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
133 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
134 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
135 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
136 |
def should_live(self, widget=None, event=None): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
137 |
return False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
138 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
139 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
140 |
def save_settings(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
141 |
rect = self.get_allocation() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
142 |
return {'gdialog': (rect.width, rect.height)} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
143 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
144 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
145 |
def load_settings(self, settings): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
146 |
if settings: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
147 |
self._setting_defsize = settings['gdialog'] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
148 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
149 |
self._setting_defsize = (678, 585) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
150 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
151 |
### End of overridable methods ### |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
152 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
153 |
def display(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
154 |
self._parse_config() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
155 |
self._load_settings() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
156 |
self._setup_gtk() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
157 |
self._parse_opts() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
158 |
self.prepare_display() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
159 |
self.show_all() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
160 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
161 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
162 |
def test_opt(self, opt): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
163 |
return opt in self.opts and self.opts[opt] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
164 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
165 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
166 |
def _parse_config(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
167 |
# defaults |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
168 |
self.fontcomment = 'courier 10' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
169 |
self.fontdiff = 'courier 10' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
170 |
self.fontlist = 'courier 9' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
171 |
self.diffopts = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
172 |
self.diffcmd = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
173 |
self.diffbottom = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
174 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
175 |
for attr, setting in self.ui.configitems('gtools'): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
176 |
if setting : setattr(self, attr, setting) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
177 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
178 |
if not self.diffcmd : |
731
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
179 |
# default to tortoisehg's configuration |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
180 |
vdiff = self.ui.config('tortoisehg', 'vdiff') |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
181 |
if vdiff: |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
182 |
self.diffcmd = self.ui.config('extdiff', 'cmd.'+vdiff) |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
183 |
else: |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
184 |
self.diffcmd = 'diff' |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
185 |
if not self.diffopts : |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
186 |
self.diffopts = '-Npru' |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
187 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
188 |
if not self.diffbottom or self.diffbottom.lower() == 'false' or self.diffbottom == '0': |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
189 |
self.diffbottom = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
190 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
191 |
self.diffbottom = True |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
192 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
193 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
194 |
def _parse_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
195 |
# Remove dry_run since Hg only honors it for certain commands |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
196 |
self.opts['dry_run'] = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
197 |
self.opts['force_editor'] = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
198 |
self.parse_opts() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
199 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
200 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
201 |
def merge_opts(self, defaults, mergelist=()): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
202 |
"""Merge default options with the specified local options and globals. |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
203 |
Results is defaults + merglist + globals |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
204 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
205 |
newopts = {} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
206 |
for hgopt in defaults: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
207 |
newopts[hgopt[1].replace('-', '_')] = hgopt[2] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
208 |
for mergeopt in mergelist: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
209 |
newopts[mergeopt] = self.opts[mergeopt] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
210 |
newopts.update(self.global_opts()) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
211 |
return newopts |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
212 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
213 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
214 |
def global_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
215 |
globals = {} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
216 |
hgglobals = [opt[1].replace('-', '_') for opt in commands.globalopts if opt[1] != 'help'] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
217 |
for key in self.opts: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
218 |
if key in hgglobals : |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
219 |
globals[key] = self.opts[key] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
220 |
return globals |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
221 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
222 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
223 |
def count_revs(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
224 |
cnt = 0 |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
225 |
if self.test_opt('rev'): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
226 |
for rev in self.opts['rev']: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
227 |
cnt += len(rev.split(cmdutil.revrangesep, 1)) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
228 |
return cnt |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
229 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
230 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
231 |
def make_toolbutton(self, stock, label, handler, |
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
232 |
userdata=None, menu=None, tip=None): |
431
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
233 |
if menu: |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
234 |
tbutton = gtk.MenuToolButton(stock) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
235 |
tbutton.set_menu(menu) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
236 |
else: |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
237 |
tbutton = gtk.ToolButton(stock) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
238 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
239 |
if tip: |
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
240 |
tbutton.set_tooltip(self.tooltips, tip) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
241 |
tbutton.set_use_underline(True) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
242 |
tbutton.set_label(label) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
243 |
tbutton.connect('clicked', handler, userdata) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
244 |
return tbutton |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
245 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
246 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
247 |
def _setup_gtk(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
248 |
self.set_title(self.get_title()) |
466 | 249 |
set_tortoise_icon(self, self.get_icon()) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
250 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
251 |
# Minimum size |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
252 |
minx, miny = self.get_minsize() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
253 |
self.set_size_request(minx, miny) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
254 |
# Initial size |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
255 |
defx, defy = self.get_defsize() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
256 |
self.set_default_size(defx, defy) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
257 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
258 |
vbox = gtk.VBox(False, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
259 |
self.add(vbox) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
260 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
261 |
self.tooltips = gtk.Tooltips() |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
262 |
toolbar = gtk.Toolbar() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
263 |
tbuttons = self.get_tbbuttons() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
264 |
for tbutton in tbuttons: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
265 |
toolbar.insert(tbutton, -1) |
759
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
266 |
sep = gtk.SeparatorToolItem() |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
267 |
sep.set_expand(True) |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
268 |
sep.set_draw(False) |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
269 |
toolbar.insert(sep, -1) |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
270 |
button = self.make_toolbutton(gtk.STOCK_CLOSE, 'Close', |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
271 |
self._quit_clicked, tip='Close Application') |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
272 |
toolbar.insert(button, -1) |
782
8693e12e923e
hggtk/history: add changeset toolbar buttons to history toolbar
Steve Borho <steve@borho.org>
parents:
759
diff
changeset
|
273 |
self.toolbar = toolbar |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
274 |
vbox.pack_start(toolbar, False, False, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
275 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
276 |
# Subclass returns the main body |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
277 |
body = self.get_body() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
278 |
vbox.pack_start(body, True, True, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
279 |
|
759
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
280 |
# Subclass provides extra stuff in bottom hbox |
749
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
281 |
extras = self.get_extras() |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
282 |
if extras: |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
283 |
hbox = gtk.HBox(False, 0) |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
284 |
hbox.set_border_width(6) |
759
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
285 |
hbox.pack_start(extras, False, False) |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
286 |
# Hack! this prevents mysterious silent crashes. |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
287 |
hbox.pack_start(gtk.Label(''), True, True) |
749
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
288 |
vbox.pack_end(hbox, False, False, 0) |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
289 |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
290 |
self.connect('destroy', self._destroying) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
291 |
self.connect('delete_event', self.should_live) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
292 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
293 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
294 |
|
749
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
295 |
def _quit_clicked(self, button, data=None): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
296 |
if not self.should_live(): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
297 |
self.destroy() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
298 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
299 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
300 |
def _destroying(self, gtkobj): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
301 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
302 |
file = None |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
303 |
settings = self.save_settings() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
304 |
versioned = (GDialog.settings_version, settings) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
305 |
dirname = os.path.join(os.path.expanduser('~'), '.hgext/gtools') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
306 |
filename = os.path.join(dirname, self.__class__.__name__) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
307 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
308 |
if not os.path.exists(dirname): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
309 |
os.makedirs(dirname) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
310 |
file = open(filename, 'wb') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
311 |
cPickle.dump(versioned, file, cPickle.HIGHEST_PROTOCOL) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
312 |
except (IOError, cPickle.PickleError): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
313 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
314 |
finally: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
315 |
if file: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
316 |
file.close() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
317 |
if self.main: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
318 |
gtk.main_quit() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
319 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
320 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
321 |
def _load_settings(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
322 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
323 |
file = None |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
324 |
settings = None |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
325 |
dirname = os.path.join(os.path.expanduser('~'), '.hgext/gtools') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
326 |
filename = os.path.join(dirname, self.__class__.__name__) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
327 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
328 |
file = open(filename, 'rb') |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
329 |
versioned = cPickle.load(file) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
330 |
if versioned[0] == GDialog.settings_version: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
331 |
settings = versioned[1] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
332 |
except (IOError, cPickle.PickleError), inst: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
333 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
334 |
finally: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
335 |
if file: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
336 |
file.close() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
337 |
self.load_settings(settings) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
338 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
339 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
340 |
def restore_cwd(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
341 |
# extdiff works on relative directories to avoid showing temp paths. Since another thread |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
342 |
# could be running that changed cwd, we always need to set it back. This is a race condition |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
343 |
# but not likely to be a problem. |
537
fafc720c937e
hggtk: pass cwd to all gtools dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
474
diff
changeset
|
344 |
os.chdir(self.repo.root) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
345 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
346 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
347 |
def _hg_call_wrapper(self, title, command, showoutput=True): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
348 |
"""Run the specified command and display any resulting aborts, messages, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
349 |
and errors |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
350 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
351 |
self.restore_cwd() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
352 |
textout = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
353 |
saved = sys.stderr |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
354 |
errors = StringIO.StringIO() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
355 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
356 |
sys.stderr = errors |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
357 |
self.ui.pushbuffer() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
358 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
359 |
command() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
360 |
except util.Abort, inst: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
361 |
Prompt(title + ' Aborted', str(inst), self).run() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
362 |
return False, '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
363 |
finally: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
364 |
sys.stderr = saved |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
365 |
textout = self.ui.popbuffer() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
366 |
prompttext = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
367 |
if showoutput: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
368 |
prompttext = textout + '\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
369 |
prompttext += errors.getvalue() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
370 |
errors.close() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
371 |
if len(prompttext) > 1: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
372 |
Prompt(title + ' Messages and Errors', prompttext, self).run() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
373 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
374 |
return True, textout |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
375 |
|
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
376 |
def _diff_file(self, stat, file): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
377 |
def dodiff(): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
378 |
self.restore_cwd() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
379 |
extdiff.dodiff(self.ui, self.repo, self.diffcmd, [self.diffopts], |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
380 |
[file], self.opts) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
381 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
382 |
if self.diffcmd == 'diff': |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
383 |
Prompt('No visual diff configured', |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
384 |
'Please select a visual diff application.', self).run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
385 |
dlg = ConfigDialog(self.repo.root, False) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
386 |
dlg.show_all() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
387 |
dlg.focus_field('tortoisehg.vdiff') |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
388 |
dlg.run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
389 |
dlg.hide() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
390 |
self.ui = ui.ui() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
391 |
self._parse_config() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
392 |
return |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
393 |
thread = threading.Thread(target=dodiff, name='diff:'+file) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
394 |
thread.setDaemon(True) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
395 |
thread.start() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
396 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
397 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
398 |
def _view_file(self, stat, file, force_left=False): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
399 |
def doedit(): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
400 |
pathroot = self.repo.root |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
401 |
tmproot = None |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
402 |
copynode = None |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
403 |
try: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
404 |
# if we aren't looking at the wc, copy the node... |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
405 |
if stat in 'R!' or force_left: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
406 |
copynode = self._node1 |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
407 |
elif self._node2: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
408 |
copynode = self._node2 |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
409 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
410 |
if copynode: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
411 |
tmproot = tempfile.mkdtemp(prefix='gtools.') |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
412 |
copydir = extdiff.snapshot_node(self.ui, self.repo, |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
413 |
[util.pconvert(file)], copynode, tmproot) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
414 |
pathroot = os.path.join(tmproot, copydir) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
415 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
416 |
file_path = os.path.join(pathroot, file) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
417 |
util.system("%s \"%s\"" % (editor, file_path), |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
418 |
environ={'HGUSER': self.ui.username()}, |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
419 |
onerr=util.Abort, errprefix=_('edit failed')) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
420 |
finally: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
421 |
if tmproot: |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
422 |
shutil.rmtree(tmproot) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
423 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
424 |
editor = (self.ui.config('tortoisehg', 'editor') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
425 |
self.ui.config('gtools', 'editor') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
426 |
os.environ.get('HGEDITOR') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
427 |
self.ui.config('ui', 'editor') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
428 |
os.environ.get('EDITOR', 'vi')) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
429 |
if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
430 |
Prompt('No visual editor configured', |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
431 |
'Please configure a visual editor.', self).run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
432 |
dlg = ConfigDialog(self.repo.root, False) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
433 |
dlg.show_all() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
434 |
dlg.focus_field('tortoisehg.editor') |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
435 |
dlg.run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
436 |
dlg.hide() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
437 |
self.ui = ui.ui() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
438 |
self._parse_config() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
439 |
return |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
440 |
thread = threading.Thread(target=doedit, name='edit:'+file) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
441 |
thread.setDaemon(True) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
442 |
thread.start() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
443 |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
444 |
class NativeSaveFileDialogWrapper: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
445 |
"""Wrap the windows file dialog, or display default gtk dialog if that isn't available""" |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
446 |
def __init__(self, InitialDir = None, Title = "Save File", |
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
447 |
Filter = {"All files": "*.*"}, FilterIndex = 1, FileName = ''): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
448 |
import os.path |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
449 |
if InitialDir == None: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
450 |
InitialDir = os.path.expanduser("~") |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
451 |
self.InitialDir = InitialDir |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
452 |
self.FileName = FileName |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
453 |
self.Title = Title |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
454 |
self.Filter = Filter |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
455 |
self.FilterIndex = FilterIndex |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
456 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
457 |
def run(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
458 |
"""run the file dialog, either return a file name, or False if the user aborted the dialog""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
459 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
460 |
import win32gui |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
461 |
if self.tortoiseHgIsInstalled(): #as of 20071021, the file dialog will hang if the tortoiseHg shell extension is installed. I have no clue why, yet - Tyberius Prime |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
462 |
return self.runCompatible() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
463 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
464 |
return self.runWindows() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
465 |
except ImportError: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
466 |
return self.runCompatible() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
467 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
468 |
def tortoiseHgIsInstalled(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
469 |
import _winreg |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
470 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
471 |
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,r"Software\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\Changed") |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
472 |
if hkey: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
473 |
cls = _winreg.QueryValue(hkey,"") |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
474 |
return cls == "{102C6A24-5F38-4186-B64A-237011809FAB}" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
475 |
except WindowsError: #reg key not found |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
476 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
477 |
return False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
478 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
479 |
def runWindows(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
480 |
import win32gui, win32con, os |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
481 |
filter = "" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
482 |
for name, pattern in self.Filter.items(): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
483 |
filter += name + "\0" + pattern + "\0" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
484 |
customfilter = "\0" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
485 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
486 |
fname, customfilter, flags=win32gui.GetSaveFileNameW( |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
487 |
InitialDir=self.InitialDir, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
488 |
Flags=win32con.OFN_EXPLORER, |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
489 |
File=self.FileName, |
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
490 |
DefExt='py', |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
491 |
Title=self.Title, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
492 |
Filter="", |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
493 |
CustomFilter="", |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
494 |
FilterIndex=1) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
495 |
if fname: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
496 |
return fname |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
497 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
498 |
return False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
499 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
500 |
def runCompatible(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
501 |
file_save =gtk.FileChooserDialog(self.Title,None, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
502 |
gtk.FILE_CHOOSER_ACTION_SAVE |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
503 |
, (gtk.STOCK_CANCEL |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
504 |
, gtk.RESPONSE_CANCEL |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
505 |
, gtk.STOCK_SAVE |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
506 |
, gtk.RESPONSE_OK)) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
507 |
file_save.set_default_response(gtk.RESPONSE_OK) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
508 |
file_save.set_current_folder(self.InitialDir) |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
509 |
file_save.set_current_name(self.FileName) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
510 |
for name, pattern in self.Filter.items(): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
511 |
fi = gtk.FileFilter() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
512 |
fi.set_name(name) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
513 |
fi.add_pattern(pattern) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
514 |
file_save.add_filter(fi) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
515 |
if file_save.run() == gtk.RESPONSE_OK: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
516 |
result = file_save.get_filename(); |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
517 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
518 |
result = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
519 |
file_save.destroy() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
520 |
return result |