[Xfce4-commits] r29349 - in xfwm4/trunk: . settings-dialogs

Olivier Fourdan olivier at xfce.org
Sun Jan 25 18:59:12 CET 2009


Author: olivier
Date: 2009-01-25 17:59:12 +0000 (Sun, 25 Jan 2009)
New Revision: 29349

Modified:
   xfwm4/trunk/ChangeLog
   xfwm4/trunk/NEWS
   xfwm4/trunk/configure.ac.in
   xfwm4/trunk/settings-dialogs/xfwm4-dialog.glade
   xfwm4/trunk/settings-dialogs/xfwm4-settings.c
Log:
	* settings-dialogs/xfwm4-settings.c, 
	  settings-dialogs/xfwm4-dialog.glade: Make title alignment and button
	  layout insensitive when not supported by the theme selected, fix a
	  memory leak,
	  configure.ac.in: Remove AC_C_CONST
	* settings-dialogs/xfwm4-settings.c: Fix dragging button layout when 
	  the dialog is embedded in the settings dialog (Bug #4524).

Modified: xfwm4/trunk/ChangeLog
===================================================================
--- xfwm4/trunk/ChangeLog	2009-01-25 16:43:14 UTC (rev 29348)
+++ xfwm4/trunk/ChangeLog	2009-01-25 17:59:12 UTC (rev 29349)
@@ -1,3 +1,16 @@
+2009-01-25	nick
+
+	* settings-dialogs/xfwm4-settings.c, 
+	  settings-dialogs/xfwm4-dialog.glade: Make title alignment and button
+	  layout insensitive when not supported by the theme selected, fix a
+	  memory leak,
+	  configure.ac.in: Remove AC_C_CONST
+
+2009-01-25	nick
+
+	* settings-dialogs/xfwm4-settings.c: Fix dragging button layout when 
+	  the dialog is embedded in the settings dialog (Bug #4524).
+
 2009-01-24	olivier
 
 	* src/display.c, src/display.h, src/events.c, src/client.c

Modified: xfwm4/trunk/NEWS
===================================================================
--- xfwm4/trunk/NEWS	2009-01-25 16:43:14 UTC (rev 29348)
+++ xfwm4/trunk/NEWS	2009-01-25 17:59:12 UTC (rev 29349)
@@ -9,6 +9,8 @@
 - Add support for NET_WM_FULLSCREEN_MONITORS
 - Fix dragging button layout when the dialog is embedded in the settings
   dialog (Bug #4524).
+- Make title alignment and button layout insensitive when not supported by the 
+  theme selected.
 
 4.5.93 (Xfce 4.6beta3)
 ======================

Modified: xfwm4/trunk/configure.ac.in
===================================================================
--- xfwm4/trunk/configure.ac.in	2009-01-25 16:43:14 UTC (rev 29348)
+++ xfwm4/trunk/configure.ac.in	2009-01-25 17:59:12 UTC (rev 29349)
@@ -47,7 +47,6 @@
 AC_PROG_LIBTOOL
 
 dnl Check C Compiler Characteristics
-AC_C_CONST
 AC_C_INLINE
 
 dnl check for standard header files

Modified: xfwm4/trunk/settings-dialogs/xfwm4-dialog.glade
===================================================================
--- xfwm4/trunk/settings-dialogs/xfwm4-dialog.glade	2009-01-25 16:43:14 UTC (rev 29348)
+++ xfwm4/trunk/settings-dialogs/xfwm4-dialog.glade	2009-01-25 17:59:12 UTC (rev 29349)
@@ -114,7 +114,7 @@
                         <property name="label_xalign">0</property>
                         <property name="shadow_type">GTK_SHADOW_NONE</property>
                         <child>
-                          <widget class="GtkAlignment" id="alignment15">
+                          <widget class="GtkAlignment" id="title_align_box">
                             <property name="visible">True</property>
                             <property name="border_width">6</property>
                             <property name="bottom_padding">6</property>
@@ -152,7 +152,7 @@
                         <property name="label_xalign">0</property>
                         <property name="shadow_type">GTK_SHADOW_NONE</property>
                         <child>
-                          <widget class="GtkAlignment" id="alignment16">
+                          <widget class="GtkAlignment" id="button_layout_box">
                             <property name="visible">True</property>
                             <property name="bottom_padding">6</property>
                             <property name="left_padding">12</property>

Modified: xfwm4/trunk/settings-dialogs/xfwm4-settings.c
===================================================================
--- xfwm4/trunk/settings-dialogs/xfwm4-settings.c	2009-01-25 16:43:14 UTC (rev 29348)
+++ xfwm4/trunk/settings-dialogs/xfwm4-settings.c	2009-01-25 17:59:12 UTC (rev 29349)
@@ -205,8 +205,15 @@
   const gchar *shortcut;
 };
 
+enum
+{
+  COL_THEME_NAME,
+  COL_THEME_RC,
+  N_COLUMNS
+};
 
 
+
 static GObjectClass      *xfwm_settings_parent_class = NULL;
 
 static const MenuTemplate double_click_values[] = {
@@ -333,26 +340,7 @@
 }
 
 
-/*
- * Xfce 4.6 depends on glib 2.12,
- * Glib 2.14 comes with g_hash_table_get_keys(),
- * until then... use the following function with
- * g_hash_table_foreach()
- */
-#if !GLIB_CHECK_VERSION (2,14,0)
-static void
-xfwm4_settings_get_list_keys_foreach (gpointer key,
-                                      gpointer value,
-                                      gpointer user_data)
-{
-  GList **keys = user_data;
-  *keys = g_list_prepend (*keys, key);
-}
-#endif
 
-
-
-
 static void
 xfwm_settings_class_init (XfwmSettingsClass *klass)
 {
@@ -446,12 +434,13 @@
 
   /* Style tab: theme name */
   {
-    list_store = gtk_list_store_new (1, G_TYPE_STRING);
-    gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (list_store), 0,
+    list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+    gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (list_store), COL_THEME_NAME,
                                      (GtkTreeIterCompareFunc) xfwm_settings_theme_sort_func,
                                      NULL, NULL);
-    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), 0, GTK_SORT_ASCENDING);
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), COL_THEME_NAME, GTK_SORT_ASCENDING);
     gtk_tree_view_set_model (GTK_TREE_VIEW (theme_name_treeview), GTK_TREE_MODEL (list_store));
+    g_object_unref (G_OBJECT (list_store));
 
     renderer = gtk_cell_renderer_text_new ();
     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (theme_name_treeview),
@@ -485,7 +474,7 @@
         gtk_list_store_append (list_store, &iter);
         gtk_list_store_set (list_store, &iter, 0, _(template->name), 1, template->value, -1);
       }
-
+    g_object_unref (G_OBJECT (list_store));
     xfconf_channel_get_property (settings->priv->wm_channel, "/general/title_alignment", &value);
     xfwm_settings_title_alignment_property_changed (settings->priv->wm_channel,
                                                     "/general/title_alignment", &value, settings);
@@ -600,6 +589,7 @@
 
     list_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
     gtk_tree_view_set_model (GTK_TREE_VIEW (shortcuts_treeview), GTK_TREE_MODEL (list_store));
+    g_object_unref (G_OBJECT (list_store));
 
     renderer = gtk_cell_renderer_text_new ();
     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (shortcuts_treeview),
@@ -680,7 +670,7 @@
         gtk_list_store_append (list_store, &iter);
         gtk_list_store_set (list_store, &iter, 0, _(template->name), 1, template->value, -1);
       }
-
+    g_object_unref (G_OBJECT (list_store));
     xfconf_channel_get_property (settings->priv->wm_channel, "/general/double_click_action",
                                  &value);
     xfwm_settings_double_click_action_property_changed (settings->priv->wm_channel,
@@ -804,7 +794,6 @@
 }
 
 
