[gtranslator] Revert "Moved *_draw methods to *_init"



commit 56254775bbd1e74724791eda84a28965de30edd1
Author: Daniel Mustieles <daniel mustieles gmail com>
Date:   Sat Apr 21 14:07:07 2012 +0200

    Revert "Moved *_draw methods to *_init"
    
    This reverts commit c1232fb3da560b24e9bc25b187127adf668078b0.

 .../gtr-alternate-language-panel.c                 |   23 ++--
 plugins/dictionary/gtr-dict-panel.c                |  132 ++++++++++---------
 plugins/glossary/glossary-panel.c                  |    6 +-
 plugins/open-tran/gtr-open-tran-panel.c            |   22 ++--
 src/gtr-message-table.c                            |   27 +++--
 src/gtr-tab.c                                      |   68 ++++++-----
 src/gtr-window.c                                   |   95 ++++++++-------
 7 files changed, 207 insertions(+), 166 deletions(-)
---
diff --git a/plugins/alternate-language/gtr-alternate-language-panel.c b/plugins/alternate-language/gtr-alternate-language-panel.c
index f09cb1e..3de6ad1 100644
--- a/plugins/alternate-language/gtr-alternate-language-panel.c
+++ b/plugins/alternate-language/gtr-alternate-language-panel.c
@@ -295,20 +295,12 @@ copy_button_clicked_cb (GtkWidget             *copy_button,
 }
 
 static void
-gtr_alternate_lang_panel_init (GtrAlternateLangPanel * panel)
+gtr_alternate_lang_panel_draw (GtrAlternateLangPanel * panel)
 {
   GtkWidget *hbox;
   GtkWidget *buttonbox;
   GtkWidget *scroll;
 
-  panel->priv = GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE (panel);
-
-  panel->priv->showed_message_id = 0;
-  panel->priv->po = NULL;
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
-                                  GTK_ORIENTATION_VERTICAL);
-
   /* Hbox */
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_widget_show (hbox);
@@ -370,7 +362,20 @@ gtr_alternate_lang_panel_init (GtrAlternateLangPanel * panel)
                                        GTK_SHADOW_IN);
 
   gtk_box_pack_start (GTK_BOX (panel), scroll, TRUE, TRUE, 0);
+}
+
+static void
+gtr_alternate_lang_panel_init (GtrAlternateLangPanel * panel)
+{
+  panel->priv = GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE (panel);
+
+  panel->priv->showed_message_id = 0;
+  panel->priv->po = NULL;
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
+                                  GTK_ORIENTATION_VERTICAL);
 
+  gtr_alternate_lang_panel_draw (panel);
 }
 
 static void
diff --git a/plugins/dictionary/gtr-dict-panel.c b/plugins/dictionary/gtr-dict-panel.c
index 13eae52..a399d8d 100644
--- a/plugins/dictionary/gtr-dict-panel.c
+++ b/plugins/dictionary/gtr-dict-panel.c
@@ -423,73 +423,11 @@ gtr_dict_panel_link_clicked (GtkWidget * defbox,
 }
 
 static void
-on_settings_changed (GSettings    *settings,
-                     const gchar  *key,
-                     GtrDictPanel *panel)
+gtr_dict_panel_draw (GtrDictPanel * panel)
 {
-  if (strcmp (key, DICTIONARY_SETTINGS_SOURCE_KEY) == 0)
-    {
-      gchar *source_name;
-
-      source_name = g_settings_get_string (settings, key);
-      gtr_dict_panel_set_source_name (panel, source_name);
-
-      g_free (source_name);
-    }
-  else if (strcmp (key, DICTIONARY_SETTINGS_DATABASE_KEY) == 0)
-    {
-      gchar *database;
-
-      database = g_settings_get_string (settings, key);
-      gtr_dict_panel_set_database (panel, database);
-
-      g_free (database);
-    }
-  else if (strcmp (key, DICTIONARY_SETTINGS_STRATEGY_KEY) == 0)
-    {
-      gchar *strategy;
-
-      strategy = g_settings_get_string (settings, key);
-      gtr_dict_panel_set_strategy (panel, strategy);
-
-      g_free (strategy);
-    }
-}
-
-static void
-gtr_dict_panel_init (GtrDictPanel * panel)
-{
-  GtrDictPanelPrivate *priv;
   GtkWidget *vbox;
   GtkWidget *hbox;
 
-  panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
-  priv = panel->priv;
-
-  priv->status = NULL;
-
-  if (!priv->loader)
-    panel->priv->loader = gdict_source_loader_new ();
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
-                                  GTK_ORIENTATION_VERTICAL);
-
-  /* add our data dir inside $HOME to the loader's search paths */
-  gdict_source_loader_add_search_path (priv->loader,
-                                       gtr_dirs_get_user_config_dir ());
-
-  /* settings */
-  priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.dictionary");
-
-  g_signal_connect (priv->settings,
-                    "changed",
-                    G_CALLBACK (on_settings_changed),
-                    panel);
-
-  /* force retrieval of the configuration from gsettings */
-  gtr_dict_panel_set_source_name (panel, NULL);
-
-  /* Draw widgets */
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
   gtk_widget_show (vbox);
