Version bump
[ejpi] / src / ejpi_glade.py
index d2cdbd8..507a345 100755 (executable)
@@ -135,19 +135,20 @@ class ErrorDisplay(history.ErrorReporting):
 
 class Calculator(object):
 
-       __pretty_app_name__ = "e^(j pi) + 1 = 0"
+       __pretty_app_name__ = "e**(j pi) + 1 = 0"
        __app_name__ = "ejpi"
-       __version__ = "0.1.0"
+       __version__ = "0.9.3"
        __app_magic__ = 0xdeadbeef
 
        _glade_files = [
-               '/usr/lib/ejpi/calc.glade',
-               os.path.join(os.path.dirname(__file__), "calc.glade"),
-               os.path.join(os.path.dirname(__file__), "../lib/calc.glade"),
+               '/usr/lib/ejpi/ejpi.glade',
+               os.path.join(os.path.dirname(__file__), "ejpi.glade"),
+               os.path.join(os.path.dirname(__file__), "../lib/ejpi.glade"),
        ]
 
        _plugin_search_paths = [
-               os.path.join(os.path.dirname(__file__), "plugins/")
+               "/usr/lib/ejpi/plugins/",
+               os.path.join(os.path.dirname(__file__), "plugins/"),
        ]
 
        _user_data = os.path.expanduser("~/.%s/" % __app_name__)
@@ -157,17 +158,21 @@ class Calculator(object):
        def __init__(self):
                self.__constantPlugins = plugin_utils.ConstantPluginManager()
                self.__constantPlugins.add_path(*self._plugin_search_paths)
-               self.__constantPlugins.enable_plugin(self.__constantPlugins.lookup_plugin("Builtin"))
-               self.__constantPlugins.enable_plugin(self.__constantPlugins.lookup_plugin("Trigonometry"))
-               self.__constantPlugins.enable_plugin(self.__constantPlugins.lookup_plugin("Computer"))
-               self.__constantPlugins.enable_plugin(self.__constantPlugins.lookup_plugin("Alphabet"))
+               for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+                       try:
+                               pluginId = self.__constantPlugins.lookup_plugin(pluginName)
+                               self.__constantPlugins.enable_plugin(pluginId)
+                       except:
+                               warnings.warn("Failed to load plugin %s" % pluginName)
 
                self.__operatorPlugins = plugin_utils.OperatorPluginManager()
                self.__operatorPlugins.add_path(*self._plugin_search_paths)
-               self.__operatorPlugins.enable_plugin(self.__operatorPlugins.lookup_plugin("Builtin"))
-               self.__operatorPlugins.enable_plugin(self.__operatorPlugins.lookup_plugin("Trigonometry"))
-               self.__operatorPlugins.enable_plugin(self.__operatorPlugins.lookup_plugin("Computer"))
-               self.__operatorPlugins.enable_plugin(self.__operatorPlugins.lookup_plugin("Alphabet"))
+               for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+                       try:
+                               pluginId = self.__operatorPlugins.lookup_plugin(pluginName)
+                               self.__operatorPlugins.enable_plugin(pluginId)
+                       except:
+                               warnings.warn("Failed to load plugin %s" % pluginName)
 
                self.__keyboardPlugins = plugin_utils.KeyboardPluginManager()
                self.__keyboardPlugins.add_path(*self._plugin_search_paths)
@@ -178,7 +183,7 @@ class Calculator(object):
                                self._widgetTree = gtk.glade.XML(path)
                                break
                else:
-                       self.display_error_message("Cannot find calc.glade")
+                       self.display_error_message("Cannot find ejpi.glade")
                        gtk.main_quit()
                try:
                        os.makedirs(self._user_data)
@@ -192,10 +197,7 @@ class Calculator(object):
                global hildon
                self._app = None
                self._isFullScreen = False
-               if hildon is not None and self.__window is gtk.Window:
-                       warnings.warn("Hildon installed but glade file not updated to work with hildon", UserWarning, 2)
-                       hildon = None
-               elif hildon is not None:
+               if hildon is not None:
                        self._app = hildon.Program()
                        self.__window = hildon.Window()
                        self._widgetTree.get_widget("mainLayout").reparent(self.__window)
@@ -212,7 +214,7 @@ class Calculator(object):
                        self.__window.connect("key-press-event", self._on_key_press)
                        self.__window.connect("window-state-event", self._on_window_state_change)
                else:
-                       warnings.warn("No Hildon", UserWarning, 2)
+                       pass # warnings.warn("No Hildon", UserWarning, 2)
 
                self.__errorDisplay = ErrorDisplay(self._widgetTree)
                self.__userEntry = ValueEntry(self._widgetTree.get_widget("entryView"))
@@ -226,7 +228,7 @@ class Calculator(object):
                )
                self.__load_history()
 
-               self.__sliceStyle = gtkpie.generate_pie_style(self.__window)
+               self.__sliceStyle = gtkpie.generate_pie_style(gtk.Button())
                self.__handler = gtkpieboard.KeyboardHandler(self._on_entry_direct)
                self.__handler.register_command_handler("push", self._on_push)
                self.__handler.register_command_handler("unpush", self._on_unpush)
@@ -246,7 +248,7 @@ class Calculator(object):
                callbackMapping = {
                        "on_calculator_quit": self._on_close,
                        "on_paste": self._on_paste,
-                       "on_clear_entry": self._on_clear_all,
+                       "on_clear_history": self._on_clear_all,
                        "on_about": self._on_about_activate,
                }
                self._widgetTree.signal_autoconnect(callbackMapping)
@@ -268,7 +270,7 @@ class Calculator(object):
                        device = osso.DeviceState(self._osso)
                        device.set_device_state_callback(self._on_device_state_change, 0)
                else:
-                       warnings.warn("No OSSO", UserWarning, 2)
+                       pass # warnings.warn("No OSSO", UserWarning, 2)
 
        def display_error_message(self, msg):
                error_dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, msg)
@@ -403,6 +405,7 @@ def run_doctest():
 def run_calculator():
        gtk.gdk.threads_init()
 
+       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__)
        handle = Calculator()
@@ -433,5 +436,4 @@ if __name__ == "__main__":
        if commandOptions.test:
                run_doctest()
        else:
-               gtkpie.IMAGES.add_path(os.path.join(os.path.dirname(__file__), "libraries/images"), )
                run_calculator()