summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Granseuer <jensgr@gmx.net>2008-05-07 20:19:36 +0000
committerJens Granseuer <jensg@src.gnome.org>2008-05-07 20:19:36 +0000
commita780f374cbe60b49b05d2c28e25b905163d62131 (patch)
treefd3663d60e0922b3eb41620b6e78531294bb76a3
parentfcfc55091e6e6412b6ae92ac44c77373b7780af2 (diff)
downloadgnome-control-center-a780f374cbe60b49b05d2c28e25b905163d62131.tar.gz
Add support for installing missing GTK+ theme engines via packagekit (bug
2008-05-07 Jens Granseuer <jensgr@gmx.net> Add support for installing missing GTK+ theme engines via packagekit (bug #511065) * appearance-themes.c: (theme_message_area_response_cb), (theme_message_area_update): when we detect a missing engine, check if packagekit is available on the session bus. If it is show an install button to pull the corresponding package * appearance.h: * theme-util.c: (packagekit_available), (theme_install_file): * theme-util.h: add support functions svn path=/trunk/; revision=8695
-rw-r--r--capplets/appearance/ChangeLog13
-rw-r--r--capplets/appearance/appearance-themes.c32
-rw-r--r--capplets/appearance/appearance.h1
-rw-r--r--capplets/appearance/theme-util.c76
-rw-r--r--capplets/appearance/theme-util.h3
5 files changed, 121 insertions, 4 deletions
diff --git a/capplets/appearance/ChangeLog b/capplets/appearance/ChangeLog
index eefd47813..269c9d14b 100644
--- a/capplets/appearance/ChangeLog
+++ b/capplets/appearance/ChangeLog
@@ -1,5 +1,18 @@
2008-05-07 Jens Granseuer <jensgr@gmx.net>
+ Add support for installing missing GTK+ theme engines via
+ packagekit (bug #511065)
+
+ * appearance-themes.c: (theme_message_area_response_cb),
+ (theme_message_area_update): when we detect a missing engine,
+ check if packagekit is available on the session bus. If it is show
+ an install button to pull the corresponding package
+ * appearance.h:
+ * theme-util.c: (packagekit_available), (theme_install_file):
+ * theme-util.h: add support functions
+
+2008-05-07 Jens Granseuer <jensgr@gmx.net>
+
Patch by: Lincoln de Sousa <lincoln@minaslivre.org>
* theme-save.c: (setup_directory_structure), (write_theme_to_disk):
diff --git a/capplets/appearance/appearance-themes.c b/capplets/appearance/appearance-themes.c
index c245b7ade..0a76d4d30 100644
--- a/capplets/appearance/appearance-themes.c
+++ b/capplets/appearance/appearance-themes.c
@@ -42,7 +42,8 @@ enum
{
RESPONSE_APPLY_BG,
RESPONSE_REVERT_FONT,
- RESPONSE_APPLY_FONT
+ RESPONSE_APPLY_FONT,
+ RESPONSE_INSTALL_ENGINE
};
enum
@@ -57,6 +58,8 @@ static const GtkTargetEntry drop_types[] =
{"_NETSCAPE_URL", 0, TARGET_NS_URL}
};
+static void theme_message_area_update (AppearanceData *data);
+
static time_t
theme_get_mtime (const char *name)
{
@@ -441,6 +444,7 @@ theme_message_area_response_cb (GtkWidget *w,
{
const GnomeThemeMetaInfo *theme;
gchar *tmpfont;
+ gchar *engine_path;
theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
if (!theme)
@@ -566,6 +570,16 @@ theme_message_area_response_cb (GtkWidget *w,
theme->monospace_font, NULL);
}
break;
+
+ case RESPONSE_INSTALL_ENGINE:
+ engine_path = gtk_theme_info_missing_engine (theme->gtk_theme_name, FALSE);
+ if (engine_path != NULL) {
+ theme_install_file (GTK_WINDOW (gtk_widget_get_toplevel (data->install_button)),
+ engine_path);
+ g_free (engine_path);
+ }
+ theme_message_area_update (data);
+ break;
}
}
@@ -583,8 +597,11 @@ theme_message_area_update (AppearanceData *data)
theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
- if (!theme)
+ if (!theme) {
+ if (data->theme_message_area != NULL)
+ gtk_widget_hide (data->theme_message_area);
return;
+ }
show_error = !gnome_theme_meta_info_validate (theme, &error);
@@ -663,6 +680,10 @@ theme_message_area_update (AppearanceData *data)
GEDIT_MESSAGE_AREA (data->theme_message_area),
_("Revert Font"),
RESPONSE_REVERT_FONT);
+ data->install_button = gedit_message_area_add_button (
+ GEDIT_MESSAGE_AREA (data->theme_message_area),
+ _("Install"),
+ RESPONSE_INSTALL_ENGINE);
data->theme_message_label = gtk_label_new (NULL);
gtk_widget_show (data->theme_message_label);
@@ -718,6 +739,13 @@ theme_message_area_update (AppearanceData *data)
else
gtk_widget_hide (data->revert_font_button);
+ if (show_error
+ && g_error_matches (error, GNOME_THEME_ERROR, GNOME_THEME_ERROR_GTK_ENGINE_NOT_AVAILABLE)
+ && packagekit_available ())
+ gtk_widget_show (data->install_button);
+ else
+ gtk_widget_hide (data->install_button);
+
if (show_error || show_apply_background || show_apply_font || show_revert_font) {
gtk_widget_show (data->theme_message_area);
gtk_widget_queue_draw (data->theme_message_area);
diff --git a/capplets/appearance/appearance.h b/capplets/appearance/appearance.h
index 4c12be076..9739a821d 100644
--- a/capplets/appearance/appearance.h
+++ b/capplets/appearance/appearance.h
@@ -62,6 +62,7 @@ typedef struct {
GtkWidget *apply_background_button;
GtkWidget *revert_font_button;
GtkWidget *apply_font_button;
+ GtkWidget *install_button;
GtkWidget *theme_info_icon;
GtkWidget *theme_error_icon;
gchar *revert_application_font;
diff --git a/capplets/appearance/theme-util.c b/capplets/appearance/theme-util.c
index 4adf3c0c7..ee016e200 100644
--- a/capplets/appearance/theme-util.c
+++ b/capplets/appearance/theme-util.c
@@ -20,10 +20,13 @@
*/
#include "appearance.h"
-#include "theme-util.h"
-#include <glib/gi18n.h>
#include <string.h>
+#include <glib/gi18n.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+
+#include "theme-util.h"
static gboolean
directory_delete_recursive (GFile *directory, GError **error)
@@ -235,3 +238,72 @@ theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
return FALSE;
}
+
+gboolean
+packagekit_available (void)
+{
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ gboolean available = FALSE;
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ if (connection == NULL) {
+ return FALSE;
+ }
+
+ proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ org_freedesktop_DBus_name_has_owner (proxy,
+ "org.freedesktop.PackageKit",
+ &available,
+ NULL);
+
+ g_object_unref (proxy);
+ dbus_g_connection_unref (connection);
+
+ return available;
+}
+
+void
+theme_install_file (GtkWindow *parent, const gchar *path)
+{
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ gboolean ret;
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ if (connection == NULL) {
+ g_warning ("Could not get session bus");
+ return;
+ }
+
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit");
+
+
+ ret = dbus_g_proxy_call (proxy, "InstallProvideFile", &error,
+ G_TYPE_STRING, path,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
+ g_object_unref (proxy);
+
+ if (!ret) {
+ GtkWidget *dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not install theme engine"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), error->message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+ }
+ dbus_g_connection_unref (connection);
+}
diff --git a/capplets/appearance/theme-util.h b/capplets/appearance/theme-util.h
index 5a921dcfd..033cd1282 100644
--- a/capplets/appearance/theme-util.h
+++ b/capplets/appearance/theme-util.h
@@ -57,3 +57,6 @@ gboolean theme_delete (const gchar *name, ThemeType type);
gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter);
gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter);
+
+void theme_install_file (GtkWindow *parent, const gchar *path);
+gboolean packagekit_available (void);