[gnome-software/wip/folders: 6/10] Add a selection mode to the installed list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/folders: 6/10] Add a selection mode to the installed list
- Date: Thu, 14 Nov 2013 02:05:46 +0000 (UTC)
commit cacdd78bf2c656a6677585d24cf1a459a1dba418
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Nov 13 20:36:24 2013 -0500
Add a selection mode to the installed list
src/gnome-software.ui | 14 ++++++++++++++
src/gs-shell-installed.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
src/gs-shell.c | 10 ++++++++++
3 files changed, 67 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 3eb52ed..5e14440 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -2,6 +2,11 @@
<!-- Generated with glade 3.15.2 on Thu Aug 15 17:13:59 2013 -->
<interface>
<!-- interface-requires gtk+ 3.10 -->
+ <object class="GtkImage" id="button_select_image">
+ <property name="visible">True</property>
+ <property name="icon_name">object-select-symbolic</property>
+ <property name="icon_size">0</property>
+ </object>
<object class="GtkApplicationWindow" id="window_software">
<property name="can_focus">False</property>
<property name="default-width">1200</property>
@@ -182,6 +187,15 @@
<property name="pack_type">end</property>
</packing>
</child>
+ <child>
+ <object class="GtkToggleButton" id="button_select">
+ <property name="image">button_select_image</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index f00ce5a..ad272bf 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -51,6 +51,7 @@ struct GsShellInstalledPrivate
gboolean cache_valid;
gboolean waiting;
GsShell *shell;
+ gboolean selection_mode;
};
G_DEFINE_TYPE (GsShellInstalled, gs_shell_installed, G_TYPE_OBJECT)
@@ -73,11 +74,18 @@ gs_shell_installed_app_widget_activated_cb (GtkListBox *list_box,
GsShellInstalled *shell_installed)
{
GsAppWidget *app_widget;
- GsApp *app;
app_widget = GS_APP_WIDGET (gtk_bin_get_child (GTK_BIN (row)));
- app = gs_app_widget_get_app (app_widget);
- gs_shell_show_app (shell_installed->priv->shell, app);
+
+ if (shell_installed->priv->selection_mode) {
+ gboolean selected;
+ selected = gs_app_widget_get_selected (app_widget);
+ gs_app_widget_set_selected (app_widget, !selected);
+ } else {
+ GsApp *app;
+ app = gs_app_widget_get_app (app_widget);
+ gs_shell_show_app (shell_installed->priv->shell, app);
+ }
}
typedef struct {
@@ -240,6 +248,10 @@ gs_shell_installed_add_app (GsShellInstalled *shell, GsApp *app)
gs_app_widget_set_size_groups (GS_APP_WIDGET (widget),
priv->sizegroup_image,
priv->sizegroup_name);
+
+ gs_app_widget_set_selectable (GS_APP_WIDGET (widget),
+ priv->selection_mode);
+
gtk_widget_show (widget);
}
@@ -298,6 +310,9 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed, gboolean scroll_u
if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_INSTALLED) {
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_show (widget);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_select"));
+ gtk_widget_show (widget);
}
gtk_list_box_invalidate_sort (priv->list_box_installed);
@@ -542,6 +557,26 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
g_ptr_array_unref (pending);
}
+static void
+selection_mode_cb (GtkToggleButton *button, GsShellInstalled *shell_installed)
+{
+ GsShellInstalledPrivate *priv = shell_installed->priv;
+ GList *children, *l;
+ GtkWidget *row;
+ GtkWidget *app_widget;
+
+ priv->selection_mode = gtk_toggle_button_get_active (button);
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->list_box_installed));
+ for (l = children; l; l = l->next) {
+ row = l->data;
+ app_widget = gtk_bin_get_child (GTK_BIN (row));
+ gs_app_widget_set_selectable (GS_APP_WIDGET (app_widget),
+ priv->selection_mode);
+ }
+ g_list_free (children);
+}
+
/**
* gs_shell_installed_setup:
*/
@@ -553,6 +588,7 @@ gs_shell_installed_setup (GsShellInstalled *shell_installed,
GCancellable *cancellable)
{
GsShellInstalledPrivate *priv = shell_installed->priv;
+ GtkWidget *widget;
g_return_if_fail (GS_IS_SHELL_INSTALLED (shell_installed));
@@ -575,6 +611,10 @@ gs_shell_installed_setup (GsShellInstalled *shell_installed,
gtk_list_box_set_sort_func (priv->list_box_installed,
gs_shell_installed_sort_func,
shell_installed, NULL);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_select"));
+ g_signal_connect (widget, "toggled",
+ G_CALLBACK (selection_mode_cb), shell_installed);
}
/**
diff --git a/src/gs-shell.c b/src/gs-shell.c
index b060fcd..2572eca 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -101,10 +101,14 @@ gs_shell_change_mode (GsShell *shell,
GtkWidget *widget;
GtkWindow *window;
const gchar *text;
+ GtkStyleContext *context;
if (priv->ignore_primary_buttons)
return;
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (widget), TRUE);
+
/* hide all mode specific header widgets here, they will be shown in the
* refresh functions
*/
@@ -119,15 +123,21 @@ gs_shell_change_mode (GsShell *shell,
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_remove"));
gtk_widget_hide (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_select"));
+ gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_hide (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_selection_menu_button"));
+ gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
gtk_widget_hide (widget);
+ context = gtk_widget_get_style_context (GTK_WIDGET (gtk_builder_get_object (priv->builder,
"header")));
+ gtk_style_context_remove_class (context, "selection-mode");
/* set the window title back to default */
window = GTK_WINDOW (gtk_builder_get_object (priv->builder, "window_software"));
/* TRANSLATORS: this is the main window title */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]