[gtranslator] [plugins] Use Tab activatable and update for new api.



commit 3f59acf55ef4463f941a5400f47cd09b6b1bd9e4
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue May 3 15:58:25 2011 +0200

    [plugins] Use Tab activatable and update for new api.

 .../gtr-alternate-language-plugin.c                |   18 +++---
 plugins/charmap/charmap/__init__.py                |   14 +++--
 plugins/dictionary/gtr-dict-panel.h                |    2 +-
 plugins/dictionary/gtr-dictionary-plugin.c         |   62 ++++++++++----------
 plugins/open-tran/gtr-open-tran-panel.c            |   10 ++--
 plugins/open-tran/gtr-open-tran-panel.h            |    2 +-
 plugins/open-tran/gtr-open-tran-plugin.c           |   54 +++++++++---------
 7 files changed, 81 insertions(+), 81 deletions(-)
---
diff --git a/plugins/alternate-language/gtr-alternate-language-plugin.c b/plugins/alternate-language/gtr-alternate-language-plugin.c
index b3ec458..c2e4d39 100644
--- a/plugins/alternate-language/gtr-alternate-language-plugin.c
+++ b/plugins/alternate-language/gtr-alternate-language-plugin.c
@@ -67,7 +67,7 @@ on_alternate_lang_activated (GtkAction *action,
   tab = gtr_window_get_active_tab (window);
   alternatelang = g_object_get_data (G_OBJECT (tab), TAB_DATA_KEY);
 
-  gtr_tab_show_lateral_panel_widget (GTR_TAB (tab), alternatelang);
+  gtr_tab_show_widget (GTR_TAB (tab), alternatelang);
 }
 
 static const GtkActionEntry action_entries[] = {
@@ -171,9 +171,12 @@ create_alternate_lang_plugin_panel (GtkNotebook * notebook,
   alternatelang = gtr_alternate_lang_panel_new (child);
   gtk_widget_show (alternatelang);
 
-  gtr_tab_add_widget_to_lateral_panel (GTR_TAB (child),
-                                       alternatelang,
-                                       _("Alternate Language"));
+  gtr_tab_add_widget (GTR_TAB (child),
+                      alternatelang,
+                      "GtrAlternateLangPluginPanel",
+                      _("Alternate Language"),
+                      NULL,
+                      GTR_TAB_PLACEMENT_RIGHT);
 
   g_object_set_data (G_OBJECT (child), TAB_DATA_KEY, alternatelang);
 }
@@ -239,11 +242,8 @@ gtr_alternate_lang_plugin_deactivate (GtrWindowActivatable *activatable)
     {
       do
         {
-          alternatelang =
-            g_object_get_data (G_OBJECT (tabs->data), TAB_DATA_KEY);
-          gtr_tab_remove_widget_from_lateral_panel (GTR_TAB
-                                                    (tabs->data),
-                                                    alternatelang);
+          alternatelang = g_object_get_data (G_OBJECT (tabs->data), TAB_DATA_KEY);
+          gtr_tab_remove_widget (GTR_TAB (tabs->data), alternatelang);
 
           g_object_set_data (G_OBJECT (tabs->data), TAB_DATA_KEY, NULL);
         }
diff --git a/plugins/charmap/charmap/__init__.py b/plugins/charmap/charmap/__init__.py
index 1dc0737..7b6b190 100644
--- a/plugins/charmap/charmap/__init__.py
+++ b/plugins/charmap/charmap/__init__.py
@@ -22,10 +22,10 @@ from panel import CharmapPanel
 import sys
 import gettext
 
-class CharmapPlugin(GObject.Object, Gtranslator.WindowActivatable):
+class CharmapPlugin(GObject.Object, Gtranslator.TabActivatable):
     __gtype_name__ = "CharmapPlugin"
 
-    window = GObject.property(type=Gtranslator.Window)
+    tab = GObject.property(type=Gtranslator.Tab)
 
     def __init__(self):
         GObject.Object.__init__(self)
@@ -37,18 +37,20 @@ class CharmapPlugin(GObject.Object, Gtranslator.WindowActivatable):
         self.system_settings = Gio.Settings.new("org.gnome.desktop.interface")
         self.system_settings.connect("changed::monospace-font-name", self.font_changed)
 
+        self.window = self.tab.get_toplevel()
+
         self.create_charmap_panel()
-        self.window.add_widget(self.panel, "GtranslatorCharmapPanel", _("Character Map"),
-                               "accessories-character-map", Gtranslator.WindowPlacement.LEFT)
+        self.tab.add_widget(self.panel, "GtrCharmapPanel", _("Character Map"),
+                            "accessories-character-map", Gtranslator.TabPlacement.LEFT)
 
         statusbar = self.window.get_statusbar()
         self.context_id = statusbar.get_context_id("Character Description")
 
     def do_deactivate(self):
-        self.window.remove_widget(self.panel)
+        self.tab.remove_widget(self.panel)
 
     def do_update_state(self):
-        self.panel.set_sensitive(len(self.window.get_all_tabs()) >= 1)
+        pass
 
     def get_document_font(self):
         if self.editor_settings.get_boolean("use-custom-font"):
diff --git a/plugins/dictionary/gtr-dict-panel.h b/plugins/dictionary/gtr-dict-panel.h
index 514ff03..c7a4b42 100644
--- a/plugins/dictionary/gtr-dict-panel.h
+++ b/plugins/dictionary/gtr-dict-panel.h
@@ -57,7 +57,7 @@ struct _GtrDictPanelClass
  */
 GType gtr_dict_panel_get_type (void) G_GNUC_CONST;
 
-GtkWidget *gtr_dict_panel_new (GtrWindow * window);
+GtkWidget *gtr_dict_panel_new (GtrWindow *window);
 
 void _gtr_dict_panel_register_type (GTypeModule *type_module);
 
diff --git a/plugins/dictionary/gtr-dictionary-plugin.c b/plugins/dictionary/gtr-dictionary-plugin.c
index 03fc166..8c9833c 100644
--- a/plugins/dictionary/gtr-dictionary-plugin.c
+++ b/plugins/dictionary/gtr-dictionary-plugin.c
@@ -23,7 +23,8 @@
 #include "gtr-dictionary-plugin.h"
 #include "gtr-dict-panel.h"
 #include "gtr-window.h"
-#include "gtr-window-activatable.h"
+#include "gtr-tab.h"
+#include "gtr-tab-activatable.h"
 
 #include <libpeas-gtk/peas-gtk-configurable.h>
 #include <glib/gi18n-lib.h>
@@ -36,40 +37,38 @@
 
 struct _GtrDictPluginPrivate
 {
-  GtrWindow *window;
+  GtrTab *tab;
   GtkWidget *dict;
 };
 
 enum
 {
   PROP_0,
-  PROP_WINDOW
+  PROP_TAB
 };
 
-static void gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface);
+static void gtr_tab_activatable_iface_init (GtrTabActivatableInterface *iface);
 
 G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtrDictPlugin,
                                 gtr_dict_plugin,
                                 PEAS_TYPE_EXTENSION_BASE,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC
-                                (GTR_TYPE_WINDOW_ACTIVATABLE,
-                                 gtr_window_activatable_iface_init)
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_TAB_ACTIVATABLE,
+                                                               gtr_tab_activatable_iface_init)
                                 _gtr_dict_panel_register_type (type_module))
 
 static GtkWidget *