@@ -598,7 +536,75 @@ gtr_dict_panel_init (GtrDictPanel * panel)
   gtk_widget_show (panel->priv->source_chooser);
 
   gtk_widget_show (panel->priv->sidebar);
+}
+
+static void
+on_settings_changed (GSettings    *settings,
+                     const gchar  *key,
+                     GtrDictPanel *panel)
+{
+  if (strcmp (key, DICTIONARY_SETTINGS_SOURCE_KEY) == 0)
+    {
+      gchar *source_name;
+
+      source_name = g_settings_get_string (settings, key);
+      gtr_dict_panel_set_source_name (panel, source_name);
+
+      g_free (source_name);
+    }
+  else if (strcmp (key, DICTIONARY_SETTINGS_DATABASE_KEY) == 0)
+    {
+      gchar *database;
+
+      database = g_settings_get_string (settings, key);
+      gtr_dict_panel_set_database (panel, database);
+
+      g_free (database);
+    }
+  else if (strcmp (key, DICTIONARY_SETTINGS_STRATEGY_KEY) == 0)
+    {
+      gchar *strategy;
+
+      strategy = g_settings_get_string (settings, key);
+      gtr_dict_panel_set_strategy (panel, strategy);
+
+      g_free (strategy);
+    }
+}
 
+static void
+gtr_dict_panel_init (GtrDictPanel * panel)
+{
+  GtrDictPanelPrivate *priv;
+
+  panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
+  priv = panel->priv;
+
+  priv->status = NULL;
+
+  if (!priv->loader)
+    panel->priv->loader = gdict_source_loader_new ();
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
+                                  GTK_ORIENTATION_VERTICAL);
+
+  /* add our data dir inside $HOME to the loader's search paths */
+  gdict_source_loader_add_search_path (priv->loader,
+                                       gtr_dirs_get_user_config_dir ());
+
+  /* settings */
+  priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.dictionary");
+
+  g_signal_connect (priv->settings,
+                    "changed",
+                    G_CALLBACK (on_settings_changed),
+                    panel);
+
+  /* force retrieval of the configuration from gsettings */
+  gtr_dict_panel_set_source_name (panel, NULL);
+
+  /* Draw widgets */
+  gtr_dict_panel_draw (panel);
 }
 
 static void
diff --git a/plugins/glossary/glossary-panel.c b/plugins/glossary/glossary-panel.c
index 2532c81..79c6516 100644
--- a/plugins/glossary/glossary-panel.c
+++ b/plugins/glossary/glossary-panel.c
@@ -132,12 +132,16 @@ gtr_glossary_panel_load_items (GtrGlossaryPanel * panel)
 }
 
 static void
-gtr_glossary_panel_init (GtrGlossaryPanel * panel)
+gtr_glossary_panel_draw (GtrGlossaryPanel * panel)
 {
   GtrGlossaryPanelPrivate *priv = panel->priv;
 
   priv->tree = gtk_tree_view_new ();
+}
 
+static void
+gtr_glossary_panel_init (GtrGlossaryPanel * panel)
+{
   panel->priv = GTR_GLOSSARY_PANEL_GET_PRIVATE (panel);
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
diff --git a/plugins/open-tran/gtr-open-tran-panel.c b/plugins/open-tran/gtr-open-tran-panel.c
index 59448f8..694d34b 100644
--- a/plugins/open-tran/gtr-open-tran-panel.c
+++ b/plugins/open-tran/gtr-open-tran-panel.c
@@ -475,19 +475,12 @@ gtr_open_tran_panel_draw_treeview (GtrOpenTranPanel * panel)
 }
 
 static void
-gtr_open_tran_panel_init (GtrOpenTranPanel * panel)
+gtr_open_tran_panel_draw (GtrOpenTranPanel * panel)
 {
   GtkWidget *scrolledwindow;
   GtkWidget *button;
   GtkWidget *hbox;
 
-  panel->priv = GTR_OPEN_TRAN_PANEL_GET_PRIVATE (panel);
-
-  panel->priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.open-tran");
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
-                                  GTK_ORIENTATION_VERTICAL);
-
   /*
    * Set up the scrolling window
    */
