connectionMgr/src/gtkProfileEntry.c File Reference

connectionMgr - the network-profile entry containing a button with profile name or SSID a icon showing the wireless signal quality a icon showing it's a profile with encryption a label showing the status a button to let user enter the profile editor More...

#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <liberdm/display.h>
#include <libergtk/ergtk.h>
#include "connectionMgrLog.h"
#include "displayStatus.h"
#include "gtkProfileEntry.h"

Go to the source code of this file.

Functions

static void gtk_profile_entry_class_init (GtkProfileEntryClass *klass)
static void gtk_profile_entry_init (GtkProfileEntry *profileEntry)
static void gtk_profile_entry_hide_signal_image (GtkProfileEntry *profileEntry)
static gboolean on_flash_status (gpointer data)
GtkWidget * gtk_profile_entry_new (void)
GType gtk_profile_entry_get_type (void)
void gtk_profile_entry_display_settings (GtkProfileEntry *profileEntry, const networkProfile_t *settings, gchar *status)
void gtk_profile_entry_set_namebutton_text (GtkProfileEntry *profileEntry, gchar *nameText)
void gtk_profile_entry_set_signal_image (GtkProfileEntry *profileEntry, gint quality)
void gtk_profile_entry_set_status (GtkProfileEntry *profileEntry, gchar *statusText)
void gtk_profile_entry_set_status_flashing (GtkProfileEntry *profileEntry, gboolean flashing)
void gtk_profile_entry_set_editbutton_text (GtkProfileEntry *profileEntry, gchar *editText)
void gtk_profile_entry_set_buttons_active (GtkProfileEntry *profileEntry, gboolean nameActive, gboolean editActive)
void gtk_profile_entry_show_encr_image (GtkProfileEntry *profileEntry, gboolean show)
void gtk_profile_entry_show_edit_button (GtkProfileEntry *profileEntry, gboolean show)
GtkWidget * gtk_profile_entry_get_namebutton (GtkProfileEntry *profileEntry)
GtkWidget * gtk_profile_entry_get_editbutton (GtkProfileEntry *profileEntry)


Detailed Description

connectionMgr - the network-profile entry containing a button with profile name or SSID a icon showing the wireless signal quality a icon showing it's a profile with encryption a label showing the status a button to let user enter the profile editor

Copyright (C) 2007 iRex Technologies BV.

Definition in file gtkProfileEntry.c.


Function Documentation

static void gtk_profile_entry_class_init ( GtkProfileEntryClass klass  )  [static]

Definition at line 98 of file gtkProfileEntry.c.

00099 {
00100     // nothing needs to be done here 
00101 }

void gtk_profile_entry_display_settings ( GtkProfileEntry profileEntry,
const networkProfile_t settings,
gchar *  status 
)

Definition at line 209 of file gtkProfileEntry.c.

