[gnome-software] Populate the application details from GsApp
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Populate the application details from GsApp
- Date: Thu, 15 Aug 2013 21:22:56 +0000 (UTC)
commit 88e75d5edf247f5c340a6a71596b54b8a3ed710d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 15 17:22:01 2013 -0400
Populate the application details from GsApp
I've accidentally duplicated this page, so merge the two, and
populate the new page from data in the GsApp.
src/gnome-software.ui | 185 +++----------------------------------------------
src/gs-main.c | 143 +++++++++++++-------------------------
2 files changed, 57 insertions(+), 271 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 6f96b78..71a940e 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.15.2 on Thu Aug 15 16:53:09 2013 -->
+<!-- Generated with glade 3.15.2 on Thu Aug 15 17:13:59 2013 -->
<interface>
<!-- interface-requires gtk+ 3.10 -->
<object class="GtkListStore" id="liststore_update">
@@ -129,7 +129,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="application_detail_header">
+ <object class="GtkLabel" id="application_details_header">
<property name="can_focus">False</property>
<property name="label">GNU Image Manipulation Program</property>
</object>
@@ -654,172 +654,6 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkViewport" id="viewport3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkGrid" id="grid1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_left">120</property>
- <property name="margin_right">120</property>
- <property name="border_width">15</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">18</property>
- <child>
- <object class="GtkImage" id="image_detail_icon">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="stock">gtk-justify-center</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage" id="image_detail_screenshot">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">30</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0.50999999046325684</property>
- <property name="stock">gtk-justify-center</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- <property name="width">3</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_detail_header">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Description</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- <property name="width">3</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_detail_description">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Shotwell is a digital photo organiser
that runs on Linux. It is the default photo manager in Ubuntu and Fedora.</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- <property name="width">3</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_detail_summary">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label">Open Source photo management for GNOME</property>
- <attributes>
- <attribute name="scale" value="1.2"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_detail_name">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label">Shotwell</property>
- <attributes>
- <attribute name="font-desc" value="<Enter Value> 10"/>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.3999999999999999"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage" id="image_detail_rating">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="yalign">0</property>
- <property name="stock">gtk-close</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">4</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">Detail Overview</property>
- </object>
- <packing>
- <property name="position">2</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -869,7 +703,7 @@
</packing>
</child>
<child>
- <object class="GtkLinkButton" id="application_details_link">
+ <object class="GtkLinkButton" id="application_details_url">
<property name="label" translatable="yes">Visit website</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -886,13 +720,14 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="application_details_subtitle">
+ <object class="GtkLabel" id="application_details_summary">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">The Gimp</property>
+ <property name="margin_bottom">20</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -902,7 +737,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label12">
+ <object class="GtkLabel" id="application_details_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -928,7 +763,7 @@ with multi-level undo.
</child>
</object>
<packing>
- <property name="position">5</property>
+ <property name="position">4</property>
</packing>
</child>
<child type="tab">
@@ -938,7 +773,7 @@ with multi-level undo.
<property name="label" translatable="yes">Application</property>
</object>
<packing>
- <property name="position">5</property>
+ <property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -980,7 +815,7 @@ with multi-level undo.
</child>
</object>
<packing>
- <property name="position">6</property>
+ <property name="position">5</property>
</packing>
</child>
<child type="tab">
@@ -990,7 +825,7 @@ with multi-level undo.
<property name="label" translatable="yes">Category</property>
</object>
<packing>
- <property name="position">6</property>
+ <property name="position">5</property>
<property name="tab_fill">False</property>
</packing>
</child>
diff --git a/src/gs-main.c b/src/gs-main.c
index 38bf8b8..ef965f4 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -38,7 +38,6 @@ typedef enum {
GS_MAIN_MODE_UPDATES,
GS_MAIN_MODE_WAITING,
GS_MAIN_MODE_DETAILS,
- GS_MAIN_MODE_APPLICATION,
GS_MAIN_MODE_CATEGORY
} GsMainMode;
@@ -750,7 +749,7 @@ app_tile_clicked (GtkButton *button, gpointer data)
GsApp *app;
app = g_object_get_data (button, "app");
- gs_main_set_overview_mode (priv, GS_MAIN_MODE_APPLICATION, app);
+ gs_main_set_overview_mode (priv, GS_MAIN_MODE_DETAILS, app);
}
static GtkWidget *
@@ -859,6 +858,16 @@ gs_main_get_popular (GsMainPrivate *priv)
priv);
}
+static void
+category_tile_clicked (GtkButton *button, gpointer data)
+{
+ GsMainPrivate *priv = data;
+ GsApp *app;
+
+ app = g_object_get_data (button, "category");
+ gs_main_set_overview_mode (priv, GS_MAIN_MODE_CATEGORY, app);
+}
+
static GtkWidget *
create_category_tile (const gchar *category)
{
@@ -920,20 +929,6 @@ gs_main_set_overview_mode_ui (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
priv->ignore_primary_buttons = TRUE;
switch (mode) {
- case GS_MAIN_MODE_DETAILS:
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
- gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
- gtk_widget_set_visible (widget, TRUE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_install"));
- gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_remove"));
- gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_update_all"));
- gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_detail_header"));
- gtk_widget_set_visible (widget, FALSE);
- break;
case GS_MAIN_MODE_NEW:
case GS_MAIN_MODE_INSTALLED:
case GS_MAIN_MODE_UPDATES:
@@ -946,13 +941,13 @@ gs_main_set_overview_mode_ui (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
gtk_widget_set_visible (widget, FALSE);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_remove"));
gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_detail_header"));
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
gtk_widget_set_visible (widget, FALSE);
break;
- case GS_MAIN_MODE_APPLICATION:
+ case GS_MAIN_MODE_DETAILS:
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_set_visible (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_detail_header"));
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
gtk_widget_set_visible (widget, TRUE);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
gtk_widget_set_visible (widget, TRUE);
@@ -1016,22 +1011,11 @@ gs_main_set_overview_mode_ui (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
gtk_spinner_start (GTK_SPINNER (widget));
break;
case GS_MAIN_MODE_DETAILS:
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_detail_name"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_detail_summary"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_detail_description"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image_detail_screenshot"));
- gtk_widget_hide (widget);
- break;
- case GS_MAIN_MODE_APPLICATION:
break;
default:
g_assert_not_reached ();
}
-
/* set panel */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "notebook_main"));
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), mode);
@@ -1044,6 +1028,7 @@ static void
gs_main_set_overview_mode (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
{
GtkWidget *widget;
+ GtkWidget *widget2;
const gchar *tmp;
GdkPixbuf *pixbuf;
gint rating;
@@ -1071,62 +1056,57 @@ gs_main_set_overview_mode (GsMainPrivate *priv, GsMainMode mode, GsApp *app)
gs_main_get_updates (priv);
break;
case GS_MAIN_MODE_DETAILS:
-
tmp = gs_app_get_name (app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_title"));
+ widget2 = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
if (tmp != NULL && tmp[0] != '\0') {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_detail_name"));
gtk_label_set_label (GTK_LABEL (widget), tmp);
+ gtk_label_set_label (GTK_LABEL (widget2), tmp);
gtk_widget_set_visible (widget, TRUE);
}
+ else {
+ gtk_widget_set_visible (widget, FALSE);
+ gtk_label_set_label (GTK_LABEL (widget2), "");
+ }
tmp = gs_app_get_summary (app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_summary"));
if (tmp != NULL && tmp[0] != '\0') {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_detail_summary"));
gtk_label_set_label (GTK_LABEL (widget), tmp);
gtk_widget_set_visible (widget, TRUE);
}
- tmp = NULL; // gs_app_get_description (app);
+ else {
+ gtk_widget_set_visible (widget, FALSE);
+ }
+ tmp = gs_app_get_description (app);
if (tmp == NULL)
tmp = _("The author of this software has not included a 'Description' in the desktop
file...");
- if (tmp != NULL && tmp[0] != '\0') {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"label_detail_description"));
- gtk_label_set_label (GTK_LABEL (widget), tmp);
- gtk_widget_set_visible (widget, TRUE);
- }
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"application_details_description"));
+ gtk_label_set_label (GTK_LABEL (widget), tmp);
+ gtk_widget_set_visible (widget, TRUE);
+
pixbuf = gs_app_get_pixbuf (app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_icon"));
if (pixbuf != NULL) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image_detail_icon"));
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), pixbuf);
gtk_widget_set_visible (widget, TRUE);
}
- tmp = gs_app_get_screenshot (app);
- if (tmp != NULL && tmp[0] != '\0') {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"image_detail_screenshot"));
- pixbuf = gdk_pixbuf_new_from_file_at_size (tmp, 1000, 500, NULL);
- gtk_image_set_from_pixbuf (GTK_IMAGE (widget), pixbuf);
- g_object_unref (pixbuf);
- gtk_widget_set_visible (widget, TRUE);
- }
-
- /* show rating */
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image_detail_rating"));
- rating = gs_app_get_rating (app);
- if (rating < 20) {
- gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars0.png");
- } else if (rating < 40) {
- gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars1.png");
- } else if (rating < 60) {
- gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars2.png");
- } else if (rating < 80) {
- gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars3.png");
- } else {
- gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/gnome-software/stars4.png");
- }
+ else {
+ gtk_widget_set_visible (widget, FALSE);
+ }
+
+ tmp = gs_app_get_url (app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_url"));
+ if (tmp != NULL && tmp[0] != '\0') {
+ gtk_link_button_set_uri (GTK_LINK_BUTTON (widget), tmp);
+ gtk_widget_set_visible (widget, TRUE);
+ }
+ else {
+ gtk_widget_set_visible (widget, FALSE);
+ }
- /* add install button if available */
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_install"));
- gtk_widget_set_visible (widget, gs_app_get_state (app) == GS_APP_STATE_AVAILABLE);
break;
- case GS_MAIN_MODE_APPLICATION:
+ case GS_MAIN_MODE_CATEGORY:
break;
default:
g_assert_not_reached ();
@@ -1307,35 +1287,6 @@ gs_main_installed_sort_func (GtkListBoxRow *a,
}
/**
- * gs_main_popular_activated_cb:
- **/
-static void
-gs_main_popular_activated_cb (GtkIconView *iconview, GtkTreePath *path, GsMainPrivate *priv)
-{
- gboolean ret;
- GsApp *app;
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- model = gtk_icon_view_get_model (iconview);
- ret = gtk_tree_model_get_iter_from_string (model, &iter, gtk_tree_path_to_string (path));
- if (!ret)
- return;
-
- gtk_tree_model_get (model, &iter,
- COLUMN_POPULAR_APP, &app,
- -1);
- g_debug ("show details with %s", gs_app_get_id (app));
-
- /* save current mode */
- priv->tab_back_id = priv->mode;
-
- /* switch to overview mode */
- gs_main_set_overview_mode (priv, GS_MAIN_MODE_DETAILS, app);
- g_object_unref (app);
-}
-
-/**
* gs_main_startup_cb:
**/
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]