[gedit] Adapt to peas api change.



commit 38e01213a0d961048c539e7609e63aae31b46daa
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Jul 1 18:41:25 2010 +0200

    Adapt to peas api change.
    
    Now we need to return the configure widget instead of the whole dialog.

 plugins/pythonconsole/pythonconsole/__init__.py |   15 ++------
 plugins/pythonconsole/pythonconsole/config.py   |   38 +++++++++--------------
 plugins/pythonconsole/pythonconsole/config.ui   |    4 ++-
 3 files changed, 22 insertions(+), 35 deletions(-)
---
diff --git a/plugins/pythonconsole/pythonconsole/__init__.py b/plugins/pythonconsole/pythonconsole/__init__.py
index 4c31c84..1de0709 100644
--- a/plugins/pythonconsole/pythonconsole/__init__.py
+++ b/plugins/pythonconsole/pythonconsole/__init__.py
@@ -27,7 +27,7 @@
 from gi.repository import GObject, Gtk, Gedit, Peas, PeasUI
 
 from console import PythonConsole
-from config import PythonConsoleConfigDialog
+from config import PythonConsoleConfigWidget
 
 PYTHON_ICON = 'gnome-mime-text-x-python'
 
@@ -36,7 +36,6 @@ class PythonConsolePlugin(GObject.Object, Gedit.WindowActivatable, PeasUI.Config
 
     def __init__(self):
         GObject.Object.__init__(self)
-        self._dlg = None
 
     def do_activate(self, window):
         self._console = PythonConsole(namespace = {'__builtins__' : __builtins__,
@@ -55,15 +54,9 @@ class PythonConsolePlugin(GObject.Object, Gedit.WindowActivatable, PeasUI.Config
         bottom = window.get_bottom_panel()
         bottom.remove_item(self._console)
 
-    def do_create_configure_dialog(self):
-        if not self._dlg:
-            self._dlg = PythonConsoleConfigDialog(self.plugin_info.get_data_dir())
+    def do_create_configure_widget(self):
+        config_widget = PythonConsoleConfigWidget(self.plugin_info.get_data_dir())
 
-        dialog = self._dlg.dialog()
-
-        app = Gedit.App.get_default()
-        dialog.set_transient_for(app.get_active_window())
-
-        return dialog
+        return config_widget.configure_widget()
 
 # ex:et:ts=4:
diff --git a/plugins/pythonconsole/pythonconsole/config.py b/plugins/pythonconsole/pythonconsole/config.py
index 117916b..ad5cdc6 100644
--- a/plugins/pythonconsole/pythonconsole/config.py
+++ b/plugins/pythonconsole/pythonconsole/config.py
@@ -29,7 +29,7 @@ from gi.repository import Gio, Gtk, Gdk
 
 __all__ = ('PythonConsoleConfigDialog')
 
-class PythonConsoleConfigDialog(object):
+class PythonConsoleConfigWidget(object):
 
     CONSOLE_KEY_BASE = 'org.gnome.gedit.plugins.pythonconsole'
     CONSOLE_KEY_COMMAND_COLOR = 'command-color'
@@ -37,28 +37,27 @@ class PythonConsoleConfigDialog(object):
 
     def __init__(self, datadir):
         object.__init__(self)
-        self._dialog = None
+
         self._ui_path = os.path.join(datadir, 'ui', 'config.ui')
         self._settings = Gio.Settings.new(self.CONSOLE_KEY_BASE)
+        self._ui = Gtk.Builder()
 
-    def dialog(self):
-        if self._dialog is None:
-            self._ui = Gtk.Builder()
-            self._ui.add_from_file(self._ui_path)
+    def configure_widget(self):
+        try:
+            self._ui.add_objects_from_file(self._ui_path, ["table"])
+        except:
+            return None
 
-            self.set_colorbutton_color(self._ui.get_object('colorbutton-command'),
-                                       self._settings.get_string(self.CONSOLE_KEY_COMMAND_COLOR))
-            self.set_colorbutton_color(self._ui.get_object('colorbutton-error'),
-                                       self._settings.get_string(self.CONSOLE_KEY_ERROR_COLOR))
+        self.set_colorbutton_color(self._ui.get_object('colorbutton-command'),
+                                   self._settings.get_string(self.CONSOLE_KEY_COMMAND_COLOR))
+        self.set_colorbutton_color(self._ui.get_object('colorbutton-error'),
+                                   self._settings.get_string(self.CONSOLE_KEY_ERROR_COLOR))
 
-            self._ui.connect_signals(self)
+        self._ui.connect_signals(self)
 
-            self._dialog = self._ui.get_object('dialog-config')
-            self._dialog.show_all()
-        else:
-            self._dialog.present()
+        widget = self._ui.get_object('table')
 
-        return self._dialog
+        return widget
 
     @staticmethod
     def set_colorbutton_color(colorbutton, value):
@@ -67,13 +66,6 @@ class PythonConsoleConfigDialog(object):
         if parsed:
             colorbutton.set_color(color)
 
-    def on_dialog_config_response(self, dialog, response_id):
-        self._dialog.destroy()
-
-    def on_dialog_config_destroy(self, dialog):
-        self._dialog = None
-        self._ui = None
-        
     def on_colorbutton_command_color_set(self, colorbutton):
         self._settings.set_string(self.CONSOLE_KEY_COMMAND_COLOR,
                                   colorbutton.get_color().to_string())
diff --git a/plugins/pythonconsole/pythonconsole/config.ui b/plugins/pythonconsole/pythonconsole/config.ui
index 4ffe26f..0a6863d 100644
--- a/plugins/pythonconsole/pythonconsole/config.ui
+++ b/plugins/pythonconsole/pythonconsole/config.ui
@@ -13,7 +13,7 @@
       <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
         <child>
-          <object class="GtkTable" id="table2">
+          <object class="GtkTable" id="table">
             <property name="visible">True</property>
             <property name="border_width">6</property>
             <property name="n_rows">2</property>
@@ -88,6 +88,8 @@
                 <property name="use_stock">True</property>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]