gnome-control-center r8698 - in trunk/capplets/appearance: . data



Author: jensg
Date: Thu May  8 19:10:14 2008
New Revision: 8698
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8698&view=rev

Log:
2008-05-08  Jens Granseuer  <jensgr gmx net>

	* appearance-style.c: (style_message_area_response_cb),
	(update_message_area), (gtk_theme_changed), (style_init):
	* appearance.h:
	* data/appearance.glade: also show a missing theme engine in the
	GTK themes list and offer to install it via packagekit


Modified:
   trunk/capplets/appearance/ChangeLog
   trunk/capplets/appearance/appearance-style.c
   trunk/capplets/appearance/appearance.h
   trunk/capplets/appearance/data/appearance.glade

Modified: trunk/capplets/appearance/appearance-style.c
==============================================================================
--- trunk/capplets/appearance/appearance-style.c	(original)
+++ trunk/capplets/appearance/appearance-style.c	Thu May  8 19:10:14 2008
@@ -26,12 +26,15 @@
 #include "gtkrc-utils.h"
 #include "gconf-property-editor.h"
 #include "theme-thumbnail.h"
+#include "gedit-message-area.h"
 
 typedef void (* ThumbnailGenFunc) (void               *type,
 				   ThemeThumbnailFunc  theme,
 				   AppearanceData     *data,
 				   GDestroyNotify     *destroy);
 
+static void update_message_area (AppearanceData *data);
+
 static const gchar *symbolic_names[NUM_SYMBOLIC_COLORS] = {
   "fg_color", "bg_color",
   "text_color", "base_color",
@@ -169,6 +172,91 @@
 }
 
 static void
+style_message_area_response_cb (GtkWidget *w,
+                                gint response_id,
+                                AppearanceData *data)
+{
+  GtkSettings *settings = gtk_settings_get_default ();
+  gchar *theme;
+  gchar *engine_path;
+
+  g_object_get (settings, "gtk-theme-name", &theme, NULL);
+  engine_path = gtk_theme_info_missing_engine (theme, FALSE);
+  g_free (theme);
+
+  if (engine_path != NULL) {
+    theme_install_file (GTK_WINDOW (gtk_widget_get_toplevel (data->style_message_area)),
+                        engine_path);
+    g_free (engine_path);
+  }
+  update_message_area (data);
+}
+
+static void
+update_message_area (AppearanceData *data)
+{
+  GtkSettings *settings = gtk_settings_get_default ();
+  gchar *theme = NULL;
+  gchar *engine;
+
+  g_object_get (settings, "gtk-theme-name", &theme, NULL);
+  engine = gtk_theme_info_missing_engine (theme, TRUE);
+  g_free (theme);
+
+  if (data->style_message_area == NULL) {
+    GtkWidget *hbox;
+    GtkWidget *parent;
+    GtkWidget *icon;
+
+    if (engine == NULL)
+      return;
+
+    data->style_message_area = gedit_message_area_new ();
+
+    g_signal_connect (data->style_message_area, "response",
+                      (GCallback) style_message_area_response_cb, data);
+
+    data->style_install_button = gedit_message_area_add_button (
+        GEDIT_MESSAGE_AREA (data->style_message_area),
+        _("Install"), GTK_RESPONSE_APPLY);
+
+    data->style_message_label = gtk_label_new (NULL);
+    gtk_label_set_line_wrap (GTK_LABEL (data->style_message_label), TRUE);
+    gtk_misc_set_alignment (GTK_MISC (data->style_message_label), 0.0, 0.5);
+
+    hbox = gtk_hbox_new (FALSE, 9);
+    icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+    gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), data->style_message_label, TRUE, TRUE, 0);
+    gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (data->style_message_area), hbox);
+    gtk_widget_show_all (data->style_message_area);
+    gtk_widget_set_no_show_all (data->style_message_area, TRUE);
+
+    parent = glade_xml_get_widget (data->xml, "gtk_themes_vbox");
+    gtk_box_pack_start (GTK_BOX (parent), data->style_message_area, FALSE, FALSE, 0);
+  }
+
+  if (engine != NULL) {
+    gchar *message = g_strdup_printf (_("This theme will not look as intended because the required GTK+ theme engine '%s' is not installed."),
+                                      engine);
+    gtk_label_set_text (GTK_LABEL (data->style_message_label), message);
+    g_free (message);
+    g_free (engine);
+
+    if (packagekit_available ())
+      gtk_widget_show (data->style_install_button);
+    else
+      gtk_widget_hide (data->style_install_button);
+
+    gtk_widget_show (data->style_message_area);
+    gtk_widget_queue_draw (data->style_message_area);
+  } else {
+    gtk_widget_hide (data->style_message_area);
+  }
+}
+
+static void
 update_color_buttons_from_string (const gchar *color_scheme, AppearanceData *data)
 {
   GdkColor colors[NUM_SYMBOLIC_COLORS];
@@ -318,8 +406,10 @@
      * info for the color scheme updates already. */
     g_object_get (settings, "gtk-theme-name", &current, NULL);
 
-    if (strcmp (current, name) != 0)
+    if (strcmp (current, name) != 0) {
       g_object_set (settings, "gtk-theme-name", name, NULL);
+      update_message_area (data);
+    }
 
     g_free (current);
 
@@ -855,6 +945,9 @@
   data->gtk_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/gtk-theme-thumbnailing.png", NULL);
   data->window_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/window-theme-thumbnailing.png", NULL);
   data->icon_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/icon-theme-thumbnailing.png", NULL);
+  data->style_message_area = NULL;
+  data->style_message_label = NULL;
+  data->style_install_button = NULL;
 
   w = glade_xml_get_widget (data->xml, "theme_details");
   g_signal_connect (w, "response", (GCallback) style_response_cb, NULL);
@@ -910,6 +1003,7 @@
   g_signal_connect (glade_xml_get_widget (data->xml, "icon_themes_delete"), "clicked", (GCallback) icon_theme_delete_cb, data);
   g_signal_connect (glade_xml_get_widget (data->xml, "cursor_themes_delete"), "clicked", (GCallback) cursor_theme_delete_cb, data);
 
+  update_message_area (data);
   gnome_theme_info_register_theme_change ((ThemeChangedCallback) changed_on_disk_cb, data);
 }
 

