View Single Post
Posts: 838 | Thanked: 3,384 times | Joined on Mar 2009
#236
Feature request / Discussion / Initial patch

General settings for application 'ProfilesX' itself.

This patch adds button 'Settings' above 'modify/new/delete/done'. Clicking it will open new dialog for settings. New dialog is currently empty as I'm not sure where to save modifications.

Code:
--- a/control_panel_plugin_src/profilesx-control-panel-plugin.c
+++ b/control_panel_plugin_src/profilesx-control-panel-plugin.c
@@ -151,6 +151,35 @@ ask_user_for_profile_name(user_data_t* data)
 }
 
 void
+general_settings(GtkButton* button, user_data_t* data)
+{
+
+  GtkWidget* dialog;
+  dialog = gtk_dialog_new_with_buttons("General settings",
+                                       GTK_WINDOW(data->main_dialog),
+                                       GTK_DIALOG_MODAL,
+                                       dgettext("hildon-libs", "wdgt_bd_save"), GTK_RESPONSE_OK,
+                                       NULL);
+  profilesx_dialog_size_changed(gdk_display_get_default_screen(gdk_display_get_default()),
+                                dialog);
+  g_signal_connect(gdk_display_get_default_screen(gdk_display_get_default()),
+                   "size-changed",
+                   G_CALLBACK(profilesx_dialog_size_changed), dialog);
+
+ //Add buttons, sliders...
+  gtk_widget_show_all(dialog);
+
+  int ret = gtk_dialog_run(GTK_DIALOG(dialog));
+  if(ret == GTK_RESPONSE_OK)
+  {
+  //DO SAVING
+  }
+  gtk_widget_destroy(dialog);
+
+}
+
+
+void
 new_profile(GtkButton* button, user_data_t* data)
 {
   gchar* new_profile_name = ask_user_for_profile_name(data);
@@ -210,22 +239,29 @@ void
 add_main_dialog_buttons(user_data_t* data)
 {
   GtkWidget* content_area;
+  GtkWidget* settings_button;
+
   GtkWidget* edit_button;
   GtkWidget* new_button;
   data->profile_delete_button = hildon_gtk_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
+  settings_button = hildon_gtk_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
   edit_button = hildon_gtk_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
   new_button = hildon_gtk_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
 
+  gtk_button_set_label(GTK_BUTTON(settings_button), "Settings");
   gtk_button_set_label(GTK_BUTTON(data->profile_delete_button), dgettext("hildon-libs", "wdgt_bd_delete"));
   gtk_button_set_label(GTK_BUTTON(edit_button), dgettext("hildon-libs", "wdgt_bd_edit"));
   gtk_button_set_label(GTK_BUTTON(new_button), dgettext("hildon-libs", "wdgt_bd_new"));
 
+  g_signal_connect(settings_button, "clicked", G_CALLBACK(general_settings), data);
   g_signal_connect(edit_button, "clicked", G_CALLBACK(edit_profile), data);
   g_signal_connect(new_button, "clicked", G_CALLBACK(new_profile), data);
   g_signal_connect(data->profile_delete_button, "clicked", G_CALLBACK(delete_profile), data);
 
   content_area = gtk_dialog_get_action_area(GTK_DIALOG(data->main_dialog));
   gtk_box_pack_start(GTK_BOX(content_area),
+                    settings_button, FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(content_area),
                     data->profile_delete_button, FALSE, FALSE, 0);
   gtk_box_pack_start(GTK_BOX(content_area),
                     edit_button, FALSE, FALSE, 0);
I'm not asking to merge empty dialog, but I'm asking discussion how to properly save and load settings.
 

The Following 2 Users Say Thank You to AapoRantalainen For This Useful Post: