[gtranslator] Move the gdl container into the tab.



commit 4c8e52de31f5ead23b7bdd3fa1f29e0c5c4b0af6
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue May 3 01:12:59 2011 +0200

    Move the gdl container into the tab.

 data/layout.xml        |   53 +++----
 src/gtr-actions-view.c |    2 +-
 src/gtr-settings.c     |   25 ---
 src/gtr-tab.c          |  328 +++++++++++++++++++++++++++-----------
 src/gtr-tab.h          |   26 +++-
 src/gtr-window.c       |  424 ++----------------------------------------------
 src/gtr-window.h       |   25 ---
 7 files changed, 290 insertions(+), 593 deletions(-)
---
diff --git a/data/layout.xml b/data/layout.xml
index ff5493d..52e99eb 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -1,35 +1,24 @@
 <?xml version="1.0"?>
-<dock-layout>
-	<layout name="__default__">
-		<dock name="__dock_1" floating="no" width="-1" height="-1" floatx="0" floaty="0">
-			<paned orientation="vertical" locked="no" position="326">
-				<paned orientation="horizontal" locked="no" position="249">
-					<notebook orientation="vertical" locked="no" page="0">
-						<item name="GtrOpenTranPlugin" orientation="horizontal" locked="no"/>
-						<item name="GtrCharmapPlugin" orientation="horizontal" locked="no"/>
-						<item name="GtrDictionaryPlugin" orientation="horizontal" locked="no"/>
-						<placeholder name="ph_left" next-placement="center"/>
-					</notebook>
-					<paned orientation="horizontal" locked="no" position="500">
-						<paned orientation="vertical" locked="no" position="200">
-							<notebook orientation="vertical" locked="no" page="0">
-								<placeholder name="ph_top" next-placement="center"/>
-							</notebook>
-							<notebook orientation="vertical" locked="no" page="0">
-								<item name="GtrNotebook" orientation="horizontal" locked="no"/>
 
-								<placeholder name="ph_center" next-placement="center"/>
-							</notebook>
-						</paned>
-						<notebook orientation="vertical" locked="no" page="0">
-							<placeholder name="ph_right" next-placement="center"/>
-						</notebook>
-					</paned>
-				</paned>
-				<notebook orientation="vertical" locked="no" page="0">
-					<placeholder name="ph_bottom" next-placement="center"/>
-				</notebook>
-			</paned>
-		</dock>
-	</layout>
+<dock-layout>
+  <layout name="__default__">
+    <dock name="__dock_1" floating="no" width="-1" height="-1" floatx="0" floaty="0">
+      <paned orientation="horizontal" locked="no" position="487">
+        <paned orientation="vertical" locked="no">
+          <placeholder name="ph_left" next-placement="center"/>
+        </paned>
+        <paned orientation="vertical" locked="no" position="168">
+          <placeholder name="ph_top" next-placement="center"/>
+          <item name="GtrMessageTable" orientation="vertical" locked="no"/>
+          <item name="GtrTranslationFields" orientation="vertical" locked="no"/>
+          <placeholder name="ph_bottom" next-placement="center"/>
+        </paned>
+        <paned orientation="vertical" locked="no" position="216">
+          <item name="GtrTranslationMemoryUI" orientation="vertical" locked="no"/>
+          <item name="GtrContextPanel" orientation="vertical" locked="no"/>
+          <placeholder name="ph_right" next-placement="center"/>
+        </paned>
+      </paned>
+    </dock>
+  </layout>
 </dock-layout>
diff --git a/src/gtr-actions-view.c b/src/gtr-actions-view.c
index 5ebde71..1e569c3 100644
--- a/src/gtr-actions-view.c
+++ b/src/gtr-actions-view.c
@@ -26,5 +26,5 @@ gtr_actions_view_context (GtkAction * action, GtrWindow * window)
   tab = gtr_window_get_active_tab (window);
   context = GTK_WIDGET (gtr_tab_get_context_panel (tab));
 
-  gtr_tab_show_lateral_panel_widget (tab, context);
+  gtr_tab_show_widget (tab, context);
 }
diff --git a/src/gtr-settings.c b/src/gtr-settings.c
index cf27d5a..fe2bb80 100644
--- a/src/gtr-settings.c
+++ b/src/gtr-settings.c
@@ -277,28 +277,6 @@ on_spellcheck_changed (GSettings * settings,
 }
 
 static void
-on_pane_switcher_style_changed (GSettings * settings, const gchar * key,
-                                GtrSettings * gs)
-{
-  const GList *windows, *l;
-  GdlSwitcherStyle style;
-
-  style = g_settings_get_enum (settings, key);
-
-  windows = gtk_application_get_windows (GTK_APPLICATION (GTR_APP));
-
-  for (l = windows; l != NULL; l = g_list_next (l))
-    {
-      GdlDockLayout *layout_manager;
-
-      layout_manager = GDL_DOCK_LAYOUT (_gtr_window_get_layout_manager (GTR_WINDOW (l->data)));
-
-      g_object_set (G_OBJECT (layout_manager->master),
-                    "switcher-style", style, NULL);
-    }
-}
-
-static void
 on_scheme_changed (GSettings * settings, const gchar * key, GtrSettings * gs)
 {
   GList *views, *l;
@@ -354,9 +332,6 @@ gtr_settings_init (GtrSettings * gs)
                     "changed::spellcheck",
                     G_CALLBACK (on_spellcheck_changed), gs);
   g_signal_connect (gs->priv->ui,
-                    "changed::pane-switcher-style",
-                    G_CALLBACK (on_pane_switcher_style_changed), gs);
-  g_signal_connect (gs->priv->ui,
                     "changed::color-scheme",
                     G_CALLBACK (on_scheme_changed), gs);
 }
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index d53037d..c6def0e 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -43,13 +43,19 @@
 #include "gtr-view.h"
 #include "gtr-translation-memory.h"
 #include "gtr-translation-memory-ui.h"
-#include "gtr-window.h"
+#include "gtr-dirs.h"
 
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#ifdef G_OS_WIN32
+#include <gdl/libgdltypebuiltins.h>
+#else
+#include <gdl/gdl.h>
+#endif
+
 #define GTR_TAB_GET_PRIVATE(object)	(G_TYPE_INSTANCE_GET_PRIVATE ( \
 					 (object),	\
 					 GTR_TYPE_TAB,     \
@@ -63,18 +69,17 @@ G_DEFINE_TYPE (GtrTab, gtr_tab, GTK_TYPE_VBOX)
 
 struct _GtrTabPrivate
 {
+  GSettings *ui_settings;
   GSettings *files_settings;
   GSettings *editor_settings;
   GSettings *state_settings;
 
   GtrPo *po;
 
-  GtkWidget *table_pane;
-  GtkWidget *content_pane;
-  GtkWidget *message_table;
-  GtkWidget *lateral_panel;        //TM, Context, etc.
+  GtkWidget *dock;
+  GdlDockLayout *layout_manager;
 
-  GtkWidget *context_pane;
+  GtkWidget *message_table;
   GtkWidget *context;
   GtkWidget *translation_memory;
 
@@ -130,6 +135,104 @@ static guint signals[LAST_SIGNAL];
 static gboolean gtr_tab_autosave (GtrTab * tab);
 
 static void
+gtr_tab_layout_save (GtrTab      *tab,
+                     const gchar *filename,
+                     const gchar *name)
+{
+  g_return_if_fail (GTR_IS_TAB (tab));
+  g_return_if_fail (filename != NULL);
+
+  gdl_dock_layout_save_layout (tab->priv->layout_manager, name);
+  if (!gdl_dock_layout_save_to_file (tab->priv->layout_manager, filename))
+    g_warning ("Saving dock layout to '%s' failed!", filename);
+}
+
+static void
+gtr_tab_layout_load (GtrTab      *tab,
+                     const gchar *layout_filename,
+                     const gchar *name)
+{
+  g_return_if_fail (GTR_IS_TAB (tab));
+
+  if (!layout_filename ||
+      !gdl_dock_layout_load_from_file (tab->priv->layout_manager,
+                                       layout_filename))
+    {
+      gchar *path;
+
+      path = gtr_dirs_get_ui_file ("layout.xml");
+
+      if (!gdl_dock_layout_load_from_file (tab->priv->layout_manager,
+                                           path))
+        g_warning ("Loading layout from '%s' failed!!", path);
+      g_free (path);
+    }
+
+  if (!gdl_dock_layout_load_layout (tab->priv->layout_manager, name))
+    g_warning ("Loading layout failed!!");
+}
+
+static void
+add_widget_to_dock (GtrTab      *tab,
+                    GtkWidget   *widget,
+                    const gchar *name,
+                    const gchar *title,
+                    const gchar *stock_id,
+                    GtrTabPlacement placement,
+                    gboolean locked)
+{
+  GtkWidget *item;
+  guint flags = 0;
+
+  g_return_if_fail (GTR_IS_TAB (tab));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (name != NULL);
+  g_return_if_fail (title != NULL);
+
+  /* Add the widget to dock */
+  if (stock_id == NULL)
+    item = gdl_dock_item_new (name, title, GDL_DOCK_ITEM_BEH_NORMAL);
+  else
+    item = gdl_dock_item_new_with_stock (name, title, stock_id,
+                                         GDL_DOCK_ITEM_BEH_NORMAL);
+
+  if (locked)
+    {
+      flags |= 
+               GDL_DOCK_ITEM_BEH_NO_GRIP;
+    }
+
+  flags |= GDL_DOCK_ITEM_BEH_CANT_CLOSE |
+           GDL_DOCK_ITEM_BEH_CANT_ICONIFY |
+           GDL_DOCK_ITEM_BEH_NEVER_FLOATING;
+  g_object_set (G_OBJECT (item), "behavior", flags, NULL);
+
+  gtk_container_add (GTK_CONTAINER (item), widget);
+  gdl_dock_add_item (GDL_DOCK (tab->priv->dock),
+                     GDL_DOCK_ITEM (item), placement);
+  gtk_widget_show (item);
+
+  /* To remove it */
+  g_object_set_data (G_OBJECT (widget), "dockitem", item);
+}
+
+static void
+remove_widget_from_dock (GtrTab    *tab,
+                         GtkWidget *widget)
+{
+  GtkWidget *dock_item;
+
+  g_return_if_fail (GTR_IS_TAB (tab));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+  g_return_if_fail (dock_item != NULL);
+
+  /* Remove the widget from container */
+  gtk_container_remove (GTK_CONTAINER (dock_item), widget);
+}
+
+static void
 install_autosave_timeout (GtrTab * tab)
 {
   gint timeout;
@@ -556,29 +659,64 @@ on_state_notify (GtrPo      *po,
 }
 
 static void
-gtr_tab_draw (GtrTab * tab)
+on_layout_changed (GdlDockMaster *master,
+                   GtrTab        *tab)
 {
+  gchar *filename;
+
+  filename = g_build_filename (gtr_dirs_get_user_config_dir (),
+                               "gtr-layout.xml", NULL);
+
+  gtr_tab_layout_save (tab, filename, NULL);
+  g_free (filename);
+}
+
+static void
+gtr_tab_draw (GtrTab *tab)
+{
+  GtkWidget *hbox;
   GtkWidget *vertical_box;
-  GtkWidget *vcontext_box;
   GtkWidget *msgid_label;
   GtkWidget *scroll;
+  GtkWidget *dockbar;
   GtrTabPrivate *priv = tab->priv;
-
-  /* Content pane; this is where the message table and message area go */
-  priv->content_pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
-  g_settings_bind (tab->priv->state_settings,
-                   GTR_SETTINGS_CONTENT_PANEL_SIZE,
-                   priv->content_pane,
-                   "position",
+  gchar *filename;
+
+  /* Docker */
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox);
+  gtk_box_pack_start (GTK_BOX (tab), hbox, TRUE, TRUE, 0);
+
+  priv->dock = gdl_dock_new ();
+  gtk_widget_show (priv->dock);
+  gtk_box_pack_end (GTK_BOX (hbox), priv->dock, TRUE, TRUE, 0);
+
+  dockbar = gdl_dock_bar_new (GDL_DOCK (priv->dock));
+  gtk_widget_show (dockbar);
+  gtk_box_pack_start (GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
+
+  priv->layout_manager = gdl_dock_layout_new (GDL_DOCK (priv->dock));
+  g_signal_connect (priv->layout_manager->master,
+                    "layout-changed",
+                    G_CALLBACK (on_layout_changed),
+                    tab);
+
+  g_settings_bind (priv->ui_settings,
+                   GTR_SETTINGS_PANEL_SWITCHER_STYLE,
+                   priv->layout_manager->master,
+                   "switcher-style",
                    G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-  gtk_widget_show (priv->content_pane);
 
   /* Message table */
   priv->message_table = gtr_message_table_new (GTK_WIDGET (tab));
   gtk_widget_show (priv->message_table);
 
-  gtk_paned_pack1 (GTK_PANED (priv->content_pane), GTK_WIDGET (priv->message_table),
-                   TRUE, FALSE);
+  add_widget_to_dock (tab, priv->message_table,
+                      "GtrMessageTable",
+                      _("Message Table"),
+                      NULL,
+                      GTR_TAB_PLACEMENT_CENTER,
+                      FALSE);
 
   /* Orignal text widgets */
   priv->msgid_hbox = gtk_hbox_new (FALSE, 0);
@@ -640,7 +778,6 @@ gtr_tab_draw (GtrTab * tab)
                       0);
   gtk_box_pack_start (GTK_BOX (vertical_box), priv->text_vbox, TRUE, TRUE, 0);
 
-
   /* Translation widgets */
   priv->msgstr_label = gtk_label_new (NULL);
   gtk_label_set_markup_with_mnemonic (GTK_LABEL (priv->msgstr_label),
@@ -658,44 +795,39 @@ gtr_tab_draw (GtrTab * tab)
   gtk_box_pack_start (GTK_BOX (vertical_box), priv->trans_notebook, TRUE,
                       TRUE, 0);
 
-  gtk_paned_pack2 (GTK_PANED (priv->content_pane), vertical_box, FALSE,
-                   TRUE);
-
-  /* Context pane */
-  priv->context_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
-  g_settings_bind (tab->priv->state_settings,
-                   GTR_SETTINGS_CONTEXT_PANEL_SIZE,
-                   priv->context_pane,
-                   "position",
-                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-  gtk_widget_show (priv->context_pane);
-
-  gtk_paned_pack1 (GTK_PANED (priv->context_pane), priv->content_pane,
-                   FALSE, TRUE);
-  gtk_box_pack_start (GTK_BOX (tab), priv->context_pane, TRUE, TRUE, 0);
-
-  /* Vertical context box (TM, context etc ) */
-  vcontext_box = gtk_vbox_new (FALSE, 6);
-  gtk_widget_show (vcontext_box);
-  gtk_paned_pack2 (GTK_PANED (priv->context_pane), vcontext_box,
-                   TRUE, TRUE);
+  add_widget_to_dock (tab, vertical_box,
+                      "GtrTranslationFields",
+                      _("Translation Fields"),
+                      NULL,
+                      GTR_TAB_PLACEMENT_BOTTOM,
+                      TRUE);
 
   /* TM */
   priv->translation_memory = gtr_translation_memory_ui_new (GTK_WIDGET (tab));
   gtk_widget_show (priv->translation_memory);
-  gtk_box_pack_start (GTK_BOX (vcontext_box), priv->translation_memory,
-                      TRUE, TRUE, 0);
-
-  /* Lateral panel */
-  tab->priv->lateral_panel = gtk_notebook_new ();
-  gtk_widget_show (tab->priv->lateral_panel);
-  gtk_box_pack_start (GTK_BOX (vcontext_box), tab->priv->lateral_panel,
-                      TRUE, TRUE, 0);
+  add_widget_to_dock (tab, priv->translation_memory,
+                      "GtrTranslationMemoryUI",
+                      _("Translation Memory"),
+                      NULL,
+                      GTR_TAB_PLACEMENT_RIGHT,
+                      FALSE);
 
   /* Context */
   priv->context = gtr_context_panel_new (GTK_WIDGET (tab));
   gtk_widget_show (priv->context);
-  gtr_tab_add_widget_to_lateral_panel (tab, priv->context, _("Context"));
+  add_widget_to_dock (tab, priv->context,
+                      "GtrContextPanel",
+                      _("Context"),
+                      NULL,
+                      GTR_TAB_PLACEMENT_RIGHT,
+                      FALSE);
+
+  /* Loading dock layout */
+  filename = g_build_filename (gtr_dirs_get_user_config_dir (),
+                               "gtr-layout.xml", NULL);
+
+  gtr_tab_layout_load (tab, filename, NULL);
+  g_free (filename);
 }
 
 static void
@@ -703,6 +835,7 @@ 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");
@@ -739,30 +872,42 @@ gtr_tab_finalize (GObject * object)
 static void
 gtr_tab_dispose (GObject * object)
 {
-  GtrTab *tab = GTR_TAB (object);
+  GtrTabPrivate *priv = GTR_TAB (object)->priv;
 
-  if (tab->priv->po != NULL)
+  if (priv->po != NULL)
     {
-      g_object_unref (tab->priv->po);
-      tab->priv->po = NULL;
+      g_object_unref (priv->po);
+      priv->po = NULL;
     }
 
-  if (tab->priv->files_settings != NULL)
+  if (priv->ui_settings)
     {
-      g_object_unref (tab->priv->files_settings);
-      tab->priv->files_settings = NULL;
+      g_object_unref (priv->ui_settings);
+      priv->ui_settings = NULL;
     }
 
-  if (tab->priv->editor_settings != NULL)
+  if (priv->files_settings != NULL)
     {
-      g_object_unref (tab->priv->editor_settings);
-      tab->priv->editor_settings = NULL;
+      g_object_unref (priv->files_settings);
+      priv->files_settings = NULL;
     }
 
-  if (tab->priv->state_settings != NULL)
+  if (priv->editor_settings != NULL)
     {
-      g_object_unref (tab->priv->state_settings);
-      tab->priv->state_settings = NULL;
+      g_object_unref (priv->editor_settings);
+      priv->editor_settings = NULL;
+    }
+
+  if (priv->state_settings != NULL)
+    {
+      g_object_unref (priv->state_settings);
+      priv->state_settings = NULL;
+    }
+
+  if (priv->layout_manager)
+    {
+      g_object_unref (priv->layout_manager);
+      priv->layout_manager = NULL;
     }
 
   G_OBJECT_CLASS (gtr_tab_parent_class)->dispose (object);
@@ -1308,24 +1453,22 @@ gtr_tab_set_autosave_interval (GtrTab * tab, gint interval)
  * gtr_tab_add_widget_to_lateral_panel:
  * @tab: a #GtrTab
  * @widget: a #GtkWidget
- * @tab_name: the tab name in the notebook
+ * @name: the tab name in the notebook
  *
  * Adds a new widget to the laberal panel notebook.
  */
 void
-gtr_tab_add_widget_to_lateral_panel (GtrTab * tab,
-                                     GtkWidget * widget,
-                                     const gchar * tab_name)
+gtr_tab_add_widget (GtrTab         *tab,
+                    GtkWidget      *widget,
+                    const gchar    *unique_name,
+                    const gchar    *name,
+                    const gchar    *stock_id,
+                    GtrTabPlacement placement)
 {
-  GtkWidget *label;
-
   g_return_if_fail (GTR_IS_TAB (tab));
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  label = gtk_label_new (tab_name);
-
-  gtk_notebook_append_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
-                            widget, label);
+  add_widget_to_dock (tab, widget, unique_name, name, NULL, placement, FALSE);
 }
 
 /**
@@ -1336,35 +1479,36 @@ gtr_tab_add_widget_to_lateral_panel (GtrTab * tab,
  * Removes the @widget from the lateral panel notebook of @tab.
  */
 void
-gtr_tab_remove_widget_from_lateral_panel (GtrTab * tab, GtkWidget * widget)
+gtr_tab_remove_widget (GtrTab    *tab,
+                       GtkWidget *widget)
 {
-  gint page;
-
   g_return_if_fail (GTR_IS_TAB (tab));
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
-                                widget);
-
-  gtk_notebook_remove_page (GTK_NOTEBOOK (tab->priv->lateral_panel), page);
+  remove_widget_from_dock (tab, widget);
 }
 
-/**
- * gtr_tab_show_lateral_panel_widget:
- * @tab: a #GtrTab
- * @widget: the widget to be shown.
- *
- * Shows the notebook page of the @widget.
- */
 void
-gtr_tab_show_lateral_panel_widget (GtrTab * tab, GtkWidget * widget)
+gtr_tab_show_widget (GtrTab    *tab,
+                     GtkWidget *widget)
 {
-  gint page;
+  GtkWidget *item;
+  GtkWidget *parent;
+
+  g_return_if_fail (GTR_IS_TAB (tab));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  item = g_object_get_data (G_OBJECT (widget), "dockitem");
+  g_return_if_fail (item != NULL);
 
-  page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
-                                widget);
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
-                                 page);
+  /* FIXME: Hack to present the dock item if it's in a notebook dock item */
+  parent = gtk_widget_get_parent (GTK_WIDGET(item) );
+  if (GTK_IS_NOTEBOOK (parent))
+    {
+      gint pagenum;
+      pagenum = gtk_notebook_page_num (GTK_NOTEBOOK (parent), item);
+      gtk_notebook_set_current_page (GTK_NOTEBOOK (parent), pagenum);
+    }
 }
 
 /**
diff --git a/src/gtr-tab.h b/src/gtr-tab.h
index 3cb96f7..69eee54 100644
--- a/src/gtr-tab.h
+++ b/src/gtr-tab.h
@@ -79,6 +79,17 @@ typedef enum
   GTR_TAB_MOVE_PREV
 } GtrTabMove;
 
+typedef enum
+{
+  GTR_TAB_PLACEMENT_NONE = 0,
+  GTR_TAB_PLACEMENT_TOP,
+  GTR_TAB_PLACEMENT_BOTTOM,
+  GTR_TAB_PLACEMENT_RIGHT,
+  GTR_TAB_PLACEMENT_LEFT,
+  GTR_TAB_PLACEMENT_CENTER,
+  GTR_TAB_PLACEMENT_FLOATING
+} GtrTabPlacement;
+
 /*
  * Public methods
  */
@@ -113,14 +124,17 @@ gint gtr_tab_get_autosave_interval (GtrTab * tab);
 
 void gtr_tab_set_autosave_interval (GtrTab * tab, gint interval);
 
-void gtr_tab_add_widget_to_lateral_panel (GtrTab * tab,
-                                          GtkWidget * widget,
-                                          const gchar * tab_name);
+void gtr_tab_add_widget (GtrTab         *tab,
+                         GtkWidget      *widget,
+                         const gchar    *unique_name,
+                         const gchar    *name,
+                         const gchar    *stock_id,
+                         GtrTabPlacement placement);
 
-void gtr_tab_remove_widget_from_lateral_panel (GtrTab *
-                                               tab, GtkWidget * widget);
+void gtr_tab_remove_widget (GtrTab *tab,
+                            GtkWidget * widget);
 
-void gtr_tab_show_lateral_panel_widget (GtrTab * tab, GtkWidget * widget);
+void gtr_tab_show_widget (GtrTab * tab, GtkWidget * widget);
 
 void gtr_tab_clear_msgstr_views (GtrTab * tab);
 
diff --git a/src/gtr-window.c b/src/gtr-window.c
index fe24132..be3d6f8 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -46,13 +46,6 @@
 #include "egg-toolbar-editor.h"
 #include "egg-editable-toolbar.h"
 
-#ifdef G_OS_WIN32
-#include <gdl/libgdltypebuiltins.h>
-#else
-#include <gdl/gdl.h>
-#endif
-
-
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
@@ -81,13 +74,11 @@ G_DEFINE_TYPE (GtrWindow, gtr_window, GTK_TYPE_WINDOW)
 
 struct _GtrWindowPrivate
 {
-  GSettings *ui_settings;
   GSettings *state_settings;
 
   GtkWidget *main_box;
 
   GtkWidget *menubar;
-  GtkWidget *view_menu;
   GtkWidget *toolbar;
   GtkActionGroup *always_sensitive_action_group;
   GtkActionGroup *action_group;
@@ -97,10 +88,6 @@ struct _GtrWindowPrivate
   GtkWidget *notebook;
   GtrTab *active_tab;
 
-  GtkWidget *dock;
-  GdlDockLayout *layout_manager;
-  GHashTable *widgets;
-
   GtkWidget *statusbar;
 
   GtkUIManager *ui_manager;
@@ -285,266 +272,6 @@ static void          profile_combo_changed            (GtrStatusComboBox *combo,
                                                        GtkMenuItem       *item,
                                                        GtrWindow         *window);
 
-/*
- * Dock funcs
- */
-static void
-on_toggle_widget_view (GtkCheckMenuItem * menuitem, GtkWidget * dockitem)
-{
-  gboolean state;
-  state = gtk_check_menu_item_get_active (menuitem);
-  if (state)
-    gdl_dock_item_show_item (GDL_DOCK_ITEM (dockitem));
-  else
-    gdl_dock_item_hide_item (GDL_DOCK_ITEM (dockitem));
-}
-
-static void
-on_update_widget_view_menuitem (gpointer key, gpointer wid, gpointer data)
-{
-  GtkCheckMenuItem *menuitem;
-  GdlDockItem *dockitem;
-
-  dockitem = g_object_get_data (G_OBJECT (wid), "dockitem");
-  menuitem = g_object_get_data (G_OBJECT (wid), "menuitem");
-
-  g_signal_handlers_block_by_func (menuitem,
-                                   G_CALLBACK (on_toggle_widget_view),
-                                   dockitem);
-
-  if (GDL_DOCK_OBJECT_ATTACHED (dockitem))
-    gtk_check_menu_item_set_active (menuitem, TRUE);
-  else
-    gtk_check_menu_item_set_active (menuitem, FALSE);
-
-  g_signal_handlers_unblock_by_func (menuitem,
-                                     G_CALLBACK (on_toggle_widget_view),
-                                     dockitem);
-}
-
-static void
-on_layout_dirty_notify (GObject * object,
-                        GParamSpec * pspec, GtrWindow * window)
-{
-  g_return_if_fail (GTR_IS_WINDOW (window));
-
-  if (!strcmp (pspec->name, "dirty"))
-    {
-      gboolean dirty;
-      g_object_get (object, "dirty", &dirty, NULL);
-      if (dirty)
-        {
-          /* Update UI toggle buttons */
-          g_hash_table_foreach (window->priv->widgets,
-                                on_update_widget_view_menuitem, NULL);
-        }
-    }
-}
-
-static void
-gtr_window_layout_save (GtrWindow * window,
-                        const gchar * filename, const gchar * name)
-{
-  g_return_if_fail (GTR_IS_WINDOW (window));
-  g_return_if_fail (filename != NULL);
-
-  gdl_dock_layout_save_layout (window->priv->layout_manager, name);
-  if (!gdl_dock_layout_save_to_file (window->priv->layout_manager, filename))
-    g_warning ("Saving dock layout to '%s' failed!", filename);
-}
-
-static void
-gtr_window_layout_load (GtrWindow * window,
-                        const gchar * layout_filename, const gchar * name)
-{
-  g_return_if_fail (GTR_IS_WINDOW (window));
-
-  if (!layout_filename ||
-      !gdl_dock_layout_load_from_file (window->priv->layout_manager,
-                                       layout_filename))
-    {
-      gchar *path;
-
-      path = gtr_dirs_get_ui_file ("layout.xml");
-
-      //DEBUG_PRINT ("Layout = %s", path);
-      if (!gdl_dock_layout_load_from_file (window->priv->layout_manager,
-                                           path))
-        g_warning ("Loading layout from '%s' failed!!", path);
-      g_free (path);
-    }
-
-  if (!gdl_dock_layout_load_layout (window->priv->layout_manager, name))
-    g_warning ("Loading layout failed!!");
-}
-
-
-static gboolean
-remove_from_widgets_hash (gpointer name,
-                          gpointer hash_widget, gpointer widget)
-{
-  if (hash_widget == widget)
-    return TRUE;
-  return FALSE;
-}
-
-static void
-on_widget_destroy (GtkWidget * widget, GtrWindow * window)
-{
-  DEBUG_PRINT ("Widget about to be destroyed");
-  g_hash_table_foreach_remove (window->priv->widgets,
-                               remove_from_widgets_hash, widget);
-}
-
-static void
-on_widget_remove (GtkWidget * container,
-                  GtkWidget * widget, GtrWindow * window)
-{
-  GtkWidget *dock_item;
-
-  dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
-  if (dock_item)
-    {
-      gchar *unique_name =
-        g_object_get_data (G_OBJECT (dock_item), "unique_name");
-      g_free (unique_name);
-      g_signal_handlers_disconnect_by_func (G_OBJECT (dock_item),
-                                            G_CALLBACK (on_widget_remove),
-                                            window);
-      gdl_dock_item_unbind (GDL_DOCK_ITEM (dock_item));
-    }
-  if (g_hash_table_foreach_remove (window->priv->widgets,
-                                   remove_from_widgets_hash, widget))
-    {
-      DEBUG_PRINT ("Widget removed from container");
-    }
-}
-
-static void
-on_widget_removed_from_hash (gpointer widget)
-{
-  GtrWindow *window;
-  GtkWidget *menuitem;
-  GdlDockItem *dockitem;
-
-  DEBUG_PRINT ("Removing widget from hash");
-
-  window = g_object_get_data (G_OBJECT (widget), "window-object");
-  dockitem = g_object_get_data (G_OBJECT (widget), "dockitem");
-  menuitem = g_object_get_data (G_OBJECT (widget), "menuitem");
-
-  gtk_widget_destroy (menuitem);
-
-  g_object_set_data (G_OBJECT (widget), "dockitem", NULL);
-  g_object_set_data (G_OBJECT (widget), "menuitem", NULL);
-
-  g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
-                                        G_CALLBACK (on_widget_destroy),
-                                        window);
-  g_signal_handlers_disconnect_by_func (G_OBJECT (dockitem),
-                                        G_CALLBACK (on_widget_remove),
-                                        window);
-
-  g_object_unref (G_OBJECT (widget));
-}
-
-static void
-add_widget_full (GtrWindow * window,
-                 GtkWidget * widget,
-                 const char *name,
-                 const char *title,
-                 const char *stock_id,
-                 GtrWindowPlacement placement,
-                 gboolean locked, GError ** error)
-{
-  GtkWidget *item;
-  GtkCheckMenuItem *menuitem;
-
-  g_return_if_fail (GTR_IS_WINDOW (window));
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (name != NULL);
-  g_return_if_fail (title != NULL);
-
-  /* Add the widget to hash */
-  if (window->priv->widgets == NULL)
-    {
-      window->priv->widgets = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                     g_free,
-                                                     on_widget_removed_from_hash);
-    }
-  g_hash_table_insert (window->priv->widgets, g_strdup (name), widget);
-  g_object_ref (widget);
-
-  /* Add the widget to dock */
-  if (stock_id == NULL)
-    item = gdl_dock_item_new (name, title, GDL_DOCK_ITEM_BEH_NORMAL);
-  else
-    item = gdl_dock_item_new_with_stock (name, title, stock_id,
-                                         GDL_DOCK_ITEM_BEH_NORMAL);
-  if (locked)
-    {
-      guint flags = 0;
-      flags |= GDL_DOCK_ITEM_BEH_NEVER_FLOATING;
-      flags |= GDL_DOCK_ITEM_BEH_CANT_CLOSE;
-      flags |= GDL_DOCK_ITEM_BEH_CANT_ICONIFY;
-      flags |= GDL_DOCK_ITEM_BEH_NO_GRIP;
-      g_object_set (G_OBJECT (item), "behavior", flags, NULL);
-    }
-
-  gtk_container_add (GTK_CONTAINER (item), widget);
-  gdl_dock_add_item (GDL_DOCK (window->priv->dock),
-                     GDL_DOCK_ITEM (item), placement);
-  gtk_widget_show_all (item);
-
-  /* Add toggle button for the widget */
-  menuitem = GTK_CHECK_MENU_ITEM (gtk_check_menu_item_new_with_label (title));
-  gtk_widget_show (GTK_WIDGET (menuitem));
-  gtk_check_menu_item_set_active (menuitem, TRUE);
-  gtk_menu_shell_append (GTK_MENU_SHELL (window->priv->view_menu),
-                         GTK_WIDGET (menuitem));
-
-  if (locked)
-    g_object_set (G_OBJECT (menuitem), "visible", FALSE, NULL);
-
-
-  g_object_set_data (G_OBJECT (widget), "window-object", window);
-  g_object_set_data (G_OBJECT (widget), "menuitem", menuitem);
-  g_object_set_data (G_OBJECT (widget), "dockitem", item);
-
-  /* For toggling widget view on/off */
-  g_signal_connect (G_OBJECT (menuitem), "toggled",
-                    G_CALLBACK (on_toggle_widget_view), item);
-
-  /*
-     Watch for widget removal/destruction so that it could be
-     removed from widgets hash.
-   */
-  g_signal_connect (G_OBJECT (item), "remove",
-                    G_CALLBACK (on_widget_remove), window);
-  g_signal_connect_after (G_OBJECT (widget), "destroy",
-                          G_CALLBACK (on_widget_destroy), window);
-}
-
-static void
-remove_widget (GtrWindow * window, GtkWidget * widget, GError ** error)
-{
-  GtkWidget *dock_item;
-
-  g_return_if_fail (GTR_IS_WINDOW (window));
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  g_return_if_fail (window->priv->widgets != NULL);
-
-  dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
-  g_return_if_fail (dock_item != NULL);
-
-  /* Remove the widget from container */
-  g_object_ref (widget);
-  /* It should call on_widget_remove() and clean up should happen */
-  gtk_container_remove (GTK_CONTAINER (dock_item), widget);
-  g_object_unref (widget);
-}
-
 void
 _gtr_window_set_sensitive_according_to_message (GtrWindow * window,
                                                 GtrPo * po)
@@ -1475,12 +1202,18 @@ fill_profile_combo (GtrWindow *window)
 }
 
 static void
