00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00029 #include <unistd.h>
00030 #include <string.h>
00031
00032 #include <gtk/gtk.h>
00033 #include <gdk/gdkkeysyms.h>
00034
00035 #include <liberipc/eripctoolbar.h>
00036
00037 #include "connectionMgrLog.h"
00038 #include "displayStatus.h"
00039 #include "connectionMgr.h"
00040 #include "background.h"
00041 #include "connectScreen.h"
00042 #include "connectScreenOptions.h"
00043 #include "connectScreenProfiles.h"
00044 #include "connectScreenData.h"
00045 #include "connectScan.h"
00046 #include "connectPing.h"
00047 #include "connectBackground.h"
00048 #include "pagebar.h"
00049 #include "erbusy.h"
00050 #include "toolbar.h"
00051
00052
00053 static GtkWidget *g_connect_notebook = NULL;
00054
00055
00056 static void on_connect_switch_page (GtkNotebook * notebook,
00057 GtkNotebookPage * new_page,
00058 guint page_num,
00059 gpointer data);
00060
00061
00062 static void connect_show_back(void);
00063 static void connect_show_keyboard(void);
00064 static void connect_show_trashcan(void);
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 GtkWidget *connect_screen_create (void)
00075 {
00076 CN_LOGPRINTF ("entry");
00077
00078 GtkWidget *alignment;
00079 GtkWidget *page;
00080
00081
00082 alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
00083 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
00084 0, 0, SCREEN_BORDER, 0);
00085 gtk_widget_show(alignment);
00086
00087
00088 g_connect_notebook = gtk_notebook_new ();
00089 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (g_connect_notebook), FALSE);
00090 gtk_notebook_set_show_border (GTK_NOTEBOOK (g_connect_notebook), FALSE);
00091 gtk_container_add (GTK_CONTAINER (alignment), g_connect_notebook);
00092
00093
00094 page = connect_options_create ();
00095 gtk_notebook_append_page(GTK_NOTEBOOK (g_connect_notebook), page, NULL);
00096
00097
00098 page = connect_profiles_create ();
00099 gtk_notebook_append_page(GTK_NOTEBOOK(g_connect_notebook), page, NULL);
00100
00101
00102 gtk_notebook_set_current_page (GTK_NOTEBOOK(g_connect_notebook), 0);
00103 gtk_widget_show (g_connect_notebook);
00104
00105 g_signal_connect_after(g_connect_notebook, "switch-page",
00106 G_CALLBACK (on_connect_switch_page), NULL);
00107
00108 return alignment;
00109 }
00110
00111 void connect_screen_display(void)
00112 {
00113 int page;
00114
00115 CN_LOGPRINTF ("entry");
00116
00117 page = connect_get_current_page(NULL);
00118 if (page == connectScreenOptions_e)
00119 {
00120 connect_options_display();
00121 }
00122 else if (page == connectScreenProfiles_e)
00123 {
00124 connect_profiles_display();
00125 }
00126 }
00127
00128
00129 void connect_screen_set_text(void)
00130 {
00131 CN_LOGPRINTF ("entry");
00132
00133 connect_options_set_text();
00134 connect_profiles_set_text();
00135 }
00136
00137
00138 void connect_set_pagebar (void)
00139 {
00140 CN_LOGPRINTF ("entry");
00141
00142
00143
00144
00145 if (!main_get_background ())
00146 {
00147
00148
00149 pagebar_reset ();
00150
00151
00152
00153 pagebar_set_pagecount( 1 );
00154 pagebar_goto_page( 1 );
00155 pagebar_redraw();
00156 }
00157 }
00158
00159 void connect_set_toolbar(void)
00160 {
00161 CN_LOGPRINTF("entry");
00162
00163 connect_show_back();
00164 connect_show_keyboard();
00165 connect_show_trashcan();
00166 }
00167
00168 static void connect_show_back(void)
00169 {
00170 screenPage_t curPage, backPage;
00171
00172 CN_LOGPRINTF("entry");
00173
00174 curPage.screen = cmgrScreenConnect_e;
00175 curPage.page = connect_get_current_page(NULL);
00176
00177 cmgr_get_back_page(&curPage, &backPage);
00178
00179 if ((backPage.screen == cmgrScreenUndef_e)
00180 || (backPage.page == -1))
00181 {
00182 toolbar_setIconState(iconID_back, iconState_grey);
00183 }
00184 else
00185 {
00186 toolbar_setIconState(iconID_back, iconState_normal);
00187 }
00188 }
00189
00190 static void connect_show_keyboard(void)
00191 {
00192 CN_LOGPRINTF("entry");
00193 show_keyboard(FALSE);
00194 }
00195
00196 static void connect_show_trashcan(void)
00197 {
00198 CN_LOGPRINTF("entry");
00199 toolbar_setIconState(iconID_trashcan, iconState_grey);
00200 }
00201
00202
00203 static void on_connect_switch_page (GtkNotebook * notebook,
00204 GtkNotebookPage * new_page,
00205 guint page_num,
00206 gpointer data)
00207 {
00208 CN_LOGPRINTF ("Entry, new_page [%d]", (int) page_num);
00209
00210 connect_set_pagebar();
00211 connect_set_toolbar();
00212 }
00213
00214 gint connect_get_current_page (gint * pagecount)
00215 {
00216 GtkNotebook *notebook = GTK_NOTEBOOK(g_connect_notebook);
00217
00218
00219 if (pagecount != NULL)
00220 {
00221 *pagecount = gtk_notebook_get_n_pages(notebook);
00222 }
00223
00224
00225 return gtk_notebook_get_current_page(notebook);
00226 }
00227
00228
00229 gboolean on_connect_keypress (GdkEventKey * event)
00230 {
00231 guint ret = 0;
00232
00233 CN_LOGPRINTF ("entry");
00234
00235 switch (connect_get_current_page(NULL))
00236 {
00237 case connectScreenOptions_e:
00238 ret = on_connect_options_keypress(event);
00239 break;
00240 case connectScreenProfiles_e:
00241 ret = on_connect_profiles_keypress(event);
00242 break;
00243 default:
00244 CN_ERRORPRINTF ("-- case default");
00245 erbusy_off ();
00246 break;
00247 }
00248
00249 return ret;
00250 }
00251
00252 void connect_goto_page(connectScreen_t newpage)
00253 {
00254 GtkNotebook *notebook;
00255 gint curpage, pagecount;
00256
00257 curpage = connect_get_current_page(&pagecount);
00258 if (curpage != newpage)
00259 {
00260 if (newpage >= 0 && newpage < pagecount)
00261 {
00262 CN_LOGPRINTF ("curpage %d-->newpage %d, pagecount %d",
00263 curpage, newpage, pagecount);
00264 notebook = GTK_NOTEBOOK(g_connect_notebook);
00265 gtk_notebook_set_current_page(notebook, newpage);
00266 }
00267 }
00268 }
00269
00270 void on_connect_goto_page (gint newpage)
00271 {
00272 CN_LOGPRINTF("entry newpage[%d]", newpage);
00273 connect_goto_page(newpage - 1);
00274 }
00275
00276 void on_connect_icon_clicked(int iconID, int iconState)
00277 {
00278 int page;
00279
00280 CN_LOGPRINTF("entry iconID[%d] iconState[%d]", iconID, iconState);
00281
00282 switch (iconID)
00283 {
00284 case iconID_back:
00285 page = connect_get_current_page(NULL);
00286 if (page == connectScreenProfiles_e)
00287 {
00288 on_connect_profiles_icon_clicked(iconID, iconState);
00289 }
00290 break;
00291 default:
00292 break;
00293 }
00294 }
00295