gnome-packagekit r105 - in trunk: data src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r105 - in trunk: data src
- Date: Sat, 1 Mar 2008 16:41:28 +0000 (GMT)
Author: rhughes
Date: Sat Mar 1 16:41:27 2008
New Revision: 105
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=105&view=rev
Log:
from git
Modified:
trunk/data/pk-update-viewer.glade
trunk/src/Makefile.am
trunk/src/pk-common-gui.c
trunk/src/pk-update-viewer.c
Modified: trunk/data/pk-update-viewer.glade
==============================================================================
--- trunk/data/pk-update-viewer.glade (original)
+++ trunk/data/pk-update-viewer.glade Sat Mar 1 16:41:27 2008
@@ -20,8 +20,8 @@
<child>
<widget class="GtkVBox" id="vbox_preview">
<property name="visible">True</property>
- <property name="border_width">10</property>
- <property name="spacing">5</property>
+ <property name="border_width">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkHBox" id="hbox4">
<property name="visible">True</property>
@@ -65,7 +65,7 @@
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
- <property name="spacing">5</property>
+ <property name="spacing">6</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_help">
@@ -252,50 +252,59 @@
<child>
<widget class="GtkVBox" id="vbox_details">
<property name="visible">True</property>
- <property name="border_width">10</property>
+ <property name="border_width">12</property>
+ <property name="spacing">12</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow_packages">
+ <widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <widget class="GtkTreeView" id="treeview_updates">
+ <widget class="GtkScrolledWindow" id="scrolledwindow_packages">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview_updates">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ </widget>
+ </child>
</widget>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">True</property>
+ </packing>
</child>
- </widget>
- </child>
- <child>
- <widget class="GtkScrolledWindow" id="details_scrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTextView" id="details_textview">
+ <widget class="GtkScrolledWindow" id="scrolledwindow_description">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="wrap_mode">GTK_WRAP_WORD</property>
- <property name="cursor_visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview_description">
+ <property name="visible">True</property>
+ <property name="headers_visible">False</property>
+ <property name="enable_search">False</property>
+ </widget>
+ </child>
</widget>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
</child>
</widget>
- <packing>
- <property name="expand">False</property>
- <property name="padding">12</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<widget class="GtkHBox" id="hbox_reboot">
<property name="visible">True</property>
- <property name="spacing">5</property>
+ <property name="spacing">12</property>
<child>
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
@@ -323,13 +332,13 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
- <property name="spacing">5</property>
+ <property name="spacing">6</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_help2">
@@ -498,7 +507,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
@@ -520,8 +529,8 @@
<child>
<widget class="GtkVBox" id="vbox_progress">
<property name="visible">True</property>
- <property name="border_width">10</property>
- <property name="spacing">5</property>
+ <property name="border_width">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow_history">
<property name="visible">True</property>
@@ -552,7 +561,7 @@
<child>
<widget class="GtkHButtonBox" id="hbuttonbox4">
<property name="visible">True</property>
- <property name="spacing">5</property>
+ <property name="spacing">6</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_help3">
@@ -653,111 +662,89 @@
<widget class="GtkVBox" id="vbox_confirm">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">10</property>
+ <property name="border_width">12</property>
<property name="spacing">5</property>
<child>
- <widget class="GtkHBox" id="hbox14">
+ <widget class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">18</property>
<child>
- <widget class="GtkImage" id="image13">
+ <widget class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="icon_size">6</property>
- <property name="icon_name">computer</property>
+ <child>
+ <widget class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"><b>System Update Completed!</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
- <property name="padding">20</property>
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox6">
+ <widget class="GtkHBox" id="hbox18">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">20</property>
<child>
- <widget class="GtkHBox" id="hbox17">
+ <widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <widget class="GtkLabel" id="label16">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes"><b>System Update Completed!</b></property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">All selected updates have been successfully installed</property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_restart">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">12</property>
<child>
- <widget class="GtkHBox" id="hbox18">
+ <widget class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <widget class="GtkLabel" id="label20">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">All selected updates have been successfully installed</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="stock">gtk-dialog-info</property>
+ <property name="icon_size">6</property>
</widget>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox_restart">
+ <widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">5</property>
- <child>
- <widget class="GtkImage" id="image15">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="stock">gtk-dialog-info</property>
- <property name="icon_size">6</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label15">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">A system restart is recommended</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="label" translatable="yes"><b>A system restart is recommended</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
@@ -765,7 +752,7 @@
<child>
<widget class="GtkHButtonBox" id="hbuttonbox5">
<property name="visible">True</property>
- <property name="spacing">5</property>
+ <property name="spacing">6</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_help4">
@@ -866,7 +853,7 @@
<widget class="GtkVBox" id="vbox_confirm2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">10</property>
+ <property name="border_width">12</property>
<property name="spacing">5</property>
<child>
<widget class="GtkHBox" id="hbox20">
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sat Mar 1 16:41:27 2008
@@ -148,6 +148,8 @@
pk-statusbar.h \
pk-common-gui.c \
pk-common-gui.h \
+ pk-cell-renderer-uri.c \
+ pk-cell-renderer-uri.h \
$(NULL)
pk_update_viewer_LDADD = \
Modified: trunk/src/pk-common-gui.c
==============================================================================
--- trunk/src/pk-common-gui.c (original)
+++ trunk/src/pk-common-gui.c Sat Mar 1 16:41:27 2008
@@ -462,6 +462,9 @@
case PK_ERROR_ENUM_FAILED_CONFIG_PARSING:
text = _("Reading the config file failed");
break;
+ case PK_ERROR_ENUM_CANNOT_CANCEL:
+ text = _("The transaction cannot be cancelled");
+ break;
default:
text = _("Unknown error");
}
@@ -557,6 +560,9 @@
text = _("The native package configuration file could not be opened.\n"
"Please make sure configuration is valid.");
break;
+ case PK_ERROR_ENUM_CANNOT_CANCEL:
+ text = _("The transaction is not safe to be cancelled at this time.");
+ break;
default:
text = _("Unknown error, please report a bug.\n"
"More information is available in the detailed report.");
Modified: trunk/src/pk-update-viewer.c
==============================================================================
--- trunk/src/pk-update-viewer.c (original)
+++ trunk/src/pk-update-viewer.c Sat Mar 1 16:41:27 2008
@@ -41,11 +41,13 @@
#include <pk-enum-list.h>
#include "pk-common-gui.h"
#include "pk-statusbar.h"
+#include "pk-cell-renderer-uri.h"
static GladeXML *glade_xml = NULL;
static GtkListStore *list_store_preview = NULL;
static GtkListStore *list_store_history = NULL;
static GtkListStore *list_store_details = NULL;
+static GtkListStore *list_store_description = NULL;
static PkClient *client = NULL;
static PkTaskList *tlist = NULL;
static gchar *package = NULL;
@@ -58,6 +60,13 @@
};
enum {
+ DESC_COLUMN_TITLE,
+ DESC_COLUMN_TEXT,
+ DESC_COLUMN_URI,
+ DESC_COLUMN_LAST
+};
+
+enum {
HISTORY_COLUMN_ICON,
HISTORY_COLUMN_TEXT,
HISTORY_COLUMN_LAST
@@ -68,9 +77,19 @@
PACKAGES_COLUMN_TEXT,
PACKAGES_COLUMN_ID,
PACKAGES_COLUMN_INFO,
+ PACKAGES_COLUMN_SELECT,
PACKAGES_COLUMN_LAST
};
+typedef enum {
+ PAGE_PREVIEW,
+ PAGE_DETAILS,
+ PAGE_PROGRESS,
+ PAGE_CONFIRM,
+ PAGE_ERROR,
+ PAGE_LAST
+} PkPageEnum;
+
/**
* pk_button_help_cb:
**/
@@ -100,15 +119,6 @@
}
}
-typedef enum {
- PAGE_PREVIEW,
- PAGE_DETAILS,
- PAGE_PROGRESS,
- PAGE_CONFIRM,
- PAGE_ERROR,
- PAGE_LAST
-} PkPageEnum;
-
/**
* pk_updates_set_page:
**/
@@ -229,6 +239,8 @@
gchar *text;
PkRoleEnum role;
const gchar *icon_name;
+ GtkWidget *widget;
+ GtkTreePath *path;
pk_client_get_role (client, &role, NULL, NULL);
pk_debug ("package = %s:%s:%s", pk_info_enum_to_text (info), package_id, summary);
@@ -242,6 +254,7 @@
PACKAGES_COLUMN_ID, package_id,
PACKAGES_COLUMN_ICON, icon_name,
PACKAGES_COLUMN_INFO, info,
+ PACKAGES_COLUMN_SELECT, TRUE,
-1);
g_free (text);
return;
@@ -250,18 +263,85 @@
if (role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
text = pk_package_id_pretty (package_id, summary);
icon_name = pk_info_enum_to_icon_name (info);
- gtk_list_store_clear (list_store_history);
- gtk_list_store_append (list_store_history, &iter);
+ gtk_list_store_prepend (list_store_history, &iter);
gtk_list_store_set (list_store_history, &iter,
HISTORY_COLUMN_TEXT, text,
HISTORY_COLUMN_ICON, icon_name,
-1);
+
+ /* move focus to top entry */
+ widget = glade_xml_get_widget (glade_xml, "treeview_history");
+ path = gtk_tree_path_new_from_indices (0, -1);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (widget), path, NULL, FALSE, 0.0, 0.0);
+
g_free (text);
return;
}
}
/**
+ * pk_updates_add_description_item:
+ **/
+static void
+pk_updates_add_description_item (const gchar *title, const gchar *text, const gchar *uri)
+{
+ gchar *markup;
+ GtkTreeIter iter;
+
+ /* format */
+ markup = g_strdup_printf ("<b>%s:</b>", title);
+
+ pk_debug ("%s %s %s", markup, text, uri);
+ gtk_list_store_append (list_store_description, &iter);
+ gtk_list_store_set (list_store_description, &iter,
+ DESC_COLUMN_TITLE, markup,
+ DESC_COLUMN_TEXT, text,
+ DESC_COLUMN_URI, uri,
+ -1);
+
+ g_free (markup);
+
+ GtkWidget *tree_view;
+ GtkTreeSelection *selection;
+ tree_view = glade_xml_get_widget (glade_xml, "treeview_description");
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
+}
+
+/**
+ * pk_updates_add_description_link_item:
+ **/
+static void
+pk_updates_add_description_link_item (const gchar *title, const gchar *url_string)
+{
+ const gchar *text;
+ const gchar *uri;
+ gchar *title_num;
+ gchar **urls;
+ guint length;
+ gint i;
+
+ urls = g_strsplit (url_string, ";", 0);
+ length = g_strv_length (urls);
+ for (i = 0; urls[i]; i += 2) {
+ uri = urls[i];
+ text = urls[i+1];
+ if (pk_strzero (text)) {
+ text = uri;
+ }
+ /* no suffix needed */
+ if (length == 2) {
+ pk_updates_add_description_item (title, text, uri);
+ } else {
+ title_num = g_strdup_printf ("%s (%i)", title, (i/2) + 1);
+ pk_updates_add_description_item (title_num, text, uri);
+ g_free (title_num);
+ }
+ }
+ g_strfreev (urls);
+}
+
+/**
* pk_updates_update_detail_cb:
**/
static void
@@ -273,31 +353,30 @@
{
GtkWidget *widget;
PkPackageId *ident;
- gchar *text, *href;
- gchar *package_pretty = NULL;
- gchar *updates_pretty = NULL;
- gchar *obsoletes_pretty = NULL;
- const gchar *info_text = NULL;
- GtkTextView *tv;
- GtkTextBuffer *buffer;
- GtkTextTag *bold_tag, *title_tag, *space_tag, *tag;
- GtkTextIter iter;
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter treeiter;
- gint info, i, j;
- const gchar *urls;
- gchar **u;
- gboolean has_title;
+ gchar *package_pretty;
+ gchar *updates_pretty;
+ gchar *obsoletes_pretty;
+ const gchar *info_text;
+ PkInfoEnum info;
+
+ /* clear existing list */
+ gtk_list_store_clear (list_store_description);
/* initially we are hidden */
- widget = glade_xml_get_widget (glade_xml, "details_scrolledwindow");
+ widget = glade_xml_get_widget (glade_xml, "scrolledwindow_description");
gtk_widget_show (widget);
- /* Grr, need to look up the info from the packages list */
widget = glade_xml_get_widget (glade_xml, "treeview_updates");
gtk_widget_set_size_request (GTK_WIDGET (widget), 500, 200);
+ widget = glade_xml_get_widget (glade_xml, "treeview_description");
+ gtk_widget_set_size_request (GTK_WIDGET (widget), 500, 200);
+
+ /* get info */
+ widget = glade_xml_get_widget (glade_xml, "treeview_updates");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
if (gtk_tree_selection_get_selected (selection, &model, &treeiter)) {
gtk_tree_model_get (model, &treeiter,
@@ -306,102 +385,44 @@
info = PK_INFO_ENUM_NORMAL;
}
- /* set restart */
- widget = glade_xml_get_widget (glade_xml, "details_textview");
- tv = GTK_TEXT_VIEW (widget);
- buffer = gtk_text_buffer_new (NULL);
- bold_tag = gtk_text_buffer_create_tag (buffer, "bold",
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
- title_tag = gtk_text_buffer_create_tag (buffer, "title",
- "font", "DejaVu LGC Sans Mono Bold",
- "foreground-gdk", &widget->style->base[GTK_STATE_NORMAL],
- "background-gdk", &widget->style->text_aa[GTK_STATE_NORMAL],
- NULL);
- space_tag = gtk_text_buffer_create_tag (buffer, "space",
- "font", "DejaVu LGC Sans Mono Bold",
- NULL);
-
- gtk_text_buffer_get_start_iter (buffer, &iter);
-
-#define ADD_LINE(title,line) \
- text = g_strdup_printf ("%12s ", title); \
- gtk_text_buffer_insert_with_tags (buffer, &iter, text, -1, \
- title_tag, NULL); \
- g_free (text); \
- text = g_strdup_printf (" %s\n", line); \
- gtk_text_buffer_insert (buffer, &iter, text, -1); \
- g_free (text);
+ info_text = pk_info_enum_to_localised_text (info);
+ pk_updates_add_description_item (_("Type"), info_text, NULL);
package_pretty = pk_package_id_name_version (package_id);
- ADD_LINE(_("Version"), package_pretty);
+ pk_updates_add_description_item (_("Version"), package_pretty, NULL);
g_free (package_pretty);
- info_text = pk_info_enum_to_localised_text (info);
- ADD_LINE(_("Type"), info_text);
-
- if (pk_strzero (updates) == FALSE) {
+ if (!pk_strzero (updates)) {
updates_pretty = pk_package_id_name_version (updates);
- ADD_LINE(_("Updates"), updates_pretty);
+ pk_updates_add_description_item (_("Updates"), updates_pretty, NULL);
g_free (updates_pretty);
}
- if (pk_strzero (obsoletes) == FALSE) {
+ if (!pk_strzero (obsoletes)) {
obsoletes_pretty = pk_package_id_name_version (obsoletes);
- ADD_LINE(_("Obsoletes"), obsoletes_pretty);
+ pk_updates_add_description_item (_("Obsoletes"), obsoletes_pretty, NULL);
g_free (obsoletes_pretty);
}
ident = pk_package_id_new_from_string (package_id);
- ADD_LINE(_("Repository"), ident->data);
+ pk_updates_add_description_item (_("Repository"), ident->data, NULL);
if (!pk_strzero (update_text)) {
- ADD_LINE(_("Description"), update_text);
+ pk_updates_add_description_item (_("Description"), update_text, NULL);
}
- has_title = FALSE;
- for (i = 0; i < 3; i++) {
- switch (i) {
- case 0:
- urls = vendor_url;
- break;
- case 1:
- urls = bugzilla_url;
- break;
- case 2:
- urls = cve_url;
- break;
- default:
- urls = NULL;
- g_assert_not_reached ();
- }
- if (pk_strzero (urls) == FALSE && has_title == FALSE) {
- has_title = TRUE;
- text = g_strdup_printf ("%12s ", _("References"));
- gtk_text_buffer_insert_with_tags (buffer, &iter, text, -1,
- title_tag, NULL);
- g_free (text);
- }
-
- u = g_strsplit (urls, ";", 0);
- for (j = 0; u[j]; j += 2) {
- href = u[j];
- text = u[j+1];
- if (pk_strzero (text)) {
- text = href;
- }
- gtk_text_buffer_insert (buffer, &iter, " ", -1);
- tag = gtk_text_buffer_create_tag (buffer, NULL,
- "foreground", "blue",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
- g_object_set_data_full (G_OBJECT (tag), "url", g_strdup (href), g_free);
- gtk_text_buffer_insert_with_tags (buffer, &iter, text, -1,
- tag, NULL);
- }
- g_strfreev (u);
+ /* add all the links */
+ if (!pk_strzero (vendor_url)) {
+ pk_updates_add_description_link_item (_("Vendor"), vendor_url);
+ }
+ if (!pk_strzero (bugzilla_url)) {
+ pk_updates_add_description_link_item (_("Bugzilla"), bugzilla_url);
+ }
+ if (!pk_strzero (cve_url)) {
+ pk_updates_add_description_link_item (_("CVE"), cve_url);
}
+ /* reboot */
if (restart == PK_RESTART_ENUM_SESSION ||
restart == PK_RESTART_ENUM_SYSTEM) {
widget = glade_xml_get_widget (glade_xml, "hbox_reboot");
@@ -410,202 +431,6 @@
widget = glade_xml_get_widget (glade_xml, "hbox_reboot");
gtk_widget_hide (widget);
}
-
- gtk_text_view_set_buffer (tv, buffer);
-}
-
-static void
-follow_if_link (GtkWidget *widget, GtkTextIter *iter)
-{
- GSList *tags = NULL, *t = NULL;
-
- tags = gtk_text_iter_get_tags (iter);
- for (t = tags; t != NULL; t = t->next) {
- GtkTextTag *tag = t->data;
- gchar *url = (gchar*) g_object_get_data (G_OBJECT (tag), "url");
- if (url) {
- pk_execute_url (url);
- break;
- }
- }
- g_slist_free (tags);
-}
-
-/* Links can be activated by pressing Enter.
- */
-static gboolean
-key_press_event (GtkWidget *widget, GdkEventKey *event)
-{
- GtkTextView *tv = GTK_TEXT_VIEW (widget);
- GtkTextIter iter;
- GtkTextBuffer *buffer;
-
- switch (event->keyval) {
- case GDK_Return:
- case GDK_KP_Enter:
- buffer = gtk_text_view_get_buffer (tv);
- gtk_text_buffer_get_iter_at_mark (buffer, &iter,
- gtk_text_buffer_get_insert (buffer));
- follow_if_link (widget, &iter);
- break;
- default:
- break;
- }
-
- return FALSE;
-}
-
-static gboolean
-event_after (GtkWidget *widget, GdkEvent *ev)
-{
- GtkTextView *tv = GTK_TEXT_VIEW (widget);
- GtkTextIter start, end, iter;
- GtkTextBuffer *buffer;
- GdkEventButton *event;
- gint x, y;
-
- if (ev->type != GDK_BUTTON_RELEASE)
- return FALSE;
-
- event = (GdkEventButton *)ev;
-
- if (event->button != 1)
- return FALSE;
-
- buffer = gtk_text_view_get_buffer (tv);
-
- /* we shouldn't follow a link if the user has selected something */
- gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
- if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
- return FALSE;
-
- gtk_text_view_window_to_buffer_coords (tv, GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
- gtk_text_view_get_iter_at_location (tv, &iter, x, y);
-
- follow_if_link (widget, &iter);
-
- return FALSE;
-}
-
-static gboolean hovering_over_link = FALSE;
-static GdkCursor *hand_cursor = NULL;
-static GdkCursor *regular_cursor = NULL;
-
-/* Looks at all tags covering the position (x, y) in the text view,
- * and if one of them is a link, change the cursor to the "hands" cursor
- * typically used by web browsers.
- */
-static void
-set_cursor_if_appropriate (GtkTextView *tv, gint x, gint y)
-{
- GSList *tags = NULL, *t = NULL;
- GtkTextIter iter;
- GdkWindow *window;
- gboolean hovering = FALSE;
-
- gtk_text_view_get_iter_at_location (tv, &iter, x, y);
-
- tags = gtk_text_iter_get_tags (&iter);
- for (t = tags; t != NULL; t = t->next) {
- GtkTextTag *tag = t->data;
- gchar *url = (gchar*) g_object_get_data (G_OBJECT (tag), "url");
- if (url) {
- hovering = TRUE;
- break;
- }
- }
-
- if (hovering != hovering_over_link) {
- hovering_over_link = hovering;
- window = gtk_text_view_get_window (tv, GTK_TEXT_WINDOW_TEXT);
- if (hovering_over_link)
- gdk_window_set_cursor (window, hand_cursor);
- else
- gdk_window_set_cursor (window, regular_cursor);
- }
-
- g_slist_free (tags);
-}
-
-/* Update the cursor image if the pointer moved.
- */
-static gboolean
-motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
-{
- GtkTextView *tv = GTK_TEXT_VIEW (widget);
- gint x, y;
-
- gtk_text_view_window_to_buffer_coords (tv, GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
- set_cursor_if_appropriate (tv, x, y);
-
- gdk_window_get_pointer (widget->window, NULL, NULL, NULL);
-
- return FALSE;
-}
-
-/* Also update the cursor image if the window becomes visible
- * * (e.g. when a window covering it got iconified).
- * */
-static gboolean
-visibility_notify_event (GtkWidget *widget, GdkEventVisibility *event)
-{
- GtkTextView *tv = GTK_TEXT_VIEW (widget);
- gint wx, wy, bx, by;
-
- gdk_window_get_pointer (widget->window, &wx, &wy, NULL);
-
- gtk_text_view_window_to_buffer_coords (tv, GTK_TEXT_WINDOW_WIDGET,
- wx, wy, &bx, &by);
- set_cursor_if_appropriate (tv, bx, by);
-
- return FALSE;
-}
-
-static void
-setup_link_support (GtkWidget *widget)
-{
- hand_cursor = gdk_cursor_new (GDK_HAND2);
- regular_cursor = gdk_cursor_new (GDK_XTERM);
-
- g_signal_connect (widget, "key-press-event",
- G_CALLBACK (key_press_event), NULL);
- g_signal_connect (widget, "event-after",
- G_CALLBACK (event_after), NULL);
- g_signal_connect (widget, "motion-notify-event",
- G_CALLBACK (motion_notify_event), NULL);
- g_signal_connect (widget, "visibility-notify-event",
- G_CALLBACK (visibility_notify_event), NULL);
-}
-
-static void
-update_tag (GtkTextTag *tag, gpointer data)
-{
- GtkWidget *widget = data;
- gchar *name;
-
- g_object_get (tag, "name", &name, NULL);
-
- if (strcmp (name, "title") == 0) {
- g_object_set (tag,
- "foreground-gdk", &widget->style->base[GTK_STATE_NORMAL],
- "background-gdk", &widget->style->text_aa[GTK_STATE_NORMAL],
- NULL);
- }
-}
-
-static void
-update_tags (GtkWidget *widget,
- GtkStyle *previous_style,
- gpointer user_data)
-{
- GtkTextBuffer *buffer;
- GtkTextTagTable *tags;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
- tags = gtk_text_buffer_get_tag_table (buffer);
- gtk_text_tag_table_foreach (tags, update_tag, widget);
}
/**
@@ -636,6 +461,36 @@
}
/**
+ * pk_treeview_update_toggled:
+ **/
+static void
+pk_treeview_update_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+ GtkTreeModel *model = (GtkTreeModel *) data;
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gboolean update;
+ gchar *package_id;
+
+ /* get toggled iter */
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, PACKAGES_COLUMN_SELECT, &update,
+ PACKAGES_COLUMN_ID, &package_id, -1);
+
+ /* unstage */
+// update ^= 1;
+
+ pk_debug ("update %s[%i]", package_id, update);
+ g_free (package_id);
+
+ /* set new value */
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, PACKAGES_COLUMN_SELECT, update, -1);
+
+ /* clean up */
+ gtk_tree_path_free (path);
+}
+
+/**
* pk_treeview_add_columns:
**/
static void
@@ -661,6 +516,65 @@
}
/**
+ * pk_treeview_renderer_clicked:
+ **/
+static void
+pk_treeview_renderer_clicked (GtkCellRendererToggle *cell, gchar *uri, gpointer data)
+{
+ pk_debug ("clicked %s", uri);
+ pk_execute_url (uri);
+}
+
+/**
+ * pk_treeview_add_columns_description:
+ **/
+static void
+pk_treeview_add_columns_description (GtkTreeView *treeview)
+{
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ /* image */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Title"), renderer,
+ "markup", DESC_COLUMN_TITLE, NULL);
+ gtk_tree_view_append_column (treeview, column);
+
+ /* column for uris */
+ renderer = pk_cell_renderer_uri_new ();
+ g_signal_connect (renderer, "clicked", G_CALLBACK (pk_treeview_renderer_clicked), NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Text"), renderer,
+ "text", DESC_COLUMN_TEXT,
+ "uri", DESC_COLUMN_URI, NULL);
+ gtk_tree_view_append_column (treeview, column);
+}
+
+/**
+ * pk_treeview_add_columns_update:
+ **/
+static void
+pk_treeview_add_columns_update (GtkTreeView *treeview)
+{
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeModel *model;
+
+ /* column for select toggle */
+ renderer = gtk_cell_renderer_toggle_new ();
+ model = gtk_tree_view_get_model (treeview);
+ g_signal_connect (renderer, "toggled", G_CALLBACK (pk_treeview_update_toggled), model);
+ column = gtk_tree_view_column_new_with_attributes ("Update", renderer, "active", PACKAGES_COLUMN_SELECT, NULL);
+
+ /* set this column to a fixed sizing (of 50 pixels) */
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 20);
+ gtk_tree_view_append_column (treeview, column);
+
+ /* usual suspects */
+ pk_treeview_add_columns (treeview);
+}
+
+/**
* pk_packages_treeview_clicked_cb:
**/
static void
@@ -672,7 +586,7 @@
GtkWidget *widget;
/* hide the widgets until we have data */
- widget = glade_xml_get_widget (glade_xml, "details_scrolledwindow");
+ widget = glade_xml_get_widget (glade_xml, "scrolledwindow_description");
gtk_widget_hide (widget);
widget = glade_xml_get_widget (glade_xml, "hbox_reboot");
gtk_widget_hide (widget);
@@ -713,13 +627,18 @@
* pk_updates_add_preview_item:
**/
static void
-pk_updates_add_preview_item (PkClient *client, const gchar *icon, const gchar *message)
+pk_updates_add_preview_item (PkClient *client, const gchar *icon, const gchar *message, gboolean clear)
{
GtkWidget *tree_view;
GtkTreeSelection *selection;
GtkTreeIter iter;
gchar *markup;
+ /* clear existing list */
+ if (clear == TRUE) {
+ gtk_list_store_clear (list_store_preview);
+ }
+
markup = g_strdup_printf ("<b>%s</b>", message);
gtk_list_store_append (list_store_preview, &iter);
gtk_list_store_set (list_store_preview, &iter,
@@ -812,11 +731,8 @@
length = pk_client_package_buffer_get_size (client);
if (length == 0) {
- /* clear existing list */
- gtk_list_store_clear (list_store_preview);
-
/* put a message in the listbox */
- pk_updates_add_preview_item (client, "dialog-information", _("There are no updates available!"));
+ pk_updates_add_preview_item (client, "dialog-information", _("There are no updates available!"), TRUE);
/* if no updates then hide apply */
widget = glade_xml_get_widget (glade_xml, "button_review");
@@ -860,37 +776,37 @@
if (num_security > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_SECURITY);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_SECURITY, num_security);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
if (num_important > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_IMPORTANT);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_IMPORTANT, num_important);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
if (num_bugfix > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_BUGFIX);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_BUGFIX, num_bugfix);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
if (num_enhancement > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_ENHANCEMENT);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_ENHANCEMENT, num_enhancement);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
if (num_low > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_LOW);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_LOW, num_low);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
if (num_normal > 0) {
icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_NORMAL);
text = pk_update_enum_to_localised_text (PK_INFO_ENUM_NORMAL, num_normal);
- pk_updates_add_preview_item (client, icon, text);
+ pk_updates_add_preview_item (client, icon, text, FALSE);
g_free (text);
}
@@ -945,10 +861,10 @@
/* hide buttons if we are updating */
if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) == TRUE) {
/* clear existing list */
- gtk_list_store_clear (list_store_details);
+ gtk_list_store_clear (list_store_preview);
/* put a message in the listbox */
- pk_updates_add_preview_item (client, "dialog-information", _("There is an update already in progress!"));
+ pk_updates_add_preview_item (client, "dialog-information", _("There is an update already in progress!"), TRUE);
/* if doing it then hide apply and refresh */
widget = glade_xml_get_widget (glade_xml, "button_apply");
@@ -1161,11 +1077,6 @@
/* we have no yelp file yet */
gtk_widget_hide (widget);
- widget = glade_xml_get_widget (glade_xml, "details_textview");
- g_signal_connect (widget, "style-set",
- G_CALLBACK (update_tags), NULL);
- setup_link_support (widget);
-
widget = glade_xml_get_widget (glade_xml, "button_update");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_button_update_cb), NULL);
@@ -1173,9 +1084,10 @@
/* create list stores */
list_store_details = gtk_list_store_new (PACKAGES_COLUMN_LAST, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
list_store_preview = gtk_list_store_new (PREVIEW_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING);
list_store_history = gtk_list_store_new (PREVIEW_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING);
+ list_store_description = gtk_list_store_new (DESC_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
/* create preview tree view */
widget = glade_xml_get_widget (glade_xml, "treeview_preview");
@@ -1191,8 +1103,13 @@
gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
GTK_TREE_MODEL (list_store_history));
+ /* create history tree view */
+ widget = glade_xml_get_widget (glade_xml, "treeview_description");
+ gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
+ GTK_TREE_MODEL (list_store_description));
+
/* add columns to the tree view */
- pk_treeview_add_columns (GTK_TREE_VIEW (widget));
+ pk_treeview_add_columns_description (GTK_TREE_VIEW (widget));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
/* create package tree view */
@@ -1205,7 +1122,7 @@
G_CALLBACK (pk_packages_treeview_clicked_cb), NULL);
/* add columns to the tree view */
- pk_treeview_add_columns (GTK_TREE_VIEW (widget));
+ pk_treeview_add_columns_update (GTK_TREE_VIEW (widget));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
/* use the in-statusbar for progress */
@@ -1241,6 +1158,7 @@
g_object_unref (glade_xml);
g_object_unref (list_store_preview);
g_object_unref (list_store_history);
+ g_object_unref (list_store_description);
g_object_unref (list_store_details);
g_object_unref (client);
g_object_unref (pconnection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]