-
 static gint
 xfwm_settings_theme_sort_func (GtkTreeModel *model,
                                GtkTreeIter  *iter1,
@@ -837,8 +826,6 @@
   GtkTreeIter   iter;
   GtkWidget    *view;
   GHashTable   *themes;
-  GList        *keys;
-  GList        *key;
   GDir         *dir;
   const gchar  *file;
   gchar       **theme_dirs;
@@ -854,6 +841,8 @@
   xfce_resource_push_path (XFCE_RESOURCE_THEMES, DATADIR G_DIR_SEPARATOR_S "themes");
   theme_dirs = xfce_resource_dirs (XFCE_RESOURCE_THEMES);
   xfce_resource_pop_path (XFCE_RESOURCE_THEMES);
+  
+  active_theme_name = xfconf_channel_get_string (settings->priv->wm_channel, "/general/theme", DEFAULT_THEME);
 
   for (i = 0; theme_dirs[i] != NULL; ++i)
     {
@@ -866,10 +855,24 @@
         {
           filename = g_build_filename (theme_dirs[i], file, "xfwm4", "themerc", NULL);
 
+          /* check if the theme rc exists and there is not already a theme with the
+           * same name in the database */
           if (g_file_test (filename, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR) &&
               g_hash_table_lookup (themes, file) == NULL)
             {
               g_hash_table_insert (themes, g_strdup (file), GINT_TO_POINTER (1));
+
+              /* insert in the list store */
+              gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+              gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
+                                  COL_THEME_NAME, file,
+                                  COL_THEME_RC, filename, -1);
+                                  
+              if (G_UNLIKELY (g_str_equal (active_theme_name, file)))
+                {
+                  gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
+                                                  &iter);
+                }
             }
 
           g_free (filename);
@@ -878,31 +881,9 @@
       g_dir_close (dir);
     }
 
-  active_theme_name = xfconf_channel_get_string (settings->priv->wm_channel, "/general/theme", DEFAULT_THEME);
-
-  keys = NULL;
-#if !GLIB_CHECK_VERSION (2,14,0)
-  g_hash_table_foreach (themes, xfwm4_settings_get_list_keys_foreach, &keys);
-#else
-  keys = g_hash_table_get_keys (themes);
-#endif
-
-  for (key = keys; key != NULL; key = g_list_next (key))
-    {
-      gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-      gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, g_strdup (key->data), -1);
-
-      if (G_UNLIKELY (g_str_equal (active_theme_name, key->data)))
-        {
-          gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
-                                          &iter);
-        }
-    }
-
-  g_list_free (keys);
   g_free (active_theme_name);
-  g_hash_table_unref (themes);
   g_strfreev (theme_dirs);
+  g_hash_table_destroy (themes);
 }
 
 
@@ -1018,22 +999,40 @@
 {
   GtkTreeModel *model;
   GtkTreeIter   iter;
-  GList        *rows;
-  gchar        *theme;
+  gchar        *theme, *filename;
+  XfceRc       *rc;
+  GtkWidget    *widget;
+  gboolean      button_layout = FALSE;
+  gboolean      title_alignment = FALSE;
 
-  rows = gtk_tree_selection_get_selected_rows (selection, &model);
-
-  if (G_UNLIKELY (g_list_length (rows) == 0))
-    return;
-
-  gtk_tree_model_get_iter (model, &iter, rows->data);
-  gtk_tree_model_get (model, &iter, 0, &theme, -1);
-
-  xfconf_channel_set_string (settings->priv->wm_channel, "/general/theme", theme);
-
-  g_free (theme);
-  g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
-  g_list_free (rows);
+  if (gtk_tree_selection_get_selected (selection, &model, &iter))
+    {
+      gtk_tree_model_get (model, &iter,
+                          COL_THEME_NAME, &theme, 
+                          COL_THEME_RC, &filename, -1);
+                          
+      /* set the theme name */
+      xfconf_channel_set_string (settings->priv->wm_channel, "/general/theme", theme);
+      g_free (theme);
+      
+      /* check in the rc if the theme supports a custom button layout and/or
+       * title alignement */
+      rc = xfce_rc_simple_open (filename, TRUE);
+      g_free (filename);
+      
+      if (G_LIKELY (rc != NULL))
+        {
+          button_layout = !xfce_rc_has_entry (rc, "button_layout");
+          title_alignment = !xfce_rc_has_entry (rc, "title_alignment");
+          xfce_rc_close (rc);
+        }
+    }
+    
+  widget = glade_xml_get_widget (settings->priv->glade_xml, "button_layout_box");
+  gtk_widget_set_sensitive (widget, button_layout);
+  
+  widget = glade_xml_get_widget (settings->priv->glade_xml, "title_align_box");
+  gtk_widget_set_sensitive (widget, title_alignment);
 }
 
 
@@ -1312,7 +1311,7 @@
 {
   gtk_widget_hide (widget);
   gtk_selection_data_set (data, gdk_atom_intern ("_xfwm4_button_layout", FALSE), 8, 
-                          gtk_widget_get_name (widget), 
+                          (const guchar *)gtk_widget_get_name (widget), 
                           strlen (gtk_widget_get_name (widget)));
 }
 




More information about the Xfce4-commits mailing list