connectionMgr/inc/widgetUtils.h File Reference

connectionMgr - Some utilities of creating widgets. More...

#include <glib.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include <libergtk/ergtk.h>
#include "connectPing.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _wdtLabelEntry
struct  _wdtLabelButton
struct  _bkWdtLabelEntry
struct  _bkWdtLabelButton
struct  _bkProfileEntry

Typedefs

typedef struct _wdtLabelEntry wdtLabelEntry
typedef struct _wdtLabelButton wdtLabelButton
typedef struct _bkWdtLabelEntry bkWdtLabelEntry
typedef struct _bkWdtLabelButton bkWdtLabelButton
typedef struct _bkProfileEntry bkProfileEntry

Functions

wdtLabelEntrywdt_label_entry_new (entryFilter_e filter)
wdtLabelButtonwdt_label_button_new (int nbutton, gboolean smallButton, int minsel, int maxsel)
bkWdtLabelEntrybk_wdt_label_entry_new (entryFilter_e filter)
bkWdtLabelButtonbk_wdt_label_button_new (int nbutton, gboolean smallButton, int minsel, int maxsel)
bkProfileEntrybk_profile_entry_new (void)
void bk_profile_entry_display (const bkProfileEntry *item, const regNetworkProfile_t *settings)
void bk_profile_entry_update_status (const bkProfileEntry *item, pingStatus_t status)


Detailed Description

connectionMgr - Some utilities of creating widgets.

These widgets include: (1) The wdtLabelEntry contains one label at first line, and one text entry and one button at second line. (2) The wdtLabelButton contains one label at first line, and some small or normal buttons at second line, and these buttons only can be selected exclusively. (3) The bkWdtLabelEntry contains one wdtLabelEntry in background. (4) The bkWdtLabelButton contains one wdtLabelButton in background. (5) The bkProfileEntry contains one gtkProfileEntry in background.

Annotation: wdt is the abbrev of widget, bk is the abbrev of background.

Copyright (C) 2007 iRex Technologies BV.

Definition in file widgetUtils.h.


Typedef Documentation

typedef struct _wdtLabelEntry wdtLabelEntry


Function Documentation

void bk_profile_entry_display ( const bkProfileEntry item,
const regNetworkProfile_t settings 
)

Definition at line 372 of file widgetUtils.c.

00374 {
00375     GtkWidget        *widget;
00376     networkProfile_t nwSettings;
00377 
00378     g_return_if_fail(item != NULL);
00379     g_return_if_fail(settings != NULL);
00380 
00381     // display the profile entry
00382     nwSettings.scanSettings = NULL;
00383    
00384     nwSettings.regSettingsList = g_new0(regNetworkProfile_t*, 1);
00385     g_return_if_fail(nwSettings.regSettingsList != NULL);
00386     
00387     nwSettings.regSettingsList[0] = (regNetworkProfile_t*)settings; 
00388     nwSettings.regIndexList = NULL;
00389     nwSettings.nRegProfiles = 1;
00390     nwSettings.nActiveIndex = 0;
00391 
00392     widget = item->details;
00393     gtk_profile_entry_display_settings(GTK_PROFILE_ENTRY(widget), 
00394                                        &nwSettings, "");
00395     
00396     g_free(nwSettings.regSettingsList);
00397     nwSettings.regSettingsList = NULL;
00398 }

Here is the call graph for this function:

bkProfileEntry* bk_profile_entry_new ( void   ) 

Definition at line 332 of file widgetUtils.c.

00333 {
00334     GtkWidget *background = NULL;
00335     GtkWidget *alignment = NULL; 
00336     GtkWidget *details = NULL;
00337     bkProfileEntry *item = NULL;
00338 
00339     CN_LOGPRINTF("entry");
00340 
00341     // background
00342     background = gtk_event_box_new();
00343     gtk_widget_set_name(background, "bk_grey_666_75");
00344     gtk_widget_set_size_request(background, 
00345             SITEM_BK_WIDTH, SITEM_BK_HEIGHT);
00346 
00347     // alignment
00348     alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
00349     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00350             PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT);
00351     gtk_container_add(GTK_CONTAINER(background), alignment);
00352 
00353     // details
00354     details = gtk_profile_entry_new();
00355     g_assert(details != NULL);
00356     gtk_container_add(GTK_CONTAINER(alignment), details);
00357 
00358     // show widgets
00359     gtk_widget_show(alignment);
00360     gtk_widget_show(details);
00361 
00362     // item 
00363     item = g_new0(bkProfileEntry, 1);
00364     g_assert(item != NULL);
00365     item->background = background;
00366     item->details = details;
00367 
00368     // return value
00369     return item;
00370 }

Here is the call graph for this function:

void bk_profile_entry_update_status ( const bkProfileEntry item,
pingStatus_t  status 
)

Definition at line 400 of file widgetUtils.c.