-create_statusbar (GtrWindow *window,
-                  GtkWidget *box)
+create_statusbar (GtrWindow *window)
 {
+  GtkWidget *hbox;
+
+  /* hbox */
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (window->priv->main_box), hbox, FALSE, FALSE, 0);
+  gtk_widget_show (hbox);
+
   window->priv->statusbar = gtr_statusbar_new ();
 
-  gtk_box_pack_end (GTK_BOX (box), window->priv->statusbar, TRUE, TRUE, 0);
+  gtk_box_pack_end (GTK_BOX (hbox), window->priv->statusbar, TRUE, TRUE, 0);
 
   gtk_widget_show (window->priv->statusbar);
 
@@ -1622,10 +1355,8 @@ on_profile_modified (GtrProfileManager *manager,
 static void
 gtr_window_draw (GtrWindow * window)
 {
-  GtkWidget *hbox;              //Statusbar and progressbar
   GtkWidget *widget;
   GError *error = NULL;
-  GtkWidget *dockbar;
   GtkActionGroup *action_group;
   gchar *path;
 
@@ -1725,30 +1456,10 @@ gtr_window_draw (GtrWindow * window)
                       priv->toolbar, FALSE, FALSE, 0);
   gtk_widget_show (priv->toolbar);
 
-  /* Docker */
-  hbox = gtk_hbox_new (FALSE, 0);
-  priv->dock = gdl_dock_new ();
-  gtk_widget_show (priv->dock);
-  gtk_box_pack_end (GTK_BOX (hbox), priv->dock, TRUE, TRUE, 0);
-
-  dockbar = gdl_dock_bar_new (GDL_DOCK (priv->dock));
-  gtk_widget_show (dockbar);
-  gtk_box_pack_start (GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (priv->main_box), hbox, TRUE, TRUE, 0);
-  gtk_widget_show (hbox);
-
-  priv->layout_manager = gdl_dock_layout_new (GDL_DOCK (priv->dock));
-  g_object_set (priv->layout_manager->master,
-                "switcher-style",
-                g_settings_get_enum (priv->ui_settings,
-                                     GTR_SETTINGS_PANEL_SWITCHER_STYLE),
-                NULL);
-  g_signal_connect (priv->layout_manager,
-                    "notify::dirty",
-                    G_CALLBACK (on_layout_dirty_notify), window);
-
   /* notebook */
   priv->notebook = GTK_WIDGET (gtr_notebook_new ());
+  gtk_widget_show (priv->notebook);
+  gtk_box_pack_start (GTK_BOX (priv->main_box), priv->notebook, TRUE, TRUE, 0);
   g_signal_connect (priv->notebook, "switch-page",
                     G_CALLBACK (notebook_switch_page), window);
   g_signal_connect (priv->notebook, "page-added",
@@ -1759,13 +1470,8 @@ gtr_window_draw (GtrWindow * window)
                     "tab_close_request",
                     G_CALLBACK (notebook_tab_close_request), window);
 
-  /* hbox */
-  hbox = gtk_hbox_new (FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (priv->main_box), hbox, FALSE, FALSE, 0);
-  gtk_widget_show (hbox);
-
   /* statusbar & progress bar */
-  create_statusbar (window, hbox);
+  create_statusbar (window);
 }
 
 static void