-create_dict_panel (GtrWindow * window)
+create_dict_panel (GtrTab *tab)
 {
   GtkWidget *panel;
 
-  panel = gtr_dict_panel_new (window);
+  panel = gtr_dict_panel_new (GTR_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))));
 
   gtk_widget_show (panel);
 
   return panel;
 }
 
-
 static void
 gtr_dict_plugin_set_property (GObject * object,
                               guint prop_id,
@@ -80,8 +79,8 @@ gtr_dict_plugin_set_property (GObject * object,
 
   switch (prop_id)
     {
-    case PROP_WINDOW:
-      priv->window = GTR_WINDOW (g_value_dup_object (value));
+    case PROP_TAB:
+      priv->tab = GTR_TAB (g_value_dup_object (value));
       break;
 
     default:
@@ -99,8 +98,8 @@ gtr_dict_plugin_get_property (GObject * object,
 
   switch (prop_id)
     {
-    case PROP_WINDOW:
-      g_value_set_object (value, priv->window);
+    case PROP_TAB:
+      g_value_set_object (value, priv->tab);
       break;
 
     default:
@@ -109,7 +108,6 @@ gtr_dict_plugin_get_property (GObject * object,
     }
 }
 
-
 static void
 gtr_dict_plugin_init (GtrDictPlugin * plugin)
 {
@@ -121,39 +119,39 @@ gtr_dict_plugin_dispose (GObject * object)
 {
   GtrDictPluginPrivate *priv = GTR_DICT_PLUGIN (object)->priv;
 
-  if (priv->window != NULL)
+  if (priv->tab != NULL)
     {
-      g_object_unref (priv->window);
-      priv->window = NULL;
+      g_object_unref (priv->tab);
+      priv->tab = NULL;
     }
 
   G_OBJECT_CLASS (gtr_dict_plugin_parent_class)->dispose (object);
 }
 
 static void
-gtr_dict_plugin_activate (GtrWindowActivatable * activatable)
+gtr_dict_plugin_activate (GtrTabActivatable * activatable)
 {
   GtrDictPluginPrivate *priv = GTR_DICT_PLUGIN (activatable)->priv;
 
   gtr_application_register_icon (GTR_APP, "gnome-dictionary.png",
                                  "dictionary-icon");
 
-  priv->dict = create_dict_panel (priv->window);
+  priv->dict = create_dict_panel (priv->tab);
 
-  gtr_window_add_widget (priv->window,
-                         priv->dict,
-                         "GtrDictionaryPlugin",
-                         _("Dictionary"),
-                         "dictionary-icon",
-                         GTR_WINDOW_PLACEMENT_LEFT);
+  gtr_tab_add_widget (priv->tab,
+                      priv->dict,
+                      "GtrDictionaryPlugin",
+                      _("Dictionary"),
+                      "dictionary-icon",
+                      GTR_TAB_PLACEMENT_LEFT);
 }
 
 static void
-gtr_dict_plugin_deactivate (GtrWindowActivatable * activatable)
+gtr_dict_plugin_deactivate (GtrTabActivatable * activatable)
 {
   GtrDictPluginPrivate *priv = GTR_DICT_PLUGIN (activatable)->priv;
 
-  gtr_window_remove_widget (priv->window, priv->dict);
+  gtr_tab_remove_widget (priv->tab, priv->dict);
 }
 
 static void
@@ -165,7 +163,7 @@ gtr_dict_plugin_class_init (GtrDictPluginClass * klass)
   object_class->set_property = gtr_dict_plugin_set_property;
   object_class->get_property = gtr_dict_plugin_get_property;
 
-  g_object_class_override_property (object_class, PROP_WINDOW, "window");
+  g_object_class_override_property (object_class, PROP_TAB, "tab");
   g_type_class_add_private (object_class, sizeof (GtrDictPluginPrivate));
 }
 
@@ -175,7 +173,7 @@ gtr_dict_plugin_class_finalize (GtrDictPluginClass * klass)
 }
 
 static void
-gtr_window_activatable_iface_init (GtrWindowActivatableInterface * iface)
+gtr_tab_activatable_iface_init (GtrTabActivatableInterface * iface)
 {
   iface->activate = gtr_dict_plugin_activate;
   iface->deactivate = gtr_dict_plugin_deactivate;
@@ -187,6 +185,6 @@ peas_register_types (PeasObjectModule * module)
   gtr_dict_plugin_register_type (G_TYPE_MODULE (module));
 
   peas_object_module_register_extension_type (module,
-      GTR_TYPE_WINDOW_ACTIVATABLE,
-      GTR_TYPE_DICT_PLUGIN);
+                                              GTR_TYPE_TAB_ACTIVATABLE,
+                                              GTR_TYPE_DICT_PLUGIN);
 }
diff --git a/plugins/open-tran/gtr-open-tran-panel.c b/plugins/open-tran/gtr-open-tran-panel.c
index 9279983..0cc9c06 100644
--- a/plugins/open-tran/gtr-open-tran-panel.c
+++ b/plugins/open-tran/gtr-open-tran-panel.c
@@ -68,8 +68,8 @@ struct _GtrOpenTranPanelPrivate
   
   GtkWidget *entry;
 
-  GtrWindow *window;
-  
+  GtkWidget *window;
+
   gchar *text;
 };
 
@@ -82,7 +82,7 @@ enum
 };
 
 static void
