diff options
author | Tristan Van Berkom <tvb@src.gnome.org> | 2007-07-24 20:33:23 +0000 |
---|---|---|
committer | Tristan Van Berkom <tvb@src.gnome.org> | 2007-07-24 20:33:23 +0000 |
commit | 775aeb219479121d8f47fb83b6ca9b8e98bc5328 (patch) | |
tree | 098cb1729c967496e836a648ad929adddabcf5df | |
parent | 6eda77f84a8f22943562ff8b66a0d2ab8b4c6384 (diff) | |
download | glade-775aeb219479121d8f47fb83b6ca9b8e98bc5328.tar.gz |
Dont add objects to a project that already contains the said object.
* gladeui/glade-project.c: Dont add objects to a project that already contains the said object.
* plugins/gtk+/glade-gtk.c: Add tab labels by default to notebook pages (bug 345438)
svn path=/trunk/; revision=1509
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | gladeui/glade-project.c | 4 | ||||
-rw-r--r-- | gladeui/glade-widget.c | 3 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk.c | 37 |
4 files changed, 40 insertions, 8 deletions
@@ -15,6 +15,10 @@ (selection wasnt being drawn on some widgets, now it's working and there's less "flicker" when drag/resizing widgets too). + * gladeui/glade-project.c: Dont add objects to a project that already contains the said object. + + * plugins/gtk+/glade-gtk.c: Add tab labels by default to notebook pages (bug 345438) + 2006-06-23 Tristan Van Berkom <tvb@gnome.org> * NEWS, configure.ac: Rolling 3.3.2 diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c index 31c8ba12..3e6a2138 100644 --- a/gladeui/glade-project.c +++ b/gladeui/glade-project.c @@ -940,6 +940,10 @@ glade_project_add_object (GladeProject *project, if ((gwidget = glade_widget_get_from_gobject (object)) == NULL) return; + /* Dont add widgets that are already in the project */ + if (glade_project_has_object (project, object)) + return; + /* Code body starts here */ reentrancy_count++; diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c index 8325654f..8715c20d 100644 --- a/gladeui/glade-widget.c +++ b/gladeui/glade-widget.c @@ -2658,7 +2658,8 @@ glade_widget_get_adaptor (GladeWidget *widget) void glade_widget_set_project (GladeWidget *widget, GladeProject *project) { - if (widget->project != project) { + if (widget->project != project) + { widget->project = project; g_object_notify (G_OBJECT (widget), "project"); } diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c index 99a3278d..751f2ef2 100644 --- a/plugins/gtk+/glade-gtk.c +++ b/plugins/gtk+/glade-gtk.c @@ -2645,6 +2645,7 @@ glade_gtk_notebook_get_first_blank_page (GtkNotebook *notebook) static void glade_gtk_notebook_set_n_pages (GObject *object, const GValue *value) { + static GladeWidgetAdaptor *wadaptor = NULL; GladeWidget *widget; GtkNotebook *notebook; GtkWidget *child_widget, *tab_widget; @@ -2659,6 +2660,9 @@ glade_gtk_notebook_set_n_pages (GObject *object, const GValue *value) new_size = g_value_get_int (value); + if (wadaptor == NULL) + wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL); + /* Ensure base size of notebook */ if (glade_widget_superuser () == FALSE) { @@ -2666,13 +2670,32 @@ glade_gtk_notebook_set_n_pages (GObject *object, const GValue *value) { gint position = glade_gtk_notebook_get_first_blank_page (notebook); GtkWidget *placeholder = glade_placeholder_new (); - GtkWidget *tab_placeholder = glade_placeholder_new (); + + GladeWidget *glabel = + glade_widget_adaptor_create_widget + (wadaptor, FALSE, + "parent", widget, + "project", glade_widget_get_project (widget), + NULL); + gchar *str = g_strdup_printf ("page %d", i + 1); + glade_widget_property_set (glabel, "label", str); + g_free (str); + + g_object_set_data (glabel->object, "special-child-type", "tab"); + gtk_widget_show (GTK_WIDGET (glabel->object)); gtk_notebook_insert_page (notebook, placeholder, NULL, position); - - gtk_notebook_set_tab_label (notebook, placeholder, tab_placeholder); - g_object_set_data (G_OBJECT (tab_placeholder), "special-child-type", "tab"); + + /* Must tell the project that were adding a widget (so that + * saving works properly & it appears in the inspector properly) + */ + glade_project_add_object (glade_widget_get_project (widget), NULL, glabel->object); + + /* Must pass through GladeWidget api so that packing props + * are correctly assigned. + */ + glade_widget_add_child (widget, glabel, FALSE); } } @@ -2767,7 +2790,8 @@ glade_gtk_notebook_add_child (GladeWidgetAdaptor *adaptor, notebook = GTK_NOTEBOOK (object); num_page = gtk_notebook_get_n_pages (notebook); - + gwidget = glade_widget_get_from_gobject (object); + /* Just append pages blindly when loading/dupping */ if (glade_widget_superuser ()) @@ -2784,7 +2808,6 @@ glade_gtk_notebook_add_child (GladeWidgetAdaptor *adaptor, { gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); - gwidget = glade_widget_get_from_gobject (object); glade_widget_property_set (gwidget, "pages", num_page + 1); gwidget = glade_widget_get_from_gobject (child); @@ -4607,7 +4630,7 @@ glade_gtk_menu_shell_delete_child (GladeBaseEditor *editor, GObject *item = glade_widget_get_object (gparent); GtkWidget *submenu = NULL; GList list = {0, }; - gint n_children; + gint n_children = 0; if (GTK_IS_MENU_ITEM (item) && (submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)))) |