00211 {
00212     CN_LOGPRINTF("entry [%p][%p][%s]", profileEntry, settings, status);
00213 
00214     int                 nActiveIndex;
00215     regNetworkProfile_t *pRegSettings = NULL;
00216     network_spec_t      *pScanSettings = NULL;
00217     char                *nwName;
00218     gboolean             encrypted;
00219 
00220     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00221 
00222     if (settings)
00223     {
00224         if ((settings->nRegProfiles > 0)
00225             && settings->regSettingsList
00226             && ((settings->nActiveIndex >= 0) 
00227                 && (settings->nActiveIndex < settings->nRegProfiles)))
00228         {
00229             nActiveIndex = settings->nActiveIndex;
00230             pRegSettings = settings->regSettingsList[nActiveIndex];
00231         }
00232         pScanSettings = settings->scanSettings;
00233     }
00234     
00235     if (pRegSettings)
00236     {
00237         nwName = pRegSettings->name;
00238     }
00239     else if (pScanSettings)
00240     {
00241         nwName = pScanSettings->ssid;
00242     }
00243     else
00244     {
00245         nwName = NULL;
00246     }
00247 
00248     if ((nwName == NULL) || (nwName[0] == '\0'))
00249     {
00250         gtk_profile_entry_set_namebutton_text(profileEntry, "");
00251         gtk_profile_entry_set_status(profileEntry, "");
00252     }
00253     else
00254     {
00255         // network name
00256         gtk_profile_entry_set_namebutton_text(profileEntry, nwName);
00257 
00258         // signal images
00259         if (pScanSettings)
00260         {
00261             gtk_profile_entry_set_signal_image(profileEntry, 
00262                                                pScanSettings->quality);
00263         }
00264         else if (pRegSettings && pRegSettings->connection == wireless_t)
00265         {
00266             gtk_profile_entry_set_signal_image(profileEntry, 0);
00267         }
00268         else
00269         {
00270             gtk_profile_entry_hide_signal_image(profileEntry);
00271         }
00272        
00273         // encryption image
00274         if (pScanSettings && (pScanSettings->encryption != encr_none_t))
00275         {
00276             encrypted = TRUE;
00277         }
00278         else if (pRegSettings 
00279                  && pRegSettings->wirelessSettings
00280                  && pRegSettings->wirelessSettings->encrType != encr_none_t)
00281         {
00282             encrypted = TRUE;
00283         }
00284         else
00285         {
00286             encrypted = FALSE;
00287         }
00288         
00289         gtk_profile_entry_show_encr_image(profileEntry, encrypted);
00290        
00291         // status
00292         gtk_profile_entry_set_status(profileEntry, status);
00293     }
00294 }

Here is the call graph for this function:

GtkWidget* gtk_profile_entry_get_editbutton ( GtkProfileEntry profileEntry  ) 

Definition at line 499 of file gtkProfileEntry.c.

00500 {
00501     CN_LOGPRINTF("entry");
00502     g_return_val_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry), NULL);
00503     return profileEntry->editButton;
00504 }

GtkWidget* gtk_profile_entry_get_namebutton ( GtkProfileEntry profileEntry  ) 

Definition at line 492 of file gtkProfileEntry.c.

00493 {
00494     CN_LOGPRINTF("entry");
00495     g_return_val_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry), NULL);
00496     return profileEntry->nameButton;
00497 }

GType gtk_profile_entry_get_type ( void   ) 

Definition at line 69 of file gtkProfileEntry.c.

00070 {
00071     static GType profile_entry_type = 0;
00072 
00073     if (!profile_entry_type)
00074     {
00075         static const GTypeInfo  profile_entry_info = 
00076         {
00077             sizeof(GtkProfileEntryClass),  /* class_size */
00078             NULL,                          /* base_init */
00079             NULL,                          /* base_finalize */
00080             (GClassInitFunc) gtk_profile_entry_class_init,/* class_init */
00081             NULL,                          /* class_finalize */
00082             NULL,                          /* class_data */
00083             sizeof(GtkProfileEntry),       /* instance_size */
00084             0,                             /* n_preallocs */
00085             (GInstanceInitFunc) gtk_profile_entry_init,  /* instance_init */
00086             0                              /* value_table */
00087         };
00088         profile_entry_type = g_type_register_static(GTK_TYPE_EVENT_BOX, 
00089                                                     "ProfileEntry", 
00090                                                     &profile_entry_info, 
00091                                                     0);
00092     }
00093 
00094     return profile_entry_type;
00095 }

Here is the call graph for this function:

static void gtk_profile_entry_hide_signal_image ( GtkProfileEntry profileEntry  )  [static]

Definition at line 408 of file gtkProfileEntry.c.

00409 {
00410     int i;
00411     
00412     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00413     
00414     for (i = 0; i < 5; i++)
00415     {
00416         gtk_widget_hide(profileEntry->sigImage[i]);
00417     }
00418 }

static void gtk_profile_entry_init ( GtkProfileEntry profileEntry  )  [static]

Definition at line 115 of file gtkProfileEntry.c.

