[gnome-software] Break out the history dialog as a separate object
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Break out the history dialog as a separate object
- Date: Thu, 6 Mar 2014 22:36:36 +0000 (UTC)
commit 403cb9b78545cec50dcb292f3c262003799a807b
Author: Kalev Lember <kalevlember gmail com>
Date: Sat Mar 1 11:28:02 2014 +0100
Break out the history dialog as a separate object
At the same time, move to a separate GtkBuilder template.
https://bugzilla.gnome.org/show_bug.cgi?id=725579
po/POTFILES.in | 2 +
src/Makefile.am | 3 +
src/gnome-software.gresource.xml | 1 +
src/gnome-software.ui | 56 ---------
src/gs-history-dialog.c | 249 ++++++++++++++++++++++++++++++++++++++
src/gs-history-dialog.h | 59 +++++++++
src/gs-history-dialog.ui | 58 +++++++++
src/gs-shell-details.c | 184 ++--------------------------
8 files changed, 381 insertions(+), 231 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bcbb55d..3b67194 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,8 @@ src/gs-app-tile.c
src/gs-app-widget.c
src/gs-category.c
src/gs-feature-tile.c
+src/gs-history-dialog.c
+[type: gettext/glade]src/gs-history-dialog.ui
src/gs-main.c
src/gs-offline-updates.c
src/gs-plugin-loader.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 81f9d36..4dda90c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,6 +32,7 @@ UI_FILES = \
category-tile.ui \
feature-tile.ui \
gnome-software.ui \
+ gs-history-dialog.ui \
gs-star-widget.ui \
screenshot-image.ui \
popular-tile.ui
@@ -101,6 +102,8 @@ gnome_software_SOURCES = \
gs-app-tile.h \
gs-app-folder-dialog.c \
gs-app-folder-dialog.h \
+ gs-history-dialog.c \
+ gs-history-dialog.h \
gs-box.h \
gs-box.c \
gs-plugin.c \
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index 15dfc50..23dd7a2 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -10,6 +10,7 @@
<file preprocess="xml-stripblanks">app-widget.ui</file>
<file preprocess="xml-stripblanks">app-folder-dialog.ui</file>
<file preprocess="xml-stripblanks">screenshot-image.ui</file>
+ <file preprocess="xml-stripblanks">gs-history-dialog.ui</file>
<file preprocess="xml-stripblanks">gs-star-widget.ui</file>
<file preprocess="xml-stripblanks">org.freedesktop.PackageKit.xml</file>
<file>gtk-style.css</file>
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 7163193..419bb01 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -2037,62 +2037,6 @@
</object>
</child>
</object>
- <object class="GtkDialog" id="dialog_history">
- <property name="can_focus">False</property>
- <property name="modal">True</property>
- <property name="use-header-bar">1</property>
- <property name="default_width">600</property>
- <property name="default_height">300</property>
- <property name="destroy_with_parent">True</property>
- <property name="title" translatable="yes">History</property>
- <property name="type_hint">dialog</property>
- <property name="transient_for">window_software</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox2">
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="margin_start">6</property>
- <property name="margin_end">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="orientation">vertical</property>
- <property name="spacing">9</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow_history">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">none</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="margin">6</property>
- <child>
- <object class="GtkFrame" id="frame_history">
- <property name="visible">True</property>
- <property name="shadow_type">in</property>
- <property name="halign">fill</property>
- <property name="valign">start</property>
- <style>
- <class name="view"/>
- </style>
- <child>
- <object class="GtkListBox" id="list_box_history">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">none</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
<object class="GtkDialog" id="dialog_update">
<property name="can_focus">False</property>
<property name="modal">True</property>
diff --git a/src/gs-history-dialog.c b/src/gs-history-dialog.c
new file mode 100644
index 0000000..f1e5ab2
--- /dev/null
+++ b/src/gs-history-dialog.c
@@ -0,0 +1,249 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gs-history-dialog.h"
+#include "gs-utils.h"
+
+struct _GsHistoryDialogPrivate
+{
+ GsApp *app;
+ GtkSizeGroup *sizegroup_state;
+ GtkSizeGroup *sizegroup_timestamp;
+ GtkSizeGroup *sizegroup_version;
+ GtkWidget *list_box;
+ GtkWidget *scrolledwindow;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsHistoryDialog, gs_history_dialog, GTK_TYPE_DIALOG)
+
+static gint
+history_sort_cb (gconstpointer a, gconstpointer b)
+{
+ gint64 timestamp_a = gs_app_get_install_date (*(GsApp **) a);
+ gint64 timestamp_b = gs_app_get_install_date (*(GsApp **) b);
+ if (timestamp_a < timestamp_b)
+ return 1;
+ if (timestamp_a > timestamp_b)
+ return -1;
+ return 0;
+}
+
+void
+gs_history_dialog_set_app (GsHistoryDialog *dialog, GsApp *app)
+{
+ GsHistoryDialogPrivate *priv = gs_history_dialog_get_instance_private (dialog);
+ const gchar *tmp;
+ gchar *date_str;
+ GDateTime *datetime;
+ GPtrArray *history;
+ GtkBox *box;
+ GtkWidget *widget;
+ guint64 timestamp;
+ guint i;
+
+ /* add each history package to the dialog */
+ gs_container_remove_all (GTK_CONTAINER (priv->list_box));
+ history = gs_app_get_history (app);
+ g_ptr_array_sort (history, history_sort_cb);
+ for (i = 0; i < history->len; i++) {
+ app = g_ptr_array_index (history, i);
+ box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+
+ /* add the action */
+ switch (gs_app_get_state (app)) {
+ case GS_APP_STATE_AVAILABLE:
+ case GS_APP_STATE_REMOVING:
+ /* TRANSLATORS: this is the status in the history UI,
+ * where we are showing the application was removed */
+ tmp = _("Removed");
+ break;
+ case GS_APP_STATE_INSTALLED:
+ case GS_APP_STATE_INSTALLING:
+ /* TRANSLATORS: this is the status in the history UI,
+ * where we are showing the application was installed */
+ tmp = _("Installed");
+ break;
+ case GS_APP_STATE_UPDATABLE:
+ /* TRANSLATORS: this is the status in the history UI,
+ * where we are showing the application was updated */
+ tmp = _("Updated");
+ break;
+ default:
+ /* TRANSLATORS: this is the status in the history UI,
+ * where we are showing that something happened to the
+ * application but we don't know what */
+ tmp = _("Unknown");
+ break;
+ }
+ widget = gtk_label_new (tmp);
+ g_object_set (widget,
+ "margin-left", 20,
+ "margin-right", 20,
+ "margin-top", 6,
+ "margin-bottom", 6,
+ "xalign", 0.0,
+ NULL);
+ gtk_size_group_add_widget (priv->sizegroup_state, widget);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+
+ /* add the timestamp */
+ timestamp = gs_app_get_install_date (app);
+ datetime = g_date_time_new_from_unix_utc (timestamp);
+ if (timestamp == GS_APP_INSTALL_DATE_UNKNOWN) {
+ date_str = g_strdup ("");
+ } else {
+ date_str = g_date_time_format (datetime, "%e %B %Y");
+ }
+ widget = gtk_label_new (date_str);
+ g_object_set (widget,
+ "margin-left", 20,
+ "margin-right", 20,
+ "margin-top", 6,
+ "margin-bottom", 6,
+ "xalign", 0.0,
+ NULL);
+ gtk_size_group_add_widget (priv->sizegroup_timestamp, widget);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+ g_free (date_str);
+ g_date_time_unref (datetime);
+
+ /* add the version */
+ widget = gtk_label_new (gs_app_get_version (app));
+ g_object_set (widget,
+ "margin-left", 20,
+ "margin-right", 20,
+ "margin-top", 6,
+ "margin-bottom", 6,
+ "xalign", 1.0,
+ NULL);
+ gtk_size_group_add_widget (priv->sizegroup_version, widget);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (GTK_WIDGET (box));
+ gtk_list_box_insert (GTK_LIST_BOX (priv->list_box), GTK_WIDGET (box), -1);
+ }
+}
+
+static void
+update_header_func (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
+{
+ GtkWidget *header;
+
+ /* first entry */
+ header = gtk_list_box_row_get_header (row);
+ if (before == NULL) {
+ gtk_list_box_row_set_header (row, NULL);
+ return;
+ }
+
+ /* already set */
+ if (header != NULL)
+ return;
+
+ /* set new */
+ header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_list_box_row_set_header (row, header);
+}
+
+static void
+scrollbar_mapped_cb (GtkWidget *sb, GtkScrolledWindow *swin)
+{
+ GtkWidget *frame;
+
+ frame = gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (swin))));
+ if (gtk_widget_get_mapped (GTK_WIDGET (sb))) {
+ gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_IN);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ } else {
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_NONE);
+ }
+}
+
+static void
+gs_history_dialog_finalize (GObject *object)
+{
+ GsHistoryDialog *dialog = GS_HISTORY_DIALOG (object);
+ GsHistoryDialogPrivate *priv = gs_history_dialog_get_instance_private (dialog);
+
+ g_object_unref (priv->sizegroup_state);
+ g_object_unref (priv->sizegroup_timestamp);
+ g_object_unref (priv->sizegroup_version);
+
+ if (priv->app != NULL)
+ g_object_unref (priv->app);
+
+ G_OBJECT_CLASS (gs_history_dialog_parent_class)->finalize (object);
+}
+
+static void
+gs_history_dialog_init (GsHistoryDialog *dialog)
+{
+ GsHistoryDialogPrivate *priv = gs_history_dialog_get_instance_private (dialog);
+ GtkWidget *scrollbar;
+
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+
+ priv->sizegroup_state = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ priv->sizegroup_timestamp = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ priv->sizegroup_version = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ gtk_list_box_set_header_func (GTK_LIST_BOX (priv->list_box),
+ update_header_func,
+ dialog,
+ NULL);
+
+ scrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->scrolledwindow));
+ g_signal_connect (scrollbar, "map", G_CALLBACK (scrollbar_mapped_cb), priv->scrolledwindow);
+ g_signal_connect (scrollbar, "unmap", G_CALLBACK (scrollbar_mapped_cb), priv->scrolledwindow);
+}
+
+static void
+gs_history_dialog_class_init (GsHistoryDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gs_history_dialog_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/software/gs-history-dialog.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GsHistoryDialog, list_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GsHistoryDialog, scrolledwindow);
+}
+
+GtkWidget *
+gs_history_dialog_new (void)
+{
+ return GTK_WIDGET (g_object_new (GS_TYPE_HISTORY_DIALOG,
+ "use-header-bar", TRUE,
+ NULL));
+}
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-history-dialog.h b/src/gs-history-dialog.h
new file mode 100644
index 0000000..6cf1829
--- /dev/null
+++ b/src/gs-history-dialog.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef GS_HISTORY_DIALOG_H
+#define GS_HISTORY_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#include "gs-app.h"
+
+#define GS_TYPE_HISTORY_DIALOG (gs_history_dialog_get_type())
+#define GS_HISTORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GS_TYPE_HISTORY_DIALOG,
GsHistoryDialog))
+#define GS_HISTORY_DIALOG_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), GS_TYPE_HISTORY_DIALOG,
GsHistoryDialogClass))
+#define GS_IS_HISTORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GS_TYPE_HISTORY_DIALOG))
+#define GS_IS_HISTORY_DIALOG_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls),
GS_TYPE_HISTORY_DIALOG))
+#define GS_HISTORY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GS_TYPE_HISTORY_DIALOG,
GsHistoryDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _GsHistoryDialog GsHistoryDialog;
+typedef struct _GsHistoryDialogClass GsHistoryDialogClass;
+typedef struct _GsHistoryDialogPrivate GsHistoryDialogPrivate;
+
+struct _GsHistoryDialog
+{
+ GtkDialog parent;
+};
+
+struct _GsHistoryDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+GType gs_history_dialog_get_type (void);
+GtkWidget *gs_history_dialog_new (void);
+void gs_history_dialog_set_app (GsHistoryDialog *dialog,
+ GsApp *app);
+
+#endif /* GS_HISTORY_DIALOG_H */
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-history-dialog.ui b/src/gs-history-dialog.ui
new file mode 100644
index 0000000..d897982
--- /dev/null
+++ b/src/gs-history-dialog.ui
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="GsHistoryDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">History</property>
+ <property name="modal">True</property>
+ <property name="default_width">600</property>
+ <property name="default_height">300</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="use_header_bar">1</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">9</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">none</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="margin">6</property>
+ <child>
+ <object class="GtkFrame" id="frame">
+ <property name="visible">True</property>
+ <property name="shadow_type">in</property>
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="view"/>
+ </style>
+ <child>
+ <object class="GtkListBox" id="list_box">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 7cb0ece..2639f39 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -29,6 +29,7 @@
#include "gs-utils.h"
#include "gs-shell-details.h"
+#include "gs-history-dialog.h"
#include "gs-screenshot-image.h"
#include "gs-star-widget.h"
@@ -49,9 +50,7 @@ struct GsShellDetailsPrivate
gboolean cache_valid;
GsApp *app;
GsShell *shell;
- GtkSizeGroup *history_sizegroup_state;
- GtkSizeGroup *history_sizegroup_timestamp;
- GtkSizeGroup *history_sizegroup_version;
+ GtkWidget *history_dialog;
GtkWidget *star;
SoupSession *session;
};
@@ -1096,21 +1095,6 @@ gs_shell_details_app_install_button_cb (GtkWidget *widget, GsShellDetails *shell
}
/**
- * gs_shell_details_history_sort_cb:
- **/
-static gint
-gs_shell_details_history_sort_cb (gconstpointer a, gconstpointer b)
-{
- gint64 timestamp_a = gs_app_get_install_date (*(GsApp **) a);
- gint64 timestamp_b = gs_app_get_install_date (*(GsApp **) b);
- if (timestamp_a < timestamp_b)
- return 1;
- if (timestamp_a > timestamp_b)
- return -1;
- return 0;
-}
-
-/**
* gs_shell_details_app_launch_button_cb:
**/
static void
@@ -1146,143 +1130,14 @@ static void
gs_shell_details_app_history_button_cb (GtkWidget *widget, GsShellDetails *shell_details)
{
GsShellDetailsPrivate *priv = shell_details->priv;
- const gchar *tmp;
- gchar *date_str;
- GDateTime *datetime;
- GPtrArray *history;
- GsApp *app;
- GtkBox *box;
- GtkListBox *list_box;
- guint64 timestamp;
- guint i;
+ GtkWidget *toplevel;
- /* add each history package to the dialog */
- list_box = GTK_LIST_BOX (gtk_builder_get_object (priv->builder, "list_box_history"));
- gs_container_remove_all (GTK_CONTAINER (list_box));
- history = gs_app_get_history (priv->app);
- g_ptr_array_sort (history, gs_shell_details_history_sort_cb);
- for (i = 0; i < history->len; i++) {
- app = g_ptr_array_index (history, i);
- box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+ gs_history_dialog_set_app (GS_HISTORY_DIALOG (priv->history_dialog), priv->app);
- /* add the action */
- switch (gs_app_get_state (app)) {
- case GS_APP_STATE_AVAILABLE:
- case GS_APP_STATE_REMOVING:
- /* TRANSLATORS: this is the status in the history UI,
- * where we are showing the application was removed */
- tmp = _("Removed");
- break;
- case GS_APP_STATE_INSTALLED:
- case GS_APP_STATE_INSTALLING:
- /* TRANSLATORS: this is the status in the history UI,
- * where we are showing the application was installed */
- tmp = _("Installed");
- break;
- case GS_APP_STATE_UPDATABLE:
- /* TRANSLATORS: this is the status in the history UI,
- * where we are showing the application was updated */
- tmp = _("Updated");
- break;
- default:
- /* TRANSLATORS: this is the status in the history UI,
- * where we are showing that something happened to the
- * application but we don't know what */
- tmp = _("Unknown");
- break;
- }
- widget = gtk_label_new (tmp);
- g_object_set (widget,
- "margin-left", 20,
- "margin-right", 20,
- "margin-top", 6,
- "margin-bottom", 6,
- "xalign", 0.0,
- NULL);
- gtk_size_group_add_widget (priv->history_sizegroup_state, widget);
- gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
-
- /* add the timestamp */
- timestamp = gs_app_get_install_date (app);
- datetime = g_date_time_new_from_unix_utc (timestamp);
- if (timestamp == GS_APP_INSTALL_DATE_UNKNOWN) {
- date_str = g_strdup ("");
- } else {
- date_str = g_date_time_format (datetime, "%e %B %Y");
- }
- widget = gtk_label_new (date_str);
- g_object_set (widget,
- "margin-left", 20,
- "margin-right", 20,
- "margin-top", 6,
- "margin-bottom", 6,
- "xalign", 0.0,
- NULL);
- gtk_size_group_add_widget (priv->history_sizegroup_timestamp, widget);
- gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
- g_free (date_str);
- g_date_time_unref (datetime);
-
- /* add the version */
- widget = gtk_label_new (gs_app_get_version (app));
- g_object_set (widget,
- "margin-left", 20,
- "margin-right", 20,
- "margin-top", 6,
- "margin-bottom", 6,
- "xalign", 1.0,
- NULL);
- gtk_size_group_add_widget (priv->history_sizegroup_version, widget);
- gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
-
- gtk_widget_show_all (GTK_WIDGET (box));
- gtk_list_box_insert (list_box, GTK_WIDGET (box), -1);
- }
+ toplevel = GTK_WIDGET (gtk_builder_get_object (priv->builder, "window_software"));
+ gtk_window_set_transient_for (GTK_WINDOW (priv->history_dialog), GTK_WINDOW (toplevel));
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_history"));
- gtk_window_present (GTK_WINDOW (widget));
-}
-
-/**
- * gs_shell_details_list_header_func
- **/
-static void
-gs_shell_details_list_header_func (GtkListBoxRow *row,
- GtkListBoxRow *before,
- gpointer user_data)
-{
- GtkWidget *header;
-
- /* first entry */
- header = gtk_list_box_row_get_header (row);
- if (before == NULL) {
- gtk_list_box_row_set_header (row, NULL);
- return;
- }
-
- /* already set */
- if (header != NULL)
- return;
-
- /* set new */
- header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_list_box_row_set_header (row, header);
-}
-
-static void
-scrollbar_mapped_cb (GtkWidget *sb, GtkScrolledWindow *swin)
-{
- GtkWidget *frame;
-
- frame = gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (swin))));
- if (gtk_widget_get_mapped (GTK_WIDGET (sb))) {
- gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_IN);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- }
- else {
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
- gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_NONE);
- }
+ gtk_window_present (GTK_WINDOW (priv->history_dialog));
}
/**
@@ -1347,7 +1202,6 @@ gs_shell_details_setup (GsShellDetails *shell_details,
{
GsShellDetailsPrivate *priv = shell_details->priv;
GtkWidget *widget;
- GtkListBox *list_box;
GtkWidget *sw;
GtkAdjustment *adj;
@@ -1370,13 +1224,6 @@ gs_shell_details_setup (GsShellDetails *shell_details,
gtk_widget_set_valign (priv->star, GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (sw), priv->star, FALSE, FALSE, 0);
- /* setup history */
- list_box = GTK_LIST_BOX (gtk_builder_get_object (priv->builder, "list_box_history"));
- gtk_list_box_set_header_func (list_box,
- gs_shell_details_list_header_func,
- shell_details,
- NULL);
-
/* setup details */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_install"));
g_signal_connect (widget, "clicked",
@@ -1400,15 +1247,10 @@ gs_shell_details_setup (GsShellDetails *shell_details,
shell_details);
/* setup history window */
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_history"));
- g_signal_connect (widget, "delete-event",
+ priv->history_dialog = gs_history_dialog_new ();
+ g_signal_connect (priv->history_dialog, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), shell_details);
- sw = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_history"));
- widget = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (sw));
- g_signal_connect (widget, "map", G_CALLBACK (scrollbar_mapped_cb), sw);
- g_signal_connect (widget, "unmap", G_CALLBACK (scrollbar_mapped_cb), sw);
-
sw = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_details"));
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
widget = GTK_WIDGET (gtk_builder_get_object (builder, "box_details"));
@@ -1439,10 +1281,6 @@ gs_shell_details_init (GsShellDetails *shell_details)
shell_details->priv = GS_SHELL_DETAILS_GET_PRIVATE (shell_details);
priv = shell_details->priv;
- priv->history_sizegroup_state = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- priv->history_sizegroup_timestamp = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- priv->history_sizegroup_version = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
/* setup networking */
priv->session = soup_session_sync_new_with_options (SOUP_SESSION_USER_AGENT,
"gnome-software",
@@ -1463,10 +1301,6 @@ gs_shell_details_finalize (GObject *object)
GsShellDetails *shell_details = GS_SHELL_DETAILS (object);
GsShellDetailsPrivate *priv = shell_details->priv;
- g_object_unref (priv->history_sizegroup_state);
- g_object_unref (priv->history_sizegroup_timestamp);
- g_object_unref (priv->history_sizegroup_version);
-
g_object_unref (priv->builder);
g_object_unref (priv->plugin_loader);
g_object_unref (priv->cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]