diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index cbedeac0e..570667b17 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,8 @@ +2002-05-26 Jody Goldberg + + * background-properties-capplet.c (cb_dialog_response) : improve + handling of help failures. + Sun May 26 11:29:14 2002 Jonathan Blandford * background-properties-capplet.c (main): use APPID instead of diff --git a/capplets/background/background-properties-capplet.c b/capplets/background/background-properties-capplet.c index f569eccfd..dc1cca924 100644 --- a/capplets/background/background-properties-capplet.c +++ b/capplets/background/background-properties-capplet.c @@ -451,19 +451,11 @@ create_dialog (ApplierSet *set) static void cb_dialog_response (GtkDialog *dialog, gint response_id) { - if (response_id == GTK_RESPONSE_HELP) { - GError *error = NULL; - - /* TODO : get this written */ - gnome_help_display_desktop (NULL, - "control-center-manual", + if (response_id == GTK_RESPONSE_HELP) + capplet_help (GTK_WINDOW (dialog), "config-background.xml", - "CONFIGURATION", &error); - if (error) { - g_warning ("help error: %s\n", error->message); - g_error_free (error); - } - } else + "CONFIGURATION"); + else gtk_main_quit (); } /* Callback issued during drag movements */ diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index 2a900f916..376d1d4ad 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,7 @@ +2002-05-26 Jody Goldberg + + * capplet-util.c (capplet_help) : new utility. + 2002-05-16 jacob berkman * gconf-property-editor.c (peditor_image_set_filename): if we diff --git a/capplets/common/capplet-util.c b/capplets/common/capplet-util.c index 8d3fa536b..a979c2671 100644 --- a/capplets/common/capplet-util.c +++ b/capplets/common/capplet-util.c @@ -284,3 +284,42 @@ capplet_init (int argc, } #endif + +/** + * capplet_help : + * @parent : + * @helpfile : + * @section : + * + * A quick utility routine to display help for capplets, and handle errors in a + * Havoc happy way. + **/ +void +capplet_help (GtkWindow *parent, char const *helpfile, char const *section) +{ + GError *error = NULL; + + g_return_if_fail (helpfile != NULL); + g_return_if_fail (section != NULL); + + gnome_help_display_desktop (NULL, + "control-center-manual", + helpfile, section, &error); + if (error) { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (GTK_WINDOW (parent), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("There was an error displaying help: %s"), + error->message); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (gtk_widget_destroy), NULL); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_widget_show (dialog); + g_error_free (error); + } +} diff --git a/capplets/common/capplet-util.h b/capplets/common/capplet-util.h index 9873bc011..39b501c28 100644 --- a/capplets/common/capplet-util.h +++ b/capplets/common/capplet-util.h @@ -90,4 +90,6 @@ void capplet_init (int argc, SetupPropertyEditorsFn setup_property_editors_fn, GetLegacySettingsFn get_legacy_settings_fn); +void capplet_help (GtkWindow *parent, char const *helpfile, char const *section); + #endif /* __CAPPLET_UTIL_H */ diff --git a/capplets/default-applications/ChangeLog b/capplets/default-applications/ChangeLog index b2c87eaca..741a4341e 100644 --- a/capplets/default-applications/ChangeLog +++ b/capplets/default-applications/ChangeLog @@ -1,3 +1,13 @@ +2002-05-26 Jody Goldberg + + * file-types-capplet.c (cb_file_type_dialog_response) : Improve + handling of help failures. + +2002-05-26 Jody Goldberg + + * gnome-default-applications-properties.c (dialog_response) : improve + handling of help failures. + Sun May 26 11:33:26 2002 Jonathan Blandford * gnome-default-applications-properties.c (main): use APPID diff --git a/capplets/default-applications/gnome-default-applications-properties.c b/capplets/default-applications/gnome-default-applications-properties.c index e3ba79e4b..3204c90fb 100644 --- a/capplets/default-applications/gnome-default-applications-properties.c +++ b/capplets/default-applications/gnome-default-applications-properties.c @@ -540,19 +540,11 @@ dialog_response (GtkDialog *widget, gint response_id, GladeXML *dialog) { - if (response_id == GTK_RESPONSE_HELP) { - GError *error = NULL; - - /* TODO : get this written */ - gnome_help_display_desktop (NULL, - "control-center-manual", - "config-default-apps.xml", - "CONFIGURATION", &error); - if (error) { - g_warning ("help error: %s\n", error->message); - g_error_free (error); - } - } else + if (response_id == GTK_RESPONSE_HELP) + capplet_help (GTK_WINDOW (widget), + "config-default-apps.xml", + "CONFIGURATION"); + else gtk_main_quit (); } diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index 06e6f7e25..e499b5ad9 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,3 +1,14 @@ +2002-05-24 Jody Goldberg + + * mime-type-info.c (mime_category_info_load_all) : make this more paranoid. + * mime-category-edit-dialog.c (update_subcategories) : Move this over + here. + +2002-05-17 Jody Goldberg + + * mime-type-info.c (mime_category_info_using_custom_app) : add some + protection. + 2002-05-08 Jody Goldberg http://bugzilla.gnome.org/show_bug.cgi?id=17728 diff --git a/capplets/file-types/file-types-capplet.c b/capplets/file-types/file-types-capplet.c index b545e0165..d2e6465fd 100644 --- a/capplets/file-types/file-types-capplet.c +++ b/capplets/file-types/file-types-capplet.c @@ -35,6 +35,7 @@ #include #include +#include "capplet-util.h" #include "mime-types-model.h" #include "mime-edit-dialog.h" #include "mime-category-edit-dialog.h" @@ -42,8 +43,6 @@ #include "service-edit-dialog.h" #include "service-info.h" -#define WID(x) (glade_xml_get_widget (dialog, x)) - static void add_mime_cb (GtkButton *button, GladeXML *dialog) { @@ -179,19 +178,11 @@ remove_cb (GtkButton *button, GladeXML *dialog) static void cb_file_type_dialog_response (GtkDialog *dialog, gint response_id) { - if (response_id == GTK_RESPONSE_HELP) { - GError *error = NULL; - - /* TODO : get this written */ - gnome_help_display_desktop (NULL, - "control-center-manual", + if (response_id == GTK_RESPONSE_HELP) + capplet_help (GTK_WINDOW (dialog), "config-file-type.xml", - "CONFIGURATION", &error); - if (error) { - g_warning ("help error: %s\n", error->message); - g_error_free (error); - } - } else + "CONFIGURATION"); + else gtk_main_quit (); } diff --git a/capplets/file-types/mime-category-edit-dialog.c b/capplets/file-types/mime-category-edit-dialog.c index 30a75127e..3cab10947 100644 --- a/capplets/file-types/mime-category-edit-dialog.c +++ b/capplets/file-types/mime-category-edit-dialog.c @@ -343,13 +343,17 @@ populate_application_list (MimeCategoryEditDialog *dialog) gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_menu_item_new_with_label (_("Custom"))); if (found_idx < 0) { + gboolean req_terminal = FALSE; found_idx = i; - if (dialog->p->info->default_action->command != NULL) - gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")), - dialog->p->info->default_action->command); + if (dialog->p->info->default_action != NULL) { + if (dialog->p->info->default_action->command != NULL) + gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("program_entry")), + dialog->p->info->default_action->command); + req_terminal = dialog->p->info->default_action->requires_terminal; + } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")), - dialog->p->info->default_action->requires_terminal); + req_terminal); } else { gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE); } @@ -363,6 +367,35 @@ populate_application_list (MimeCategoryEditDialog *dialog) update_sensitivity (dialog); } +static void +update_subcategories (ModelEntry *entry, MimeCategoryInfo *category) +{ + ModelEntry *tmp; + + switch (entry->type) { + case MODEL_ENTRY_MIME_TYPE: + if (MIME_TYPE_INFO (entry)->use_category) { + gnome_vfs_mime_application_free (MIME_TYPE_INFO (entry)->default_action); + + if (category->default_action == NULL) + MIME_TYPE_INFO (entry)->default_action = NULL; + else + MIME_TYPE_INFO (entry)->default_action = gnome_vfs_mime_application_copy (category->default_action); + } + + break; + + case MODEL_ENTRY_CATEGORY: + if (entry == MODEL_ENTRY (category) || MIME_CATEGORY_INFO (entry)->use_parent_category) + for (tmp = entry->first_child; tmp != NULL; tmp = tmp->next) + update_subcategories (tmp, category); + break; + + default: + break; + } +} + static void store_data (MimeCategoryEditDialog *dialog) { @@ -401,8 +434,7 @@ store_data (MimeCategoryEditDialog *dialog) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("use_category_toggle"))); model_entry_save (MODEL_ENTRY (dialog->p->info)); - - mime_category_info_update (dialog->p->info); + update_subcategories (MODEL_ENTRY (dialog->p->info), dialog->p->info); } static void diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index 0791b2c08..5918b2108 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -357,7 +357,11 @@ mime_category_info_load_all (MimeCategoryInfo *category) if (appid != NULL && *appid != '\0') category->default_action = gnome_vfs_application_registry_get_mime_application (appid); - else + + /* This must be non NULL, so be extra careful incase gnome-vfs + * spits back a NULL + */ + if (category->default_action == NULL) category->default_action = g_new0 (GnomeVFSMimeApplication, 1); } @@ -382,7 +386,9 @@ mime_category_info_using_custom_app (const MimeCategoryInfo *category) gchar *tmp; gboolean ret; - if (category->default_action->name == NULL) + if (category == NULL || + category->default_action == NULL || + category->default_action->name == NULL) return TRUE; tmp = g_strdup_printf ("Custom %s", category->name); @@ -471,41 +477,6 @@ mime_category_info_save (MimeCategoryInfo *category) set_subcategory_ids (MODEL_ENTRY (category), category, category->default_action->id); } -static void -update_subcategories (ModelEntry *entry, MimeCategoryInfo *category) -{ - ModelEntry *tmp; - - switch (entry->type) { - case MODEL_ENTRY_MIME_TYPE: - if (MIME_TYPE_INFO (entry)->use_category) { - gnome_vfs_mime_application_free (MIME_TYPE_INFO (entry)->default_action); - - if (category->default_action == NULL) - MIME_TYPE_INFO (entry)->default_action = NULL; - else - MIME_TYPE_INFO (entry)->default_action = gnome_vfs_mime_application_copy (category->default_action); - } - - break; - - case MODEL_ENTRY_CATEGORY: - if (entry == MODEL_ENTRY (category) || MIME_CATEGORY_INFO (entry)->use_parent_category) - for (tmp = entry->first_child; tmp != NULL; tmp = tmp->next) - update_subcategories (tmp, category); - break; - - default: - break; - } -} - -void -mime_category_info_update (MimeCategoryInfo *info) -{ - update_subcategories (MODEL_ENTRY (info), info); -} - static GList * find_possible_supported_apps (ModelEntry *entry, gboolean top) { diff --git a/capplets/file-types/mime-type-info.h b/capplets/file-types/mime-type-info.h index a73a3f34c..264e810b9 100644 --- a/capplets/file-types/mime-type-info.h +++ b/capplets/file-types/mime-type-info.h @@ -107,7 +107,6 @@ MimeCategoryInfo *mime_category_info_new (MimeCategoryInfo *parent, void mime_category_info_load_all (MimeCategoryInfo *category); gboolean mime_category_info_using_custom_app (const MimeCategoryInfo *category); void mime_category_info_save (MimeCategoryInfo *category); -void mime_category_info_update (MimeCategoryInfo *info); GList *mime_category_info_find_apps (MimeCategoryInfo *info); gchar *mime_category_info_get_full_name (MimeCategoryInfo *info);