00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00029
00030 #include <gtk/gtk.h>
00031
00032
00033 #include <liberdm/display.h>
00034 #include <libergtk/ergtk.h>
00035 #include <libermanifest/ermanifest.h>
00036
00037
00038 #include "contentListerLog.h"
00039 #include "displayUpdate.h"
00040 #include "erbusy.h"
00041 #include "erConnect.h"
00042 #include "system.h"
00043 #include "gtkPincodeScreen.h"
00044 #include "control.h"
00045 #include "erMdsContent.h"
00046 #include "gtkDistListWnd.h"
00047 #include "pagebar.h"
00048
00049 #include "languages.h"
00050
00051
00052
00053 static GtkWidget* g_parent_widget = NULL;
00054 static GtkWidget* g_notebook = NULL;
00055 static GtkWidget* g_lastpage_vbox = NULL;
00056 static guint g_lastpage_height = 0;
00057
00058
00059 static void dist_list_wnd_create_notebook(void);
00060 static void dist_list_wnd_notebook_append_page(void);
00061 static void dist_list_wnd_update_pagebar(void);
00062
00063
00064 static void on_switch_page(GtkNotebook *notebook, GtkNotebookPage *new_page, guint page_num, gpointer data);
00065 static void on_selection_update(erGtkSelectionGroup *item, gpointer user_data);
00066
00067
00068
00069 void create_dist_list_wnd(GtkWidget *parent)
00070 {
00071 CL_LOGPRINTF("entry");
00072
00073 g_parent_widget = parent;
00074 dist_list_wnd_create_notebook();
00075 }
00076
00077 void dist_list_wnd_clear(void)
00078 {
00079 CL_LOGPRINTF("entry: g_notebook [%p]", g_notebook);
00080
00081 if (g_notebook)
00082 {
00083 gtk_widget_destroy(g_notebook);
00084 dist_list_wnd_create_notebook();
00085 }
00086 }
00087
00088 erGtkSelectionGroup* dist_list_wnd_add_list(const gchar* display_as,
00089 const gchar* title,
00090 const gchar* instruction,
00091 const gchar** item_tbl)
00092 {
00093 CL_LOGPRINTF("entry: title [%s]", title);
00094
00095 GtkWidget* list = NULL;
00096 GtkWidget* master_list = NULL;
00097 GtkWidget* lastpage_vbox = g_lastpage_vbox;
00098 guint list_height = 0;
00099 guint list_items = 0;
00100 guint next_item = 0;
00101 guint available_height;
00102
00103
00104 erGtkSelectionList_displayAs_e list_display_as;
00105 if (strcmp(display_as, "radiobutton") == 0)
00106 {
00107 list_display_as = esl_RadioButton;
00108 }
00109 else if (strcmp(display_as, "textbutton") == 0)
00110 {
00111 list_display_as = esl_TextButton;
00112 }
00113 else
00114 {
00115 list_display_as = esl_Checklist;
00116 }
00117
00118
00119 if (lastpage_vbox == NULL)
00120 {
00121 available_height = DIST_LIST_WND_HEIGHT_SMALL;
00122 }
00123 else
00124 {
00125 if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(g_notebook)) <= 1)
00126 {
00127 available_height = DIST_LIST_WND_HEIGHT_SMALL;
00128 }
00129 else
00130 {
00131 available_height = DIST_LIST_WND_HEIGHT_BIG;
00132 }
00133 available_height = available_height - g_lastpage_height - DIST_LIST_WND_V_SPACING;
00134 }
00135
00136
00137 list = ergtk_selection_list_new( list_display_as,
00138 title,
00139 instruction,
00140 item_tbl,
00141 available_height,
00142 &list_items,
00143 &list_height );
00144 if (list == NULL)
00145 {
00146
00147 lastpage_vbox = NULL;
00148 available_height = DIST_LIST_WND_HEIGHT_BIG;
00149 list = ergtk_selection_list_new( list_display_as,
00150 title,
00151 instruction,
00152 item_tbl,
00153 available_height,
00154 &list_items,
00155 &list_height );
00156 }
00157
00158
00159 master_list = list;
00160 while (list)
00161 {
00162 g_signal_connect(G_OBJECT(list), "selection-update", G_CALLBACK(on_selection_update), NULL);
00163
00164
00165 if (lastpage_vbox == NULL)
00166 {
00167 dist_list_wnd_notebook_append_page();
00168 lastpage_vbox = g_lastpage_vbox;
00169
00170 g_lastpage_height += list_height;
00171 }
00172 else
00173 {
00174 g_lastpage_height += DIST_LIST_WND_V_SPACING + list_height;
00175 }
00176 gtk_box_pack_start(GTK_BOX(lastpage_vbox), list, FALSE, FALSE, 0);
00177 next_item += list_items;
00178
00179
00180 if (item_tbl[next_item] == NULL)
00181 {
00182
00183 list = NULL;
00184 }
00185 else
00186 {
00187
00188 lastpage_vbox = NULL;
00189 available_height = DIST_LIST_WND_HEIGHT_BIG;
00190
00191 list = ergtk_selection_list_new_from_master( ERGTK_SELECTION_LIST(master_list),
00192 next_item,
00193 available_height,
00194 &list_items,
00195 &list_height );
00196 }
00197 }
00198
00199 return ERGTK_SELECTION_GROUP(master_list);
00200 }
00201
00202 void dist_list_wnd_page_forward(guint offset)
00203 {
00204 gint last_page;
00205 gint old_page;
00206 gint new_page;
00207
00208 if (g_notebook)
00209 {
00210 last_page = gtk_notebook_get_n_pages(GTK_NOTEBOOK(g_notebook)) - 1;
00211 old_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(g_notebook));
00212 if (old_page < last_page)
00213 {
00214 new_page = old_page + offset;
00215 if (new_page > last_page)
00216 {
00217 new_page = last_page;
00218 }
00219 gtk_notebook_set_current_page(GTK_NOTEBOOK(g_notebook), new_page);
00220 }
00221 else
00222 {
00223 erbusy_off();
00224 }
00225 }
00226 }
00227
00228 void dist_list_wnd_page_back(guint offset)
00229 {
00230 gint first_page = 0;
00231 gint old_page;
00232 gint new_page;
00233
00234 if (g_notebook)
00235 {
00236 old_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(g_notebook));
00237 if (old_page > first_page)
00238 {
00239 new_page = old_page - offset;
00240 if (new_page < first_page)
00241 {
00242 new_page = first_page;
00243 }
00244 gtk_notebook_set_current_page(GTK_NOTEBOOK(g_notebook), new_page);
00245 }
00246 else
00247 {
00248 erbusy_off();
00249 }
00250 }
00251 }
00252
00253 gboolean dist_list_wnd_is_visible(void)
00254 {
00255 if (g_parent_widget && GTK_WIDGET_VISIBLE(g_parent_widget))
00256 {
00257 return TRUE;
00258 }
00259 else
00260 {
00261 return FALSE;
00262 }
00263 }
00264
00265
00266
00267 static void dist_list_wnd_create_notebook(void)
00268 {
00269 GtkWidget *widget;
00270
00271 if (g_parent_widget)
00272 {
00273
00274
00275
00276 widget = gtk_notebook_new();
00277 gtk_widget_set_size_request(widget, DIST_LIST_WND_WIDTH, -1);
00278 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE);
00279 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE);
00280 g_signal_connect_after(widget, "switch-page", G_CALLBACK(on_switch_page), NULL);
00281 g_signal_connect_after(widget, "destroy-event", G_CALLBACK(gtk_widget_destroyed), &g_notebook);
00282 gtk_container_add(GTK_CONTAINER(g_parent_widget), widget);
00283 gtk_widget_show(widget);
00284 g_notebook = widget;
00285
00286
00287 g_lastpage_vbox = NULL;
00288 g_lastpage_height = 0;
00289 }
00290 }
00291
00292 static void dist_list_wnd_notebook_append_page(void)
00293 {
00294 GtkWidget *widget;
00295
00296
00297
00298
00299 widget = gtk_vbox_new(FALSE, DIST_LIST_WND_V_SPACING);
00300 gtk_widget_show(widget);
00301 gtk_notebook_append_page(GTK_NOTEBOOK(g_notebook), widget, NULL);
00302 g_lastpage_vbox = widget;
00303
00304
00305 g_lastpage_height = 0;
00306 }
00307
00308 void dist_list_wnd_goto_page(gint new_page)
00309 {
00310 gint old_page;
00311
00312 if (g_notebook)
00313 {
00314 old_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(g_notebook));
00315 new_page--;
00316
00317 if (new_page != old_page)
00318 {
00319 gtk_notebook_set_current_page(GTK_NOTEBOOK(g_notebook), new_page);
00320 }
00321 else
00322 {
00323 dist_list_wnd_update_pagebar();
00324 }
00325 }
00326 }
00327
00328 static void dist_list_wnd_update_pagebar()
00329 {
00330 const gint current_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(g_notebook));
00331 const gint num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(g_notebook));
00332
00333 CL_LOGPRINTF("entry: page [%d] num_pages [%d]", current_page, num_pages);
00334
00335 pagebar_reset();
00336 pagebar_set_pagecount(num_pages);
00337 pagebar_goto_page(current_page + 1);
00338 pagebar_redraw();
00339 }
00340
00341
00342
00343 static void on_switch_page(GtkNotebook *notebook, GtkNotebookPage *new_page, guint page_num, gpointer data)
00344 {
00345 CL_LOGPRINTF("entry: new_page [%d]", (int)page_num);
00346
00347 dist_list_wnd_update_pagebar();
00348
00349 if (page_num == 0)
00350 {
00351 ctrl_show_lister_area();
00352 }
00353 else
00354 {
00355 ctrl_hide_lister_area();
00356 }
00357
00358 display_update_request_screen_refresh(LISTER_EXPOSE_LEVEL);
00359 }
00360
00361 static void on_selection_update(erGtkSelectionGroup *item, gpointer user_data)
00362 {
00363 CL_LOGPRINTF("entry");
00364
00365 display_update_request_screen_refresh(TEXTENTRY_CHANGED_LEVEL);
00366 }
00367