import history
import gtkhistory
import gtk_toolbox
+import constants
PLUGIN_SEARCH_PATHS = [
class Calculator(object):
- __pretty_app_name__ = "e**(j pi) + 1 = 0"
- __app_name__ = "ejpi"
- __version__ = "0.9.4"
- __app_magic__ = 0xdeadbeef
-
_glade_files = [
'/usr/lib/ejpi/ejpi.glade',
os.path.join(os.path.dirname(__file__), "ejpi.glade"),
os.path.join(os.path.dirname(__file__), "plugins/"),
]
- _user_data = os.path.expanduser("~/.%s/" % __app_name__)
+ _user_data = os.path.expanduser("~/.%s/" % constants.__app_name__)
_user_settings = "%s/settings.ini" % _user_data
_user_history = "%s/history.stack" % _user_data
else:
self.display_error_message("Cannot find ejpi.glade")
gtk.main_quit()
+ return
try:
os.makedirs(self._user_data)
except OSError, e:
raise
self._clipboard = gtk.clipboard_get()
- self.__window = self._widgetTree.get_widget("mainWindow")
+ self._window = self._widgetTree.get_widget("mainWindow")
- global hildon
self._app = None
self._isFullScreen = False
if hildon is not None:
self._app = hildon.Program()
oldWindow = self._window
- self.__window = hildon.Window()
- oldWindow.get_child().reparent(self.__window)
- self._app.add_window(self.__window)
+ self._window = hildon.Window()
+ oldWindow.get_child().reparent(self._window)
+ self._app.add_window(self._window)
hildon.hildon_helper_set_thumb_scrollbar(self._widgetTree.get_widget('scrollingHistory'), True)
gtkMenu = self._widgetTree.get_widget("mainMenubar")
menu = gtk.Menu()
for child in gtkMenu.get_children():
child.reparent(menu)
- self.__window.set_menu(menu)
+ self._window.set_menu(menu)
gtkMenu.destroy()
- self.__window.connect("key-press-event", self._on_key_press)
- self.__window.connect("window-state-event", self._on_window_state_change)
+ self._window.connect("key-press-event", self._on_key_press)
+ self._window.connect("window-state-event", self._on_window_state_change)
else:
pass # warnings.warn("No Hildon", UserWarning, 2)
self._widgetTree.get_widget("copyMenuItem").connect("activate", self._on_copy)
self._widgetTree.get_widget("copyEquationMenuItem").connect("activate", self._on_copy_equation)
- if self.__window:
- if hildon is None:
- self.__window.set_title("%s" % self.__pretty_app_name__)
- self.__window.connect("destroy", self._on_close)
- self.__window.show_all()
+ if hildon is None:
+ self._window.set_title("%s" % constants.__pretty_app_name__)
+ self._window.connect("destroy", self._on_close)
+ self._window.show_all()
try:
import osso
except ImportError:
osso = None
-
self._osso = None
if osso is not None:
- self._osso = osso.Context(Calculator.__app_name__, Calculator.__version__, False)
+ self._osso = osso.Context(constants.__app_name__, constants.__version__, False)
device = osso.DeviceState(self._osso)
device.set_device_state_callback(self._on_device_state_change, 0)
else:
"""
if event.keyval == gtk.keysyms.F6:
if self._isFullScreen:
- self.__window.unfullscreen()
+ self._window.unfullscreen()
else:
- self.__window.fullscreen()
+ self._window.fullscreen()
def _on_push(self, *args):
self.__history.push_entry()
def _on_about_activate(self, *args):
dlg = gtk.AboutDialog()
- dlg.set_name(self.__pretty_app_name__)
- dlg.set_version(self.__version__)
+ dlg.set_name(constants.__pretty_app_name__)
+ dlg.set_version(constants.__version__)
dlg.set_copyright("Copyright 2008 - LGPL")
dlg.set_comments("""
ejpi A Touch Screen Optimized RPN Calculator for Maemo and Linux.
-How do I use this?
-The buttons are all pie-menus. Clicking on them will give you the default (center) behavior. If you click and hold, the menu gets displayed showing what other actions you can then perform. While still holding, just drag in the direction of one of these actions.
-
-This is RPN, where are the swap, roll, etc operations?
-This also uses a touch screen, go ahead and feel adventerous by dragging the stack items around.
+RPN: Stack based math, its fun
+Buttons: Try both pressing and hold/drag
+History: Try dragging things around, deleting them, etc
""")
dlg.set_website("http://ejpi.garage.maemo.org")
dlg.set_authors(["Ed Page"])
gtkpie.IMAGES.add_path(os.path.join(os.path.dirname(__file__), "libraries/images"), )
if hildon is not None:
- gtk.set_application_name(Calculator.__pretty_app_name__)
+ gtk.set_application_name(constants.__pretty_app_name__)
handle = Calculator()
gtk.main()
#!/usr/bin/python
+from __future__ import with_statement
+
import sys
import traceback
import functools
gtk.gdk.threads_leave()
+def find_parent_window(widget):
+ while True:
+ parent = widget.get_parent()
+ if isinstance(parent, gtk.Window):
+ return parent
+ widget = parent
+
+
def make_idler(func):
"""
Decorator that makes a generator-function into a function that will continue execution on next call
def execute(allArgs):
args, kwargs = allArgs
- original_func(*args, **kwargs)
+ with gtk_lock():
+ original_func(*args, **kwargs)
+ return False
@functools.wraps(original_func)
def delayed_func(*args, **kwargs):
self.__parentBox.remove(self.__errorBox)
def push_message_with_lock(self, message):
- gtk.gdk.threads_enter()
- try:
+ with gtk_lock():
self.push_message(message)
- finally:
- gtk.gdk.threads_leave()
def push_message(self, message):
if 0 < len(self.__messages):
else:
self.__show_message(message)
+ def push_exception_with_lock(self, exception = None):
+ with gtk_lock():
+ self.push_exception(exception)
+
def push_exception(self, exception = None):
if exception is None:
userMessage = str(sys.exc_value)