00116 {
00117     CN_LOGPRINTF("entry");
00118 
00119     GtkWidget* clientArea;
00120     GtkWidget* nameButton;
00121     GtkWidget* sigVbox;
00122     GtkWidget* sigImage;
00123     GtkWidget* encrVbox;
00124     GtkWidget* encrImage;
00125     GtkWidget* status;
00126     GtkWidget* editButton;
00127 
00128     gtk_widget_set_size_request(GTK_WIDGET(profileEntry), 
00129                 PROFILE_ENTRY_WIDTH, PROFILE_ENTRY_HEIGHT);
00130     // setting event box invisible can make it transparent
00131     gtk_event_box_set_visible_window(GTK_EVENT_BOX(profileEntry), FALSE);
00132 
00133     // client area
00134     clientArea = gtk_hbox_new(FALSE, PROFILE_ENTRY_SPACING);
00135     gtk_widget_set_size_request(GTK_WIDGET(clientArea), 
00136                 PROFILE_ENTRY_WIDTH, PROFILE_ENTRY_HEIGHT);
00137 
00138     gtk_container_add(GTK_CONTAINER(profileEntry), clientArea);
00139     profileEntry->clientArea = clientArea;
00140 
00141     // name button
00142     nameButton = ergtk_toggle_button_new_with_label("");
00143     gtk_widget_set_size_request(GTK_WIDGET(nameButton), 
00144         PROFILE_ENTRY_NAME_BUTTON_WIDTH, PROFILE_ENTRY_NAME_BUTTON_HEIGHT);
00145     gtk_box_pack_start(GTK_BOX(clientArea), nameButton, FALSE, FALSE, 0);
00146     profileEntry->nameButton = nameButton;
00147 
00148     // signal quality images.
00149     sigVbox = gtk_vbox_new(FALSE, 0);
00150     gtk_widget_set_size_request(GTK_WIDGET(sigVbox), 
00151         PROFILE_ENTRY_SIG_IMG_WIDTH, PROFILE_ENTRY_SIG_IMG_HEIGHT);
00152     gtk_box_pack_start(GTK_BOX(clientArea), sigVbox, FALSE, FALSE, 0);
00153     profileEntry->sigVbox = sigVbox;
00154 
00155     // signal images
00156     int  i;
00157     char bgStyle[] = "profile_entry_signal0_background";
00158     for (i = 0; i < 5; i++)
00159     {
00160         sigImage = gtk_event_box_new();
00161         gtk_widget_set_size_request(GTK_WIDGET(sigImage), 
00162             PROFILE_ENTRY_SIG_IMG_WIDTH, PROFILE_ENTRY_SIG_IMG_HEIGHT);
00163         snprintf(bgStyle, sizeof(bgStyle), 
00164                 "profile_entry_signal%d_background", i);
00165         gtk_widget_set_name(GTK_WIDGET(sigImage), bgStyle);
00166         gtk_box_pack_start(GTK_BOX(sigVbox), sigImage, FALSE, FALSE, 0);
00167         profileEntry->sigImage[i] = sigImage;    
00168     }
00169 
00170     // encrVbox
00171     encrVbox = gtk_vbox_new(FALSE, 0);
00172     gtk_widget_set_size_request(GTK_WIDGET(encrVbox), 
00173         PROFILE_ENTRY_ENCR_IMG_WIDTH, PROFILE_ENTRY_ENCR_IMG_HEIGHT);
00174     gtk_box_pack_start(GTK_BOX(clientArea), encrVbox, FALSE, FALSE, 0);
00175     profileEntry->encrVbox = encrVbox;
00176 
00177     // encrImage
00178     encrImage = gtk_event_box_new();
00179     gtk_widget_set_size_request(GTK_WIDGET(encrImage), 
00180         PROFILE_ENTRY_ENCR_IMG_WIDTH, PROFILE_ENTRY_ENCR_IMG_HEIGHT);
00181     gtk_widget_set_name(GTK_WIDGET(encrImage), 
00182             "profile_entry_encrimg_background");
00183     gtk_box_pack_start(GTK_BOX(encrVbox), encrImage, FALSE, FALSE, 0);
00184     profileEntry->encrImage = encrImage;
00185 
00186     // status
00187     status = gtk_label_new("");
00188     gtk_widget_set_size_request(GTK_WIDGET(status), 
00189         PROFILE_ENTRY_STATUS_WIDTH, PROFILE_ENTRY_STATUS_HEIGHT);
00190     gtk_misc_set_alignment(GTK_MISC(status), 0.02, 0.5);
00191     gtk_widget_set_name(GTK_WIDGET(status), "profile_entry_status");
00192     gtk_box_pack_start(GTK_BOX(clientArea), status, FALSE, FALSE, 0);
00193     profileEntry->status = status;
00194     
00195     // editButton
00196     editButton = ergtk_toggle_button_new_with_label("");
00197     gtk_widget_set_size_request(GTK_WIDGET(editButton), 
00198         PROFILE_ENTRY_EDIT_BUTTON_WIDTH, PROFILE_ENTRY_EDIT_BUTTON_HEIGHT);
00199     gtk_box_pack_end(GTK_BOX(clientArea), editButton, FALSE, FALSE, 0);
00200     profileEntry->editButton = editButton;
00201 
00202     // local data
00203     profileEntry->statusFlashing = FALSE;
00204     
00205     CN_LOGPRINTF("done");
00206 }

