[gnome-software] Add a checkbox to GsAppWidget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add a checkbox to GsAppWidget
- Date: Fri, 15 Nov 2013 03:38:37 +0000 (UTC)
commit a5a86738d27ac25239f932bb5426a3df889b8533
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Nov 13 20:35:08 2013 -0500
Add a checkbox to GsAppWidget
Make it possible to show a checkbox at the very left of the
app widget. This will be used to implement selection mode for
the list of installed apps.
src/app-widget.ui | 9 +++++++++
src/gs-app-widget.c | 36 ++++++++++++++++++++++++++++++++++++
src/gs-app-widget.h | 5 +++++
3 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/app-widget.ui b/src/app-widget.ui
index 1bdeb70..2a3ec92 100644
--- a/src/app-widget.ui
+++ b/src/app-widget.ui
@@ -10,6 +10,15 @@
<property name="orientation">horizontal</property>
<property name="spacing">3</property>
<child>
+ <object class="GtkCheckButton" id="checkbox">
+ <property name="margin-right">9</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="pixel_size">64</property>
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index 68ce322..4fb043e 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -43,8 +43,10 @@ struct _GsAppWidgetPrivate
GtkWidget *button;
GtkWidget *spinner;
GtkWidget *label;
+ GtkWidget *checkbox;
gboolean colorful;
gboolean show_update;
+ gboolean selectable;
};
G_DEFINE_TYPE_WITH_PRIVATE (GsAppWidget, gs_app_widget, GTK_TYPE_BIN)
@@ -222,6 +224,15 @@ gs_app_widget_refresh (GsAppWidget *app_widget)
default:
break;
}
+
+ if (priv->selectable) {
+ if (gs_app_get_id_kind (priv->app) == GS_APP_ID_KIND_DESKTOP ||
+ gs_app_get_id_kind (priv->app) == GS_APP_ID_KIND_WEBAPP)
+ gtk_widget_set_visible (priv->checkbox, TRUE);
+ gtk_widget_set_sensitive (priv->button, FALSE);
+ } else {
+ gtk_widget_set_visible (priv->checkbox, FALSE);
+ }
}
/**
@@ -301,6 +312,7 @@ gs_app_widget_class_init (GsAppWidgetClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsAppWidget, button);
gtk_widget_class_bind_template_child_private (widget_class, GsAppWidget, spinner);
gtk_widget_class_bind_template_child_private (widget_class, GsAppWidget, label);
+ gtk_widget_class_bind_template_child_private (widget_class, GsAppWidget, checkbox);
}
static void
@@ -353,6 +365,30 @@ gs_app_widget_set_show_update (GsAppWidget *app_widget, gboolean show_update)
app_widget->priv->show_update = show_update;
}
+void
+gs_app_widget_set_selectable (GsAppWidget *app_widget, gboolean selectable)
+{
+ app_widget->priv->selectable = selectable;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app_widget->priv->checkbox), FALSE);
+ gs_app_widget_refresh (app_widget);
+}
+
+void
+gs_app_widget_set_selected (GsAppWidget *app_widget, gboolean selected)
+{
+ if (app_widget->priv->selectable)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app_widget->priv->checkbox), selected);
+}
+
+gboolean
+gs_app_widget_get_selected (GsAppWidget *app_widget)
+{
+ if (app_widget->priv->selectable)
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app_widget->priv->checkbox));
+ else
+ return FALSE;
+}
+
GtkWidget *
gs_app_widget_new (void)
{
diff --git a/src/gs-app-widget.h b/src/gs-app-widget.h
index 5c0324d..f6bff46 100644
--- a/src/gs-app-widget.h
+++ b/src/gs-app-widget.h
@@ -59,6 +59,11 @@ void gs_app_widget_set_colorful (GsAppWidget *app_widget,
gboolean colorful);
void gs_app_widget_set_show_update (GsAppWidget *app_widget,
gboolean show_update);
+void gs_app_widget_set_selectable (GsAppWidget *app_widget,
+ gboolean selectable);
+void gs_app_widget_set_selected (GsAppWidget *app_widget,
+ gboolean selected);
+gboolean gs_app_widget_get_selected (GsAppWidget *app_widget);
GsApp *gs_app_widget_get_app (GsAppWidget *app_widget);
void gs_app_widget_set_app (GsAppWidget *app_widget,
GsApp *app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]