account.h File Reference

#include <gtk/gtk.h>
Include dependency graph for account.h:

Go to the source code of this file.

Functions

G_BEGIN_DECLS GtkWidget * create_account_window (GtkWidget *parent)
void load_account_settings ()
void save_account_settings ()

Function Documentation

G_BEGIN_DECLS GtkWidget* create_account_window ( GtkWidget *  parent  ) 

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 104 of file irex-account.c.

Referenced by create_concrete_win().

00105 {
00106     // create the top level window 
00107     GtkWidget* top_window = parent;
00108     gtk_window_maximize(GTK_WINDOW(top_window));
00109     gtk_window_set_resizable(GTK_WINDOW(top_window), FALSE);
00110     gtk_container_set_border_width(GTK_CONTAINER(top_window),WINDOW_BORDER_PADDING  );
00111     gtk_window_set_modal(GTK_WINDOW(top_window), TRUE);
00112 
00113     // vboxtop in top level window
00114     GtkWidget* vboxtop = gtk_vbox_new(FALSE, 3);
00115     gtk_container_add(GTK_CONTAINER(top_window), vboxtop);   
00116 
00117     // add title (header) in vboxtop
00118     create_title(GTK_VBOX(vboxtop), _("Settings"), _("MYIREX Account"));
00119 
00120     // add back/exit bar below title (header) in vboxtop
00121     GtkWidget* view = create_settingsview();
00122     gtk_box_pack_start(GTK_BOX(vboxtop), view, FALSE, FALSE,0 ); 
00123     g_signal_connect(view, "row-activated",   G_CALLBACK(on_listview_row_activated),   NULL);
00124     g_signal_connect(view, "navigate-cursor", G_CALLBACK(on_listview_navigate_cursor), NULL );
00125     g_signal_connect(view, "focus-in-event", G_CALLBACK(on_focus_in), NULL );
00126     g_signal_connect(view, "focus-out-event", G_CALLBACK(on_focus_out), NULL );
00127 
00128     // add alignment for frame below back/exit bar in vboxtop
00129     GtkWidget* top_frame_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 0.0 );
00130     gtk_box_pack_start(GTK_BOX(vboxtop), top_frame_alignment, FALSE, FALSE, 0);
00131 
00132     // add frame in top_frame_alignment
00133     GtkWidget* top_frame  = gtk_frame_new(NULL);
00134     gtk_widget_set_name(top_frame, "irex-margins-frame");
00135     gtk_container_add(GTK_CONTAINER(top_frame_alignment), top_frame);
00136     gtk_container_set_border_width(GTK_CONTAINER(top_frame), 3  );
00137 
00138     // Alignment.
00139     GtkWidget* alignment = gtk_alignment_new(0, 0, 1.0, 1.0);
00140     gtk_container_add(GTK_CONTAINER(top_frame), alignment);
00141     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00142                               WINDOW_TOP_ALT_PADDING,
00143                               WINDOW_BOTTOM_PADDING,
00144                               WINDOW_H_PADDING,
00145                               WINDOW_H_PADDING);
00146    
00147     // add  vbox in top frame 
00148     GtkWidget* vbox = gtk_vbox_new(FALSE, SMALL_SPACING);
00149     gtk_container_add(GTK_CONTAINER(alignment), vbox);
00150 
00151     // The label ("MyiRex Account Information").
00152     GtkWidget* label = gtk_label_new(_("MYIREX Account Information"));
00153     gtk_widget_set_name(label, "irex-normal-text");
00154     gtk_widget_set_size_request(label, -1, -1);
00155     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
00156     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
00157 
00158     // the second label
00159     label = gtk_label_new(_("A MYIREX account is used to deliver newspaper "
00160                             "and periodical subscriptions directly to your device."
00161                             ));
00162     gtk_widget_set_name(label, "irex-sans-small-grey-italic");
00163     gtk_widget_set_size_request(label, SETTINGS_LABEL_MAX_WIDTH - 15 , -1);
00164     gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
00165     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
00166     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
00167     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
00168 
00169     // hbox with username/email
00170     GtkWidget* hbox = gtk_hbox_new(FALSE,0);
00171     gtk_box_pack_start(GTK_BOX(vbox),hbox , FALSE, FALSE, SMALL_SPACING);
00172 
00173     // the label "email"
00174     label = gtk_label_new(_("Email"));
00175     gtk_widget_set_name(label, "irex-normal-text");
00176     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
00177     gtk_widget_set_size_request(label, ENTRY_LABEL_WIDTH, -1);
00178     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);  
00179     
00180     // the text entry for the email
00181     g_entry_email = ergtk_entry_new();
00182     gtk_widget_set_size_request(g_entry_email,ENTRY_EMAIL_WIDTH, -1);
00183     gtk_box_pack_start(GTK_BOX(hbox), g_entry_email, TRUE, TRUE, SMALL_SPACING);
00184     g_object_set(G_OBJECT(g_entry_email), "im-context-inhibit", TRUE, NULL);
00185      
00186     // second hbox for password
00187     hbox = gtk_hbox_new(FALSE,0);
00188     gtk_box_pack_start(GTK_BOX(vbox),hbox , FALSE, FALSE, SMALL_SPACING);
00189 
00190     // the label "password"
00191     label = gtk_label_new(_("Password"));
00192     gtk_widget_set_name(label, "irex-normal-text");
00193     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
00194     gtk_widget_set_size_request(label, ENTRY_LABEL_WIDTH, -1);
00195     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);  
00196     
00197     // the text entry for the password
00198     g_entry_passwd = ergtk_entry_new();
00199     gtk_entry_set_visibility(GTK_ENTRY(g_entry_passwd),FALSE);
00200     gtk_entry_set_max_length(GTK_ENTRY(g_entry_passwd),ENTRY_PASSWD_LENGTH_LIMITATION);
00201     gtk_widget_set_size_request(g_entry_passwd,ENTRY_PASSWD_WIDTH, -1);
00202     gtk_box_pack_start(GTK_BOX(hbox), g_entry_passwd, TRUE, TRUE, SMALL_SPACING);
00203     g_object_set(G_OBJECT(g_entry_passwd), "im-context-inhibit", TRUE, NULL);
00204 
00205     // hbuttonbox for the save button
00206     GtkWidget* hbuttonbox = gtk_hbutton_box_new();
00207     gtk_box_set_spacing(GTK_BOX(hbuttonbox), 15);
00208     gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_END);
00209     gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, FALSE, 0);
00210     // the save button
00211     GtkWidget* save_button = gtk_button_new_with_label( _("Save") );
00212     gtk_container_add(GTK_CONTAINER(hbuttonbox),save_button);
00213     g_signal_connect(G_OBJECT(save_button), "clicked", G_CALLBACK(on_save_button_clicked), NULL);
00214 
00215     // Add separator here.
00216     GtkWidget* separator = create_separator_widgets();
00217     gtk_widget_set_name(separator, "irex-separator-invisible");
00218     gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
00219 
00220     // label "To create ..."
00221     label = gtk_label_new(NULL);
00222     gtk_label_set_markup(GTK_LABEL(label), _("To create a MYIREX account, use a computer with internet "
00223       "connection and go to <b>www.irexreader.com/setup</b> for directions."));
00224     gtk_widget_set_name(label, "irex-sans-small-grey-italic");
00225     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
00226     gtk_widget_set_size_request(label, SETTINGS_LABEL_MAX_WIDTH, -1);
00227     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0);
00228     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 10);
00229     
00230     //  separator here.
00231     separator = create_separator_widgets();
00232     gtk_widget_set_name(separator, "irex-separator-invisible");
00233     gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
00234     
00235     // alignment for the keyboard (prevent ugly scaled buttons)
00236     GtkWidget* keyb_align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
00237     gtk_box_pack_start(GTK_BOX(vbox), keyb_align, FALSE, FALSE, 0 );
00238    
00239     // keyboard in keyb_align
00240     GtkWidget* keyboard = ergtk_keyb_new();
00241     gtk_container_add(GTK_CONTAINER(keyb_align), keyboard );
00242 
00243     // Update widget with current settings.
00244     init_widgets_with_settings();
00245    
00246     g_myirex_window = top_window;
00247 
00248     gtk_widget_grab_focus(view);
00249 
00250     gtk_widget_show_all(top_window);
00251 
00252     return top_window;
00253 }

