aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-prefs.c
diff options
context:
space:
mode:
authorMichael Terry <mike@mterry.name>2011-02-22 15:17:48 -0600
committerMichael Terry <mike@mterry.name>2011-02-22 15:17:48 -0600
commitdeafbc1da6b3c29e04455e46414342bcb9841c2a (patch)
tree6bb04fbe40f5a5ffebb31a95b328c76d363e6379 /src/datetime-prefs.c
parent07c5056f4604b4294f42492e27ea3fcf85019dc3 (diff)
downloadayatana-indicator-datetime-deafbc1da6b3c29e04455e46414342bcb9841c2a.tar.gz
ayatana-indicator-datetime-deafbc1da6b3c29e04455e46414342bcb9841c2a.tar.bz2
ayatana-indicator-datetime-deafbc1da6b3c29e04455e46414342bcb9841c2a.zip
beginnings of completion support
Diffstat (limited to 'src/datetime-prefs.c')
-rw-r--r--src/datetime-prefs.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
index ee4b26a..dbacee1 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -36,6 +36,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "settings-shared.h"
#include "utils.h"
#include "datetime-prefs-locations.h"
+#include "timezone-completion.h"
#include "cc-timezone-map.h"
#define DATETIME_DIALOG_UI_FILE PKGDATADIR "/datetime-dialog.ui"
@@ -176,8 +177,10 @@ tz_changed (CcTimezoneMap * map, TzLocation * location)
if (location == NULL)
return;
- g_dbus_proxy_call (proxy, "SetTimezone", g_variant_new ("(s)", location->zone),
+ gchar * file = g_build_filename ("/usr/share/zoneinfo", location->zone, NULL);
+ g_dbus_proxy_call (proxy, "SetTimezone", g_variant_new ("(s)", file),
G_DBUS_CALL_FLAGS_NONE, -1, NULL, dbus_set_answered, "timezone");
+ g_free (file);
}
static void
@@ -371,6 +374,25 @@ show_locations (GtkWidget * button, GtkWidget * dlg)
gtk_widget_show_all (locationsDlg);
}
+static gboolean
+timezone_selected (GtkEntryCompletion * widget, GtkTreeModel * model,
+ GtkTreeIter * iter, gpointer user_data)
+{
+ GValue value = {0};
+ const gchar * strval;
+
+ gtk_tree_model_get_value (model, iter, TIMEZONE_COMPLETION_ZONE, &value);
+ strval = g_value_get_string (&value);
+
+ if (strval != NULL && strval[0] != 0) {
+ cc_timezone_map_set_timezone (tzmap, strval);
+ }
+
+ g_value_unset (&value);
+
+ return FALSE; // Do normal action too
+}
+
static GtkWidget *
create_dialog (void)
{
@@ -401,6 +423,12 @@ create_dialog (void)
tzmap = cc_timezone_map_new ();
gtk_container_add (GTK_CONTAINER (WIG ("mapBox")), GTK_WIDGET (tzmap));
+ /* And completion entry */
+ TimezoneCompletion * completion = timezone_completion_new ();
+ gtk_entry_set_completion (GTK_ENTRY (WIG ("timezoneEntry")),
+ GTK_ENTRY_COMPLETION (completion));
+ g_signal_connect (completion, "match-selected", G_CALLBACK (timezone_selected), NULL);
+
/* Set up settings bindings */
g_settings_bind (conf, SETTINGS_SHOW_CLOCK_S, WIG ("showClockCheck"),
"active", G_SETTINGS_BIND_DEFAULT);