author | Radek Brich <radek.brich@devl.cz> |
Tue, 16 Aug 2011 23:53:54 +0200 | |
changeset 10 | f3a1b9792cc9 |
child 11 | bc69eca59041 |
permissions | -rwxr-xr-x |
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 |
#!/usr/bin/env python |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
import 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
|
4 |
import gobject, gtk, pango, cairo |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
6 |
|
f3a1b9792cc9
Added pgconsole. 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 |
import psycopg2 |
f3a1b9792cc9
Added pgconsole. 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 |
import psycopg2.extensions |
f3a1b9792cc9
Added pgconsole. 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 |
import psycopg2.extras |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
from pgconsole.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
|
12 |
from pgconsole.editor import Editor |
f3a1b9792cc9
Added pgconsole. 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 |
from pgconsole.dataview import DataView |
f3a1b9792cc9
Added pgconsole. 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 |
from pgconsole.database import Database, BadConnectionError, DatabaseError |
f3a1b9792cc9
Added pgconsole. 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 |
from pgconsole.settings import Settings |
f3a1b9792cc9
Added pgconsole. 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 |
from pgconsole.panedext import HPanedExt, VPanedExt |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
class PgConsoleApp: |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
21 |
self.db = Database() |
f3a1b9792cc9
Added pgconsole. 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 |
self.conn = 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
|
23 |
|
f3a1b9792cc9
Added pgconsole. 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 |
win = gtk.Window(gtk.WINDOW_TOPLEVEL) |
f3a1b9792cc9
Added pgconsole. 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 |
self.win = win |
f3a1b9792cc9
Added pgconsole. 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 |
win.set_title('PostgreSQL Console') |
f3a1b9792cc9
Added pgconsole. 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 |
win.set_size_request(300, 200) # minimal size |
f3a1b9792cc9
Added pgconsole. 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 |
win.set_default_size(800, 600) |
f3a1b9792cc9
Added pgconsole. 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 |
self.restore_window_size() |
f3a1b9792cc9
Added pgconsole. 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 |
win.connect("destroy", self.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
|
31 |
win.connect("key_press_event", self.keypress) |
f3a1b9792cc9
Added pgconsole. 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 |
win.connect('configure-event', self.on_configure) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
# 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
|
35 |
toolbar = gtk.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
|
36 |
toolbar.set_style(gtk.TOOLBAR_ICONS) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.set_property("icon-size", 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
|
38 |
|
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_PREFERENCES) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_label('Settings') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Settings') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.settings) |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_settings = tb |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.cb_server = gtk.combo_box_entry_new_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
|
47 |
self.cb_server.set_tooltip_text('Server') |
f3a1b9792cc9
Added pgconsole. 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 |
self.cb_server.get_child().set_property("editable", 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 |
self.cb_server.set_property("add_tearoffs", 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
|
50 |
#self.cb_server.set_property("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
|
51 |
self.cb_server.set_property("can-focus", 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
|
52 |
self.cb_server.connect('changed', self.on_server_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
|
53 |
self.cb_server.connect("key_press_event", self.toolbar_server_keypress) |
f3a1b9792cc9
Added pgconsole. 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 |
ti = gtk.ToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
ti.add(self.cb_server) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(ti) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.cb_dbname = gtk.combo_box_entry_new_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
|
59 |
self.cb_dbname.set_tooltip_text('Database') |
f3a1b9792cc9
Added pgconsole. 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 |
self.cb_dbname.get_child().set_property("editable", 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 |
self.cb_dbname.set_property("add_tearoffs", 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
|
62 |
#self.cb_dbname.set_property("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
|
63 |
self.cb_dbname.set_property("can-focus", 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
|
64 |
ti = gtk.ToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
ti.add(self.cb_dbname) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(ti) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_CONNECT) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_label('Connect') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Connect') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.connect) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect = tb |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
sep = gtk.SeparatorToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(sep) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_EXECUTE) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_label('Execute') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Execute') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.execute) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_sensitive(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
|
84 |
self.tb_execute = tb |
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_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
|
86 |
tb.set_label('Begin transaction') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Begin transaction') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.begin) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_sensitive(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
|
90 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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.tb_begin = tb |
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_APPLY) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_label('Commit') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Commit') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.commit) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_sensitive(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
|
97 |
self.tb_commit = tb |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
tb = gtk.ToolButton(gtk.STOCK_CANCEL) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_label('Rollback') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_tooltip_text('Rollback') |
f3a1b9792cc9
Added pgconsole. 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 |
tb.connect('clicked', self.rollback) |
f3a1b9792cc9
Added pgconsole. 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 |
tb.set_sensitive(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
|
104 |
self.tb_rollback = tb |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
sep = gtk.SeparatorToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(sep) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
# editor |
f3a1b9792cc9
Added pgconsole. 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 |
self.editor = Editor() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
# data 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
|
114 |
self.dataview = DataView() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
vbox = gtk.VBox(False, 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
|
118 |
|
f3a1b9792cc9
Added pgconsole. 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 |
sep = gtk.SeparatorToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
sep.set_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
|
121 |
sep.set_draw(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
|
122 |
toolbar.add(sep) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.throbber_anim = gtk.gdk.PixbufAnimation('data/Throbber.gif') |
f3a1b9792cc9
Added pgconsole. 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 |
self.throbber = 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
|
126 |
tb = gtk.ToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
tb.add(self.throbber) |
f3a1b9792cc9
Added pgconsole. 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 |
toolbar.add(tb) |
f3a1b9792cc9
Added pgconsole. 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 |
sep = gtk.SeparatorToolItem() |
f3a1b9792cc9
Added pgconsole. 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 |
sep.set_draw(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
|
131 |
toolbar.add(sep) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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(toolbar, False, False, 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 |
vpaned = VPanedExt() |
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.set_border_width(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
|
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 |
hpaned = 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
|
139 |
hpaned.set_border_width(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
|
140 |
hpaned.add1(self.editor) |
f3a1b9792cc9
Added pgconsole. 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 |
hpaned.child_set_property(self.editor, '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
|
142 |
hpaned.set_snap2(80) |
f3a1b9792cc9
Added pgconsole. 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 |
hpaned.set_property('position', 500) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.add1(hpaned) |
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.set_snap1(80) |
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.set_property('position', 300) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.add2(self.dataview) |
f3a1b9792cc9
Added pgconsole. 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 |
vpaned.set_snap2(80) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.vpaned = vpaned |
f3a1b9792cc9
Added pgconsole. 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 |
self.hpaned = hpaned |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
# log |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf = gtk.TextBuffer() |
f3a1b9792cc9
Added pgconsole. 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 |
view = gtk.TextView(self.logbuf) |
f3a1b9792cc9
Added pgconsole. 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 |
view.set_editable(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
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
|
f3a1b9792cc9
Added pgconsole. 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 |
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
|
164 |
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
|
165 |
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
|
166 |
sw.add(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
|
167 |
hpaned.add2(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
|
168 |
|
f3a1b9792cc9
Added pgconsole. 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 |
vbox.pack_start(vpaned, 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
|
170 |
|
f3a1b9792cc9
Added pgconsole. 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 |
win.add(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
|
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 |
self.editor.view.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
|
174 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.reload_server_list(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
|
176 |
|
f3a1b9792cc9
Added pgconsole. 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 |
win.show_all() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.restore_win_state() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def main(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
|
183 |
gtk.main() |
f3a1b9792cc9
Added pgconsole. 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 |
def destroy(self, widget, data=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
|
187 |
self.save_win_state() |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
189 |
gtk.main_quit() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def on_configure(self, w, ev): |
f3a1b9792cc9
Added pgconsole. 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 |
cfg.root.window.size.width = ev.width |
f3a1b9792cc9
Added pgconsole. 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 |
cfg.root.window.size.height = ev.height |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def restore_window_size(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
|
198 |
self.win.resize(cfg.root.window.size.width, cfg.root.window.size.height) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def save_win_state(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
|
202 |
cfg.root.window.dividers.verticaldivider = self.vpaned.get_position() |
f3a1b9792cc9
Added pgconsole. 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 |
cfg.root.window.dividers.horizontaldivider = self.hpaned.get_position() |
f3a1b9792cc9
Added pgconsole. 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 |
cfg.root.window.dividers.editordivider = self.editor.get_position() |
f3a1b9792cc9
Added pgconsole. 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 restore_win_state(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 |
pos = cfg.root.window.dividers.verticaldivider |
f3a1b9792cc9
Added pgconsole. 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 |
if pos >= 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
|
210 |
self.vpaned.set_position(pos) |
f3a1b9792cc9
Added pgconsole. 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 |
pos = cfg.root.window.dividers.horizontaldivider |
f3a1b9792cc9
Added pgconsole. 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 |
if pos >= 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
|
213 |
self.hpaned.set_position(pos) |
f3a1b9792cc9
Added pgconsole. 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 |
pos = cfg.root.window.dividers.editordivider |
f3a1b9792cc9
Added pgconsole. 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 pos >= 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
|
216 |
self.editor.set_position(pos) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def get_typename(self, oid, size): |
f3a1b9792cc9
Added pgconsole. 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 |
self.curs.execute('SELECT typname FROM pg_type WHERE oid=%s', [oid]) |
f3a1b9792cc9
Added pgconsole. 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 |
psycopg2.extras.wait_select(self.curs.connection) |
f3a1b9792cc9
Added pgconsole. 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 |
row = self.curs.fetchone() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
typname = 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
|
225 |
if row: |
f3a1b9792cc9
Added pgconsole. 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 |
typname = row[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
|
227 |
if typname == 'int4': |
f3a1b9792cc9
Added pgconsole. 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 |
return 'integer' |
f3a1b9792cc9
Added pgconsole. 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 |
if typname in ('timestamp', 'interval', 'date'): |
f3a1b9792cc9
Added pgconsole. 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 |
return typname |
f3a1b9792cc9
Added pgconsole. 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 |
if size and size > 0 and size < 65535: |
f3a1b9792cc9
Added pgconsole. 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 |
typname += '(%s)' % size |
f3a1b9792cc9
Added pgconsole. 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 |
return typname |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def get_conninfo(self, nodb=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
|
237 |
sel = self.cb_server.get_active() |
f3a1b9792cc9
Added pgconsole. 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 |
srv = cfg.servers.server[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
|
239 |
if nodb: |
f3a1b9792cc9
Added pgconsole. 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 |
dbname = 'postgres' |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
242 |
dbname = self.cb_dbname.get_active_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 |
conninfo = 'host=%s port=%s dbname=%s user=%s password=%s' \ |
f3a1b9792cc9
Added pgconsole. 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 |
% (srv.host, srv.port, dbname, srv.user, srv.password) |
f3a1b9792cc9
Added pgconsole. 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 |
return conninfo |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def connect(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
|
249 |
conninfo = self.get_conninfo() |
f3a1b9792cc9
Added pgconsole. 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 |
if self.conn: |
f3a1b9792cc9
Added pgconsole. 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 |
# disconnect |
f3a1b9792cc9
Added pgconsole. 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 |
self.db.put_conn(conninfo, self.conn) |
f3a1b9792cc9
Added pgconsole. 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 |
self.conn = 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
|
254 |
self.cb_server.set_sensitive(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
|
255 |
self.cb_dbname.set_sensitive(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
|
256 |
self.tb_connect.set_stock_id(gtk.STOCK_CONNECT) |
f3a1b9792cc9
Added pgconsole. 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.tb_connect.set_label('Connect') |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_tooltip_text('Connect') |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_execute.set_sensitive(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
|
260 |
self.tb_begin.set_sensitive(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
|
261 |
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
|
262 |
# connect |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Connect %s\n' % conninfo) |
f3a1b9792cc9
Added pgconsole. 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 |
try: |
f3a1b9792cc9
Added pgconsole. 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 |
self.conn = self.db.get_conn(conninfo) |
f3a1b9792cc9
Added pgconsole. 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 |
except DatabaseError, e: |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Error:\n%s\n' % e) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
269 |
self.cb_server.set_sensitive(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
|
270 |
self.cb_dbname.set_sensitive(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
|
271 |
self.tb_connect.set_stock_id(gtk.STOCK_DISCONNECT) |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_label('Disconnect') |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_tooltip_text('Disconnect') |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_execute.set_sensitive(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
|
275 |
self.tb_begin.set_sensitive(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
|
276 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def begin(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
|
279 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Begin transaction\n') |
f3a1b9792cc9
Added pgconsole. 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 |
curs = self.conn.cursor() |
f3a1b9792cc9
Added pgconsole. 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 |
curs.execute('BEGIN') |
f3a1b9792cc9
Added pgconsole. 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 |
psycopg2.extras.wait_select(curs.connection) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_sensitive(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
|
285 |
self.tb_begin.set_sensitive(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
|
286 |
self.tb_commit.set_sensitive(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
|
287 |
self.tb_rollback.set_sensitive(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
|
288 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def commit(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
|
291 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Commit\n') |
f3a1b9792cc9
Added pgconsole. 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 |
curs = self.conn.cursor() |
f3a1b9792cc9
Added pgconsole. 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 |
curs.execute('COMMIT') |
f3a1b9792cc9
Added pgconsole. 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 |
psycopg2.extras.wait_select(curs.connection) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_sensitive(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
|
297 |
self.tb_begin.set_sensitive(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
|
298 |
self.tb_commit.set_sensitive(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
|
299 |
self.tb_rollback.set_sensitive(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
|
300 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def rollback(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
|
303 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Rollback\n') |
f3a1b9792cc9
Added pgconsole. 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 |
curs = self.conn.cursor() |
f3a1b9792cc9
Added pgconsole. 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 |
curs.execute('ROLLBACK') |
f3a1b9792cc9
Added pgconsole. 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 |
psycopg2.extras.wait_select(curs.connection) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_sensitive(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
|
309 |
self.tb_begin.set_sensitive(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
|
310 |
self.tb_commit.set_sensitive(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
|
311 |
self.tb_rollback.set_sensitive(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
|
312 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def execute(self, widget): |
f3a1b9792cc9
Added pgconsole. 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 |
query = self.editor.get_selection() or self.editor.get_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
|
316 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_connect.set_sensitive(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
|
318 |
self.tb_execute.set_sensitive(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
|
319 |
self.tb_begin.set_sensitive(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
|
320 |
self.tb_commit.set_sensitive(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
|
321 |
self.tb_rollback.set_sensitive(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
|
322 |
self.throbber.set_from_animation(self.throbber_anim) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.curs = self.conn.cursor() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.t1 = time.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
|
327 |
try: |
f3a1b9792cc9
Added pgconsole. 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 |
self.curs.execute(query) |
f3a1b9792cc9
Added pgconsole. 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 |
except (psycopg2.OperationalError, psycopg2.DatabaseError), e: |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Error:\n' + str(e)) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
332 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.execute_poll() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def execute_poll(self, source=None, cond=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
|
337 |
try: |
f3a1b9792cc9
Added pgconsole. 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 |
state = self.conn.poll() |
f3a1b9792cc9
Added pgconsole. 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 |
except (psycopg2.OperationalError, psycopg2.DatabaseError), e: |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Error:\n' + str(e)) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
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 |
if state == psycopg2.extensions.POLL_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
|
344 |
self.execute_finish() |
f3a1b9792cc9
Added pgconsole. 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 |
elif state == psycopg2.extensions.POLL_WRITE: |
f3a1b9792cc9
Added pgconsole. 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 |
gobject.io_add_watch(self.conn.fileno(), gobject.IO_OUT, self.execute_poll) |
f3a1b9792cc9
Added pgconsole. 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 |
elif state == psycopg2.extensions.POLL_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
|
348 |
gobject.io_add_watch(self.conn.fileno(), gobject.IO_IN, self.execute_poll) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
350 |
self.logbuf.insert(self.logbuf.get_end_iter(), "poll() returned %s" % state) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
352 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def execute_finish(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
|
355 |
t2 = time.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
|
356 |
t = (t2 - self.t1)*1000 |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.throbber.clear() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_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
|
361 |
'Query successful (%d ms, %d rows)\n' % (t, self.curs.rowcount)) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
# notices |
f3a1b9792cc9
Added pgconsole. 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 |
for n in self.conn.notices: |
f3a1b9792cc9
Added pgconsole. 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.logbuf.insert(self.logbuf.get_end_iter(), n) |
f3a1b9792cc9
Added pgconsole. 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 |
if self.curs.rowcount >= 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
|
368 |
rows = self.curs.fetchall() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
names = [] |
f3a1b9792cc9
Added pgconsole. 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 |
for c in self.curs.description: |
f3a1b9792cc9
Added pgconsole. 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 |
name = c[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
|
373 |
typename = self.get_typename(c[1], c[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
|
374 |
names += [(name, typename)] |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.dataview.load_data(names, 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
|
377 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_execute.set_sensitive(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
|
379 |
if self.conn.get_transaction_status() == psycopg2.extensions.TRANSACTION_STATUS_INTRANS: |
f3a1b9792cc9
Added pgconsole. 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 |
self.tb_commit.set_sensitive(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
|
381 |
self.tb_rollback.set_sensitive(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
|
382 |
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
|
383 |
self.tb_connect.set_sensitive(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
|
384 |
self.tb_begin.set_sensitive(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
|
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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def simulate_click(self, tb): |
f3a1b9792cc9
Added pgconsole. 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 tb.get_property('sensitive'): |
f3a1b9792cc9
Added pgconsole. 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 |
tb.get_child().activate() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def keypress(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
|
393 |
keyname = gtk.gdk.keyval_name(event.keyval) |
f3a1b9792cc9
Added pgconsole. 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 |
if keyname == 'F1': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_settings) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
397 |
if keyname == 'F2': |
f3a1b9792cc9
Added pgconsole. 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 |
print self.cb_server.popup() |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
400 |
if keyname == 'F3': |
f3a1b9792cc9
Added pgconsole. 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 |
print self.cb_dbname.popup() |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
403 |
if keyname == 'F4': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_connect) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
406 |
if keyname == 'F5': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_execute) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
409 |
if keyname == 'F6': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_begin) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
412 |
if keyname == 'F7': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_commit) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
415 |
if keyname == 'F8': |
f3a1b9792cc9
Added pgconsole. 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 |
self.simulate_click(self.tb_rollback) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
418 |
|
f3a1b9792cc9
Added pgconsole. 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 |
return 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
|
420 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def toolbar_server_keypress(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
|
423 |
keyname = gtk.gdk.keyval_name(event.keyval) |
f3a1b9792cc9
Added pgconsole. 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 |
if keyname == 'Tab': |
f3a1b9792cc9
Added pgconsole. 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 |
self.populate_db_list() |
f3a1b9792cc9
Added pgconsole. 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 |
self.cb_dbname.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
|
427 |
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
|
428 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def on_server_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
|
431 |
if self.cb_server.get_active() != -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
|
432 |
self.populate_db_list() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
def populate_db_list(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
|
436 |
conninfo = self.get_conninfo(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
|
437 |
try: |
f3a1b9792cc9
Added pgconsole. 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 |
conn = self.db.get_conn(conninfo) |
f3a1b9792cc9
Added pgconsole. 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 |
except DatabaseError, e: |
f3a1b9792cc9
Added pgconsole. 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 |
self.logbuf.insert(self.logbuf.get_end_iter(), 'Error:\n%s\n' % e) |
f3a1b9792cc9
Added pgconsole. 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 |
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
|
442 |
|
f3a1b9792cc9
Added pgconsole. 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 |
curs = conn.cursor() |
f3a1b9792cc9
Added pgconsole. 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 |
curs.execute('SELECT * FROM pg_catalog.pg_database WHERE NOT datistemplate ORDER BY 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
|
445 |
psycopg2.extras.wait_select(conn) |
f3a1b9792cc9
Added pgconsole. 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 |
rows = curs.fetchall() |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
self.db.put_conn(conninfo, conn) |
f3a1b9792cc9
Added pgconsole. 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 |
|
f3a1b9792cc9
Added pgconsole. 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 |
for i in range(self.cb_dbname.get_model().iter_n_children(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
|
451 |
self.cb_dbname.remove_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
|
452 |
|
f3a1b9792cc9
Added pgconsole. 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 |
for row in 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
|
454 |
self.cb_dbname.append_text(row[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
|
455 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
456 |
self.cb_dbname.set_active(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
|
457 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
458 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
459 |
def reload_server_list(self, sel=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
|
460 |
# clean |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
461 |
for i in range(self.cb_server.get_model().iter_n_children(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
|
462 |
self.cb_server.remove_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
|
463 |
self.cb_server.get_child().set_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
|
464 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
465 |
try: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
466 |
# populate |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
467 |
for server in cfg.servers.server: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
468 |
if str(server.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
|
469 |
title = '%s (%s)' % (str(server.name), str(server.host)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
470 |
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
|
471 |
title = str(server.host) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
472 |
self.cb_server.append_text(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
|
473 |
except AttributeError: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
474 |
pass |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
475 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
476 |
if not sel 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
|
477 |
self.cb_server.set_active(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
|
478 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
479 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
480 |
def settings(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
|
481 |
Settings(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
|
482 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
483 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
484 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
485 |
if __name__ == '__main__': |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
486 |
try: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
487 |
cfg.load('pgconsole.xml.gz') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
488 |
except IOError: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
489 |
cfg.new('pgconsole.xml.gz') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
490 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
491 |
try: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
492 |
gtkrc = cfg.root.style.gtkrc.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
|
493 |
except AttributeError: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
494 |
pass |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
495 |
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
|
496 |
gtk.rc_parse_string(gtkrc) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
497 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
498 |
app = PgConsoleApp() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
499 |
app.main() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
500 |