[gnome-color-manager] Offer to install shared-color-profiles-extra if it is not yet installed
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Offer to install shared-color-profiles-extra if it is not yet installed
- Date: Tue, 6 Apr 2010 09:15:11 +0000 (UTC)
commit b69b110945decc34ba111faeba9d36789c5b198d
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 6 09:32:10 2010 +0100
Offer to install shared-color-profiles-extra if it is not yet installed
src/gcm-prefs.c | 35 +++++++++++++++++++++++++++++++++++
src/gcm-utils.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/gcm-utils.h | 5 ++++-
3 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 4330195..2dd6c73 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -56,6 +56,7 @@ static GcmColorimeter *colorimeter = NULL;
static gboolean setting_up_device = FALSE;
static GtkWidget *info_bar_loading = NULL;
static GtkWidget *info_bar_vcgt = NULL;
+static GtkWidget *info_bar_profiles = NULL;
static GtkWidget *cie_widget = NULL;
static GtkWidget *trc_widget = NULL;
static GConfClient *gconf_client = NULL;
@@ -2180,6 +2181,7 @@ gcm_prefs_startup_phase2_idle_cb (gpointer user_data)
GtkWidget *widget;
GtkTreeSelection *selection;
GtkTreePath *path;
+ gboolean ret;
/* update list of profiles */
gcm_prefs_update_profile_list ();
@@ -2191,6 +2193,11 @@ gcm_prefs_startup_phase2_idle_cb (gpointer user_data)
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
+ /* do we show the shared-color-profiles-extra installer? */
+ egg_debug ("getting installed");
+ ret = gcm_utils_is_package_installed (GCM_PREFS_PACKAGE_NAME_COLOR_PROFILES_EXTRA);
+ gtk_widget_set_visible (info_bar_profiles, !ret);
+
return FALSE;
}
@@ -2600,9 +2607,19 @@ gcm_prefs_client_notify_loading_cb (GcmClient *client, GParamSpec *pspec, gpoint
static void
gcm_prefs_info_bar_response_cb (GtkDialog *dialog, GtkResponseType response, gpointer user_data)
{
+ GtkWindow *window;
+ gboolean ret;
+
if (response == GTK_RESPONSE_HELP) {
/* open the help file in the right place */
gcm_gnome_help ("faq-missing-vcgt");
+
+ } else if (response == GTK_RESPONSE_APPLY) {
+ /* install the extra profiles */
+ window = GTK_WINDOW(gtk_builder_get_object (builder, "dialog_prefs"));
+ ret = gcm_utils_install_package (GCM_PREFS_PACKAGE_NAME_COLOR_PROFILES_EXTRA, window);
+ if (ret)
+ gtk_widget_hide (info_bar_profiles);
}
}
@@ -2686,6 +2703,7 @@ main (int argc, char **argv)
GtkTreeSelection *selection;
GtkWidget *info_bar_loading_label;
GtkWidget *info_bar_vcgt_label;
+ GtkWidget *info_bar_profiles_label;
GtkSizeGroup *size_group = NULL;
GtkSizeGroup *size_group2 = NULL;
GdkScreen *screen;
@@ -2987,10 +3005,16 @@ main (int argc, char **argv)
info_bar_vcgt = gtk_info_bar_new ();
g_signal_connect (info_bar_vcgt, "response",
G_CALLBACK (gcm_prefs_info_bar_response_cb), NULL);
+ info_bar_profiles = gtk_info_bar_new ();
+ g_signal_connect (info_bar_profiles, "response",
+ G_CALLBACK (gcm_prefs_info_bar_response_cb), NULL);
/* TRANSLATORS: button for more details about the vcgt failure */
gtk_info_bar_add_button (GTK_INFO_BAR(info_bar_vcgt), _("More Information"), GTK_RESPONSE_HELP);
+ /* TRANSLATORS: button to install extra profiles */
+ gtk_info_bar_add_button (GTK_INFO_BAR(info_bar_profiles), _("Install now"), GTK_RESPONSE_APPLY);
+
/* TRANSLATORS: this is displayed while the devices are being probed */
info_bar_loading_label = gtk_label_new (_("Loading list of devicesâ?¦"));
gtk_info_bar_set_message_type (GTK_INFO_BAR(info_bar_loading), GTK_MESSAGE_INFO);
@@ -3005,6 +3029,13 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER(widget), info_bar_vcgt_label);
gtk_widget_show (info_bar_vcgt_label);
+ /* TRANSLATORS: this is displayed when the profile is crap */
+ info_bar_profiles_label = gtk_label_new (_("More color profiles could be automatically installed."));
+ gtk_info_bar_set_message_type (GTK_INFO_BAR(info_bar_profiles), GTK_MESSAGE_INFO);
+ widget = gtk_info_bar_get_content_area (GTK_INFO_BAR(info_bar_profiles));
+ gtk_container_add (GTK_CONTAINER(widget), info_bar_profiles_label);
+ gtk_widget_show (info_bar_profiles_label);
+
/* add infobar to devices pane */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_devices"));
gtk_box_pack_start (GTK_BOX(widget), info_bar_loading, FALSE, FALSE, 0);
@@ -3013,6 +3044,10 @@ main (int argc, char **argv)
widget = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_sections"));
gtk_box_pack_start (GTK_BOX(widget), info_bar_vcgt, FALSE, FALSE, 0);
+ /* add infobar to defaults pane */
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "vbox3"));
+ gtk_box_pack_start (GTK_BOX(widget), info_bar_profiles, TRUE, FALSE, 0);
+
/* show main UI */
gtk_window_set_default_size (GTK_WINDOW(main_window), 1000, 450);
gtk_widget_show (main_window);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 410c0b8..d7ac2f6 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -181,6 +181,54 @@ out:
}
/**
+ * gcm_utils_is_package_installed:
+ **/
+gboolean
+gcm_utils_is_package_installed (const gchar *package_name)
+{
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ gboolean ret;
+ gboolean installed = TRUE;
+
+ g_return_val_if_fail (package_name != NULL, FALSE);
+
+#ifndef GCM_USE_PACKAGEKIT
+ egg_warning ("cannot query %s: this package was not compiled with --enable-packagekit", package_name);
+ return TRUE;
+#endif
+
+ /* get a session bus connection */
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+ /* connect to PackageKit */
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit.Query");
+
+ /* set timeout */
+ dbus_g_proxy_set_default_timeout (proxy, G_MAXINT);
+
+ /* execute sync method */
+ ret = dbus_g_proxy_call (proxy, "IsInstalled", &error,
+ G_TYPE_STRING, package_name,
+ G_TYPE_STRING, "timeout=5",
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &installed,
+ G_TYPE_INVALID);
+ if (!ret) {
+ egg_warning ("failed to get installed status: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+out:
+ g_object_unref (proxy);
+ return installed;
+}
+
+/**
* gcm_utils_output_is_lcd_internal:
* @output_name: the output name
*
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index 6102373..f40a0ca 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -50,6 +50,8 @@
/* DISTROS: you will have to patch if you have changed the name of these packages */
#define GCM_PREFS_PACKAGE_NAME_SHARED_COLOR_TARGETS "shared-color-targets"
#define GCM_PREFS_PACKAGE_NAME_ARGYLLCMS "argyllcms"
+#define GCM_PREFS_PACKAGE_NAME_COLOR_PROFILES "shared-color-profiles"
+#define GCM_PREFS_PACKAGE_NAME_COLOR_PROFILES_EXTRA "shared-color-profiles-extra"
gboolean gcm_utils_mkdir_for_filename (const gchar *filename,
GError **error);
@@ -70,10 +72,11 @@ GcmProfileKind gcm_utils_device_kind_to_profile_kind (GcmDeviceKind kind);
gchar *gcm_utils_format_date_time (const struct tm *created);
gboolean gcm_utils_install_package (const gchar *package_name,
GtkWindow *window);
+gboolean gcm_utils_is_package_installed (const gchar *package_name);
void gcm_utils_ensure_printable (gchar *text);
gboolean gcm_utils_is_icc_profile (GFile *file);
gchar *gcm_utils_linkify (const gchar *text);
-const gchar *gcm_intent_to_localized_text (GcmIntent intent);
+const gchar *gcm_intent_to_localized_text (GcmIntent intent);
#endif /* __GCM_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]