00402 {
00403     gchar     *text;
00404     gboolean  flashing = FALSE;
00405     GtkWidget *widget;
00406 
00407     g_return_if_fail(item != NULL);
00408 
00409     switch (status)
00410     {
00411         case pingSucceeded_e:
00412             text = _("Connected");
00413             break;
00414         case pingFailed_e:
00415         case pingFailedPCShare_e:
00416         case pingFailedNetwork_e:
00417             text = _("Unsuccessful");
00418             break;
00419         case pingSkipped_e:
00420             text = ("Skipped");
00421             break;
00422         case pingNeedKey_e:
00423             text = _("Security key required");
00424             break;
00425         case pingAborted_e:
00426             text = _("Aborted");
00427             break;
00428         case pingAborting_e:
00429             text = _("Aborting...");
00430             flashing = TRUE;
00431             break;
00432         case pingConnecting_e:
00433             text = _("Connecting...");
00434             flashing = TRUE;
00435             break;
00436         default:
00437             text = "";
00438             break;
00439     }
00440 
00441     // display the profile entry
00442     widget = item->details;
00443     gtk_profile_entry_set_status(GTK_PROFILE_ENTRY(widget), text);
00444     gtk_profile_entry_set_status_flashing(GTK_PROFILE_ENTRY(widget), 
00445                                           flashing);
00446 }

Here is the call graph for this function:

bkWdtLabelButton* bk_wdt_label_button_new ( int  nbutton,
gboolean  smallButton,
int  minsel,
int  maxsel 
)

Definition at line 282 of file widgetUtils.c.

00284 {
00285     GtkWidget *background = NULL;
00286     GtkWidget *alignment = NULL; 
00287     wdtLabelButton *details = NULL;
00288     bkWdtLabelButton *item = NULL;
00289 
00290     CN_LOGPRINTF("entry nbutton[%d] smallButton[%d] minsel[%d] maxsel[%d]",
00291                   nbutton, smallButton, minsel, maxsel);
00292 
00293     // background
00294     background = gtk_event_box_new();
00295     gtk_widget_set_name(background, "bk_grey_666_75");
00296     gtk_widget_set_size_request(background, 
00297             SITEM_BK_WIDTH, SITEM_BK_HEIGHT);
00298 
00299     // alignment
00300     alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00301     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00302             PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT);
00303     gtk_container_add(GTK_CONTAINER(background), alignment);
00304 
00305     // details
00306     details = wdt_label_button_new(nbutton, smallButton, minsel, maxsel);
00307     g_assert(details != NULL);
00308     gtk_container_add(GTK_CONTAINER(alignment), details->parent);
00309 
00310     // show widgets
00311     gtk_widget_show(alignment);
00312     gtk_widget_show(details->parent);
00313 
00314     // item 
00315     item = g_new0(bkWdtLabelButton, 1);
00316     g_assert(item != NULL);
00317     item->background = background;
00318     item->details = details;
00319 
00320     // return value
00321     return item;
00322 }

Here is the call graph for this function:

bkWdtLabelEntry* bk_wdt_label_entry_new ( entryFilter_e  filter  ) 

Definition at line 234 of file widgetUtils.c.

00235 {
00236     GtkWidget *background = NULL;
00237     GtkWidget *alignment = NULL;
00238     wdtLabelEntry *details = NULL;
00239     bkWdtLabelEntry *item = NULL;
00240 
00241     CN_LOGPRINTF("entry filter[%d]", filter);
00242 
00243     // background
00244     background = gtk_event_box_new();
00245     gtk_widget_set_name(background, "bk_grey_666_75");
00246     gtk_widget_set_size_request(background, 
00247             SITEM_BK_WIDTH, SITEM_BK_HEIGHT);
00248 
00249     // alignment
00250     alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00251     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00252             PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT);
00253     gtk_container_add(GTK_CONTAINER(background), alignment);
00254 
00255     // details
00256     details = wdt_label_entry_new(filter);
00257     g_assert(details != NULL);
00258     gtk_container_add(GTK_CONTAINER(alignment), details->parent);
00259 
00260     // show widgets
00261     gtk_widget_show(alignment);
00262     gtk_widget_show(details->parent);
00263 
00264     // item 
00265     item = g_new0(bkWdtLabelEntry, 1);
00266     g_assert(item != NULL);
00267     item->background = background;
00268     item->details = details;
00269 
00270     // return value
00271     return item;
00272 }

Here is the call graph for this function:

wdtLabelButton* wdt_label_button_new ( int  nbutton,
gboolean  smallButton,
int  minsel,
int  maxsel 
)

Definition at line 132 of file widgetUtils.c.

