[gnome-software] First cut at implementing details popup
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] First cut at implementing details popup
- Date: Thu, 22 Aug 2013 02:28:22 +0000 (UTC)
commit 166b7b942953fc1674d936637f95bafe6049530f
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 21 22:27:37 2013 -0400
First cut at implementing details popup
This dialog opens when the 'read more' link on the installed list
is activated.
src/gs-app-widget.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index ee23b99..9b25eca 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -368,6 +368,87 @@ size_allocate_cb (GtkWidget *box,
g_string_free (s, TRUE);
}
+static gboolean
+read_more_cb (GtkLabel *widget,
+ const gchar *uri,
+ GsAppWidget *app_widget)
+{
+ GtkWidget *details, *button, *grid;
+ GtkWidget *image, *label;
+ GsApp *app;
+ PangoAttrList *attr_list;
+ const gchar *tmp;
+
+ app = gs_app_widget_get_app (app_widget);
+
+ details = gtk_dialog_new_with_buttons (_("Details"),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(app_widget))),
+ GTK_DIALOG_MODAL,
+ _("_Done"), GTK_RESPONSE_CLOSE,
+ NULL);
+ gtk_container_set_border_width (GTK_CONTAINER (details), 20);
+
+ button = gtk_dialog_get_widget_for_response (GTK_DIALOG (details), GTK_RESPONSE_CLOSE);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), details);
+
+ grid = gtk_grid_new ();
+ gtk_widget_show (grid);
+ gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 20);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (details))), grid);
+
+ image = gtk_image_new ();
+ if (gs_app_get_pixbuf (app)) {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), gs_app_get_pixbuf (app));
gtk_widget_show (image);
+ }
+ gtk_grid_attach (GTK_GRID (grid), image, 0, 0, 1, 3);
+
+ label = gtk_label_new (gs_app_get_name (app));
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_widget_set_margin_bottom (label, 10);
+ attr_list = pango_attr_list_new ();
+ pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+ pango_attr_list_insert (attr_list, pango_attr_scale_new (1));
+ gtk_label_set_attributes (GTK_LABEL (label), attr_list);
+ pango_attr_list_unref (attr_list);
+ gtk_widget_show (label);
+ gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
+
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_widget_set_margin_bottom (label, 20);
+ if (gs_app_get_summary (app)) {
+ gtk_label_set_label (GTK_LABEL (label), gs_app_get_summary (app));
+ gtk_widget_show (label);
+ }
+ gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
+
+ tmp = gs_app_get_description (app);
+ if (!tmp) {
+ tmp = _("The author of this software has not included a long description.");
+ }
+ label = gtk_label_new (tmp);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_widget_show (label);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 2, 1);
+
+ if (gs_app_get_url (app)) {
+ button = gtk_link_button_new_with_label (gs_app_get_url (app), _("Visit website"));
+ gtk_widget_set_halign (button, GTK_ALIGN_START);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_show (button);
+ gtk_grid_attach (GTK_GRID (grid), button, 0, 4, 2, 1);
+ }
+
+ gtk_window_present (GTK_WINDOW (details));
+
+ return TRUE;
+}
+
/**
* gs_app_widget_init:
**/
@@ -442,6 +523,8 @@ gs_app_widget_init (GsAppWidget *app_widget)
gtk_widget_set_size_request (priv->widget_description3, 100, -1);
gtk_container_add (GTK_CONTAINER (box2), priv->widget_description3);
priv->widget_read_more = gtk_label_new (NULL);
+ g_signal_connect (priv->widget_read_more, "activate-link",
+ G_CALLBACK (read_more_cb), app_widget);
tmp = g_markup_printf_escaped ("<a href=''>%s</a>", _("Read More"));
gtk_label_set_markup (GTK_LABEL (priv->widget_read_more), tmp);
g_free (tmp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]