Mercurial > geeqie.yaz
changeset 1470:38925ff71a46
do not re-create ui_manager at layout change
author | nadvornik |
---|---|
date | Fri, 20 Mar 2009 22:48:01 +0000 |
parents | 607c60506863 |
children | 65a5c27823c2 |
files | src/layout.c src/layout_util.c src/typedefs.h |
diffstat | 3 files changed, 31 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout.c Fri Mar 20 21:28:31 2009 +0000 +++ b/src/layout.c Fri Mar 20 22:48:01 2009 +0000 @@ -258,7 +258,7 @@ gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0); gtk_widget_show(menu_bar); - lw->toolbar = layout_actions_toolbar(lw); + layout_actions_toolbar(lw); gtk_box_pack_start(GTK_BOX(box), lw->toolbar, FALSE, FALSE, 0); if (!lw->options.toolbar_hidden) gtk_widget_show(lw->toolbar); @@ -1638,7 +1638,6 @@ GtkWidget *files; layout_actions_setup(lw); - layout_actions_add_window(lw, lw->window); lw->group_box = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0); @@ -1770,21 +1769,17 @@ layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); + /* preserve utility_box (image + sidebars), menu_bar and toolbar to be reused later in layout_grid_setup */ /* lw->image is preserved together with lw->utility_box */ - if (lw->utility_box) - { - /* preserve utility_box (image + sidebars) to be reused later in layout_grid_setup */ - gtk_widget_hide(lw->utility_box); - g_object_ref(lw->utility_box); - gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); - } + if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); + if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(lw->menu_bar->parent), lw->menu_bar); + if (lw->toolbar) gtk_container_remove(GTK_CONTAINER(lw->toolbar->parent), lw->toolbar); /* clear it all */ lw->h_pane = NULL; lw->v_pane = NULL; - lw->toolbar = NULL; lw->path_entry = NULL; lw->dir_view = NULL; lw->vd = NULL; @@ -1801,10 +1796,12 @@ lw->info_pixel = NULL; lw->info_zoom = NULL; +/* if (lw->ui_manager) g_object_unref(lw->ui_manager); lw->ui_manager = NULL; lw->action_group = NULL; lw->action_group_editors = NULL; +*/ gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box); lw->group_box = NULL; @@ -1817,6 +1814,9 @@ layout_util_sync(lw); layout_status_update_all(lw); + + // printf("%d %d %d \n", G_OBJECT(lw->utility_box)->ref_count, G_OBJECT(lw->menu_bar)->ref_count, G_OBJECT(lw->toolbar)->ref_count); + /* sync */ if (image_get_fd(lw->image)) @@ -2208,6 +2208,10 @@ layout_bars_close(lw); + g_object_unref(lw->menu_bar); + g_object_unref(lw->toolbar); + g_object_unref(lw->utility_box); + gtk_widget_destroy(lw->window); if (lw->split_image_sizegroup) g_object_unref(lw->split_image_sizegroup);
--- a/src/layout_util.c Fri Mar 20 21:28:31 2009 +0000 +++ b/src/layout_util.c Fri Mar 20 22:48:01 2009 +0000 @@ -1760,6 +1760,8 @@ layout_actions_setup_marks(lw); layout_actions_setup_editors(lw); layout_copy_path_update(lw); + + layout_actions_add_window(lw, lw->window); } void layout_editors_reload_all(void) @@ -1800,15 +1802,20 @@ GtkWidget *layout_actions_menu_bar(LayoutWindow *lw) { - return gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu"); + if (lw->menu_bar) return lw->menu_bar; + lw->menu_bar = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu"); + g_object_ref(lw->menu_bar); + return lw->menu_bar; } GtkWidget *layout_actions_toolbar(LayoutWindow *lw) { - GtkWidget *bar = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar"); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(bar), GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS); - return bar; + if (lw->toolbar) return lw->toolbar; + lw->toolbar = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar"); + g_object_ref(lw->toolbar); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar), GTK_TOOLBAR_ICONS); + return lw->toolbar; } void layout_toolbar_clear(LayoutWindow *lw) @@ -2164,6 +2171,7 @@ GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image) { + if (lw->utility_box) return lw->utility_box; lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); lw->utility_paned = gtk_hpaned_new(); gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->utility_paned, TRUE, TRUE, 0); @@ -2173,6 +2181,7 @@ gtk_widget_show(image); + g_object_ref(lw->utility_box); return lw->utility_box; }
--- a/src/typedefs.h Fri Mar 20 21:28:31 2009 +0000 +++ b/src/typedefs.h Fri Mar 20 22:48:01 2009 +0000 @@ -578,9 +578,10 @@ // gint tools_float; // gint tools_hidden; + GtkWidget *menu_bar; /* referenced by lw, exist during whole lw lifetime */ /* toolbar */ - GtkWidget *toolbar; + GtkWidget *toolbar; /* referenced by lw, exist during whole lw lifetime */ // gint toolbar_hidden; // GtkWidget *thumb_button; @@ -638,7 +639,7 @@ /* misc */ - GtkWidget *utility_box; + GtkWidget *utility_box; /* referenced by lw, exist during whole lw lifetime */ GtkWidget *utility_paned; /* between image and bar */ GtkWidget *bar_sort; GtkWidget *bar;