[Xfce4-commits] [apps/xfdashboard] 01/01: Split creation and handling of tab 'General' into seperate files at xfdashboard settings application
noreply at xfce.org
noreply at xfce.org
Mon Feb 15 20:46:11 CET 2016
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 60f85a3090d68a2afa942d22b7c7572d3212de3d
Author: Stephan Haller <nomad at froevel.de>
Date: Mon Feb 15 20:45:54 2016 +0100
Split creation and handling of tab 'General' into seperate files at xfdashboard settings application
---
settings/Makefile.am | 2 +
settings/general.c | 755 +++++++++++++++++++++++++++++++++++++++++++++++++++
settings/general.h | 68 +++++
settings/settings.c | 560 ++------------------------------------
settings/themes.c | 4 +-
5 files changed, 848 insertions(+), 541 deletions(-)
diff --git a/settings/Makefile.am b/settings/Makefile.am
index df1d728..c9aef5d 100644
--- a/settings/Makefile.am
+++ b/settings/Makefile.am
@@ -9,11 +9,13 @@ bin_PROGRAMS = \
xfdashboard-settings
xfdashboard_settings_headers = \
+ general.h \
settings.h \
themes.h
xfdashboard_settings_SOURCES = \
$(xfdashboard_settings_headers) \
+ general.c \
main.c \
settings.c \
themes.c
diff --git a/settings/general.c b/settings/general.c
new file mode 100644
index 0000000..2422850
--- /dev/null
+++ b/settings/general.c
@@ -0,0 +1,755 @@
+/*
+ * themes: Theme settings of application
+ *
+ * Copyright 2012-2016 Stephan Haller <nomad at froevel.de>
+ *
+ * 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 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
+
+#include "general.h"
+
+#include <glib/gi18n-lib.h>
+#include <xfconf/xfconf.h>
+#include <math.h>
+
+
+/* Define this class in GObject system */
+G_DEFINE_TYPE(XfdashboardSettingsGeneral,
+ xfdashboard_settings_general,
+ G_TYPE_OBJECT)
+
+/* Private structure - access only by public API if needed */
+#define XFDASHBOARD_SETTINGS_GENERAL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), XFDASHBOARD_TYPE_SETTINGS_GENERAL, XfdashboardSettingsGeneralPrivate))
+
+struct _XfdashboardSettingsGeneralPrivate
+{
+ /* Properties related */
+ GtkBuilder *builder;
+
+ /* Instance related */
+ XfconfChannel *xfconfChannel;
+
+ GtkWidget *widgetResetSearchOnResume;
+ GtkWidget *widgetSwitchToViewOnResume;
+ GtkWidget *widgetMinNotificationTimeout;
+ GtkWidget *widgetEnableUnmappedWindowWorkaround;
+ GtkWidget *widgetWindowCreationPriority;
+ GtkWidget *widgetAlwaysLaunchNewInstance;
+ GtkWidget *widgetShowAllApps;
+ GtkWidget *widgetScrollEventChangesWorkspace;
+ GtkWidget *widgetDelaySearchTimeout;
+};
+
+/* Properties */
+enum
+{
+ PROP_0,
+
+ PROP_BUILDER,
+
+ PROP_LAST
+};
+
+static GParamSpec* XfdashboardSettingsGeneralProperties[PROP_LAST]={ 0, };
+
+
+/* IMPLEMENTATION: Private variables and methods */
+#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
+
+#define RESET_SEARCH_ON_RESUME_XFCONF_PROP "/reset-search-on-resume"
+#define DEFAULT_RESET_SEARCH_ON_RESUME TRUE
+
+#define SWITCH_TO_VIEW_ON_RESUME_XFCONF_PROP "/switch-to-view-on-resume"
+#define DEFAULT_SWITCH_TO_VIEW_ON_RESUME NULL
+
+#define MIN_NOTIFICATION_TIMEOUT_XFCONF_PROP "/min-notification-timeout"
+#define DEFAULT_MIN_NOTIFICATION_TIMEOUT 3000
+
+#define ENABLE_UNMAPPED_WINDOW_WORKAROUND_XFCONF_PROP "enable-unmapped-window-workaround"
+#define DEFAULT_ENABLE_UNMAPPED_WINDOW_WORKAROUND FALSE
+
+#define ALWAYS_LAUNCH_NEW_INSTANCE "/always-launch-new-instance"
+#define DEFAULT_ALWAYS_LAUNCH_NEW_INSTANCE TRUE
+
+#define SHOW_ALL_APPS_XFCONF_PROP "/components/applications-view/show-all-apps"
+#define DEFAULT_SHOW_ALL_APPS FALSE
+
+#define SCROLL_EVENT_CHANGES_WORKSPACE_XFCONF_PROP "/components/windows-view/scroll-event-changes-workspace"
+#define DEFAULT_SCROLL_EVENT_CHANGES_WORKSPACE FALSE
+
+#define DELAY_SEARCH_TIMEOUT_XFCONF_PROP "/components/search-view/delay-search-timeout"
+#define DEFAULT_DELAY_SEARCH_TIMEOUT 0
+
+#define WINDOW_CONTENT_CREATION_PRIORITY_XFCONF_PROP "/window-content-creation-priority"
+#define DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY "immediate"
+
+
+typedef struct _XfdashboardSettingsGeneralNameValuePair XfdashboardSettingsGeneralNameValuePair;
+struct _XfdashboardSettingsGeneralNameValuePair
+{
+ const gchar *displayName;
+ const gchar *value;
+};
+
+static XfdashboardSettingsGeneralNameValuePair _xfdashboard_settings_general_resumable_views_values[]=
+{
+ { N_("Do nothing"), "" },
+ { N_("Windows view"), "windows" },
+ { N_("Applications view"), "applications" },
+ { NULL, NULL }
+};
+
+static XfdashboardSettingsGeneralNameValuePair _xfdashboard_settings_general_window_creation_priorities_values[]=
+{
+ { N_("Immediately"), "immediate", },
+ { N_("High"), "high"},
+ { N_("Normal"), "normal" },
+ { N_("Low"), "low" },
+ { NULL, NULL },
+};
+
+
+/* Setting '/switch-to-view-on-resume' changed either at widget or at xfconf property */
+static void _xfdashboard_settings_general_switch_to_view_on_resume_changed_by_widget(XfdashboardSettingsGeneral *self,
+ GtkComboBox *inComboBox)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *value;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(GTK_IS_COMBO_BOX(inComboBox));
+
+ priv=self->priv;
+
+ /* Get selected entry from combo box */
+ model=gtk_combo_box_get_model(inComboBox);
+ gtk_combo_box_get_active_iter(inComboBox, &iter);
+ gtk_tree_model_get(model, &iter, 1, &value, -1);
+
+ /* Set value at xfconf property */
+ xfconf_channel_set_string(priv->xfconfChannel, SWITCH_TO_VIEW_ON_RESUME_XFCONF_PROP, value);
+
+ /* Release allocated resources */
+ if(value) g_free(value);
+}
+
+static void _xfdashboard_settings_general_switch_to_view_on_resume_changed_by_xfconf(XfdashboardSettingsGeneral *self,
+ const gchar *inProperty,
+ const GValue *inValue,
+ XfconfChannel *inChannel)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *value;
+ const gchar *newValue;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(inValue);
+ g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
+
+ priv=self->priv;
+
+ /* Get new value to lookup and set at combo box */
+ if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue="";
+ else newValue=g_value_get_string(inValue);
+
+ /* Iterate through combo box value and set new value if match is found */
+ model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetSwitchToViewOnResume));
+ if(gtk_tree_model_get_iter_first(model, &iter))
+ {
+ do
+ {
+ gtk_tree_model_get(model, &iter, 1, &value, -1);
+ if(G_UNLIKELY(g_str_equal(value, newValue)))
+ {
+ g_free(value);
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchToViewOnResume), &iter);
+ break;
+ }
+ g_free(value);
+ }
+ while(gtk_tree_model_iter_next(model, &iter));
+ }
+}
+
+/* Setting '/window-content-creation-priority' changed either at widget or at xfconf property */
+static void _xfdashboard_settings_general_window_creation_priority_changed_by_widget(XfdashboardSettingsGeneral *self,
+ GtkComboBox *inComboBox)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *value;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(GTK_IS_COMBO_BOX(inComboBox));
+
+ priv=self->priv;
+
+ /* Get selected entry from combo box */
+ model=gtk_combo_box_get_model(inComboBox);
+ gtk_combo_box_get_active_iter(inComboBox, &iter);
+ gtk_tree_model_get(model, &iter, 1, &value, -1);
+
+ /* Set value at xfconf property */
+ xfconf_channel_set_string(priv->xfconfChannel, WINDOW_CONTENT_CREATION_PRIORITY_XFCONF_PROP, value);
+
+ /* Release allocated resources */
+ if(value) g_free(value);
+}
+
+static void _xfdashboard_settings_general_window_creation_priority_changed_by_xfconf(XfdashboardSettingsGeneral *self,
+ const gchar *inProperty,
+ const GValue *inValue,
+ XfconfChannel *inChannel)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *value;
+ const gchar *newValue;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(inValue);
+ g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
+
+ priv=self->priv;
+
+ /* Get new value to lookup and set at combo box */
+ if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue=DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY;
+ else newValue=g_value_get_string(inValue);
+
+ /* Iterate through combo box value and set new value if match is found */
+ model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetWindowCreationPriority));
+ if(gtk_tree_model_get_iter_first(model, &iter))
+ {
+ do
+ {
+ gtk_tree_model_get(model, &iter, 1, &value, -1);
+ if(G_UNLIKELY(g_str_equal(value, newValue)))
+ {
+ g_free(value);
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), &iter);
+ break;
+ }
+ g_free(value);
+ }
+ while(gtk_tree_model_iter_next(model, &iter));
+ }
+}
+
+/* Setting '/min-notification-timeout' changed either at widget or at xfconf property */
+static void _xfdashboard_settings_general_notification_timeout_changed_by_widget(XfdashboardSettingsGeneral *self,
+ GtkRange *inRange)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ guint value;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(GTK_IS_RANGE(inRange));
+
+ priv=self->priv;
+
+ /* Get value from widget */
+ value=floor(gtk_range_get_value(inRange)*1000);
+
+ /* Set value at xfconf property */
+ xfconf_channel_set_uint(priv->xfconfChannel, MIN_NOTIFICATION_TIMEOUT_XFCONF_PROP, value);
+}
+
+static void _xfdashboard_settings_general_notification_timeout_changed_by_xfconf(XfdashboardSettingsGeneral *self,
+ const gchar *inProperty,
+ const GValue *inValue,
+ XfconfChannel *inChannel)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ guint newValue;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(inValue);
+ g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
+
+ priv=self->priv;
+
+ /* Get new value to set at widget */
+ if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_UINT)) newValue=DEFAULT_MIN_NOTIFICATION_TIMEOUT;
+ else newValue=g_value_get_uint(inValue);
+
+ /* Set new value at widget */
+ gtk_range_set_value(GTK_RANGE(priv->widgetMinNotificationTimeout), newValue/1000.0);
+}
+
+/* Format value to show in notification timeout slider */
+static gchar* _xfdashboard_settings_general_on_format_notification_timeout_value(GtkScale *inWidget,
+ gdouble inValue,
+ gpointer inUserData)
+{
+ gchar *text;
+
+ text=g_strdup_printf("%.1f %s", inValue, _("seconds"));
+
+ return(text);
+}
+
+/* Setting '/components/search-view/delay-search-timeout' changed either at widget or at xfconf property */
+static void _xfdashboard_settings_general_delay_search_timeout_changed_by_widget(XfdashboardSettingsGeneral *self,
+ GtkRange *inRange)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ guint value;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(GTK_IS_RANGE(inRange));
+
+ priv=self->priv;
+
+ /* Get value from widget */
+ value=floor(gtk_range_get_value(inRange));
+
+ /* Set value at xfconf property */
+ xfconf_channel_set_uint(priv->xfconfChannel, DELAY_SEARCH_TIMEOUT_XFCONF_PROP, value);
+}
+
+static void _xfdashboard_settings_general_delay_search_timeout_changed_by_xfconf(XfdashboardSettingsGeneral *self,
+ const gchar *inProperty,
+ const GValue *inValue,
+ XfconfChannel *inChannel)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+ guint newValue;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(inValue);
+ g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
+
+ priv=self->priv;
+
+ /* Get new value to set at widget */
+ if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_UINT)) newValue=DEFAULT_DELAY_SEARCH_TIMEOUT;
+ else newValue=g_value_get_uint(inValue);
+
+ /* Set new value at widget */
+ gtk_range_set_value(GTK_RANGE(priv->widgetDelaySearchTimeout), (gdouble)newValue);
+}
+
+/* Format value to show in delay search timeout slider */
+static gchar* _xfdashboard_settings_general_on_format_delay_search_timeout_value(GtkScale *inWidget,
+ gdouble inValue,
+ gpointer inUserData)
+{
+ gchar *text;
+
+ if(inValue>0.0)
+ {
+ text=g_strdup_printf("%u %s", (guint)inValue, _("ms"));
+ }
+ else
+ {
+ text=g_strdup(_("Immediately"));
+ }
+
+ return(text);
+}
+
+/* Create and set up GtkBuilder */
+static void _xfdashboard_settings_general_set_builder(XfdashboardSettingsGeneral *self,
+ GtkBuilder *inBuilder)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_SETTINGS_GENERAL(self));
+ g_return_if_fail(GTK_IS_BUILDER(inBuilder));
+
+ priv=self->priv;
+
+ /* Set builder object which must not be set yet */
+ g_assert(!priv->builder);
+
+ priv->builder=g_object_ref(inBuilder);
+
+ /* Get widgets from builder */
+ priv->widgetResetSearchOnResume=GTK_WIDGET(gtk_builder_get_object(priv->builder, "reset-search-on-resume"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetResetSearchOnResume), DEFAULT_RESET_SEARCH_ON_RESUME);
+ xfconf_g_property_bind(priv->xfconfChannel,
+ RESET_SEARCH_ON_RESUME_XFCONF_PROP,
+ G_TYPE_BOOLEAN,
+ priv->widgetResetSearchOnResume,
+ "active");
+
+ priv->widgetSwitchToViewOnResume=GTK_WIDGET(gtk_builder_get_object(priv->builder, "switch-to-view-on-resume"));
+ if(priv->widgetSwitchToViewOnResume)
+ {
+ GtkCellRenderer *renderer;
+ GtkListStore *listStore;
+ GtkTreeIter listStoreIter;
+ GtkTreeIter *defaultListStoreIter;
+ XfdashboardSettingsGeneralNameValuePair *iter;
+ gchar *defaultValue;
+
+ /* Get default value from settings */
+ defaultValue=xfconf_channel_get_string(priv->xfconfChannel, SWITCH_TO_VIEW_ON_RESUME_XFCONF_PROP, DEFAULT_SWITCH_TO_VIEW_ON_RESUME);
+ if(!defaultValue) defaultValue=g_strdup("");
+
+ /* Clear combo box */
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(priv->widgetSwitchToViewOnResume));
+
+ /* Set up renderer for combo box */
+ renderer=gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->widgetSwitchToViewOnResume), renderer, TRUE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->widgetSwitchToViewOnResume), renderer, "text", 0);
+
+ /* Set up list to show at combo box */
+ defaultListStoreIter=NULL;
+ listStore=gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+ for(iter=_xfdashboard_settings_general_resumable_views_values; iter->displayName; ++iter)
+ {
+ gtk_list_store_append(listStore, &listStoreIter);
+ gtk_list_store_set(listStore, &listStoreIter, 0, _(iter->displayName), 1, iter->value, -1);
+ if(!g_strcmp0(iter->value, defaultValue))
+ {
+ defaultListStoreIter=gtk_tree_iter_copy(&listStoreIter);
+ }
+ }
+ gtk_combo_box_set_model(GTK_COMBO_BOX(priv->widgetSwitchToViewOnResume), GTK_TREE_MODEL(listStore));
+ g_object_unref(G_OBJECT(listStore));
+
+ /* Set up default value */
+ if(defaultListStoreIter)
+ {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchToViewOnResume), defaultListStoreIter);
+ gtk_tree_iter_free(defaultListStoreIter);
+ defaultListStoreIter=NULL;
+ }
+
+ /* Connect signals */
+ g_signal_connect_swapped(priv->widgetSwitchToViewOnResume,
+ "changed",
+ G_CALLBACK(_xfdashboard_settings_general_switch_to_view_on_resume_changed_by_widget),
+ self);
+ g_signal_connect_swapped(priv->xfconfChannel,
+ "property-changed::"SWITCH_TO_VIEW_ON_RESUME_XFCONF_PROP,
+ G_CALLBACK(_xfdashboard_settings_general_switch_to_view_on_resume_changed_by_xfconf),
+ self);
+
+ /* Release allocated resources */
+ if(defaultValue) g_free(defaultValue);
+ }
+
+ priv->widgetMinNotificationTimeout=GTK_WIDGET(gtk_builder_get_object(priv->builder, "notification-timeout"));
+ if(priv->widgetMinNotificationTimeout)
+ {
+ GtkAdjustment *adjustment;
+ gdouble defaultValue;
+
+ /* Get default value */
+ defaultValue=xfconf_channel_get_uint(priv->xfconfChannel, MIN_NOTIFICATION_TIMEOUT_XFCONF_PROP, DEFAULT_MIN_NOTIFICATION_TIMEOUT)/1000.0;
+
+ /* Set up scaling settings of widget */
+ adjustment=GTK_ADJUSTMENT(gtk_builder_get_object(priv->builder, "notification-timeout-adjustment"));
+ gtk_range_set_adjustment(GTK_RANGE(priv->widgetMinNotificationTimeout), adjustment);
+
+ /* Set up default value */
+ gtk_range_set_value(GTK_RANGE(priv->widgetMinNotificationTimeout), defaultValue);
+
+ /* Connect signals */
+ g_signal_connect(priv->widgetMinNotificationTimeout,
+ "format-value",
+ G_CALLBACK(_xfdashboard_settings_general_on_format_notification_timeout_value),
+ NULL);
+ g_signal_connect_swapped(priv->widgetMinNotificationTimeout,
+ "value-changed",
+ G_CALLBACK(_xfdashboard_settings_general_notification_timeout_changed_by_widget),
+ self);
+ g_signal_connect_swapped(priv->xfconfChannel,
+ "property-changed::"MIN_NOTIFICATION_TIMEOUT_XFCONF_PROP,
+ G_CALLBACK(_xfdashboard_settings_general_notification_timeout_changed_by_xfconf),
+ self);
+ }
+
+ priv->widgetEnableUnmappedWindowWorkaround=GTK_WIDGET(gtk_builder_get_object(priv->builder, ENABLE_UNMAPPED_WINDOW_WORKAROUND_XFCONF_PROP));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetEnableUnmappedWindowWorkaround), DEFAULT_ENABLE_UNMAPPED_WINDOW_WORKAROUND);
+ xfconf_g_property_bind(priv->xfconfChannel,
+ "/enable-unmapped-window-workaround",
+ G_TYPE_BOOLEAN,
+ priv->widgetEnableUnmappedWindowWorkaround,
+ "active");
+
+ priv->widgetAlwaysLaunchNewInstance=GTK_WIDGET(gtk_builder_get_object(priv->builder, "always-launch-new-instance"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetAlwaysLaunchNewInstance), DEFAULT_ALWAYS_LAUNCH_NEW_INSTANCE);
+ xfconf_g_property_bind(priv->xfconfChannel,
+ ALWAYS_LAUNCH_NEW_INSTANCE,
+ G_TYPE_BOOLEAN,
+ priv->widgetAlwaysLaunchNewInstance,
+ "active");
+
+ priv->widgetShowAllApps=GTK_WIDGET(gtk_builder_get_object(priv->builder, "show-all-apps"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetShowAllApps), DEFAULT_SHOW_ALL_APPS);
+ xfconf_g_property_bind(priv->xfconfChannel,
+ SHOW_ALL_APPS_XFCONF_PROP,
+ G_TYPE_BOOLEAN,
+ priv->widgetShowAllApps,
+ "active");
+
+ priv->widgetScrollEventChangesWorkspace=GTK_WIDGET(gtk_builder_get_object(priv->builder, "scroll-event-changes-workspace"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetScrollEventChangesWorkspace), DEFAULT_SCROLL_EVENT_CHANGES_WORKSPACE);
+ xfconf_g_property_bind(priv->xfconfChannel,
+ SCROLL_EVENT_CHANGES_WORKSPACE_XFCONF_PROP,
+ G_TYPE_BOOLEAN,
+ priv->widgetScrollEventChangesWorkspace,
+ "active");
+
+ priv->widgetDelaySearchTimeout=GTK_WIDGET(gtk_builder_get_object(priv->builder, "delay-search-timeout"));
+ if(priv->widgetDelaySearchTimeout)
+ {
+ GtkAdjustment *adjustment;
+ gdouble defaultValue;
+
+ /* Get default value */
+ defaultValue=xfconf_channel_get_uint(priv->xfconfChannel, DELAY_SEARCH_TIMEOUT_XFCONF_PROP, DEFAULT_DELAY_SEARCH_TIMEOUT);
+
+ /* Set up scaling settings of widget */
+ adjustment=GTK_ADJUSTMENT(gtk_builder_get_object(priv->builder, "delay-search-timeout-adjustment"));
+ gtk_range_set_adjustment(GTK_RANGE(priv->widgetDelaySearchTimeout), adjustment);
+
+ /* Set up default value */
+ gtk_range_set_value(GTK_RANGE(priv->widgetDelaySearchTimeout), defaultValue);
+
+ /* Connect signals */
+ g_signal_connect(priv->widgetDelaySearchTimeout,
+ "format-value",
+ G_CALLBACK(_xfdashboard_settings_general_on_format_delay_search_timeout_value),
+ NULL);
+ g_signal_connect_swapped(priv->widgetDelaySearchTimeout,
+ "value-changed",
+ G_CALLBACK(_xfdashboard_settings_general_delay_search_timeout_changed_by_widget),
+ self);
+ g_signal_connect_swapped(priv->xfconfChannel,
+ "property-changed::"DELAY_SEARCH_TIMEOUT_XFCONF_PROP,
+ G_CALLBACK(_xfdashboard_settings_general_delay_search_timeout_changed_by_xfconf),
+ self);
+ }
+
+ priv->widgetWindowCreationPriority=GTK_WIDGET(gtk_builder_get_object(priv->builder, "window-creation-priority"));
+ if(priv->widgetWindowCreationPriority)
+ {
+ GtkCellRenderer *renderer;
+ GtkListStore *listStore;
+ GtkTreeIter listStoreIter;
+ GtkTreeIter *defaultListStoreIter;
+ XfdashboardSettingsGeneralNameValuePair *iter;
+ gchar *defaultValue;
+
+ /* Get default value from settings */
+ defaultValue=xfconf_channel_get_string(priv->xfconfChannel, WINDOW_CONTENT_CREATION_PRIORITY_XFCONF_PROP, DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY);
+ if(!defaultValue) defaultValue=g_strdup(_xfdashboard_settings_general_window_creation_priorities_values[0].value);
+
+ /* Clear combo box */
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority));
+
+ /* Set up renderer for combo box */
+ renderer=gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority), renderer, TRUE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority), renderer, "text", 0);
+
+ /* Set up list to show at combo box */
+ defaultListStoreIter=NULL;
+ listStore=gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+ for(iter=_xfdashboard_settings_general_window_creation_priorities_values; iter->displayName; ++iter)
+ {
+ gtk_list_store_append(listStore, &listStoreIter);
+ gtk_list_store_set(listStore, &listStoreIter, 0, _(iter->displayName), 1, iter->value, -1);
+ if(!g_strcmp0(iter->value, defaultValue))
+ {
+ defaultListStoreIter=gtk_tree_iter_copy(&listStoreIter);
+ }
+ }
+ gtk_combo_box_set_model(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), GTK_TREE_MODEL(listStore));
+ g_object_unref(G_OBJECT(listStore));
+
+ /* Set up default value */
+ if(defaultListStoreIter)
+ {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), defaultListStoreIter);
+ gtk_tree_iter_free(defaultListStoreIter);
+ defaultListStoreIter=NULL;
+ }
+
+ /* Connect signals */
+ g_signal_connect_swapped(priv->widgetWindowCreationPriority,
+ "changed",
+ G_CALLBACK(_xfdashboard_settings_general_window_creation_priority_changed_by_widget),
+ self);
+ g_signal_connect_swapped(priv->xfconfChannel,
+ "property-changed::"WINDOW_CONTENT_CREATION_PRIORITY_XFCONF_PROP,
+ G_CALLBACK(_xfdashboard_settings_general_window_creation_priority_changed_by_xfconf),
+ self);
+
+ /* Release allocated resources */
+ if(defaultValue) g_free(defaultValue);
+ }
+}
+
+/* IMPLEMENTATION: GObject */
+
+/* Dispose this object */
+static void _xfdashboard_settings_general_dispose(GObject *inObject)
+{
+ XfdashboardSettingsGeneral *self=XFDASHBOARD_SETTINGS_GENERAL(inObject);
+ XfdashboardSettingsGeneralPrivate *priv=self->priv;
+
+ /* Release allocated resouces */
+ priv->widgetResetSearchOnResume=NULL;
+ priv->widgetSwitchToViewOnResume=NULL;
+ priv->widgetMinNotificationTimeout=NULL;
+ priv->widgetEnableUnmappedWindowWorkaround=NULL;
+ priv->widgetWindowCreationPriority=NULL;
+ priv->widgetAlwaysLaunchNewInstance=NULL;
+ priv->widgetScrollEventChangesWorkspace=NULL;
+ priv->widgetDelaySearchTimeout=NULL;
+
+ if(priv->builder)
+ {
+ g_object_unref(priv->builder);
+ priv->builder=NULL;
+ }
+
+ if(priv->xfconfChannel)
+ {
+ priv->xfconfChannel=NULL;
+ }
+
+ /* Call parent's class dispose method */
+ G_OBJECT_CLASS(xfdashboard_settings_general_parent_class)->dispose(inObject);
+}
+
+/* Set/get properties */
+static void _xfdashboard_settings_general_set_property(GObject *inObject,
+ guint inPropID,
+ const GValue *inValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardSettingsGeneral *self=XFDASHBOARD_SETTINGS_GENERAL(inObject);
+
+ switch(inPropID)
+ {
+ case PROP_BUILDER:
+ _xfdashboard_settings_general_set_builder(self, GTK_BUILDER(g_value_get_object(inValue)));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
+ break;
+ }
+}
+
+static void _xfdashboard_settings_general_get_property(GObject *inObject,
+ guint inPropID,
+ GValue *outValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardSettingsGeneral *self=XFDASHBOARD_SETTINGS_GENERAL(inObject);
+ XfdashboardSettingsGeneralPrivate *priv=self->priv;
+
+ switch(inPropID)
+ {
+ case PROP_BUILDER:
+ g_value_set_object(outValue, priv->builder);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
+ break;
+ }
+}
+
+/* Class initialization
+ * Override functions in parent classes and define properties
+ * and signals
+ */
+static void xfdashboard_settings_general_class_init(XfdashboardSettingsGeneralClass *klass)
+{
+ GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
+
+ /* Override functions */
+ gobjectClass->dispose=_xfdashboard_settings_general_dispose;
+ gobjectClass->set_property=_xfdashboard_settings_general_set_property;
+ gobjectClass->get_property=_xfdashboard_settings_general_get_property;
+
+ /* Set up private structure */
+ g_type_class_add_private(klass, sizeof(XfdashboardSettingsGeneralPrivate));
+
+ /* Define properties */
+ XfdashboardSettingsGeneralProperties[PROP_BUILDER]=
+ g_param_spec_object("builder",
+ _("Builder"),
+ _("The initialized GtkBuilder object where to set up themes tab from"),
+ GTK_TYPE_BUILDER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardSettingsGeneralProperties);
+}
+
+/* Object initialization
+ * Create private structure and set up default values
+ */
+static void xfdashboard_settings_general_init(XfdashboardSettingsGeneral *self)
+{
+ XfdashboardSettingsGeneralPrivate *priv;
+
+ priv=self->priv=XFDASHBOARD_SETTINGS_GENERAL_GET_PRIVATE(self);
+
+ /* Set default values */
+ priv->builder=NULL;
+
+ priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL);
+
+ priv->widgetResetSearchOnResume=NULL;
+ priv->widgetSwitchToViewOnResume=NULL;
+ priv->widgetMinNotificationTimeout=NULL;
+ priv->widgetEnableUnmappedWindowWorkaround=NULL;
+ priv->widgetWindowCreationPriority=NULL;
+ priv->widgetAlwaysLaunchNewInstance=NULL;
+ priv->widgetScrollEventChangesWorkspace=NULL;
+ priv->widgetDelaySearchTimeout=NULL;
+}
+
+/* IMPLEMENTATION: Public API */
+
+/* Create instance of this class */
+XfdashboardSettingsGeneral* xfdashboard_settings_general_new(GtkBuilder *inBuilder)
+{
+ GObject *instance;
+
+ g_return_val_if_fail(GTK_IS_BUILDER(inBuilder), NULL);
+
+ /* Create instance */
+ instance=g_object_new(XFDASHBOARD_TYPE_SETTINGS_GENERAL,
+ "builder", inBuilder,
+ NULL);
+
+ /* Return newly created instance */
+ return(XFDASHBOARD_SETTINGS_GENERAL(instance));
+}
diff --git a/settings/general.h b/settings/general.h
new file mode 100644
index 0000000..a71ad8b
--- /dev/null
+++ b/settings/general.h
@@ -0,0 +1,68 @@
+/*
+ * themes: Theme settings of application
+ *
+ * Copyright 2012-2016 Stephan Haller <nomad at froevel.de>
+ *
+ * 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 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 __XFDASHBOARD_SETTINGS_GENERAL__
+#define __XFDASHBOARD_SETTINGS_GENERAL__
+
+#include <gtk/gtkx.h>
+
+G_BEGIN_DECLS
+
+#define XFDASHBOARD_TYPE_SETTINGS_GENERAL (xfdashboard_settings_general_get_type())
+#define XFDASHBOARD_SETTINGS_GENERAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_SETTINGS_GENERAL, XfdashboardSettingsGeneral))
+#define XFDASHBOARD_IS_SETTINGS_GENERAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_SETTINGS_GENERAL))
+#define XFDASHBOARD_SETTINGS_GENERAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_SETTINGS_GENERAL, XfdashboardSettingsGeneralClass))
+#define XFDASHBOARD_IS_SETTINGS_GENERAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_SETTINGS_GENERAL))
+#define XFDASHBOARD_SETTINGS_GENERAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_SETTINGS_GENERAL, XfdashboardSettingsGeneralClass))
+
+typedef struct _XfdashboardSettingsGeneral XfdashboardSettingsGeneral;
+typedef struct _XfdashboardSettingsGeneralClass XfdashboardSettingsGeneralClass;
+typedef struct _XfdashboardSettingsGeneralPrivate XfdashboardSettingsGeneralPrivate;
+
+struct _XfdashboardSettingsGeneral
+{
+ /* Parent instance */
+ GObject parent_instance;
+
+ /* Private structure */
+ XfdashboardSettingsGeneralPrivate *priv;
+};
+
+struct _XfdashboardSettingsGeneralClass
+{
+ /*< private >*/
+ /* Parent class */
+ GObjectClass parent_class;
+
+ /*< public >*/
+ /* Virtual functions */
+};
+
+/* Public API */
+GType xfdashboard_settings_general_get_type(void) G_GNUC_CONST;
+
+XfdashboardSettingsGeneral* xfdashboard_settings_general_new(GtkBuilder *inBuilder);
+
+G_END_DECLS
+
+#endif /* __XFDASHBOARD_SETTINGS_GENERAL__ */
diff --git a/settings/settings.c b/settings/settings.c
index 334b712..f1f1a19 100644
--- a/settings/settings.c
+++ b/settings/settings.c
@@ -31,6 +31,7 @@
#include <xfconf/xfconf.h>
#include <math.h>
+#include "general.h"
#include "themes.h"
@@ -46,314 +47,21 @@ G_DEFINE_TYPE(XfdashboardSettings,
struct _XfdashboardSettingsPrivate
{
/* Instance related */
- XfconfChannel *xfconfChannel;
-
- GtkBuilder *builder;
-
- GtkWidget *widgetCloseButton;
- GtkWidget *widgetResetSearchOnResume;
- GtkWidget *widgetSwitchViewOnResume;
- GtkWidget *widgetNotificationTimeout;
- GtkWidget *widgetEnableUnmappedWindowWorkaround;
- GtkWidget *widgetWindowCreationPriority;
- GtkWidget *widgetAlwaysLaunchNewInstance;
- GtkWidget *widgetShowAllApps;
- GtkWidget *widgetScrollEventChangedWorkspace;
- GtkWidget *widgetDelaySearchTimeout;
-
- XfdashboardSettingsThemes *themes;
-};
-
-
-/* IMPLEMENTATION: Private variables and methods */
-#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
-#define PREFERENCES_UI_FILE "preferences.ui"
-#define XFDASHBOARD_THEME_SUBPATH "xfdashboard-1.0"
-#define XFDASHBOARD_THEME_FILE "xfdashboard.theme"
-#define XFDASHBOARD_THEME_GROUP "Xfdashboard Theme"
-#define DEFAULT_DELAY_SEARCH_TIMEOUT 0
-#define DEFAULT_NOTIFICATION_TIMEOUT 3000
-#define DEFAULT_RESET_SEARCH_ON_RESUME TRUE
-#define DEFAULT_SWITCH_VIEW_ON_RESUME NULL
-#define DEFAULT_THEME "xfdashboard"
-#define DEFAULT_ENABLE_HOTKEY FALSE
-#define DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY "immediate"
-#define DEFAULT_LAUNCH_NEW_INSTANCE TRUE
-#define MAX_SCREENSHOT_WIDTH 400
-
-typedef struct _XfdashboardSettingsResumableViews XfdashboardSettingsResumableViews;
-struct _XfdashboardSettingsResumableViews
-{
- const gchar *displayName;
- const gchar *viewName;
-};
+ XfconfChannel *xfconfChannel;
-static XfdashboardSettingsResumableViews resumableViews[]=
-{
- { N_("Do nothing"), "" },
- { N_("Windows view"), "windows" },
- { N_("Applications view"), "applications" },
- { NULL, NULL }
-};
+ GtkBuilder *builder;
-typedef struct _XfdashboardSettingsWindowContentPriority XfdashboardSettingsWindowContentPriority;
-struct _XfdashboardSettingsWindowContentPriority
-{
- const gchar *displayName;
- const gchar *priorityName;
-};
+ XfdashboardSettingsGeneral *general;
+ XfdashboardSettingsThemes *themes;
-static XfdashboardSettingsWindowContentPriority windowCreationPriorities[]=
-{
- { N_("Immediately"), "immediate", },
- { N_("High"), "high"},
- { N_("Normal"), "normal" },
- { N_("Low"), "low" },
- { NULL, NULL },
+ GtkWidget *widgetCloseButton;
};
-/* Setting '/switch-to-view-on-resume' changed either at widget or at xfconf property */
-static void _xfdashboard_settings_widget_changed_switch_view_on_resume(XfdashboardSettings *self, GtkComboBox *inComboBox)
-{
- XfdashboardSettingsPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *value;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(GTK_IS_COMBO_BOX(inComboBox));
-
- priv=self->priv;
-
- /* Get selected entry from combo box */
- model=gtk_combo_box_get_model(inComboBox);
- gtk_combo_box_get_active_iter(inComboBox, &iter);
- gtk_tree_model_get(model, &iter, 1, &value, -1);
-
- /* Set value at xfconf property */
- xfconf_channel_set_string(priv->xfconfChannel, "/switch-to-view-on-resume", value);
-
- /* Release allocated resources */
- if(value) g_free(value);
-}
-
-static void _xfdashboard_settings_xfconf_changed_switch_view_on_resume(XfdashboardSettings *self,
- const gchar *inProperty,
- const GValue *inValue,
- XfconfChannel *inChannel)
-{
- XfdashboardSettingsPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *value;
- const gchar *newValue;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(inValue);
- g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
-
- priv=self->priv;
-
- /* Get new value to lookup and set at combo box */
- if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue="";
- else newValue=g_value_get_string(inValue);
-
- /* Iterate through combo box value and set new value if match is found */
- model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume));
- if(gtk_tree_model_get_iter_first(model, &iter))
- {
- do
- {
- gtk_tree_model_get(model, &iter, 1, &value, -1);
- if(G_UNLIKELY(g_str_equal(value, newValue)))
- {
- g_free(value);
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume), &iter);
- break;
- }
- g_free(value);
- }
- while(gtk_tree_model_iter_next(model, &iter));
- }
-}
-
-/* Setting '/window-content-creation-priority' changed either at widget or at xfconf property */
-static void _xfdashboard_settings_widget_changed_window_creation_priority(XfdashboardSettings *self, GtkComboBox *inComboBox)
-{
- XfdashboardSettingsPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *value;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(GTK_IS_COMBO_BOX(inComboBox));
-
- priv=self->priv;
-
- /* Get selected entry from combo box */
- model=gtk_combo_box_get_model(inComboBox);
- gtk_combo_box_get_active_iter(inComboBox, &iter);
- gtk_tree_model_get(model, &iter, 1, &value, -1);
-
- /* Set value at xfconf property */
- xfconf_channel_set_string(priv->xfconfChannel, "/window-content-creation-priority", value);
-
- /* Release allocated resources */
- if(value) g_free(value);
-}
-
-static void _xfdashboard_settings_xfconf_changed_window_creation_priority(XfdashboardSettings *self,
- const gchar *inProperty,
- const GValue *inValue,
- XfconfChannel *inChannel)
-{
- XfdashboardSettingsPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *value;
- const gchar *newValue;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(inValue);
- g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
-
- priv=self->priv;
-
- /* Get new value to lookup and set at combo box */
- if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue=DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY;
- else newValue=g_value_get_string(inValue);
-
- /* Iterate through combo box value and set new value if match is found */
- model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetWindowCreationPriority));
- if(gtk_tree_model_get_iter_first(model, &iter))
- {
- do
- {
- gtk_tree_model_get(model, &iter, 1, &value, -1);
- if(G_UNLIKELY(g_str_equal(value, newValue)))
- {
- g_free(value);
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), &iter);
- break;
- }
- g_free(value);
- }
- while(gtk_tree_model_iter_next(model, &iter));
- }
-}
-
-/* Setting '/min-notification-timeout' changed either at widget or at xfconf property */
-static void _xfdashboard_settings_widget_changed_notification_timeout(XfdashboardSettings *self, GtkRange *inRange)
-{
- XfdashboardSettingsPrivate *priv;
- guint value;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(GTK_IS_RANGE(inRange));
-
- priv=self->priv;
-
- /* Get value from widget */
- value=floor(gtk_range_get_value(inRange)*1000);
-
- /* Set value at xfconf property */
- xfconf_channel_set_uint(priv->xfconfChannel, "/min-notification-timeout", value);
-}
-
-static void _xfdashboard_settings_xfconf_changed_notification_timeout(XfdashboardSettings *self,
- const gchar *inProperty,
- const GValue *inValue,
- XfconfChannel *inChannel)
-{
- XfdashboardSettingsPrivate *priv;
- guint newValue;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(inValue);
- g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
-
- priv=self->priv;
-
- /* Get new value to set at widget */
- if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_UINT)) newValue=DEFAULT_NOTIFICATION_TIMEOUT;
- else newValue=g_value_get_uint(inValue);
-
- /* Set new value at widget */
- gtk_range_set_value(GTK_RANGE(priv->widgetNotificationTimeout), newValue/1000.0);
-}
-
-/* Format value to show in notification timeout slider */
-static gchar* _xfdashboard_settings_on_format_notification_timeout_value(GtkScale *inWidget,
- gdouble inValue,
- gpointer inUserData)
-{
- gchar *text;
-
- text=g_strdup_printf("%.1f %s", inValue, _("seconds"));
-
- return(text);
-}
-
-/* Setting '/components/search-view/delay-search-timeout' changed either at widget or at xfconf property */
-static void _xfdashboard_settings_widget_changed_delay_search_timeout(XfdashboardSettings *self, GtkRange *inRange)
-{
- XfdashboardSettingsPrivate *priv;
- guint value;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(GTK_IS_RANGE(inRange));
-
- priv=self->priv;
-
- /* Get value from widget */
- value=floor(gtk_range_get_value(inRange));
-
- /* Set value at xfconf property */
- xfconf_channel_set_uint(priv->xfconfChannel, "/components/search-view/delay-search-timeout", value);
-}
-
-static void _xfdashboard_settings_xfconf_changed_delay_search_timeout(XfdashboardSettings *self,
- const gchar *inProperty,
- const GValue *inValue,
- XfconfChannel *inChannel)
-{
- XfdashboardSettingsPrivate *priv;
- guint newValue;
-
- g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
- g_return_if_fail(inValue);
- g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));
-
- priv=self->priv;
-
- /* Get new value to set at widget */
- if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_UINT)) newValue=DEFAULT_DELAY_SEARCH_TIMEOUT;
- else newValue=g_value_get_uint(inValue);
-
- /* Set new value at widget */
- gtk_range_set_value(GTK_RANGE(priv->widgetDelaySearchTimeout), (gdouble)newValue);
-}
-
-/* Format value to show in delay search timeout slider */
-static gchar* _xfdashboard_settings_on_format_delay_search_timeout_value(GtkScale *inWidget,
- gdouble inValue,
- gpointer inUserData)
-{
- gchar *text;
-
- if(inValue>0.0)
- {
- text=g_strdup_printf("%u %s", (guint)inValue, _("ms"));
- }
- else
- {
- text=g_strdup(_("Immediately"));
- }
-
- return(text);
-}
+/* IMPLEMENTATION: Private variables and methods */
+#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
+#define PREFERENCES_UI_FILE "preferences.ui"
/* Close button was clicked */
@@ -447,233 +155,15 @@ static gboolean _xfdashboard_settings_create_builder(XfdashboardSettings *self)
priv->builder=GTK_BUILDER(g_object_ref(builder));
g_debug("Loaded UI resources from '%s' successfully.", builderFile);
- /* Tab: General */
- priv->widgetResetSearchOnResume=GTK_WIDGET(gtk_builder_get_object(priv->builder, "reset-search-on-resume"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetResetSearchOnResume), DEFAULT_RESET_SEARCH_ON_RESUME);
- xfconf_g_property_bind(priv->xfconfChannel,
- "/reset-search-on-resume",
- G_TYPE_BOOLEAN,
- priv->widgetResetSearchOnResume,
- "active");
-
-
- priv->widgetSwitchViewOnResume=GTK_WIDGET(gtk_builder_get_object(priv->builder, "switch-to-view-on-resume"));
- if(priv->widgetSwitchViewOnResume)
- {
- GtkCellRenderer *renderer;
- GtkListStore *listStore;
- GtkTreeIter listStoreIter;
- GtkTreeIter *defaultListStoreIter;
- XfdashboardSettingsResumableViews *iter;
- gchar *defaultValue;
-
- /* Get default value from settings */
- defaultValue=xfconf_channel_get_string(priv->xfconfChannel, "/switch-to-view-on-resume", DEFAULT_SWITCH_VIEW_ON_RESUME);
- if(!defaultValue) defaultValue=g_strdup("");
-
- /* Clear combo box */
- gtk_cell_layout_clear(GTK_CELL_LAYOUT(priv->widgetSwitchViewOnResume));
-
- /* Set up renderer for combo box */
- renderer=gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->widgetSwitchViewOnResume), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->widgetSwitchViewOnResume), renderer, "text", 0);
-
- /* Set up list to show at combo box */
- defaultListStoreIter=NULL;
- listStore=gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
- for(iter=resumableViews; iter->displayName; ++iter)
- {
- gtk_list_store_append(listStore, &listStoreIter);
- gtk_list_store_set(listStore, &listStoreIter, 0, _(iter->displayName), 1, iter->viewName, -1);
- if(!g_strcmp0(iter->viewName, defaultValue))
- {
- defaultListStoreIter=gtk_tree_iter_copy(&listStoreIter);
- }
- }
- gtk_combo_box_set_model(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume), GTK_TREE_MODEL(listStore));
- g_object_unref(G_OBJECT(listStore));
-
- /* Set up default value */
- if(defaultListStoreIter)
- {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume), defaultListStoreIter);
- gtk_tree_iter_free(defaultListStoreIter);
- defaultListStoreIter=NULL;
- }
-
- /* Connect signals */
- g_signal_connect_swapped(priv->widgetSwitchViewOnResume,
- "changed",
- G_CALLBACK(_xfdashboard_settings_widget_changed_switch_view_on_resume),
- self);
- g_signal_connect_swapped(priv->xfconfChannel,
- "property-changed::/switch-to-view-on-resume",
- G_CALLBACK(_xfdashboard_settings_xfconf_changed_switch_view_on_resume),
- self);
-
- /* Release allocated resources */
- if(defaultValue) g_free(defaultValue);
- }
-
- priv->widgetNotificationTimeout=GTK_WIDGET(gtk_builder_get_object(priv->builder, "notification-timeout"));
- if(priv->widgetNotificationTimeout)
- {
- GtkAdjustment *adjustment;
- gdouble defaultValue;
-
- /* Get default value */
- defaultValue=xfconf_channel_get_uint(priv->xfconfChannel, "/min-notification-timeout", DEFAULT_NOTIFICATION_TIMEOUT)/1000.0;
-
- /* Set up scaling settings of widget */
- adjustment=GTK_ADJUSTMENT(gtk_builder_get_object(priv->builder, "notification-timeout-adjustment"));
- gtk_range_set_adjustment(GTK_RANGE(priv->widgetNotificationTimeout), adjustment);
-
- /* Set up default value */
- gtk_range_set_value(GTK_RANGE(priv->widgetNotificationTimeout), defaultValue);
-
- /* Connect signals */
- g_signal_connect(priv->widgetNotificationTimeout,
- "format-value",
- G_CALLBACK(_xfdashboard_settings_on_format_notification_timeout_value),
- NULL);
- g_signal_connect_swapped(priv->widgetNotificationTimeout,
- "value-changed",
- G_CALLBACK(_xfdashboard_settings_widget_changed_notification_timeout),
- self);
- g_signal_connect_swapped(priv->xfconfChannel,
- "property-changed::/min-notification-timeout",
- G_CALLBACK(_xfdashboard_settings_xfconf_changed_notification_timeout),
- self);
- }
-
- priv->widgetEnableUnmappedWindowWorkaround=GTK_WIDGET(gtk_builder_get_object(priv->builder, "enable-unmapped-window-workaround"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetEnableUnmappedWindowWorkaround), FALSE);
- xfconf_g_property_bind(priv->xfconfChannel,
- "/enable-unmapped-window-workaround",
- G_TYPE_BOOLEAN,
- priv->widgetEnableUnmappedWindowWorkaround,
- "active");
-
- priv->widgetAlwaysLaunchNewInstance=GTK_WIDGET(gtk_builder_get_object(priv->builder, "always-launch-new-instance"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetAlwaysLaunchNewInstance), DEFAULT_LAUNCH_NEW_INSTANCE);
- xfconf_g_property_bind(priv->xfconfChannel,
- "/always-launch-new-instance",
- G_TYPE_BOOLEAN,
- priv->widgetAlwaysLaunchNewInstance,
- "active");
-
- priv->widgetShowAllApps=GTK_WIDGET(gtk_builder_get_object(priv->builder, "show-all-apps"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetShowAllApps), FALSE);
- xfconf_g_property_bind(priv->xfconfChannel,
- "/components/applications-view/show-all-apps",
- G_TYPE_BOOLEAN,
- priv->widgetShowAllApps,
- "active");
-
- priv->widgetScrollEventChangedWorkspace=GTK_WIDGET(gtk_builder_get_object(priv->builder, "scroll-event-changes-workspace"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->widgetScrollEventChangedWorkspace), FALSE);
- xfconf_g_property_bind(priv->xfconfChannel,
- "/components/windows-view/scroll-event-changes-workspace",
- G_TYPE_BOOLEAN,
- priv->widgetScrollEventChangedWorkspace,
- "active");
-
- priv->widgetDelaySearchTimeout=GTK_WIDGET(gtk_builder_get_object(priv->builder, "delay-search-timeout"));
- if(priv->widgetDelaySearchTimeout)
- {
- GtkAdjustment *adjustment;
- gdouble defaultValue;
-
- /* Get default value */
- defaultValue=xfconf_channel_get_uint(priv->xfconfChannel, "/components/search-view/delay-search-timeout", DEFAULT_DELAY_SEARCH_TIMEOUT);
-
- /* Set up scaling settings of widget */
- adjustment=GTK_ADJUSTMENT(gtk_builder_get_object(priv->builder, "delay-search-timeout-adjustment"));
- gtk_range_set_adjustment(GTK_RANGE(priv->widgetDelaySearchTimeout), adjustment);
-
- /* Set up default value */
- gtk_range_set_value(GTK_RANGE(priv->widgetDelaySearchTimeout), defaultValue);
-
- /* Connect signals */
- g_signal_connect(priv->widgetDelaySearchTimeout,
- "format-value",
- G_CALLBACK(_xfdashboard_settings_on_format_delay_search_timeout_value),
- NULL);
- g_signal_connect_swapped(priv->widgetDelaySearchTimeout,
- "value-changed",
- G_CALLBACK(_xfdashboard_settings_widget_changed_delay_search_timeout),
- self);
- g_signal_connect_swapped(priv->xfconfChannel,
- "property-changed::/components/search-view/delay-search-timeout",
- G_CALLBACK(_xfdashboard_settings_xfconf_changed_delay_search_timeout),
- self);
- }
-
+ /* Setup common widgets */
priv->widgetCloseButton=GTK_WIDGET(gtk_builder_get_object(priv->builder, "close-button"));
g_signal_connect_swapped(priv->widgetCloseButton,
"clicked",
G_CALLBACK(_xfdashboard_settings_on_close_clicked),
self);
- priv->widgetWindowCreationPriority=GTK_WIDGET(gtk_builder_get_object(priv->builder, "window-creation-priority"));
- if(priv->widgetWindowCreationPriority)
- {
- GtkCellRenderer *renderer;
- GtkListStore *listStore;
- GtkTreeIter listStoreIter;
- GtkTreeIter *defaultListStoreIter;
- XfdashboardSettingsWindowContentPriority *iter;
- gchar *defaultValue;
-
- /* Get default value from settings */
- defaultValue=xfconf_channel_get_string(priv->xfconfChannel, "/window-content-creation-priority", DEFAULT_WINDOW_CONTENT_CREATION_PRIORITY);
- if(!defaultValue) defaultValue=g_strdup(windowCreationPriorities[0].priorityName);
-
- /* Clear combo box */
- gtk_cell_layout_clear(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority));
-
- /* Set up renderer for combo box */
- renderer=gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->widgetWindowCreationPriority), renderer, "text", 0);
-
- /* Set up list to show at combo box */
- defaultListStoreIter=NULL;
- listStore=gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
- for(iter=windowCreationPriorities; iter->displayName; ++iter)
- {
- gtk_list_store_append(listStore, &listStoreIter);
- gtk_list_store_set(listStore, &listStoreIter, 0, _(iter->displayName), 1, iter->priorityName, -1);
- if(!g_strcmp0(iter->priorityName, defaultValue))
- {
- defaultListStoreIter=gtk_tree_iter_copy(&listStoreIter);
- }
- }
- gtk_combo_box_set_model(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), GTK_TREE_MODEL(listStore));
- g_object_unref(G_OBJECT(listStore));
-
- /* Set up default value */
- if(defaultListStoreIter)
- {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetWindowCreationPriority), defaultListStoreIter);
- gtk_tree_iter_free(defaultListStoreIter);
- defaultListStoreIter=NULL;
- }
-
- /* Connect signals */
- g_signal_connect_swapped(priv->widgetWindowCreationPriority,
- "changed",
- G_CALLBACK(_xfdashboard_settings_widget_changed_window_creation_priority),
- self);
- g_signal_connect_swapped(priv->xfconfChannel,
- "property-changed::/window-content-creation-priority",
- G_CALLBACK(_xfdashboard_settings_xfconf_changed_window_creation_priority),
- self);
-
- /* Release allocated resources */
- if(defaultValue) g_free(defaultValue);
- }
+ /* Tab: General */
+ priv->general=xfdashboard_settings_general_new(builder);
/* Tab: Themes */
priv->themes=xfdashboard_settings_themes_new(builder);
@@ -686,6 +176,7 @@ static gboolean _xfdashboard_settings_create_builder(XfdashboardSettings *self)
return(TRUE);
}
+
/* IMPLEMENTATION: GObject */
/* Dispose this object */
@@ -696,14 +187,6 @@ static void _xfdashboard_settings_dispose(GObject *inObject)
/* Release allocated resouces */
priv->widgetCloseButton=NULL;
- priv->widgetResetSearchOnResume=NULL;
- priv->widgetSwitchViewOnResume=NULL;
- priv->widgetNotificationTimeout=NULL;
- priv->widgetEnableUnmappedWindowWorkaround=NULL;
- priv->widgetWindowCreationPriority=NULL;
- priv->widgetAlwaysLaunchNewInstance=NULL;
- priv->widgetScrollEventChangedWorkspace=NULL;
- priv->widgetDelaySearchTimeout=NULL;
if(priv->themes)
{
@@ -711,6 +194,12 @@ static void _xfdashboard_settings_dispose(GObject *inObject)
priv->themes=NULL;
}
+ if(priv->general)
+ {
+ g_object_unref(priv->general);
+ priv->general=NULL;
+ }
+
if(priv->xfconfChannel)
{
priv->xfconfChannel=NULL;
@@ -752,17 +241,10 @@ static void xfdashboard_settings_init(XfdashboardSettings *self)
/* Set default values */
priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL);
-
priv->builder=NULL;
+ priv->themes=NULL;
+ priv->general=NULL;
priv->widgetCloseButton=NULL;
- priv->widgetResetSearchOnResume=NULL;
- priv->widgetSwitchViewOnResume=NULL;
- priv->widgetNotificationTimeout=NULL;
- priv->widgetEnableUnmappedWindowWorkaround=NULL;
- priv->widgetWindowCreationPriority=NULL;
- priv->widgetAlwaysLaunchNewInstance=NULL;
- priv->widgetScrollEventChangedWorkspace=NULL;
- priv->widgetDelaySearchTimeout=NULL;
}
/* IMPLEMENTATION: Public API */
diff --git a/settings/themes.c b/settings/themes.c
index d00e63c..d6fe75e 100644
--- a/settings/themes.c
+++ b/settings/themes.c
@@ -74,13 +74,13 @@ static GParamSpec* XfdashboardSettingsThemesProperties[PROP_LAST]={ 0, };
/* IMPLEMENTATION: Private variables and methods */
#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
+
#define THEME_XFCONF_PROP "/theme"
#define DEFAULT_THEME "xfdashboard"
#define XFDASHBOARD_THEME_SUBPATH "xfdashboard-1.0"
#define XFDASHBOARD_THEME_FILE "xfdashboard.theme"
#define XFDASHBOARD_THEME_GROUP "Xfdashboard Theme"
-#define DEFAULT_ENABLE_HOTKEY FALSE
#define MAX_SCREENSHOT_WIDTH 400
enum
@@ -735,7 +735,7 @@ static void _xfdashboard_settings_themes_populate_themes_list(XfdashboardSetting
/* Create and set up GtkBuilder */
static void _xfdashboard_settings_themes_set_builder(XfdashboardSettingsThemes *self,
- GtkBuilder *inBuilder)
+ GtkBuilder *inBuilder)
{
XfdashboardSettingsThemesPrivate *priv;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list