[gtranslator] [tab] Activate extensions when the tab is realized.



commit 40ff5d7d0f4e19c0bb4b5ff8a605f4960b3dc491
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue May 3 16:16:26 2011 +0200

    [tab] Activate extensions when the tab is realized.

 plugins/open-tran/gtr-open-tran-plugin.c |    2 +-
 src/gtr-tab.c                            |   23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/plugins/open-tran/gtr-open-tran-plugin.c b/plugins/open-tran/gtr-open-tran-plugin.c
index 69d0e30..5b1642b 100644
--- a/plugins/open-tran/gtr-open-tran-plugin.c
+++ b/plugins/open-tran/gtr-open-tran-plugin.c
@@ -158,7 +158,7 @@ gtr_open_tran_plugin_activate (GtrTabActivatable *activatable)
                                  "open-tran-plugin-icon");
 
   priv->opentran = gtr_open_tran_panel_new (priv->tab);
-  gtk_widget_show (priv->opentran);
+  gtk_widget_show_all (priv->opentran);
 
   gtr_tab_add_widget (priv->tab,
                       priv->opentran,
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 21419e9..3d799e9 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -117,6 +117,8 @@ struct _GtrTabPrivate
 
   /*Blocking movement */
   guint blocking : 1;
+
+  guint tab_realized : 1;
 };
 
 enum
@@ -890,7 +892,6 @@ gtr_tab_init (GtrTab * tab)
                     "extension-removed",
                     G_CALLBACK (extension_removed),
                     tab);
-  peas_extension_set_call (tab->priv->extensions, "activate");
 }
 
 static void
@@ -998,9 +999,26 @@ gtr_tab_set_property (GObject * object,
 }
 
 static void
+gtr_tab_realize (GtkWidget *widget)
+{
+  GtrTab *tab = GTR_TAB (widget);
+
+  if (!tab->priv->tab_realized)
+    {
+      /* We only activate the extensions when the tab is realized,
+       * because most plugins will expect this behaviour. */
+      peas_extension_set_call (tab->priv->extensions, "activate");
+      tab->priv->tab_realized = TRUE;
+    }
+
+  GTK_WIDGET_CLASS (gtr_tab_parent_class)->realize (widget);
+}
+
+static void
 gtr_tab_class_init (GtrTabClass * klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   g_type_class_add_private (klass, sizeof (GtrTabPrivate));
 
@@ -1008,6 +1026,9 @@ gtr_tab_class_init (GtrTabClass * klass)
   object_class->dispose = gtr_tab_dispose;
   object_class->set_property = gtr_tab_set_property;
   object_class->get_property = gtr_tab_get_property;
+
+  widget_class->realize = gtr_tab_realize;
+
   klass->message_edition_finished = gtr_tab_edition_finished;
 
   /* Signals */



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