From 2e0741e34ffdc0666bbd307e13f1ff59e73f27a6 Mon Sep 17 00:00:00 2001 From: Salvatore Iovene Date: Fri, 18 Dec 2009 00:26:44 +0200 Subject: [PATCH] Have Use custom profile button and populate it. --- modules/tweakr-profile.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/modules/tweakr-profile.c b/modules/tweakr-profile.c index 749d018..d3b0402 100644 --- a/modules/tweakr-profile.c +++ b/modules/tweakr-profile.c @@ -13,8 +13,11 @@ #include #include #include + #include +#include + #include "libtweakr-section/tweakr-section.h" #include "libtweakr-section/tweakr-module.h" @@ -40,6 +43,8 @@ typedef struct _TweakrProfileSectionClass struct _TweakrProfileSection { TweakrSection parent_instance; + + GtkWidget *profile_button; }; struct _TweakrProfileSectionClass @@ -118,6 +123,65 @@ tweakr_profile_section_class_init object_class->dispose = tweakr_profile_section_dispose; } +static GtkWidget * +_build_profile_select_button (TweakrProfileSection *section) +{ + GtkWidget *button, *selector; + char **profiles; + gint i; + char *current_profile; + + selector = hildon_touch_selector_new_text (); + hildon_touch_selector_append_text + (HILDON_TOUCH_SELECTOR (selector), + _("Save current profile with new name...")); + + profiles = profile_get_profiles (); + for (i = 0; profiles && profiles[i] && profiles[i] != '\0'; i++) + { + /* + * Gotta make some l10n substitution here. + */ + const gchar *p = profiles[i]; + + if (strcmp (p, "general") == 0) + { + p = _("General"); + } + else if (strcmp (p, "silent") == 0) + { + p = _("Silent"); + } + + hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), + p); + } + + current_profile = profile_get_profile (); + for (i = 0; profiles[i] && profiles[i] != '\0'; i++) + { + if (g_strcmp0 (profiles[i], current_profile) == 0) + { + hildon_touch_selector_set_active + (HILDON_TOUCH_SELECTOR (selector), 0, i + 1); + } + } + g_free (current_profile); + profile_free_profiles (profiles); + + button = hildon_picker_button_new (HILDON_SIZE_AUTO | + HILDON_SIZE_FINGER_HEIGHT, + HILDON_BUTTON_ARRANGEMENT_VERTICAL); + hildon_button_set_title (HILDON_BUTTON (button), + _("Use custom profile")); + gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f); + hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button), + HILDON_TOUCH_SELECTOR (selector)); + + gtk_widget_show (button); + return button; +} + static void tweakr_profile_section_init (TweakrProfileSection *section) { @@ -125,6 +189,12 @@ tweakr_profile_section_init (TweakrProfileSection *section) iface = TWEAKR_SECTION (section); iface->name = _("Profile"); + iface->widget = gtk_vbox_new (FALSE, 0); + + section->profile_button = _build_profile_select_button (section); + + gtk_box_pack_start (GTK_BOX (iface->widget), section->profile_button, + FALSE, FALSE, 0); } static void -- 1.7.9.5