#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#include <liberregxml/erregapi.h>
Go to the source code of this file.
Functions | |
GtkWidget * | edit_static_create (void) |
void | edit_static_set_text (void) |
void | edit_static_set_network_settings (const regNetworkProfile_t *settings) |
void | edit_static_get_network_settings (regNetworkProfile_t *settings) |
gboolean | edit_static_check_network_settings (void) |
void | edit_static_restore_network_settings (void) |
void | edit_static_set_title (const char *profilename) |
void | edit_static_screen_leave (void) |
gboolean | on_edit_static_keypress (GdkEventKey *event) |
gboolean edit_static_check_network_settings | ( | void | ) |
Definition at line 513 of file editScreenStatic.c.
00514 { 00515 staticStatus_t status; 00516 gboolean valid = TRUE; 00517 00518 CN_LOGPRINTF("entry"); 00519 00520 status = edit_static_detect_status(); 00521 if (status != undefStatus_e) 00522 { 00523 valid = FALSE; 00524 } 00525 00526 CN_LOGPRINTF("return valid=%d", valid); 00527 return valid; 00528 }
GtkWidget* edit_static_create | ( | void | ) |
Definition at line 93 of file editScreenStatic.c.
00094 { 00095 GtkWidget *item; 00096 GtkWidget *topVbox; 00097 GtkWidget *background; 00098 GtkWidget *alignment; 00099 GtkWidget *vbox; 00100 wdtLabelEntry *address; 00101 wdtLabelEntry *netmask; 00102 wdtLabelEntry *gateway; 00103 wdtLabelEntry *dns; 00104 GtkWidget *info; 00105 GtkWidget *widget; 00106 00107 CN_LOGPRINTF("entry"); 00108 00109 // item 00110 item = gtk_settingitem_new(""); 00111 00112 // topVbox 00113 topVbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00114 gtk_settingitem_add_details(GTK_SETTINGITEM(item), topVbox); 00115 00116 // background 00117 background = gtk_event_box_new(); 00118 gtk_widget_set_name(background, "bk_grey_666_273"); 00119 gtk_widget_set_size_request(background, 00120 BK_666_273_WIDTH, BK_666_273_HEIGHT); 00121 gtk_box_pack_start(GTK_BOX(topVbox), background, FALSE, FALSE, 0); 00122 00123 // alignment 00124 alignment = gtk_alignment_new(0.0, 0.0, 0, 0); 00125 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00126 PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT); 00127 gtk_container_add(GTK_CONTAINER(background), alignment); 00128 00129 // vbox 00130 vbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00131 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00132 00133 // address 00134 address = wdt_label_entry_new(ipAddress_e); 00135 gtk_box_pack_start(GTK_BOX(vbox), address->parent, FALSE, FALSE, 0); 00136 00137 // netmask 00138 netmask = wdt_label_entry_new(ipAddress_e); 00139 gtk_box_pack_start(GTK_BOX(vbox), netmask->parent, FALSE, FALSE, 0); 00140 00141 // gateway 00142 gateway = wdt_label_entry_new(ipAddress_e); 00143 gtk_box_pack_start(GTK_BOX(vbox), gateway->parent, FALSE, FALSE, 0); 00144 00145 // dns 00146 dns = wdt_label_entry_new(ipAddress_e); 00147 gtk_box_pack_start(GTK_BOX(vbox), dns->parent, FALSE, FALSE, 0); 00148 00149 // info item 00150 info = gtk_infoitem_new(FALSE); 00151 gtk_box_pack_start(GTK_BOX(topVbox), info, FALSE, FALSE, 0); 00152 00153 // signal handlers 00154 widget = dns->button; 00155 g_signal_connect_after(G_OBJECT(widget), "toggled", 00156 G_CALLBACK(on_next), NULL); 00157 00158 // show the widgets 00159 gtk_widget_show(item); 00160 gtk_widget_show(topVbox); 00161 gtk_widget_show(background); 00162 gtk_widget_show(alignment); 00163 gtk_widget_show(vbox); 00164 gtk_widget_show(address->parent); 00165 gtk_widget_hide(address->button); 00166 gtk_widget_show(netmask->parent); 00167 gtk_widget_hide(netmask->button); 00168 gtk_widget_show(gateway->parent); 00169 gtk_widget_hide(gateway->button); 00170 gtk_widget_show(dns->parent); 00171 gtk_widget_show(info); 00172 00173 // set the global variables 00174 g_static = item; 00175 g_address = address; 00176 g_netmask = netmask; 00177 g_gateway = gateway; 00178 g_dns = dns; 00179 g_info = info; 00180 00181 CN_LOGPRINTF("done"); 00182 00183 // return 00184 return item; 00185 }
void edit_static_get_network_settings | ( | regNetworkProfile_t * | settings | ) |
Definition at line 408 of file editScreenStatic.c.
00409 { 00410 const gchar *address, *netmask, *gateway, *dns; 00411 regIpSetting_t *ipSettings; 00412 00413 CN_LOGPRINTF("entry"); 00414 00415 g_return_if_fail(settings != NULL); 00416 g_return_if_fail(settings->addressMode == static_t); 00417 00418 // clear static IP settings 00419 ipSettings = settings->ipSettings; 00420 if (ipSettings) 00421 { 00422 g_free(ipSettings->address); 00423 g_free(ipSettings->netmask); 00424 g_free(ipSettings->gateway); 00425 g_free(ipSettings->dns); 00426 g_free(ipSettings); 00427 ipSettings = NULL; 00428 settings->ipSettings = NULL; 00429 } 00430 00431 // get current value from screen objects 00432 address = edit_static_get_address(); 00433 netmask = edit_static_get_netmask(); 00434 gateway = edit_static_get_gateway(); 00435 dns = edit_static_get_dns(); 00436 00437 // store new settings, if static IP selected 00438 if (settings->addressMode == static_t) 00439 { 00440 ipSettings = g_new0(regIpSetting_t, 1); 00441 if (ipSettings) 00442 { 00443 ipSettings->address = g_strdup(address); 00444 ipSettings->netmask = g_strdup(netmask); 00445 ipSettings->gateway = g_strdup(gateway); 00446 ipSettings->dns = g_strdup(dns ); 00447 } 00448 settings->ipSettings = ipSettings; 00449 } 00450 }
void edit_static_restore_network_settings | ( | void | ) |
Definition at line 560 of file editScreenStatic.c.
00561 { 00562 char *address = NULL; 00563 char *netmask = NULL; 00564 char *gateway = NULL; 00565 char *dns = NULL; 00566 00567 CN_LOGPRINTF("entry"); 00568 00569 if (g_old_settings) 00570 { 00571 address = g_old_settings->address; 00572 netmask = g_old_settings->netmask; 00573 gateway = g_old_settings->gateway; 00574 dns = g_old_settings->dns; 00575 } 00576 00577 edit_static_set_address(address); 00578 edit_static_set_netmask(netmask); 00579 edit_static_set_gateway(gateway); 00580 edit_static_set_dns(dns); 00581 }
void edit_static_screen_leave | ( | void | ) |
Definition at line 583 of file editScreenStatic.c.
00584 { 00585 gboolean valid = TRUE; 00586 00587 CN_LOGPRINTF("entry"); 00588 00589 valid = edit_static_check_network_settings(); 00590 00591 // force overview screen to DHCP when no static settings 00592 if (!valid) 00593 { 00594 edit_overview_set_address(dhcp_t); 00595 } 00596 }
void edit_static_set_network_settings | ( | const regNetworkProfile_t * | settings | ) |
Definition at line 295 of file editScreenStatic.c.
00296 { 00297 gchar *profilename = NULL; 00298 gchar *address = NULL; 00299 gchar *netmask = NULL; 00300 gchar *gateway = NULL; 00301 gchar *dns = NULL; 00302 regIpSetting_t* ipSettings; 00303 00304 CN_LOGPRINTF("entry [%p]", settings); 00305 00306 g_return_if_fail(settings != NULL); 00307 // g_return_if_fail(settings->addressMode == static_t); 00308 00309 profilename = settings->name; 00310 00311 ipSettings = settings->ipSettings; 00312 if (ipSettings) 00313 { 00314 address = ipSettings->address; 00315 netmask = ipSettings->netmask; 00316 gateway = ipSettings->gateway; 00317 dns = ipSettings->dns; 00318 } 00319 00320 edit_static_set_title(profilename); 00321 edit_static_set_address(address); 00322 edit_static_set_netmask(netmask); 00323 edit_static_set_gateway(gateway); 00324 edit_static_set_dns(dns); 00325 00326 edit_static_determine_status(); 00327 00328 // a backup copy of settings 00329 edit_static_backup_network_settings(); 00330 }
void edit_static_set_text | ( | void | ) |
Definition at line 187 of file editScreenStatic.c.
00188 { 00189 GtkWidget* widget = NULL; 00190 00191 CN_LOGPRINTF("entry"); 00192 00193 if (g_static) 00194 { 00195 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_static), 00196 _("Network profile")); 00197 } 00198 00199 if (g_address) 00200 { 00201 widget = g_address->label; 00202 gtk_label_set_text(GTK_LABEL(widget), 00203 _("Enter the iLiad's IP address:")); 00204 } 00205 00206 if (g_netmask) 00207 { 00208 widget = g_netmask->label; 00209 gtk_label_set_text(GTK_LABEL(widget), 00210 _("Enter the iLiad's netmask:")); 00211 } 00212 00213 if (g_gateway) 00214 { 00215 widget = g_gateway->label; 00216 gtk_label_set_text(GTK_LABEL(widget), 00217 _("Enter the default gateway's IP address:")); 00218 } 00219 00220 if (g_dns) 00221 { 00222 widget = g_dns->label; 00223 gtk_label_set_text(GTK_LABEL(widget), 00224 _("Enter the DNS name server's IP address:")); 00225 00226 widget = g_dns->button; 00227 gtk_button_set_label(GTK_BUTTON(widget), _("Next")); 00228 } 00229 00230 if (g_info) 00231 { 00232 gtk_infoitem_set_text(GTK_INFOITEM(g_info), 00233 _("If you do not know the settings for this network, " 00234 "please ask your network administrator.")); 00235 } 00236 }
void edit_static_set_title | ( | const char * | profilename | ) |
Definition at line 332 of file editScreenStatic.c.
00333 { 00334 char *title = NULL; 00335 00336 CN_LOGPRINTF("entry[%s]", profilename); 00337 00338 if (g_static) 00339 { 00340 if (profilename) 00341 { 00342 title = g_strdup_printf(_("Network profile: %s/static"), 00343 profilename); 00344 } 00345 else 00346 { 00347 title = g_strdup(_("Network profile: static")); 00348 } 00349 00350 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_static), title); 00351 00352 g_free(title); 00353 } 00354 }
gboolean on_edit_static_keypress | ( | GdkEventKey * | event | ) |
Definition at line 640 of file editScreenStatic.c.
00641 { 00642 GtkToggleButton *button; 00643 gboolean ret = FALSE; 00644 00645 CN_LOGPRINTF("entry"); 00646 00647 switch (event->keyval) 00648 { 00649 case GDK_Return: 00650 // 'Enter' key is pressed 00651 // simulate clicking the 'Next' button 00652 if (g_dns) 00653 { 00654 button = GTK_TOGGLE_BUTTON(g_dns->button); 00655 gtk_toggle_button_set_active(button, TRUE); 00656 } 00657 ret = TRUE; 00658 break; 00659 00660 case GDK_F5: 00661 // 'UP' key is pressed 00662 // goto the one top level page 00663 cmgr_up_page(); 00664 ret = TRUE; 00665 break; 00666 00667 case GDK_Down: 00668 case GDK_Up: 00669 // avoid the standard GTK behaviour for GtkEntries 00670 erbusy_off(); 00671 ret = TRUE; 00672 00673 default: 00674 erbusy_off(); 00675 break; 00676 } 00677 00678 return ret; 00679 }