aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-prefs.c
diff options
context:
space:
mode:
authorMichael Terry <mike@mterry.name>2011-02-23 14:07:19 -0500
committerMichael Terry <mike@mterry.name>2011-02-23 14:07:19 -0500
commitb3a34d487c8c3724752b522fd352c96ba0bcf1a4 (patch)
tree634b06e05dc44af9de3646e7f2f4dfe352d59561 /src/datetime-prefs.c
parentb4a4c9682ca2413175386ad36d06fc4e1032badc (diff)
downloadayatana-indicator-datetime-b3a34d487c8c3724752b522fd352c96ba0bcf1a4.tar.gz
ayatana-indicator-datetime-b3a34d487c8c3724752b522fd352c96ba0bcf1a4.tar.bz2
ayatana-indicator-datetime-b3a34d487c8c3724752b522fd352c96ba0bcf1a4.zip
add week-start controls and settings
Diffstat (limited to 'src/datetime-prefs.c')
-rw-r--r--src/datetime-prefs.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
index 622a999..44b9b24 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -29,7 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libintl.h>
#include <locale.h>
#include <langinfo.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <unique/unique.h>
#include <polkitgtk/polkitgtk.h>
@@ -85,6 +85,45 @@ bind_hours_get (GValue * value, GVariant * variant, gpointer user_data)
return TRUE;
}
+/* Turns the boolean property into a string gsettings */
+static GVariant *
+bind_week_start_set (const GValue * value, const GVariantType * type, gpointer user_data)
+{
+ const gchar * output = NULL;
+ gboolean is_sunday_button = (gboolean)GPOINTER_TO_INT(user_data);
+
+ if (g_value_get_boolean(value)) {
+ /* Only do anything if we're setting active = true */
+ output = is_sunday_button ? "sunday" : "monday";
+ } else {
+ return NULL;
+ }
+
+ return g_variant_new_string (output);
+}
+
+/* Turns a string gsettings into a boolean property */
+static gboolean
+bind_week_start_get (GValue * value, GVariant * variant, gpointer user_data)
+{
+ const gchar * str = g_variant_get_string(variant, NULL);
+ gboolean output = FALSE;
+ gboolean is_sunday_button = (gboolean)GPOINTER_TO_INT(user_data);
+
+ if (g_strcmp0(str, "locale-default") == 0) {
+ output = (is_sunday_button == is_locale_week_start_sunday ());
+ } else if (g_strcmp0(str, "sunday") == 0) {
+ output = is_sunday_button;
+ } else if (g_strcmp0(str, "monday") == 0) {
+ output = !is_sunday_button;
+ } else {
+ return FALSE;
+ }
+
+ g_value_set_boolean (value, output);
+ return TRUE;
+}
+
static void
widget_dependency_cb (GtkWidget * parent, GParamSpec *pspec, GtkWidget * dependent)
{
@@ -473,8 +512,16 @@ create_dialog (void)
"active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (conf, SETTINGS_SHOW_WEEK_NUMBERS_S, WIG ("includeWeekNumbersCheck"),
"active", G_SETTINGS_BIND_DEFAULT);
- /*g_settings_bind_(conf, SETTINGS_WEEK_BEGINS_SUNDAY_S, WIG ("startOnSundayRadio"),
- "active", G_SETTINGS_BIND_DEFAULT);*/
+ g_settings_bind_with_mapping (conf, SETTINGS_WEEK_START_S,
+ WIG ("startOnSundayRadio"), "active",
+ G_SETTINGS_BIND_DEFAULT,
+ bind_week_start_get, bind_week_start_set,
+ GINT_TO_POINTER(TRUE), NULL);
+ g_settings_bind_with_mapping (conf, SETTINGS_WEEK_START_S,
+ WIG ("startOnMondayRadio"), "active",
+ G_SETTINGS_BIND_DEFAULT,
+ bind_week_start_get, bind_week_start_set,
+ GINT_TO_POINTER(FALSE), NULL);
g_settings_bind (conf, SETTINGS_SHOW_EVENTS_S, WIG ("showEventsCheck"),
"active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (conf, SETTINGS_SHOW_LOCATIONS_S, WIG ("showLocationsCheck"),