@@ -519,7 +512,20 @@ gtr_open_tran_panel_init (GtrOpenTranPanel * panel)
                     G_CALLBACK (entry_activate_cb), panel);
 
   gtk_box_pack_start (GTK_BOX (panel), hbox, FALSE, TRUE, 0);
+}
+
+static void
+gtr_open_tran_panel_init (GtrOpenTranPanel * panel)
+{
+
+  panel->priv = GTR_OPEN_TRAN_PANEL_GET_PRIVATE (panel);
+
+  panel->priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.open-tran");
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
+                                  GTK_ORIENTATION_VERTICAL);
 
+  gtr_open_tran_panel_draw (panel);
 }
 
 static void
diff --git a/src/gtr-message-table.c b/src/gtr-message-table.c
index e69e990..954879f 100644
--- a/src/gtr-message-table.c
+++ b/src/gtr-message-table.c
@@ -231,22 +231,15 @@ sort_message_list (GtkTreeViewColumn * column, GtrMessageTable * table)
                          g_list_first (messages), FALSE, GTR_TAB_MOVE_NONE);
 }
 
-  
 static void
-gtr_message_table_init (GtrMessageTable * table)
+gtr_message_table_draw (GtrMessageTable * table)
 {
-  GtkWidget *scrolledwindow;
+  GtrMessageTablePrivate *priv = table->priv;
+
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
   GtkTreeSelection *selection;
 
-  table->priv = GTR_MESSAGE_TABLE_GET_PRIVATE (table);
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
-                                  GTK_ORIENTATION_VERTICAL);
-
-  GtrMessageTablePrivate *priv = table->priv;
-
   priv->store = gtr_message_table_model_new ();
 
   priv->sort_model =
@@ -344,6 +337,20 @@ gtr_message_table_init (GtrMessageTable * table)
 
   g_signal_connect (G_OBJECT (selection), "changed",
                     G_CALLBACK (gtr_message_table_selection_changed), table);
+}
+
+
+static void
+gtr_message_table_init (GtrMessageTable * table)
+{
+  GtkWidget *scrolledwindow;
+
+  table->priv = GTR_MESSAGE_TABLE_GET_PRIVATE (table);
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+                                  GTK_ORIENTATION_VERTICAL);
+
+  gtr_message_table_draw (table);
 
   scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
   gtk_box_pack_start (GTK_BOX (table), scrolledwindow, TRUE, TRUE, 0);
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index b567bc6..9e0a36c 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -669,25 +669,7 @@ on_layout_changed (GdlDockMaster *master,
 }
 
 static void
-extension_added (PeasExtensionSet *extensions,
-                 PeasPluginInfo   *info,
-                 PeasExtension    *exten,
-                 GtrTab           *tab)
-{
-  gtr_tab_activatable_activate (GTR_TAB_ACTIVATABLE (exten));
-}
-
-static void
-extension_removed (PeasExtensionSet *extensions,
-                   PeasPluginInfo   *info,
-                   PeasExtension    *exten,
-                   GtrTab           *tab)
-{
-  gtr_tab_activatable_deactivate (GTR_TAB_ACTIVATABLE (exten));
-}
-
-static void
-gtr_tab_init (GtrTab * tab)
+gtr_tab_draw (GtrTab *tab)
 {
   GtkWidget *hbox;
   GtkWidget *vertical_box;
@@ -696,18 +678,6 @@ gtr_tab_init (GtrTab * tab)
   GtkWidget *dockbar;
   GtrTabPrivate *priv = tab->priv;
 
-  tab->priv = GTR_TAB_GET_PRIVATE (tab);
-
-  tab->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
-  tab->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
-  tab->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
-  tab->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
-
-  g_signal_connect (tab, "message-changed", G_CALLBACK (update_status), NULL);
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (tab),
-                                  GTK_ORIENTATION_VERTICAL);
-
   /* Docker */
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_show (hbox);
@@ -832,6 +802,42 @@ gtr_tab_init (GtrTab * tab)
                       NULL,
                       GTR_TAB_PLACEMENT_RIGHT,
                       FALSE);
