1.1 --- a/maemo-ui/src/mmyth_uisettings.c Thu Sep 28 16:02:14 2006 +0100
1.2 +++ b/maemo-ui/src/mmyth_uisettings.c Wed Dec 20 14:43:11 2006 +0000
1.3 @@ -9,7 +9,7 @@
1.4
1.5 #include "mmyth_uisettings.h"
1.6
1.7 -#include "gmyth_context.h"
1.8 +#include <gmyth/gmyth_backendinfo.h>
1.9
1.10 static GtkWidget *settings_dialog;
1.11 static GtkWidget *entry_hostname;
1.12 @@ -19,12 +19,13 @@
1.13 static GtkWidget *entry_port;
1.14
1.15 static void settings_dialog_update_data (void);
1.16 -static GtkWidget* add_entry_to_table (GtkWidget *table, GString *init_str,
1.17 +static GtkWidget* add_entry_to_table (GtkWidget *table, const gchar *init_str,
1.18 guint pos_left, guint pos_right, guint pos_top, guint pos_bottom);
1.19 static GtkWidget* add_label_to_table (GtkWidget *table, const gchar *str,
1.20 guint pos_left, guint pos_right, guint pos_top, guint pos_bottom);
1.21
1.22 -
1.23 +static GMythBackendInfo *backend_info = NULL;
1.24 +
1.25 gboolean
1.26 mmyth_uisettings_run (GtkWindow *main_window)
1.27 {
1.28 @@ -33,7 +34,8 @@
1.29 GtkWidget *label_hostname, *label_dbname;
1.30 GtkWidget *label_username, *label_passwd, *label_port;
1.31
1.32 - GMythSettings *msettings = gmyth_context_get_settings();
1.33 + backend_info = gmyth_backend_info_new_full( "192.168.1.109", "mythtv",
1.34 + "mythtv", "mythconverg", 6543 );
1.35
1.36 settings_dialog = gtk_dialog_new_with_buttons ("Settings",
1.37 main_window,
1.38 @@ -72,24 +74,20 @@
1.39 label_port = add_label_to_table (settings_table, "Server port:", 0, 1, 4, 5);
1.40
1.41 entry_hostname = add_entry_to_table (settings_table,
1.42 - gmyth_settings_get_backend_hostname (msettings),
1.43 + gmyth_backend_info_get_hostname (backend_info),
1.44 1, 2, 0, 1);
1.45 entry_dbname = add_entry_to_table (settings_table,
1.46 - gmyth_settings_get_dbname (msettings),
1.47 + gmyth_backend_info_get_db_name (backend_info),
1.48 1, 2, 1, 2 );
1.49 entry_username = add_entry_to_table (settings_table,
1.50 - gmyth_settings_get_username (msettings),
1.51 + gmyth_backend_info_get_username (backend_info),
1.52 1, 2, 2, 3 );
1.53 entry_passwd = add_entry_to_table (settings_table,
1.54 - gmyth_settings_get_password (msettings),
1.55 + gmyth_backend_info_get_password (backend_info),
1.56 1, 2, 3, 4 );
1.57
1.58 - GString *str_port = g_string_new ("");
1.59 - g_string_printf (str_port, "%d",
1.60 - gmyth_settings_get_backend_port (msettings));
1.61 - entry_port = add_entry_to_table (settings_table, str_port,
1.62 + entry_port = add_entry_to_table (settings_table, g_strdup_printf( "%d", gmyth_backend_info_get_port (backend_info) ),
1.63 1, 2, 4, 5 );
1.64 - g_string_free (str_port, TRUE);
1.65
1.66 if (gtk_dialog_run (GTK_DIALOG (settings_dialog)) == GTK_RESPONSE_ACCEPT) {
1.67 settings_dialog_update_data ();
1.68 @@ -120,7 +118,7 @@
1.69 }
1.70
1.71 static GtkWidget*
1.72 -add_entry_to_table (GtkWidget *table, GString *init_str, guint pos_left, guint pos_right,
1.73 +add_entry_to_table (GtkWidget *table, const gchar *init_str, guint pos_left, guint pos_right,
1.74 guint pos_top, guint pos_bottom)
1.75 {
1.76 GtkWidget *tmp_entry = gtk_entry_new ();
1.77 @@ -130,7 +128,7 @@
1.78 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1.79 (GtkAttachOptions) (0), 0, 0);
1.80 if (init_str)
1.81 - gtk_entry_set_text (GTK_ENTRY (tmp_entry), (init_str->str));
1.82 + gtk_entry_set_text (GTK_ENTRY (tmp_entry), init_str);
1.83
1.84 //gtk_entry_set_invisible_char (GTK_ENTRY (entry_port), 9679);
1.85
1.86 @@ -141,29 +139,24 @@
1.87 settings_dialog_update_data (void)
1.88 {
1.89 GString *tmp_entry_text;
1.90 - GMythSettings *msettings = gmyth_context_get_settings();
1.91 + //GMythSettings *backend_info = gmyth_context_get_settings();
1.92
1.93 - if (!msettings) {
1.94 + if (!backend_info) {
1.95 g_warning ("[%s] Could not get GMythSettings instance from context\n", __FUNCTION__);
1.96 return;
1.97 }
1.98
1.99 - tmp_entry_text = g_string_new("");
1.100 - g_string_printf(tmp_entry_text, "%s", gtk_entry_get_text( GTK_ENTRY(entry_hostname)));
1.101 - gmyth_settings_set_backend_hostname(msettings, tmp_entry_text);
1.102 + gmyth_backend_info_set_hostname(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_hostname) ));
1.103
1.104 - g_string_printf(tmp_entry_text, "%s", gtk_entry_get_text( GTK_ENTRY(entry_dbname)));
1.105 - gmyth_settings_set_dbname(msettings, tmp_entry_text);
1.106 + gmyth_backend_info_set_db_name(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_dbname)));
1.107
1.108 - g_string_printf(tmp_entry_text, "%s", gtk_entry_get_text( GTK_ENTRY(entry_username)));
1.109 - gmyth_settings_set_username(msettings, tmp_entry_text);
1.110 + gmyth_backend_info_set_username(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_username)));
1.111 +
1.112 + gmyth_backend_info_set_password(backend_info, gtk_entry_get_text( GTK_ENTRY(entry_passwd)));
1.113
1.114 - g_string_printf(tmp_entry_text, "%s", gtk_entry_get_text( GTK_ENTRY(entry_passwd)));
1.115 - gmyth_settings_set_password(msettings, tmp_entry_text);
1.116 + gmyth_backend_info_set_port(backend_info, (gint)g_ascii_strtoull( gtk_entry_get_text( GTK_ENTRY(entry_port) ),
1.117 + NULL, 10) );
1.118
1.119 - g_string_printf(tmp_entry_text, "%s", gtk_entry_get_text( GTK_ENTRY(entry_port)));
1.120 - gmyth_settings_set_backend_port(msettings, atoi(tmp_entry_text->str));
1.121 -
1.122 - gmyth_settings_save (msettings);
1.123 + //gmyth_backend_info_save (backend_info);
1.124
1.125 }