-show_error_dialog (GtrWindow * parent,
+show_error_dialog (GtkWidget * parent,
                    const gchar * message_format, ...)
 {
   gchar *msg = NULL;
@@ -558,13 +558,13 @@ gtr_open_tran_panel_class_finalize (GtrOpenTranPanelClass *klass)
 }
 
 GtkWidget *
-gtr_open_tran_panel_new (GtrWindow * window)
+gtr_open_tran_panel_new (GtrTab *tab)
 {
   GtrOpenTranPanel *panel;
 
   panel = g_object_new (GTR_TYPE_OPEN_TRAN_PANEL, NULL);
 
-  panel->priv->window = window;
+  panel->priv->window = gtk_widget_get_toplevel (GTK_WIDGET (tab));
 
   return GTK_WIDGET (panel);
 }
diff --git a/plugins/open-tran/gtr-open-tran-panel.h b/plugins/open-tran/gtr-open-tran-panel.h
index 041e744..4b0ecc4 100644
--- a/plugins/open-tran/gtr-open-tran-panel.h
+++ b/plugins/open-tran/gtr-open-tran-panel.h
@@ -59,7 +59,7 @@ struct _GtrOpenTranPanelClass
 
 GType gtr_open_tran_panel_get_type (void) G_GNUC_CONST;
 
-GtkWidget *gtr_open_tran_panel_new (GtrWindow * window);
+GtkWidget *gtr_open_tran_panel_new (GtrTab * window);
 
 void _gtr_open_tran_panel_register_type (GTypeModule *type_module);
 
diff --git a/plugins/open-tran/gtr-open-tran-plugin.c b/plugins/open-tran/gtr-open-tran-plugin.c
index c4d7128..69d0e30 100644
--- a/plugins/open-tran/gtr-open-tran-plugin.c
+++ b/plugins/open-tran/gtr-open-tran-plugin.c
@@ -25,8 +25,8 @@
 #include "gtr-open-tran-panel.h"
 #include "gtr-application.h"
 #include "gtr-dirs.h"
-#include "gtr-window.h"
-#include "gtr-window-activatable.h"
+#include "gtr-tab.h"
+#include "gtr-tab-activatable.h"
 #include "gtr-utils.h"
 
 #include <libpeas-gtk/peas-gtk-configurable.h>
@@ -45,7 +45,7 @@ struct _GtrOpenTranPluginPrivate
 {
   GSettings *settings;
 
-  GtrWindow *window;
+  GtrTab *tab;
   GtkWidget *opentran;
 
   GtkWidget *main_box;
@@ -59,18 +59,18 @@ struct _GtrOpenTranPluginPrivate
 enum
 {
   PROP_0,
-  PROP_WINDOW
+  PROP_TAB
 };
 
-static void gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface);
+static void gtr_tab_activatable_iface_init (GtrTabActivatableInterface *iface);
 static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
 
 G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtrOpenTranPlugin,
                                 gtr_open_tran_plugin,
                                 PEAS_TYPE_EXTENSION_BASE,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_WINDOW_ACTIVATABLE,
-                                                               gtr_window_activatable_iface_init)
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_TAB_ACTIVATABLE,
+                                                               gtr_tab_activatable_iface_init)
                                 G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
                                                                peas_gtk_configurable_iface_init) \
                                                                                                  \
