[patch] GdlDock bugfixes for gdl and anjuta2
- From: "Gustavo M. Giráldez" <gustavo giraldez gmx net>
- To: gnome-devtools gnome org
- Cc: Dave Camp <dave ximian com>, Jeroen Zwartepoorte <jeroen xs4all nl>
- Subject: [patch] GdlDock bugfixes for gdl and anjuta2
- Date: Sat, 10 Nov 2001 05:59:22 -0300
Hi all,
The patches fix some bugs I found in gdl and anjuta2 when using the dock. The gdl_dock_item_hide_cb one was the culprit of a segfault when hiding a notebook. The other fixes are mostly for correctness and to eliminate warnings.
Regards,
Gustavo
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gdl/ChangeLog,v
retrieving revision 1.35
diff -u -r1.35 ChangeLog
--- ChangeLog 2001/10/28 20:00:54 1.35
+++ ChangeLog 2001/11/10 08:48:21
@@ -1,3 +1,13 @@
+2001-11-10 Gustavo Giráldez <gustavo giraldez gmx net>
+
+ * gdl/gdl-dock.c (gdl_dock_layout_build): changed signature and
+ reorganized function to avoid creating empty docking containers.
+ (gdl_dock_bind_item): check for dockitem name duplication.
+ * gdl/gdl-dock-item.c (gdl_dock_item_hide_cb): save pointer to
+ dock before calling hide to emit signal later.
+ * gdl/gdl-dock-notebook.c: removed auto_reduce debug message.
+ Create the GtkNotebook with scrollable tabs.
+
2001-10-28 Christian Rose <menthos menthos com>
* configure.in: Added "da" to ALL_LINGUAS.
Index: gdl/gdl-dock.c
===================================================================
RCS file: /cvs/gnome/gdl/gdl/gdl-dock.c,v
retrieving revision 1.3
diff -u -r1.3 gdl-dock.c
--- gdl/gdl-dock.c 2001/10/10 13:09:14 1.3
+++ gdl/gdl-dock.c 2001/11/10 08:48:23
@@ -39,7 +39,7 @@
gpointer data);
static gint item_name_compare (gconstpointer a,
gconstpointer b);
-static void gdl_dock_layout_build (GdlDock *dock,
+static gint gdl_dock_layout_build (GdlDock *dock,
GdlDockItem *item,
xmlNodePtr node);
@@ -632,65 +632,98 @@
};
}
-static void
+static gint
gdl_dock_layout_build (GdlDock *dock,
GdlDockItem *item,
xmlNodePtr node)
{
- gchar *name;
- GtkWidget *widget;
-
- g_return_if_fail (dock != NULL);
- g_return_if_fail (node != NULL);
+ gchar *name;
+ GtkWidget *widget;
+ gint items_docked = 0, i;
+ GtkContainer *parent;
+
+ g_return_val_if_fail (dock != NULL, 0);
+ g_return_val_if_fail (node != NULL, 0);
+ if (item)
+ parent = GTK_CONTAINER (item);
+ else
+ parent = GTK_CONTAINER (dock);
+
for (; node; node = node->next) {
- name = (gchar *)node->name;
+ name = (gchar *) node->name;
/* Create/get root container/item. */
if (!strcmp ("paned", name)) {
- /* Create new GdlDockPaned with specified orientation. */
- if (!strcmp ("horizontal", xmlGetProp (node, "orientation")))
- widget = gdl_dock_paned_new (GTK_ORIENTATION_HORIZONTAL);
- else
- widget = gdl_dock_paned_new (GTK_ORIENTATION_VERTICAL);
+ if (node->childs) {
+ /* Create new GdlDockPaned with specified orientation. */
+ if (!strcmp ("horizontal", xmlGetProp (node, "orientation")))
+ widget = gdl_dock_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ else
+ widget = gdl_dock_paned_new (GTK_ORIENTATION_VERTICAL);
- gdl_dock_bind_item (dock, GDL_DOCK_ITEM (widget));
-
- /* Recurse. */
- if (node->childs)
- gdl_dock_layout_build (dock, GDL_DOCK_ITEM (widget),
- node->childs);
-
- /* Set divider location. */
- gdl_dock_paned_set_position (GDL_DOCK_PANED (widget),
- atoi (xmlGetProp (node, "divider")));
+ gdl_dock_bind_item (dock, GDL_DOCK_ITEM (widget));
+ gtk_container_add (parent, widget);
+ /* Recurse. */
+ i = gdl_dock_layout_build (dock, GDL_DOCK_ITEM (widget),
+ node->childs);
+
+ if (i > 0) {
+ if (i < 2)
+ gdl_dock_item_auto_reduce (GDL_DOCK_ITEM (widget));
+ else {
+ /* Set divider location. */
+ gdl_dock_paned_set_position (
+ GDL_DOCK_PANED (widget),
+ atoi (xmlGetProp (node, "divider")));
+ };
+ items_docked++;
+
+ } else
+ gdl_dock_unbind_item (dock, GDL_DOCK_ITEM (widget));
+ };
+
} else if (!strcmp ("notebook", name)) {
- /* Create new GdlDockNotebook. */
- widget = gdl_dock_notebook_new ();
+ if (node->childs) {
+ /* Create new GdlDockNotebook. */
+ widget = gdl_dock_notebook_new ();
- gdl_dock_bind_item (dock, GDL_DOCK_ITEM (widget));
-
- /* Recurse. */
- if (node->childs)
- gdl_dock_layout_build (dock, GDL_DOCK_ITEM (widget),
- node->childs);
-
- /* Set tab index. */
- gtk_notebook_set_page (GTK_NOTEBOOK (
- GDL_DOCK_NOTEBOOK (widget)->notebook),
- atoi (xmlGetProp (node, "index")));
+ gdl_dock_bind_item (dock, GDL_DOCK_ITEM (widget));
+ gtk_container_add (parent, widget);
- } else
- widget = GTK_WIDGET (gdl_dock_get_item_by_name (
- dock, (gchar *)xmlGetProp (node, "name")));
+ /* Recurse. */
+ i = gdl_dock_layout_build (dock, GDL_DOCK_ITEM (widget),
+ node->childs);
+
+ if (i > 0) {
+ if (i < 2)
+ gdl_dock_item_auto_reduce (GDL_DOCK_ITEM (widget));
+ else {
+ /* Set tab index. */
+ gtk_notebook_set_page (
+ GTK_NOTEBOOK (GDL_DOCK_NOTEBOOK
+ (widget)->notebook),
+ atoi (xmlGetProp (node, "index")));
+ };
+ items_docked++;
+
+ } else
+ gdl_dock_unbind_item (dock, GDL_DOCK_ITEM (widget));
+ };
- /* Add widget to dock. */
- if (!item)
- gtk_container_add (GTK_CONTAINER (dock), widget);
- else
- gtk_container_add (GTK_CONTAINER (item), widget);
+ } else {
+ GdlDockItem *w;
+ w = gdl_dock_get_item_by_name (
+ dock, (gchar *) xmlGetProp (node, "name"));
+ if (w) {
+ gtk_container_add (parent, GTK_WIDGET (w));
+ items_docked++;
+ };
+ };
}
+
+ return items_docked;
}
/* Public interface */
@@ -924,12 +957,13 @@
return;
};
- /* FIXME: check for item name duplication */
-
/* bind the item: keep a ref only if the item has a name */
if (item->name) {
- gtk_widget_ref (GTK_WIDGET (item));
- dock->items = g_list_prepend (dock->items, item);
+ if (!gdl_dock_get_item_by_name (dock, item->name)) {
+ gtk_widget_ref (GTK_WIDGET (item));
+ dock->items = g_list_prepend (dock->items, item);
+ } else
+ g_warning (_("Duplicate dock item name"));
};
item->dock = GTK_WIDGET (dock);
@@ -990,4 +1024,3 @@
else
return NULL;
}
-
Index: gdl/gdl-dock-item.c
===================================================================
RCS file: /cvs/gnome/gdl/gdl/gdl-dock-item.c,v
retrieving revision 1.2
diff -u -r1.2 gdl-dock-item.c
--- gdl/gdl-dock-item.c 2001/10/10 13:09:14 1.2
+++ gdl/gdl-dock-item.c 2001/11/10 08:48:26
@@ -1261,8 +1261,13 @@
gdl_dock_item_hide_cb (GtkWidget *widget,
GdlDockItem *item)
{
+ GtkObject *dock;
+
+ /* if the item is anonymous the item gets destroyed after the hide,
+ so save the pointer to the dock */
+ dock = GTK_OBJECT (item->dock);
gdl_dock_item_hide (item);
- gtk_signal_emit_by_name (GTK_OBJECT (item->dock), "layout_changed");
+ gtk_signal_emit_by_name (dock, "layout_changed");
}
Index: gdl/gdl-dock-notebook.c
===================================================================
RCS file: /cvs/gnome/gdl/gdl/gdl-dock-notebook.c,v
retrieving revision 1.2
diff -u -r1.2 gdl-dock-notebook.c
--- gdl/gdl-dock-notebook.c 2001/10/10 13:09:14 1.2
+++ gdl/gdl-dock-notebook.c 2001/11/10 08:48:26
@@ -164,8 +164,6 @@
parent = GTK_WIDGET (item)->parent;
nb = GDL_DOCK_NOTEBOOK (item);
- GDL_TRACE ();
-
children = gtk_container_children (GTK_CONTAINER (nb->notebook));
/* Check if only one item remains in the notebook. */
if (g_list_length (children) <= 1) {
@@ -300,6 +298,7 @@
/* create the container notebook */
bin->child = notebook->notebook = gtk_notebook_new ();
gtk_widget_set_parent (notebook->notebook, GTK_WIDGET (notebook));
+ gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook->notebook), TRUE);
gtk_signal_connect (GTK_OBJECT (notebook->notebook), "switch_page",
(GtkSignalFunc) gdl_dock_notebook_switch_page,
(gpointer) notebook);
? anjuta.spec
? anjuta2.patch
? libanjuta/GNOME_Development_Anjuta-common.c
? libanjuta/GNOME_Development_Anjuta-skels.c
? libanjuta/GNOME_Development_Anjuta-stubs.c
? libanjuta/GNOME_Development_Anjuta.h
? src/anjuta2
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/anjuta2/ChangeLog,v
retrieving revision 1.148
diff -u -r1.148 ChangeLog
--- ChangeLog 2001/11/09 05:03:54 1.148
+++ ChangeLog 2001/11/10 08:40:48
@@ -1,3 +1,20 @@
+2001-11-10 Gustavo Giráldez <gustavo giraldez gmx net>
+
+ * src/tools.c (update_plugins): call anjuta_window_save_layout
+ when (de)activating plugins.
+ * src/window.c (anjuta_window_add_widget): bind the new item to
+ the dock instead of adding it. This is more efficient, since
+ add_item creates a paned which will be later destroyed when
+ loading the layout.
+ (anjuta_window_remove_widget): hide the item instead of removing
+ from the container. Hide takes care of auto_reducing the
+ container.
+ (anjuta_window_load_layout): check if the default layout contains
+ any dock items.
+ * plugins/document-manager/document-manager-tool.c (impl_cleanup):
+ commented a gtk_container_remove which caused a Gtk warning if the
+ dockitem was hidden.
+
2001-11-08 Naba Kumar <kh_naba yahoo com>
* MAINTAINERS: Corrected my email address.
Index: plugins/document-manager/document-manager-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/document-manager-tool.c,v
retrieving revision 1.10
diff -u -r1.10 document-manager-tool.c
--- plugins/document-manager/document-manager-tool.c 2001/11/04 01:55:21 1.10
+++ plugins/document-manager/document-manager-tool.c 2001/11/10 08:40:52
@@ -122,8 +122,8 @@
docman = gtk_object_get_data (GTK_OBJECT (tool), "DocumentManager");
- gtk_container_remove (GTK_CONTAINER (GTK_WIDGET (docman)->parent),
- docman);
+/* gtk_container_remove (GTK_CONTAINER (GTK_WIDGET (docman)->parent), */
+/* docman); */
if (docman->current_document) {
set_current_document (tool, NULL);
Index: src/tools.c
===================================================================
RCS file: /cvs/gnome/anjuta2/src/tools.c,v
retrieving revision 1.13
diff -u -r1.13 tools.c
--- src/tools.c 2001/11/04 01:55:57 1.13
+++ src/tools.c 2001/11/10 08:40:52
@@ -238,6 +238,7 @@
CORBA_Environment ev;
InstalledTool *tool;
OAF_ServerInfo *ret;
+ gboolean save_layout = FALSE;
CORBA_exception_init (&ev);
@@ -268,6 +269,7 @@
g_free (tool->name);
CORBA_Object_release (tool->tool, &ev);
g_free (tool);
+ save_layout = TRUE;
}
else
{
@@ -310,8 +312,12 @@
installed_tools = g_slist_append (
installed_tools, tool);
}
+ save_layout = TRUE;
}
}
+
+ if (save_layout)
+ anjuta_window_save_layout (shell->window);
CORBA_exception_free (&ev);
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/anjuta2/src/window.c,v
retrieving revision 1.43
diff -u -r1.43 window.c
--- src/window.c 2001/11/04 01:55:57 1.43
+++ src/window.c 2001/11/10 08:40:52
@@ -272,8 +272,7 @@
GtkWidget *item;
item = gdl_dock_item_new (id, name, GDL_DOCK_ITEM_BEH_NORMAL);
gtk_container_add (GTK_CONTAINER (item), w);
- gdl_dock_add_item (GDL_DOCK (window->dock),
- GDL_DOCK_ITEM (item), GDL_DOCK_LEFT);
+ gdl_dock_bind_item (GDL_DOCK (window->dock), GDL_DOCK_ITEM (item));
gtk_object_set_data (GTK_OBJECT (w), "dockitem", item);
@@ -285,7 +284,7 @@
{
GtkWidget *item;
item = gtk_object_get_data (GTK_OBJECT (w), "dockitem");
- gtk_container_remove (item->parent, item);
+ gdl_dock_item_hide (GDL_DOCK_ITEM (item));
}
void
@@ -365,7 +364,9 @@
g_free (filename);
if (doc) {
- gdl_dock_layout_load (GDL_DOCK (window->dock), doc->root->childs->childs);
+ if (doc->root->childs->childs)
+ gdl_dock_layout_load (GDL_DOCK (window->dock),
+ doc->root->childs->childs);
xmlFreeDoc (doc);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]