From: Salvatore Iovene Date: Sat, 19 Dec 2009 18:34:42 +0000 (+0200) Subject: Finalize support for profiles. X-Git-Tag: 0.0.11~6 X-Git-Url: https://vcs.maemo.org/git/?p=tweakr;a=commitdiff_plain;h=3fc4a9e0570243b04133a3d8c8485e0248c1bff4 Finalize support for profiles. --- diff --git a/debian/tweakr.install b/debian/tweakr.install index ff6dd7d..44706e5 100644 --- a/debian/tweakr.install +++ b/debian/tweakr.install @@ -5,3 +5,4 @@ usr/share/locale/*/LC_MESSAGES/* usr/share/icons/hicolor/48x48/hildon/control_tweakr.png usr/lib/tweakr/modules/*.so* usr/bin/* +/etc/profiled/* diff --git a/modules/Makefile.am b/modules/Makefile.am index ce6043d..6b0772c 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -52,3 +52,8 @@ tweakr_mce_save_SOURCES = tweakr-mce-save.c tweakr_mce_save_LDADD = \ $(GLIB_LIBS) +tweakr_profile_datadir = /etc/profiled +tweakr_profile_data_DATA = data/91.tweakr.ini + +EXTRA_DIST = $(tweakr_profile_data_DATA) + diff --git a/modules/data/91.tweakr.ini b/modules/data/91.tweakr.ini new file mode 100644 index 0000000..c223b51 --- /dev/null +++ b/modules/data/91.tweakr.ini @@ -0,0 +1,81 @@ +[datatype] + +ringing.alert.tone = SOUNDFILE +ringing.alert.type = STRING "Ringing" "Silent" +ringing.alert.volume = INTEGER 0-100 + +vibrating.alert.enabled = BOOLEAN + +sms.alert.tone = SOUNDFILE +sms.alert.volume = INTEGER 0-100 + +im.alert.tone = SOUNDFILE +im.alert.volume = INTEGER 0-100 + +email.alert.tone = SOUNDFILE +email.alert.volume = INTEGER 0-100 + +keypad.sound.level = INTEGER 0-2 +system.sound.level = INTEGER 0-2 +touchscreen.sound.level = INTEGER 0-2 + +clock.alarm.enabled = BOOLEAN +calendar.alarm.enabled = BOOLEAN + +[fallback] + +ringing.alert.tone = Nokia_tune.aac +ringing.alert.type = ringing +ringing.alert.volume = 75 + +vibrating.alert.enabled = On + +sms.alert.tone = Message1.aac +sms.alert.volume = 60 + +im.alert.tone = Message1.aac +im.alert.volume = 60 + +email.alert.tone = Email1.aac +email.alert.volume = 60 + +keypad.sound.level = 0 +system.sound.level = 1 +touchscreen.sound.level = 1 + +clock.alarm.enabled = On +calendar.alarm.enabled = On + +[Meeting] + +ringing.alert.type = silent +ringing.alert.volume = 0 + +vibrating.alert.enabled = on + +sms.alert.volume = 0 +im.alert.volume = 0 +email.alert.volume = 0 + +keypad.sound.level = 0 +system.sound.level = 0 +touchscreen.sound.level = 0 + +calendar.alarm.enabled = Off + +[Night] + +ringing.alert.type = ringing +ringing.alert.volume = 20 + +vibrating.alert.enabled = off + +sms.alert.volume = 20 +im.alert.volume = 0 +email.alert.volume = 0 + +keypad.sound.level = 0 +system.sound.level = 0 +touchscreen.sound.level = 0 + +calendar.alarm.enabled = Off diff --git a/modules/tweakr-profile.c b/modules/tweakr-profile.c index d3b0402..61e5d60 100644 --- a/modules/tweakr-profile.c +++ b/modules/tweakr-profile.c @@ -9,10 +9,9 @@ #include #include #include -#include #include -#include #include +#include #include @@ -45,6 +44,9 @@ struct _TweakrProfileSection TweakrSection parent_instance; GtkWidget *profile_button; + GHashTable *profile_map; + guint value_changed : 1; + gint previous_selected; }; struct _TweakrProfileSectionClass @@ -123,6 +125,78 @@ tweakr_profile_section_class_init object_class->dispose = tweakr_profile_section_dispose; } +static void +_value_changed (HildonPickerButton *button, TweakrProfileSection *section) +{ + HildonTouchSelector *selector; + gint active; + GtkWindow *parent; + + selector = hildon_picker_button_get_selector (button); + active = hildon_touch_selector_get_active (selector, 0); + + parent = GTK_WINDOW (gtk_widget_get_ancestor (tweakr_section_get_widget + (TWEAKR_SECTION (section)), + GTK_TYPE_WINDOW)); +#if 0 + if (active == 0) + { + GtkWidget *dialog, *entry; + gint ret; + const gchar *text = NULL; + + dialog = gtk_dialog_new_with_buttons + (_("Save current profile with new name"), + parent, + GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + entry = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT); + gtk_widget_show (entry); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), entry, + TRUE, TRUE, 0); + while (text == NULL || text [0] == '\0') + { + GtkTreeModel *model; + gint index; + + ret = gtk_dialog_run (GTK_DIALOG (dialog)); + if (ret == GTK_RESPONSE_OK) + { + text = hildon_entry_get_text (HILDON_ENTRY (entry)); + if (text == NULL || text[0] == '\0') + { + GtkWidget *banner; + + banner = hildon_banner_show_information + (dialog, NULL, _("Enter the name first.")); + + continue; + } + + hildon_touch_selector_append_text (selector, text); + model = hildon_touch_selector_get_model (selector, 0); + index = gtk_tree_model_iter_n_children (model, NULL); + hildon_touch_selector_set_active (selector, 0, index); + } + else + { + gtk_widget_destroy (dialog); + hildon_touch_selector_set_active (selector, 0, + section->previous_selected); + break; + } + gtk_widget_destroy (dialog); + } + } +#endif + section->previous_selected = hildon_touch_selector_get_active (selector, + 0); + section->value_changed = TRUE; +} + static GtkWidget * _build_profile_select_button (TweakrProfileSection *section) { @@ -132,9 +206,11 @@ _build_profile_select_button (TweakrProfileSection *section) char *current_profile; selector = hildon_touch_selector_new_text (); + /* hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), - _("Save current profile with new name...")); + _("Save current profile with new name")); + */ profiles = profile_get_profiles (); for (i = 0; profiles && profiles[i] && profiles[i] != '\0'; i++) @@ -144,17 +220,11 @@ _build_profile_select_button (TweakrProfileSection *section) */ 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); + _(p)); + g_hash_table_insert (section->profile_map, + GINT_TO_POINTER (i /*+ 1*/), g_strdup (p)); + } current_profile = profile_get_profile (); @@ -163,7 +233,8 @@ _build_profile_select_button (TweakrProfileSection *section) if (g_strcmp0 (profiles[i], current_profile) == 0) { hildon_touch_selector_set_active - (HILDON_TOUCH_SELECTOR (selector), 0, i + 1); + (HILDON_TOUCH_SELECTOR (selector), 0, i/* + 1*/); + section->previous_selected = i/* + 1*/; } } g_free (current_profile); @@ -178,6 +249,9 @@ _build_profile_select_button (TweakrProfileSection *section) hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button), HILDON_TOUCH_SELECTOR (selector)); + g_signal_connect (G_OBJECT (button), "value-changed", + G_CALLBACK (_value_changed), section); + gtk_widget_show (button); return button; } @@ -188,9 +262,12 @@ tweakr_profile_section_init (TweakrProfileSection *section) TweakrSection *iface; iface = TWEAKR_SECTION (section); - iface->name = _("Profile"); + iface->name = _("Profiles"); iface->widget = gtk_vbox_new (FALSE, 0); + section->profile_map = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, g_free); section->profile_button = _build_profile_select_button (section); gtk_box_pack_start (GTK_BOX (iface->widget), section->profile_button, @@ -200,11 +277,38 @@ tweakr_profile_section_init (TweakrProfileSection *section) static void tweakr_profile_section_dispose (GObject *obj) { + TweakrProfileSection *section = TWEAKR_PROFILE_SECTION (obj); + + if (section->profile_map) + { + g_hash_table_destroy (section->profile_map); + section->profile_map = NULL; + } + G_OBJECT_CLASS (tweakr_profile_section_parent_class)->dispose (obj); } static gboolean _save (TweakrSection *section, gboolean *requires_restart) { + if (TWEAKR_PROFILE_SECTION (section)->value_changed) + { + gint active; + const gchar *profile; + + active = + hildon_picker_button_get_active (HILDON_PICKER_BUTTON + (TWEAKR_PROFILE_SECTION + (section)->profile_button)); + profile = g_hash_table_lookup + (TWEAKR_PROFILE_SECTION (section)->profile_map, + GINT_TO_POINTER (active)); + + if (profile != NULL && profile[0] != '\0') + { + profile_set_profile (profile); + } + } + return TRUE; } diff --git a/po/en_GB.po b/po/en_GB.po index 1cbf4f3..d436e14 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -101,3 +101,21 @@ msgstr "" "that the only way to turn the device off is the removal of " "the battery. Do you want to continue?" +# tweakr-profile-section.c +msgid "general" +msgstr "General" + +msgid "silent" +msgstr "Silent" + +msgid "Meeting" +msgstr "Meeting" + +msgid "Night" +msgstr "Night" + +msgid "User custom profile" +msgstr "User custom profile" + +msgid "Profiles" +msgstr "Profiles" diff --git a/po/it_IT.po b/po/it_IT.po index 6f39b8f..b7fc7ed 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -101,3 +101,21 @@ msgstr "" "a \"Ignora\" vuol dire che l'unico modo per spegnere " "il telefono sarà rimuovere la batteria. Continuare?" +# tweakr-profile-section.c +msgid "general" +msgstr "Generale" + +msgid "silent" +msgstr "Silenzioso" + +msgid "Meeting" +msgstr "Riunione" + +msgid "Night" +msgstr "Notte" + +msgid "User custom profile" +msgstr "User custom profile" + +msgid "Profiles" +msgstr "Profiles"