[gnome-packagekit] Pack package dependency lists into tabs
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Pack package dependency lists into tabs
- Date: Fri, 1 Jul 2011 10:33:22 +0000 (UTC)
commit 97b37b13f25e3c3734f2fe264d2a8c363712705e
Author: Gary Ching-Pang Lin <chingpang gmail com>
Date: Fri Jul 1 11:32:55 2011 +0100
Pack package dependency lists into tabs
If all package dependency lists are showed in the dialog at the
same time, the window size of the dialog can easily become larger
than the screen, and the user can not click 'Cancel' or 'Continue'.
This patch packs the lists into several tabs, so the window size
is fixed and will not grow.
https://bugzilla.gnome.org/show_bug.cgi?id=653626
Signed-off-by: Gary Ching-Pang Lin <chingpang gmail com>
Signed-off-by: Richard Hughes <richard hughsie com>
src/gpk-dialog.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/gpk-dialog.h | 7 +++
src/gpk-task.c | 46 ++++++++++++++++++-----
3 files changed, 152 insertions(+), 10 deletions(-)
---
diff --git a/src/gpk-dialog.c b/src/gpk-dialog.c
index 939a323..bda890a 100644
--- a/src/gpk-dialog.c
+++ b/src/gpk-dialog.c
@@ -363,3 +363,112 @@ out:
return TRUE;
}
+/**
+ * gpk_dialog_embed_tabbed_widget
+ **/
+gboolean
+gpk_dialog_embed_tabbed_widget (GtkDialog *dialog, GtkNotebook *tabbed_widget)
+{
+ GtkWidget *widget;
+
+ if (! GTK_IS_NOTEBOOK (tabbed_widget))
+ return FALSE;
+
+ widget = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_container_add_with_properties (GTK_CONTAINER (widget),
+ GTK_WIDGET (tabbed_widget),
+ "expand", FALSE,
+ "fill", FALSE,
+ NULL);
+
+ return TRUE;
+}
+
+/**
+ * gpk_dialog_tabbed_package_list_widget:
+ **/
+gboolean
+gpk_dialog_tabbed_package_list_widget (GtkWidget *tab_page, GPtrArray *array)
+{
+ GtkWidget *scroll;
+ GtkListStore *store;
+ GtkWidget *widget;
+ const guint row_height = 48;
+
+ /* convert to a store */
+ store = gpk_dialog_package_array_to_list_store (array);
+
+ /* create a treeview to hold the store */
+ widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+ gpk_dialog_treeview_for_package_list (GTK_TREE_VIEW (widget));
+ gtk_widget_show (widget);
+
+ /* scroll the treeview */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), widget);
+ gtk_widget_show (scroll);
+
+ /* add some spacing to conform to the GNOME HIG */
+ gtk_container_set_border_width (GTK_CONTAINER (scroll), 6);
+
+ /* only allow more space if there are a large number of items */
+ if (array->len > 5) {
+ gtk_widget_set_size_request (GTK_WIDGET (scroll), -1, (row_height * 5) + 8);
+ } else if (array->len > 1) {
+ gtk_widget_set_size_request (GTK_WIDGET (scroll), -1, (row_height * array->len) + 8);
+ }
+
+ /* add scrolled window */
+ gtk_container_add_with_properties (GTK_CONTAINER (tab_page), scroll,
+ "expand", TRUE,
+ "fill", TRUE,
+ NULL);
+
+ /* free the store */
+ g_signal_connect (G_OBJECT (tab_page), "unrealize",
+ G_CALLBACK (gpk_dialog_widget_unrealize_unref_cb), store);
+
+ return TRUE;
+}
+
+/**
+ * gpk_dialog_tabbed_download_size_widget:
+ **/
+gboolean
+gpk_dialog_tabbed_download_size_widget (GtkWidget *tab_page, const gchar *title, guint64 size)
+{
+ GtkWidget *label;
+ GtkWidget *hbox;
+ gchar *text = NULL;
+ gchar *size_str = NULL;
+
+ /* size is zero, don't show "0 bytes" */
+ if (size == 0) {
+ label = gtk_label_new (title);
+ gtk_container_add_with_properties (GTK_CONTAINER (tab_page), label,
+ "expand", FALSE,
+ "fill", FALSE,
+ NULL);
+ goto out;
+ }
+
+ /* add a hbox with the size for deps screen */
+ size_str = g_format_size_for_display (size);
+ text = g_strdup_printf ("%s: %s", title, size_str);
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add_with_properties (GTK_CONTAINER (tab_page), hbox,
+ "expand", FALSE,
+ "fill", FALSE,
+ NULL);
+
+ /* add a label */
+ label = gtk_label_new (text);
+ gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+out:
+ gtk_widget_show (label);
+ g_free (text);
+ g_free (size_str);
+ return TRUE;
+}
diff --git a/src/gpk-dialog.h b/src/gpk-dialog.h
index 233be22..3fd252b 100644
--- a/src/gpk-dialog.h
+++ b/src/gpk-dialog.h
@@ -38,6 +38,13 @@ gboolean gpk_dialog_embed_download_size_widget (GtkDialog *dialog,
const gchar *title,
guint64 size);
gchar *gpk_dialog_package_id_name_join_locale (gchar **package_ids);
+gboolean gpk_dialog_embed_tabbed_widget (GtkDialog *dialog,
+ GtkNotebook *tabbed_widget);
+gboolean gpk_dialog_tabbed_package_list_widget (GtkWidget *tab_page,
+ GPtrArray *array);
+gboolean gpk_dialog_tabbed_download_size_widget (GtkWidget *tab_page,
+ const gchar *title,
+ guint64 size);
G_END_DECLS
diff --git a/src/gpk-task.c b/src/gpk-task.c
index 50e86c4..088b93d 100644
--- a/src/gpk-task.c
+++ b/src/gpk-task.c
@@ -374,7 +374,10 @@ out:
* gpk_task_add_dialog_deps_section:
**/
static void
-gpk_task_add_dialog_deps_section (PkTask *task, PkPackageSack *sack, PkInfoEnum info)
+gpk_task_add_dialog_deps_section (PkTask *task,
+ GtkNotebook *tabbed_widget,
+ PkPackageSack *sack,
+ PkInfoEnum info)
{
PkPackageSack *sack_tmp;
GPtrArray *array_tmp = NULL;
@@ -382,7 +385,8 @@ gpk_task_add_dialog_deps_section (PkTask *task, PkPackageSack *sack, PkInfoEnum
GError *error = NULL;
guint64 size;
const gchar *title;
- GpkTaskPrivate *priv = GPK_TASK(task)->priv;
+ GtkWidget *tab_page;
+ GtkWidget *tab_label;
sack_tmp = pk_package_sack_filter_by_info (sack, info);
if (pk_package_sack_get_size (sack_tmp) == 0) {
@@ -390,32 +394,41 @@ gpk_task_add_dialog_deps_section (PkTask *task, PkPackageSack *sack, PkInfoEnum
goto out;
}
+ tab_page = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (tab_page), 12);
+
/* get the header */
switch (info) {
case PK_INFO_ENUM_INSTALLING:
/* TRANSLATORS: additional message text for the deps dialog */
title = _("The following software also needs to be installed");
+ tab_label = gtk_label_new (_("Install"));
break;
case PK_INFO_ENUM_REMOVING:
case PK_INFO_ENUM_OBSOLETING:
/* TRANSLATORS: additional message text for the deps dialog */
title = _("The following software also needs to be removed");
+ tab_label = gtk_label_new (_("Remove"));
break;
case PK_INFO_ENUM_UPDATING:
/* TRANSLATORS: additional message text for the deps dialog */
title = _("The following software also needs to be updated");
+ tab_label = gtk_label_new (_("Update"));
break;
case PK_INFO_ENUM_REINSTALLING:
/* TRANSLATORS: additional message text for the deps dialog */
title = _("The following software also needs to be re-installed");
+ tab_label = gtk_label_new (_("Reinstall"));
break;
case PK_INFO_ENUM_DOWNGRADING:
/* TRANSLATORS: additional message text for the deps dialog */
title = _("The following software also needs to be downgraded");
+ tab_label = gtk_label_new (_("Downgrade"));
break;
default:
/* TRANSLATORS: additional message text for the deps dialog (we don't know how it's going to be processed -- eeek) */
title = _("The following software also needs to be processed");
+ tab_label = gtk_label_new (_("Other"));
break;
}
@@ -429,8 +442,9 @@ gpk_task_add_dialog_deps_section (PkTask *task, PkPackageSack *sack, PkInfoEnum
/* embed title */
array_tmp = pk_package_sack_get_array (sack_tmp);
- gpk_dialog_embed_download_size_widget (GTK_DIALOG(priv->current_window), title, size);
- gpk_dialog_embed_package_list_widget (GTK_DIALOG(priv->current_window), array_tmp);
+ gpk_dialog_tabbed_download_size_widget (tab_page, title, size);
+ gpk_dialog_tabbed_package_list_widget (tab_page, array_tmp);
+ gtk_notebook_append_page (tabbed_widget, tab_page, tab_label);
out:
if (array_tmp != NULL)
g_ptr_array_unref (array_tmp);
@@ -451,6 +465,7 @@ gpk_task_simulate_question (PkTask *task, guint request, PkResults *results)
guint inputs;
const gchar *title;
const gchar *message = NULL;
+ GtkNotebook *tabbed_widget = NULL;
/* save the current request */
priv->request = request;
@@ -507,25 +522,36 @@ gpk_task_simulate_question (PkTask *task, guint request, PkResults *results)
GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL, "%s", title));
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (priv->current_window), "%s", message);
+ tabbed_widget = GTK_NOTEBOOK (gtk_notebook_new ());
+
/* get the details for all the packages */
sack = pk_results_get_package_sack (results);
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_INSTALLING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_INSTALLING);
/* TRANSLATORS: additional message text for the deps dialog */
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_REMOVING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_REMOVING);
/* TRANSLATORS: additional message text for the deps dialog */
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_UPDATING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_UPDATING);
/* TRANSLATORS: additional message text for the deps dialog */
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_OBSOLETING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_OBSOLETING);
/* TRANSLATORS: additional message text for the deps dialog */
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_REINSTALLING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_REINSTALLING);
/* TRANSLATORS: additional message text for the deps dialog */
- gpk_task_add_dialog_deps_section (task, sack, PK_INFO_ENUM_DOWNGRADING);
+ gpk_task_add_dialog_deps_section (task, tabbed_widget, sack,
+ PK_INFO_ENUM_DOWNGRADING);
+
+ gpk_dialog_embed_tabbed_widget (GTK_DIALOG(priv->current_window),
+ tabbed_widget);
gpk_dialog_embed_do_not_show_widget (GTK_DIALOG(priv->current_window), GPK_SETTINGS_SHOW_DEPENDS);
/* TRANSLATORS: this is button text */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]