author | Germán Póo-Caamaño <gpoo@calcifer.org> |
Mon, 21 Jul 2008 11:51:12 -0400 | |
changeset 1182 | cbe418752174 |
parent 1166 | 94abe456eaab |
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 |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
30 |
from shlib import shell_notify, set_tortoise_icon, Settings |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
31 |
from thgconfig import ConfigDialog |
1119
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
32 |
from gtklib import MessageDialog |
1157
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
33 |
from hglib import toutf |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
34 |
|
1119
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
35 |
|
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
36 |
class SimpleMessage(MessageDialog): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
37 |
def run(self): |
1119
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
38 |
response = MessageDialog.run(self) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
39 |
self.destroy() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
40 |
return response |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
41 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
42 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
43 |
class Prompt(SimpleMessage): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
44 |
def __init__(self, title, message, parent): |
1119
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
45 |
SimpleMessage.__init__(self, parent, gtk.DIALOG_MODAL, |
790
dff3ff17be57
hggtk/gdialog: whitespace cleanups
Steve Borho <steve@borho.org>
parents:
782
diff
changeset
|
46 |
gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE) |
1157
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
47 |
self.set_title(toutf(title)) |
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
48 |
self.set_markup('<b>' + toutf(message) + '</b>') |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
49 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
50 |
class Confirm(SimpleMessage): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
51 |
"""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
|
52 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
53 |
def __init__(self, title, files, parent, primary=None): |
1119
f01671e11984
hggtk: add home grown MessageDialog class
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
54 |
SimpleMessage.__init__(self, parent, gtk.DIALOG_MODAL, |
790
dff3ff17be57
hggtk/gdialog: whitespace cleanups
Steve Borho <steve@borho.org>
parents:
782
diff
changeset
|
55 |
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO) |
1157
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
56 |
self.set_title(toutf('Confirm ' + title)) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
57 |
if primary is None: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
58 |
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
|
59 |
primary = '<b>' + primary + '</b>' |
1157
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
60 |
self.set_markup(toutf(primary)) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
61 |
message = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
62 |
for i, file in enumerate(files): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
63 |
message += ' ' + file + '\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
64 |
if i == 9: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
65 |
message += ' ...\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
66 |
break |
1157
7946187e1b6b
gdialog: fix UTF-8 error in message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1133
diff
changeset
|
67 |
self.format_secondary_text(toutf(message)) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
68 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
69 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
70 |
class GDialog(gtk.Window): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
71 |
"""GTK+ based dialog for displaying mercurial information |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
72 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
73 |
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
|
74 |
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
|
75 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
76 |
parse_opts(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
77 |
get_title(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
78 |
get_minsize(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
79 |
get_defsize(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
80 |
get_tbbuttons(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
81 |
get_body(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
82 |
get_extras(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
83 |
prepare_display(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
84 |
should_live(self, widget, event) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
85 |
save_settings(self) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
86 |
load_settings(self, settings) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
87 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
88 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
89 |
# "Constants" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
90 |
settings_version = 1 |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
91 |
|
537
fafc720c937e
hggtk: pass cwd to all gtools dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
474
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
self.cwd = cwd |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
95 |
self.ui = ui |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
96 |
self.ui.interactive=False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
97 |
self.repo = repo |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
98 |
self.pats = pats |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
99 |
self.opts = opts |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
100 |
self.main = main |
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
101 |
self.tmproot = None |
1125
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
102 |
self.toolbuttons = {} |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
103 |
self.settings = Settings(self.__class__.__name__) |
423
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 |
### 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
|
106 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
107 |
def parse_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
108 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
109 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
110 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
111 |
def get_title(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
112 |
return '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
113 |
|
466 | 114 |
def get_icon(self): |
115 |
return '' |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
116 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
117 |
def get_minsize(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
118 |
return (395, 200) |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
121 |
def get_defsize(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
122 |
return self._setting_defsize |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
125 |
def get_tbbuttons(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
126 |
return [] |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
129 |
def get_body(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
130 |
return None |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
133 |
def get_extras(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
134 |
return None |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
137 |
def prepare_display(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
138 |
pass |
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
141 |
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
|
142 |
return False |
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 save_settings(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
146 |
rect = self.get_allocation() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
147 |
return {'gdialog': (rect.width, rect.height)} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
148 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
149 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
150 |
def load_settings(self, settings): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
151 |
if settings: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
152 |
self._setting_defsize = settings['gdialog'] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
153 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
154 |
self._setting_defsize = (678, 585) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
155 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
156 |
### End of overridable methods ### |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
157 |
|
791
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
158 |
def display(self, opengui=True): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
159 |
self._parse_config() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
160 |
self._load_settings() |
791
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
161 |
if opengui: |
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
162 |
self._setup_gtk() |
812
0429fbeef14d
hggtk/gdialog: restore order of display() method
Steve Borho <steve@borho.org>
parents:
806
diff
changeset
|
163 |
self._parse_opts() |
791
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
164 |
self.prepare_display() |
796
774e1f05e939
hggtk/gdialog: prevent extra GChange window
Steve Borho <steve@borho.org>
parents:
791
diff
changeset
|
165 |
self.show_all() |
791
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
166 |
else: |
812
0429fbeef14d
hggtk/gdialog: restore order of display() method
Steve Borho <steve@borho.org>
parents:
806
diff
changeset
|
167 |
self._parse_opts() |
791
15c081945e56
hggtk/history: cleaner integration of changeset viewer
Steve Borho <steve@borho.org>
parents:
790
diff
changeset
|
168 |
self.tooltips = gtk.Tooltips() |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
169 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
170 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
171 |
def test_opt(self, opt): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
172 |
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
|
173 |
|
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 |
def _parse_config(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
176 |
# defaults |
1133
66736cfd76fe
hggtk/status: fix display error of multi-byte text and filenames
TK Soh <teekaysoh@yahoo.com>
parents:
1125
diff
changeset
|
177 |
self.fontcomment = 'monospace 10' |
66736cfd76fe
hggtk/status: fix display error of multi-byte text and filenames
TK Soh <teekaysoh@yahoo.com>
parents:
1125
diff
changeset
|
178 |
self.fontdiff = 'monospace 10' |
66736cfd76fe
hggtk/status: fix display error of multi-byte text and filenames
TK Soh <teekaysoh@yahoo.com>
parents:
1125
diff
changeset
|
179 |
self.fontlist = 'monospace 9' |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
180 |
self.diffopts = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
181 |
self.diffcmd = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
182 |
self.diffbottom = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
183 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
184 |
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
|
185 |
if setting : setattr(self, attr, setting) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
186 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
187 |
if not self.diffcmd : |
731
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
188 |
# default to tortoisehg's configuration |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
189 |
vdiff = self.ui.config('tortoisehg', 'vdiff') |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
190 |
if vdiff: |
1166
94abe456eaab
hggtk/gdialog: handle empty cmd.differ entries in hgrc like hg does
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
1157
diff
changeset
|
191 |
self.diffcmd = self.ui.config('extdiff', 'cmd.'+vdiff) or vdiff |
731
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
192 |
else: |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
193 |
self.diffcmd = 'diff' |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
194 |
if not self.diffopts : |
ec3d891212f7
hggtk/gdialog: better default applications for diff, edit
Steve Borho <steve@borho.org>
parents:
723
diff
changeset
|
195 |
self.diffopts = '-Npru' |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
196 |
|
790
dff3ff17be57
hggtk/gdialog: whitespace cleanups
Steve Borho <steve@borho.org>
parents:
782
diff
changeset
|
197 |
if not self.diffbottom: |
dff3ff17be57
hggtk/gdialog: whitespace cleanups
Steve Borho <steve@borho.org>
parents:
782
diff
changeset
|
198 |
self.diffbottom = False |
dff3ff17be57
hggtk/gdialog: whitespace cleanups
Steve Borho <steve@borho.org>
parents:
782
diff
changeset
|
199 |
elif self.diffbottom.lower() == 'false' or self.diffbottom == '0': |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
200 |
self.diffbottom = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
201 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
202 |
self.diffbottom = True |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
203 |
|
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 |
def _parse_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
206 |
# 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
|
207 |
self.opts['dry_run'] = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
208 |
self.opts['force_editor'] = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
209 |
self.parse_opts() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
210 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
211 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
212 |
def merge_opts(self, defaults, mergelist=()): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
213 |
"""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
|
214 |
Results is defaults + merglist + globals |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
215 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
216 |
newopts = {} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
217 |
for hgopt in defaults: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
218 |
newopts[hgopt[1].replace('-', '_')] = hgopt[2] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
219 |
for mergeopt in mergelist: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
220 |
newopts[mergeopt] = self.opts[mergeopt] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
221 |
newopts.update(self.global_opts()) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
222 |
return newopts |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
223 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
224 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
225 |
def global_opts(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
226 |
globals = {} |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
227 |
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
|
228 |
for key in self.opts: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
229 |
if key in hgglobals : |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
230 |
globals[key] = self.opts[key] |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
231 |
return globals |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
232 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
233 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
234 |
def count_revs(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
235 |
cnt = 0 |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
236 |
if self.test_opt('rev'): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
237 |
for rev in self.opts['rev']: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
238 |
cnt += len(rev.split(cmdutil.revrangesep, 1)) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
239 |
return cnt |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
240 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
241 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
242 |
def make_toolbutton(self, stock, label, handler, |
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
243 |
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
|
244 |
if menu: |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
245 |
tbutton = gtk.MenuToolButton(stock) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
246 |
tbutton.set_menu(menu) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
247 |
else: |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
248 |
tbutton = gtk.ToolButton(stock) |
be66d429c526
hggtk/gdialog: add support for creating tool buttons with menu
TK Soh <teekaysoh@yahoo.com>
parents:
423
diff
changeset
|
249 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
250 |
if tip: |
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
251 |
tbutton.set_tooltip(self.tooltips, tip) |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
252 |
tbutton.set_use_underline(True) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
253 |
tbutton.set_label(label) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
254 |
tbutton.connect('clicked', handler, userdata) |
1125
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
255 |
self.toolbuttons[label] = tbutton |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
256 |
return tbutton |
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 |
|
1125
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
259 |
def get_toolbutton(self, label): |
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
260 |
return self.toolbuttons[label] |
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
261 |
|
604dc351ce76
hggtk/commit: disable some tool buttons if repo is merging
TK Soh <teekaysoh@yahoo.com>
parents:
1119
diff
changeset
|
262 |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
263 |
def _setup_gtk(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
264 |
self.set_title(self.get_title()) |
466 | 265 |
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
|
266 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
267 |
# Minimum size |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
268 |
minx, miny = self.get_minsize() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
269 |
self.set_size_request(minx, miny) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
270 |
# Initial size |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
271 |
defx, defy = self.get_defsize() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
272 |
self.set_default_size(defx, defy) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
273 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
274 |
vbox = gtk.VBox(False, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
275 |
self.add(vbox) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
276 |
|
723
b0ab241a5f1c
hggtk: integrate tooltips into GStatus class
Steve Borho <steve@borho.org>
parents:
594
diff
changeset
|
277 |
self.tooltips = gtk.Tooltips() |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
278 |
toolbar = gtk.Toolbar() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
279 |
tbuttons = self.get_tbbuttons() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
280 |
for tbutton in tbuttons: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
281 |
toolbar.insert(tbutton, -1) |
782
8693e12e923e
hggtk/history: add changeset toolbar buttons to history toolbar
Steve Borho <steve@borho.org>
parents:
759
diff
changeset
|
282 |
self.toolbar = toolbar |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
283 |
vbox.pack_start(toolbar, False, False, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
284 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
285 |
# Subclass returns the main body |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
286 |
body = self.get_body() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
287 |
vbox.pack_start(body, True, True, 0) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
288 |
|
759
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
289 |
# 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
|
290 |
extras = self.get_extras() |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
291 |
if extras: |
f929007e3ee9
hggtk/gdialog: move close button to right edge of toolbar
Steve Borho <steve@borho.org>
parents:
731
diff
changeset
|
292 |
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
|
293 |
hbox.set_border_width(6) |
759
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
294 |
hbox.pack_start(extras, False, False) |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
295 |
# Hack! this prevents mysterious silent crashes. |
ec14d2ae0b79
hggtk/gdialog: unconditionally move close button to toolbar
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
296 |
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
|
297 |
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
|
298 |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
299 |
self.connect('destroy', self._destroying) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
300 |
self.connect('delete_event', self.should_live) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
301 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
302 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
303 |
def _destroying(self, gtkobj): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
304 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
305 |
settings = self.save_settings() |
1075
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1061
diff
changeset
|
306 |
self.settings.set_value('settings_version', GDialog.settings_version) |
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1061
diff
changeset
|
307 |
self.settings.set_value('dialogs', settings) |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
308 |
self.settings.write() |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
309 |
finally: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
310 |
if self.main: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
311 |
gtk.main_quit() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
312 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
313 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
314 |
def _load_settings(self): |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
315 |
settings = {} |
1075
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1061
diff
changeset
|
316 |
version = self.settings.get_value('settings_version', None) |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
317 |
if version == GDialog.settings_version: |
1075
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1061
diff
changeset
|
318 |
settings = self.settings.get_value('dialogs', {}) |
1061
15d08463ac53
hggtk/gdialog: adopt hggtk's native settings management
TK Soh <teekaysoh@yahoo.com>
parents:
1040
diff
changeset
|
319 |
self.load_settings(settings) |
423
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 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
322 |
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
|
323 |
"""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
|
324 |
and errors |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
325 |
""" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
326 |
textout = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
327 |
saved = sys.stderr |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
328 |
errors = StringIO.StringIO() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
329 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
330 |
sys.stderr = errors |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
331 |
self.ui.pushbuffer() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
332 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
333 |
command() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
334 |
except util.Abort, inst: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
335 |
Prompt(title + ' Aborted', str(inst), self).run() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
336 |
return False, '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
337 |
finally: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
338 |
sys.stderr = saved |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
339 |
textout = self.ui.popbuffer() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
340 |
prompttext = '' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
341 |
if showoutput: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
342 |
prompttext = textout + '\n' |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
343 |
prompttext += errors.getvalue() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
344 |
errors.close() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
345 |
if len(prompttext) > 1: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
346 |
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
|
347 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
348 |
return True, textout |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
349 |
|
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
350 |
def _diff_file(self, stat, file): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
351 |
def dodiff(): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
352 |
extdiff.dodiff(self.ui, self.repo, self.diffcmd, [self.diffopts], |
1040
23a57e67af3d
hggtk: remove chdir hack in commit and status dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1022
diff
changeset
|
353 |
[self.repo.wjoin(file)], self.opts) |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
354 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
355 |
if self.diffcmd == 'diff': |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
356 |
Prompt('No visual diff configured', |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
357 |
'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
|
358 |
dlg = ConfigDialog(self.repo.root, False) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
359 |
dlg.show_all() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
360 |
dlg.focus_field('tortoisehg.vdiff') |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
361 |
dlg.run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
362 |
dlg.hide() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
363 |
self.ui = ui.ui() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
364 |
self._parse_config() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
365 |
return |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
366 |
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
|
367 |
thread.setDaemon(True) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
368 |
thread.start() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
369 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
370 |
|
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
371 |
def _view_file(self, stat, file, force_left=False): |
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
372 |
import atexit |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
373 |
|
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
374 |
def cleanup(): |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
375 |
shutil.rmtree(self.tmproot) |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
376 |
|
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
377 |
if not self.tmproot: |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
378 |
self.tmproot = tempfile.mkdtemp(prefix='gtools.') |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
379 |
atexit.register(cleanup) |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
380 |
|
893
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
381 |
def snapshot_node(ui, repo, files, node, tmproot): |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
382 |
''' |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
383 |
snapshot files as of some revision |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
384 |
(adapted from Extdiff extension) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
385 |
''' |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
386 |
mf = repo.changectx(node).manifest() |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
387 |
dirname = os.path.basename(repo.root) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
388 |
if dirname == "": |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
389 |
dirname = "root" |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
390 |
dirname = '%s.%s' % (dirname, short(node)) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
391 |
base = os.path.join(tmproot, dirname) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
392 |
try: |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
393 |
os.mkdir(base) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
394 |
except: |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
395 |
pass |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
396 |
ui.note(_('making snapshot of %d files from rev %s\n') % |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
397 |
(len(files), short(node))) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
398 |
for fn in files: |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
399 |
if not fn in mf: |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
400 |
# skipping new file after a merge ? |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
401 |
continue |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
402 |
wfn = util.pconvert(fn) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
403 |
ui.note(' %s\n' % wfn) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
404 |
dest = os.path.join(base, wfn) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
405 |
destdir = os.path.dirname(dest) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
406 |
if not os.path.isdir(destdir): |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
407 |
os.makedirs(destdir) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
408 |
data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn])) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
409 |
open(dest, 'wb').write(data) |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
410 |
return dirname |
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
411 |
|
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
412 |
def doedit(): |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
413 |
pathroot = self.repo.root |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
414 |
copynode = None |
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
415 |
# if we aren't looking at the wc, copy the node... |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
416 |
if stat in 'R!' or force_left: |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
417 |
copynode = self._node1 |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
418 |
elif self._node2: |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
419 |
copynode = self._node2 |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
420 |
|
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
421 |
if copynode: |
893
fe23e928cd27
hggtk/gdialog: fix traceback on viewing multiple files in same changesets
TK Soh <teekaysoh@yahoo.com>
parents:
892
diff
changeset
|
422 |
copydir = snapshot_node(self.ui, self.repo, |
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
423 |
[util.pconvert(file)], copynode, self.tmproot) |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
424 |
pathroot = os.path.join(self.tmproot, copydir) |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
425 |
|
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
426 |
file_path = os.path.join(pathroot, file) |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
427 |
util.system("%s \"%s\"" % (editor, file_path), |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
428 |
environ={'HGUSER': self.ui.username()}, |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
429 |
onerr=util.Abort, errprefix=_('edit failed')) |
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
430 |
|
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
431 |
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
|
432 |
self.ui.config('gtools', 'editor') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
433 |
os.environ.get('HGEDITOR') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
434 |
self.ui.config('ui', 'editor') or |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
435 |
os.environ.get('EDITOR', 'vi')) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
436 |
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
|
437 |
Prompt('No visual editor configured', |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
438 |
'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
|
439 |
dlg = ConfigDialog(self.repo.root, False) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
440 |
dlg.show_all() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
441 |
dlg.focus_field('tortoisehg.editor') |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
442 |
dlg.run() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
443 |
dlg.hide() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
444 |
self.ui = ui.ui() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
445 |
self._parse_config() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
446 |
return |
892
715c7ead5538
hggtk/gdialog: keep view files until dialog session ended
TK Soh <teekaysoh@yahoo.com>
parents:
812
diff
changeset
|
447 |
|
1022
fbd4883d07c1
hggtk/changeset: use util.localpath() to create safe path names
Steve Borho <steve@borho.org>
parents:
997
diff
changeset
|
448 |
file = util.localpath(file) |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
449 |
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
|
450 |
thread.setDaemon(True) |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
451 |
thread.start() |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
749
diff
changeset
|
452 |
|
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
453 |
class NativeSaveFileDialogWrapper: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
454 |
"""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
|
455 |
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
|
456 |
Filter = {"All files": "*.*"}, FilterIndex = 1, FileName = ''): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
457 |
import os.path |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
458 |
if InitialDir == None: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
459 |
InitialDir = os.path.expanduser("~") |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
460 |
self.InitialDir = InitialDir |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
461 |
self.FileName = FileName |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
462 |
self.Title = Title |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
463 |
self.Filter = Filter |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
464 |
self.FilterIndex = FilterIndex |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
465 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
466 |
def run(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
467 |
"""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
|
468 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
469 |
import win32gui |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
470 |
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
|
471 |
return self.runCompatible() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
472 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
473 |
return self.runWindows() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
474 |
except ImportError: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
475 |
return self.runCompatible() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
476 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
477 |
def tortoiseHgIsInstalled(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
478 |
import _winreg |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
479 |
try: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
480 |
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
|
481 |
if hkey: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
482 |
cls = _winreg.QueryValue(hkey,"") |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
483 |
return cls == "{102C6A24-5F38-4186-B64A-237011809FAB}" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
484 |
except WindowsError: #reg key not found |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
485 |
pass |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
486 |
return False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
487 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
488 |
def runWindows(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
489 |
import win32gui, win32con, os |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
490 |
filter = "" |
806
f0278682fadf
hggtk: use iteritems() when possible
Steve Borho <steve@borho.org>
parents:
804
diff
changeset
|
491 |
for name, pattern in self.Filter.iteritems(): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
492 |
filter += name + "\0" + pattern + "\0" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
493 |
customfilter = "\0" |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
494 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
495 |
fname, customfilter, flags=win32gui.GetSaveFileNameW( |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
496 |
InitialDir=self.InitialDir, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
497 |
Flags=win32con.OFN_EXPLORER, |
446
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
498 |
File=self.FileName, |
5d500008cb21
hggtk/gdialog: accept predefined filename in savefile dialog
TK Soh <teekaysoh@yahoo.com>
parents:
438
diff
changeset
|
499 |
DefExt='py', |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
500 |
Title=self.Title, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
501 |
Filter="", |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
502 |
CustomFilter="", |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
503 |
FilterIndex=1) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
504 |
if fname: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
505 |
return fname |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
506 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
507 |
return False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
508 |
|
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
509 |
def runCompatible(self): |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
510 |
file_save =gtk.FileChooserDialog(self.Title,None, |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
511 |
gtk.FILE_CHOOSER_ACTION_SAVE |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
512 |
, (gtk.STOCK_CANCEL |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
513 |
, gtk.RESPONSE_CANCEL |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
514 |
, gtk.STOCK_SAVE |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
515 |
, gtk.RESPONSE_OK)) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
516 |
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
|
517 |
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
|
518 |
file_save.set_current_name(self.FileName) |
806
f0278682fadf
hggtk: use iteritems() when possible
Steve Borho <steve@borho.org>
parents:
804
diff
changeset
|
519 |
for name, pattern in self.Filter.iteritems(): |
423
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
520 |
fi = gtk.FileFilter() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
521 |
fi.set_name(name) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
522 |
fi.add_pattern(pattern) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
523 |
file_save.add_filter(fi) |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
524 |
if file_save.run() == gtk.RESPONSE_OK: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
525 |
result = file_save.get_filename(); |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
526 |
else: |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
527 |
result = False |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
528 |
file_save.destroy() |
6bc79fa0ce34
hggtk: move gtools dialogs into their respective modules
TK Soh <teekaysoh@yahoo.com>
parents:
diff
changeset
|
529 |
return result |