+}
+
+static void
+extension_added (PeasExtensionSet *extensions,
+                 PeasPluginInfo   *info,
+                 PeasExtension    *exten,
+                 GtrTab           *tab)
+{
+  gtr_tab_activatable_activate (GTR_TAB_ACTIVATABLE (exten));
+}
+
+static void
+extension_removed (PeasExtensionSet *extensions,
+                   PeasPluginInfo   *info,
+                   PeasExtension    *exten,
+                   GtrTab           *tab)
+{
+  gtr_tab_activatable_deactivate (GTR_TAB_ACTIVATABLE (exten));
+}
+
+static void
+gtr_tab_init (GtrTab * tab)
+{
+  tab->priv = GTR_TAB_GET_PRIVATE (tab);
+
+  tab->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+  tab->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+  tab->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+  tab->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
+  g_signal_connect (tab, "message-changed", G_CALLBACK (update_status), NULL);
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (tab),
+                                  GTK_ORIENTATION_VERTICAL);
+
+  gtr_tab_draw (tab);
 
   /* Manage auto save data */
   tab->priv->autosave = g_settings_get_boolean (tab->priv->files_settings,
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 534973e..7accd00 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -1369,56 +1369,13 @@ on_profile_modified (GtrProfileManager *manager,
 }
 
 static void
-extension_added (PeasExtensionSet *extensions,
-                 PeasPluginInfo   *info,
-                 PeasExtension    *exten,
-                 GtrWindow        *window)
-{
-  gtr_window_activatable_activate (GTR_WINDOW_ACTIVATABLE (exten));
-}
-
-static void
-extension_removed (PeasExtensionSet *extensions,
-                   PeasPluginInfo   *info,
-                   PeasExtension    *exten,
-                   GtrWindow        *window)
-{
-  gtr_window_activatable_deactivate (GTR_WINDOW_ACTIVATABLE (exten));
-
-  /* Ensure update of ui manager, because we suspect it does something
-   * with expected static strings in the type module (when unloaded the
-   * strings don't exist anymore, and ui manager updates in an idle
-   * func) */
-  gtk_ui_manager_ensure_update (window->priv->ui_manager);
-}
-
-static void
-gtr_window_init (GtrWindow * window)
+gtr_window_draw (GtrWindow * window)
 {
-  GtkTargetList *tl;
   GtkWidget *widget;
   GError *error = NULL;
   GtkActionGroup *action_group;
   GtrWindowPrivate *priv = window->priv;
 
-  window->priv = GTR_WINDOW_GET_PRIVATE (window);
-
-  window->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
-
-  window->priv->dispose_has_run = FALSE;
-
-  /* Profile manager */
-  window->priv->prof_manager = gtr_profile_manager_get_default ();
-
-  g_signal_connect (window->priv->prof_manager, "active-profile-changed",
-                    G_CALLBACK (on_active_profile_changed), window);
-  g_signal_connect (window->priv->prof_manager, "profile-added",
-                    G_CALLBACK (on_profile_added), window);
-  g_signal_connect (window->priv->prof_manager, "profile-removed",
-                    G_CALLBACK (on_profile_removed), window);
-  g_signal_connect (window->priv->prof_manager, "profile-modified",
-                    G_CALLBACK (on_profile_modified), window);
-
   /* Main box */
   priv->main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_container_add (GTK_CONTAINER (window), priv->main_box);
@@ -1526,7 +1483,57 @@ gtr_window_init (GtrWindow * window)
 
   /* statusbar & progress bar */
   create_statusbar (window);
+}
+
+static void
+extension_added (PeasExtensionSet *extensions,
+                 PeasPluginInfo   *info,
+                 PeasExtension    *exten,
+                 GtrWindow        *window)
+{
+  gtr_window_activatable_activate (GTR_WINDOW_ACTIVATABLE (exten));
+}
+
+static void
+extension_removed (PeasExtensionSet *extensions,
+                   PeasPluginInfo   *info,
+                   PeasExtension    *exten,
+                   GtrWindow        *window)
+{
+  gtr_window_activatable_deactivate (GTR_WINDOW_ACTIVATABLE (exten));
+
+  /* Ensure update of ui manager, because we suspect it does something
+   * with expected static strings in the type module (when unloaded the
+   * strings don't exist anymore, and ui manager updates in an idle
+   * func) */
+  gtk_ui_manager_ensure_update (window->priv->ui_manager);
+}
+
+static void
+gtr_window_init (GtrWindow * window)
+{
+  GtkTargetList *tl;
+
+  window->priv = GTR_WINDOW_GET_PRIVATE (window);
+
+  window->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
+
+  window->priv->dispose_has_run = FALSE;
+
+  /* Profile manager */
+  window->priv->prof_manager = gtr_profile_manager_get_default ();
+
+  g_signal_connect (window->priv->prof_manager, "active-profile-changed",
+                    G_CALLBACK (on_active_profile_changed), window);
+  g_signal_connect (window->priv->prof_manager, "profile-added",
+                    G_CALLBACK (on_profile_added), window);
+  g_signal_connect (window->priv->prof_manager, "profile-removed",
+                    G_CALLBACK (on_profile_removed), window);
+  g_signal_connect (window->priv->prof_manager, "profile-modified",
+                    G_CALLBACK (on_profile_modified), window);
 
+  /* set up the window widgets */
+  gtr_window_draw (window);
 
   set_sensitive_according_to_window (window);
 



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