Permalink
Browse files

Bugfixes.

 * Make the exec function work more efficiently and without leaks.
 * Cleanup remainders of the GtkDialog base class.
  • Loading branch information...
1 parent b99874c commit 2d0cbaa7cae42803f9ca7894041356c930421860 David Mohr committed Aug 7, 2010
Showing with 27 additions and 20 deletions.
  1. +27 −20 src/grub-choose-default-window.c
@@ -49,6 +49,7 @@
static void update_reboot (GrubChooseDefaultWindow *win);
static void update_once (GrubChooseDefaultWindow *win);
static void perform_reboot (GrubChooseDefaultWindow *win);
+static void quit (GrubChooseDefaultWindow *win);
static void handle_selected (GrubChooseDefaultWidget *box, const gchar * entry, gpointer data);
static void handle_cancel (GtkButton *button, gpointer data);
static void handle_delete (GtkWidget *widget, GdkEvent * event, gpointer data);
@@ -295,28 +296,35 @@ perform_reboot (GrubChooseDefaultWindow *win)
r = grub_choose_default_exec (config_dir, script, FALSE, NULL);
- if (r)
+ if (!r)
{
- return;
- }
+ for (config_dirs = g_get_system_config_dirs (); *config_dirs != NULL && !r; config_dirs++)
+ {
+ r = grub_choose_default_exec (*config_dirs, script, FALSE, NULL);
+ }
- for (config_dirs = g_get_system_config_dirs (); *config_dirs != NULL; config_dirs++)
- {
- r = grub_choose_default_exec (*config_dirs, script, FALSE, NULL);
- if (r)
- break;
+ /* we found no script */
+
+ if (!r)
+ {
+ g_set_error (&error,
+ GCHD_ERROR, GCHD_ERROR_NO_REBOOT_SCRIPT,
+ "Could not find any reboot scripts.\nYou can install one in %s/%s .",
+ config_dir, script);
+ grub_choose_default_error (GTK_WIDGET (win), error);
+ g_error_free (error);
+ }
}
- /* we found no script */
+ g_free (script);
+}
- g_set_error (&error,
- GCHD_ERROR, GCHD_ERROR_NO_REBOOT_SCRIPT,
- "Could not find any reboot scripts.\nYou can install one in %s/%s .",
- config_dir, script);
- grub_choose_default_error (GTK_WIDGET (win), error);
- g_error_free (error);
+static void
+quit (GrubChooseDefaultWindow *win)
+{
+ save_settings (win);
- g_free (script);
+ gtk_main_quit ();
}
static void
@@ -332,19 +340,18 @@ handle_selected (GrubChooseDefaultWidget *box, const gchar * entry, gpointer dat
perform_reboot (win);
}
- gtk_dialog_response (GTK_DIALOG (win), GTK_RESPONSE_ACCEPT);
+ quit ();
}
static void
handle_cancel (GtkButton *button, gpointer data)
{
GrubChooseDefaultWindow *win = GRUB_CHOOSE_DEFAULT_WINDOW (data);
- save_settings (win);
-
- gtk_main_quit ();
+ quit (win);
}
+
static void
handle_delete (GtkWidget *widget, GdkEvent * event, gpointer data)
{

0 comments on commit 2d0cbaa

Please sign in to comment.