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
This commit is contained in:
parent
fcfc55091e
commit
a780f374cb
5 changed files with 121 additions and 4 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
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>
|
2008-05-07 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
Patch by: Lincoln de Sousa <lincoln@minaslivre.org>
|
Patch by: Lincoln de Sousa <lincoln@minaslivre.org>
|
||||||
|
|
|
@ -42,7 +42,8 @@ enum
|
||||||
{
|
{
|
||||||
RESPONSE_APPLY_BG,
|
RESPONSE_APPLY_BG,
|
||||||
RESPONSE_REVERT_FONT,
|
RESPONSE_REVERT_FONT,
|
||||||
RESPONSE_APPLY_FONT
|
RESPONSE_APPLY_FONT,
|
||||||
|
RESPONSE_INSTALL_ENGINE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -57,6 +58,8 @@ static const GtkTargetEntry drop_types[] =
|
||||||
{"_NETSCAPE_URL", 0, TARGET_NS_URL}
|
{"_NETSCAPE_URL", 0, TARGET_NS_URL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void theme_message_area_update (AppearanceData *data);
|
||||||
|
|
||||||
static time_t
|
static time_t
|
||||||
theme_get_mtime (const char *name)
|
theme_get_mtime (const char *name)
|
||||||
{
|
{
|
||||||
|
@ -441,6 +444,7 @@ theme_message_area_response_cb (GtkWidget *w,
|
||||||
{
|
{
|
||||||
const GnomeThemeMetaInfo *theme;
|
const GnomeThemeMetaInfo *theme;
|
||||||
gchar *tmpfont;
|
gchar *tmpfont;
|
||||||
|
gchar *engine_path;
|
||||||
|
|
||||||
theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
|
theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
|
||||||
if (!theme)
|
if (!theme)
|
||||||
|
@ -566,6 +570,16 @@ theme_message_area_response_cb (GtkWidget *w,
|
||||||
theme->monospace_font, NULL);
|
theme->monospace_font, NULL);
|
||||||
}
|
}
|
||||||
break;
|
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);
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
show_error = !gnome_theme_meta_info_validate (theme, &error);
|
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),
|
GEDIT_MESSAGE_AREA (data->theme_message_area),
|
||||||
_("Revert Font"),
|
_("Revert Font"),
|
||||||
RESPONSE_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);
|
data->theme_message_label = gtk_label_new (NULL);
|
||||||
gtk_widget_show (data->theme_message_label);
|
gtk_widget_show (data->theme_message_label);
|
||||||
|
@ -718,6 +739,13 @@ theme_message_area_update (AppearanceData *data)
|
||||||
else
|
else
|
||||||
gtk_widget_hide (data->revert_font_button);
|
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) {
|
if (show_error || show_apply_background || show_apply_font || show_revert_font) {
|
||||||
gtk_widget_show (data->theme_message_area);
|
gtk_widget_show (data->theme_message_area);
|
||||||
gtk_widget_queue_draw (data->theme_message_area);
|
gtk_widget_queue_draw (data->theme_message_area);
|
||||||
|
|
|
@ -62,6 +62,7 @@ typedef struct {
|
||||||
GtkWidget *apply_background_button;
|
GtkWidget *apply_background_button;
|
||||||
GtkWidget *revert_font_button;
|
GtkWidget *revert_font_button;
|
||||||
GtkWidget *apply_font_button;
|
GtkWidget *apply_font_button;
|
||||||
|
GtkWidget *install_button;
|
||||||
GtkWidget *theme_info_icon;
|
GtkWidget *theme_info_icon;
|
||||||
GtkWidget *theme_error_icon;
|
GtkWidget *theme_error_icon;
|
||||||
gchar *revert_application_font;
|
gchar *revert_application_font;
|
||||||
|
|
|
@ -20,10 +20,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "appearance.h"
|
#include "appearance.h"
|
||||||
#include "theme-util.h"
|
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
#include <string.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
|
static gboolean
|
||||||
directory_delete_recursive (GFile *directory, GError **error)
|
directory_delete_recursive (GFile *directory, GError **error)
|
||||||
|
@ -235,3 +238,72 @@ theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
|
||||||
|
|
||||||
return FALSE;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -57,3 +57,6 @@ gboolean theme_delete (const gchar *name, ThemeType type);
|
||||||
|
|
||||||
gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter);
|
gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter);
|
||||||
gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, 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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue