1.1 --- a/maemo-ui/src/mmyth_uisettings.c Fri Jan 12 21:26:30 2007 +0000
1.2 +++ b/maemo-ui/src/mmyth_uisettings.c Tue Jul 03 21:20:15 2007 +0100
1.3 @@ -18,144 +18,179 @@
1.4 static GtkWidget *entry_passwd;
1.5 static GtkWidget *entry_port;
1.6
1.7 -static void settings_dialog_update_data (void);
1.8 -static GtkWidget* add_entry_to_table (GtkWidget *table, const gchar *init_str,
1.9 - guint pos_left, guint pos_right, guint pos_top, guint pos_bottom);
1.10 -static GtkWidget* add_label_to_table (GtkWidget *table, const gchar *str,
1.11 - guint pos_left, guint pos_right, guint pos_top, guint pos_bottom);
1.12 -
1.13 +static void settings_dialog_update_data(void);
1.14 +static GtkWidget *add_entry_to_table(GtkWidget * table,
1.15 + const gchar * init_str,
1.16 + guint pos_left, guint pos_right,
1.17 + guint pos_top, guint pos_bottom);
1.18 +static GtkWidget *add_label_to_table(GtkWidget * table, const gchar * str,
1.19 + guint pos_left, guint pos_right,
1.20 + guint pos_top, guint pos_bottom);
1.21 +
1.22 static GMythBackendInfo *backend_info = NULL;
1.23
1.24 gboolean
1.25 -mmyth_uisettings_run (GtkWindow *main_window)
1.26 +mmyth_uisettings_run(GtkWindow * main_window)
1.27 {
1.28
1.29 - GtkWidget *settings_table;
1.30 - GtkWidget *label_hostname, *label_dbname;
1.31 - GtkWidget *label_username, *label_passwd, *label_port;
1.32 + GtkWidget *settings_table;
1.33 + GtkWidget *label_hostname,
1.34 + *label_dbname;
1.35 + GtkWidget *label_username,
1.36 + *label_passwd,
1.37 + *label_port;
1.38
1.39 - backend_info = gmyth_backend_info_new_full( "localhost", "mythtv",
1.40 - "mythtv", "mythconverg", 6543 );
1.41 -
1.42 - settings_dialog = gtk_dialog_new_with_buttons ("Settings",
1.43 - main_window,
1.44 - GTK_DIALOG_DESTROY_WITH_PARENT,
1.45 - GTK_STOCK_OK,
1.46 - GTK_RESPONSE_ACCEPT,
1.47 - GTK_STOCK_CANCEL,
1.48 - GTK_RESPONSE_REJECT,
1.49 - NULL);
1.50 -
1.51 - gtk_widget_set_size_request (settings_dialog, 400, 244);
1.52 + backend_info = gmyth_backend_info_new_full("localhost", "mythtv",
1.53 + "mythtv", "mythconverg",
1.54 + 6543);
1.55
1.56 -/* scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
1.57 - gtk_widget_show (scrolledwindow1);
1.58 - gtk_container_add (GTK_CONTAINER (window1), scrolledwindow1);
1.59 - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
1.60 + settings_dialog = gtk_dialog_new_with_buttons("Settings",
1.61 + main_window,
1.62 + GTK_DIALOG_DESTROY_WITH_PARENT,
1.63 + GTK_STOCK_OK,
1.64 + GTK_RESPONSE_ACCEPT,
1.65 + GTK_STOCK_CANCEL,
1.66 + GTK_RESPONSE_REJECT,
1.67 + NULL);
1.68
1.69 - viewport1 = gtk_viewport_new (NULL, NULL);
1.70 - gtk_widget_show (viewport1);
1.71 - gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
1.72 - gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport1), GTK_SHADOW_NONE);
1.73 -*/
1.74 + gtk_widget_set_size_request(settings_dialog, 400, 244);
1.75
1.76 - // Creates the table and attach it to the settings dialog
1.77 - settings_table = gtk_table_new (5, 2, FALSE);
1.78 - gtk_widget_show (settings_table);
1.79 - gtk_box_pack_start (GTK_BOX (GTK_DIALOG(settings_dialog)->vbox), settings_table, FALSE, TRUE, 0);
1.80 - gtk_container_set_border_width (GTK_CONTAINER (settings_table), 3);
1.81 - gtk_table_set_row_spacings (GTK_TABLE (settings_table), 5);
1.82 - gtk_table_set_col_spacings (GTK_TABLE (settings_table), 10);
1.83 + /*
1.84 + * scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
1.85 + * gtk_widget_show (scrolledwindow1); gtk_container_add (GTK_CONTAINER
1.86 + * (window1), scrolledwindow1); gtk_scrolled_window_set_policy
1.87 + * (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC,
1.88 + * GTK_POLICY_NEVER);
1.89 + *
1.90 + * viewport1 = gtk_viewport_new (NULL, NULL); gtk_widget_show
1.91 + * (viewport1); gtk_container_add (GTK_CONTAINER (scrolledwindow1),
1.92 + * viewport1); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport1),
1.93 + * GTK_SHADOW_NONE);
1.94 + */
1.95
1.96 - label_hostname = add_label_to_table (settings_table, "Host Name:", 0, 1, 0, 1);
1.97 - label_dbname = add_label_to_table (settings_table, "Database Name:", 0, 1, 1, 2);
1.98 - label_username = add_label_to_table (settings_table, "Username:", 0, 1, 2, 3);
1.99 - label_passwd = add_label_to_table (settings_table, "Password:", 0, 1, 3, 4);
1.100 - label_port = add_label_to_table (settings_table, "Server port:", 0, 1, 4, 5);
1.101 -
1.102 - entry_hostname = add_entry_to_table (settings_table,
1.103 - gmyth_backend_info_get_hostname (backend_info),
1.104 - 1, 2, 0, 1);
1.105 - entry_dbname = add_entry_to_table (settings_table,
1.106 - gmyth_backend_info_get_db_name (backend_info),
1.107 - 1, 2, 1, 2 );
1.108 - entry_username = add_entry_to_table (settings_table,
1.109 - gmyth_backend_info_get_username (backend_info),
1.110 - 1, 2, 2, 3 );
1.111 - entry_passwd = add_entry_to_table (settings_table,
1.112 - gmyth_backend_info_get_password (backend_info),
1.113 - 1, 2, 3, 4 );
1.114 -
1.115 - entry_port = add_entry_to_table (settings_table, g_strdup_printf( "%d", gmyth_backend_info_get_port (backend_info) ),
1.116 - 1, 2, 4, 5 );
1.117 -
1.118 - if (gtk_dialog_run (GTK_DIALOG (settings_dialog)) == GTK_RESPONSE_ACCEPT) {
1.119 - settings_dialog_update_data ();
1.120 - gtk_widget_destroy (settings_dialog);
1.121 - return TRUE;
1.122 - }
1.123 -
1.124 - gtk_widget_destroy (settings_dialog);
1.125 -
1.126 - return FALSE;
1.127 -
1.128 + // Creates the table and attach it to the settings dialog
1.129 + settings_table = gtk_table_new(5, 2, FALSE);
1.130 + gtk_widget_show(settings_table);
1.131 + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(settings_dialog)->vbox),
1.132 + settings_table, FALSE, TRUE, 0);
1.133 + gtk_container_set_border_width(GTK_CONTAINER(settings_table), 3);
1.134 + gtk_table_set_row_spacings(GTK_TABLE(settings_table), 5);
1.135 + gtk_table_set_col_spacings(GTK_TABLE(settings_table), 10);
1.136 +
1.137 + label_hostname =
1.138 + add_label_to_table(settings_table, "Host Name:", 0, 1, 0, 1);
1.139 + label_dbname =
1.140 + add_label_to_table(settings_table, "Database Name:", 0, 1, 1, 2);
1.141 + label_username =
1.142 + add_label_to_table(settings_table, "Username:", 0, 1, 2, 3);
1.143 + label_passwd =
1.144 + add_label_to_table(settings_table, "Password:", 0, 1, 3, 4);
1.145 + label_port =
1.146 + add_label_to_table(settings_table, "Server port:", 0, 1, 4, 5);
1.147 +
1.148 + entry_hostname = add_entry_to_table(settings_table,
1.149 + gmyth_backend_info_get_hostname
1.150 + (backend_info), 1, 2, 0, 1);
1.151 + entry_dbname =
1.152 + add_entry_to_table(settings_table,
1.153 + gmyth_backend_info_get_db_name(backend_info), 1,
1.154 + 2, 1, 2);
1.155 + entry_username =
1.156 + add_entry_to_table(settings_table,
1.157 + gmyth_backend_info_get_username(backend_info),
1.158 + 1, 2, 2, 3);
1.159 + entry_passwd =
1.160 + add_entry_to_table(settings_table,
1.161 + gmyth_backend_info_get_password(backend_info),
1.162 + 1, 2, 3, 4);
1.163 +
1.164 + entry_port =
1.165 + add_entry_to_table(settings_table,
1.166 + g_strdup_printf("%d",
1.167 + gmyth_backend_info_get_port
1.168 + (backend_info)), 1, 2, 4, 5);
1.169 +
1.170 + if (gtk_dialog_run(GTK_DIALOG(settings_dialog)) == GTK_RESPONSE_ACCEPT) {
1.171 + settings_dialog_update_data();
1.172 + gtk_widget_destroy(settings_dialog);
1.173 + return TRUE;
1.174 + }
1.175 +
1.176 + gtk_widget_destroy(settings_dialog);
1.177 +
1.178 + return FALSE;
1.179 +
1.180 }
1.181
1.182 -static GtkWidget*
1.183 -add_label_to_table (GtkWidget *table, const gchar *str, guint pos_left, guint pos_right,
1.184 - guint pos_top, guint pos_bottom )
1.185 +static GtkWidget *
1.186 +add_label_to_table(GtkWidget * table, const gchar * str, guint pos_left,
1.187 + guint pos_right, guint pos_top, guint pos_bottom)
1.188 {
1.189 - GtkWidget *tmp_label = gtk_label_new (str);
1.190 -
1.191 - gtk_widget_show (tmp_label);
1.192 - gtk_table_attach (GTK_TABLE (table), tmp_label,
1.193 - pos_left, pos_right, pos_top, pos_bottom,
1.194 - (GtkAttachOptions) (GTK_FILL),
1.195 - (GtkAttachOptions) (0), 0, 0);
1.196 - gtk_misc_set_alignment (GTK_MISC (tmp_label), 0, 0.5);
1.197 -
1.198 - return tmp_label;
1.199 + GtkWidget *tmp_label = gtk_label_new(str);
1.200 +
1.201 + gtk_widget_show(tmp_label);
1.202 + gtk_table_attach(GTK_TABLE(table), tmp_label,
1.203 + pos_left, pos_right, pos_top, pos_bottom,
1.204 + (GtkAttachOptions) (GTK_FILL),
1.205 + (GtkAttachOptions) (0), 0, 0);
1.206 + gtk_misc_set_alignment(GTK_MISC(tmp_label), 0, 0.5);
1.207 +
1.208 + return tmp_label;
1.209 }
1.210
1.211 -static GtkWidget*
1.212 -add_entry_to_table (GtkWidget *table, const gchar *init_str, guint pos_left, guint pos_right,
1.213 - guint pos_top, guint pos_bottom)
1.214 +static GtkWidget *
1.215 +add_entry_to_table(GtkWidget * table, const gchar * init_str,
1.216 + guint pos_left, guint pos_right, guint pos_top,
1.217 + guint pos_bottom)
1.218 {
1.219 - GtkWidget *tmp_entry = gtk_entry_new ();
1.220 - gtk_widget_show (tmp_entry);
1.221 - gtk_table_attach (GTK_TABLE (table), tmp_entry,
1.222 - pos_left, pos_right, pos_top, pos_bottom,
1.223 - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1.224 - (GtkAttachOptions) (0), 0, 0);
1.225 + GtkWidget *tmp_entry = gtk_entry_new();
1.226 + gtk_widget_show(tmp_entry);
1.227 + gtk_table_attach(GTK_TABLE(table), tmp_entry,
1.228 + pos_left, pos_right, pos_top, pos_bottom,
1.229 + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1.230 + (GtkAttachOptions) (0), 0, 0);
1.231 if (init_str)
1.232 - gtk_entry_set_text (GTK_ENTRY (tmp_entry), init_str);
1.233 -
1.234 - //gtk_entry_set_invisible_char (GTK_ENTRY (entry_port), 9679);
1.235 -
1.236 - return tmp_entry;
1.237 + gtk_entry_set_text(GTK_ENTRY(tmp_entry), init_str);
1.238 +
1.239 + // gtk_entry_set_invisible_char (GTK_ENTRY (entry_port), 9679);
1.240 +
1.241 + return tmp_entry;
1.242 }
1.243
1.244 static void
1.245 -settings_dialog_update_data (void)
1.246 +settings_dialog_update_data(void)
1.247 {
1.248 - //GMythSettings *backend_info = gmyth_context_get_settings();
1.249 -
1.250 - if (!backend_info) {
1.251 - g_warning ("[%s] Could not get GMythSettings instance from context\n", __FUNCTION__);
1.252 - return;
1.253 - }
1.254 -
1.255 - gmyth_backend_info_set_hostname(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_hostname) ));
1.256 -
1.257 - gmyth_backend_info_set_db_name(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_dbname)));
1.258 -
1.259 - gmyth_backend_info_set_username(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_username)));
1.260 + // GMythSettings *backend_info = gmyth_context_get_settings();
1.261
1.262 - gmyth_backend_info_set_password(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_passwd)));
1.263 -
1.264 - gmyth_backend_info_set_port(backend_info, (gint)g_ascii_strtoull( gtk_entry_get_text( GTK_ENTRY(entry_port) ),
1.265 - NULL, 10) );
1.266 -
1.267 - //gmyth_backend_info_save (backend_info);
1.268 -
1.269 + if (!backend_info) {
1.270 + g_warning
1.271 + ("[%s] Could not get GMythSettings instance from context\n",
1.272 + __FUNCTION__);
1.273 + return;
1.274 + }
1.275 +
1.276 + gmyth_backend_info_set_hostname(backend_info,
1.277 + gtk_entry_get_text(GTK_ENTRY
1.278 + (entry_hostname)));
1.279 +
1.280 + gmyth_backend_info_set_db_name(backend_info,
1.281 + gtk_entry_get_text(GTK_ENTRY
1.282 + (entry_dbname)));
1.283 +
1.284 + gmyth_backend_info_set_username(backend_info,
1.285 + gtk_entry_get_text(GTK_ENTRY
1.286 + (entry_username)));
1.287 +
1.288 + gmyth_backend_info_set_password(backend_info,
1.289 + gtk_entry_get_text(GTK_ENTRY
1.290 + (entry_passwd)));
1.291 +
1.292 + gmyth_backend_info_set_port(backend_info,
1.293 + (gint)
1.294 + g_ascii_strtoull(gtk_entry_get_text
1.295 + (GTK_ENTRY(entry_port)),
1.296 + NULL, 10));
1.297 +
1.298 + // gmyth_backend_info_save (backend_info);
1.299 +
1.300 }