[Xfce4-commits] <xfce4-settings:master> Rework settings editor.
Nick Schermer
noreply at xfce.org
Sun Feb 5 14:38:01 CET 2012
Updating branch refs/heads/master
to 2e0bf850a344a43efd3728dff70454895acf3b8e (commit)
from b66f3b95c820dace59310b1e05fd078698e940c2 (commit)
commit 2e0bf850a344a43efd3728dff70454895acf3b8e
Author: Nick Schermer <nick at xfce.org>
Date: Sat Jan 28 21:55:33 2012 +0100
Rework settings editor.
- Update the model when a property changes.
- Only limited UI, so but it directly in the code, no glade.
- Add property monitoring in separate window.
- Channel refresh from interface.
- You can edit a number of property types in the treeview.
- Display property arrays, you can't edit them.
po/POTFILES.in | 5 +-
xfce4-settings-editor/Makefile.am | 50 +-
xfce4-settings-editor/main.c | 18 +-
xfce4-settings-editor/main_window.c | 1105 ----------------
xfce4-settings-editor/main_window.h | 21 -
.../xfce-settings-cell-renderer.c | 637 +++++++++
.../xfce-settings-cell-renderer.h | 45 +
.../xfce-settings-editor-dialog.c | 1385 ++++++++++++++++++++
.../xfce-settings-editor-dialog.h | 46 +
xfce4-settings-editor/xfce-settings-marshal.list | 1 +
xfce4-settings-editor/xfce-settings-prop-dialog.c | 690 ++++++++++
xfce4-settings-editor/xfce-settings-prop-dialog.h | 49 +
xfce4-settings-editor/xfce4-settings-editor.glade | 407 ------
13 files changed, 2894 insertions(+), 1565 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d24819d..14bf032 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -30,9 +30,10 @@ dialogs/mouse-settings/mouse-dialog.glade
dialogs/mouse-settings/xfce-mouse-settings.desktop.in
xfce4-settings-editor/main.c
-xfce4-settings-editor/main_window.c
+xfce4-settings-editor/xfce-settings-cell-renderer.c
+xfce4-settings-editor/xfce-settings-editor-dialog.c
+xfce4-settings-editor/xfce-settings-prop-dialog.c
xfce4-settings-editor/xfce4-settings-editor.desktop.in
-xfce4-settings-editor/xfce4-settings-editor.glade
xfsettingsd/accessibility.c
xfsettingsd/keyboard-layout.c
diff --git a/xfce4-settings-editor/Makefile.am b/xfce4-settings-editor/Makefile.am
index c6c9a2d..fd272d1 100644
--- a/xfce4-settings-editor/Makefile.am
+++ b/xfce4-settings-editor/Makefile.am
@@ -1,9 +1,6 @@
-# $Id: Makefile.am 27279 2008-07-13 19:24:20Z nick $
INCLUDES = \
-I${top_srcdir} \
- -DDATADIR=\"$(datadir)\" \
- -DSRCDIR=\"$(top_srcdir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DG_LOG_DOMAIN=\"xfce4-settings-editor\" \
$(PLATFORM_CPPFLAGS)
@@ -11,17 +8,25 @@ INCLUDES = \
bin_PROGRAMS = \
xfce4-settings-editor
+xfce4_settings_editor_built_sources = \
+ xfce-settings-marshal.c \
+ xfce-settings-marshal.h
+
xfce4_settings_editor_SOURCES = \
+ $(xfce4_settings_editor_built_sources) \
main.c \
- main_window.c main_window.h \
- xfce4-settings-editor_ui.h
+ xfce-settings-cell-renderer.c \
+ xfce-settings-cell-renderer.h \
+ xfce-settings-editor-dialog.c \
+ xfce-settings-editor-dialog.h \
+ xfce-settings-prop-dialog.c \
+ xfce-settings-prop-dialog.h
xfce4_settings_editor_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(XFCONF_CFLAGS) \
- $(EXO_CFLAGS) \
$(PLATFORM_CFLAGS)
xfce4_settings_editor_LDFLAGS = \
@@ -32,8 +37,7 @@ xfce4_settings_editor_LDADD = \
$(GTK_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCE4UI_LIBS) \
- $(XFCONF_LIBS) \
- $(EXO_LIBS)
+ $(XFCONF_LIBS)
desktopdir = $(datadir)/applications
desktop_in_files = xfce4-settings-editor.desktop.in
@@ -41,21 +45,31 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-EXTRA_DIST = \
- $(desktop_in_files) \
- xfce4-settings-editor.glade
+#
+# Build sources
+#
+if MAINTAINER_MODE
-DISTCLEANFILES = \
- $(desktop_DATA)
+xfce-settings-marshal.h: xfce-settings-marshal.list Makefile
+ $(AM_V_GEN) glib-genmarshal --prefix=_xfce_settings_marshal --internal --header $< > $@
-if MAINTAINER_MODE
+xfce-settings-marshal.c: xfce-settings-marshal.list Makefile
+ $(AM_V_GEN) echo "#include \"xfce-settings-marshal.h\"" > $@ \
+ && glib-genmarshal --prefix=_xfce_settings_marshal --body $< >> $@
-BUILT_SOURCES = \
- xfce4-settings-editor_ui.h
+DISTCLEANFILES = \
+ $(xfce4_settings_editor_built_sources)
-xfce4-settings-editor_ui.h: xfce4-settings-editor.glade
- exo-csource --static --strip-comments --strip-content --name=xfce4_settings_editor_ui $< >$@
+BUILT_SOURCES = \
+ $(xfce4_settings_editor_built_sources)
endif
+EXTRA_DIST = \
+ xfce-settings-marshal.list \
+ $(desktop_in_files)
+
+DISTCLEANFILES = \
+ $(desktop_DATA)
+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/xfce4-settings-editor/main.c b/xfce4-settings-editor/main.c
index cda9cde..296fd39 100644
--- a/xfce4-settings-editor/main.c
+++ b/xfce4-settings-editor/main.c
@@ -33,7 +33,7 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
-#include "main_window.h"
+#include "xfce-settings-editor-dialog.h"
/* option entries */
static gboolean opt_version = FALSE;
@@ -47,8 +47,8 @@ static GOptionEntry option_entries[] =
gint
main(gint argc, gchar **argv)
{
- GtkDialog *dialog;
- GError *error = NULL;
+ GtkWidget *dialog;
+ GError *error = NULL;
/* setup translation domain */
xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
@@ -96,16 +96,10 @@ main(gint argc, gchar **argv)
return EXIT_FAILURE;
}
- /* We don't want a gradient on our toolbar */
- gtk_rc_parse_string ("style \"xfce-no-shadow\"\n"
- "{\n"
- "GtkToolbar::shadow-type = GTK_SHADOW_NONE\n"
- "}\n"
- "class \"*\" style \"xfce-no-shadow\"\n");
+ dialog = xfce_settings_editor_dialog_new ();
+ gtk_window_present (GTK_WINDOW (dialog));
- dialog = xfce4_settings_editor_main_window_new();
-
- gtk_dialog_run (dialog);
+ gtk_main ();
/* shutdown xfconf */
xfconf_shutdown ();
diff --git a/xfce4-settings-editor/main_window.c b/xfce4-settings-editor/main_window.c
deleted file mode 100644
index 144c979..0000000
--- a/xfce4-settings-editor/main_window.c
+++ /dev/null
@@ -1,1105 +0,0 @@
-/*
- * Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
- * Copyright (c) 2009-2010 Jérôme Guelfucci <jeromeg at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <xfconf/xfconf.h>
-#include <libxfce4util/libxfce4util.h>
-#include <libxfce4ui/libxfce4ui.h>
-
-#include "xfce4-settings-editor_ui.h"
-#include "main_window.h"
-
-#define WINDOW_WIDTH 600
-#define WINDOW_HEIGHT 380
-#define HPANED_POSITION 200
-
-static XfconfChannel *current_channel = NULL;
-static gchar *current_property = NULL;
-
-enum {
- PROP_TYPE_EMPTY,
- PROP_TYPE_STRING,
- PROP_TYPE_INT,
- PROP_TYPE_UINT,
- PROP_TYPE_INT64,
- PROP_TYPE_UINT64,
- PROP_TYPE_DOUBLE,
- PROP_TYPE_BOOLEAN,
- PROP_TYPE_ARRAY /* Not used yet */
-};
-
-static void
-load_channels (GtkListStore *store, GtkTreeView *treeview);
-static void
-update_iter (gboolean empty, XfconfChannel *channel, gchar *key, GtkTreeStore *store, GtkTreeIter *child_iter);
-static void
-load_properties (XfconfChannel *channel, GtkTreeStore *store, GtkTreeView *treeview);
-
-static void
-cb_channel_treeview_selection_changed (GtkTreeSelection *selection, GtkBuilder *builder);
-static void
-cb_property_treeview_selection_changed (GtkTreeSelection *selection, GtkBuilder *builder);
-static void
-cb_property_treeview_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, GtkBuilder *builder);
-static gboolean
-cb_property_treeview_key_pressed (GtkWidget *widget, GdkEventKey *event, GtkBuilder *builder);
-static void
-cb_property_new_button_clicked (GtkButton *button, GtkBuilder *builder);
-static void
-cb_property_edit_button_clicked (GtkButton *button, GtkBuilder *builder);
-static void
-cb_property_revert_button_clicked (GtkButton *button, GtkBuilder *builder);
-static void
-cb_settings_editor_dialog_response (GtkWidget *dialog, gint response, GtkBuilder *builder);
-static void
-cb_channel_property_changed (XfconfChannel *channel, gchar *property, GValue *value, GtkBuilder *builder);
-static gboolean
-xfconf_property_is_valid(const gchar *property, GError **error);
-static void
-channel_treeview_popup_menu (GtkWidget *widget, GdkEventButton *event, GtkBuilder *builder);
-static gboolean
-cb_channel_treeview_button_press_event (GtkWidget *widget, GdkEventButton *event, GtkBuilder *builder);
-static gboolean
-cb_channel_treeview_popup_menu (GtkWidget *widget, GtkBuilder *builder);
-static void
-cb_channel_popup_menu_remove_item_activate (GtkMenuItem *item, GtkBuilder *builder);
-static void
-print_list (gpointer data, gpointer user_data);
-
-
-GtkDialog *
-xfce4_settings_editor_main_window_new(void)
-{
- gint width, height, position, i;
- GObject *dialog;
- GObject *channel_treeview;
- GObject *property_treeview;
- GObject *hpaned;
- XfconfChannel *channel;
- GtkBuilder *builder = NULL;
- GtkListStore *channel_list_store;
- GtkTreeStore *property_tree_store;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- GObject *property_edit_button, *property_new_button, *property_revert_button;
-
- /* hook to make sure the libxfce4ui library is linked */
- if (xfce_titled_dialog_get_type () == 0)
- return NULL;
-
- builder = gtk_builder_new ();
- gtk_builder_add_from_string (builder, xfce4_settings_editor_ui, xfce4_settings_editor_ui_length, NULL);
-
- dialog = gtk_builder_get_object (builder, "main_dialog");
- g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
-
- gtk_widget_add_events (GTK_WIDGET (dialog), GDK_KEY_PRESS_MASK);
-
- hpaned = gtk_builder_get_object (builder, "hpaned2");
-
- /* Set the default size of the window */
- channel = xfconf_channel_get ("xfce4-settings-editor");
- width = xfconf_channel_get_int (channel, "/window-width", WINDOW_WIDTH);
- height = xfconf_channel_get_int (channel, "/window-height", WINDOW_HEIGHT);
- position = xfconf_channel_get_int (channel, "/hpaned-position", HPANED_POSITION);
- gtk_window_set_default_size (GTK_WINDOW (dialog), width, height);
- gtk_paned_set_position (GTK_PANED (hpaned), position);
-
- g_signal_connect (dialog, "response", G_CALLBACK (cb_settings_editor_dialog_response), builder);
-
- channel_treeview = gtk_builder_get_object (builder, "channel_treeview");
- property_treeview = gtk_builder_get_object (builder, "property_treeview");
-
- property_edit_button = gtk_builder_get_object (builder, "property_edit_button");
- property_new_button = gtk_builder_get_object (builder, "property_new_button");
- property_revert_button = gtk_builder_get_object (builder, "property_revert_button");
-
- gtk_widget_set_sensitive (GTK_WIDGET (property_edit_button), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (property_revert_button), FALSE);
-
- /*
- * Channel List
- */
- channel_list_store = gtk_list_store_new (1, G_TYPE_STRING);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (channel_treeview), GTK_TREE_MODEL (channel_list_store));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (channel_treeview), 1, _("Channel"), renderer, "text", 0, NULL);
-
- /* Set sorting */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (channel_list_store), 0, GTK_SORT_ASCENDING);
-
- /*
- * property list
- */
- property_tree_store = gtk_tree_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (property_treeview), GTK_TREE_MODEL (property_tree_store));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (property_treeview), 0, _("Property"), renderer, "text", 0, NULL);
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (property_treeview), 1, _("Type"), renderer, "text", 1, NULL);
-
- renderer = gtk_cell_renderer_toggle_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (property_treeview), 2, _("Locked"), renderer, "active", 2, NULL);
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (property_treeview), 3, _("Value"), renderer, "text", 3, NULL);
-
- /* Allow the user to sort the column items by clicking on headers */
- for (i = 0; i < 4; i++)
- gtk_tree_view_column_set_sort_column_id (gtk_tree_view_get_column (GTK_TREE_VIEW (property_treeview), i), i);
-
- /* Allow the user to resize the columns */
- gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (GTK_TREE_VIEW (property_treeview), 0), TRUE);
- gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (GTK_TREE_VIEW (property_treeview), 1), TRUE);
- gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (GTK_TREE_VIEW (property_treeview), 2), TRUE);
- gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (GTK_TREE_VIEW (property_treeview), 3), TRUE);
-
- /* Set sorting */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (property_tree_store), 0, GTK_SORT_ASCENDING);
-
- /* improve usability by expanding nodes when clicking on them */
- g_signal_connect (G_OBJECT (property_treeview), "row-activated", G_CALLBACK (cb_property_treeview_row_activated), builder);
-
- /* Set a handler for key-press-event */
- g_signal_connect (G_OBJECT (property_treeview), "key-press-event", G_CALLBACK (cb_property_treeview_key_pressed), builder);
-
- /* selection handling */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (channel_treeview));
- g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_channel_treeview_selection_changed), builder);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (property_treeview));
- g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_property_treeview_selection_changed), builder);
-
- /* Connect signal-handlers for the popup-menu and button-press-event events */
- g_signal_connect (G_OBJECT (channel_treeview), "popup-menu", G_CALLBACK (cb_channel_treeview_popup_menu), builder);
- g_signal_connect (G_OBJECT (channel_treeview), "button-press-event", G_CALLBACK (cb_channel_treeview_button_press_event), builder);
-
- /* Connect signal-handlers to toolbar buttons */
- g_signal_connect (G_OBJECT (property_new_button), "clicked", G_CALLBACK (cb_property_new_button_clicked), builder);
- g_signal_connect (G_OBJECT (property_edit_button), "clicked", G_CALLBACK (cb_property_edit_button_clicked), builder);
- g_signal_connect (G_OBJECT (property_revert_button), "clicked", G_CALLBACK (cb_property_revert_button_clicked), builder);
-
- load_channels (channel_list_store, GTK_TREE_VIEW (channel_treeview));
-
- return GTK_DIALOG (dialog);
-}
-
-/**
- * load_channels
- *
- * get the available channels from xfconf and put them in the treemodel
- */
-static void
-load_channels (GtkListStore *store, GtkTreeView *treeview)
-{
- GtkTreeIter iter;
- gchar **channel_names;
- guint i;
- GtkTreeSelection *selection;
-
- channel_names = xfconf_list_channels();
- if (channel_names != NULL)
- {
- for (i = 0; channel_names[i] != NULL; i++)
- {
- gtk_list_store_insert_with_values (store, NULL, i,
- 0, channel_names[i], -1);
- }
-
- g_strfreev (channel_names);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
- gtk_tree_selection_select_iter (selection, &iter);
- }
-}
-
-static void print_list (gpointer data, gpointer user_data)
-{
- TRACE ("%s", (gchar *) data);
-}
-
-static void update_iter (gboolean not_empty, XfconfChannel *channel, gchar *key, GtkTreeStore *store, GtkTreeIter *child_iter)
-{
- GValue child_locked = {0, };
- GValue child_type = {0, };
- GValue child_value = {0, };
-
- g_value_init (&child_locked, G_TYPE_BOOLEAN);
- g_value_init (&child_type, G_TYPE_STRING);
- g_value_init (&child_value, G_TYPE_STRING);
-
- if (not_empty)
- {
- GValue property_value = {0, };
-
- xfconf_channel_get_property (channel, key, &property_value);
-
- switch (G_VALUE_TYPE(&property_value))
- {
- case G_TYPE_INT:
- g_value_set_string (&child_type, "Int");
- g_value_transform (&property_value, &child_value);
- break;
- case G_TYPE_UINT:
- g_value_set_string (&child_type, "Unsigned Int");
- g_value_transform (&property_value, &child_value);
- break;
- case G_TYPE_INT64:
- g_value_set_string (&child_type, "Int64");
- g_value_transform (&property_value, &child_value);
- break;
- case G_TYPE_UINT64:
- g_value_set_string (&child_type, "Unsigned Int64");
- g_value_transform (&property_value, &child_value);
- break;
- case G_TYPE_DOUBLE:
- g_value_set_string (&child_type, "Double");
- g_value_transform (&property_value, &child_value);
- break;
- case G_TYPE_STRING:
- g_value_set_string (&child_type, "String");
- g_value_copy (&property_value, &child_value);
- break;
- case G_TYPE_BOOLEAN:
- g_value_set_string (&child_type, "Bool");
- g_value_transform (&property_value, &child_value);
- break;
- default:
- g_value_set_string (&child_type, g_type_name (G_VALUE_TYPE(&property_value)));
- break;
- }
-
- g_value_unset (&property_value);
- }
- else
- g_value_set_string (&child_type, _("Empty"));
-
- gtk_tree_store_set_value (store, child_iter, 1, &child_type);
- g_value_unset (&child_type);
-
- g_value_set_boolean (&child_locked, xfconf_channel_is_property_locked (channel, key));
- gtk_tree_store_set_value (store, child_iter, 2, &child_locked);
- g_value_unset (&child_locked);
-
- gtk_tree_store_set_value (store, child_iter, 3, &child_value);
- g_value_unset (&child_value);
-}
-
-/**
- * load_properties
- *
- * get the available properties from xfconf and put them in the treemodel
- */
-static void
-load_properties (XfconfChannel *channel, GtkTreeStore *store, GtkTreeView *treeview)
-{
- gint i = 0;
- gchar *key;
- GList *keys, *_keys;
- GtkTreeIter parent_iter;
- GtkTreeIter child_iter;
- GValue parent_val = {0,};
-
- GValue child_name = {0,};
-
- GHashTable *hash_table;
- gchar **components;
-
- g_value_init (&child_name, G_TYPE_STRING);
-
- hash_table = xfconf_channel_get_properties (channel, NULL);
-
- if (hash_table != NULL)
- {
- keys = g_hash_table_get_keys (hash_table);
- g_list_foreach (keys, (GFunc) print_list, NULL);
- for(_keys = keys; _keys != NULL; _keys = g_list_next (_keys))
- {
- key = _keys->data;
- TRACE ("Key: %s", key);
- components = g_strsplit (key, "/", 0);
-
- /* components[0] will be empty because properties start with '/'*/
- for (i = 1; components[i]; ++i)
- {
- TRACE ("Component: %s", components[i]);
-
- /* Check if this parent has children */
- if (gtk_tree_model_iter_children (GTK_TREE_MODEL (store), &child_iter, i==1?NULL:&parent_iter))
- {
- TRACE ("Parent has children");
-
- while (1)
- {
- /* Check if the component already exists, if so, return this child */
- gtk_tree_model_get_value (GTK_TREE_MODEL(store), &child_iter, 0, &parent_val);
- if (!g_strcmp0 (components[i], g_value_get_string (&parent_val)))
- {
- GValue current_parent_value = {0, };
-
- TRACE ("Component already exists");
- g_value_unset (&parent_val);
-
- gtk_tree_model_get_value (GTK_TREE_MODEL(store), &child_iter, 3, ¤t_parent_value);
-
- if (!g_value_get_string (¤t_parent_value))
- update_iter (!components[i+1], channel, key, store, &child_iter);
-
- g_value_unset (¤t_parent_value);
-
- break;
- }
- else
- g_value_unset (&parent_val);
-
- /* If we are at the end of the list of children, the required child is not available and should be created */
- if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &child_iter))
- {
- TRACE ("Create the children");
- gtk_tree_store_append (store, &child_iter, i==1?NULL:&parent_iter);
- g_value_set_string (&child_name, components[i]);
- gtk_tree_store_set_value (store, &child_iter, 0, &child_name);
- g_value_reset (&child_name);
-
- update_iter (!components[i+1], channel, key, store, &child_iter);
-
- break;
- }
- }
- }
- else
- {
- /* If the parent does not have any children, create this one */
- TRACE ("Parent has no children");
- gtk_tree_store_append (store, &child_iter, i==1?NULL:&parent_iter);
- g_value_set_string (&child_name, components[i]);
- gtk_tree_store_set_value (store, &child_iter, 0, &child_name);
- g_value_reset (&child_name);
-
- update_iter (!components[i+1], channel, key, store, &child_iter);
- }
- parent_iter = child_iter;
- }
-
- g_strfreev (components);
-
- }
-
- g_list_free (keys);
- g_hash_table_destroy (hash_table);
- }
-}
-
-static void
-cb_property_treeview_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, GtkBuilder *builder)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (tree_view);
- gtk_tree_model_get_iter (model, &iter, path);
-
- if (gtk_tree_model_iter_has_child (model, &iter))
- {
- if (gtk_tree_view_row_expanded (tree_view, path))
- gtk_tree_view_collapse_row (tree_view, path);
- else
- gtk_tree_view_expand_row (tree_view, path, FALSE);
-
- }
- else
- cb_property_edit_button_clicked (NULL, builder);
-}
-
-static void
-cb_channel_treeview_selection_changed (GtkTreeSelection *selection, GtkBuilder *builder)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- XfconfChannel *channel;
- GObject *property_treeview;
- GObject *property_new_button;
- GtkTreeModel *tree_store = NULL;
- GValue value = {0, };
-
- property_new_button = gtk_builder_get_object (builder, "property_new_button");
-
- if (current_channel)
- {
- g_object_unref (G_OBJECT(current_channel));
- current_channel = NULL;
- }
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (property_new_button), FALSE);
- return;
- }
-
- gtk_widget_set_sensitive (GTK_WIDGET (property_new_button), TRUE);
-
- property_treeview = gtk_builder_get_object (builder, "property_treeview");
- tree_store = gtk_tree_view_get_model (GTK_TREE_VIEW (property_treeview));
-
- gtk_tree_model_get_value (model, &iter, 0, &value);
-
- g_return_if_fail (G_VALUE_HOLDS_STRING (&value));
-
- channel = xfconf_channel_new (g_value_get_string (&value));
-
- gtk_tree_store_clear (GTK_TREE_STORE(tree_store));
- load_properties (channel, GTK_TREE_STORE(tree_store), GTK_TREE_VIEW(property_treeview));
-
- current_channel = channel;
-
- g_signal_connect (channel, "property-changed", G_CALLBACK (cb_channel_property_changed), builder);
-}
-
-static gboolean
-cb_channel_treeview_button_press_event (GtkWidget *widget, GdkEventButton *event, GtkBuilder *builder)
-{
- if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
- channel_treeview_popup_menu (widget, event, builder);
-
- return FALSE;
-}
-
-static gboolean
-cb_channel_treeview_popup_menu (GtkWidget *widget, GtkBuilder *builder)
-{
- channel_treeview_popup_menu (widget, NULL, builder);
- return TRUE;
-}
-
-static void
-cb_property_treeview_selection_changed (GtkTreeSelection *selection, GtkBuilder *builder)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeIter p_iter;
- gboolean locked;
- GObject *property_edit_button;
- GObject *property_revert_button;
- GValue value = {0, };
- gchar *prop_name = NULL;
- const gchar *prop_type;
- gchar *temp = NULL;
-
- property_edit_button = gtk_builder_get_object (builder, "property_edit_button");
- property_revert_button = gtk_builder_get_object (builder, "property_revert_button");
-
- if (current_property)
- {
- g_free (prop_name);
- current_property = NULL;
- }
-
- /* return if no property is selected */
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (property_edit_button), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (property_revert_button), FALSE);
-
- return;
- }
-
- /* create the complete property-name */
- gtk_tree_model_get_value (model, &iter, 0, &value);
- prop_name = g_strconcat ("/", g_value_get_string(&value), NULL);
- g_value_unset (&value);
-
- /* to create the complete property-name, we need it's parents too */
- while (gtk_tree_model_iter_parent (model, &p_iter, &iter))
- {
- gtk_tree_model_get_value (model, &p_iter, 0, &value);
- temp = g_strconcat ("/", g_value_get_string(&value), prop_name, NULL);
- g_value_unset (&value);
-
- if (prop_name)
- g_free (prop_name);
- prop_name = temp;
-
- iter = p_iter;
- }
-
- current_property = prop_name;
-
- /* Set the state of the edit and reset buttons */
- locked = xfconf_channel_is_property_locked (current_channel, current_property);
-
- gtk_widget_set_sensitive (GTK_WIDGET (property_edit_button), !locked);
- gtk_widget_set_sensitive (GTK_WIDGET (property_revert_button), !locked);
-
- /* If type is Empty, we don't want the user to edit the property */
- gtk_tree_selection_get_selected (selection, &model, &iter);
- gtk_tree_model_get_value (model, &iter, 1, &value);
-
- prop_type = g_value_get_string (&value);
-
- if ((g_strcmp0 (prop_type, "Empty") == 0) || g_strcmp0 (prop_type, "GPtrArray_GValue_") == 0)
- gtk_widget_set_sensitive (GTK_WIDGET (property_edit_button), FALSE);
- g_value_unset (&value);
-}
-
-static gboolean
-cb_property_treeview_key_pressed (GtkWidget *widget, GdkEventKey *event, GtkBuilder *builder)
-{
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
-
- if (event->keyval == GDK_Delete && gtk_tree_selection_get_selected (selection, NULL, NULL))
- {
- cb_property_revert_button_clicked (NULL, builder);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-cb_type_combo_changed (GtkComboBox *widget, GtkBuilder *builder)
-{
- GObject *prop_value_text_entry = gtk_builder_get_object (builder, "property_value_text_entry");
- GObject *prop_value_spin_button = gtk_builder_get_object (builder, "property_value_spin_button");
- GObject *prop_value_sw = gtk_builder_get_object (builder, "property_value_sw");
- GObject *prop_value_checkbox = gtk_builder_get_object (builder, "property_value_checkbutton");
-
- switch (gtk_combo_box_get_active (widget))
- {
- case PROP_TYPE_STRING:
- gtk_widget_hide (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_show (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- break;
- case PROP_TYPE_INT:
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MININT, G_MAXINT);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- break;
- case PROP_TYPE_UINT:
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), 0, G_MAXINT);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- break;
- case PROP_TYPE_INT64:
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MININT64, G_MAXINT64);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- break;
- case PROP_TYPE_UINT64:
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), 0, G_MAXUINT64);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- break;
- case PROP_TYPE_DOUBLE:
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MINDOUBLE, G_MAXDOUBLE);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 2);
- break;
- case PROP_TYPE_BOOLEAN:
- gtk_widget_hide (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_show (GTK_WIDGET (prop_value_checkbox));
- break;
- default:
- return;
- break;
- }
-}
-
-static void
-cb_property_new_button_clicked (GtkButton *button, GtkBuilder *builder)
-{
- GObject *dialog = gtk_builder_get_object (builder, "edit_settings_dialog");
- GObject *prop_name_entry = gtk_builder_get_object (builder, "property_name_entry");
- GObject *prop_type_combo = gtk_builder_get_object (builder, "property_type_combo");
-
- GObject *prop_value_text_entry = gtk_builder_get_object (builder, "property_value_text_entry");
- GObject *prop_value_spin_button = gtk_builder_get_object (builder, "property_value_spin_button");
- GObject *prop_value_checkbox = gtk_builder_get_object (builder, "property_value_checkbutton");
-
- g_signal_connect (prop_type_combo, "changed", G_CALLBACK (cb_type_combo_changed), builder);
-
- /* Default to string properties */
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_STRING);
- gtk_widget_set_sensitive (GTK_WIDGET (prop_type_combo), TRUE);
-
- /* Reset all the value fields */
- gtk_entry_set_text (GTK_ENTRY (prop_name_entry), "");
- gtk_entry_set_text (GTK_ENTRY (prop_value_text_entry), "");
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop_value_checkbox), TRUE);
-
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_APPLY)
- {
- const gchar *prop_name = gtk_entry_get_text (GTK_ENTRY (prop_name_entry));
- GValue value = {0, };
- GError *error = NULL;
- GObject *property_treeview;
- GtkTreeModel *tree_store;
-
- gtk_widget_hide (GTK_WIDGET (dialog));
-
- if (!xfconf_property_is_valid (prop_name, &error))
- {
- GObject *main_window = gtk_builder_get_object (builder, "main_dialog");
-
- xfce_dialog_show_error (GTK_WINDOW (main_window), error, _("This property name is not valid."));
-
- g_error_free (error);
- return;
- }
-
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (prop_type_combo)))
- {
- case PROP_TYPE_EMPTY:
- break;
- case PROP_TYPE_STRING:
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, gtk_entry_get_text (GTK_ENTRY (prop_value_text_entry)));
- break;
- case PROP_TYPE_INT:
- g_value_init (&value, G_TYPE_INT);
- g_value_set_int (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_UINT:
- g_value_init (&value, G_TYPE_UINT);
- g_value_set_uint (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_INT64:
- g_value_init (&value, G_TYPE_INT64);
- g_value_set_int64 (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_UINT64:
- g_value_init (&value, G_TYPE_UINT64);
- g_value_set_uint64 (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_DOUBLE:
- g_value_init (&value, G_TYPE_DOUBLE);
- g_value_set_double (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_BOOLEAN:
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop_value_checkbox)));
- break;
- case PROP_TYPE_ARRAY:
- break;
- }
-
- xfconf_channel_set_property (current_channel, prop_name, &value);
-
- /* Refresh the view */
- property_treeview = gtk_builder_get_object (builder, "property_treeview");
- tree_store = gtk_tree_view_get_model (GTK_TREE_VIEW (property_treeview));
-
- gtk_tree_store_clear (GTK_TREE_STORE(tree_store));
- load_properties (current_channel, GTK_TREE_STORE (tree_store), GTK_TREE_VIEW (property_treeview));
- }
- else
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
-static void
-cb_property_edit_button_clicked (GtkButton *button, GtkBuilder *builder)
-{
- GValue value = {0, };
-
- GObject *dialog = gtk_builder_get_object (builder, "edit_settings_dialog");
- GObject *prop_name_entry = gtk_builder_get_object (builder, "property_name_entry");
- GObject *prop_type_combo = gtk_builder_get_object (builder, "property_type_combo");
-
- GObject *prop_value_text_entry = gtk_builder_get_object (builder, "property_value_text_entry");
- GObject *prop_value_spin_button = gtk_builder_get_object (builder, "property_value_spin_button");
- GObject *prop_value_sw = gtk_builder_get_object (builder, "property_value_sw");
- GObject *prop_value_checkbox = gtk_builder_get_object (builder, "property_value_checkbutton");
-
- /* Set the correct properties in the ui */
- gtk_entry_set_text (GTK_ENTRY(prop_name_entry), current_property);
- gtk_widget_set_sensitive (GTK_WIDGET (prop_type_combo), FALSE);
-
- if (xfconf_channel_get_property (current_channel, current_property, &value))
- {
- switch (G_VALUE_TYPE(&value))
- {
- case G_TYPE_STRING:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_STRING);
- gtk_widget_hide (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_show (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_entry_set_text (GTK_ENTRY (prop_value_text_entry), g_value_get_string (&value));
- break;
- case G_TYPE_INT:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_INT);
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MININT, G_MAXINT);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), g_value_get_int (&value));
- break;
- case G_TYPE_UINT:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_UINT);
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), 0, G_MAXUINT);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), g_value_get_uint (&value));
- break;
- case G_TYPE_INT64:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_INT64);
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MININT64, G_MAXINT64);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), g_value_get_int64 (&value));
- break;
- case G_TYPE_UINT64:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_UINT64);
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), 0, G_MAXUINT64);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), g_value_get_uint64 (&value));
- break;
- case G_TYPE_DOUBLE:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_DOUBLE);
- gtk_widget_show (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_hide (GTK_WIDGET (prop_value_checkbox));
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (prop_value_spin_button), G_MINDOUBLE, G_MAXDOUBLE);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (prop_value_spin_button), 2);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop_value_spin_button), g_value_get_double (&value));
- break;
- case G_TYPE_BOOLEAN:
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_BOOLEAN);
- gtk_widget_hide (GTK_WIDGET (prop_value_spin_button));
- gtk_widget_hide (GTK_WIDGET (prop_value_text_entry));
- gtk_widget_hide (GTK_WIDGET (prop_value_sw));
- gtk_widget_show (GTK_WIDGET (prop_value_checkbox));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop_value_checkbox), g_value_get_boolean (&value));
- break;
- default:
- return;
- break;
- }
- }
- else
- gtk_combo_box_set_active (GTK_COMBO_BOX (prop_type_combo), PROP_TYPE_EMPTY);
-
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_APPLY)
- {
- gchar *prop_name;
- GError *error = NULL;
-
- gtk_widget_hide (GTK_WIDGET (dialog));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (prop_type_combo)))
- {
- case PROP_TYPE_EMPTY:
- break;
- case PROP_TYPE_STRING:
- g_value_set_string (&value, gtk_entry_get_text (GTK_ENTRY (prop_value_text_entry)));
- break;
- case PROP_TYPE_INT:
- g_value_set_int (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_UINT:
- g_value_set_uint (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_INT64:
- g_value_set_int64 (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_UINT64:
- g_value_set_uint64 (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_DOUBLE:
- g_value_set_double (&value, gtk_spin_button_get_value (GTK_SPIN_BUTTON (prop_value_spin_button)));
- break;
- case PROP_TYPE_BOOLEAN:
- g_value_set_boolean (&value, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop_value_checkbox)));
- break;
- case PROP_TYPE_ARRAY:
- break;
- }
-
- prop_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (prop_name_entry)));
-
- if (!xfconf_property_is_valid (prop_name, &error))
- {
- GObject *main_window = gtk_builder_get_object (builder, "main_dialog");
-
- xfce_dialog_show_error (GTK_WINDOW (main_window), error, _("This property name is not valid."));
-
- g_error_free (error);
- g_free (prop_name);
-
- return;
- }
-
- if (g_strcmp0 (prop_name, current_property) != 0)
- {
- xfconf_channel_reset_property (current_channel, current_property, FALSE);
- g_free (current_property);
- current_property = prop_name;
- }
- else
- g_free (prop_name);
-
- xfconf_channel_set_property (current_channel, current_property, &value);
- }
- else
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
-/**
- * cb_property_revert_button_clicked
- *
- * Resets a property to it's system-default, it removes the property if it does not exist as a system default.
- */
-static void
-cb_property_revert_button_clicked (GtkButton *button, GtkBuilder *builder)
-{
- gboolean response;
-
- response = xfce_dialog_confirm (GTK_WINDOW (gtk_builder_get_object (builder, "main_window")),
- GTK_STOCK_YES,
- _("Reset"),
- _("Resetting a property will permanently remove those custom settings."),
- _("Are you sure you want to reset property \"%s\"?"),
- current_property);
-
- if (response)
- xfconf_channel_reset_property (current_channel, current_property, FALSE);
-}
-
-static void
-cb_settings_editor_dialog_response (GtkWidget *dialog, gint response, GtkBuilder *builder)
-{
- XfconfChannel *channel;
- gint width, height;
- GObject *hpaned;
-
- hpaned = gtk_builder_get_object (builder, "hpaned2");
-
- channel = xfconf_channel_get ("xfce4-settings-editor");
- gtk_window_get_size (GTK_WINDOW (dialog), &width, &height);
- xfconf_channel_set_int (channel, "/window-width", width);
- xfconf_channel_set_int (channel, "/window-height", height);
- xfconf_channel_set_int (channel, "/hpaned-position", gtk_paned_get_position (GTK_PANED (hpaned)));
-
- gtk_widget_destroy (dialog);
-
- if (current_channel)
- {
- g_object_unref (G_OBJECT(current_channel));
- current_channel = NULL;
- }
-}
-
-static void
-cb_channel_property_changed (XfconfChannel *channel, gchar *property, GValue *value, GtkBuilder *builder)
-{
- if (g_strcmp0 (property, current_property) == 0)
- {
- GObject *property_treeview;
- GtkTreeModel *tree_store = NULL;
-
- property_treeview = gtk_builder_get_object (builder, "property_treeview");
- tree_store = gtk_tree_view_get_model (GTK_TREE_VIEW (property_treeview));
-
- gtk_tree_store_clear (GTK_TREE_STORE(tree_store));
- load_properties (current_channel, GTK_TREE_STORE (tree_store), GTK_TREE_VIEW (property_treeview));
- }
-}
-
-/* Copied from xfconfd/xfconf-backend.c */
-static gboolean
-xfconf_property_is_valid(const gchar *property, GError **error)
-{
- const gchar *p = property;
-
- if(!p || *p != '/') {
- if(error) {
- g_set_error(error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
- _("Property names must start with a '/' character"));
- }
- return FALSE;
- }
-
- p++;
- if(!*p) {
- if(error) {
- g_set_error(error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
- _("The root element ('/') is not a valid property name"));
- }
- return FALSE;
- }
-
- while(*p) {
- if(!(*p >= 'A' && *p <= 'Z') && !(*p >= 'a' && *p <= 'z')
- && !(*p >= '0' && *p <= '9')
- && *p != '_' && *p != '-' && *p != '/'
- && !(*p == '<' || *p == '>'))
- {
- if(error) {
- g_set_error(error, XFCONF_ERROR,
- XFCONF_ERROR_INVALID_PROPERTY,
- _("Property names can only include the ASCII characters A-Z, a-z, 0-9, '_', '-', '<' and '>', as well as '/' as a separator"));
- }
- return FALSE;
- }
-
- if('/' == *p && '/' == *(p-1)) {
- if(error) {
- g_set_error(error, XFCONF_ERROR,
- XFCONF_ERROR_INVALID_PROPERTY,
- _("Property names cannot have two or more consecutive '/' characters"));
- }
- return FALSE;
- }
-
- p++;
- }
-
- if(*(p-1) == '/') {
- if(error) {
- g_set_error(error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
- _("Property names cannot end with a '/' character"));
- }
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-channel_treeview_popup_menu (GtkWidget *widget, GdkEventButton *event, GtkBuilder *builder)
-{
- GtkWidget *menu;
- GtkWidget *menu_item;
- GtkWidget *image;
- int button, event_time;
-
- menu = gtk_menu_new ();
- g_signal_connect (menu, "deactivate", G_CALLBACK (gtk_menu_popdown), NULL);
-
- menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Reset"));
- image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (cb_channel_popup_menu_remove_item_activate), builder);
- gtk_widget_set_sensitive (menu_item, !xfconf_channel_is_property_locked (current_channel, "/"));
- gtk_widget_show_all (menu_item);
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time);
-}
-
-static void
-cb_channel_popup_menu_remove_item_activate (GtkMenuItem *item, GtkBuilder *builder)
-{
- gboolean response;
- gchar *channel_name;
-
- g_object_get (G_OBJECT (current_channel), "channel-name", &channel_name, NULL);
-
- response = xfce_dialog_confirm (GTK_WINDOW (gtk_builder_get_object (builder, "main_window")),
- GTK_STOCK_REVERT_TO_SAVED,
- _("Reset"),
- _("Resetting a channel will permanently remove those custom settings."),
- _("Are you sure you want to reset channel \"%s\" and all its properties?"),
- channel_name);
-
- if (response)
- {
- GObject *channel_treeview;
- GObject *property_treeview;
- GtkTreeModel *list_store = NULL;
- GtkTreeModel *tree_store = NULL;
-
- channel_treeview = gtk_builder_get_object (builder, "channel_treeview");
- list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (channel_treeview));
- xfconf_channel_reset_property (current_channel, "/", TRUE);
-
- gtk_list_store_clear (GTK_LIST_STORE(list_store));
- load_channels (GTK_LIST_STORE (list_store), GTK_TREE_VIEW (channel_treeview));
-
- property_treeview = gtk_builder_get_object (builder, "property_treeview");
- tree_store = gtk_tree_view_get_model (GTK_TREE_VIEW (property_treeview));
-
- gtk_tree_store_clear (GTK_TREE_STORE(tree_store));
- load_properties (current_channel, GTK_TREE_STORE (tree_store), GTK_TREE_VIEW (property_treeview));
- }
-
- g_free (channel_name);
-}
diff --git a/xfce4-settings-editor/main_window.h b/xfce4-settings-editor/main_window.h
deleted file mode 100644
index 223e2a7..0000000
--- a/xfce4-settings-editor/main_window.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-
-GtkDialog *
-xfce4_settings_editor_main_window_new(void);
diff --git a/xfce4-settings-editor/xfce-settings-cell-renderer.c b/xfce4-settings-editor/xfce-settings-cell-renderer.c
new file mode 100644
index 0000000..fd684a1
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-cell-renderer.c
@@ -0,0 +1,637 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "xfce-settings-cell-renderer.h"
+#include "xfce-settings-marshal.h"
+
+
+
+struct _XfceSettingsCellRendererClass
+{
+ GtkCellRendererClass __parent__;
+};
+
+struct _XfceSettingsCellRenderer
+{
+ GtkCellRenderer __parent__;
+
+ GValue cell_value;
+
+ guint locked : 1;
+
+ GtkCellRenderer *renderer_text;
+ GtkCellRenderer *renderer_toggle;
+};
+
+enum
+{
+ PROP_0,
+ PROP_VALUE,
+ PROP_LOCKED
+};
+
+enum
+{
+ VALUE_CHANGED,
+ LAST_SIGNAL
+};
+
+static GQuark edit_data_quark = 0;
+
+static guint renderer_signals[LAST_SIGNAL];
+
+
+
+static void xfce_settings_cell_renderer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void xfce_settings_cell_renderer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void xfce_settings_cell_renderer_finalize (GObject *object);
+static void xfce_settings_cell_renderer_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height);
+static void xfce_settings_cell_renderer_render (GtkCellRenderer *cell,
+ GdkDrawable *window,
+ GtkWidget *widget,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GdkRectangle *expose_area,
+ GtkCellRendererState flags);
+static gint xfce_settings_cell_renderer_activate (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags);
+static GtkCellEditable *xfce_settings_cell_renderer_start_editing (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags);
+
+
+
+G_DEFINE_TYPE (XfceSettingsCellRenderer, xfce_settings_cell_renderer, GTK_TYPE_CELL_RENDERER)
+
+
+
+static void
+xfce_settings_cell_renderer_class_init (XfceSettingsCellRendererClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkCellRendererClass *gtkcellrenderer_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->set_property = xfce_settings_cell_renderer_set_property;
+ gobject_class->get_property = xfce_settings_cell_renderer_get_property;
+ gobject_class->finalize = xfce_settings_cell_renderer_finalize;
+
+ gtkcellrenderer_class = GTK_CELL_RENDERER_CLASS (klass);
+ gtkcellrenderer_class->get_size = xfce_settings_cell_renderer_get_size;
+ gtkcellrenderer_class->render = xfce_settings_cell_renderer_render;
+ gtkcellrenderer_class->activate = xfce_settings_cell_renderer_activate;
+ gtkcellrenderer_class->start_editing = xfce_settings_cell_renderer_start_editing;
+
+ g_object_class_install_property (gobject_class,
+ PROP_VALUE,
+ g_param_spec_boxed ("value",
+ NULL, NULL,
+ G_TYPE_VALUE,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_LOCKED,
+ g_param_spec_boolean ("locked",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+ renderer_signals[VALUE_CHANGED] = g_signal_new (g_intern_static_string ("value-changed"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ _xfce_settings_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_VALUE);
+
+ edit_data_quark = g_quark_from_static_string ("path");
+}
+
+
+
+static void
+xfce_settings_cell_renderer_init (XfceSettingsCellRenderer *renderer)
+{
+ renderer->renderer_text = gtk_cell_renderer_text_new ();
+ g_object_ref_sink (G_OBJECT (renderer->renderer_text));
+
+ renderer->renderer_toggle = gtk_cell_renderer_toggle_new ();
+ g_object_ref_sink (G_OBJECT (renderer->renderer_toggle));
+}
+
+
+
+static void
+xfce_settings_cell_renderer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (object);
+ GValue *real_value;
+ GtkCellRendererMode cell_mode;
+ GType cell_type;
+
+ switch (prop_id)
+ {
+ case PROP_VALUE:
+ if (G_IS_VALUE (&renderer->cell_value))
+ g_value_unset (&renderer->cell_value);
+
+ real_value = g_value_get_boxed (value);
+ cell_mode = GTK_CELL_RENDERER_MODE_INERT;
+ if (G_IS_VALUE (real_value))
+ {
+ cell_type = G_VALUE_TYPE (real_value);
+ g_value_init (&renderer->cell_value, cell_type);
+ g_value_copy (real_value, &renderer->cell_value);
+
+ switch (cell_type)
+ {
+ case G_TYPE_STRING:
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ case G_TYPE_INT64:
+ case G_TYPE_UINT64:
+ case G_TYPE_DOUBLE:
+ cell_mode = GTK_CELL_RENDERER_MODE_EDITABLE;
+ break;
+
+ case G_TYPE_BOOLEAN:
+ cell_mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
+ break;
+ }
+ }
+
+ g_object_set (object, "mode", cell_mode, NULL);
+ break;
+
+ case PROP_LOCKED:
+ renderer->locked = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+xfce_settings_cell_renderer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (object);
+
+ switch (prop_id)
+ {
+ case PROP_VALUE:
+ if (G_IS_VALUE (&renderer->cell_value))
+ g_value_set_boxed (value, &renderer->cell_value);
+ else
+ g_value_set_boxed (value, NULL);
+ break;
+
+ case PROP_LOCKED:
+ g_value_set_boolean (value, renderer->locked);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+xfce_settings_cell_renderer_finalize (GObject *object)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (object);
+
+ if (G_IS_VALUE (&renderer->cell_value))
+ g_value_unset (&renderer->cell_value);
+
+ g_object_unref (G_OBJECT (renderer->renderer_text));
+ g_object_unref (G_OBJECT (renderer->renderer_toggle));
+
+ G_OBJECT_CLASS (xfce_settings_cell_renderer_parent_class)->finalize (object);
+}
+
+
+
+static GtkCellRenderer *
+xfce_settings_cell_renderer_prepare (XfceSettingsCellRenderer *renderer)
+{
+ const GValue *value = &renderer->cell_value;
+ GValue str_value = { 0, };
+
+ if (G_VALUE_TYPE (value) == xfce_settings_array_type ())
+ goto transform_value;
+
+ switch (G_VALUE_TYPE (value))
+ {
+ case G_TYPE_NONE:
+ case G_TYPE_INVALID:
+ g_object_set (G_OBJECT (renderer->renderer_text),
+ "text", NULL, NULL);
+ break;
+
+ case G_TYPE_STRING:
+ g_object_set (G_OBJECT (renderer->renderer_text),
+ "text", g_value_get_string (value), NULL);
+ break;
+
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ case G_TYPE_INT64:
+ case G_TYPE_UINT64:
+ case G_TYPE_DOUBLE:
+ transform_value:
+
+ g_value_init (&str_value, G_TYPE_STRING);
+ if (g_value_transform (value, &str_value))
+ {
+ g_object_set (G_OBJECT (renderer->renderer_text),
+ "text", g_value_get_string (&str_value), NULL);
+ }
+ g_value_unset (&str_value);
+ break;
+
+ case G_TYPE_BOOLEAN:
+ g_object_set (G_OBJECT (renderer->renderer_toggle),
+ "xalign", 0.0,
+ "active", g_value_get_boolean (value), NULL);
+
+ return renderer->renderer_toggle;
+
+ default:
+ g_object_set (G_OBJECT (renderer->renderer_text),
+ "text", "<unknown>", NULL);
+ break;
+ }
+
+ return renderer->renderer_text;
+}
+
+
+
+static void
+xfce_settings_cell_renderer_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (cell);
+ GtkCellRenderer *cell_renderer;
+
+ cell_renderer = xfce_settings_cell_renderer_prepare (renderer);
+ gtk_cell_renderer_get_size (cell_renderer,
+ widget, cell_area,
+ x_offset, y_offset,
+ width, height);
+}
+
+
+
+static void
+xfce_settings_cell_renderer_render (GtkCellRenderer *cell,
+ GdkDrawable *window,
+ GtkWidget *widget,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GdkRectangle *expose_area,
+ GtkCellRendererState flags)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (cell);
+ GtkCellRenderer *cell_renderer;
+
+ cell_renderer = xfce_settings_cell_renderer_prepare (renderer);
+ gtk_cell_renderer_render (cell_renderer,
+ window, widget,
+ background_area, cell_area,
+ expose_area, flags);
+}
+
+
+
+static gint
+xfce_settings_cell_renderer_activate (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (cell);
+ GValue new_value = { 0, };
+
+ if (renderer->locked)
+ return FALSE;
+
+ switch (G_VALUE_TYPE (&renderer->cell_value))
+ {
+ case G_TYPE_NONE:
+ case G_TYPE_INVALID:
+ return FALSE;
+
+ case G_TYPE_BOOLEAN:
+ g_value_init (&new_value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&new_value, !g_value_get_boolean (&renderer->cell_value));
+
+ g_signal_emit (G_OBJECT (renderer),
+ renderer_signals[VALUE_CHANGED], 0,
+ path, &new_value);
+
+ g_value_unset (&new_value);
+ return TRUE;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return FALSE;
+}
+
+
+
+typedef struct
+{
+ gchar *path;
+ GType dest_type;
+}
+EditData;
+
+
+
+static void
+xfce_settings_cell_renderer_done_editing (GtkCellEditable *entry,
+ XfceSettingsCellRenderer *renderer)
+{
+ EditData *data;
+ const gchar *text;
+ GValue value = { 0, };
+ gdouble dval;
+
+ data = g_object_get_qdata (G_OBJECT (entry), edit_data_quark);
+ g_value_init (&value, data->dest_type);
+
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ if (G_UNLIKELY (text == NULL))
+ text = "";
+
+ switch (data->dest_type)
+ {
+ case G_TYPE_INT:
+ dval = g_ascii_strtod (text, NULL);
+ g_value_set_int (&value, CLAMP (dval, G_MININT, G_MAXINT));
+ break;
+
+ case G_TYPE_UINT:
+ dval = g_ascii_strtod (text, NULL);
+ g_value_set_uint (&value, CLAMP (dval, 0, G_MAXUINT));
+ break;
+
+ case G_TYPE_INT64:
+ g_value_set_int64 (&value, g_ascii_strtoll (text, NULL, 0));
+ break;
+
+ case G_TYPE_UINT64:
+ g_value_set_uint64 (&value, g_ascii_strtoull (text, NULL, 0));
+ break;
+
+ case G_TYPE_DOUBLE:
+ g_value_set_double (&value, g_ascii_strtod (text, NULL));
+ break;
+
+ case G_TYPE_STRING:
+ g_value_set_static_string (&value, text);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_signal_emit (G_OBJECT (renderer),
+ renderer_signals[VALUE_CHANGED], 0,
+ data->path, &value);
+
+ g_value_unset (&value);
+}
+
+
+
+static void
+xfce_settings_cell_renderer_edit_free (gpointer user_data)
+{
+ EditData *data = user_data;
+ g_free (data->path);
+ g_slice_free (EditData, data);
+}
+
+
+
+static GtkCellEditable *
+xfce_settings_cell_renderer_start_editing (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ XfceSettingsCellRenderer *renderer = XFCE_SETTINGS_CELL_RENDERER (cell);
+ GtkWidget *entry;
+ GValue str_value = { 0, };
+ const gchar *text;
+ EditData *data;
+
+ if (renderer->locked)
+ return NULL;
+
+ switch (G_VALUE_TYPE (&renderer->cell_value))
+ {
+ case G_TYPE_NONE:
+ case G_TYPE_INVALID:
+ return NULL;
+
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ case G_TYPE_INT64:
+ case G_TYPE_UINT64:
+ case G_TYPE_DOUBLE:
+ case G_TYPE_STRING:
+ g_value_init (&str_value, G_TYPE_STRING);
+ if (g_value_transform (&renderer->cell_value, &str_value))
+ {
+ entry = gtk_entry_new ();
+ text = g_value_get_string (&str_value);
+ gtk_entry_set_text (GTK_ENTRY (entry), text == NULL ? "" : text);
+ gtk_entry_set_has_frame (GTK_ENTRY (entry), FALSE);
+ gtk_widget_show (entry);
+
+ data = g_slice_new0 (EditData);
+ data->path = g_strdup (path);
+ data->dest_type = G_VALUE_TYPE (&renderer->cell_value);
+
+ g_object_set_qdata_full (G_OBJECT (entry), edit_data_quark, data,
+ xfce_settings_cell_renderer_edit_free);
+
+ g_signal_connect (G_OBJECT (entry), "editing-done",
+ G_CALLBACK (xfce_settings_cell_renderer_done_editing), cell);
+
+ g_value_unset (&str_value);
+
+ return GTK_CELL_EDITABLE (entry);
+ }
+ else
+ {
+ g_warning ("Unable to transform value from %s to %s",
+ G_VALUE_TYPE_NAME (&renderer->cell_value),
+ G_VALUE_TYPE_NAME (&str_value));
+ }
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return NULL;
+}
+
+
+
+static void
+xfce_settings_array_to_string (const GValue *src_value,
+ GValue *dest_value)
+{
+ GString *str;
+ GPtrArray *array = g_value_get_boxed (src_value);
+ guint i;
+ const GValue *val;
+ GValue str_val = { 0, };
+
+ g_return_if_fail (G_VALUE_HOLDS_STRING (dest_value));
+ g_return_if_fail (array != NULL);
+
+ str = g_string_new ("[ ");
+
+ for (i = 0; i < array->len; i++)
+ {
+ val = g_ptr_array_index (array, i);
+
+ if (val == NULL)
+ {
+ g_string_append (str, "Null");
+ }
+ else if (G_VALUE_HOLDS_STRING (val))
+ {
+ g_string_append_printf (str, "\"%s\"",
+ g_value_get_string (val));
+ }
+ else
+ {
+ g_value_init (&str_val, G_TYPE_STRING);
+ if (g_value_transform (val, &str_val))
+ g_string_append (str, g_value_get_string (&str_val));
+ else
+ g_string_append (str, "?");
+ g_value_unset (&str_val);
+ }
+
+ if (i < array->len - 1)
+ g_string_append (str, ", ");
+ }
+
+ g_string_append (str, " ]");
+
+ g_value_take_string (dest_value, g_string_free (str, FALSE));
+}
+
+
+
+GtkCellRenderer *
+xfce_settings_cell_renderer_new (void)
+{
+ return g_object_new (XFCE_TYPE_SETTINGS_CELL_RENDERER, NULL);
+}
+
+
+
+GType
+xfce_settings_array_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ type = dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE);
+ g_value_register_transform_func (type, G_TYPE_STRING,
+ xfce_settings_array_to_string);
+ }
+
+ return type;
+}
diff --git a/xfce4-settings-editor/xfce-settings-cell-renderer.h b/xfce4-settings-editor/xfce-settings-cell-renderer.h
new file mode 100644
index 0000000..9934089
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-cell-renderer.h
@@ -0,0 +1,45 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFCE_SETTINGS_CELL_RENDERER_H__
+#define __XFCE_SETTINGS_CELL_RENDERER_H__
+
+#include <gtk/gtk.h>
+
+#define XFCE_TYPE_SETTINGS_CELL_RENDERER (xfce_settings_cell_renderer_get_type ())
+#define XFCE_SETTINGS_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SETTINGS_CELL_RENDERER, XfceSettingsCellRenderer))
+#define XFCE_SETTINGS_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SETTINGS_CELL_RENDERER, XfceSettingsCellRendererClass))
+#define XFCE_IS_SETTINGS_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SETTINGS_CELL_RENDERER))
+#define XFCE_IS_SETTINGS_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SETTINGS_CELL_RENDERER))
+#define XFCE_SETTINGS_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SETTINGS_CELL_RENDERER, XfceSettingsCellRendererClass))
+
+G_BEGIN_DECLS
+
+typedef struct _XfceSettingsCellRenderer XfceSettingsCellRenderer;
+typedef struct _XfceSettingsCellRendererClass XfceSettingsCellRendererClass;
+
+GType xfce_settings_cell_renderer_get_type (void) G_GNUC_CONST;
+
+GtkCellRenderer *xfce_settings_cell_renderer_new (void);
+
+GType xfce_settings_array_type (void);
+
+G_END_DECLS
+
+#endif /* __XFCE_SETTINGS_CELL_RENDERER_H__ */
diff --git a/xfce4-settings-editor/xfce-settings-editor-dialog.c b/xfce4-settings-editor/xfce-settings-editor-dialog.c
new file mode 100644
index 0000000..fb7a10f
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-editor-dialog.c
@@ -0,0 +1,1385 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2008 Brian Tarricone <bjt23 at cornell.edu>
+ * Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
+ * Copyright (c) 2009-2010 Jérôme Guelfucci <jeromeg at xfce.org>
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
+
+#include "xfce-settings-editor-dialog.h"
+#include "xfce-settings-prop-dialog.h"
+#include "xfce-settings-cell-renderer.h"
+
+
+
+struct _XfceSettingsEditorDialogClass
+{
+ XfceTitledDialogClass __parent__;
+};
+
+struct _XfceSettingsEditorDialog
+{
+ XfceTitledDialog __parent__;
+
+ XfconfChannel *channel;
+
+ GtkWidget *paned;
+
+ GtkListStore *channels_store;
+ GtkWidget *channels_treeview;
+
+ GtkTreeStore *props_store;
+ XfconfChannel *props_channel;
+ GtkWidget *props_treeview;
+
+ GtkWidget *button_new;
+ GtkWidget *button_edit;
+ GtkWidget *button_reset;
+};
+
+
+
+enum
+{
+ CHANNEL_COLUMN_NAME,
+ N_CHANNEL_COLUMNS
+};
+
+enum
+{
+ PROP_COLUMN_FULL,
+ PROP_COLUMN_NAME,
+ PROP_COLUMN_TYPE_NAME,
+ PROP_COLUMN_TYPE,
+ PROP_COLUMN_LOCKED,
+ PROP_COLUMN_VALUE,
+ N_PROP_COLUMNS
+};
+
+
+
+static GSList *monitor_dialogs = NULL;
+static GtkWindowGroup *monitor_group = NULL;
+
+
+
+static void xfce_settings_editor_dialog_finalize (GObject *object);
+static void xfce_settings_editor_dialog_response (GtkDialog *widget,
+ gint response_id);
+static void xfce_settings_editor_dialog_load_channels (XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_channel_changed (GtkTreeSelection *selection,
+ XfceSettingsEditorDialog *dialog);
+static gboolean xfce_settings_editor_dialog_channel_menu (XfceSettingsEditorDialog *dialog);
+static gboolean xfce_settings_editor_dialog_channel_button_press (GtkWidget *treeview,
+ GdkEventButton *event,
+ XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_value_changed (GtkCellRenderer *renderer,
+ const gchar *path,
+ const GValue *new_value,
+ XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_selection_changed (GtkTreeSelection *selection,
+ XfceSettingsEditorDialog *dialog);
+static gboolean xfce_settings_editor_dialog_query_tooltip (GtkWidget *treeview,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_row_activated (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ XfceSettingsEditorDialog *dialog);
+static gboolean xfce_settings_editor_dialog_key_press_event (GtkTreeView *treeview,
+ GdkEventKey *event,
+ XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_property_new (XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_property_edit (XfceSettingsEditorDialog *dialog);
+static void xfce_settings_editor_dialog_property_reset (XfceSettingsEditorDialog *dialog);
+
+
+
+G_DEFINE_TYPE (XfceSettingsEditorDialog, xfce_settings_editor_dialog, XFCE_TYPE_TITLED_DIALOG)
+
+
+
+static void
+xfce_settings_editor_dialog_class_init (XfceSettingsEditorDialogClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkDialogClass *gtkdialog_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_settings_editor_dialog_finalize;
+
+ gtkdialog_class = GTK_DIALOG_CLASS (klass);
+ gtkdialog_class->response = xfce_settings_editor_dialog_response;
+}
+
+
+
+static void
+xfce_settings_editor_dialog_init (XfceSettingsEditorDialog *dialog)
+{
+ GtkWidget *paned;
+ GtkWidget *content_area;
+ GtkWidget *scroll;
+ GtkWidget *treeview;
+ GtkCellRenderer *render;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GtkWidget *vbox;
+ GtkWidget *bbox;
+ GtkWidget *button;
+
+ dialog->channel = xfconf_channel_new ("xfce4-settings-editor");
+
+ dialog->channels_store = gtk_list_store_new (N_CHANNEL_COLUMNS,
+ G_TYPE_STRING);
+ xfce_settings_editor_dialog_load_channels (dialog);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->channels_store),
+ CHANNEL_COLUMN_NAME, GTK_SORT_ASCENDING);
+
+ dialog->props_store = gtk_tree_store_new (N_PROP_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ G_TYPE_VALUE);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->props_store),
+ PROP_COLUMN_NAME, GTK_SORT_ASCENDING);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Settings Editor"));
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Customize settings stored by Xfconf"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-system");
+ gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL);
+ gtk_window_set_default_size (GTK_WINDOW (dialog),
+ xfconf_channel_get_int (dialog->channel, "/last/window-width", 640),
+ xfconf_channel_get_int (dialog->channel, "/last/window-height", 500));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_HELP, GTK_RESPONSE_HELP,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ dialog->paned = paned = gtk_hpaned_new ();
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_start (GTK_BOX (content_area), paned, TRUE, TRUE, 0);
+ gtk_paned_set_position (GTK_PANED (paned),
+ xfconf_channel_get_int (dialog->channel, "/last/paned-position", 180));
+ gtk_container_set_border_width (GTK_CONTAINER (paned), 6);
+ gtk_widget_show (paned);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
+ gtk_paned_add1 (GTK_PANED (paned), scroll);
+ gtk_widget_show (scroll);
+
+ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->channels_store));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
+ gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (treeview), TRUE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_container_add (GTK_CONTAINER (scroll), treeview);
+ dialog->channels_treeview = treeview;
+ gtk_widget_show (treeview);
+
+ g_signal_connect_swapped (G_OBJECT (treeview), "popup-menu",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_menu), dialog);
+ g_signal_connect (G_OBJECT (treeview), "button-press-event",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_button_press), dialog);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_changed), dialog);
+
+ render = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), 0,
+ _("Channel"), render,
+ "text", CHANNEL_COLUMN_NAME, NULL);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_paned_add2 (GTK_PANED (paned), vbox);
+ gtk_widget_show (vbox);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
+ gtk_widget_show (scroll);
+
+ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->props_store));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
+ gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_container_add (GTK_CONTAINER (scroll), treeview);
+ dialog->props_treeview = treeview;
+ gtk_widget_show (treeview);
+
+ gtk_widget_set_has_tooltip (treeview, TRUE);
+ g_signal_connect (G_OBJECT (treeview), "query-tooltip",
+ G_CALLBACK (xfce_settings_editor_dialog_query_tooltip), dialog);
+ g_signal_connect (G_OBJECT (treeview), "row-activated",
+ G_CALLBACK (xfce_settings_editor_dialog_row_activated), dialog);
+ g_signal_connect (G_OBJECT (treeview), "key-press-event",
+ G_CALLBACK (xfce_settings_editor_dialog_key_press_event), dialog);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (xfce_settings_editor_dialog_selection_changed), dialog);
+
+ render = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Property"), render,
+ "text", PROP_COLUMN_NAME,
+ NULL);
+ gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ render = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Type"), render,
+ "text", PROP_COLUMN_TYPE_NAME,
+ NULL);
+ gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ render = gtk_cell_renderer_toggle_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Locked"), render,
+ "active", PROP_COLUMN_LOCKED,
+ NULL);
+ gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ render = xfce_settings_cell_renderer_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Value"), render,
+ "value", PROP_COLUMN_VALUE,
+ "locked", PROP_COLUMN_LOCKED,
+ NULL);
+ gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+ g_signal_connect (G_OBJECT (render), "value-changed",
+ G_CALLBACK (xfce_settings_editor_dialog_value_changed), dialog);
+
+ bbox = gtk_hbutton_box_new ();
+ gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
+ gtk_widget_show (bbox);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_NEW);
+ gtk_container_add (GTK_CONTAINER (bbox), button);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text (button, _("New property"));
+ gtk_widget_set_sensitive (button, FALSE);
+ gtk_widget_set_can_focus (button, FALSE);
+ dialog->button_new = button;
+ gtk_widget_show (button);
+ g_signal_connect_swapped (G_OBJECT (button), "clicked",
+ G_CALLBACK (xfce_settings_editor_dialog_property_new), dialog);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
+ gtk_container_add (GTK_CONTAINER (bbox), button);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text (button, _("Edit selected property"));
+ gtk_widget_set_sensitive (button, FALSE);
+ gtk_widget_set_can_focus (button, FALSE);
+ dialog->button_edit = button;
+ gtk_widget_show (button);
+ g_signal_connect_swapped (G_OBJECT (button), "clicked",
+ G_CALLBACK (xfce_settings_editor_dialog_property_edit), dialog);
+
+ button = xfce_gtk_button_new_mixed (GTK_STOCK_REVERT_TO_SAVED, _("_Reset"));
+ gtk_container_add (GTK_CONTAINER (bbox), button);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text (button, _("Reset selected property"));
+ gtk_widget_set_sensitive (button, FALSE);
+ gtk_widget_set_can_focus (button, FALSE);
+ dialog->button_reset = button;
+ gtk_widget_show (button);
+ g_signal_connect_swapped (G_OBJECT (button), "clicked",
+ G_CALLBACK (xfce_settings_editor_dialog_property_reset), dialog);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_finalize (GObject *object)
+{
+ GSList *li, *lnext;
+
+ XfceSettingsEditorDialog *dialog = XFCE_SETTINGS_EDITOR_DIALOG (object);
+
+ for (li = monitor_dialogs; li != NULL; li = lnext)
+ {
+ lnext = li->next;
+ gtk_dialog_response (GTK_DIALOG (li->data), GTK_RESPONSE_CLOSE);
+ }
+
+ if (monitor_group != NULL)
+ g_object_unref (G_OBJECT (monitor_group));
+
+ g_object_unref (G_OBJECT (dialog->channels_store));
+
+ g_object_unref (G_OBJECT (dialog->props_store));
+ if (dialog->props_channel != NULL)
+ g_object_unref (G_OBJECT (dialog->props_channel));
+
+ g_object_unref (G_OBJECT (dialog->channel));
+
+ G_OBJECT_CLASS (xfce_settings_editor_dialog_parent_class)->finalize (object);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_response (GtkDialog *widget,
+ gint response_id)
+{
+ XfceSettingsEditorDialog *dialog = XFCE_SETTINGS_EDITOR_DIALOG (widget);
+ gint width, height;
+ GdkWindowState state;
+
+ if (response_id == GTK_RESPONSE_HELP)
+ {
+ xfce_dialog_show_help (GTK_WINDOW (widget),
+ "xfce4-settings",
+ "settings-editor", NULL);
+ }
+ else
+ {
+ /* don't save the state for full-screen windows */
+ state = gdk_window_get_state (GTK_WIDGET (widget)->window);
+ if ((state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
+ {
+ /* save window size */
+ gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+ xfconf_channel_set_int (dialog->channel, "/last/window-width", width),
+ xfconf_channel_set_int (dialog->channel, "/last/window-height", height);
+
+ xfconf_channel_set_int (dialog->channel, "/last/paned-position",
+ gtk_paned_get_position (GTK_PANED (dialog->paned)));
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (widget));
+ gtk_main_quit ();
+ }
+}
+
+
+
+static void
+xfce_settings_editor_dialog_load_channels (XfceSettingsEditorDialog *dialog)
+{
+ gchar **channel_names;
+ guint i;
+ gchar *channel_name = NULL;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->channels_store));
+
+ /* try to restore the selected name (for reload) */
+ if (dialog->props_channel != NULL)
+ {
+ g_object_get (G_OBJECT (dialog->props_channel),
+ "channel-name", &channel_name, NULL);
+ }
+
+ gtk_list_store_clear (dialog->channels_store);
+
+ channel_names = xfconf_list_channels ();
+ if (G_LIKELY (channel_names != NULL))
+ {
+ for (i = 0; channel_names[i] != NULL; i++)
+ {
+ gtk_list_store_insert_with_values (dialog->channels_store, &iter, i,
+ CHANNEL_COLUMN_NAME, channel_names[i],
+ -1);
+
+ if (g_strcmp0 (channel_name, channel_names[i]) == 0)
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->channels_store), &iter);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->channels_treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+ }
+ g_strfreev (channel_names);
+ }
+
+ g_free (channel_name);
+}
+
+
+
+static const gchar *
+xfce_settings_editor_dialog_type_name (const GValue *value)
+{
+ if (G_UNLIKELY (value == NULL))
+ return _("Empty");
+
+ if (G_UNLIKELY (G_VALUE_TYPE (value) == xfce_settings_array_type ()))
+ return _("Array");
+
+ switch (G_VALUE_TYPE (value))
+ {
+ case G_TYPE_STRING:
+ return _("String");
+
+ /* show non-technical name here, the tooltip
+ * contains the full type name */
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ case G_TYPE_INT64:
+ case G_TYPE_UINT64:
+ return _("Integer");
+
+ case G_TYPE_BOOLEAN:
+ return _("Boolean");
+
+ case G_TYPE_DOUBLE:
+ return _("Double");
+
+ default:
+ return G_VALUE_TYPE_NAME (value);
+ }
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_load (const gchar *property,
+ const GValue *value,
+ XfceSettingsEditorDialog *dialog,
+ GtkTreePath **expand_path)
+{
+ gchar **paths;
+ guint i;
+ GtkTreeIter child_iter;
+ GtkTreeIter parent_iter;
+ GValue parent_val = { 0,};
+ gboolean found_parent;
+ GValue string_value = { 0, };
+ GtkTreeModel *model = GTK_TREE_MODEL (dialog->props_store);
+
+ g_return_if_fail (GTK_IS_TREE_STORE (dialog->props_store));
+ g_return_if_fail (G_IS_VALUE (value));
+ g_return_if_fail (property != NULL && *property == '/');
+
+ paths = g_strsplit (property, "/", -1);
+ if (paths == NULL)
+ return;
+
+ for (i = 1; paths[i] != NULL; i++)
+ {
+ found_parent = FALSE;
+
+ if (gtk_tree_model_iter_children (model, &child_iter, i == 1 ? NULL : &parent_iter))
+ {
+ for (;;)
+ {
+ /* look if one of the paths already exists */
+ gtk_tree_model_get_value (model, &child_iter, PROP_COLUMN_NAME, &parent_val);
+ found_parent = g_strcmp0 (g_value_get_string (&parent_val), paths[i]) == 0;
+ g_value_unset (&parent_val);
+
+ /* maybe we still need to set the value */
+ if (found_parent)
+ {
+ /* set this property in case it is the last value */
+ if (paths[i + 1] == NULL)
+ goto set_child_values;
+ break;
+ }
+
+ /* append at the end of this parent */
+ if (!gtk_tree_model_iter_next (model, &child_iter))
+ break;
+ }
+ }
+
+ if (!found_parent)
+ {
+ gtk_tree_store_append (GTK_TREE_STORE (model), &child_iter,
+ i == 1 ? NULL : &parent_iter);
+
+ if (G_LIKELY (paths[i + 1] != NULL))
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model), &child_iter,
+ PROP_COLUMN_NAME, paths[i],
+ PROP_COLUMN_TYPE_NAME, _("Empty"), -1);
+ }
+ else
+ {
+ set_child_values:
+
+ g_value_init (&string_value, G_TYPE_STRING);
+ if (!g_value_transform (value, &string_value))
+ g_value_set_string (&string_value, "Unknown");
+
+ gtk_tree_store_set (GTK_TREE_STORE (model), &child_iter,
+ PROP_COLUMN_NAME, paths[i],
+ PROP_COLUMN_FULL, property,
+ PROP_COLUMN_TYPE, G_VALUE_TYPE_NAME (value),
+ PROP_COLUMN_TYPE_NAME, xfce_settings_editor_dialog_type_name (value),
+ PROP_COLUMN_LOCKED, xfconf_channel_is_property_locked (dialog->props_channel, property),
+ PROP_COLUMN_VALUE, value,
+ -1);
+
+ if (expand_path != NULL)
+ *expand_path = gtk_tree_model_get_path (model, &child_iter);
+
+ g_value_unset (&string_value);
+ }
+ }
+
+ parent_iter = child_iter;
+ }
+
+ g_strfreev (paths);
+}
+
+
+
+typedef struct
+{
+ const gchar *prop;
+ GtkTreePath *path;
+}
+DeleteContext;
+
+
+
+static gboolean
+xfce_settings_editor_dialog_property_find (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ GValue prop = { 0, };
+ DeleteContext *context = data;
+ gboolean found = FALSE;
+
+ gtk_tree_model_get_value (model, iter, PROP_COLUMN_FULL, &prop);
+
+ if (g_strcmp0 (g_value_get_string (&prop), context->prop) == 0)
+ {
+ found = TRUE;
+ context->path = gtk_tree_path_copy (path);
+ }
+
+ g_value_unset (&prop);
+
+ return found;
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_changed (XfconfChannel *channel,
+ const gchar *property,
+ const GValue *value,
+ XfceSettingsEditorDialog *dialog)
+{
+ GtkTreePath *path = NULL;
+ DeleteContext *context;
+ GtkTreeIter child_iter;
+ GtkTreeModel *model;
+ GValue parent_val = { 0, };
+ GtkTreeIter parent_iter;
+ gboolean empty_prop;
+ gboolean has_parent;
+ GtkTreeSelection *selection;
+
+ g_return_if_fail (GTK_IS_TREE_STORE (dialog->props_store));
+ g_return_if_fail (XFCONF_IS_CHANNEL (channel));
+ g_return_if_fail (dialog->props_channel == channel);
+
+ if (value != NULL && G_IS_VALUE (value))
+ {
+ xfce_settings_editor_dialog_property_load (property, value, dialog, &path);
+
+ if (path != NULL)
+ {
+ /* show the new value */
+ gtk_tree_view_expand_to_path (GTK_TREE_VIEW (dialog->props_treeview), path);
+ gtk_tree_path_free (path);
+ }
+ }
+ else
+ {
+ /* we only get here when the property must be deleted, this means there
+ * is also no reset value in one of the xdg channels */
+ context = g_slice_new0 (DeleteContext);
+ context->prop = property;
+
+ model = GTK_TREE_MODEL (dialog->props_store);
+ gtk_tree_model_foreach (model, xfce_settings_editor_dialog_property_find, context);
+
+ if (context->path != NULL)
+ {
+ if (gtk_tree_model_get_iter (model, &child_iter, context->path))
+ {
+ if (gtk_tree_model_iter_has_child (model, &child_iter))
+ {
+ /* the node has children, so only unset it */
+ gtk_tree_store_set (GTK_TREE_STORE (model), &child_iter,
+ PROP_COLUMN_FULL, NULL,
+ PROP_COLUMN_TYPE, NULL,
+ PROP_COLUMN_TYPE_NAME, _("Empty"),
+ PROP_COLUMN_LOCKED, FALSE,
+ PROP_COLUMN_VALUE, NULL,
+ -1);
+ }
+ else
+ {
+ /* delete the node */
+ has_parent = gtk_tree_model_iter_parent (model, &parent_iter, &child_iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (model), &child_iter);
+
+ /* remove the parent nodes if they are empty */
+ while (has_parent)
+ {
+ /* if the parent still has children, stop cleaning */
+ if (gtk_tree_model_iter_has_child (model, &parent_iter))
+ break;
+
+ /* maybe the parent has a value */
+ gtk_tree_model_get_value (model, &parent_iter, PROP_COLUMN_FULL, &parent_val);
+ empty_prop = g_value_get_string (&parent_val) == NULL;
+ g_value_unset (&parent_val);
+
+ /* nope it points to a real xfconf property */
+ if (!empty_prop)
+ break;
+
+ /* get the parent and remove the empty row */
+ child_iter = parent_iter;
+ has_parent = gtk_tree_model_iter_parent (model, &parent_iter, &child_iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (model), &child_iter);
+ }
+ }
+ }
+
+ gtk_tree_path_free (context->path);
+ }
+
+ g_slice_free (DeleteContext, context);
+ }
+
+ /* update button sensitivity */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->props_treeview));
+ xfce_settings_editor_dialog_selection_changed (selection, dialog);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_load_hash (gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ xfce_settings_editor_dialog_property_load (key, value, data, NULL);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_properties_load (XfceSettingsEditorDialog *dialog,
+ XfconfChannel *channel)
+{
+ GHashTable *props;
+
+ g_return_if_fail (GTK_IS_TREE_STORE (dialog->props_store));
+ g_return_if_fail (XFCONF_IS_CHANNEL (channel));
+
+ if (dialog->props_channel != NULL)
+ {
+ g_signal_handlers_block_by_func (G_OBJECT (dialog->props_channel),
+ G_CALLBACK (xfce_settings_editor_dialog_property_changed), dialog);
+ g_object_unref (G_OBJECT (dialog->props_channel));
+ dialog->props_channel = NULL;
+ }
+
+ gtk_tree_store_clear (dialog->props_store);
+
+ dialog->props_channel = g_object_ref (G_OBJECT (channel));
+
+ props = xfconf_channel_get_properties (channel, NULL);
+ if (G_LIKELY (props != NULL))
+ {
+ g_hash_table_foreach (props, xfce_settings_editor_dialog_property_load_hash, dialog);
+ g_hash_table_destroy (props);
+ }
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->props_treeview));
+
+ g_signal_connect (G_OBJECT (dialog->props_channel), "property-changed",
+ G_CALLBACK (xfce_settings_editor_dialog_property_changed), dialog);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_channel_changed (GtkTreeSelection *selection,
+ XfceSettingsEditorDialog *dialog)
+{
+ GtkTreeIter iter;
+ GValue value = { 0, };
+ XfconfChannel *channel;
+ gboolean locked;
+
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ gtk_tree_model_get_value (GTK_TREE_MODEL (dialog->channels_store), &iter,
+ CHANNEL_COLUMN_NAME, &value);
+
+ channel = xfconf_channel_new (g_value_get_string (&value));
+
+ locked = xfconf_channel_is_property_locked (channel, "/");
+ gtk_widget_set_sensitive (dialog->button_new, !locked);
+
+ xfce_settings_editor_dialog_properties_load (dialog, channel);
+
+ g_object_unref (G_OBJECT (channel));
+
+ g_value_unset (&value);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (dialog->button_new, FALSE);
+ gtk_tree_store_clear (dialog->props_store);
+ }
+}
+
+
+
+static void
+xfce_settings_editor_dialog_channel_reset (XfceSettingsEditorDialog *dialog)
+{
+ gchar *channel_name;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ gchar **channels;
+ gboolean found;
+ guint i;
+
+ if (dialog->props_channel == NULL)
+ return;
+
+ g_object_get (dialog->props_channel, "channel-name", &channel_name, NULL);
+
+ if (xfce_dialog_confirm (GTK_WINDOW (dialog),
+ GTK_STOCK_REVERT_TO_SAVED,
+ _("_Reset Channel"),
+ _("Resetting a channel will permanently remove those custom settings."),
+ _("Are you sure you want to reset channel \"%s\" and all its properties?"),
+ channel_name))
+ {
+ /* reset all channel properties */
+ xfconf_channel_reset_property (dialog->props_channel, "/", TRUE);
+
+ /* check if the channel still exists (channel reset, not remove) */
+ channels = xfconf_list_channels ();
+ if (G_LIKELY (channels != NULL))
+ {
+ for (i = 0, found = FALSE; !found && channels[i] != NULL; i++)
+ found = g_strcmp0 (channels[i], channel_name) == 0;
+ g_strfreev (channels);
+ }
+
+ if (!found)
+ {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->channels_treeview));
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ if (gtk_list_store_remove (dialog->channels_store, &iter))
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->channels_store), &iter);
+ else
+ path = gtk_tree_path_new_first ();
+
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->channels_treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+ }
+ }
+
+ g_free (channel_name);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_channel_monitor_changed (XfconfChannel *channel,
+ const gchar *property,
+ const GValue *value,
+ GtkWidget *window)
+{
+ GtkTextBuffer *buffer;
+ GTimeVal timeval;
+ gchar *str;
+ GValue str_value = { 0, };
+ GtkTextIter iter;
+
+ buffer = g_object_get_data (G_OBJECT (window), "buffer");
+ g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+ g_get_current_time (&timeval);
+
+ if (value != NULL && G_IS_VALUE (value))
+ {
+ g_value_init (&str_value, G_TYPE_STRING);
+ if (g_value_transform (value, &str_value))
+ {
+ str = g_strdup_printf ("%ld: %s (%s: %s)\n",
+ timeval.tv_sec, property,
+ G_VALUE_TYPE_NAME (value),
+ g_value_get_string (&str_value));
+ }
+ else
+ {
+ str = g_strdup_printf ("%ld: %s (%s)\n",
+ timeval.tv_sec, property,
+ G_VALUE_TYPE_NAME (value));
+ }
+ g_value_unset (&str_value);
+ }
+ else
+ {
+ /* I18N: if a property is removed from the channel */
+ str = g_strdup_printf ("%ld: %s (%s)\n", timeval.tv_sec,
+ property, _("reset"));
+ }
+
+ /* prepend to the buffer */
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, str, -1, "monospace", NULL);
+ g_free (str);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_channel_monitor_response (GtkWidget *window,
+ gint response_id,
+ XfconfChannel *channel)
+{
+ GtkTextBuffer *buffer;
+
+ if (response_id == GTK_RESPONSE_REJECT)
+ {
+ buffer = g_object_get_data (G_OBJECT (window), "buffer");
+ g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+ gtk_text_buffer_set_text (buffer, "", 0);
+ }
+ else
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT (channel),
+ G_CALLBACK (xfce_settings_editor_dialog_channel_monitor_changed), window);
+
+ g_object_unref (G_OBJECT (channel));
+
+ monitor_dialogs = g_slist_remove (monitor_dialogs, window);
+
+ gtk_widget_destroy (window);
+ }
+}
+
+
+
+static void
+xfce_settings_editor_dialog_channel_monitor (XfceSettingsEditorDialog *dialog)
+{
+ GtkWidget *window;
+ gchar *channel_name;
+ gchar *title;
+ GtkWidget *scroll;
+ GtkWidget *textview;
+ GtkWidget *content_area;
+ GtkTextBuffer *buffer;
+ GTimeVal timeval;
+ gchar *str;
+ GtkTextIter iter;
+
+ if (dialog->props_channel == NULL)
+ return;
+
+ g_object_get (dialog->props_channel, "channel-name", &channel_name, NULL);
+ title = g_strdup_printf (_("Monitor %s"), channel_name);
+
+ window = xfce_titled_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ gtk_window_set_icon_name (GTK_WINDOW (window), "utilities-system-monitor");
+ gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (window),
+ _("Watch an Xfconf channel for property changes"));
+ gtk_dialog_add_buttons (GTK_DIALOG (window),
+ GTK_STOCK_CLEAR, GTK_RESPONSE_REJECT,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ g_signal_connect (G_OBJECT (window), "response",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_monitor_response),
+ g_object_ref (G_OBJECT (dialog->props_channel)));
+ gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_CLOSE);
+ g_free (title);
+
+ monitor_dialogs = g_slist_prepend (monitor_dialogs, window);
+
+ if (monitor_group == NULL)
+ monitor_group = gtk_window_group_new ();
+ gtk_window_group_add_window (monitor_group, GTK_WINDOW (window));
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
+ gtk_box_pack_start (GTK_BOX (content_area), scroll, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (scroll), 6);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_widget_show (scroll);
+
+ buffer = gtk_text_buffer_new (NULL);
+ g_object_set_data_full (G_OBJECT (window), "buffer", buffer, g_object_unref);
+ gtk_text_buffer_create_tag (buffer, "monospace", "font", "monospace", NULL);
+ g_signal_connect (G_OBJECT (dialog->props_channel), "property-changed",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_monitor_changed), window);
+
+ g_get_current_time (&timeval);
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+ str = g_strdup_printf ("%ld: ", timeval.tv_sec);
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, str, -1, "monospace", NULL);
+ g_free (str);
+
+ str = g_strdup_printf (_("start monitoring channel \"%s\""), channel_name);
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, str, -1, "monospace", NULL);
+ g_free (str);
+
+ textview = gtk_text_view_new_with_buffer (buffer);
+ gtk_container_add (GTK_CONTAINER (scroll), textview);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_NONE);
+ gtk_widget_show (textview);
+
+ gtk_window_present_with_time (GTK_WINDOW (window), gtk_get_current_event_time ());
+
+ g_free (channel_name);
+}
+
+
+
+static gboolean
+xfce_settings_editor_dialog_channel_menu (XfceSettingsEditorDialog *dialog)
+{
+ GtkWidget *menu;
+ GtkWidget *mi;
+ gchar *channel_name;
+ GtkWidget *image;
+
+ if (dialog->props_channel == NULL)
+ return FALSE;
+
+ menu = gtk_menu_new ();
+ g_signal_connect (G_OBJECT (menu), "selection-done",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+
+ g_object_get (dialog->props_channel, "channel-name", &channel_name, NULL);
+ mi = gtk_menu_item_new_with_label (channel_name);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_widget_set_sensitive (mi, FALSE);
+ gtk_widget_show (mi);
+ g_free (channel_name);
+
+ mi = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_widget_show (mi);
+
+ mi = gtk_image_menu_item_new_with_mnemonic (_("_Reset"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ g_signal_connect_swapped (G_OBJECT (mi), "activate",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_reset), dialog);
+ gtk_widget_show (mi);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_REVERT_TO_SAVED, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
+ gtk_widget_show (image);
+
+ mi = gtk_image_menu_item_new_with_mnemonic (_("_Monitor"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_widget_show (mi);
+
+ image = gtk_image_new_from_icon_name ("utilities-system-monitor", GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
+ g_signal_connect_swapped (G_OBJECT (mi), "activate",
+ G_CALLBACK (xfce_settings_editor_dialog_channel_monitor), dialog);
+ gtk_widget_show (image);
+
+ mi = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_widget_show (mi);
+
+ mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_REFRESH, NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ g_signal_connect_swapped (G_OBJECT (mi), "activate",
+ G_CALLBACK (xfce_settings_editor_dialog_load_channels), dialog);
+ gtk_widget_show (mi);
+
+ gtk_menu_popup (GTK_MENU (menu),
+ NULL, NULL, NULL, NULL, 3,
+ gtk_get_current_event_time ());
+
+ return TRUE;
+}
+
+
+
+static gboolean
+xfce_settings_editor_dialog_channel_button_press (GtkWidget *treeview,
+ GdkEventButton *event,
+ XfceSettingsEditorDialog *dialog)
+{
+ guint modifiers;
+ GtkTreePath *path;
+
+ if (event->type == GDK_BUTTON_PRESS)
+ {
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
+ if (event->button == 3 || (event->button == 1 && modifiers == GDK_CONTROL_MASK))
+ {
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview), event->x, event->y,
+ &path, NULL, NULL, NULL))
+ {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+
+ return xfce_settings_editor_dialog_channel_menu (dialog);;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
+
+static gchar *
+xfce_settings_editor_dialog_selected (XfceSettingsEditorDialog *dialog,
+ gboolean *is_real_prop,
+ gboolean *is_array)
+{
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ gchar *property = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter parent_iter;
+ GValue name_val = { 0, };
+ GString *string_prop;
+ gboolean property_real = TRUE;
+ gchar *type_name;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->props_treeview));
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ model = GTK_TREE_MODEL (dialog->props_store);
+ gtk_tree_model_get (model, &iter, PROP_COLUMN_FULL, &property, -1);
+
+ /* if this is not a real property, look it up by the tree structure */
+ if (property == NULL)
+ {
+ string_prop = g_string_new (NULL);
+ for (;;)
+ {
+ gtk_tree_model_get_value (model, &iter, PROP_COLUMN_NAME, &name_val);
+ g_string_prepend (string_prop, g_value_get_string (&name_val));
+ g_string_prepend_c (string_prop, '/');
+ g_value_unset (&name_val);
+
+ if (!gtk_tree_model_iter_parent (model, &parent_iter, &iter))
+ break;
+
+ iter = parent_iter;
+ }
+ property = g_string_free (string_prop, FALSE);
+ property_real = FALSE;
+ }
+ else if (is_array != NULL)
+ {
+ gtk_tree_model_get (model, &iter, PROP_COLUMN_TYPE, &type_name, -1);
+ *is_array = g_strcmp0 (type_name, g_type_name (xfce_settings_array_type ())) == 0;
+ g_free (type_name);
+ }
+ }
+
+ if (is_real_prop != NULL)
+ *is_real_prop = property_real;
+
+ return property;
+}
+
+
+
+static void
+xfce_settings_editor_dialog_value_changed (GtkCellRenderer *renderer,
+ const gchar *str_path,
+ const GValue *new_value,
+ XfceSettingsEditorDialog *dialog)
+{
+ GtkTreeModel *model = GTK_TREE_MODEL (dialog->props_store);
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gchar *property;
+ GtkTreeSelection *selection;
+
+ g_return_if_fail (G_IS_VALUE (new_value));
+ g_return_if_fail (XFCE_IS_SETTINGS_EDITOR_DIALOG (dialog));
+
+ /* only change values on selected paths, this to avoid miss clicking */
+ path = gtk_tree_path_new_from_string (str_path);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->props_treeview));
+ if (gtk_tree_selection_path_is_selected (selection, path)
+ && gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gtk_tree_model_get (model, &iter, PROP_COLUMN_FULL, &property, -1);
+ if (G_LIKELY (property != NULL))
+ {
+ if (!xfconf_channel_is_property_locked (dialog->props_channel, property))
+ xfconf_channel_set_property (dialog->props_channel, property, new_value);
+ g_free (property);
+ }
+ }
+ gtk_tree_path_free (path);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_selection_changed (GtkTreeSelection *selection,
+ XfceSettingsEditorDialog *dialog)
+{
+ gchar *property;
+ gboolean can_edit = FALSE;
+ gboolean can_reset = FALSE;
+ gboolean is_real_prop = TRUE;
+ gboolean is_array = FALSE;
+
+ g_return_if_fail (dialog->props_channel == NULL
+ || XFCONF_IS_CHANNEL (dialog->props_channel));
+
+ /* do nothing if the entre channel is locked */
+ if (dialog->props_channel != NULL
+ && gtk_widget_get_sensitive (dialog->button_new))
+ {
+ property = xfce_settings_editor_dialog_selected (dialog, &is_real_prop, &is_array);
+
+ can_edit = !xfconf_channel_is_property_locked (dialog->props_channel, property);
+ can_reset = can_edit && is_real_prop;
+
+ if (is_array)
+ can_edit = FALSE;
+
+ g_free (property);
+ }
+
+ gtk_widget_set_sensitive (dialog->button_edit, can_edit);
+ gtk_widget_set_sensitive (dialog->button_reset, can_reset);
+}
+
+
+
+static gboolean
+xfce_settings_editor_dialog_query_tooltip (GtkWidget *treeview,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ XfceSettingsEditorDialog *dialog)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GValue value = { 0, };
+ GtkTreeModel *model;
+ gboolean show = FALSE;
+ const gchar *text;
+ GtkTreeViewColumn *column;
+ GList *columns;
+ gint idx;
+
+ gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (treeview), x, y, &x, &y);
+
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview), x, y, &path,
+ &column, NULL, NULL))
+ {
+ columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (treeview));
+ idx = g_list_index (columns, column);
+ g_list_free (columns);
+
+ model = GTK_TREE_MODEL (dialog->props_store);
+ if (idx < 2 && gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gtk_tree_model_get_value (model, &iter,
+ idx == 0 ? PROP_COLUMN_FULL : PROP_COLUMN_TYPE, &value);
+
+ text = g_value_get_string (&value);
+ if (text != NULL)
+ {
+ gtk_tooltip_set_text (tooltip, text);
+ show = TRUE;
+ }
+ g_value_unset (&value);
+ }
+
+ gtk_tree_path_free (path);
+ }
+
+ return show;
+}
+
+
+
+static void
+xfce_settings_editor_dialog_row_activated (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ XfceSettingsEditorDialog *dialog)
+{
+ GtkTreeModel *model = GTK_TREE_MODEL (dialog->props_store);
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_get_iter (model, &iter, path))
+ {
+ if (gtk_tree_model_iter_has_child (model, &iter))
+ {
+ if (gtk_tree_view_row_expanded (treeview, path))
+ gtk_tree_view_collapse_row (treeview, path);
+ else
+ gtk_tree_view_expand_row (treeview, path, FALSE);
+ }
+ else if (gtk_widget_is_sensitive (dialog->button_edit))
+ {
+ xfce_settings_editor_dialog_property_edit (dialog);
+ }
+ }
+}
+
+
+
+static gboolean
+xfce_settings_editor_dialog_key_press_event (GtkTreeView *treeview,
+ GdkEventKey *event,
+ XfceSettingsEditorDialog *dialog)
+{
+ if (event->keyval == GDK_Delete
+ && gtk_widget_get_sensitive (dialog->button_reset))
+ {
+ xfce_settings_editor_dialog_property_reset (dialog);
+ return TRUE;
+ }
+ else if (event->keyval == GDK_Insert
+ && gtk_widget_get_sensitive (dialog->button_new))
+ {
+ xfce_settings_editor_dialog_property_new (dialog);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_dialog (XfceSettingsEditorDialog *dialog,
+ gboolean make_new)
+{
+ GtkWidget *prop_dialog;
+ gchar *property;
+
+ property = xfce_settings_editor_dialog_selected (dialog, NULL, NULL);
+
+ prop_dialog = xfce_settings_prop_dialog_new (GTK_WINDOW (dialog),
+ dialog->props_channel,
+ make_new ? NULL : property);
+ if (make_new)
+ {
+ /* hint for the parent property based on selected property */
+ xfce_settings_prop_dialog_set_parent_property (
+ XFCE_SETTINGS_PROP_DIALOG (prop_dialog), property);
+ }
+
+ gtk_dialog_run (GTK_DIALOG (prop_dialog));
+ gtk_widget_destroy (prop_dialog);
+
+ g_free (property);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_new (XfceSettingsEditorDialog *dialog)
+{
+ xfce_settings_editor_dialog_property_dialog (dialog, TRUE);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_edit (XfceSettingsEditorDialog *dialog)
+{
+ xfce_settings_editor_dialog_property_dialog (dialog, FALSE);
+}
+
+
+
+static void
+xfce_settings_editor_dialog_property_reset (XfceSettingsEditorDialog *dialog)
+{
+ gchar *property;
+
+ property = xfce_settings_editor_dialog_selected (dialog, NULL, NULL);
+ if (property != NULL
+ && xfce_dialog_confirm (GTK_WINDOW (dialog),
+ GTK_STOCK_REVERT_TO_SAVED, _("_Reset"),
+ _("Resetting a property will permanently remove those custom settings."),
+ _("Are you sure you want to reset property \"%s\"?"), property))
+ {
+ xfconf_channel_reset_property (dialog->props_channel, property, FALSE);
+ }
+
+ g_free (property);
+}
+
+
+
+GtkWidget *
+xfce_settings_editor_dialog_new (void)
+{
+ return g_object_new (XFCE_TYPE_SETTINGS_EDITOR_DIALOG, NULL);
+}
diff --git a/xfce4-settings-editor/xfce-settings-editor-dialog.h b/xfce4-settings-editor/xfce-settings-editor-dialog.h
new file mode 100644
index 0000000..6acd90a
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-editor-dialog.h
@@ -0,0 +1,46 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2008 Brian Tarricone <bjt23 at cornell.edu>
+ * Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
+ * Copyright (c) 2009-2010 Jérôme Guelfucci <jeromeg at xfce.org>
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFCE_SETTINGS_EDITOR_DIALOG_H__
+#define __XFCE_SETTINGS_EDITOR_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+#define XFCE_TYPE_SETTINGS_EDITOR_DIALOG (xfce_settings_editor_dialog_get_type ())
+#define XFCE_SETTINGS_EDITOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SETTINGS_EDITOR_DIALOG, XfceSettingsEditorDialog))
+#define XFCE_SETTINGS_EDITOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SETTINGS_EDITOR_DIALOG, XfceSettingsEditorDialogClass))
+#define XFCE_IS_SETTINGS_EDITOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SETTINGS_EDITOR_DIALOG))
+#define XFCE_IS_SETTINGS_EDITOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SETTINGS_EDITOR_DIALOG))
+#define XFCE_SETTINGS_EDITOR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SETTINGS_EDITOR_DIALOG, XfceSettingsEditorDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _XfceSettingsEditorDialog XfceSettingsEditorDialog;
+typedef struct _XfceSettingsEditorDialogClass XfceSettingsEditorDialogClass;
+
+GType xfce_settings_editor_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget *xfce_settings_editor_dialog_new (void);
+
+G_END_DECLS
+
+#endif /* __XFCE_SETTINGS_EDITOR_DIALOG_H__ */
diff --git a/xfce4-settings-editor/xfce-settings-marshal.list b/xfce4-settings-editor/xfce-settings-marshal.list
new file mode 100644
index 0000000..e72aa4b
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-marshal.list
@@ -0,0 +1 @@
+VOID:STRING,BOXED
diff --git a/xfce4-settings-editor/xfce-settings-prop-dialog.c b/xfce4-settings-editor/xfce-settings-prop-dialog.c
new file mode 100644
index 0000000..4a137ba
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-prop-dialog.c
@@ -0,0 +1,690 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
+
+#include "xfce-settings-prop-dialog.h"
+
+
+
+struct _XfceSettingsPropDialogClass
+{
+ GtkDialogClass __parent__;
+};
+
+struct _XfceSettingsPropDialog
+{
+ GtkDialog __parent__;
+
+ XfconfChannel *channel;
+
+ GValue prop_value;
+
+ GtkWidget *prop_name;
+ GtkWidget *prop_type;
+ GtkWidget *prop_string;
+ GtkWidget *prop_integer;
+ GtkWidget *prop_bool;
+};
+
+typedef struct
+{
+ const gchar *name;
+ GType type;
+}
+ValueTypes;
+
+
+
+static void xfce_settings_prop_dialog_finalize (GObject *object);
+static void xfce_settings_prop_dialog_response (GtkDialog *widget,
+ gint response_id);
+static void xfce_settings_prop_dialog_visible_bind (GtkWidget *widget,
+ GtkWidget *label);
+static void xfce_settings_prop_dialog_entry_validate (GtkWidget *entry,
+ XfceSettingsPropDialog *dialog);
+static void xfce_settings_prop_dialog_button_toggled (GtkWidget *button);
+static void xfce_settings_prop_dialog_type_changed (GtkWidget *combo,
+ XfceSettingsPropDialog *dialog);
+
+
+
+G_DEFINE_TYPE (XfceSettingsPropDialog, xfce_settings_prop_dialog, GTK_TYPE_DIALOG)
+
+
+
+static ValueTypes value_types[] =
+{
+ { N_("Empty"), G_TYPE_NONE },
+ { N_("String"), G_TYPE_STRING },
+ { N_("Boolean"), G_TYPE_BOOLEAN },
+ { N_("Int"), G_TYPE_INT },
+ { N_("Double"), G_TYPE_DOUBLE },
+ { N_("Unsigned Int"), G_TYPE_UINT },
+ { N_("Int64"), G_TYPE_INT64 },
+ { N_("Unsigned Int64"), G_TYPE_UINT64 }
+};
+
+
+
+enum
+{
+ COLUMN_NAME,
+ COLUMN_ID,
+ N_COLUMNS
+};
+
+
+
+static void
+xfce_settings_prop_dialog_class_init (XfceSettingsPropDialogClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkDialogClass *gtkdialog_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_settings_prop_dialog_finalize;
+
+ gtkdialog_class = GTK_DIALOG_CLASS (klass);
+ gtkdialog_class->response = xfce_settings_prop_dialog_response;
+}
+
+
+
+static void
+xfce_settings_prop_dialog_init (XfceSettingsPropDialog *dialog)
+{
+ GtkWidget *table;
+ GtkWidget *content_area;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *combo;
+ GtkWidget *spin;
+ GtkWidget *toggle;
+ GtkListStore *store;
+ guint i;
+ GtkCellRenderer *render;
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("New Property"));
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 200);
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ table = gtk_table_new (5, 2, FALSE);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_start (GTK_BOX (content_area), table, TRUE, TRUE, 0);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+ gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+ gtk_widget_show (table);
+
+ label = gtk_label_new_with_mnemonic (_("_Property:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_set_row_spacing (GTK_TABLE (table), 0, 6);
+ gtk_widget_show (label);
+
+ dialog->prop_name = entry = gtk_entry_new ();
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ xfce_settings_prop_dialog_visible_bind (entry, label);
+ g_signal_connect (G_OBJECT (entry), "changed",
+ G_CALLBACK (xfce_settings_prop_dialog_entry_validate), dialog);
+ gtk_widget_show (entry);
+
+ label = gtk_label_new_with_mnemonic (_("_Type:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ GTK_FILL, GTK_FILL, 0, 0);
+ gtk_widget_show (label);
+
+ store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_UINT);
+ for (i = 0; i < G_N_ELEMENTS (value_types); i++)
+ {
+ gtk_list_store_insert_with_values (store, NULL, i,
+ COLUMN_NAME, _(value_types[i].name),
+ COLUMN_ID, i, -1);
+ }
+
+ dialog->prop_type = combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_table_set_row_spacing (GTK_TABLE (table), 1, 6);
+ xfce_settings_prop_dialog_visible_bind (combo, label);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (xfce_settings_prop_dialog_type_changed), dialog);
+ gtk_widget_show (combo);
+ g_object_unref (G_OBJECT (store));
+
+ render = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), render, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), render,
+ "text", COLUMN_NAME);
+
+ /* strings */
+ label = gtk_label_new_with_mnemonic (_("_Value:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ entry = dialog->prop_string = gtk_entry_new ();
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ xfce_settings_prop_dialog_visible_bind (entry, label);
+
+ /* integers */
+ label = gtk_label_new_with_mnemonic (_("_Value:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ spin = dialog->prop_integer = gtk_spin_button_new_with_range (0.00, 0.00, 1.00);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE);
+ gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 3, 4,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ xfce_settings_prop_dialog_visible_bind (spin, label);
+
+ /* bool */
+ label = gtk_label_new_with_mnemonic (_("_Value:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ toggle = dialog->prop_bool = gtk_toggle_button_new_with_label ("FALSE");
+ g_signal_connect (G_OBJECT (toggle), "toggled",
+ G_CALLBACK (xfce_settings_prop_dialog_button_toggled), NULL);
+ gtk_table_attach (GTK_TABLE (table), toggle, 1, 2, 4, 5,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ xfce_settings_prop_dialog_visible_bind (toggle, label);
+}
+
+
+
+static void
+xfce_settings_prop_dialog_finalize (GObject *object)
+{
+ XfceSettingsPropDialog *dialog = XFCE_SETTINGS_PROP_DIALOG (object);
+
+ if (dialog->channel != NULL)
+ g_object_unref (G_OBJECT (dialog->channel));
+
+ if (G_IS_VALUE (&dialog->prop_value))
+ g_value_unset (&dialog->prop_value);
+
+ G_OBJECT_CLASS (xfce_settings_prop_dialog_parent_class)->finalize (object);
+}
+
+
+
+static void
+xfce_settings_prop_dialog_response (GtkDialog *widget,
+ gint response_id)
+{
+ XfceSettingsPropDialog *dialog = XFCE_SETTINGS_PROP_DIALOG (widget);
+ const gchar *property;
+ ValueTypes *value_type;
+ GValue value = { 0, };
+ gdouble spin_value;
+ gint active;
+
+ g_return_if_fail (XFCONF_IS_CHANNEL (dialog->channel));
+
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ property = gtk_entry_get_text (GTK_ENTRY (dialog->prop_name));
+
+ active = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->prop_type));
+ g_assert (active >= 0 && active < (gint) G_N_ELEMENTS (value_types));
+ value_type = &value_types[active];
+
+ spin_value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->prop_integer));
+
+ switch (value_type->type)
+ {
+ case G_TYPE_NONE:
+ return;
+
+ case G_TYPE_STRING:
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value,
+ gtk_entry_get_text (GTK_ENTRY (dialog->prop_string)));
+ break;
+
+ case G_TYPE_BOOLEAN:
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->prop_bool)));
+ break;
+
+ case G_TYPE_INT:
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, spin_value);
+ break;
+
+ case G_TYPE_DOUBLE:
+ g_value_init (&value, G_TYPE_DOUBLE);
+ g_value_set_double (&value, spin_value);
+ break;
+
+ case G_TYPE_UINT:
+ g_value_init (&value, G_TYPE_UINT);
+ g_value_set_uint (&value, spin_value);
+ break;
+
+ case G_TYPE_INT64:
+ g_value_init (&value, G_TYPE_INT64);
+ g_value_set_int64 (&value, spin_value);
+ break;
+
+ case G_TYPE_UINT64:
+ g_value_init (&value, G_TYPE_UINT64);
+ g_value_set_uint64 (&value, spin_value);
+ break;
+ }
+
+ if (G_IS_VALUE (&value))
+ {
+ xfconf_channel_set_property (dialog->channel, property, &value);
+ g_value_unset (&value);
+ }
+ }
+}
+
+
+
+static void
+xfce_settings_prop_dialog_visible_changed (GtkWidget *widget,
+ GParamSpec *pspec,
+ GtkWidget *label)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ gtk_widget_set_visible (label, gtk_widget_get_visible (widget));
+}
+
+
+
+static void
+xfce_settings_prop_dialog_sensitive_changed (GtkWidget *widget,
+ GParamSpec *pspec,
+ GtkWidget *label)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ gtk_widget_set_sensitive (label, gtk_widget_get_sensitive (widget));
+}
+
+
+
+static void
+xfce_settings_prop_dialog_visible_bind (GtkWidget *widget,
+ GtkWidget *label)
+{
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
+ g_signal_connect (G_OBJECT (widget), "notify::visible",
+ G_CALLBACK (xfce_settings_prop_dialog_visible_changed), label);
+ g_signal_connect (G_OBJECT (widget), "notify::sensitive",
+ G_CALLBACK (xfce_settings_prop_dialog_sensitive_changed), label);
+}
+
+
+
+/* Copied from xfconfd/xfconf-backend.c */
+static gboolean
+xfconf_property_is_valid (const gchar *property,
+ GError **error)
+{
+ const gchar *p = property;
+
+ if (!p || *p != '/')
+ {
+ if (error != NULL)
+ {
+ g_set_error (error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
+ _("Property names must start with a '/' character"));
+ }
+ return FALSE;
+ }
+
+ p++;
+ if (!*p)
+ {
+ if (error != NULL)
+ {
+ g_set_error (error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
+ _("The root element ('/') is not a valid property name"));
+ }
+ return FALSE;
+ }
+
+ while (*p)
+ {
+ if (!(*p >= 'A' && *p <= 'Z') && !(*p >= 'a' && *p <= 'z')
+ && !(*p >= '0' && *p <= '9')
+ && *p != '_' && *p != '-' && *p != '/'
+ && !(*p == '<' || *p == '>'))
+ {
+ if (error != NULL)
+ {
+ g_set_error (error, XFCONF_ERROR,
+ XFCONF_ERROR_INVALID_PROPERTY,
+ _("Property names can only include the ASCII "
+ "characters A-Z, a-z, 0-9, '_', '-', '<' "
+ "and '>', as well as '/' as a separator"));
+ }
+ return FALSE;
+ }
+
+ if ('/' == *p && '/' == *(p - 1))
+ {
+ if (error != NULL)
+ {
+ g_set_error (error, XFCONF_ERROR,
+ XFCONF_ERROR_INVALID_PROPERTY,
+ _("Property names cannot have two or more "
+ "consecutive '/' characters"));
+ }
+ return FALSE;
+ }
+
+ p++;
+ }
+
+ if (*(p - 1) == '/')
+ {
+ if (error != NULL)
+ {
+ g_set_error (error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
+ _("Property names cannot end with a '/' character"));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+static void
+xfce_settings_prop_dialog_entry_validate (GtkWidget *entry,
+ XfceSettingsPropDialog *dialog)
+{
+ GtkWidget *save_button;
+ const gchar *text;
+ gboolean is_valid = FALSE;
+ GError *error = NULL;
+
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (text != NULL && *text != '\0')
+ {
+ is_valid = xfconf_property_is_valid (text, &error);
+
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY,
+ is_valid ? NULL : GTK_STOCK_DIALOG_ERROR);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY,
+ is_valid ? NULL : error->message);
+
+ if (error != NULL)
+ g_error_free (error);
+ }
+ else
+ {
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, NULL);
+ }
+
+ save_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_widget_set_sensitive (save_button, is_valid);
+}
+
+
+
+static void
+xfce_settings_prop_dialog_button_toggled (GtkWidget *button)
+{
+ const gchar *label;
+
+ label = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? "TRUE" : "FALSE";
+ gtk_button_set_label (GTK_BUTTON (button), label);
+}
+
+
+
+static void
+xfce_settings_prop_dialog_type_changed (GtkWidget *combo,
+ XfceSettingsPropDialog *dialog)
+{
+ gint active;
+ ValueTypes *value_type;
+ const GValue *value = &dialog->prop_value;
+
+ gtk_widget_hide (dialog->prop_string);
+ gtk_widget_hide (dialog->prop_integer);
+ gtk_widget_hide (dialog->prop_bool);
+
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (dialog->prop_integer), 0);
+ gtk_entry_set_text (GTK_ENTRY (dialog->prop_string), "");
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer), 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->prop_bool), FALSE);
+
+ active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ if (active < 0 || active >= (gint) G_N_ELEMENTS (value_types))
+ return;
+
+ value_type = &value_types[active];
+
+ switch (value_type->type)
+ {
+ case G_TYPE_NONE:
+ gtk_widget_grab_focus (dialog->prop_type);
+ return;
+
+ case G_TYPE_STRING:
+ gtk_widget_show (dialog->prop_string);
+ gtk_widget_grab_focus (dialog->prop_string);
+
+ if (G_VALUE_HOLDS_STRING (value))
+ {
+ gtk_entry_set_text (GTK_ENTRY (dialog->prop_string),
+ g_value_get_string (value));
+ }
+ break;
+
+ case G_TYPE_BOOLEAN:
+ gtk_widget_show (dialog->prop_bool);
+ gtk_widget_grab_focus (dialog->prop_bool);
+
+ if (G_VALUE_HOLDS_BOOLEAN (value))
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->prop_bool),
+ g_value_get_boolean (value));
+ }
+ break;
+
+ case G_TYPE_INT:
+ gtk_widget_show (dialog->prop_integer);
+ gtk_widget_grab_focus (dialog->prop_integer);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->prop_integer),
+ G_MININT, G_MAXINT);
+
+ if (G_VALUE_HOLDS_INT (value))
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer),
+ g_value_get_int (value));
+ }
+ break;
+
+ case G_TYPE_DOUBLE:
+ gtk_widget_show (dialog->prop_integer);
+ gtk_widget_grab_focus (dialog->prop_integer);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (dialog->prop_integer), 4);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->prop_integer),
+ G_MINDOUBLE, G_MAXDOUBLE);
+
+ if (G_VALUE_HOLDS_DOUBLE (value))
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer),
+ g_value_get_double (value));
+ }
+ break;
+
+ case G_TYPE_UINT:
+ gtk_widget_show (dialog->prop_integer);
+ gtk_widget_grab_focus (dialog->prop_integer);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->prop_integer),
+ 0, G_MAXUINT);
+
+ if (G_VALUE_HOLDS_UINT (value))
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer),
+ g_value_get_uint (value));
+ }
+ break;
+
+ case G_TYPE_INT64:
+ gtk_widget_show (dialog->prop_integer);
+ gtk_widget_grab_focus (dialog->prop_integer);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->prop_integer),
+ G_MININT64, G_MAXINT64);
+
+ if (G_VALUE_HOLDS_INT64 (value))
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer),
+ g_value_get_int64 (value));
+ }
+ break;
+
+ case G_TYPE_UINT64:
+ gtk_widget_show (dialog->prop_integer);
+ gtk_widget_grab_focus (dialog->prop_integer);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dialog->prop_integer),
+ 0, G_MAXUINT64);
+
+ if (G_VALUE_HOLDS_UINT64 (value))
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prop_integer),
+ g_value_get_uint64 (value));
+ }
+ break;
+ }
+}
+
+
+
+static void
+xfce_settings_prop_dialog_type_set_active (XfceSettingsPropDialog *dialog,
+ GType value_type)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (value_types); i++)
+ {
+ if (value_types[i].type == value_type)
+ {
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->prop_type), i);
+ break;
+ }
+ }
+}
+
+
+
+GtkWidget *
+xfce_settings_prop_dialog_new (GtkWindow *parent,
+ XfconfChannel *channel,
+ const gchar *property)
+{
+ XfceSettingsPropDialog *dialog;
+
+ g_return_val_if_fail (XFCONF_IS_CHANNEL (channel), NULL);
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
+
+ dialog = g_object_new (XFCE_TYPE_SETTINGS_PROP_DIALOG, NULL);
+
+ dialog->channel = g_object_ref (G_OBJECT (channel));
+
+ if (property != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (dialog->prop_name), property);
+ gtk_editable_set_editable (GTK_EDITABLE (dialog->prop_name), FALSE);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Property"));
+
+ if (xfconf_channel_get_property (channel, property, &dialog->prop_value))
+ {
+ xfce_settings_prop_dialog_type_set_active (dialog,
+ G_VALUE_TYPE (&dialog->prop_value));
+ gtk_widget_set_sensitive (dialog->prop_type, FALSE);
+ }
+ }
+
+ /* set the transient parent (if any) */
+ if (G_LIKELY (parent != NULL))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ }
+
+ return GTK_WIDGET (dialog);
+}
+
+
+
+void
+xfce_settings_prop_dialog_set_parent_property (XfceSettingsPropDialog *dialog,
+ const gchar *property)
+{
+ gchar *p;
+ gint length = -1;
+ gint pos = 0;
+
+ g_return_if_fail (XFCE_IS_SETTINGS_PROP_DIALOG (dialog));
+
+ if (property != NULL && *property == '/')
+ {
+ p = strrchr (property, '/');
+ if (G_LIKELY (p != NULL))
+ length = (p - property) + 1;
+
+ gtk_editable_insert_text (GTK_EDITABLE (dialog->prop_name),
+ property, length, &pos);
+ }
+}
diff --git a/xfce4-settings-editor/xfce-settings-prop-dialog.h b/xfce4-settings-editor/xfce-settings-prop-dialog.h
new file mode 100644
index 0000000..1fc7aec
--- /dev/null
+++ b/xfce4-settings-editor/xfce-settings-prop-dialog.h
@@ -0,0 +1,49 @@
+/*
+ * xfce4-settings-editor
+ *
+ * Copyright (c) 2012 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFCE_SETTINGS_PROP_DIALOG_H__
+#define __XFCE_SETTINGS_PROP_DIALOG_H__
+
+#include <gtk/gtk.h>
+#include <xfconf/xfconf.h>
+
+#define XFCE_TYPE_SETTINGS_PROP_DIALOG (xfce_settings_prop_dialog_get_type ())
+#define XFCE_SETTINGS_PROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SETTINGS_PROP_DIALOG, XfceSettingsPropDialog))
+#define XFCE_SETTINGS_PROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SETTINGS_PROP_DIALOG, XfceSettingsPropDialogClass))
+#define XFCE_IS_SETTINGS_PROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SETTINGS_PROP_DIALOG))
+#define XFCE_IS_SETTINGS_PROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SETTINGS_PROP_DIALOG))
+#define XFCE_SETTINGS_PROP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SETTINGS_PROP_DIALOG, XfceSettingsPropDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _XfceSettingsPropDialog XfceSettingsPropDialog;
+typedef struct _XfceSettingsPropDialogClass XfceSettingsPropDialogClass;
+
+GType xfce_settings_prop_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget *xfce_settings_prop_dialog_new (GtkWindow *parent,
+ XfconfChannel *channel,
+ const gchar *property);
+
+void xfce_settings_prop_dialog_set_parent_property (XfceSettingsPropDialog *dialog,
+ const gchar *property);
+
+G_END_DECLS
+
+#endif /* __XFCE_SETTINGS_PROP_DIALOG_H__ */
diff --git a/xfce4-settings-editor/xfce4-settings-editor.glade b/xfce4-settings-editor/xfce4-settings-editor.glade
deleted file mode 100644
index badc413..0000000
--- a/xfce4-settings-editor/xfce4-settings-editor.glade
+++ /dev/null
@@ -1,407 +0,0 @@
-<?xml version="1.0"?>
-<interface>
- <!-- interface-requires gtk+ 2.12 -->
- <!-- interface-requires libxfce4ui 4.5 -->
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkAdjustment" id="adjustment1">
- <property name="upper">100</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkListStore" id="model1">
- <columns>
- <!-- column-name gchararray -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">Empty</col>
- </row>
- <row>
- <col id="0" translatable="yes">String</col>
- </row>
- <row>
- <col id="0" translatable="yes">Int</col>
- </row>
- <row>
- <col id="0" translatable="yes">Unsigned Int</col>
- </row>
- <row>
- <col id="0" translatable="yes">Int64</col>
- </row>
- <row>
- <col id="0" translatable="yes">Unsigned Int64</col>
- </row>
- <row>
- <col id="0" translatable="yes">Double</col>
- </row>
- <row>
- <col id="0" translatable="yes">Boolean</col>
- </row>
- </data>
- </object>
- <object class="XfceTitledDialog" id="edit_settings_dialog">
- <property name="title" translatable="yes">Edit Property</property>
- <property name="window_position">center-on-parent</property>
- <property name="icon_name">preferences-system</property>
- <property name="type_hint">dialog</property>
- <property name="transient_for">main_dialog</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="border_width">6</property>
- <property name="n_rows">3</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkScrolledWindow" id="property_value_sw">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="property_value_treeview">
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="property_value_text_entry">
- <property name="can_focus">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="property_value_spin_button">
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="property_value_checkbutton">
- <property name="label" translatable="yes">Enabled</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_type">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Type:</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_name">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Name:</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Value:</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="property_name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="property_type_combo">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="model">model1</property>
- <child>
- <object class="GtkCellRendererText" id="renderer1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button3">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button2">
- <property name="label">gtk-save</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">button3</action-widget>
- <action-widget response="-10">button2</action-widget>
- </action-widgets>
- </object>
- <object class="XfceTitledDialog" id="main_dialog">
- <property name="title" translatable="yes">Settings Editor</property>
- <property name="icon_name">preferences-system</property>
- <property name="type_hint">normal</property>
- <property name="has_separator">False</property>
- <property name="subtitle" translatable="yes">Customize settings stored by Xfconf</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox4">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkNotebook" id="notebook2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">6</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
- <child>
- <object class="GtkHPaned" id="hpaned2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="position_set">True</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="channel_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="rules_hint">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkToolbar" id="toolbar1">
- <property name="visible">True</property>
- <child>
- <object class="GtkToolButton" id="property_new_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="tooltip_text" translatable="yes">New property</property>
- <property name="stock_id">gtk-new</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="property_edit_button">
- <property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Edit property</property>
- <property name="stock_id">gtk-edit</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="property_revert_button">
- <property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Reset property</property>
- <property name="stock_id">gtk-revert-to-saved</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="property_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">200</property>
- <property name="tab_expand">True</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Xfconf channels</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area4">
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-7">button1</action-widget>
- </action-widgets>
- </object>
-</interface>
More information about the Xfce4-commits
mailing list