[gnome-packagekit] Do not use PkDesktop
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Do not use PkDesktop
- Date: Thu, 4 Sep 2014 15:08:44 +0000 (UTC)
commit 4532131bbea17ae9f6206bde1fa4b016a93340a4
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 4 16:04:06 2014 +0100
Do not use PkDesktop
The service is no longer provided by PackageKit git master.
src/Makefile.am | 4 -
src/gpk-common.c | 117 +----------------------
src/gpk-dbus-task.c | 23 +----
src/gpk-desktop.c | 237 ----------------------------------------------
src/gpk-desktop.h | 41 --------
src/gpk-dialog.c | 8 +--
src/gpk-helper-chooser.c | 16 +---
src/gpk-helper-run.c | 141 +---------------------------
src/gpk-modal-dialog.c | 14 +---
9 files changed, 8 insertions(+), 593 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 629089d..b9a6364 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,8 +53,6 @@ libgpkshared_a_SOURCES = \
gpk-marshal.h \
gpk-session.c \
gpk-session.h \
- gpk-desktop.c \
- gpk-desktop.h \
gpk-animated-icon.c \
gpk-animated-icon.h \
gpk-dialog.c \
@@ -231,8 +229,6 @@ gpk_self_test_SOURCES = \
gpk-x11.h \
gpk-vendor.c \
gpk-vendor.h \
- gpk-desktop.c \
- gpk-desktop.h \
gpk-task.c \
gpk-task.h \
gpk-helper-run.c \
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 205202f..2783c61 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -655,104 +655,6 @@ gpk_strv_join_locale (gchar **array)
}
/**
- * gpk_package_entry_completion_get_names_from_file:
- *
- * Creates a tree model containing completions from the system package list
- **/
-static GPtrArray *
-gpk_package_entry_completion_get_names_from_file (const gchar *filename)
-{
- GPtrArray *array = NULL;
- gboolean ret;
- GError *error = NULL;
- gchar *data = NULL;
- gchar **lines = NULL;
- guint i;
- gchar **split;
- PkPackage *item;
-
- /* get data */
- ret = g_file_get_contents (filename, &data, NULL, &error);
- if (!ret) {
- g_warning ("failed to open package list: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* create array of PkPackage's */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* split */
- lines = g_strsplit (data, "\n", -1);
- for (i=0; lines[i] != NULL; i++) {
- split = g_strsplit (lines[i], "\t", 3);
- if (g_strv_length (split) != 3)
- continue;
- item = pk_package_new ();
- pk_package_set_id (item, split[1], NULL);
- g_object_set (item,
- "info", pk_info_enum_from_string (split[0]),
- "summary", split[2],
- NULL);
- g_ptr_array_add (array, item);
- g_strfreev (split);
- }
-out:
- g_free (data);
- g_strfreev (lines);
- return array;
-}
-
-/**
- * gpk_package_entry_completion_model_new:
- *
- * Creates a tree model containing completions from the system package list
- **/
-static GtkTreeModel *
-gpk_package_entry_completion_model_new (void)
-{
- GPtrArray *list;
- guint i;
- PkPackage *item;
- GHashTable *hash;
- gpointer data;
- GtkListStore *store;
- GtkTreeIter iter;
- gchar **split;
-
- store = gtk_list_store_new (1, G_TYPE_STRING);
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- list = gpk_package_entry_completion_get_names_from_file (PK_SYSTEM_PACKAGE_LIST_FILENAME);
- if (list == NULL) {
- g_warning ("no package list, try refreshing");
- return NULL;
- }
-
- g_debug ("loading %i autocomplete items", list->len);
- for (i=0; i<list->len; i++) {
- item = g_ptr_array_index (list, i);
- if (item == NULL || pk_package_get_id (item) == NULL) {
- g_warning ("item invalid!");
- break;
- }
-
- split = pk_package_id_split (pk_package_get_id (item));
- data = g_hash_table_lookup (hash, (gpointer) split[PK_PACKAGE_ID_NAME]);
- if (data == NULL) {
- /* append just the name */
- g_hash_table_insert (hash, g_strdup (split[PK_PACKAGE_ID_NAME]), GINT_TO_POINTER (1));
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, split[PK_PACKAGE_ID_NAME], -1);
- }
- g_strfreev (split);
- }
- g_hash_table_unref (hash);
- g_ptr_array_unref (list);
-
- return GTK_TREE_MODEL (store);
-}
-
-/**
* gpk_package_entry_completion_new:
*
* Creates a %GtkEntryCompletion containing completions from the system package list
@@ -760,22 +662,5 @@ gpk_package_entry_completion_model_new (void)
GtkEntryCompletion *
gpk_package_entry_completion_new (void)
{
- GtkEntryCompletion *completion;
- GtkTreeModel *model;
-
- /* create a tree model and use it as the completion model */
- completion = gtk_entry_completion_new ();
- model = gpk_package_entry_completion_model_new ();
- if (model == NULL)
- return completion;
-
- /* set the model for our completion model */
- gtk_entry_completion_set_model (completion, model);
- g_object_unref (model);
-
- /* use model column 0 as the text column */
- gtk_entry_completion_set_text_column (completion, 0);
- gtk_entry_completion_set_inline_completion (completion, TRUE);
-
- return completion;
+ return NULL;
}
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 577149d..b381957 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -39,7 +39,6 @@
#include "gpk-common.h"
#include "gpk-dbus.h"
#include "gpk-dbus-task.h"
-#include "gpk-desktop.h"
#include "gpk-dialog.h"
#include "gpk-enum.h"
#include "gpk-error.h"
@@ -68,7 +67,6 @@ struct _GpkDbusTaskPrivate
GdkWindow *parent_window;
GSettings *settings;
PkTask *task;
- PkDesktop *desktop;
PkControl *control;
PkExitEnum exit;
PkBitfield roles;
@@ -3124,17 +3122,8 @@ gpk_dbus_task_set_exec (GpkDbusTask *dtask, const gchar *exec)
/* get from installed database */
package = gpk_dbus_task_get_package_for_exec (dtask, exec);
g_debug ("got package %s", package);
-
- /* try to get from PkDesktop */
- if (package != NULL) {
- dtask->priv->parent_title = gpk_desktop_guess_localised_name (dtask->priv->desktop, package);
- dtask->priv->parent_icon_name = gpk_desktop_guess_icon_name (dtask->priv->desktop, package);
- /* fallback to package name */
- if (dtask->priv->parent_title == NULL) {
- g_debug ("did not get localized description for %s", package);
- dtask->priv->parent_title = g_strdup (package);
- }
- }
+ if (package != NULL)
+ dtask->priv->parent_title = g_strdup (package);
/* fallback to exec - eugh... */
if (dtask->priv->parent_title == NULL) {
@@ -3166,7 +3155,6 @@ gpk_dbus_task_class_init (GpkDbusTaskClass *klass)
static void
gpk_dbus_task_init (GpkDbusTask *dtask)
{
- gboolean ret;
GtkWindow *main_window;
dtask->priv = GPK_DBUS_TASK_GET_PRIVATE (dtask);
@@ -3225,12 +3213,6 @@ gpk_dbus_task_init (GpkDbusTask *dtask)
dtask->priv->control = pk_control_new ();
dtask->priv->task = PK_TASK(gpk_task_new ());
dtask->priv->roles = pk_control_get_properties (dtask->priv->control, NULL, NULL);
-
- /* used for icons and translations */
- dtask->priv->desktop = pk_desktop_new ();
- ret = pk_desktop_open_database (dtask->priv->desktop, NULL);
- if (!ret)
- g_warning ("failed to open desktop database");
}
/**
@@ -3264,7 +3246,6 @@ gpk_dbus_task_finalize (GObject *object)
g_strfreev (dtask->priv->package_ids);
g_object_unref (PK_CLIENT(dtask->priv->task));
g_object_unref (dtask->priv->control);
- g_object_unref (dtask->priv->desktop);
g_object_unref (dtask->priv->settings);
g_object_unref (dtask->priv->dialog);
g_object_unref (dtask->priv->vendor);
diff --git a/src/gpk-dialog.c b/src/gpk-dialog.c
index 6e5c103..516c315 100644
--- a/src/gpk-dialog.c
+++ b/src/gpk-dialog.c
@@ -31,7 +31,6 @@
#include "gpk-common.h"
#include "gpk-dialog.h"
#include "gpk-enum.h"
-#include "gpk-desktop.h"
enum {
GPK_DIALOG_STORE_IMAGE,
@@ -84,7 +83,6 @@ gpk_dialog_package_array_to_list_store (GPtrArray *array)
GtkListStore *store;
GtkTreeIter iter;
PkPackage *item;
- PkDesktop *desktop;
const gchar *icon;
gchar *text;
guint i;
@@ -93,7 +91,6 @@ gpk_dialog_package_array_to_list_store (GPtrArray *array)
gchar *package_id = NULL;
gchar *summary = NULL;
- desktop = pk_desktop_new ();
store = gtk_list_store_new (GPK_DIALOG_STORE_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
/* add each well */
@@ -108,9 +105,7 @@ gpk_dialog_package_array_to_list_store (GPtrArray *array)
/* get the icon */
split = pk_package_id_split (package_id);
- icon = gpk_desktop_guess_icon_name (desktop, split[0]);
- if (icon == NULL)
- icon = gpk_info_enum_to_icon_name (info);
+ icon = gpk_info_enum_to_icon_name (info);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
@@ -124,7 +119,6 @@ gpk_dialog_package_array_to_list_store (GPtrArray *array)
g_free (text);
}
- g_object_unref (desktop);
return store;
}
diff --git a/src/gpk-helper-chooser.c b/src/gpk-helper-chooser.c
index 0f80038..d211af6 100644
--- a/src/gpk-helper-chooser.c
+++ b/src/gpk-helper-chooser.c
@@ -30,7 +30,6 @@
#include "gpk-gnome.h"
#include "gpk-common.h"
#include "gpk-enum.h"
-#include "gpk-desktop.h"
static void gpk_helper_chooser_finalize (GObject *object);
@@ -39,7 +38,6 @@ static void gpk_helper_chooser_finalize (GObject *object);
struct GpkHelperChooserPrivate
{
GtkBuilder *builder;
- PkDesktop *desktop;
gchar *package_id;
GtkListStore *list_store;
};
@@ -155,7 +153,6 @@ gpk_helper_chooser_show (GpkHelperChooser *helper, GPtrArray *list)
guint i;
PkPackage *item;
GtkTreeIter iter;
- gchar **split;
PkInfoEnum info;
gchar *package_id = NULL;
gchar *summary = NULL;
@@ -179,14 +176,7 @@ gpk_helper_chooser_show (GpkHelperChooser *helper, GPtrArray *list)
text = gpk_package_id_format_twoline (gtk_widget_get_style_context (widget),
package_id,
summary);
-
- /* get the icon */
- split = pk_package_id_split (package_id);
- icon_name = gpk_desktop_guess_icon_name (helper->priv->desktop, split[PK_PACKAGE_ID_NAME]);
- g_strfreev (split);
- if (icon_name == NULL)
- icon_name = gpk_info_enum_to_icon_name (info);
-
+ icon_name = gpk_info_enum_to_icon_name (info);
gtk_list_store_set (helper->priv->list_store, &iter,
GPK_CHOOSER_COLUMN_TEXT, text,
GPK_CHOOSER_COLUMN_ID, package_id, -1);
@@ -320,9 +310,6 @@ gpk_helper_chooser_init (GpkHelperChooser *helper)
pk_treeview_add_general_columns (GTK_TREE_VIEW (widget));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
-
- /* use PkDesktop to get better icon */
- helper->priv->desktop = pk_desktop_new ();
}
/**
@@ -344,7 +331,6 @@ gpk_helper_chooser_finalize (GObject *object)
gtk_widget_hide (widget);
g_free (helper->priv->package_id);
g_object_unref (helper->priv->builder);
- g_object_unref (helper->priv->desktop);
G_OBJECT_CLASS (gpk_helper_chooser_parent_class)->finalize (object);
}
diff --git a/src/gpk-helper-run.c b/src/gpk-helper-run.c
index 3d998b7..ac20577 100644
--- a/src/gpk-helper-run.c
+++ b/src/gpk-helper-run.c
@@ -30,7 +30,6 @@
#include "gpk-marshal.h"
#include "gpk-gnome.h"
#include "gpk-common.h"
-#include "gpk-desktop.h"
#include "gpk-enum.h"
static void gpk_helper_run_finalize (GObject *object);
@@ -205,150 +204,12 @@ pk_treeview_add_general_columns (GtkTreeView *treeview)
}
/**
- * gpk_helper_run_add_desktop_file:
- **/
-static gboolean
-gpk_helper_run_add_desktop_file (GpkHelperRun *helper, const gchar *package_id, const gchar *filename)
-{
- gboolean ret = FALSE;
- gchar *icon = NULL;
- gchar *text = NULL;
- gchar *fulltext = NULL;
- gchar *name = NULL;
- gchar *exec = NULL;
- gchar *summary = NULL;
- gchar *joint = NULL;
- GtkTreeIter iter;
- GKeyFile *file = NULL;
- gint weight;
- gboolean hidden;
-
- /* get weight */
- weight = gpk_desktop_get_file_weight (filename);
- if (weight < 0) {
- g_debug ("ignoring %s", filename);
- goto out;
- }
-
- /* get some data from the desktop file */
- file = g_key_file_new ();
- ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, NULL);
- if (!ret) {
- g_debug ("failed to load %s", filename);
- goto out;
- }
-
- /* get hidden */
- hidden = g_key_file_get_boolean (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL);
- if (hidden) {
- g_debug ("hidden, so ignoring %s", filename);
- ret = FALSE;
- goto out;
- }
-
- /* is WM? */
- ret = !g_key_file_has_group (file, "Window Manager");
- if (!ret) {
- g_debug ("ignoring Window Manager");
- goto out;
- }
-
- /* get exec */
- exec = g_key_file_get_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TRY_EXEC, NULL);
- if (exec == NULL)
- exec = g_key_file_get_string (file, G_KEY_FILE_DESKTOP_GROUP, "Exec", NULL);
-
- /* abandon attempt */
- if (exec == NULL) {
- ret = FALSE;
- goto out;
- }
-
- /* get name */
- text = g_key_file_get_locale_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME,
NULL, NULL);
- if (text != NULL)
- name = g_markup_escape_text (text, -1);
-
- /* get icon */
- icon = g_key_file_get_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
- if (icon == NULL || !gpk_desktop_check_icon_valid (icon)) {
- g_free (icon);
- icon = g_strdup (gpk_info_enum_to_icon_name (PK_INFO_ENUM_AVAILABLE));
- }
-
- /* get summary */
- summary = g_key_file_get_locale_string (file, G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
- if (summary == NULL)
- summary = g_key_file_get_locale_string (file, G_KEY_FILE_DESKTOP_GROUP, "GenericName", NULL,
NULL);
-
- /* put formatted text into treeview */
- gtk_list_store_append (helper->priv->list_store, &iter);
- joint = g_strdup_printf ("%s - %s", name, summary);
- fulltext = gpk_package_id_format_twoline (NULL, package_id, joint);
-
- gtk_list_store_set (helper->priv->list_store, &iter,
- GPK_CHOOSER_COLUMN_TEXT, fulltext,
- GPK_CHOOSER_COLUMN_FILENAME, filename,
- GPK_CHOOSER_COLUMN_ICON, icon, -1);
-out:
- if (file != NULL)
- g_key_file_free (file);
- g_free (exec);
- g_free (icon);
- g_free (name);
- g_free (text);
- g_free (joint);
- g_free (summary);
-
- return ret;
-}
-
-/**
* gpk_helper_run_add_package_ids:
**/
static guint
gpk_helper_run_add_package_ids (GpkHelperRun *helper, gchar **package_ids)
{
- guint i, j;
- guint length;
- guint added = 0;
- const gchar *filename;
- GPtrArray *array;
- gchar **parts;
- gboolean ret;
- PkDesktop *desktop;
- GError *error = NULL;
-
- /* open database */
- desktop = pk_desktop_new ();
- ret = pk_desktop_open_database (desktop, NULL);
- if (!ret) {
- g_debug ("failed to open desktop DB");
- goto out;
- }
-
- /* add each package */
- length = g_strv_length (package_ids);
- for (i=0; i<length; i++) {
- parts = g_strsplit (package_ids[i], ";", 0);
- array = pk_desktop_get_files_for_package (desktop, parts[0], &error);
- if (array != NULL) {
- for (j=0; j<array->len; j++) {
- filename = g_ptr_array_index (array, j);
- ret = gpk_helper_run_add_desktop_file (helper, package_ids[i], filename);
- if (ret)
- added++;
- }
- g_ptr_array_unref (array);
- } else {
- g_warning ("failed to get files for %s: %s", parts[0], error->message);
- g_clear_error (&error);
- }
- g_strfreev (parts);
- }
- g_object_unref (desktop);
-out:
- return added;
+ return 0;
}
/**
diff --git a/src/gpk-modal-dialog.c b/src/gpk-modal-dialog.c
index c96eff7..f98c9e0 100644
--- a/src/gpk-modal-dialog.c
+++ b/src/gpk-modal-dialog.c
@@ -43,7 +43,6 @@
#include "gpk-common.h"
#include "gpk-gnome.h"
#include "gpk-enum.h"
-#include "gpk-desktop.h"
static void gpk_modal_dialog_finalize (GObject *object);
@@ -612,8 +611,7 @@ gpk_modal_dialog_set_package_list (GpkModalDialog *dialog, const GPtrArray *list
{
GtkTreeIter iter;
PkPackage *item;
- PkDesktop *desktop;
- gchar *icon;
+ const gchar *icon;
gchar *text;
guint i;
GtkWidget *widget;
@@ -630,8 +628,6 @@ gpk_modal_dialog_set_package_list (GpkModalDialog *dialog, const GPtrArray *list
else if (list->len > 1)
gtk_widget_set_size_request (widget, -1, 150);
- desktop = pk_desktop_new ();
-
/* add each well */
for (i=0; i<list->len; i++) {
item = g_ptr_array_index (list, i);
@@ -654,10 +650,7 @@ gpk_modal_dialog_set_package_list (GpkModalDialog *dialog, const GPtrArray *list
/* get the icon */
split = pk_package_id_split (package_id);
- icon = gpk_desktop_guess_icon_name (desktop, split[0]);
- if (icon == NULL)
- icon = g_strdup (gpk_info_enum_to_icon_name (PK_INFO_ENUM_INSTALLED));
-
+ icon = gpk_info_enum_to_icon_name (PK_INFO_ENUM_INSTALLED);
gtk_list_store_append (dialog->priv->store, &iter);
gtk_list_store_set (dialog->priv->store, &iter,
GPK_MODAL_DIALOG_STORE_IMAGE, icon,
@@ -667,12 +660,9 @@ gpk_modal_dialog_set_package_list (GpkModalDialog *dialog, const GPtrArray *list
g_strfreev (split);
g_free (package_id);
g_free (summary);
- g_free (icon);
g_free (text);
}
- g_object_unref (desktop);
-
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]