From: Jim Evins Date: Thu, 12 May 2005 02:41:48 +0000 (+0000) Subject: 2005-05-11 Jim Evins X-Git-Tag: glabels-2_3_0~418 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=843936402808e55c2be7970c22ecbaaafe2f7f73;p=glabels 2005-05-11 Jim Evins * src/window.h: * src/window.c: (gl_window_init), (gl_window_destroy): * src/ui.c: (gl_ui_new), (gl_ui_unref), (recent_tooltip_func): * src/ui-commands.c: (gl_ui_cmd_file_open_recent): Moved management of recent_view back from window.c to ui.c -- it just feels better there. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@531 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index d30ec4e5..e6644679 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2005-05-11 Jim Evins + + * src/window.h: + * src/window.c: (gl_window_init), (gl_window_destroy): + * src/ui.c: (gl_ui_new), (gl_ui_unref), (recent_tooltip_func): + * src/ui-commands.c: (gl_ui_cmd_file_open_recent): + Moved management of recent_view back from window.c to ui.c -- it just feels + better there. + 2005-05-10 Jim Evins * src/window.h: diff --git a/glabels2/src/ui-commands.c b/glabels2/src/ui-commands.c index 1aae2b0a..ef528ebc 100644 --- a/glabels2/src/ui-commands.c +++ b/glabels2/src/ui-commands.c @@ -128,6 +128,7 @@ void gl_ui_cmd_file_open_recent (GtkAction *action, glWindow *window) { + EggRecentViewUIManager *recent_view; EggRecentItem *item; gchar *utf8_filename; @@ -136,7 +137,10 @@ gl_ui_cmd_file_open_recent (GtkAction *action, g_return_if_fail (action && GTK_IS_ACTION(action)); g_return_if_fail (window && GL_IS_WINDOW(window)); - item = egg_recent_view_uimanager_get_item (window->recent_view, action); + recent_view = g_object_get_data (G_OBJECT(window->ui), "recent-view"); + g_return_if_fail (recent_view && EGG_IS_RECENT_VIEW_UIMANAGER (recent_view)); + + item = egg_recent_view_uimanager_get_item (recent_view, action); utf8_filename = gl_recent_get_filename (item); gl_file_open_recent (utf8_filename, window); diff --git a/glabels2/src/ui.c b/glabels2/src/ui.c index 14b821da..53727197 100644 --- a/glabels2/src/ui.c +++ b/glabels2/src/ui.c @@ -27,6 +27,8 @@ #include #include +#include "recent-files/egg-recent-view.h" +#include "recent-files/egg-recent-view-uimanager.h" #include "ui-util.h" #include "ui-commands.h" @@ -34,6 +36,7 @@ #include "prefs.h" #include "stock.h" #include "window.h" +#include "recent.h" #include "debug.h" @@ -75,6 +78,9 @@ static void menu_item_select_cb (GtkMenuItem *proxy, static void menu_item_deselect_cb (GtkMenuItem *proxy, glWindow *window); +static char *recent_tooltip_func (EggRecentItem *item, + gpointer user_data); + /*==========================================================================*/ @@ -718,6 +724,7 @@ gl_ui_new (glWindow *window) GtkUIManager *ui; GtkActionGroup *actions; GError *error = NULL; + EggRecentViewUIManager *recent_view; gl_debug (DEBUG_UI, "START"); @@ -756,6 +763,17 @@ gl_ui_new (glWindow *window) /* Set view grid and markup visibility according to prefs */ set_view_style (ui); + /* add an eggRecentView */ + recent_view = + egg_recent_view_uimanager_new (ui, + "/ui/MenuBar/FileMenu/FileRecentsMenu/FileRecentsPlaceHolder", + G_CALLBACK (gl_ui_cmd_file_open_recent), + window); + egg_recent_view_uimanager_show_icons (recent_view, FALSE); + egg_recent_view_uimanager_set_tooltip_func (recent_view, recent_tooltip_func, NULL); + egg_recent_view_set_model (EGG_RECENT_VIEW (recent_view), gl_recent_get_model ()); + g_object_set_data (G_OBJECT (ui), "recent-view", recent_view); + gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE); gl_debug (DEBUG_UI, "END"); @@ -769,8 +787,16 @@ gl_ui_new (glWindow *window) void gl_ui_unref (GtkUIManager *ui) { + GObject *recent_view; + gl_debug (DEBUG_UI, "START"); + /* Pull out recent view to unreference. */ + recent_view = g_object_get_data (G_OBJECT(ui), "recent-view"); + if (recent_view) { + g_object_unref (recent_view); + } + g_object_unref(ui); gl_debug (DEBUG_UI, "END"); @@ -1125,3 +1151,23 @@ menu_item_deselect_cb (GtkMenuItem *proxy, window->menu_tips_context_id); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Tooltip function for recent file menu items. */ +/*---------------------------------------------------------------------------*/ +static char * +recent_tooltip_func (EggRecentItem *item, gpointer user_data) +{ + char *tip; + char *uri_for_display; + + uri_for_display = egg_recent_item_get_uri_for_display (item); + g_return_val_if_fail (uri_for_display != NULL, NULL); + + tip = g_strdup_printf (_("Open '%s'"), uri_for_display); + + g_free (uri_for_display); + + return tip; +} + + diff --git a/glabels2/src/window.c b/glabels2/src/window.c index 724582a9..d3754865 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "ui.h" #include "ui-commands.h" @@ -38,7 +39,6 @@ #include "xml-label.h" #include "prefs.h" #include "file.h" -#include "recent.h" #include "debug.h" @@ -97,9 +97,6 @@ static void name_changed_cb (glLabel *label, static void modified_changed_cb (glLabel *label, glWindow *window); -static char *recent_tooltip_func (EggRecentItem *item, - gpointer user_data); - /****************************************************************************/ /* Boilerplate Object stuff. */ @@ -170,20 +167,6 @@ gl_window_init (glWindow *window) gtk_ui_manager_get_widget (ui, "/DrawingToolBar"), FALSE, FALSE, 0); - /* add an eggRecentView */ - window->recent_view = - egg_recent_view_uimanager_new (ui, - "/ui/MenuBar/FileMenu/FileRecentsMenu/FileRecentsPlaceHolder", - G_CALLBACK (gl_ui_cmd_file_open_recent), - window); - egg_recent_view_uimanager_show_icons (window->recent_view, FALSE); - egg_recent_view_uimanager_set_tooltip_func (window->recent_view, - recent_tooltip_func, - NULL); - egg_recent_view_set_model (EGG_RECENT_VIEW (window->recent_view), - gl_recent_get_model ()); - - window->hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox1), window->hbox, TRUE, TRUE, 0); @@ -268,11 +251,6 @@ gl_window_destroy (GtkObject *gtk_object) window = GL_WINDOW (gtk_object); window_list = g_list_remove (window_list, window); - if (window->recent_view) { - g_object_unref (window->recent_view); - window->recent_view = NULL; - } - if (window->ui) { gl_ui_unref(window->ui); window->ui = NULL; @@ -623,23 +601,3 @@ modified_changed_cb (glLabel *label, gl_debug (DEBUG_WINDOW, "END"); } -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Tooltip function for recent file menu items. */ -/*---------------------------------------------------------------------------*/ -static char * -recent_tooltip_func (EggRecentItem *item, gpointer user_data) -{ - char *tip; - char *uri_for_display; - - uri_for_display = egg_recent_item_get_uri_for_display (item); - g_return_val_if_fail (uri_for_display != NULL, NULL); - - tip = g_strdup_printf (_("Open '%s'"), uri_for_display); - - g_free (uri_for_display); - - return tip; -} - - diff --git a/glabels2/src/window.h b/glabels2/src/window.h index 09f736d0..502b1d6c 100644 --- a/glabels2/src/window.h +++ b/glabels2/src/window.h @@ -27,8 +27,6 @@ #include #include -#include "recent-files/egg-recent-view.h" -#include "recent-files/egg-recent-view-uimanager.h" #include "view.h" #include "label.h" @@ -63,8 +61,6 @@ struct _glWindow { glUIPropertyBar *property_bar; glUISidebar *sidebar; - EggRecentViewUIManager *recent_view; - GtkWidget *status_bar; GtkWidget *cursor_info; GtkWidget *cursor_info_frame;