From: John Darrington Date: Mon, 2 Mar 2009 07:58:01 +0000 (+0900) Subject: Rename get_object_assert to get_action_assert X-Git-Tag: v0.7.3~269 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f36da737674d3a58b3d8a7f404ca40cb3ba09394;p=pspp-builds.git Rename get_object_assert to get_action_assert --- diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index aa052c07..a65764f4 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -120,7 +120,7 @@ builder_new_real (const gchar *name) GObject * -get_object_assert (GtkBuilder *builder, const gchar *name) +get_object_assert (GtkBuilder *builder, const gchar *name, GType type) { GObject *o = NULL; g_assert (name); @@ -130,23 +130,26 @@ get_object_assert (GtkBuilder *builder, const gchar *name) if ( !o ) g_critical ("Object \"%s\" could not be found\n", name); + if ( ! g_type_is_a (G_OBJECT_TYPE (o), type)) + { + g_critical ("Object \"%s\" was expected to have type %s, but in fact has type %s", + name, g_type_name (type), G_OBJECT_TYPE_NAME (o)); + } + return o; } -GtkWidget * -get_widget_assert (gpointer x, const gchar *name) -{ - GObject *obj = G_OBJECT (x); - GtkWidget *w = NULL; - g_assert (name); - - if (GTK_IS_BUILDER (obj)) - w = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (obj), name)); - if ( !w ) - g_critical ("Widget \"%s\" could not be found\n", name); +GtkAction * +get_action_assert (GtkBuilder *builder, const gchar *name) +{ + return GTK_ACTION (get_object_assert (builder, name, GTK_TYPE_ACTION)); +} - return w; +GtkWidget * +get_widget_assert (GtkBuilder *builder, const gchar *name) +{ + return GTK_WIDGET (get_object_assert (builder, name, GTK_TYPE_WIDGET)); } /* Converts a string in the pspp locale to utf-8. diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index e1fc0e82..17e777ac 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -29,13 +29,6 @@ void paste_syntax_in_new_window (const gchar *syntax); -/* - GtkRecentChooserMenu was added in 2.10.0 - but it didn't support GtkRecentFilters until - 2.10.2 -*/ -#define RECENT_LISTS_AVAILABLE GTK_CHECK_VERSION (2, 10, 2) - struct fmt_spec; /* Formats a value according to FORMAT @@ -46,8 +39,9 @@ gchar * value_to_text (union value v, struct fmt_spec format); gboolean text_to_value (const gchar *text, union value *v, struct fmt_spec format); -GObject * get_object_assert (GtkBuilder *builder, const gchar *name); -GtkWidget * get_widget_assert (gpointer x, const gchar *name); +GObject *get_object_assert (GtkBuilder *builder, const gchar *name, GType type); +GtkAction * get_action_assert (GtkBuilder *builder, const gchar *name); +GtkWidget * get_widget_assert (GtkBuilder *builder, const gchar *name); /* Converts a string in the pspp locale to utf-8 */ char * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err); diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index c8263183..e2424cf0 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -165,19 +165,19 @@ extern PsppireDataStore *the_data_store ; static void set_paste_menuitem_sensitivity (PsppireDataWindow *de, gboolean x) { - GObject *edit_paste = get_object_assert (de->builder, "edit_paste"); + GtkAction *edit_paste = get_action_assert (de->builder, "edit_paste"); - gtk_action_set_sensitive (GTK_ACTION (edit_paste), x); + gtk_action_set_sensitive (edit_paste, x); } static void set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x) { - GObject *edit_copy = get_object_assert (de->builder, "edit_copy"); - GObject *edit_cut = get_object_assert (de->builder, "edit_cut"); + GtkAction *edit_copy = get_action_assert (de->builder, "edit_copy"); + GtkAction *edit_cut = get_action_assert (de->builder, "edit_cut"); - gtk_action_set_sensitive (GTK_ACTION (edit_copy), x); - gtk_action_set_sensitive (GTK_ACTION (edit_cut), x); + gtk_action_set_sensitive (edit_copy, x); + gtk_action_set_sensitive (edit_cut, x); } /* Run the EXECUTE command. */ @@ -195,8 +195,7 @@ transformation_change_callback (bool transformations_pending, { PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - GtkUIManager *uim = - GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1")); + GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER)); GtkWidget *menuitem = gtk_ui_manager_get_widget (uim,"/ui/menubar/transform/transform_run-pending"); @@ -321,18 +320,6 @@ on_weight_change (GObject *o, gint weight_index, gpointer data) static void add_most_recent (const char *file_name) { -#if RECENT_LISTS_AVAILABLE - - GtkRecentManager *manager = gtk_recent_manager_get_default(); - gchar *uri = g_filename_to_uri (file_name, NULL, NULL); - - gtk_recent_manager_remove_item (manager, uri, NULL); - - if ( ! gtk_recent_manager_add_item (manager, uri)) - g_warning ("Could not add item %s to recent list\n",uri); - - g_free (uri); -#endif } void @@ -884,8 +871,6 @@ create_var_sheet_variable_popup_menu (PsppireDataWindow *de) } -#if RECENT_LISTS_AVAILABLE && 0 - static void on_recent_data_select (GtkMenuShell *menushell, gpointer user_data) { @@ -926,7 +911,6 @@ on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) g_free (file); } -#endif static void enable_delete_cases (GtkWidget *w, gint case_num, gpointer data) @@ -954,8 +938,7 @@ on_switch_sheet (GtkNotebook *notebook, { PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (user_data); - GtkUIManager *uim = - GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1")); + GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER)); GtkWidget *view_data = gtk_ui_manager_get_widget (uim,"/ui/menubar/view/view_data"); @@ -992,20 +975,17 @@ on_switch_sheet (GtkNotebook *notebook, static GtkAction * resolve_action (GtkBuilder *builder, const gchar *action, const gchar *proxy) { - GObject *pr = NULL; - GObject *act = get_object_assert (builder, action); + GtkWidget *pr = NULL; + GtkAction *act = get_action_assert (builder, action); g_assert (GTK_IS_ACTION (act)); if ( proxy ) - { - pr = get_object_assert (builder, proxy); - g_assert (GTK_IS_WIDGET (pr)); - } + pr = get_widget_assert (builder, proxy); if ( pr ) - gtk_action_connect_proxy (GTK_ACTION (act), GTK_WIDGET (pr)); + gtk_action_connect_proxy (act, pr); - return GTK_ACTION (act); + return act; } @@ -1024,8 +1004,6 @@ psppire_data_window_init (PsppireDataWindow *de) GtkWidget *hb ; GtkWidget *sb ; - GtkUIManager *uim; - GtkWidget *box = gtk_vbox_new (FALSE, 0); de->builder = builder_new ("data-editor.ui"); @@ -1098,11 +1076,11 @@ psppire_data_window_init (PsppireDataWindow *de) de); - g_signal_connect (get_object_assert (de->builder, "edit_copy"), + g_signal_connect (get_action_assert (de->builder, "edit_copy"), "activate", G_CALLBACK (on_edit_copy), de); - g_signal_connect (get_object_assert (de->builder, "edit_cut"), + g_signal_connect (get_action_assert (de->builder, "edit_cut"), "activate", G_CALLBACK (on_edit_cut), de); @@ -1201,7 +1179,7 @@ psppire_data_window_init (PsppireDataWindow *de) } - g_signal_connect (get_object_assert (de->builder, "edit_paste"), "activate", + g_signal_connect (get_action_assert (de->builder, "edit_paste"), "activate", G_CALLBACK (on_edit_paste), de); @@ -1586,28 +1564,31 @@ psppire_data_window_init (PsppireDataWindow *de) } - -#if RECENT_LISTS_AVAILABLE && 0 +#if 0 { GtkRecentManager *rm = gtk_recent_manager_get_default (); - GtkWidget *recent_data = get_object_assert (de->builder, "file_recent-data"); - GtkWidget *recent_files = get_object_assert (de->builder, "file_recent-files"); - GtkWidget *recent_separator = get_object_assert (de->builder, "file_separator1"); + GtkAction *recent_data = get_action_assert (de->builder, "file_recent-data"); + GtkAction *recent_files = get_action_assert (de->builder, "file_recent-files"); +#if 0 + GtkWidget *recent_separator = get_widget_assert (de->builder, "file_separator1"); +#endif GtkWidget *menu = gtk_recent_chooser_menu_new_for_manager (rm); GtkRecentFilter *filter = gtk_recent_filter_new (); +#if 0 gtk_widget_show (recent_data); gtk_widget_show (recent_files); gtk_widget_show (recent_separator); +#endif gtk_recent_filter_add_pattern (filter, "*.sav"); gtk_recent_filter_add_pattern (filter, "*.SAV"); gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter); - gtk_widget_set_sensitive (recent_data, TRUE); + gtk_action_set_sensitive (recent_data, TRUE); g_signal_connect (menu, "selection-done", G_CALLBACK (on_recent_data_select), de); @@ -1630,18 +1611,18 @@ psppire_data_window_init (PsppireDataWindow *de) } #endif - g_signal_connect (get_object_assert (de->builder,"file_new_syntax"), + g_signal_connect (get_action_assert (de->builder,"file_new_syntax"), "activate", G_CALLBACK (create_syntax_window), NULL); - g_signal_connect (get_object_assert (de->builder,"file_open_syntax"), + g_signal_connect (get_action_assert (de->builder,"file_open_syntax"), "activate", G_CALLBACK (open_syntax_window), de); { - GObject *abt = get_object_assert (de->builder, "help_about"); + GtkAction *abt = get_action_assert (de->builder, "help_about"); g_object_set (abt, "stock-id", "gtk-about", NULL); g_signal_connect (abt, "activate", @@ -1650,7 +1631,7 @@ psppire_data_window_init (PsppireDataWindow *de) } - g_signal_connect (get_object_assert (de->builder,"help_reference"), + g_signal_connect (get_action_assert (de->builder,"help_reference"), "activate", G_CALLBACK (reference_manual), de); @@ -1674,22 +1655,22 @@ psppire_data_window_init (PsppireDataWindow *de) gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW); gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW); - g_signal_connect (get_object_assert (de->builder, "view_statusbar"), + g_signal_connect (get_action_assert (de->builder, "view_statusbar"), "activate", G_CALLBACK (status_bar_activate), de); - g_signal_connect (get_object_assert (de->builder, "view_gridlines"), + g_signal_connect (get_action_assert (de->builder, "view_gridlines"), "activate", G_CALLBACK (grid_lines_activate), de); - g_signal_connect (get_object_assert (de->builder, "view_data"), + g_signal_connect (get_action_assert (de->builder, "view_data"), "activate", G_CALLBACK (data_view_activate), de); - g_signal_connect (get_object_assert (de->builder, "view_variables"), + g_signal_connect (get_action_assert (de->builder, "view_variables"), "activate", G_CALLBACK (variable_view_activate), de); @@ -1709,16 +1690,16 @@ psppire_data_window_init (PsppireDataWindow *de) - g_signal_connect (get_object_assert (de->builder, "file_quit"), + g_signal_connect (get_action_assert (de->builder, "file_quit"), "activate", G_CALLBACK (file_quit), de); - g_signal_connect (get_object_assert (de->builder, "transform_run-pending"), + g_signal_connect (get_action_assert (de->builder, "transform_run-pending"), "activate", G_CALLBACK (execute), de); - g_signal_connect (get_object_assert (de->builder, "windows_minimise_all"), + g_signal_connect (get_action_assert (de->builder, "windows_minimise_all"), "activate", G_CALLBACK (psppire_window_minimise_all), NULL); @@ -1746,10 +1727,12 @@ psppire_data_window_init (PsppireDataWindow *de) de->data_sheet_cases_popup_menu = GTK_MENU (create_data_sheet_cases_popup_menu (de)); - uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1")); + { + GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER)); PSPPIRE_WINDOW (de)->menu = GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows/windows_minimise_all")->parent); + } g_object_set (de->data_editor, diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index 9c1e73a5..3e6b2e44 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -232,23 +232,23 @@ psppire_output_window_init (PsppireOutputWindow *window) window->fp = NULL; - g_signal_connect (get_object_assert (xml,"help_about"), + g_signal_connect (get_action_assert (xml,"help_about"), "activate", G_CALLBACK (about_new), window); - g_signal_connect (get_object_assert (xml,"help_reference"), + g_signal_connect (get_action_assert (xml,"help_reference"), "activate", G_CALLBACK (reference_manual), NULL); - g_signal_connect (get_object_assert (xml,"windows_minimise-all"), + g_signal_connect (get_action_assert (xml,"windows_minimise-all"), "activate", G_CALLBACK (psppire_window_minimise_all), NULL); { - GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (xml, "uimanager1")); + GtkUIManager *uim = GTK_UI_MANAGER (get_action_assert (xml, "uimanager1")); PSPPIRE_WINDOW (window)->menu = GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar1/windows_menuitem/windows_minimise-all")->parent); diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 2a09c71c..ae9c1a42 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -395,20 +395,8 @@ open_syntax_window (GtkMenuItem *menuitem, gpointer parent) GtkWidget *se = psppire_syntax_window_new (); if ( psppire_syntax_window_load_from_file (PSPPIRE_SYNTAX_WINDOW (se), file_name, NULL) ) -#if RECENT_LISTS_AVAILABLE - { - GtkRecentManager *manager = gtk_recent_manager_get_default(); - gchar *uri = g_filename_to_uri (file_name, NULL, NULL); - - gtk_recent_manager_remove_item (manager, uri, NULL); - if ( ! gtk_recent_manager_add_item (manager, uri)) - g_warning ("Could not add item %s to recent list\n",uri); + ; - g_free (uri); - } -#else - ; -#endif gtk_widget_show (se); } @@ -470,76 +458,76 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) gtk_widget_show_all (box); - g_signal_connect (get_object_assert (xml,"file_new_syntax"), + g_signal_connect (get_action_assert (xml,"file_new_syntax"), "activate", G_CALLBACK (create_syntax_window), NULL); - g_signal_connect (get_object_assert (xml,"file_open_syntax"), + g_signal_connect (get_action_assert (xml,"file_open_syntax"), "activate", G_CALLBACK (open_syntax_window), window); #if 0 - g_signal_connect (get_object_assert (xml,"file_new_data"), + g_signal_connect (get_action_assert (xml,"file_new_data"), "activate", G_CALLBACK (create_data_window), window); #endif - g_signal_connect (get_object_assert (xml,"help_about"), + g_signal_connect (get_action_assert (xml,"help_about"), "activate", G_CALLBACK (about_new), window); - g_signal_connect (get_object_assert (xml,"help_reference"), + g_signal_connect (get_action_assert (xml,"help_reference"), "activate", G_CALLBACK (reference_manual), NULL); - g_signal_connect_swapped (get_object_assert (xml, "file_save"), + g_signal_connect_swapped (get_action_assert (xml, "file_save"), "activate", G_CALLBACK (syntax_save), window); - g_signal_connect_swapped (get_object_assert (xml, "file_save_as"), + g_signal_connect_swapped (get_action_assert (xml, "file_save_as"), "activate", G_CALLBACK (syntax_save_as), window); - g_signal_connect (get_object_assert (xml,"file_quit"), + g_signal_connect (get_action_assert (xml,"file_quit"), "activate", G_CALLBACK (on_quit), window); - g_signal_connect (get_object_assert (xml,"run_all"), + g_signal_connect (get_action_assert (xml,"run_all"), "activate", G_CALLBACK (on_run_all), window); - g_signal_connect (get_object_assert (xml,"run_selection"), + g_signal_connect (get_action_assert (xml,"run_selection"), "activate", G_CALLBACK (on_run_selection), window); - g_signal_connect (get_object_assert (xml,"run_current_line"), + g_signal_connect (get_action_assert (xml,"run_current_line"), "activate", G_CALLBACK (on_run_current_line), window); - g_signal_connect (get_object_assert (xml,"run_to_end"), + g_signal_connect (get_action_assert (xml,"run_to_end"), "activate", G_CALLBACK (on_run_to_end), window); - g_signal_connect (get_object_assert (xml,"windows_minimise_all"), + g_signal_connect (get_action_assert (xml,"windows_minimise_all"), "activate", G_CALLBACK (psppire_window_minimise_all), NULL); { - GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (xml, "uimanager1")); + GtkUIManager *uim = GTK_UI_MANAGER (get_action_assert (xml, "uimanager1")); PSPPIRE_WINDOW (window)->menu = GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar2/windows/windows_minimise_all")->parent);