@@ -100,10 +100,10 @@ gtr_open_tran_plugin_dispose (GObject * object)
       priv->settings = NULL;
     }
 
-  if (priv->window != NULL)
+  if (priv->tab != NULL)
     {
-      g_object_unref (priv->window);
-      priv->window = NULL;
+      g_object_unref (priv->tab);
+      priv->tab = NULL;
     }
 
   G_OBJECT_CLASS (gtr_open_tran_plugin_parent_class)->dispose (object);
@@ -119,8 +119,8 @@ gtr_open_tran_plugin_set_property (GObject      *object,
 
   switch (prop_id)
     {
-      case PROP_WINDOW:
-        priv->window = GTR_WINDOW (g_value_dup_object (value));
+      case PROP_TAB:
+        priv->tab = GTR_TAB (g_value_dup_object (value));
         break;
 
       default:
@@ -139,8 +139,8 @@ gtr_open_tran_plugin_get_property (GObject    *object,
 
   switch (prop_id)
     {
-      case PROP_WINDOW:
-        g_value_set_object (value, priv->window);
+      case PROP_TAB:
+        g_value_set_object (value, priv->tab);
         break;
 
       default:
@@ -150,30 +150,30 @@ gtr_open_tran_plugin_get_property (GObject    *object,
 }
 
 static void
-gtr_open_tran_plugin_activate (GtrWindowActivatable *activatable)
+gtr_open_tran_plugin_activate (GtrTabActivatable *activatable)
 {
   GtrOpenTranPluginPrivate *priv = GTR_OPEN_TRAN_PLUGIN (activatable)->priv;
 
   gtr_application_register_icon (GTR_APP, "open-tran.png",
                                  "open-tran-plugin-icon");
 
-  priv->opentran = gtr_open_tran_panel_new (priv->window);
+  priv->opentran = gtr_open_tran_panel_new (priv->tab);
   gtk_widget_show (priv->opentran);
 
-  gtr_window_add_widget (priv->window,
-                         priv->opentran,
-                         "GtrOpenTranPlugin",
-                         _("Open Tran"),
-                         "open-tran-plugin-icon",
-                         GTR_WINDOW_PLACEMENT_LEFT);
+  gtr_tab_add_widget (priv->tab,
+                      priv->opentran,
+                      "GtrOpenTranPlugin",
+                      _("Open Tran"),
+                      "open-tran-plugin-icon",
+                      GTR_TAB_PLACEMENT_LEFT);
 }
 
 static void
-gtr_open_tran_plugin_deactivate (GtrWindowActivatable *activatable)
+gtr_open_tran_plugin_deactivate (GtrTabActivatable *activatable)
 {
   GtrOpenTranPluginPrivate *priv = GTR_OPEN_TRAN_PLUGIN (activatable)->priv;
 
-  gtr_window_remove_widget (priv->window, priv->opentran);
+  gtr_tab_remove_widget (priv->tab, priv->opentran);
 }
 
 static void
@@ -265,7 +265,7 @@ gtr_open_tran_plugin_class_init (GtrOpenTranPluginClass * klass)
   object_class->set_property = gtr_open_tran_plugin_set_property;
   object_class->get_property = gtr_open_tran_plugin_get_property;
 
-  g_object_class_override_property (object_class, PROP_WINDOW, "window");
+  g_object_class_override_property (object_class, PROP_TAB, "tab");
 
   g_type_class_add_private (object_class, sizeof (GtrOpenTranPluginPrivate));
 }
@@ -282,7 +282,7 @@ peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
 }
 
 static void
-gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface)
+gtr_tab_activatable_iface_init (GtrTabActivatableInterface *iface)
 {
   iface->activate = gtr_open_tran_plugin_activate;
   iface->deactivate = gtr_open_tran_plugin_deactivate;
@@ -294,7 +294,7 @@ peas_register_types (PeasObjectModule *module)
   gtr_open_tran_plugin_register_type (G_TYPE_MODULE (module));
 
   peas_object_module_register_extension_type (module,
-                                              GTR_TYPE_WINDOW_ACTIVATABLE,
+                                              GTR_TYPE_TAB_ACTIVATABLE,
                                               GTR_TYPE_OPEN_TRAN_PLUGIN);
   peas_object_module_register_extension_type (module,
                                               PEAS_GTK_TYPE_CONFIGURABLE,



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