API addition to GdlDockLayout
- From: Gustavo Giráldez <gustavo giraldez gmx net>
- To: Gnome Devtools list <gnome-devtools gnome org>
- Cc: Dave Camp <dave ximian com>
- Subject: API addition to GdlDockLayout
- Date: 04 Jun 2002 07:52:53 -0300
Hi Dave et al,
I just commited this patch which adds a couple of functions to
GdlDockLayout to get separate controls for dock items and saved
layouts. With these, building the preferences dialog should be a lot
cleaner.
Regards,
Gustavo
? .tm_project.cache
? autom4te.cache
? stamp-h1
? gdl/layout.gladep
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gdl/ChangeLog,v
retrieving revision 1.74
diff -u -r1.74 ChangeLog
--- ChangeLog 1 Jun 2002 23:09:25 -0000 1.74
+++ ChangeLog 4 Jun 2002 10:50:08 -0000
@@ -1,3 +1,14 @@
+2002-06-04 Gustavo Giráldez <gustavo giraldez gmx net>
+
+ * gdl/gdl-dock-layout.h: API additions.
+ * gdl/gdl-dock-layout.c (gdl_dock_layout_construct_ui): Splitted
+ in gdl_dock_layout_construct_items_ui and
+ gdl_dock_layout_construct_layouts_ui to support the two new API
+ functions.
+ (gdl_dock_layout_get_items_ui, gdl_dock_layout_get_layouts_ui):
+ New API functions.
+ * gdl/layout.glade: Minor cosmetic and naming fixes.
+
2002-06-01 Gustavo Giráldez <gustavo giraldez gmx net>
* gdl/gdl-dock.c (gdl_dock_set_title)
Index: gdl/gdl-dock-layout.c
===================================================================
RCS file: /cvs/gnome/gdl/gdl/gdl-dock-layout.c,v
retrieving revision 1.4
diff -u -r1.4 gdl-dock-layout.c
--- gdl/gdl-dock-layout.c 1 Jun 2002 23:09:26 -0000 1.4
+++ gdl/gdl-dock-layout.c 4 Jun 2002 10:50:10 -0000
@@ -63,6 +63,9 @@
/* idle control */
gboolean idle_save_pending;
+
+ /* ui change control */
+ gboolean changed_by_user;
};
typedef struct _GdlDockLayoutUIData GdlDockLayoutUIData;
@@ -73,7 +76,6 @@
GtkWidget *layout_entry;
GtkWidget *locked_check;
GtkTreeSelection *selection;
- gboolean changed_by_user;
};
@@ -432,7 +434,7 @@
COLUMN_NAME, &name,
-1);
gdl_dock_layout_load_layout (layout, name);
- ui_data->changed_by_user = TRUE;
+ layout->_priv->changed_by_user = TRUE;
g_free (name);
gdl_dock_layout_update_items_model (layout);
if (ui_data->layout->master)
@@ -492,7 +494,7 @@
else
gdl_dock_item_hide_item (item);
- ui_data->changed_by_user = TRUE;
+ layout->_priv->changed_by_user = TRUE;
gtk_tree_path_free (path);
}
@@ -527,7 +529,7 @@
else
gdl_dock_item_unlock (item);
- ui_data->changed_by_user = TRUE;
+ layout->_priv->changed_by_user = TRUE;
gtk_tree_path_free (path);
}
#endif
@@ -566,7 +568,7 @@
locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
g_object_set (master, "locked", locked ? 1 : 0, NULL);
- ui_data->changed_by_user = TRUE;
+ ui_data->layout->_priv->changed_by_user = TRUE;
}
static void
@@ -615,35 +617,48 @@
}
}
-static GtkWidget *
-gdl_dock_layout_construct_ui (GdlDockLayout *layout)
+static GladeXML *
+load_interface (const gchar *top_widget)
{
- gchar *gui_file;
- GladeXML *gui;
- GtkWidget *container;
- GtkWidget *items_list, *layouts_list;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
+ GladeXML *gui;
+ gchar *gui_file;
- GdlDockLayoutUIData *ui_data;
-
/* load ui */
/* FIXME: set the translation domain here */
gui_file = g_build_filename (GDL_GLADEDIR, LAYOUT_GLADE_FILE, NULL);
- gui = glade_xml_new (gui_file, "layout_container", NULL);
+ gui = glade_xml_new (gui_file, top_widget, NULL);
g_free (gui_file);
if (!gui) {
+ /* FIXME: pop up an error dialog */
g_warning (_("Could not load layout user interface file '%s'"),
LAYOUT_GLADE_FILE);
return NULL;
};
+ return gui;
+}
+static GtkWidget *
+gdl_dock_layout_construct_items_ui (GdlDockLayout *layout)
+{
+ GladeXML *gui;
+ GtkWidget *container;
+ GtkWidget *items_list;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ GdlDockLayoutUIData *ui_data;
+
+ /* load the interface if it wasn't provided */
+ gui = load_interface ("items_vbox");
+
+ if (!gui)
+ return NULL;
+
/* get the container */
- container = glade_xml_get_widget (gui, "layout_container");
+ container = glade_xml_get_widget (gui, "items_vbox");
ui_data = g_new0 (GdlDockLayoutUIData, 1);
ui_data->layout = layout;
- ui_data->changed_by_user = FALSE;
g_object_add_weak_pointer (G_OBJECT (layout),
(gpointer *) &ui_data->layout);
g_object_set_data (G_OBJECT (container), "ui_data", ui_data);
@@ -652,11 +667,8 @@
gdl_dock_layout_build_models (layout);
/* get ui widget references */
- ui_data->layout_entry = glade_xml_get_widget (gui, "newlayout_entry");
ui_data->locked_check = glade_xml_get_widget (gui, "locked_check");
-
items_list = glade_xml_get_widget (gui, "items_list");
- layouts_list = glade_xml_get_widget (gui, "layouts_list");
/* locked check connections */
g_signal_connect (ui_data->locked_check, "toggled",
@@ -671,8 +683,6 @@
/* set models */
gtk_tree_view_set_model (GTK_TREE_VIEW (items_list),
GTK_TREE_MODEL (layout->_priv->items_model));
- gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list),
- GTK_TREE_MODEL (layout->_priv->layouts_model));
/* construct list views */
renderer = gtk_cell_renderer_toggle_new ();
@@ -702,6 +712,52 @@
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column);
+ /* connect signals */
+ g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL);
+
+ g_object_unref (gui);
+
+ return container;
+}
+
+static GtkWidget *
+gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout)
+{
+ GladeXML *gui;
+ GtkWidget *container;
+ GtkWidget *layouts_list;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ GdlDockLayoutUIData *ui_data;
+
+ /* load the interface if it wasn't provided */
+ gui = load_interface ("layouts_vbox");
+
+ if (!gui)
+ return NULL;
+
+ /* get the container */
+ container = glade_xml_get_widget (gui, "layouts_vbox");
+
+ ui_data = g_new0 (GdlDockLayoutUIData, 1);
+ ui_data->layout = layout;
+ g_object_add_weak_pointer (G_OBJECT (layout),
+ (gpointer *) &ui_data->layout);
+ g_object_set_data (G_OBJECT (container), "ui_data", ui_data);
+
+ /* ensure model availability */
+ gdl_dock_layout_build_models (layout);
+
+ /* get ui widget references */
+ ui_data->layout_entry = glade_xml_get_widget (gui, "newlayout_entry");
+ layouts_list = glade_xml_get_widget (gui, "layouts_list");
+
+ /* set models */
+ gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list),
+ GTK_TREE_MODEL (layout->_priv->layouts_model));
+
+ /* construct list views */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Name"),
renderer,
@@ -730,6 +786,31 @@
return container;
}
+static GtkWidget *
+gdl_dock_layout_construct_ui (GdlDockLayout *layout)
+{
+ GtkWidget *container, *child;
+
+ container = gtk_notebook_new ();
+ gtk_widget_show (container);
+
+ child = gdl_dock_layout_construct_items_ui (layout);
+ if (child)
+ gtk_notebook_append_page (GTK_NOTEBOOK (container),
+ child,
+ gtk_label_new (_("Dock items")));
+
+ child = gdl_dock_layout_construct_layouts_ui (layout);
+ if (child)
+ gtk_notebook_append_page (GTK_NOTEBOOK (container),
+ child,
+ gtk_label_new (_("Saved layouts")));
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (container), 0);
+
+ return container;
+}
+
/* ----- Save & Load layout functions --------- */
#define GDL_DOCK_PARAM_CONSTRUCTION(p) \
@@ -1188,6 +1269,7 @@
/* save the layout */
gdl_dock_layout_save (layout->master, node);
+ layout->_priv->changed_by_user = FALSE;
layout->dirty = TRUE;
g_object_notify (G_OBJECT (layout), "dirty");
}
@@ -1216,7 +1298,6 @@
void
gdl_dock_layout_run_manager (GdlDockLayout *layout)
{
- GdlDockLayoutUIData *ui_data;
GtkWidget *dialog, *container;
GtkWidget *parent = NULL;
@@ -1249,8 +1330,7 @@
gtk_dialog_run (GTK_DIALOG (dialog));
- ui_data = g_object_get_data (G_OBJECT (container), "ui_data");
- if (ui_data->changed_by_user) {
+ if (layout->_priv->changed_by_user) {
/* save the default (current) layout */
gdl_dock_layout_save_layout (layout, NULL);
};
@@ -1358,5 +1438,46 @@
GtkWidget *
gdl_dock_layout_get_ui (GdlDockLayout *layout)
{
- return gdl_dock_layout_construct_ui (layout);
+ GtkWidget *ui;
+
+ g_return_val_if_fail (layout != NULL, NULL);
+ ui = gdl_dock_layout_construct_ui (layout);
+
+ /* FIXME: this shouldn't be here. Instead populate models should
+ change when an item is added/removed from the dock master, and
+ when gdl_dock_layout_load_from_file is called. And do it in an
+ idle handler */
+ gdl_dock_layout_populate_models (layout);
+
+ return ui;
+}
+
+GtkWidget *
+gdl_dock_layout_get_items_ui (GdlDockLayout *layout)
+{
+ GtkWidget *ui;
+
+ g_return_val_if_fail (layout != NULL, NULL);
+ ui = gdl_dock_layout_construct_items_ui (layout);
+
+ /* FIXME: same case as gdl_dock_layout_get_ui */
+ gdl_dock_layout_populate_models (layout);
+
+ return ui;
+}
+
+GtkWidget *
+gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout)
+{
+ GtkWidget *ui;
+
+ g_return_val_if_fail (layout != NULL, NULL);
+ ui = gdl_dock_layout_construct_layouts_ui (layout);
+
+ /* FIXME: same case as gdl_dock_layout_get_ui */
+ gdl_dock_layout_populate_models (layout);
+
+ return ui;
}
+
+
Index: gdl/gdl-dock-layout.h
===================================================================
RCS file: /cvs/gnome/gdl/gdl/gdl-dock-layout.h,v
retrieving revision 1.2
diff -u -r1.2 gdl-dock-layout.h
--- gdl/gdl-dock-layout.h 12 May 2002 08:50:25 -0000 1.2
+++ gdl/gdl-dock-layout.h 4 Jun 2002 10:50:11 -0000
@@ -89,6 +89,8 @@
gboolean gdl_dock_layout_is_dirty (GdlDockLayout *layout);
GtkWidget *gdl_dock_layout_get_ui (GdlDockLayout *layout);
+GtkWidget *gdl_dock_layout_get_items_ui (GdlDockLayout *layout);
+GtkWidget *gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout);
G_END_DECLS
Index: gdl/layout.glade
===================================================================
RCS file: /cvs/gnome/gdl/gdl/layout.glade,v
retrieving revision 1.2
diff -u -r1.2 layout.glade
--- gdl/layout.glade 12 May 2002 08:50:25 -0000 1.2
+++ gdl/layout.glade 4 Jun 2002 10:50:12 -0000
@@ -48,7 +48,7 @@
<property name="enable_popup">False</property>
<child>
- <widget class="GtkVBox" id="vbox2">
+ <widget class="GtkVBox" id="items_vbox">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
@@ -85,7 +85,7 @@
<widget class="GtkCheckButton" id="locked_check">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Lock dock items</property>
+ <property name="label" translatable="yes">_Lock dock items</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
@@ -125,7 +125,7 @@
</child>
<child>
- <widget class="GtkVBox" id="vbox1">
+ <widget class="GtkVBox" id="layouts_vbox">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]