Here is the call graph for this function:

GtkWidget* gtk_profile_entry_new ( void   ) 

Definition at line 52 of file gtkProfileEntry.c.

00053 {
00054     GtkProfileEntry *profileEntry;
00055 
00056     profileEntry = (GtkProfileEntry *) g_object_new(GTK_PROFILE_ENTRY_TYPE, NULL);
00057 
00058     gtk_widget_show_all(profileEntry->clientArea);
00059     gdk_flush();
00060 
00061     gtk_profile_entry_hide_signal_image(profileEntry);
00062     gtk_widget_hide(profileEntry->encrImage);
00063     gtk_widget_hide(profileEntry->editButton);
00064 
00065     return GTK_WIDGET(profileEntry);
00066 }

Here is the call graph for this function:

void gtk_profile_entry_set_buttons_active ( GtkProfileEntry profileEntry,
gboolean  nameActive,
gboolean  editActive 
)

Definition at line 389 of file gtkProfileEntry.c.

00392 {
00393     GtkToggleButton *button;
00394 
00395     CN_LOGPRINTF("entry nameActive[%d]editActive[%d]", 
00396                   nameActive, editActive);
00397 
00398     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00399 
00400     button = GTK_TOGGLE_BUTTON(profileEntry->nameButton);
00401     gtk_toggle_button_set_active(button, nameActive);
00402 
00403     button = GTK_TOGGLE_BUTTON(profileEntry->editButton);
00404     gtk_toggle_button_set_active(button, editActive);
00405 }

void gtk_profile_entry_set_editbutton_text ( GtkProfileEntry profileEntry,
gchar *  editText 
)

Definition at line 376 of file gtkProfileEntry.c.

00378 {
00379     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00380 
00381     if (editText)
00382     {
00383         CN_LOGPRINTF("edit: [%s]", editText);
00384         gtk_button_set_label(GTK_BUTTON(profileEntry->editButton), 
00385                              editText);
00386     }
00387 }

void gtk_profile_entry_set_namebutton_text ( GtkProfileEntry profileEntry,
gchar *  nameText 
)

Definition at line 297 of file gtkProfileEntry.c.

00299 {
00300     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00301 
00302     if (nameText)
00303     {
00304         CN_LOGPRINTF("name: [%s]", nameText);
00305         gtk_button_set_label(GTK_BUTTON(profileEntry->nameButton), 
00306                              nameText);
00307     }
00308 }

void gtk_profile_entry_set_signal_image ( GtkProfileEntry profileEntry,
gint  quality 
)

Definition at line 310 of file gtkProfileEntry.c.

00312 {
00313     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00314     g_return_if_fail((quality >= 0) && (quality <= 100));
00315 
00316     CN_LOGPRINTF("quality: [%d]", quality);
00317 
00318     // hide all signal images firstly
00319     gtk_profile_entry_hide_signal_image(profileEntry);
00320 
00321     // show one correct signal image secondly
00322     if (quality <= 0)
00323     {
00324         gtk_widget_show(profileEntry->sigImage[0]);
00325     }
00326     else if (quality <= 25)
00327     {
00328         gtk_widget_show(profileEntry->sigImage[1]);
00329     }
00330     else if (quality <= 50)
00331     {
00332         gtk_widget_show(profileEntry->sigImage[2]);
00333     }
00334     else if (quality <= 75)
00335     {
00336         gtk_widget_show(profileEntry->sigImage[3]);
00337     }
00338     else
00339     {
00340         gtk_widget_show(profileEntry->sigImage[4]);
00341     }
00342 }

