From: Ben Pfaff Date: Tue, 10 May 2011 05:42:37 +0000 (-0700) Subject: gui: Get rid of the_recent_manager global. X-Git-Tag: v0.7.9~302 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b73c7309c2fff2b35f406d8e0e75be3dc3621396;p=pspp-builds.git gui: Get rid of the_recent_manager global. The GTK+ function gtk_recent_manager_get_default() is documented to return a singleton. We might as well take advantage of that instead of caching its return value and passing it around. --- diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 3698a7af..00efcb6b 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -152,9 +152,6 @@ psppire_data_window_class_init (PsppireDataWindowClass *class) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); } - -extern GtkRecentManager *the_recent_mgr; - static void set_paste_menuitem_sensitivity (PsppireDataWindow *de, gboolean x) { @@ -1073,11 +1070,11 @@ psppire_data_window_finish_init (PsppireDataWindow *de, gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-files"); - GtkWidget *menu_data = - gtk_recent_chooser_menu_new_for_manager (the_recent_mgr); + GtkWidget *menu_data = gtk_recent_chooser_menu_new_for_manager ( + gtk_recent_manager_get_default ()); - GtkWidget *menu_files = - gtk_recent_chooser_menu_new_for_manager (the_recent_mgr); + GtkWidget *menu_files = gtk_recent_chooser_menu_new_for_manager ( + gtk_recent_manager_get_default ()); { GtkRecentFilter *filter = gtk_recent_filter_new (); diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index a2bf672e..6612a5d5 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -703,10 +703,9 @@ psppire_window_save_as (PsppireWindow *w) } } -extern GtkRecentManager *the_recent_mgr; -static void add_most_recent (const char *file_name, GtkRecentManager *rm); -static void delete_recent (const char *file_name, GtkRecentManager *rm); +static void add_most_recent (const char *file_name); +static void delete_recent (const char *file_name); gboolean psppire_window_load (PsppireWindow *w, const gchar *file) @@ -725,11 +724,11 @@ psppire_window_load (PsppireWindow *w, const gchar *file) if ( ok ) { psppire_window_set_filename (w, file); - add_most_recent (file, the_recent_mgr); + add_most_recent (file); w->dirty = FALSE; } else - delete_recent (file, the_recent_mgr); + delete_recent (file); return ok; } @@ -841,12 +840,12 @@ psppire_window_open (PsppireWindow *de) If it's already in the list, it moves it to the top */ static void -add_most_recent (const char *file_name, GtkRecentManager *rm) +add_most_recent (const char *file_name) { gchar *uri = g_filename_to_uri (file_name, NULL, NULL); if ( uri ) - gtk_recent_manager_add_item (rm, uri); + gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri); g_free (uri); } @@ -857,12 +856,12 @@ add_most_recent (const char *file_name, GtkRecentManager *rm) If FILE_NAME exists in the recent list, then delete it. */ static void -delete_recent (const char *file_name, GtkRecentManager *rm) +delete_recent (const char *file_name) { gchar *uri = g_filename_to_uri (file_name, NULL, NULL); if ( uri ) - gtk_recent_manager_remove_item (rm, uri, NULL); + gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL); g_free (uri); } diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index e1e352f5..453bc3a8 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -60,8 +60,6 @@ #include "gl/xalloc.h" #include "gl/relocatable.h" -GtkRecentManager *the_recent_mgr; - static void inject_renamed_icons (void); static void create_icon_factory (void); static void load_data_file (PsppireDataWindow *, const char *); @@ -95,9 +93,6 @@ initialize (const char *data_file) journal_enable (); textdomain (PACKAGE); - - the_recent_mgr = gtk_recent_manager_get_default (); - psppire_selector_set_default_selection_func (GTK_TYPE_ENTRY, insert_source_row_into_entry); psppire_selector_set_default_selection_func (PSPPIRE_VAR_VIEW_TYPE, insert_source_row_into_tree_view); psppire_selector_set_default_selection_func (GTK_TYPE_TREE_VIEW, insert_source_row_into_tree_view);