contentLister/src/gtkDistListWnd.c File Reference

#include <gtk/gtk.h>
#include <liberdm/display.h>
#include <libergtk/ergtk.h>
#include <libermanifest/ermanifest.h>
#include "contentListerLog.h"
#include "displayUpdate.h"
#include "erbusy.h"
#include "erConnect.h"
#include "system.h"
#include "gtkPincodeScreen.h"
#include "control.h"
#include "erMdsContent.h"
#include "gtkDistListWnd.h"
#include "pagebar.h"
#include "languages.h"

Go to the source code of this file.

Functions

static void dist_list_wnd_create_notebook (void)
static void dist_list_wnd_notebook_append_page (void)
static void dist_list_wnd_update_pagebar (void)
static void on_switch_page (GtkNotebook *notebook, GtkNotebookPage *new_page, guint page_num, gpointer data)
static void on_selection_update (erGtkSelectionGroup *item, gpointer user_data)
void create_dist_list_wnd (GtkWidget *parent)
void dist_list_wnd_clear (void)
erGtkSelectionGroupdist_list_wnd_add_list (const gchar *display_as, const gchar *title, const gchar *instruction, const gchar **item_tbl)
void dist_list_wnd_page_forward (guint offset)
void dist_list_wnd_page_back (guint offset)
gboolean dist_list_wnd_is_visible (void)
void dist_list_wnd_goto_page (gint new_page)

Variables

static GtkWidget * g_parent_widget = NULL
static GtkWidget * g_notebook = NULL
static GtkWidget * g_lastpage_vbox = NULL
static guint g_lastpage_height = 0


Function Documentation

void create_dist_list_wnd ( GtkWidget *  parent  ) 

Create an empty distribution list window

Parameters:
parent - gtk event box on which to append the distribution list window
Returns:
--

Definition at line 69 of file gtkDistListWnd.c.

00070 {
00071     CL_LOGPRINTF("entry");
00072 
00073     g_parent_widget = parent;
00074     dist_list_wnd_create_notebook();
00075 }

Here is the call graph for this function:

erGtkSelectionGroup* dist_list_wnd_add_list ( const gchar *  display_as,
const gchar *  title,
const gchar *  instruction,
const gchar **  item_tbl 
)

Append a selection list to the distribution list window

Parameters:
display_as - specifies how to display the item list
title - text to appear in title bar
instruction - text to appear above list of items
item_tbl - array of items to be displayed
Returns:
erGtkSelectionGroup object for this list

Definition at line 88 of file gtkDistListWnd.c.

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     // determine display_as for selection list
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     // calculate space available for selection list
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     // create selection list
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         // list cannot start on current page
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     // add list to notebook, continue on next pages when needed
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         // add selection list to notebook
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         // create additional selection list, if needed
00180         if (item_tbl[next_item] == NULL)
00181         {
00182             // all items done, no continuation list needed
00183             list = NULL;
00184         }
00185         else
00186         {
00187             // item(s) left, start continuation list on new page
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 }

Here is the call graph for this function:

void dist_list_wnd_clear ( void   ) 

Clear the distribution window, i.e. remove all selection lists from it

Parameters:
-- 
Returns:
--

Definition at line 77 of file gtkDistListWnd.c.

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 }

Here is the call graph for this function:

static void dist_list_wnd_create_notebook ( void   )  [static]

Definition at line 267 of file gtkDistListWnd.c.

00268 {
00269     GtkWidget *widget;
00270 
00271     if (g_parent_widget)
00272     {
00273         // g_parent_widget
00274         //   |-- g_notebook (GtkNotebook)
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         // no selection lists yet
00287         g_lastpage_vbox   = NULL;
00288         g_lastpage_height = 0;
00289     }
00290 }

Here is the call graph for this function:

void dist_list_wnd_goto_page ( gint  page  ) 

Show specified page of distribution list window

Parameters:
page - pagenumber (1 ..) to display
Returns:
--

Definition at line 308 of file gtkDistListWnd.c.

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--;  // notebook counts 0 ..
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 }

Here is the call graph for this function:

gboolean dist_list_wnd_is_visible ( void   ) 

Tell whether distribution list window is visible

Parameters:
-- 
Returns:
TRUE/FALSE - window visible / not visible

Definition at line 253 of file gtkDistListWnd.c.

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 }

static void dist_list_wnd_notebook_append_page ( void   )  [static]

Definition at line 292 of file gtkDistListWnd.c.

00293 {
00294     GtkWidget *widget;
00295 
00296     // g_notebook (GtkNotebook)
00297     //   |-- g_lastpage_vbox (one for each page)
00298     //         |-- ...
00299     widget = gtk_vbox_new(FALSE, DIST_LIST_WND_V_SPACING);
00300     gtk_widget_show(widget);  // Note: MUST show widget before appending to notebook
00301     gtk_notebook_append_page(GTK_NOTEBOOK(g_notebook), widget, NULL);
00302     g_lastpage_vbox = widget;
00303 
00304     // no selection lists yet
00305     g_lastpage_height = 0;
00306 }

void dist_list_wnd_page_back ( guint  offset  ) 

Definition at line 228 of file gtkDistListWnd.c.

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 }

Here is the call graph for this function:

void dist_list_wnd_page_forward ( guint  offset  ) 

Goto next page / previous page

Parameters:
-- 
Returns:
--

Definition at line 202 of file gtkDistListWnd.c.

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 }

Here is the call graph for this function:

static void dist_list_wnd_update_pagebar ( void   )  [static]

Definition at line 328 of file gtkDistListWnd.c.

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();   // send pageBar events to us
00336     pagebar_set_pagecount(num_pages);
00337     pagebar_goto_page(current_page + 1);  // pagebar counts from 1
00338     pagebar_redraw();
00339 }

Here is the call graph for this function:

static void on_selection_update ( erGtkSelectionGroup item,
gpointer  user_data 
) [static]

Definition at line 361 of file gtkDistListWnd.c.

00362 {
00363     CL_LOGPRINTF("entry");
00364 
00365     display_update_request_screen_refresh(TEXTENTRY_CHANGED_LEVEL);
00366 }

Here is the call graph for this function:

static void on_switch_page ( GtkNotebook *  notebook,
GtkNotebookPage *  new_page,
guint  page_num,
gpointer  data 
) [static]

Definition at line 343 of file gtkDistListWnd.c.

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 }

Here is the call graph for this function:


Variable Documentation

guint g_lastpage_height = 0 [static]

Definition at line 56 of file gtkDistListWnd.c.

GtkWidget* g_lastpage_vbox = NULL [static]

Definition at line 55 of file gtkDistListWnd.c.

GtkWidget* g_notebook = NULL [static]

Definition at line 54 of file gtkDistListWnd.c.

GtkWidget* g_parent_widget = NULL [static]

Definition at line 53 of file gtkDistListWnd.c.


Generated on Sun Dec 14 17:13:28 2008 by  doxygen 1.5.6