Here is the call graph for this function:

void gtk_profile_entry_set_status ( GtkProfileEntry profileEntry,
gchar *  statusText 
)

Definition at line 345 of file gtkProfileEntry.c.

00347 {
00348     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00349 
00350     if (statusText)
00351     {
00352         CN_LOGPRINTF("status: [%s]", statusText);
00353         gtk_label_set_text(GTK_LABEL(profileEntry->status), statusText);
00354         gtk_profile_entry_set_status_flashing(profileEntry, FALSE);
00355     }
00356 }

Here is the call graph for this function:

void gtk_profile_entry_set_status_flashing ( GtkProfileEntry profileEntry,
gboolean  flashing 
)

Definition at line 358 of file gtkProfileEntry.c.

00360 {
00361     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00362 
00363     CN_LOGPRINTF("flashing: [%d]", flashing);
00364 
00365     gtk_widget_set_state(GTK_WIDGET(profileEntry->status), 
00366                          GTK_STATE_NORMAL);
00367 
00368     if (flashing == TRUE && profileEntry->statusFlashing == FALSE)
00369     {
00370         g_timeout_add(1100, on_flash_status, profileEntry);
00371     }
00372     profileEntry->statusFlashing = flashing;
00373 }

Here is the call graph for this function:

void gtk_profile_entry_show_edit_button ( GtkProfileEntry profileEntry,
gboolean  show 
)

Definition at line 437 of file gtkProfileEntry.c.

00439 {
00440     CN_LOGPRINTF("entry show[%d]", show);
00441 
00442     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00443 
00444     if (show)
00445     {
00446         gtk_widget_show(profileEntry->editButton);
00447     }
00448     else
00449     {
00450         gtk_widget_hide(profileEntry->editButton);
00451     }
00452 }

void gtk_profile_entry_show_encr_image ( GtkProfileEntry profileEntry,
gboolean  show 
)

Definition at line 420 of file gtkProfileEntry.c.

00422 {
00423     CN_LOGPRINTF("entry show[%d]", show);
00424 
00425     g_return_if_fail(IS_GTK_PROFILE_ENTRY(profileEntry));
00426 
00427     if (show)
00428     {
00429         gtk_widget_show(profileEntry->encrImage);
00430     }
00431     else
00432     {
00433         gtk_widget_hide(profileEntry->encrImage);
00434     }
00435 }

static gboolean on_flash_status ( gpointer  data  )  [static]

Definition at line 454 of file gtkProfileEntry.c.

00455 {
00456     CN_LOGPRINTF("entry");
00457 
00458     GtkWidget *status;
00459     static int delay = 0;
00460 
00461     g_return_val_if_fail((data != NULL), FALSE);
00462     GtkProfileEntry* profileEntry = GTK_PROFILE_ENTRY(data);
00463 
00464     if (profileEntry->statusFlashing)
00465     {
00466         if (--delay < 0)
00467         {
00468             status = GTK_WIDGET(profileEntry->status);
00469             if (GTK_WIDGET_STATE(status) == GTK_STATE_NORMAL)
00470             {
00471                 gtk_widget_set_state(status, GTK_STATE_ACTIVE);
00472                 delay = 0;
00473             }
00474             else
00475             {
00476                 gtk_widget_set_state(status, GTK_STATE_NORMAL);
00477                 delay = 3;
00478             }
00479             
00480             display_update_request_screen_refresh(TEXT_ENTRY_CHANGED_LEVEL,
00481                                                   WAVEFORM_TYPING);
00482         }
00483 
00484         return TRUE;
00485     }
00486     else
00487     {
00488         return FALSE;
00489     }
00490 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:16:39 2008 by  doxygen 1.5.6