]> git.sur5r.net Git - glabels/commitdiff
2005-05-11 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Thu, 12 May 2005 02:41:48 +0000 (02:41 +0000)
committerJim Evins <evins@snaught.com>
Thu, 12 May 2005 02:41:48 +0000 (02:41 +0000)
* 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

glabels2/ChangeLog
glabels2/src/ui-commands.c
glabels2/src/ui.c
glabels2/src/window.c
glabels2/src/window.h

index d30ec4e5eac90c5565f3baea7c9e59785d518787..e664467921fdbe5993e0088adcdb3d8d2676ee12 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-11  Jim Evins  <evins@snaught.com>
+
+       * 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  <evins@snaught.com>
 
        * src/window.h:
index 1aae2b0a69951eaaeb6f1832911e2da410ddd665..ef528ebc2eadd9dfdc85e067a412eac93b873700 100644 (file)
@@ -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);
index 14b821da0fab05fc4d00db688b72a8f4ae77af6f..53727197cea1765e9f75b1a5f00bdd8b263fe5e3 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <glib/gi18n.h>
 #include <gconf/gconf-client.h>
+#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;
+}
+
+
index 724582a92c3c0dc0e2721bd689cf0e740754cd08..d3754865f8f36591ed5a048552c9a3f36b37c095 100644 (file)
@@ -31,6 +31,7 @@
 #include <gtk/gtkhbox.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkframe.h>
+#include <gtk/gtkstatusbar.h>
 
 #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);
-
 \f
 /****************************************************************************/
 /* 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;
-}
-
-
index 09f736d070fb2d07f9ac567bc359f01748e9f052..502b1d6c2efa84d1149a34d4bd52938109c8fc07 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <gtk/gtkwindow.h>
 #include <gtk/gtkuimanager.h>
-#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;