Here is the caller graph for this function:

void load_account_settings (  ) 

Definition at line 255 of file irex-account.c.

Referenced by create_concrete_win().

00256 {
00257     gchar* email_gconf  = (gchar*)get_value_string(GCONF_DOWNLOAD_ACCOUNT_EMAIL);
00258     gchar* password_gconf = (gchar*)get_value_string(GCONF_DOWNLOAD_ACCOUNT_PASSWD);
00259 
00260     if (!email_gconf || !password_gconf)
00261     {
00262         ERRORPRINTF("Error reading settings from gconf");
00263         _exit(1);
00264     }
00265 
00266     strncpy(g_email, email_gconf, sizeof(g_email));
00267     g_email[sizeof(g_email)-1] = '\0';
00268     
00269     if (strcmp(password_gconf, "") != 0)
00270     {
00271         gchar* password_fixed = fix_base64_missing_equals(password_gconf);
00272         gsize len = 0;
00273         guchar* password = g_base64_decode(password_fixed, &len);
00274         g_free(password_fixed);
00275         strncpy(g_passwd, (gchar*)password, sizeof(g_passwd));
00276     }
00277     else
00278     {
00279         strncpy(g_passwd, password_gconf,  sizeof(g_passwd));
00280     }
00281     g_passwd[sizeof(g_passwd)-1] = '\0';
00282 
00283     g_free(email_gconf);
00284     g_free(password_gconf);
00285 }

Here is the caller graph for this function:

void save_account_settings (  ) 

Definition at line 288 of file irex-account.c.

Referenced by on_listview_row_activated(), and on_save_button_clicked().

00289 {
00290     const gchar* email = gtk_entry_get_text(GTK_ENTRY(g_entry_email));
00291     const gchar* passwd = gtk_entry_get_text(GTK_ENTRY(g_entry_passwd));
00292     if (email != NULL)
00293     {
00294       set_value_string(GCONF_DOWNLOAD_ACCOUNT_EMAIL, email);
00295 
00296         if (passwd != NULL)
00297         {
00298             if (strcmp(passwd, "") == 0)
00299             {
00300                 set_value_string(GCONF_DOWNLOAD_ACCOUNT_PASSWD, passwd);
00301             }
00302             else
00303             {
00304                 gsize len = strlen(passwd);  
00305                 gchar* passwd_encode = g_base64_encode((const guchar*)passwd, len); 
00306                 gchar* passwd_cut = cut_base64_existing_equals(passwd_encode);
00307                 set_value_string(GCONF_DOWNLOAD_ACCOUNT_PASSWD, passwd_cut);
00308                 g_free(passwd_encode);
00309                 g_free(passwd_cut);
00310                 
00311                 run_dialog(GTK_MESSAGE_INFO, _("Your MYIREX account has been saved"));
00312             }
00313         }
00314     }
00315 }

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208