Browse files

Enable backend once under Unix

  • Loading branch information...
1 parent 4d4ffed commit 4fc81c736bbd4bcc488034d10b0020edbad356a1 David Mohr committed Aug 1, 2010
Showing with 37 additions and 2 deletions.
  1. +1 −0 src/gchd-internal.h
  2. +1 −1 src/gchd-menu.c
  3. +4 −1 src/gchd-unix.c
  4. +14 −0 src/gchd.c
  5. +1 −0 src/gchd.h
  6. +9 −0 src/grub-choose-default-button-box.c
  7. +7 −0 src/grub-choose-default-widget.c
View
1 src/gchd-internal.h
@@ -42,6 +42,7 @@ struct _Gchd {
GchdMenu menu;
gchar * default_entry;
gchar * grub_dir;
+ gboolean once;
GchdSetDefaultCallback set_callback;
gpointer set_callback_data;
View
2 src/gchd-menu.c
@@ -29,8 +29,8 @@ parse_entries (GchdMenu *menu, gchar * contents) {
/* matched "^menuentry */
c += strlen (mi);
- /* we expect at least one white space */
+ /* we expect at least one white space */
if (*c != ' ')
continue;
else
View
5 src/gchd-unix.c
@@ -142,7 +142,10 @@ set_default_entry (Gchd * gchd, gchar * entry, GError **error)
i = 0;
}
- argv[i++] = "grub-set-default";
+ if (!gchd->once)
+ argv[i++] = "grub-set-default";
+ else
+ argv[i++] = "grub-reboot";
argv[i++] = entry;
argv[i++] = NULL;
View
14 src/gchd.c
@@ -386,3 +386,17 @@ gchd_uses_default (Gchd * gchd, GError ** error)
return TRUE;
}
+
+/**
+ * gchd_set_once:
+ * @gchd : a #Gchd.
+ * @enable : should the selection only be valid for the next reboot?
+ *
+ * If enable is true it will commit the user's selection to be used only
+ * for the next reboot.
+ **/
+void
+gchd_set_once (Gchd * gchd, gboolean enable)
+{
+ gchd->once = enable;
+}
View
1 src/gchd.h
@@ -45,6 +45,7 @@ gint gchd_get_menu_entries (Gchd * gchd, GList **entries, GError **error);
gchar * gchd_get_default_entry (Gchd * gchd, GError **error);
gboolean gchd_set_default_entry (Gchd * gchd, gchar * entry, GchdSetDefaultCallback callback, gpointer data, GError **error);
gboolean gchd_uses_default (Gchd * gchd, GError ** error);
+void gchd_set_once (Gchd * gchd, gboolean enable);
void gchd_set_grub_dir (Gchd * gchd, const gchar * grub_dir);
const gchar * gchd_get_grub_dir (Gchd * gchd);
View
9 src/grub-choose-default-button-box.c
@@ -43,6 +43,7 @@ enum {
PROP_0,
PROP_DEFAULT_ENTRY,
PROP_AUTO_COMMIT,
+ PROP_ONCE,
PROP_GCHD,
PROP_GRUB_DIR,
};
@@ -72,6 +73,7 @@ struct _GrubChooseDefaultButtonBoxPrivate {
GtkWidget ** buttons;
gchar * def_entry;
gboolean autocommit;
+ gboolean once;
};
static void
@@ -87,6 +89,9 @@ grub_choose_default_button_box_get_property (GObject *object, guint property_id,
case PROP_AUTO_COMMIT:
g_value_set_boolean (value, priv->autocommit);
break;
+ case PROP_ONCE:
+ g_value_set_boolean (value, priv->once);
+ break;
case PROP_GCHD:
g_value_set_pointer (value, priv->gchd);
break;
@@ -111,6 +116,9 @@ grub_choose_default_button_box_set_property (GObject *object, guint property_id,
case PROP_AUTO_COMMIT:
priv->autocommit = g_value_get_boolean (value);
break;
+ case PROP_ONCE:
+ priv->once = g_value_get_boolean (value);
+ break;
case PROP_GRUB_DIR:
gchd_set_grub_dir (priv->gchd, g_value_get_string (value));
DBG ("Set grub dir to %s", gchd_get_grub_dir (priv->gchd));
@@ -147,6 +155,7 @@ grub_choose_default_button_box_class_init (GrubChooseDefaultButtonBoxClass *klas
g_object_class_override_property (object_class, PROP_DEFAULT_ENTRY, "default-entry");
g_object_class_override_property (object_class, PROP_AUTO_COMMIT, "auto-commit");
+ g_object_class_override_property (object_class, PROP_ONCE, "once");
g_object_class_install_property (object_class, PROP_GCHD,
g_param_spec_pointer ("gchd", "gchd", "gchd", G_PARAM_READABLE));
View
7 src/grub-choose-default-widget.c
@@ -39,6 +39,13 @@ grub_choose_default_widget_init (gpointer g_iface)
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_interface_install_property (g_iface,
+ g_param_spec_boolean ("once",
+ "once",
+ "Reboot only once with this selection",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
iface->signals[GRUB_CHOOSE_DEFAULT_WIDGET_SIGNAL_SELECTED] = g_signal_new ("selected",
G_TYPE_FROM_CLASS (g_iface), G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GrubChooseDefaultWidgetInterface, selected),

0 comments on commit 4fc81c7

Please sign in to comment.