[gnome-packagekit] Add a supported checkbox to gpk-application if the backend supports it
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Add a supported checkbox to gpk-application if the backend supports it
- Date: Thu, 19 Apr 2012 15:52:52 +0000 (UTC)
commit 89563b30ed5f40ccb9ec2ddc90fb0a0c771f8b6d
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 19 16:51:04 2012 +0100
Add a supported checkbox to gpk-application if the backend supports it
data/gpk-application.ui | 8 +++++
data/org.gnome.packagekit.gschema.xml | 5 +++
src/gpk-application.c | 48 ++++++++++++++++++++++++++++++++-
src/gpk-common.h | 1 +
4 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/data/gpk-application.ui b/data/gpk-application.ui
index d66a54c..20e2496 100644
--- a/data/gpk-application.ui
+++ b/data/gpk-application.ui
@@ -309,6 +309,14 @@
<property name="use_underline">True</property>
</object>
</child>
+ <child>
+ <object class="GtkCheckMenuItem" id="menuitem_supported">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">Only show packages supported by the vendor</property>
+ <property name="label" translatable="yes">Only S_upported Packages</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/data/org.gnome.packagekit.gschema.xml b/data/org.gnome.packagekit.gschema.xml
index b515661..674e529 100644
--- a/data/org.gnome.packagekit.gschema.xml
+++ b/data/org.gnome.packagekit.gschema.xml
@@ -35,6 +35,11 @@
<summary>Only show the newest packages in the file lists</summary>
<description>Only show the newest packages in the file lists.</description>
</key>
+ <key name="filter-supported" type="b">
+ <default>false</default>
+ <summary>Only show supported packages in the file lists</summary>
+ <description>Only show supported packages in the file lists.</description>
+ </key>
<key name="filter-arch" type="b">
<default>true</default>
<summary>Only show native packages in the file lists</summary>
diff --git a/src/gpk-application.c b/src/gpk-application.c
index f568f9c..c4b0dc3 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -3020,6 +3020,30 @@ gpk_application_menu_filter_newest_cb (GtkWidget *widget, gpointer user_data)
}
/**
+ * gpk_application_menu_filter_supported_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpk_application_menu_filter_supported_cb (GtkWidget *widget, gpointer user_data)
+{
+ gboolean enabled;
+
+ /* save users preference to GSettings */
+ enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
+ g_settings_set_boolean (settings,
+ GPK_SETTINGS_FILTER_SUPPORTED, enabled);
+
+ /* change the filter */
+ if (enabled)
+ pk_bitfield_add (filters_current, PK_FILTER_ENUM_SUPPORTED);
+ else
+ pk_bitfield_remove (filters_current, PK_FILTER_ENUM_SUPPORTED);
+
+ /* refresh the search results */
+ gpk_application_perform_search (NULL);
+}
+
+/**
* gpk_application_menu_filter_arch_cb:
* @widget: The GtkWidget object
**/
@@ -3457,6 +3481,10 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, gpointe
widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_source"));
gtk_widget_hide (widget);
}
+ if (pk_bitfield_contain (filters, PK_FILTER_ENUM_SUPPORTED) == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_supported"));
+ gtk_widget_hide (widget);
+ }
/* BASENAME, use by default, or hide */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_basename"));
@@ -3496,6 +3524,19 @@ pk_backend_status_get_properties_cb (GObject *object, GAsyncResult *res, gpointe
gtk_widget_hide (widget);
}
+ /* SUPPORTED, use by default, or hide */
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_supported"));
+ if (pk_bitfield_contain (filters, PK_FILTER_ENUM_SUPPORTED)) {
+ /* set from remembered state */
+ enabled = g_settings_get_boolean (settings,
+ GPK_SETTINGS_FILTER_SUPPORTED);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), enabled);
+ /* work round a gtk2+ bug: toggled should be fired when doing gtk_check_menu_item_set_active */
+ gpk_application_menu_filter_supported_cb (widget, NULL);
+ } else {
+ gtk_widget_hide (widget);
+ }
+
/* add an "all" entry if we can GetPackages */
ret = g_settings_get_boolean (settings, GPK_SETTINGS_SHOW_ALL_PACKAGES);
if (ret && pk_bitfield_contain (roles, PK_ROLE_ENUM_GET_PACKAGES)) {
@@ -3893,11 +3934,16 @@ gpk_application_startup_cb (GtkApplication *application, gpointer user_data)
g_signal_connect (widget, "toggled",
G_CALLBACK (gpk_application_menu_filter_newest_cb), NULL);
- /* newest filter */
+ /* arch filter */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_arch"));
g_signal_connect (widget, "toggled",
G_CALLBACK (gpk_application_menu_filter_arch_cb), NULL);
+ /* supported filter */
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "menuitem_supported"));
+ g_signal_connect (widget, "toggled",
+ G_CALLBACK (gpk_application_menu_filter_supported_cb), NULL);
+
/* simple find button */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_find"));
g_signal_connect (widget, "clicked",
diff --git a/src/gpk-common.h b/src/gpk-common.h
index bbbeffd..3b7324e 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -43,6 +43,7 @@ G_BEGIN_DECLS
#define GPK_SETTINGS_FILTER_ARCH "filter-arch"
#define GPK_SETTINGS_FILTER_BASENAME "filter-basename"
#define GPK_SETTINGS_FILTER_NEWEST "filter-newest"
+#define GPK_SETTINGS_FILTER_SUPPORTED "filter-supported"
#define GPK_SETTINGS_IGNORED_DBUS_REQUESTS "ignored-dbus-requests"
#define GPK_SETTINGS_NOTIFY_MOBILE_CONNECTION "notify-mobile-connection"
#define GPK_SETTINGS_ONLY_NEWEST "only-newest"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]