/usr/lib/gjots2/general.py is in gjots2 2.4.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | import gtk
import inspect
from common import *
class general_dialog:
def destroy(self):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.general_get_widget(self.name).destroy()
def on_generalField1_key_press_event(self, widget, event):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
if event.keyval == 65307: # Escape
self.generalValue = CANCEL;
return 1
if event.keyval == 65289: # tab
if self.generalNumFields > 1:
self.general_get_widget("generalField2").grab_focus()
return 1
if event.keyval == 65421 or event.keyval == 65293: # KP_Enter / Return
if self.generalNumFields > 1:
#generalDialog = gtk_widget_get_toplevel(widget);
self.general_get_widget("generalField2").grab_focus()
else:
self.generalValue = OK;
return 1
return 0
def on_generalField2_key_press_event(self, widget, event):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
if event.keyval == 65307: # Escape
self.generalValue = CANCEL;
return 1
if event.keyval == 65289: # tab
self.general_get_widget("generalField1").grab_focus()
return 1
if event.keyval == 65421 or event.keyval == 65293: # KP_Enter / Return
self.generalValue = OK;
return 1
return 0
def on_generalOK_clicked(self, widget):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.generalValue = OK
def on_generalNo_clicked(self, widget):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.generalValue = NO
def on_generalCancel_clicked(self, widget):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.generalValue = CANCEL
def on_generalTryagain_clicked(self, widget):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.generalValue = TRYAGAIN
def on_generalReadonly_clicked(self, widget):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
self.generalValue = READONLY
def get_field1(self):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
return self.field1
def get_field2(self):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
return self.field2
def get_value(self):
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2]
return self.generalValue
def __init__(self, gui, title, prompt, buttons, num_fields = 0, secretp = 0, feedback = "",
field1_label = "", field1_default = "",
field2_label = "", field2_default = ""):
self.gui = gui
if self.gui.debug:
print inspect.getframeinfo(inspect.currentframe())[2], vars()
callbacks = {
# General popup:
"on_generalField1_key_press_event": self.on_generalField1_key_press_event,
"on_generalField2_key_press_event": self.on_generalField2_key_press_event,
"on_generalOK_clicked": self.on_generalOK_clicked,
"on_generalNo_clicked": self.on_generalNo_clicked,
"on_generalCancel_clicked": self.on_generalCancel_clicked,
"on_generalTryagain_clicked": self.on_generalTryagain_clicked,
"on_generalReadonly_clicked": self.on_generalReadonly_clicked,
}
self.field1 = field1_default
self.field2 = field2_default
self.generalNumFields = num_fields
self.name = "generalDialog"
self.filename = self.gui.sharedir + "ui/generalDialog.ui"
if self.gui.builder:
self.gui.builder.add_from_file(self.filename)
self.gui.builder.connect_signals(callbacks)
self.general_get_widget = self.gui.gui_get_widget
else:
self.xml = gtk.glade.XML(self.gui.gui_filename, self.name, domain="gjots2")
self.xml.signal_autoconnect(callbacks)
self.general_get_widget = self.xml.get_widget
self.general_dialog = self.general_get_widget(self.name)
#gtk.Widget.show(self)
self.general_dialog.set_transient_for(self.gui.gjots)
self.general_dialog.set_title(title)
self.general_get_widget("generalPromptLabel").set_label(prompt)
if num_fields < 1:
self.general_get_widget("generalLabel1").hide()
self.general_get_widget("generalField1").hide()
else:
self.general_get_widget("generalLabel1").set_label(field1_label)
self.general_get_widget("generalLabel1").show()
self.general_get_widget("generalField1").set_text(field1_default)
self.general_get_widget("generalField1").set_visibility(not secretp)
self.general_get_widget("generalField1").show()
if num_fields < 2:
self.general_get_widget("generalLabel2").hide()
self.general_get_widget("generalField2").hide()
else:
self.general_get_widget("generalLabel2").set_label(field2_label)
self.general_get_widget("generalLabel2").show()
self.general_get_widget("generalField2").set_text(field2_default)
self.general_get_widget("generalField2").set_visibility(not secretp)
self.general_get_widget("generalField2").show()
if feedback:
self.general_get_widget("generalFeedback").set_label(feedback)
self.general_get_widget("generalFeedback").show()
else:
self.general_get_widget("generalFeedback").hide()
if (buttons & YES or buttons & OK):
self.general_get_widget("generalOK").show()
if (buttons & YES):
self.general_get_widget("generalOK").set_label(_("Yes"))
else:
self.general_get_widget("generalOK").hide()
if (buttons & NO):
self.general_get_widget("generalNo").show()
else:
self.general_get_widget("generalNo").hide()
if (buttons & CANCEL):
self.general_get_widget("generalCancel").show()
else:
self.general_get_widget("generalCancel").hide()
if (buttons & READONLY):
self.general_get_widget("generalReadonly").show()
else:
self.general_get_widget("generalReadonly").hide()
if (buttons & TRYAGAIN):
self.general_get_widget("generalTryagain").show()
else:
self.general_get_widget("generalTryagain").hide()
self.generalValue = WAITING
while self.generalValue == WAITING:
gtk.main_iteration()
if self.generalValue == OK:
if num_fields > 1:
self.field2 = self.general_get_widget("generalField2").get_text()
if num_fields > 0:
self.field1 = self.general_get_widget("generalField1").get_text()
self.general_get_widget(self.name).destroy()
# Local variables:
# eval:(setq compile-command "cd ..; ./gjots2 test.gjots")
# eval:(setq-default indent-tabs-mode 1)
# eval:(setq tab-width 4)
# eval:(setq python-indent 4)
# End:
|