00134 {
00135     GtkWidget *vbox = NULL;
00136     GtkWidget *label = NULL;
00137     GtkWidget *hbox = NULL;
00138     GtkWidget *button = NULL;
00139     GtkToggleButton **buttonList = NULL;
00140     GtkWidget *selection = NULL;
00141     wdtLabelButton *item = NULL;
00142     int i;
00143     int spacing = 0, maxSpacing;
00144     int buttonWidth, buttonHeight;
00145 
00146     CN_LOGPRINTF("entry nbutton[%d] smallButton[%d] minsel[%d] maxsel[%d]",
00147                   nbutton, smallButton, minsel, maxsel);
00148 
00149     // vbox
00150     vbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00151 
00152     // label
00153     label = gtk_label_new("");
00154     gtk_widget_set_name(label, "info_label");
00155     gtk_widget_set_size_request(label, LABEL_WIDTH, LABEL_HEIGHT);
00156     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
00157     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
00158 
00159     // button size
00160     if (smallButton)
00161     {
00162         buttonWidth = SBUTTON_WIDTH;
00163         buttonHeight = SBUTTON_HEIGHT;
00164     }
00165     else
00166     {
00167         buttonWidth = BUTTON_WIDTH;
00168         buttonHeight = BUTTON_HEIGHT;
00169     }
00170 
00171     // the spacing among buttons
00172     if (nbutton > 1)
00173     {
00174         spacing = (SITEM_BK_WIDTH - PADDING_LEFT - PADDING_RIGHT 
00175                    - buttonWidth * nbutton)
00176                   / (nbutton -1);
00177     }
00178     maxSpacing = (SITEM_BK_WIDTH - PADDING_LEFT - PADDING_RIGHT 
00179                   - BUTTON_WIDTH * 3) / 2; 
00180     if (spacing > maxSpacing)
00181     {
00182         spacing = maxSpacing;
00183     }
00184 
00185     // hbox
00186     hbox = gtk_hbox_new(FALSE, spacing);
00187     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00188    
00189     // buttonList
00190     buttonList = g_new0(GtkToggleButton*, nbutton+1);
00191     g_assert(buttonList != NULL);
00192 
00193     // button
00194     for (i = 0; i < nbutton; i++)
00195     {
00196         button = ergtk_toggle_button_new_with_label("");
00197         gtk_widget_set_size_request(button, buttonWidth, buttonHeight);
00198         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
00199         buttonList[i] = GTK_TOGGLE_BUTTON(button);
00200     }
00201     buttonList[i] = NULL;
00202 
00203     // selection
00204     selection = ergtk_selection_group_new(buttonList);
00205     ergtk_selection_group_set_details(ERGTK_SELECTION_GROUP(selection), 
00206                                       minsel, maxsel);
00207 
00208     // show widgets
00209     gtk_widget_show(label);
00210     gtk_widget_show_all(hbox);
00211 
00212     // item 
00213     item = g_new0(wdtLabelButton, 1);
00214     g_assert(item != NULL);
00215 
00216     item->parent = vbox;
00217     item->label = label;
00218     item->selection = selection;
00219     item->buttonList = buttonList;
00220     item->nbutton = nbutton;
00221 
00222     // return value
00223     return item;
00224 }

Here is the call graph for this function:

wdtLabelEntry* wdt_label_entry_new ( entryFilter_e  filter  ) 

Definition at line 60 of file widgetUtils.c.

00061 {
00062     GtkWidget *vbox = NULL;
00063     GtkWidget *label = NULL;
00064     GtkWidget *hbox = NULL;
00065     GtkWidget *entry = NULL;
00066     GtkWidget *button = NULL;
00067     wdtLabelEntry *item = NULL;
00068     int spacing = 0;
00069 
00070     CN_LOGPRINTF("entry filter[%d]", filter);
00071 
00072     // vbox
00073     vbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00074 
00075     // label
00076     label = gtk_label_new("");
00077     gtk_widget_set_name(label, "info_label");
00078     gtk_widget_set_size_request(label, LABEL_WIDTH, LABEL_HEIGHT);
00079     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
00080     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
00081    
00082     // hbox
00083     spacing = SITEM_BK_WIDTH - PADDING_LEFT - PADDING_RIGHT 
00084               - ENTRY_WIDTH - SBUTTON_WIDTH;
00085     hbox = gtk_hbox_new(FALSE, spacing);
00086     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00087    
00088     // entry
00089     entry = ergtk_entry_new();
00090     if (filter == ipAddress_e)
00091     {
00092         ergtk_entry_set_ipv4_filter(ERGTK_ENTRY(entry));
00093     }
00094     else if (filter == integer_e)
00095     {
00096         ergtk_entry_set_integer_filter(ERGTK_ENTRY(entry));
00097     }
00098     
00099     gtk_widget_set_size_request(entry, ENTRY_WIDTH, ENTRY_HEIGHT);
00100     gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
00101     
00102     // button
00103     button = ergtk_toggle_button_new_with_label("");
00104     gtk_widget_set_size_request(button, SBUTTON_WIDTH, SBUTTON_HEIGHT);
00105     gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
00106 
00107     // show widgets
00108     gtk_widget_show(label);
00109     gtk_widget_show_all(hbox);
00110 
00111     // item 
00112     item = g_new0(wdtLabelEntry, 1);
00113     g_assert(item != NULL);
00114     item->parent = vbox;
00115     item->label = label;
00116     item->entry = entry;
00117     item->button = button;
00118 
00119     // return value
00120     return item;
00121 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:15:51 2008 by  doxygen 1.5.6