author | Radek Brich <radek.brich@devl.cz> |
Fri, 25 Jan 2013 17:44:49 +0100 | |
changeset 60 | bb6b20106ff5 |
parent 10 | f3a1b9792cc9 |
child 76 | 3a41b351b122 |
permissions | -rw-r--r-- |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
import gtk, pango |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
import gtksourceview2 as gtksourceview |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
from lxml import etree |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
from panedext import HPanedExt |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
from config import cfg |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
class Editor(HPanedExt): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
def __init__(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
super(Editor, self).__init__() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
self.view = gtksourceview.View() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
self.view.connect('toggle-overwrite', self.on_toggle_overwrite) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
vbox = gtk.VBox() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
self.vbox1 = vbox |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
self.add1(vbox) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
sw = gtk.ScrolledWindow() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
sw.set_shadow_type(gtk.SHADOW_IN) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
vbox.pack_start(sw) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
tree = gtk.TreeView() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
tree.set_headers_visible(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
tree.get_selection().set_mode(gtk.SELECTION_BROWSE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
sw.add(tree) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
model = gtk.ListStore(str, str, object, bool) # title, filename, buffer, modified |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
tree.set_model(model) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
cell = gtk.CellRendererPixbuf() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
cell.set_property('stock-id', gtk.STOCK_SAVE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
column = gtk.TreeViewColumn("File", cell, visible=3) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
tree.append_column(column) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
column = gtk.TreeViewColumn("File", gtk.CellRendererText(), text=0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
tree.append_column(column) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
tree.get_selection().connect('changed', self.item_change) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
tree.set_property('can-focus', False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
self.filelist = tree |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
hbox = gtk.HBox() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
43 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
44 |
img = gtk.Image() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
45 |
img.set_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_SMALL_TOOLBAR) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
46 |
btn = gtk.Button() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
47 |
btn.set_relief(gtk.RELIEF_NONE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
48 |
btn.set_focus_on_click(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
49 |
btn.set_image(img) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
50 |
btn.connect('clicked', self.item_new) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
51 |
hbox.pack_start(btn, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
52 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
53 |
img = gtk.Image() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
54 |
img.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_SMALL_TOOLBAR) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
55 |
btn = gtk.Button() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
56 |
btn.set_relief(gtk.RELIEF_NONE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
57 |
btn.set_focus_on_click(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
58 |
btn.set_image(img) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
59 |
btn.connect('clicked', self.item_open) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
60 |
hbox.pack_start(btn, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
61 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
62 |
img = gtk.Image() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
63 |
img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
64 |
btn = gtk.Button() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
65 |
btn.set_relief(gtk.RELIEF_NONE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
66 |
btn.set_focus_on_click(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
67 |
btn.set_image(img) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
68 |
btn.connect('clicked', self.item_close) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
69 |
hbox.pack_start(btn, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
70 |
hbox.connect('size-request', self.leftbuttons_size_request) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
71 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
72 |
vbox.pack_start(hbox, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
73 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
74 |
vbox = gtk.VBox() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
75 |
vbox.set_property("width-request", 200) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
76 |
self.add2(vbox) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
77 |
self.child_set_property(vbox, 'shrink', False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
78 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
79 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
80 |
# scroll |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
81 |
sw = gtk.ScrolledWindow() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
82 |
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
83 |
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
84 |
sw.add(self.view) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
85 |
vbox.pack_start(sw) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
86 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
87 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
88 |
self.view.set_show_line_numbers(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
89 |
self.view.set_smart_home_end(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
90 |
#self.view.set_insert_spaces_instead_of_tabs(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
91 |
self.view.set_property("tab-width", 4) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
92 |
self.view.set_auto_indent(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
93 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
94 |
# font |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
95 |
font_desc = pango.FontDescription('monospace') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
96 |
if font_desc: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
97 |
self.view.modify_font(font_desc) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
98 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
99 |
# status bar |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
100 |
hbox = gtk.HBox() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
101 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
102 |
self.st_file, fr1 = self.construct_status('SQL snippet') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
103 |
self.st_file.set_ellipsize(pango.ELLIPSIZE_START) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
104 |
self.st_insovr, fr2 = self.construct_status('INS') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
105 |
self.st_linecol, fr3 = self.construct_status('Line: 0 Col: 0') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
106 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
107 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
108 |
img = gtk.Image() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
109 |
img.set_from_stock(gtk.STOCK_SAVE, gtk.ICON_SIZE_SMALL_TOOLBAR) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
110 |
#save = img |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
111 |
save = gtk.Button() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
112 |
save.set_relief(gtk.RELIEF_NONE) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
113 |
save.set_focus_on_click(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
114 |
save.set_image(img) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
115 |
save.connect('clicked', self.item_save) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
116 |
hbox.pack_start(save, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
117 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
118 |
hbox.pack_start(fr1, expand=True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
119 |
hbox.pack_start(fr2, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
120 |
hbox.pack_start(fr3, expand=False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
121 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
122 |
#sep = gtk.HSeparator() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
123 |
#vbox.pack_start(sep, expand=False, fill=False, padding=0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
124 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
125 |
#align = gtk.Alignment() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
126 |
#align.set_property("bottom-padding", 3) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
127 |
#align.set_property("xscale", 1.0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
128 |
#align.add(hbox) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
129 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
130 |
#frame = gtk.Frame() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
131 |
#frame.add(hbox) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
132 |
#frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
133 |
vbox.pack_start(hbox, expand=False, padding=0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
134 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
135 |
self.load_nodes() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
136 |
self.build_context_menu() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
137 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
138 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
139 |
def build_context_menu(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
140 |
menu = gtk.Menu() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
141 |
item = gtk.ImageMenuItem(gtk.STOCK_SAVE, "Save") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
142 |
item.connect("activate", self.item_save) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
143 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
144 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
145 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
146 |
item = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS, "Save as") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
147 |
item.connect("activate", self.item_save_as) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
148 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
149 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
150 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
151 |
item = gtk.ImageMenuItem(gtk.STOCK_CLOSE, "Close") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
152 |
item.connect("activate", self.item_close) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
153 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
154 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
155 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
156 |
item = gtk.SeparatorMenuItem() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
157 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
158 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
159 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
160 |
item = gtk.ImageMenuItem(gtk.STOCK_GO_UP, "Move up") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
161 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
162 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
163 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
164 |
item = gtk.ImageMenuItem(gtk.STOCK_GO_DOWN, "Move down") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
165 |
item.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
166 |
menu.append(item) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
167 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
168 |
self.filelist_menu = menu |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
169 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
170 |
self.filelist.connect_object("button-press-event", self.on_filelist_button_press_event, menu) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
171 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
172 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
173 |
def on_filelist_button_press_event(self, w, event): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
174 |
if event.button == 3: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
175 |
x = int(event.x) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
176 |
y = int(event.y) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
177 |
pathinfo = self.filelist.get_path_at_pos(x, y) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
178 |
if pathinfo is not None: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
179 |
path, col, cellx, celly = pathinfo |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
180 |
self.filelist.grab_focus() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
181 |
self.filelist.set_cursor(path, col, 0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
182 |
self.filelist_menu.popup(None, None, None, event.button, event.time) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
183 |
return True |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
184 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
185 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
186 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
187 |
def make_buffer(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
188 |
buffer = gtksourceview.Buffer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
189 |
buffer.connect('mark-set', self.buffer_mark_set) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
190 |
buffer.connect('changed', self.buffer_changed) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
191 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
192 |
# style |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
193 |
mgr = gtksourceview.style_scheme_manager_get_default() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
194 |
style_scheme = mgr.get_scheme('kate') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
195 |
if style_scheme: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
196 |
buffer.set_style_scheme(style_scheme) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
197 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
198 |
# syntax |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
199 |
lngman = gtksourceview.language_manager_get_default() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
200 |
langsql = lngman.get_language('sql') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
201 |
buffer.set_language(langsql) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
202 |
buffer.set_highlight_syntax(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
203 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
204 |
return buffer |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
205 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
206 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
207 |
def load_nodes(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
208 |
model = self.filelist.get_model() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
209 |
sel = cfg.root.editor.nodes.get('selected') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
210 |
for node in cfg.root.editor.nodes.node: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
211 |
buffer = self.make_buffer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
212 |
name = node.get('name') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
213 |
type = node.get('type') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
214 |
filename = None |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
215 |
if type == 'text' and node.text: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
216 |
buffer.set_text(node.text) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
217 |
if type == 'file': |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
218 |
filename = node.text |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
219 |
content = open(filename).read() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
220 |
buffer.set_text(content) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
221 |
iter = model.append([name, filename, buffer, False]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
222 |
if sel == name: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
223 |
self.filelist.get_selection().select_iter(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
224 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
225 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
226 |
def set_text(self, text): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
227 |
self.buffer.set_text(text) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
228 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
229 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
230 |
def get_text(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
231 |
start, end = self.buffer.get_bounds() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
232 |
return self.buffer.get_text(start, end) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
233 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
234 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
235 |
def get_selection(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
236 |
bounds = self.buffer.get_selection_bounds() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
237 |
if not bounds: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
238 |
return None |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
239 |
return self.buffer.get_text(*bounds) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
240 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
241 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
242 |
def construct_status(self, text): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
243 |
st = gtk.Label(text) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
244 |
st.set_property("single-line-mode", True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
245 |
st.set_property("xpad", 3) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
246 |
st.set_alignment(0.0, 0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
247 |
fr = gtk.Frame() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
248 |
fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
249 |
fr.add(st) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
250 |
return st, fr |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
251 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
252 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
253 |
def on_toggle_overwrite(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
254 |
if not w.get_overwrite(): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
255 |
self.st_insovr.set_label('OVR') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
256 |
else: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
257 |
self.st_insovr.set_label('INS') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
258 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
259 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
260 |
def buffer_mark_set(self, w, iter, textmark): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
261 |
if textmark == w.get_insert(): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
262 |
line = iter.get_line() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
263 |
col = iter.get_visible_line_offset() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
264 |
self.st_linecol.set_label('Line: %d Col: %d' % (line + 1, col + 1)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
265 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
266 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
267 |
def buffer_changed(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
268 |
iter = w.get_iter_at_mark(w.get_insert()) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
269 |
line = iter.get_line() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
270 |
col = iter.get_visible_line_offset() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
271 |
self.st_linecol.set_label('Line: %d Col: %d' % (line + 1, col + 1)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
272 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
273 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
274 |
def item_change(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
275 |
model, sel = self.filelist.get_selection().get_selected_rows() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
276 |
if not sel: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
277 |
return |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
278 |
iter = model.get_iter(sel[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
279 |
title, filename, self.buffer = model.get(iter, 0, 1, 2) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
280 |
self.view.set_buffer(self.buffer) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
281 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
282 |
if filename: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
283 |
self.st_file.set_text(filename) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
284 |
else: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
285 |
self.st_file.set_text('SQL snippet') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
286 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
287 |
# update config |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
288 |
cfg.root.editor.nodes.set('selected', title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
289 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
290 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
291 |
def probe_title(self, model, title): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
292 |
iter = model.get_iter_first() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
293 |
i = 1 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
294 |
while iter: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
295 |
if model.get_value(iter, 0).split(' /')[0] == title: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
296 |
new = title |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
297 |
if i > 1: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
298 |
new += ' /%d' % i |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
299 |
model.set_value(iter, 0, new) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
300 |
i += 1 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
301 |
iter = model.iter_next(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
302 |
if i > 1: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
303 |
title = '%s /%d' % (title, i) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
304 |
return title |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
305 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
306 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
307 |
def item_new(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
308 |
model = self.filelist.get_model() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
309 |
title = 'Untitled' |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
310 |
title = self.probe_title(model, title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
311 |
buffer = self.make_buffer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
312 |
iter = model.append([title, None, buffer, False]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
313 |
self.filelist.get_selection().select_iter(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
314 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
315 |
# update config |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
316 |
etree.SubElement(cfg.root.editor.nodes, 'node', type='text', name=title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
317 |
cfg.root.editor.nodes.set('selected', title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
318 |
cfg.save() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
319 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
320 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
321 |
def item_open(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
322 |
dialog = gtk.FileChooserDialog(title='Open file', action=gtk.FILE_CHOOSER_ACTION_OPEN, |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
323 |
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
324 |
dialog.set_default_response(gtk.RESPONSE_OK) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
325 |
dialog.set_select_multiple(True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
326 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
327 |
filter = gtk.FileFilter() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
328 |
filter.set_name("SQL files") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
329 |
filter.add_pattern("*.sql") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
330 |
dialog.add_filter(filter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
331 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
332 |
filter = gtk.FileFilter() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
333 |
filter.set_name("All files") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
334 |
filter.add_pattern("*") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
335 |
dialog.add_filter(filter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
336 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
337 |
response = dialog.run() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
338 |
if response == gtk.RESPONSE_OK: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
339 |
filenames = dialog.get_filenames() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
340 |
for fname in filenames: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
341 |
self.open_file(fname) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
342 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
343 |
dialog.destroy() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
344 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
345 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
346 |
def open_file(self, filename): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
347 |
title = filename.rsplit('/', 1)[1] |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
348 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
349 |
model = self.filelist.get_model() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
350 |
iter = model.get_iter_first() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
351 |
i = 1 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
352 |
while iter: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
353 |
if model.get_value(iter, 1) == filename: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
354 |
# file already opened, select it |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
355 |
self.filelist.get_selection().select_iter(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
356 |
return |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
357 |
iter = model.iter_next(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
358 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
359 |
title = self.probe_title(model, title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
360 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
361 |
# add item |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
362 |
buffer = self.make_buffer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
363 |
buffer.set_text(open(filename).read()) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
364 |
iter = model.append([title, filename, buffer, False]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
365 |
self.filelist.get_selection().select_iter(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
366 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
367 |
# update config |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
368 |
el = etree.SubElement(cfg.root.editor.nodes, 'node', type='file', name=title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
369 |
el._setText(filename) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
370 |
cfg.root.editor.nodes.set('selected', title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
371 |
cfg.save() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
372 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
373 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
374 |
def item_save(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
375 |
model, sel = self.filelist.get_selection().get_selected_rows() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
376 |
if not sel: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
377 |
return |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
378 |
iter = model.get_iter(sel[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
379 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
380 |
filename, buffer = model.get(iter, 1, 2) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
381 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
382 |
data = buffer.get_text(*buffer.get_bounds()) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
383 |
open(filename, 'w').write(data) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
384 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
385 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
386 |
def item_save_as(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
387 |
model, sel = self.filelist.get_selection().get_selected_rows() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
388 |
if not sel: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
389 |
return |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
390 |
iter = model.get_iter(sel[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
391 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
392 |
filename, buffer = model.get(iter, 1, 2) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
393 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
394 |
path, file = filename.rsplit('/',1) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
395 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
396 |
dialog = gtk.FileChooserDialog(title='Save as', action=gtk.FILE_CHOOSER_ACTION_SAVE, |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
397 |
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
398 |
dialog.set_default_response(gtk.RESPONSE_OK) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
399 |
dialog.set_current_folder(path) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
400 |
dialog.set_current_name(file) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
401 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
402 |
filter = gtk.FileFilter() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
403 |
filter.set_name("SQL files") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
404 |
filter.add_pattern("*.sql") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
405 |
dialog.add_filter(filter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
406 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
407 |
filter = gtk.FileFilter() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
408 |
filter.set_name("All files") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
409 |
filter.add_pattern("*") |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
410 |
dialog.add_filter(filter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
411 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
412 |
response = dialog.run() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
413 |
if response == gtk.RESPONSE_OK: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
414 |
filename = dialog.get_filename() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
415 |
data = buffer.get_text(*buffer.get_bounds()) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
416 |
open(filename, 'w').write(data) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
417 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
418 |
title = filename.rsplit('/',1)[1] |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
419 |
title = self.probe_title(model, title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
420 |
model.set(iter, 0, title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
421 |
model.set(iter, 1, filename) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
422 |
model.set(iter, 3, False) # modified |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
423 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
424 |
dialog.destroy() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
425 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
426 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
427 |
def item_close(self, w): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
428 |
model, sel = self.filelist.get_selection().get_selected_rows() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
429 |
if not sel: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
430 |
return |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
431 |
iter = model.get_iter(sel[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
432 |
newiter = model.iter_next(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
433 |
if newiter is None and sel[0][0] > 0: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
434 |
newiter = model.get_iter((sel[0][0]-1,)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
435 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
436 |
title, buffer = model.get(iter, 0, 2) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
437 |
#buffer.destroy() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
438 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
439 |
model.remove(iter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
440 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
441 |
if newiter is None: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
442 |
self.item_new(None) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
443 |
else: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
444 |
self.filelist.get_selection().select_iter(newiter) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
445 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
446 |
# update config |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
447 |
el = cfg.root.editor.nodes.find('node[@name="%s"]' % title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
448 |
el.getparent().remove(el) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
449 |
cfg.save() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
450 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
451 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
452 |
def leftbuttons_size_request(self, w, request): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
453 |
self.set_snap1(request[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
454 |
return True |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
455 |