[gnome-packagekit] Add #ifdef's for the new API in PackageKit git master



commit f6e68d8d8b4d536df06bf10cfcef12db0becb13b
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 12 18:43:13 2012 +0100

    Add #ifdef's for the new API in PackageKit git master

 src/gpk-update-viewer.c |   89 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 79 insertions(+), 10 deletions(-)
---
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index df3720f..2b1d5aa 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -1783,11 +1783,43 @@ gpk_update_viewer_treeview_add_columns_update (GtkTreeView *treeview)
 	g_object_set_data (G_OBJECT (column), "tooltip-id", GINT_TO_POINTER (GPK_UPDATES_COLUMN_SIZE_DISPLAY));
 }
 
+#if PK_CHECK_VERSION(0,8,1)
 /**
  * gpk_update_viewer_add_description_link_item:
  **/
 static void
-gpk_update_viewer_add_description_link_item (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *title, const GPtrArray *array)
+gpk_update_viewer_add_description_link_item (GtkTextBuffer *buffer,
+					     GtkTextIter *iter,
+					     const gchar *title,
+					     gchar **urls)
+{
+	GtkTextTag *tag;
+	gint i;
+
+	/* insert at end */
+	gtk_text_buffer_insert_with_tags_by_name (buffer, iter, title, -1, "para", NULL);
+	for (i = 0; urls[i] != NULL; i++) {
+		gtk_text_buffer_insert (buffer, iter, "\n", -1);
+		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 (G_OBJECT (tag), "href", g_strdup (urls[i]));
+		gtk_text_buffer_insert_with_tags (buffer, iter, urls[i], -1, tag, NULL);
+		gtk_text_buffer_insert (buffer, iter, ".", -1);
+	}
+	gtk_text_buffer_insert (buffer, iter, "\n", -1);
+}
+#else
+/**
+ * gpk_update_viewer_add_description_link_item:
+ **/
+static void
+gpk_update_viewer_add_description_link_item (GtkTextBuffer *buffer,
+					     GtkTextIter *iter,
+					     const gchar *title,
+					     const GPtrArray *array)
 {
 	GtkTextTag *tag;
 	const gchar *uri;
@@ -1812,7 +1844,7 @@ gpk_update_viewer_add_description_link_item (GtkTextBuffer *buffer, GtkTextIter
 }
 
 /**
- * gpk_update_viewer_add_description_link_item:
+ * gpk_update_viewer_get_uris:
  **/
 static GPtrArray *
 gpk_update_viewer_get_uris (const gchar *url_string)
@@ -1839,6 +1871,7 @@ gpk_update_viewer_get_uris (const gchar *url_string)
 
 	return array;
 }
+#endif
 
 /**
  * gpk_update_viewer_iso8601_format_locale_date:
@@ -1886,7 +1919,6 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 	GtkTreeSelection *selection;
 	GtkTreeModel *model;
 	GtkTreeIter treeiter;
-	GPtrArray *array;
 	PkInfoEnum info;
 	gchar *line;
 	gchar *line2;
@@ -1894,11 +1926,16 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 	GtkTextIter iter;
 	gboolean has_update_text = FALSE;
 	gchar *package_id;
-	gchar *updates;
-	gchar *obsoletes;
+#if PK_CHECK_VERSION(0,8,1)
+	gchar **vendor_urls;
+	gchar **bugzilla_urls;
+	gchar **cve_urls;
+#else
+	GPtrArray *array;
 	gchar *vendor_url;
 	gchar *bugzilla_url;
 	gchar *cve_url;
+#endif
 	PkRestartEnum restart;
 	gchar *update_text;
 	gchar *changelog;
@@ -1911,11 +1948,15 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 	/* get data */
 	g_object_get (item,
 		      "package-id", &package_id,
-		      "updates", &updates,
-		      "obsoletes", &obsoletes,
+#if PK_CHECK_VERSION(0,8,1)
+		      "vendor-urls", &vendor_urls,
+		      "bugzilla-urls", &bugzilla_urls,
+		      "cve-urls", &cve_urls,
+#else
 		      "vendor-url", &vendor_url,
 		      "bugzilla-url", &bugzilla_url,
 		      "cve-url", &cve_url,
+#endif
 		      "restart", &restart,
 		      "update-text", &update_text,
 		      "changelog", &changelog,
@@ -1992,6 +2033,30 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 		g_free (line);
 	}
 
+#if PK_CHECK_VERSION(0,8,1)
+	/* add all the links */
+	if (vendor_urls != NULL) {
+		/* TRANSLATORS: this is a array of vendor URLs */
+		title = ngettext ("For more information about this update please visit this website:",
+				  "For more information about this update please visit these websites:",
+				  g_strv_length (vendor_urls));
+		gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, vendor_urls);
+	}
+	if (bugzilla_urls != NULL) {
+		/* TRANSLATORS: this is a array of bugzilla URLs */
+		title = ngettext ("For more information about bugs fixed by this update please visit this website:",
+				  "For more information about bugs fixed by this update please visit these websites:",
+				  g_strv_length (bugzilla_urls));
+		gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, bugzilla_urls);
+	}
+	if (cve_urls != NULL) {
+		/* TRANSLATORS: this is a array of CVE (security) URLs */
+		title = ngettext ("For more information about this security update please visit this website:",
+				  "For more information about this security update please visit these websites:",
+				  g_strv_length (cve_urls));
+		gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, cve_urls);
+	}
+#else
 	/* add all the links */
 	if (!egg_strzero (vendor_url)) {
 		array = gpk_update_viewer_get_uris (vendor_url);
@@ -2017,7 +2082,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 		gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, array);
 		g_ptr_array_unref (array);
 	}
-
+#endif
 	/* reboot */
 	if (restart == PK_RESTART_ENUM_SYSTEM) {
 		/* TRANSLATORS: reboot required */
@@ -2053,11 +2118,15 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
 	}
 
 	g_free (package_id);
-	g_free (updates);
-	g_free (obsoletes);
+#if PK_CHECK_VERSION(0,8,1)
+	g_strfreev (vendor_urls);
+	g_strfreev (bugzilla_urls);
+	g_strfreev (cve_urls);
+#else
 	g_free (vendor_url);
 	g_free (bugzilla_url);
 	g_free (cve_url);
+#endif
 	g_free (update_text);
 	g_free (changelog);
 	g_free (issued);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]