@@ -1796,13 +1502,9 @@ static void
 gtr_window_init (GtrWindow * window)
 {
   GtkTargetList *tl;
-  GtkWidget *view_menu;
-  const gchar *config_folder;
-  gchar *filename;
 
   window->priv = GTR_WINDOW_GET_PRIVATE (window);
 
-  window->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
   window->priv->state_settings = g_settings_new ("org.gnome.gtranslator.state.window");
 
   window->priv->dispose_has_run = FALSE;
@@ -1848,27 +1550,6 @@ gtr_window_init (GtrWindow * window)
                     "drag_data_received",
                     G_CALLBACK (drag_data_received_cb), NULL);
 
-  /* Create widgets menu */
-  view_menu =
-    gtk_ui_manager_get_widget (window->priv->ui_manager,
-                               "/MainMenu/ViewMenu");
-  window->priv->view_menu =
-    gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));
-
-  /* Adding notebook to dock */
-  add_widget_full (window,
-                   window->priv->notebook,
-                   "GtrNotebook",
-                   _("Documents"),
-                   NULL, GTR_WINDOW_PLACEMENT_CENTER, TRUE, NULL);
-
-  /* Loading dock layout */
-  config_folder = gtr_dirs_get_user_config_dir ();
-  filename = g_build_filename (config_folder, "gtr-layout.xml", NULL);
-
-  gtr_window_layout_load (window, filename, NULL);
-  g_free (filename);
-
   /* Plugins */
   window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gtr_plugins_engine_get_default ()),
                                                      GTR_TYPE_WINDOW_ACTIVATABLE,