Modified: trunk/capplets/appearance/appearance.h
==============================================================================
--- trunk/capplets/appearance/appearance.h	(original)
+++ trunk/capplets/appearance/appearance.h	Thu May  8 19:10:14 2008
@@ -75,4 +75,7 @@
   GdkPixbuf *gtk_theme_icon;
   GdkPixbuf *window_theme_icon;
   GdkPixbuf *icon_theme_icon;
+  GtkWidget *style_message_area;
+  GtkWidget *style_message_label;
+  GtkWidget *style_install_button;
 } AppearanceData;

Modified: trunk/capplets/appearance/data/appearance.glade
==============================================================================
--- trunk/capplets/appearance/data/appearance.glade	(original)
+++ trunk/capplets/appearance/data/appearance.glade	Thu May  8 19:10:14 2008
@@ -1893,21 +1893,28 @@
                 <property name="border_width">12</property>
                 <property name="spacing">6</property>
                 <child>
-                  <widget class="GtkScrolledWindow" id="scrolledwindow3">
+                  <widget class="GtkVBox" id="gtk_themes_vbox">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_IN</property>
+                    <property name="spacing">6</property>
                     <child>
-                      <widget class="GtkTreeView" id="gtk_themes_list">
-                        <property name="height_request">300</property>
+                      <widget class="GtkScrolledWindow" id="scrolledwindow3">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="headers_visible">False</property>
-                        <property name="headers_clickable">True</property>
+                        <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                        <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                        <property name="shadow_type">GTK_SHADOW_IN</property>
+                        <child>
+                          <widget class="GtkTreeView" id="gtk_themes_list">
+                            <property name="height_request">300</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="headers_visible">False</property>
+                            <property name="headers_clickable">True</property>
+                          </widget>
+                        </child>
                       </widget>
                     </child>
                   </widget>



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