From: Salvatore Iovene Date: Sun, 20 Dec 2009 19:38:44 +0000 (+0200) Subject: Show the button when new preset is added; improve translations. X-Git-Tag: 0.0.11~3 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=31684bed7834ef2b8271a695616ebe2b1e32354a;p=tweakr Show the button when new preset is added; improve translations. --- diff --git a/modules/tweakr-profile-status-menu-widget.c b/modules/tweakr-profile-status-menu-widget.c index 7d2e7a8..75e2634 100644 --- a/modules/tweakr-profile-status-menu-widget.c +++ b/modules/tweakr-profile-status-menu-widget.c @@ -70,6 +70,7 @@ struct _TweakrProfileStatusPluginPrivate GtkWidget *dialog; GtkWidget *box; GConfClient *gconf; + guint notify_id; }; HD_DEFINE_PLUGIN_MODULE (TweakrProfileStatusPlugin, @@ -107,7 +108,7 @@ _preset_clicked (HildonButton *button, TweakrProfileStatusPlugin *plugin) basename = g_path_get_basename (path); hildon_button_set_value (HILDON_BUTTON (plugin->priv->button), basename); gconf_client_set_string (plugin->priv->gconf, - "/system/tweakr/current-preset", basename, NULL); + GCONF_PATH "/current-preset", basename, NULL); g_free (basename); gtk_dialog_response (GTK_DIALOG (plugin->priv->dialog), GTK_RESPONSE_OK); @@ -172,6 +173,55 @@ _button_clicked (HildonButton *b, TweakrProfileStatusPlugin *plugin) } static void +_create_main_button (TweakrProfileStatusPlugin *plugin) +{ + gchar *current; + GtkWidget *image; + + plugin->priv->button = hildon_button_new + (HILDON_SIZE_AUTO | HILDON_SIZE_FINGER_HEIGHT, + HILDON_BUTTON_ARRANGEMENT_VERTICAL); + hildon_button_set_title (HILDON_BUTTON (plugin->priv->button), + _("Profile preset")); + + current = gconf_client_get_string (plugin->priv->gconf, + GCONF_PATH "/current-preset", + NULL); + + hildon_button_set_value (HILDON_BUTTON (plugin->priv->button), current); + g_free (current); + gtk_button_set_alignment (GTK_BUTTON (plugin->priv->button), 0.0f, 0.5f); + + image = gtk_image_new_from_icon_name ("control_tweakr", + GTK_ICON_SIZE_BUTTON); + hildon_button_set_image (HILDON_BUTTON (plugin->priv->button), image); + + g_signal_connect (G_OBJECT (plugin->priv->button), "clicked", + G_CALLBACK (_button_clicked), plugin); + + gtk_container_add (GTK_CONTAINER (plugin), plugin->priv->button); + gtk_widget_show_all (plugin->priv->button); +} + +static void +_current_preset_changed_cb (GConfClient *client, guint notify_id, + GConfEntry *entry, + TweakrProfileStatusPlugin *plugin) +{ + if (plugin->priv->button == NULL) + { + _create_main_button (plugin); + gtk_widget_show (GTK_WIDGET (plugin)); + } + else + { + hildon_button_set_value (HILDON_BUTTON (plugin->priv->button), + gconf_value_get_string (entry->value)); + } +} + + +static void tweakr_profile_status_plugin_class_finalize (TweakrProfileStatusPluginClass *klass) { @@ -184,6 +234,14 @@ tweakr_profile_status_plugin_dispose (GObject *obj) if (plugin->priv->gconf != NULL) { + if (plugin->priv->notify_id) + { + gconf_client_notify_remove (plugin->priv->gconf, + plugin->priv->notify_id); + plugin->priv->notify_id = 0; + } + + gconf_client_remove_dir (plugin->priv->gconf, GCONF_PATH, NULL); g_object_unref (plugin->priv->gconf); plugin->priv->gconf = NULL; } @@ -207,34 +265,26 @@ static void tweakr_profile_status_plugin_init (TweakrProfileStatusPlugin *plugin) { gchar *current; - GtkWidget *image; plugin->priv = TWEAKR_PROFILE_STATUS_PLUGIN_GET_PRIVATE (plugin); plugin->priv->gconf = gconf_client_get_default (); - plugin->priv->button = hildon_button_new - (HILDON_SIZE_AUTO | HILDON_SIZE_FINGER_HEIGHT, - HILDON_BUTTON_ARRANGEMENT_VERTICAL); - hildon_button_set_title (HILDON_BUTTON (plugin->priv->button), - _("Tweakr profile preset")); + gconf_client_add_dir (plugin->priv->gconf, GCONF_PATH, + GCONF_CLIENT_PRELOAD_NONE, NULL); + plugin->priv->notify_id = gconf_client_notify_add + (plugin->priv->gconf, GCONF_PATH "/current-preset", + (GConfClientNotifyFunc) _current_preset_changed_cb, plugin, + NULL, NULL); current = gconf_client_get_string (plugin->priv->gconf, - "/system/tweakr/current-preset", + GCONF_PATH "/current-preset", NULL); - hildon_button_set_value (HILDON_BUTTON (plugin->priv->button), current); - g_free (current); - gtk_button_set_alignment (GTK_BUTTON (plugin->priv->button), 0.0f, 0.5f); - image = gtk_image_new_from_icon_name ("control_tweakr", - GTK_ICON_SIZE_BUTTON); - hildon_button_set_image (HILDON_BUTTON (plugin->priv->button), image); - - g_signal_connect (G_OBJECT (plugin->priv->button), "clicked", - G_CALLBACK (_button_clicked), plugin); - - gtk_container_add (GTK_CONTAINER (plugin), plugin->priv->button); - gtk_widget_show_all (plugin->priv->button); + if (current == NULL) + return; + _create_main_button (plugin); gtk_widget_show (GTK_WIDGET (plugin)); + g_free (current); } diff --git a/modules/tweakr-profile.c b/modules/tweakr-profile.c index 26b524d..b24864d 100644 --- a/modules/tweakr-profile.c +++ b/modules/tweakr-profile.c @@ -136,7 +136,7 @@ _save_preset_clicked (HildonPickerButton *button, (TWEAKR_SECTION (section)), GTK_TYPE_WINDOW)); dialog = gtk_dialog_new_with_buttons - (_("Save current profile with new name"), + (_("Preset name"), parent, GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_OK, GTK_RESPONSE_OK, @@ -172,6 +172,8 @@ _save_preset_clicked (HildonPickerButton *button, /* Save the settings to our own gconf directory. */ gconf = gconf_client_get_default (); + gconf_client_set_string (gconf, GCONF_PATH "/current-preset", + _("None"), NULL); values = profile_get_values ("general"); for (values_iter = values; values_iter->pv_key != NULL; @@ -225,7 +227,7 @@ tweakr_profile_section_init (TweakrProfileSection *section) TweakrSection *iface; iface = TWEAKR_SECTION (section); - iface->name = _("Profiles"); + iface->name = _("Profile presets"); iface->widget = gtk_vbox_new (FALSE, 0); section->preset_button = _build_save_preset_button (section); diff --git a/po/en_GB.po b/po/en_GB.po index d436e14..2a2342d 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -101,21 +101,31 @@ 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" +# tweakr-profile.c +msgid "Profile presets" +msgstr "Profile presets" -msgid "silent" -msgstr "Silent" +msgid "Preset name" +msgstr "Preset name" -msgid "Meeting" -msgstr "Meeting" +msgid "Enter the name first." +msgstr "Enter the name first." -msgid "Night" -msgstr "Night" +msgid "Preset saved. Use the status menu to select it." +msgstr "Preset saved. Use the status menu to select it." -msgid "User custom profile" -msgstr "User custom profile" +msgid "Save current General profile to new preset" +msgstr "Save current General profile to new preset" -msgid "Profiles" -msgstr "Profiles" +# tweakr-profile-status-menu-widget.c +msgid "Preset activated." +msgstr "Preset activated." + +msgid "Select preset" +msgstr "Select preset" + +msgid "Profile preset" +msgstr "Profile preset" + +msgid "None" +msgstr "None" diff --git a/po/it_IT.po b/po/it_IT.po index b7fc7ed..ee4945d 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -101,21 +101,31 @@ 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" +# tweakr-profile.c +msgid "Profile presets" +msgstr "Varianti di profilo" -msgid "silent" -msgstr "Silenzioso" +msgid "Preset name" +msgstr "Nome della variante" -msgid "Meeting" -msgstr "Riunione" +msgid "Enter the name first." +msgstr "Inserire prima il nome" -msgid "Night" -msgstr "Notte" +msgid "Preset saved. Use the status menu to select it." +msgstr "Variante del profilo salvata. Puoi selezionarla nel menu di stato." -msgid "User custom profile" -msgstr "User custom profile" +msgid "Save current General profile to new preset" +msgstr "Nuova variante del profilo Generale" -msgid "Profiles" -msgstr "Profiles" +# tweakr-profile-status-menu-widget.c +msgid "Preset activated." +msgstr "Variante attivata." + +msgid "Select preset" +msgstr "Selezionare una variante" + +msgid "Profile preset" +msgstr "Variante di profilo" + +msgid "None" +msgstr "Nessuna"