@@ -1888,19 +1569,10 @@ gtr_window_init (GtrWindow * window)
 static void
 save_panes_state (GtrWindow * window)
 {
-  const gchar *config_folder;
-  gchar *filename;
-
   g_settings_set (window->priv->state_settings, GTR_SETTINGS_WINDOW_SIZE, "(ii)",
                   window->priv->width, window->priv->height);
   g_settings_set_int (window->priv->state_settings, GTR_SETTINGS_WINDOW_STATE,
                       window->priv->window_state);
-
-  config_folder = gtr_dirs_get_user_config_dir ();
-  filename = g_build_filename (config_folder, "gtr-layout.xml", NULL);
-
-  gtr_window_layout_save (window, filename, NULL);
-  g_free (filename);
 }
 
 static void
@@ -1929,12 +1601,6 @@ gtr_window_dispose (GObject * object)
       priv->dispose_has_run = TRUE;
     }
 
-  if (priv->ui_settings)
-    {
-      g_object_unref (priv->ui_settings);
-      priv->ui_settings = NULL;
-    }
-
   if (priv->state_settings)
     {
       g_object_unref (priv->state_settings);
@@ -1958,18 +1624,6 @@ gtr_window_dispose (GObject * object)
       priv->prof_manager = NULL;
     }
 
