[gnome-packagekit] Use the GSetting enum functionality



commit af232059eee7a7a5695c4e07e8bd0dc0df4d6bf7
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jun 20 13:11:35 2010 +0100

    Use the GSetting enum functionality

 data/org.gnome.packagekit.gschema.migrate |    2 -
 data/org.gnome.packagekit.gschema.xml     |   16 +++-
 src/cc-update-panel.c                     |   35 +------
 src/gpk-application.c                     |  146 ++++++++++++++--------------
 src/gpk-check-update.c                    |   23 +-----
 src/gpk-enum.c                            |   47 ---------
 src/gpk-enum.h                            |    2 -
 7 files changed, 92 insertions(+), 179 deletions(-)
---
diff --git a/data/org.gnome.packagekit.gschema.migrate b/data/org.gnome.packagekit.gschema.migrate
index 5b831be..edaa19f 100644
--- a/data/org.gnome.packagekit.gschema.migrate
+++ b/data/org.gnome.packagekit.gschema.migrate
@@ -27,14 +27,12 @@ force-get-updates-login = /apps/gnome-packagekit/update-icon/force_get_updates_l
 frequency-get-updates = /apps/gnome-packagekit/update-icon/frequency_get_updates
 frequency-get-upgrades = /apps/gnome-packagekit/update-icon/frequency_get_upgrades
 frequency-refresh-cache = /apps/gnome-packagekit/update-icon/frequency_refresh_cache
-auto-update = /apps/gnome-packagekit/update-icon/auto_update
 update-battery = /apps/gnome-packagekit/update-icon/update_battery
 filter-basename = /apps/gnome-packagekit/application/filter_basename
 filter-newest = /apps/gnome-packagekit/application/filter_newest
 filter-arch = /apps/gnome-packagekit/application/filter_arch
 category-groups = /apps/gnome-packagekit/application/category_groups
 show-all-packages = /apps/gnome-packagekit/application/show_all_packages
-search-mode = /apps/gnome-packagekit/application/search_mode
 repo-show-details = /apps/gnome-packagekit/repo/show_details
 notify-mobile-connection = /apps/gnome-packagekit/update-viewer/notify_mobile_connection
 only-newest = /apps/gnome-packagekit/update-viewer/only_newest
diff --git a/data/org.gnome.packagekit.gschema.xml b/data/org.gnome.packagekit.gschema.xml
index dbb08fa..5e14085 100644
--- a/data/org.gnome.packagekit.gschema.xml
+++ b/data/org.gnome.packagekit.gschema.xml
@@ -1,4 +1,14 @@
 <schemalist>
+  <enum id="org.gnome.packagekit.AutoUpdateType">
+    <value nick="all" value="0"/>
+    <value nick="security" value="1"/>
+    <value nick="none" value="2"/>
+  </enum>
+  <enum id="org.gnome.packagekit.SearchType">
+    <value nick="name" value="0"/>
+    <value nick="details" value="1"/>
+    <value nick="file" value="2"/>
+  </enum>
   <schema id="FIXME" path="/apps/">
     <child name="gnome-packagekit" schema="gnome-packagekit"/>
     <child name="gnome-settings-daemon" schema="gnome-settings-daemon"/>
@@ -143,10 +153,10 @@
       <summary>How often to refresh the package cache</summary>
       <description>How often to refresh the package cache. Value is in seconds.</description>
     </key>
-    <key name="auto-update" type="s">
+    <key name="auto-update" enum="org.gnome.packagekit.AutoUpdateType">
       <default>'none'</default>
       <summary>Automatically update these types of updates</summary>
-      <description>Automatically update these types of updates. Options are "all", "security", or "none".</description>
+      <description>Automatically update these types of updates.</description>
     </key>
     <key name="update-battery" type="b">
       <default>false</default>
@@ -178,7 +188,7 @@
       <summary>Show the 'All Packages' group menu</summary>
       <description>Show the all packages menu item. This takes a long time to populate on most backends and is not generally required by end users.</description>
     </key>
-    <key name="search-mode" type="s">
+    <key name="search-mode" enum="org.gnome.packagekit.SearchType">
       <default>'details'</default>
       <summary>The search mode used by default</summary>
       <description>The search mode used by default. Options are "name", "details", or "file".</description>
diff --git a/src/cc-update-panel.c b/src/cc-update-panel.c
index 475b96e..2ea72e9 100644
--- a/src/cc-update-panel.c
+++ b/src/cc-update-panel.c
@@ -133,29 +133,12 @@ cc_update_panel_upgrade_freq_combo_changed (GtkWidget *widget, CcUpdatePanel *pa
 static void
 cc_update_panel_update_combo_changed (GtkWidget *widget, CcUpdatePanel *panel)
 {
-	gchar *value;
-	const gchar *action;
-	GpkUpdateEnum update = GPK_UPDATE_ENUM_UNKNOWN;
+	GpkUpdateEnum update;
 
-	value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
-	if (value == NULL) {
-		egg_warning ("value NULL");
+	update = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+	if (update == -1)
 		return;
-	}
-	if (strcmp (value, PK_UPDATE_ALL_TEXT) == 0) {
-		update = GPK_UPDATE_ENUM_ALL;
-	} else if (strcmp (value, PK_UPDATE_SECURITY_TEXT) == 0) {
-		update = GPK_UPDATE_ENUM_SECURITY;
-	} else if (strcmp (value, PK_UPDATE_NONE_TEXT) == 0) {
-		update = GPK_UPDATE_ENUM_NONE;
-	} else {
-		g_assert (FALSE);
-	}
-
-	action = gpk_update_enum_to_text (update);
-	egg_debug ("Changing %s to %s", GPK_SETTINGS_AUTO_UPDATE, action);
-	g_settings_set_string (panel->priv->settings, GPK_SETTINGS_AUTO_UPDATE, action);
-	g_free (value);
+	g_settings_set_enum (panel->priv->settings, GPK_SETTINGS_AUTO_UPDATE, update);
 }
 
 /**
@@ -261,21 +244,13 @@ cc_update_panel_upgrade_freq_combo_setup (CcUpdatePanel *panel)
 static void
 cc_update_panel_auto_update_combo_setup (CcUpdatePanel *panel)
 {
-	gchar *value;
 	gboolean is_writable;
 	GtkWidget *widget;
 	GpkUpdateEnum update;
 
 	widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "combobox_install"));
 	is_writable = g_settings_is_writable (panel->priv->settings, GPK_SETTINGS_AUTO_UPDATE);
-	value = g_settings_get_string (panel->priv->settings, GPK_SETTINGS_AUTO_UPDATE);
-	if (value == NULL) {
-		egg_warning ("invalid schema, please re-install");
-		return;
-	}
-	egg_debug ("value from settings %s", value);
-	update = gpk_update_enum_from_text (value);
-	g_free (value);
+	update = g_settings_get_enum (panel->priv->settings, GPK_SETTINGS_AUTO_UPDATE);
 
 	/* do we have permission to write? */
 	gtk_widget_set_sensitive (widget, is_writable);
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 15378aa..d132e0a 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -51,26 +51,26 @@ static void     gpk_application_finalize   (GObject	    *object);
 #define GPK_APPLICATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_APPLICATION, GpkApplicationPrivate))
 
 typedef enum {
-	PK_SEARCH_NAME,
-	PK_SEARCH_DETAILS,
-	PK_SEARCH_FILE,
-	PK_SEARCH_UNKNOWN
-} PkSearchType;
+	GPK_SEARCH_NAME,
+	GPK_SEARCH_DETAILS,
+	GPK_SEARCH_FILE,
+	GPK_SEARCH_UNKNOWN
+} GpkSearchType;
 
 typedef enum {
-	PK_MODE_NAME_DETAILS_FILE,
-	PK_MODE_GROUP,
-	PK_MODE_ALL_PACKAGES,
-	PK_MODE_SELECTED,
-	PK_MODE_UNKNOWN
-} PkSearchMode;
+	GPK_MODE_NAME_DETAILS_FILE,
+	GPK_MODE_GROUP,
+	GPK_MODE_ALL_PACKAGES,
+	GPK_MODE_SELECTED,
+	GPK_MODE_UNKNOWN
+} GpkSearchMode;
 
 typedef enum {
-	PK_ACTION_NONE,
-	PK_ACTION_INSTALL,
-	PK_ACTION_REMOVE,
-	PK_ACTION_UNKNOWN
-} PkActionMode;
+	GPK_ACTION_NONE,
+	GPK_ACTION_INSTALL,
+	GPK_ACTION_REMOVE,
+	GPK_ACTION_UNKNOWN
+} GpkActionMode;
 
 struct GpkApplicationPrivate
 {
@@ -94,9 +94,9 @@ struct GpkApplicationPrivate
 	PkBitfield		 filters_current;
 	gboolean		 has_package; /* if we got a package in the search */
 	gboolean		 search_in_progress;
-	PkSearchType		 search_type;
-	PkSearchMode		 search_mode;
-	PkActionMode		 action;
+	GpkSearchType		 search_type;
+	GpkSearchMode		 search_mode;
+	GpkActionMode		 action;
 	PkPackageSack		*package_sack;
 	GtkWidget		*image_status;
 	GpkHelperRun		*helper_run;
@@ -339,9 +339,9 @@ gpk_application_get_checkbox_enable (GpkApplication *application, PkBitfield sta
 	gboolean enable_installed = TRUE;
 	gboolean enable_available = TRUE;
 
-	if (application->priv->action == PK_ACTION_INSTALL)
+	if (application->priv->action == GPK_ACTION_INSTALL)
 		enable_installed = FALSE;
-	else if (application->priv->action == PK_ACTION_REMOVE)
+	else if (application->priv->action == GPK_ACTION_REMOVE)
 		enable_available = FALSE;
 
 	if (pk_bitfield_contain (state, GPK_STATE_INSTALLED))
@@ -383,7 +383,7 @@ gpk_application_set_buttons_apply_clear (GpkApplication *application)
 		gtk_widget_set_sensitive (widget, FALSE);
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "button_clear"));
 		gtk_widget_set_sensitive (widget, FALSE);
