[Xfce4-commits] <xfce4-settings:stephan/dialogs> Hide wm-theme tab when xfwm4 is not running
Stephan Arts
noreply at xfce.org
Tue Mar 27 19:20:01 CEST 2012
Updating branch refs/heads/stephan/dialogs
to 0415184000dd825eaa0ff88854899843915bf8f2 (commit)
from 81ff93c572655a54a9083f6ba944e5fc46b72c65 (commit)
commit 0415184000dd825eaa0ff88854899843915bf8f2
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Mar 27 19:18:50 2012 +0200
Hide wm-theme tab when xfwm4 is not running
.../appearance-settings/appearance-dialog.glade | 2 +-
dialogs/appearance-settings/main.c | 232 ++++++++++---------
2 files changed, 123 insertions(+), 111 deletions(-)
diff --git a/dialogs/appearance-settings/appearance-dialog.glade b/dialogs/appearance-settings/appearance-dialog.glade
index 20582fa..954981e 100644
--- a/dialogs/appearance-settings/appearance-dialog.glade
+++ b/dialogs/appearance-settings/appearance-dialog.glade
@@ -104,7 +104,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox7">
+ <object class="GtkHBox" id="xfwm4_theme_hbox">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="spacing">12</property>
diff --git a/dialogs/appearance-settings/main.c b/dialogs/appearance-settings/main.c
index 777ab37..08fefd0 100644
--- a/dialogs/appearance-settings/main.c
+++ b/dialogs/appearance-settings/main.c
@@ -33,6 +33,7 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4util/libxfce4util.h>
@@ -41,6 +42,7 @@
#include "appearance-dialog_ui.h"
#include "images.h"
+#define XFWM4_WM_NAME "Xfwm4"
#define XFWM4_DEFAULT_THEME "Default"
#define INCH_MM 25.4
@@ -1175,141 +1177,151 @@ appearance_settings_dialog_configure_widgets (GtkBuilder *builder)
const gchar *name;
/* xfwm4 themes */
- object = gtk_builder_get_object (builder, "xfwm4_theme_treeview");
-
- list_store = gtk_list_store_new (N_XFWM4_THEME_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), XFWM4_THEME_COLUMN_NAME, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (list_store));
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (object), 0, "", renderer, "text", XFWM4_THEME_COLUMN_NAME, NULL);
+ if (strcmp(XFWM4_WM_NAME, gdk_x11_screen_get_window_manager_name (
+gdk_screen_get_default ())))
+ {
+ g_debug ("xfwm4 not running, wm: %s", gdk_x11_screen_get_window_manager_name ( gdk_screen_get_default ()));
+ object = gtk_builder_get_object (builder, "xfwm4_theme_hbox");
+ gtk_widget_destroy (GTK_WIDGET (object));
+ }
+ else
+ {
+ object = gtk_builder_get_object (builder, "xfwm4_theme_treeview");
- appearance_settings_load_xfwm4_themes (list_store, GTK_TREE_VIEW (object));
+ list_store = gtk_list_store_new (N_XFWM4_THEME_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), XFWM4_THEME_COLUMN_NAME, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (list_store));
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (object), 0, "", renderer, "text", XFWM4_THEME_COLUMN_NAME, NULL);
- g_object_unref (G_OBJECT (list_store));
+ appearance_settings_load_xfwm4_themes (list_store, GTK_TREE_VIEW (object));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_xfwm_theme_tree_selection_changed), builder);
+ g_object_unref (G_OBJECT (list_store));
- title_font_button = GTK_WIDGET (gtk_builder_get_object (builder, "title_font_button"));
- xfconf_g_property_bind (xfwm4_channel,
- "/general/title_font", G_TYPE_STRING,
- title_font_button, "font-name");
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_xfwm_theme_tree_selection_changed), builder);
- title_align_combo = GTK_WIDGET (gtk_builder_get_object (builder, "title_align_combo"));
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (title_align_combo));
+ title_font_button = GTK_WIDGET (gtk_builder_get_object (builder, "title_font_button"));
+ xfconf_g_property_bind (xfwm4_channel,
+ "/general/title_font", G_TYPE_STRING,
+ title_font_button, "font-name");
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (title_align_combo), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (title_align_combo), renderer, "text", 0);
+ title_align_combo = GTK_WIDGET (gtk_builder_get_object (builder, "title_align_combo"));
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (title_align_combo));
- list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- gtk_combo_box_set_model (GTK_COMBO_BOX (title_align_combo), GTK_TREE_MODEL (list_store));
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (title_align_combo), renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (title_align_combo), renderer, "text", 0);
- for (template = title_align_values; template->name != NULL; ++template)
- {
- 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));
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (title_align_combo), GTK_TREE_MODEL (list_store));
- xfconf_channel_get_property (xfwm4_channel, "/general/title_alignment", &value);
- appearance_settings_dialog_channel_property_changed (xfwm4_channel, "/general/title_alignment", &value, builder);
- g_value_unset (&value);
+ for (template = title_align_values; template->name != NULL; ++template)
+ {
+ 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));
- g_signal_connect (title_align_combo, "changed",
- G_CALLBACK (cb_xfwm_title_alignment_changed), NULL);
+ xfconf_channel_get_property (xfwm4_channel, "/general/title_alignment", &value);
+ appearance_settings_dialog_channel_property_changed (xfwm4_channel, "/general/title_alignment", &value, builder);
+ g_value_unset (&value);
- /* Style tab: button layout */
- {
+ g_signal_connect (title_align_combo, "changed",
+ G_CALLBACK (cb_xfwm_title_alignment_changed), NULL);
- active_frame = GTK_WIDGET (gtk_builder_get_object (builder, "active-frame"));
- hidden_frame = GTK_WIDGET (gtk_builder_get_object (builder, "hidden-frame"));
- active_box = GTK_WIDGET (gtk_builder_get_object (builder, "active-box"));
- hidden_box = GTK_WIDGET (gtk_builder_get_object (builder, "hidden-box"));
+ /* Style tab: button layout */
+ {
- target_entry[0].target = "_xfwm4_button_layout";
- target_entry[0].flags = 0;
- target_entry[0].info = 2;
+ active_frame = GTK_WIDGET (gtk_builder_get_object (builder, "active-frame"));
+ hidden_frame = GTK_WIDGET (gtk_builder_get_object (builder, "hidden-frame"));
+ active_box = GTK_WIDGET (gtk_builder_get_object (builder, "active-box"));
+ hidden_box = GTK_WIDGET (gtk_builder_get_object (builder, "hidden-box"));
- target_entry[1].target = "_xfwm4_active_layout";
- target_entry[1].flags = 0;
- target_entry[1].info = 3;
+ target_entry[0].target = "_xfwm4_button_layout";
+ target_entry[0].flags = 0;
+ target_entry[0].info = 2;
- gtk_drag_dest_set (active_frame, GTK_DEST_DEFAULT_ALL, target_entry, 2, GDK_ACTION_MOVE);
+ target_entry[1].target = "_xfwm4_active_layout";
+ target_entry[1].flags = 0;
+ target_entry[1].info = 3;
- g_signal_connect (active_frame, "drag-data-received",
- G_CALLBACK (xfwm_settings_active_frame_drag_data), builder);
-#if 0
- g_signal_connect (active_frame, "drag-motion",
- G_CALLBACK (xfwm_settings_active_frame_drag_motion), builder);
- g_signal_connect (active_frame, "drag-leave",
- G_CALLBACK (xfwm_settings_active_frame_drag_leave), builder);
-#endif
+ gtk_drag_dest_set (active_frame, GTK_DEST_DEFAULT_ALL, target_entry, 2, GDK_ACTION_MOVE);
- gtk_drag_dest_set (hidden_frame, GTK_DEST_DEFAULT_ALL, target_entry, 1, GDK_ACTION_MOVE);
+ g_signal_connect (active_frame, "drag-data-received",
+ G_CALLBACK (xfwm_settings_active_frame_drag_data), builder);
+ #if 0
+ g_signal_connect (active_frame, "drag-motion",
+ G_CALLBACK (xfwm_settings_active_frame_drag_motion), builder);
+ g_signal_connect (active_frame, "drag-leave",
+ G_CALLBACK (xfwm_settings_active_frame_drag_leave), builder);
+ #endif
- g_signal_connect (hidden_frame, "drag-data-received",
- G_CALLBACK (xfwm_settings_hidden_frame_drag_data), builder);
+ gtk_drag_dest_set (hidden_frame, GTK_DEST_DEFAULT_ALL, target_entry, 1, GDK_ACTION_MOVE);
- children = gtk_container_get_children (GTK_CONTAINER (active_box));
- for (list_iter = children; list_iter != NULL; list_iter = g_list_next (list_iter))
- {
- object = list_iter->data;
- name = gtk_buildable_get_name (GTK_BUILDABLE (object));
+ g_signal_connect (hidden_frame, "drag-data-received",
+ G_CALLBACK (xfwm_settings_hidden_frame_drag_data), builder);
- if (name[strlen (name) - 1] == '|')
+ children = gtk_container_get_children (GTK_CONTAINER (active_box));
+ for (list_iter = children; list_iter != NULL; list_iter = g_list_next (list_iter))
{
- g_signal_connect (title_align_combo, "changed",
- G_CALLBACK (cb_xfwm_title_button_alignment_changed), object);
- cb_xfwm_title_button_alignment_changed (GTK_COMBO_BOX (title_align_combo),
- GTK_WIDGET (object));
+ object = list_iter->data;
+ name = gtk_buildable_get_name (GTK_BUILDABLE (object));
+
+ if (name[strlen (name) - 1] == '|')
+ {
+ g_signal_connect (title_align_combo, "changed",
+ G_CALLBACK (cb_xfwm_title_button_alignment_changed), object);
+ cb_xfwm_title_button_alignment_changed (GTK_COMBO_BOX (title_align_combo),
+ GTK_WIDGET (object));
+ }
+
+ g_object_set_data (object, "key_char", (gpointer) &name[strlen (name) - 1]);
+ gtk_drag_source_set (GTK_WIDGET(object), GDK_BUTTON1_MASK, &target_entry[1], 1, GDK_ACTION_MOVE);
+
+ g_signal_connect (object, "drag_data_get",
+ G_CALLBACK (cb_xfwm_title_button_drag_data), NULL);
+ g_signal_connect (object, "drag_begin", G_CALLBACK (cb_xfwm_title_button_drag_begin),
+ NULL);
+ g_signal_connect (object, "drag_end", G_CALLBACK (cb_xfwm_title_button_drag_end),
+ NULL);
+ g_signal_connect (object, "button_press_event",
+ G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ g_signal_connect (object, "enter_notify_event",
+ G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ g_signal_connect (object, "focus", G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
}
+ g_list_free (children);
- g_object_set_data (object, "key_char", (gpointer) &name[strlen (name) - 1]);
- gtk_drag_source_set (GTK_WIDGET(object), GDK_BUTTON1_MASK, &target_entry[1], 1, GDK_ACTION_MOVE);
-
- g_signal_connect (object, "drag_data_get",
- G_CALLBACK (cb_xfwm_title_button_drag_data), NULL);
- g_signal_connect (object, "drag_begin", G_CALLBACK (cb_xfwm_title_button_drag_begin),
- NULL);
- g_signal_connect (object, "drag_end", G_CALLBACK (cb_xfwm_title_button_drag_end),
- NULL);
- g_signal_connect (object, "button_press_event",
- G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
- g_signal_connect (object, "enter_notify_event",
- G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
- g_signal_connect (object, "focus", G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
- }
- g_list_free (children);
+ children = gtk_container_get_children (GTK_CONTAINER (hidden_box));
+ for (list_iter = children; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ object = list_iter->data;
+ name = gtk_buildable_get_name (GTK_BUILDABLE (object));
+
+ g_object_set_data (object, "key_char", (gpointer) &name[strlen (name) - 1]);
+ gtk_drag_source_set (GTK_WIDGET (object), GDK_BUTTON1_MASK, &target_entry[0], 1, GDK_ACTION_MOVE);
+
+ g_signal_connect (object, "drag_data_get",
+ G_CALLBACK (cb_xfwm_title_button_drag_data), NULL);
+ g_signal_connect (object, "drag_begin", G_CALLBACK (cb_xfwm_title_button_drag_begin),
+ NULL);
+ g_signal_connect (object, "drag_end", G_CALLBACK (cb_xfwm_title_button_drag_end),
+ NULL);
+ g_signal_connect (object, "button_press_event",
+ G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ g_signal_connect (object, "enter_notify_event",
+ G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ g_signal_connect (object, "focus", G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ }
+ g_list_free (children);
- children = gtk_container_get_children (GTK_CONTAINER (hidden_box));
- for (list_iter = children; list_iter != NULL; list_iter = g_list_next (list_iter))
- {
- object = list_iter->data;
- name = gtk_buildable_get_name (GTK_BUILDABLE (object));
-
- g_object_set_data (object, "key_char", (gpointer) &name[strlen (name) - 1]);
- gtk_drag_source_set (GTK_WIDGET (object), GDK_BUTTON1_MASK, &target_entry[0], 1, GDK_ACTION_MOVE);
-
- g_signal_connect (object, "drag_data_get",
- G_CALLBACK (cb_xfwm_title_button_drag_data), NULL);
- g_signal_connect (object, "drag_begin", G_CALLBACK (cb_xfwm_title_button_drag_begin),
- NULL);
- g_signal_connect (object, "drag_end", G_CALLBACK (cb_xfwm_title_button_drag_end),
- NULL);
- g_signal_connect (object, "button_press_event",
- G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
- g_signal_connect (object, "enter_notify_event",
- G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
- g_signal_connect (object, "focus", G_CALLBACK (cb_appearance_settings_signal_blocker), NULL);
+ xfconf_channel_get_property (xfwm4_channel, "/general/button_layout", &value);
+ appearance_settings_dialog_channel_property_changed(xfwm4_channel,
+ "/general/button_layout", &value, builder);
+ g_value_unset (&value);
}
- g_list_free (children);
-
- xfconf_channel_get_property (xfwm4_channel, "/general/button_layout", &value);
- appearance_settings_dialog_channel_property_changed(xfwm4_channel,
- "/general/button_layout", &value, builder);
- g_value_unset (&value);
}
/* Icon themes list */
More information about the Xfce4-commits
mailing list