-  if (priv->widgets)
-    {
-      g_hash_table_unref (priv->widgets);
-      priv->widgets = NULL;
-    }
-
-  if (priv->layout_manager)
-    {
-      g_object_unref (priv->layout_manager);
-      priv->layout_manager = NULL;
-    }
-
   /* Now that there have broken some reference loops,
    * force collection again.
    */
@@ -2252,60 +1906,6 @@ gtr_window_get_all_views (GtrWindow * window,
 }
 
 /**
- * gtr_window_add_widget:
- * @window: a #GtrWindow
- * @widget: the widget to add in the window
- * @name: the name of the widged
- * @title: the title
- * @stock_id: the stock id for the icon
- * @placement: a #GtrWindowPlacement
- *
- * Adds a new widget to the @window in the placement you prefer with and 
- * specific name, title and icon you want.
- */
-void
-gtr_window_add_widget (GtrWindow * window,
-                       GtkWidget * widget,
-                       const gchar * name,
-                       const gchar * title,
-                       const gchar * stock_id, GtrWindowPlacement placement)
-{
-  /*FIXME: We have to manage the error */
-  add_widget_full (window, widget,
-                   name, title, stock_id, placement, FALSE, NULL);
-}
-
-/**
- * gtr_window_remove_widget:
- * @window: a #GtrWindow
- * @widget: the widget to remove
- *
- * Removes from the @window the @widget if it exists.
- */
-void
-gtr_window_remove_widget (GtrWindow * window, GtkWidget * widget)
-{
-  /*FIXME: We have to manage the error */
-  remove_widget (window, widget, NULL);
-}
-
-/**
- * _gtr_window_get_layout_manager:
- * @window: a #GtrWindow
- * 
- * Gets the GDL layout manager of the window.
- * 
- * Returns: the GDL layout manager of the window.
- */
-GObject *
-_gtr_window_get_layout_manager (GtrWindow * window)
-{
-  g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
-
-  return G_OBJECT (window->priv->layout_manager);
-}
-
-/**
  * gtr_window_get_tab_from_location:
  * @window: a #GtrWindow
  * @location: the GFile of the po file of the #GtrTab
diff --git a/src/gtr-window.h b/src/gtr-window.h
index b942917..07f039b 100644
--- a/src/gtr-window.h
+++ b/src/gtr-window.h
@@ -68,17 +68,6 @@ struct _GtrWindowClass
   GtkWindowClass parent_class;
 };
 
-typedef enum
-{
-  GTR_WINDOW_PLACEMENT_NONE = 0,
-  GTR_WINDOW_PLACEMENT_TOP,
-  GTR_WINDOW_PLACEMENT_BOTTOM,
-  GTR_WINDOW_PLACEMENT_RIGHT,
-  GTR_WINDOW_PLACEMENT_LEFT,
-  GTR_WINDOW_PLACEMENT_CENTER,
-  GTR_WINDOW_PLACEMENT_FLOATING
-} GtrWindowPlacement;
-
 /*
  * Public methods
  */
@@ -110,20 +99,6 @@ GtrHeader * gtr_window_get_header_from_active_tab (GtrWindow * window);
      gtr_window_get_all_views (GtrWindow * window,
                                gboolean original, gboolean translated);
 
-     void
-     gtr_window_add_widget (GtrWindow * window,
-                            GtkWidget * widget,
-                            const gchar * name,
-                            const gchar * title,
-                            const gchar * stock_id,
-                            GtrWindowPlacement placement);
-
-     void
-     gtr_window_remove_widget (GtrWindow * window, GtkWidget * widget);
-
-     GObject *
-     _gtr_window_get_layout_manager (GtrWindow * window);
-
      GtkWidget *
      gtr_window_get_tab_from_location (GtrWindow * window, GFile * location);
 



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