-		application->priv->action = PK_ACTION_NONE;
+		application->priv->action = GPK_ACTION_NONE;
 	} else {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "button_apply"));
 		gtk_widget_set_sensitive (widget, TRUE);
@@ -477,7 +477,7 @@ gpk_application_install (GpkApplication *application)
 	}
 
 	/* changed mind, or wrong mode */
-	if (application->priv->action == PK_ACTION_REMOVE) {
+	if (application->priv->action == GPK_ACTION_REMOVE) {
 		ret = pk_package_sack_remove_package_by_id (application->priv->package_sack, package_id_selected);
 		if (ret) {
 			egg_debug ("removed %s from package array", package_id_selected);
@@ -501,7 +501,7 @@ gpk_application_install (GpkApplication *application)
 	}
 
 	/* set mode */
-	application->priv->action = PK_ACTION_INSTALL;
+	application->priv->action = GPK_ACTION_INSTALL;
 
 	/* add to array */
 	package = pk_package_new ();
@@ -796,7 +796,7 @@ gpk_application_remove (GpkApplication *application)
 	}
 
 	/* changed mind, or wrong mode */
-	if (application->priv->action == PK_ACTION_INSTALL) {
+	if (application->priv->action == GPK_ACTION_INSTALL) {
 		ret = pk_package_sack_remove_package_by_id (application->priv->package_sack, package_id_selected);
 		if (ret) {
 			egg_debug ("removed %s from package array", package_id_selected);
@@ -819,7 +819,7 @@ gpk_application_remove (GpkApplication *application)
 		goto out;
 	}
 
-	application->priv->action = PK_ACTION_REMOVE;
+	application->priv->action = GPK_ACTION_REMOVE;
 	package = pk_package_new ();
 	pk_package_set_id (package, package_id_selected, NULL);
 	g_object_set (package,
@@ -1365,16 +1365,16 @@ gpk_application_suggest_better_search (GpkApplication *application)
 	gchar *text;
 	PkBitfield state = 0;
 
-	if (application->priv->search_mode == PK_MODE_GROUP ||
-	    application->priv->search_mode == PK_MODE_ALL_PACKAGES) {
+	if (application->priv->search_mode == GPK_MODE_GROUP ||
+	    application->priv->search_mode == GPK_MODE_ALL_PACKAGES) {
 		/* TRANSLATORS: be helpful, but this shouldn't happen */
 		message = _("Try entering a package name in the search bar.");
-	}  else if (application->priv->search_mode == PK_MODE_SELECTED) {
+	}  else if (application->priv->search_mode == GPK_MODE_SELECTED) {
 		/* TRANSLATORS: nothing in the package queue */
 		message = _("There are no packages queued to be installed or removed.");
 	} else {
-		if (application->priv->search_type == PK_SEARCH_NAME ||
-		    application->priv->search_type == PK_SEARCH_FILE)
+		if (application->priv->search_type == GPK_SEARCH_NAME ||
+		    application->priv->search_type == GPK_SEARCH_FILE)
 			/* TRANSLATORS: tell the user to switch to details search mode */
 			message = _("Try searching package descriptions by clicking the icon next to the search text.");
 		else
@@ -1526,7 +1526,7 @@ gpk_application_cancel_cb (GtkWidget *button_widget, GpkApplication *application
 	g_cancellable_cancel (application->priv->cancellable);
 
 	/* switch buttons around */
-	application->priv->search_mode = PK_MODE_UNKNOWN;
+	application->priv->search_mode = GPK_MODE_UNKNOWN;
 }
 
 /**
@@ -1671,19 +1671,19 @@ gpk_application_perform_search_name_details_file (GpkApplication *application)
 
 	/* do the search */
 	searches = g_strsplit (application->priv->search_text, " ", -1);
-	if (application->priv->search_type == PK_SEARCH_NAME) {
+	if (application->priv->search_type == GPK_SEARCH_NAME) {
 		pk_client_search_names_async (PK_CLIENT(application->priv->task),
 					     application->priv->filters_current,
 					     searches, application->priv->cancellable,
 					     (PkProgressCallback) gpk_application_progress_cb, application,
 					     (GAsyncReadyCallback) gpk_application_search_cb, application);
-	} else if (application->priv->search_type == PK_SEARCH_DETAILS) {
+	} else if (application->priv->search_type == GPK_SEARCH_DETAILS) {
 		pk_client_search_details_async (PK_CLIENT(application->priv->task),
 					     application->priv->filters_current,
 					     searches, application->priv->cancellable,
 					     (PkProgressCallback) gpk_application_progress_cb, application,
 					     (GAsyncReadyCallback) gpk_application_search_cb, application);
-	} else if (application->priv->search_type == PK_SEARCH_FILE) {
+	} else if (application->priv->search_type == GPK_SEARCH_FILE) {
 		pk_client_search_files_async (PK_CLIENT(application->priv->task),
 					     application->priv->filters_current,
 					     searches, application->priv->cancellable,
@@ -1719,7 +1719,7 @@ gpk_application_perform_search_others (GpkApplication *application)
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 	g_return_if_fail (application->priv->group != NULL);
 
-	if (application->priv->search_mode == PK_MODE_GROUP) {
+	if (application->priv->search_mode == GPK_MODE_GROUP) {
 		groups = g_strsplit (application->priv->group, " ", -1);
 		pk_client_search_groups_async (PK_CLIENT(application->priv->task),
 					      application->priv->filters_current, groups, application->priv->cancellable,
@@ -1794,12 +1794,12 @@ gpk_application_perform_search (GpkApplication *application)
 	gpk_application_clear_details (application);
 	gpk_application_clear_packages (application);
 
-	if (application->priv->search_mode == PK_MODE_NAME_DETAILS_FILE) {
+	if (application->priv->search_mode == GPK_MODE_NAME_DETAILS_FILE) {
 		gpk_application_perform_search_name_details_file (application);
-	} else if (application->priv->search_mode == PK_MODE_GROUP ||
-		   application->priv->search_mode == PK_MODE_ALL_PACKAGES) {
+	} else if (application->priv->search_mode == GPK_MODE_GROUP ||
+		   application->priv->search_mode == GPK_MODE_ALL_PACKAGES) {
 		gpk_application_perform_search_others (application);
-	} else if (application->priv->search_mode == PK_MODE_SELECTED) {
+	} else if (application->priv->search_mode == GPK_MODE_SELECTED) {
 		gpk_application_populate_selected (application);
 	} else {
 		egg_debug ("doing nothing");
@@ -1814,7 +1814,7 @@ gpk_application_find_cb (GtkWidget *button_widget, GpkApplication *application)
 {
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
-	application->priv->search_mode = PK_MODE_NAME_DETAILS_FILE;
+	application->priv->search_mode = GPK_MODE_NAME_DETAILS_FILE;
 	gpk_application_perform_search (application);
 }
 
@@ -2065,7 +2065,7 @@ gpk_application_install_packages_cb (PkTask *task, GAsyncResult *res, GpkApplica
 
 	/* clear if success */
 	pk_package_sack_clear (application->priv->package_sack);
-	application->priv->action = PK_ACTION_NONE;
+	application->priv->action = GPK_ACTION_NONE;
 	gpk_application_set_buttons_apply_clear (application);
 out:
 	if (error_code != NULL)
@@ -2116,7 +2116,7 @@ gpk_application_remove_packages_cb (PkTask *task, GAsyncResult *res, GpkApplicat
 
 	/* clear if success */
 	pk_package_sack_clear (application->priv->package_sack);
-	application->priv->action = PK_ACTION_NONE;
+	application->priv->action = GPK_ACTION_NONE;
 	gpk_application_set_buttons_apply_clear (application);
 out:
 	if (error_code != NULL)
@@ -2137,7 +2137,7 @@ gpk_application_button_apply_cb (GtkWidget *widget, GpkApplication *application)
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
 	package_ids = pk_package_sack_get_ids (application->priv->package_sack);
-	if (application->priv->action == PK_ACTION_INSTALL) {
+	if (application->priv->action == GPK_ACTION_INSTALL) {
 
 		/* install */
 		pk_task_install_packages_async (application->priv->task, package_ids, application->priv->cancellable,
@@ -2148,7 +2148,7 @@ gpk_application_button_apply_cb (GtkWidget *widget, GpkApplication *application)
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "treeview_packages"));
 		gtk_widget_set_sensitive (widget, FALSE);
 
-	} else if (application->priv->action == PK_ACTION_REMOVE) {
+	} else if (application->priv->action == GPK_ACTION_REMOVE) {
 
 		autoremove = g_settings_get_boolean (application->priv->settings, GPK_SETTINGS_ENABLE_AUTOREMOVE);
 
@@ -2267,11 +2267,11 @@ gpk_application_groups_treeview_changed_cb (GtkTreeSelection *selection, GpkAppl
 
 		/* GetPackages? */
 		if (g_strcmp0 (application->priv->group, "all-packages") == 0)
-			application->priv->search_mode = PK_MODE_ALL_PACKAGES;
+			application->priv->search_mode = GPK_MODE_ALL_PACKAGES;
 		else if (g_strcmp0 (application->priv->group, "selected") == 0)
-			application->priv->search_mode = PK_MODE_SELECTED;
+			application->priv->search_mode = GPK_MODE_SELECTED;
 		else
-			application->priv->search_mode = PK_MODE_GROUP;
+			application->priv->search_mode = GPK_MODE_GROUP;
 
 		/* actually do the search */
 		gpk_application_perform_search (application);
@@ -2503,9 +2503,9 @@ gpk_application_packages_treeview_clicked_cb (GtkTreeSelection *selection, GpkAp
 	show_remove = (state == pk_bitfield_value (GPK_STATE_INSTALLED) ||
 		       state == pk_bitfield_value (GPK_STATE_IN_LIST));
 
-	if (application->priv->action == PK_ACTION_INSTALL && !pk_bitfield_contain (state, GPK_STATE_IN_LIST))
+	if (application->priv->action == GPK_ACTION_INSTALL && !pk_bitfield_contain (state, GPK_STATE_IN_LIST))
 		show_remove = FALSE;
-	if (application->priv->action == PK_ACTION_REMOVE && !pk_bitfield_contain (state, GPK_STATE_IN_LIST))
+	if (application->priv->action == GPK_ACTION_REMOVE && !pk_bitfield_contain (state, GPK_STATE_IN_LIST))
 		show_install = FALSE;
 
 	/* only show buttons if we are in the correct mode */
@@ -2624,11 +2624,13 @@ gpk_application_menu_search_by_name (GtkMenuItem *item, gpointer data)
 	GpkApplication *application = GPK_APPLICATION (data);
 
 	/* change type */
-	application->priv->search_type = PK_SEARCH_NAME;
+	application->priv->search_type = GPK_SEARCH_NAME;
 	egg_debug ("set search type=%i", application->priv->search_type);
 
 	/* save default to GSettings */
-	g_settings_set_string (application->priv->settings, GPK_SETTINGS_SEARCH_MODE, "name");
+	g_settings_set_enum (application->priv->settings,
+			     GPK_SETTINGS_SEARCH_MODE,
+			     application->priv->search_type);
 
 	/* set the new icon */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "entry_text"));
@@ -2647,11 +2649,13 @@ gpk_application_menu_search_by_description (GtkMenuItem *item, gpointer data)
 	GpkApplication *application = GPK_APPLICATION (data);
 
 	/* set type */
-	application->priv->search_type = PK_SEARCH_DETAILS;
+	application->priv->search_type = GPK_SEARCH_DETAILS;
 	egg_debug ("set search type=%i", application->priv->search_type);
 
 	/* save default to GSettings */
-	g_settings_set_string (application->priv->settings, GPK_SETTINGS_SEARCH_MODE, "details");
+	g_settings_set_enum (application->priv->settings,
+			     GPK_SETTINGS_SEARCH_MODE,
+			     application->priv->search_type);
 
 	/* set the new icon */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "entry_text"));
@@ -2670,11 +2674,13 @@ gpk_application_menu_search_by_file (GtkMenuItem *item, gpointer data)
 	GpkApplication *application = GPK_APPLICATION (data);
 
 	/* set type */
-	application->priv->search_type = PK_SEARCH_FILE;
+	application->priv->search_type = GPK_SEARCH_FILE;
 	egg_debug ("set search type=%i", application->priv->search_type);
 
 	/* save default to GSettings */
-	g_settings_set_string (application->priv->settings, GPK_SETTINGS_SEARCH_MODE, "file");
+	g_settings_set_enum (application->priv->settings,
+			     GPK_SETTINGS_SEARCH_MODE,
+			     application->priv->search_type);
 
 	/* set the new icon */
 	widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "entry_text"));
@@ -3495,7 +3501,7 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkAppl
 	gboolean enabled;
 	GtkTreeIter iter;
 	const gchar *icon_name;
-	gchar *mode = NULL;
+	GpkSearchType search_type;
 
 	/* get the result */
 	ret = pk_control_get_properties_finish (control, res, &error);
@@ -3549,7 +3555,6 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkAppl
 		gtk_widget_hide (widget);
 	}
 
-
 	/* hide the filters we can't support */
 	if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) == FALSE) {
 		widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "menuitem_installed"));
@@ -3654,43 +3659,38 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, GpkAppl
 		gpk_application_create_group_array_enum (application);
 
 	/* set the search mode */
-	mode = g_settings_get_string (application->priv->settings, GPK_SETTINGS_SEARCH_MODE);
-	if (mode == NULL) {
-		egg_warning ("search mode not set, using name");
-		mode = g_strdup ("name");
-	}
+	search_type = g_settings_get_enum (application->priv->settings, GPK_SETTINGS_SEARCH_MODE);
 
 	/* search by name */
-	if (g_strcmp0 (mode, "name") == 0) {
+	if (search_type == GPK_SEARCH_NAME) {
 		gpk_application_menu_search_by_name (NULL, application);
 
 	/* set to details if we can we do the action? */
-	} else if (g_strcmp0 (mode, "details") == 0) {
+	} else if (search_type == GPK_SEARCH_DETAILS) {
 		if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_DETAILS)) {
 			gpk_application_menu_search_by_description (NULL, application);
 		} else {
-			egg_warning ("cannont use mode %s as not capable, using name", mode);
+			egg_warning ("cannont use mode %i as not capable, using name", search_type);
 			gpk_application_menu_search_by_name (NULL, application);
 		}
 
 	/* set to file if we can we do the action? */
-	} else if (g_strcmp0 (mode, "file") == 0) {
+	} else if (search_type == GPK_SEARCH_FILE) {
 		gpk_application_menu_search_by_file (NULL, application);
 
 		if (pk_bitfield_contain (application->priv->roles, PK_ROLE_ENUM_SEARCH_FILE)) {
 			gpk_application_menu_search_by_file (NULL, application);
 		} else {
-			egg_warning ("cannont use mode %s as not capable, using name", mode);
+			egg_warning ("cannont use mode %i as not capable, using name", search_type);
 			gpk_application_menu_search_by_name (NULL, application);
 		}
 
 	/* mode not recognised */
 	} else {
-		egg_warning ("cannot recognise mode %s, using name", mode);
+		egg_warning ("cannot recognise mode %i, using name", search_type);
 		gpk_application_menu_search_by_name (NULL, application);
 	}
 out:
-	g_free (mode);
 	return;
 }
 
@@ -3789,8 +3789,8 @@ gpk_application_init (GpkApplication *application)
 	application->priv->cancellable = g_cancellable_new ();
 	application->priv->repos = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
-	application->priv->search_type = PK_SEARCH_UNKNOWN;
-	application->priv->search_mode = PK_MODE_UNKNOWN;
+	application->priv->search_type = GPK_SEARCH_UNKNOWN;
+	application->priv->search_mode = GPK_MODE_UNKNOWN;
 	application->priv->filters_current = 0;
 
 	application->priv->markdown = egg_markdown_new ();
@@ -4145,7 +4145,7 @@ gpk_application_init (GpkApplication *application)
 				       (GAsyncReadyCallback) gpk_application_get_repo_list_cb, application);
 
 	/* set current action */
-	application->priv->action = PK_ACTION_NONE;
+	application->priv->action = GPK_ACTION_NONE;
 	gpk_application_set_buttons_apply_clear (application);
 
 	/* hide details */
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index ee4dc71..93185ec 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -781,27 +781,6 @@ gpk_check_update_check_on_battery (GpkCheckUpdate *cupdate)
 }
 
 /**
- * gpk_check_update_get_update_policy:
- **/
-static GpkUpdateEnum
-gpk_check_update_get_update_policy (GpkCheckUpdate *cupdate)
-{
-	GpkUpdateEnum update;
-	gchar *updates;
-
-	g_return_val_if_fail (GPK_IS_CHECK_UPDATE (cupdate), FALSE);
-
-	updates = g_settings_get_string (cupdate->priv->settings, GPK_SETTINGS_AUTO_UPDATE);
-	if (updates == NULL) {
-		egg_warning ("'%s' settings key is null!", GPK_SETTINGS_AUTO_UPDATE);
-		return GPK_UPDATE_ENUM_UNKNOWN;
-	}
-	update = gpk_update_enum_from_text (updates);
-	g_free (updates);
-	return update;
-}
-
-/**
  * gpk_check_update_notify_doing_updates:
  **/
 static void
@@ -920,7 +899,7 @@ gpk_check_update_get_updates_finished_cb (GObject *object, GAsyncResult *res, Gp
 	}
 
 	/* do we do the automatic updates? */
-	update = gpk_check_update_get_update_policy (cupdate);
+	update = g_settings_get_enum (cupdate->priv->settings, GPK_SETTINGS_AUTO_UPDATE);
 	if (update == GPK_UPDATE_ENUM_UNKNOWN) {
 		egg_warning ("policy unknown");
 		goto out;
diff --git a/src/gpk-enum.c b/src/gpk-enum.c
index 077bf50..6e8e3c4 100644
--- a/src/gpk-enum.c
+++ b/src/gpk-enum.c
@@ -262,42 +262,6 @@ static const PkEnumMatch enum_message_icon_name[] = {
 	{0, NULL}
 };
 
-static const PkEnumMatch enum_update[] = {
-	{GPK_UPDATE_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
-	{GPK_UPDATE_ENUM_ALL,			"all"},
-	{GPK_UPDATE_ENUM_SECURITY,		"security"},
-	{GPK_UPDATE_ENUM_NONE,			"none"},
-	{0, NULL}
-};
-
-/**
- * gpk_update_enum_from_text:
- * @update: Text describing the enumerated type
- *
- * Converts a text enumerated type to its unsigned integer representation
- *
- * Return value: the enumerated constant value, e.g. PK_SIGTYPE_ENUM_GPG
- **/
-GpkUpdateEnum
-gpk_update_enum_from_text (const gchar *update)
-{
-	return pk_enum_find_value (enum_update, update);
-}
-
-/**
- * gpk_update_enum_to_text:
- * @update: The enumerated type value
- *
- * Converts a enumerated type to its text representation
- *
- * Return value: the enumerated constant value, e.g. "available"
- **/
-const gchar *
-gpk_update_enum_to_text (GpkUpdateEnum update)
-{
-	return pk_enum_find_string (enum_update, update);
-}
-
 /**
  * gpk_media_type_enum_to_localised_text:
  **/
@@ -2050,17 +2014,6 @@ gpk_enum_test (gpointer data)
 	}
 	egg_test_success (test, NULL);
 
-	/************************************************************/
-	egg_test_title (test, "check we convert all the update bitfield");
-	for (i=0; i<=GPK_UPDATE_ENUM_UNKNOWN; i++) {
-		string = gpk_update_enum_to_text (i);
-		if (string == NULL) {
-			egg_test_failed (test, "failed to get %i", i);
-			break;
-		}
-	}
-	egg_test_success (test, NULL);
-
 	egg_test_end (test);
 }
 #endif
diff --git a/src/gpk-enum.h b/src/gpk-enum.h
index 06ac9b3..cb259e3 100644
--- a/src/gpk-enum.h
+++ b/src/gpk-enum.h
@@ -84,8 +84,6 @@ const gchar	*gpk_role_enum_to_localised_past	(PkRoleEnum	 role)
 							 G_GNUC_CONST;
 const gchar	*gpk_role_enum_to_localised_present	(PkRoleEnum	 role)
 							 G_GNUC_CONST;
-GpkUpdateEnum	 gpk_update_enum_from_text		(const gchar	*update);
-const gchar	*gpk_update_enum_to_text		(GpkUpdateEnum	 update);
 const gchar	*gpk_role_enum_to_icon_name		(PkRoleEnum	 role);
 const gchar	*gpk_media_type_enum_to_localised_text	(PkMediaTypeEnum type)
 							 G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]