00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00030 #include <unistd.h>
00031 #include <string.h>
00032
00033 #include <gtk/gtk.h>
00034 #include <gdk/gdkkeysyms.h>
00035
00036 #include <liberregxml/erregapi.h>
00037 #include <libergtk/ergtk.h>
00038 #include <liberipc/eripctoolbar.h>
00039
00040 #include "connectionMgrLog.h"
00041 #include "connectionMgr.h"
00042 #include "gtkSettingItem.h"
00043 #include "gtkProfileEntry.h"
00044 #include "gtkProfileGroup.h"
00045 #include "widgetUtils.h"
00046 #include "commonData.h"
00047 #include "editScreenData.h"
00048 #include "editScreen.h"
00049 #include "editScreenProfiles.h"
00050 #include "editScreenOverview.h"
00051 #include "editScreenSearch.h"
00052 #include "background.h"
00053 #include "displayStatus.h"
00054 #include "erbusy.h"
00055 #include "pagebar.h"
00056 #include "toolbar.h"
00057 #include "languages.h"
00058
00059
00060 typedef void on_item_selected_t(const int* index_tbl);
00061 static struct
00062 {
00063 int iconID;
00064 gboolean confirm_with_icon;
00065 guint ticks;
00066 guint timerID;
00067 gboolean active;
00068 gboolean icon_clicked;
00069 gboolean item_selected[MAX_PROFILES_PER_PAGE];
00070 on_item_selected_t* on_item_selected;
00071 } g_select = { ICON_ID_NOTUSED, FALSE, 0, 0, FALSE, FALSE, {}, NULL };
00072
00073
00074 static GtkWidget *g_edit_profiles = NULL;
00075
00076
00077 static GtkWidget *g_networktype = NULL;
00078 static bkWdtLabelButton *g_nwtype_labelbutton = NULL;
00079
00080
00081 static GtkWidget *g_new_profile = NULL;
00082 static bkWdtLabelButton *g_newprofile_labelbutton = NULL;
00083
00084
00085 static GtkWidget *g_known_profiles = NULL;
00086
00087 static gboolean g_first_display = TRUE;
00088
00089 static GtkWidget* create_new_profile(void);
00090 static GtkWidget* create_known_profiles(void);
00091
00092 static GtkWidget *create_network_type (void);
00093
00094
00095 static void on_networktype_update (erGtkSelectionGroup * selection,
00096 gpointer button, gpointer data);
00097 static void on_new_profile_toggled (GtkWidget* button,
00098 GdkEventButton * event,
00099 gpointer data);
00100 static void on_profile_entry_selected (GtkProfileGroup *profileGroup,
00101 guint profileIndex);
00102
00103 static void edit_profile(guint profileIndex);
00104
00105 static void on_icon_clicked(int iconID, int iconState);
00106
00107 static void begin_select_delete_profiles(int iconID,
00108 gboolean confirm_with_icon,
00109 on_item_selected_t* callback_on_selected);
00110
00111 static gboolean on_end_select_delete_profiles_timer(gpointer data);
00112 static void select_delete_profiles_stop(gboolean restore_toolbar);
00113 static void unselect_delete_profiles(void);
00114 static gboolean on_delete_profile_selected(GtkProfileGroup* profileGroup,
00115 guint index, gboolean active);
00116 static void delete_profiles(const int* index_tbl);
00117
00119
00121
00122
00123
00124
00125
00126
00127 GtkWidget *edit_profiles_create(void)
00128 {
00129 CN_LOGPRINTF("entry");
00130
00131 GtkWidget *vbox;
00132 GtkWidget *networkTypeItem;
00133 GtkWidget *newProfileItem;
00134 GtkWidget *knownProfilesItem;
00135
00136
00137 vbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00138 gtk_widget_show(vbox);
00139 g_edit_profiles = vbox;
00140
00141
00142 networkTypeItem = create_network_type();
00143 gtk_box_pack_start(GTK_BOX(vbox), networkTypeItem, FALSE, FALSE, 0);
00144 gtk_widget_show(networkTypeItem);
00145
00146
00147 newProfileItem = create_new_profile();
00148 gtk_box_pack_start(GTK_BOX(vbox), newProfileItem, FALSE, FALSE, 0);
00149 gtk_widget_show(newProfileItem);
00150
00151
00152 knownProfilesItem = create_known_profiles();
00153 gtk_box_pack_start(GTK_BOX(vbox), knownProfilesItem, FALSE, FALSE, 0);
00154 gtk_widget_show(knownProfilesItem);
00155
00156 return vbox;
00157 }
00158
00159
00160
00161 static GtkWidget *create_new_profile(void)
00162 {
00163 GtkWidget *item;
00164 bkWdtLabelButton *widget;
00165 GtkToggleButton *button;
00166
00167
00168 item = gtk_settingitem_new("");
00169
00170
00171 widget = bk_wdt_label_button_new(1, FALSE, 0, 1);
00172 gtk_settingitem_add_details(GTK_SETTINGITEM(item), widget->background);
00173
00174
00175 button = widget->details->buttonList[0];
00176 g_signal_connect(G_OBJECT(button), "toggled",
00177 G_CALLBACK(on_new_profile_toggled), 0);
00178
00179
00180 gtk_widget_show(widget->background);
00181
00182
00183 g_new_profile = item;
00184 g_newprofile_labelbutton = widget;
00185
00186
00187 return item;
00188 }
00189
00190
00191
00192
00193 static GtkWidget *create_network_type (void)
00194 {
00195 GtkWidget *item = NULL;
00196 bkWdtLabelButton *widget;
00197 GtkWidget *selection;
00198
00199
00200 item = gtk_settingitem_new("");
00201
00202
00203 widget = bk_wdt_label_button_new(3, FALSE, 1, 1);
00204 gtk_settingitem_add_details(GTK_SETTINGITEM(item), widget->background);
00205
00206
00207 selection = widget->details->selection;
00208 g_signal_connect (G_OBJECT (selection), "selection-update",
00209 G_CALLBACK (on_networktype_update), NULL);
00210
00211
00212 gtk_widget_show(widget->background);
00213
00214
00215 g_networktype = item;
00216 g_nwtype_labelbutton = widget;
00217
00218
00219 return item;
00220 }
00221
00222
00223
00224
00225 static GtkWidget *create_known_profiles (void)
00226 {
00227 GtkWidget* item;
00228
00229
00230 item = gtk_profile_group_new(MAX_PROFILES_PER_PAGE, editMode_e);
00231 gtk_profile_group_show_dialup(GTK_PROFILE_GROUP(item), FALSE);
00232
00233 gtk_profile_group_callback_on_buttons_press(GTK_PROFILE_GROUP(item),
00234 on_delete_profile_selected, NULL);
00235 gtk_profile_group_callback_on_buttons_clicked(GTK_PROFILE_GROUP(item),
00236 NULL, on_profile_entry_selected);
00237 g_known_profiles = item;
00238
00239 return item;
00240 }
00241
00243
00245 void edit_profiles_set_text (void)
00246 {
00247 GtkWidget *widget;
00248 GtkProfileGroup *profileGroup;
00249
00250 CN_LOGPRINTF ("entry");
00251
00252 if (g_networktype)
00253 {
00254 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_networktype),
00255 _("Show network profiles for"));
00256 }
00257
00258 if (g_nwtype_labelbutton)
00259 {
00260 widget = g_nwtype_labelbutton->details->label;
00261 gtk_label_set_text (GTK_LABEL(widget),
00262 _("Select the type of network profiles to list below."));
00263
00264 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[0]);
00265 gtk_button_set_label (GTK_BUTTON (widget), _("Wired"));
00266
00267 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[1]);
00268 gtk_button_set_label (GTK_BUTTON (widget), _("Wireless"));
00269
00270 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[2]);
00271 gtk_button_set_label (GTK_BUTTON (widget), _("Dial-up"));
00272 }
00273
00274 if (g_new_profile)
00275 {
00276 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_new_profile),
00277 _("Network profiles"));
00278 }
00279
00280 if (g_newprofile_labelbutton)
00281 {
00282 widget = g_newprofile_labelbutton->details->label;
00283 gtk_label_set_text (GTK_LABEL (widget),
00284 _("Create a new network profile:"));
00285
00286 widget = GTK_WIDGET(g_newprofile_labelbutton->details->buttonList[0]);
00287 gtk_button_set_label (GTK_BUTTON (widget), _("Create new profile"));
00288 }
00289
00290 if (g_known_profiles)
00291 {
00292 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00293 gtk_profile_group_set_header_text(profileGroup,
00294 _("Network profiles"));
00295 gtk_profile_group_set_info_text (profileGroup,
00296 _("Stored network profiles on your iLiad: "));
00297 gtk_profile_group_set_editbuttons_text(profileGroup,
00298 _("Edit"));
00299 }
00300 }
00301
00303
00305 void edit_profiles_display (void)
00306 {
00307 CN_LOGPRINTF ("entry");
00308
00309 GtkProfileGroup *profileGroup;
00310 networkProfile_t *settings;
00311 int i, profileIndex;
00312 int nProfiles, nDisplayed;
00313
00314 GtkWidget* widget;
00315 GtkToggleButton* button;
00316
00317 if (g_nwtype_labelbutton)
00318 {
00319
00320 switch (edit_data_get_network_type())
00321 {
00322 case wired_t:
00323 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[0]);
00324 break;
00325 case wireless_t:
00326 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[1]);
00327 break;
00328 case dialup_t:
00329 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[2]);
00330 break;
00331 default:
00332
00333 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[0]);
00334 edit_data_set_network_type (wired_t);
00335 break;
00336 }
00337
00338
00339
00340
00341
00342
00343 button = GTK_TOGGLE_BUTTON(widget);
00344 if (g_first_display && gtk_toggle_button_get_active(button))
00345 {
00346
00347
00348 gtk_toggle_button_set_active(button, FALSE);
00349 }
00350 gtk_toggle_button_set_active(button, TRUE);
00351
00352
00353 if (main_get_wifi_disabled())
00354 {
00355
00356 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[1]);
00357 gtk_widget_set_sensitive(widget, FALSE);
00358 }
00359
00360 if (main_get_dialup_disabled())
00361 {
00362
00363 widget = GTK_WIDGET(g_nwtype_labelbutton->details->buttonList[2]);
00364 gtk_widget_set_sensitive(widget, FALSE);
00365 }
00366 }
00367
00368 if (g_newprofile_labelbutton)
00369 {
00370 button = g_newprofile_labelbutton->details->buttonList[0];
00371
00372
00373 if (edit_data_reach_max_profiles())
00374 {
00375 gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
00376 }
00377 else
00378 {
00379 gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
00380 }
00381
00382
00383 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
00384 }
00385
00386
00387 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00388 nProfiles = edit_data_get_n_network_profiles();
00389 CN_LOGPRINTF("nProfiles[%d]", nProfiles);
00390
00391 nDisplayed = ((nProfiles < MAX_PROFILES_PER_PAGE) ? nProfiles: MAX_PROFILES_PER_PAGE);
00392 if (nDisplayed > 0)
00393 {
00394 for (i = 0; i < nDisplayed; i++)
00395 {
00396 settings = (networkProfile_t*)edit_data_get_network_profile(i);
00397 gtk_profile_group_display_settings(profileGroup, i,
00398 settings, TRUE);
00399 }
00400 }
00401 gtk_profile_group_show_profile_entries(profileGroup, nDisplayed);
00402
00403
00404 profileIndex = gtk_profile_group_get_selected_profile_index(profileGroup);
00405 if (profileIndex != -1)
00406 {
00407 gtk_profile_group_unselect_profile(profileGroup, profileIndex);
00408 }
00409
00410
00411 edit_show_trashcan();
00412
00413
00414 g_first_display = FALSE;
00415 }
00416
00418
00420 static void on_networktype_update (erGtkSelectionGroup * selection,
00421 gpointer button, gpointer data)
00422 {
00423 CN_LOGPRINTF("entry selection[%p], button[%p], data[%p]",
00424 selection, button, data);
00425
00426 GtkToggleButton* btn;
00427 gboolean active;
00428 int nsel;
00429
00430 btn = GTK_TOGGLE_BUTTON(button);
00431 active = gtk_toggle_button_get_active(btn);
00432 if (active)
00433 {
00434
00435 erbusy_blink();
00436
00437
00438 select_delete_profiles_stop(TRUE);
00439
00440 ergtk_selection_group_get_selected_buttons(selection, &nsel, 1);
00441 if (nsel == 0)
00442 {
00443
00444 edit_data_set_network_type(wired_t);
00445 }
00446 else if (nsel == 1)
00447 {
00448
00449 edit_data_set_network_type (wireless_t);
00450 }
00451 else if (nsel == 2)
00452 {
00453
00454 edit_data_set_network_type(dialup_t);
00455 }
00456
00457
00458 edit_data_init_network_profiles();
00459
00460
00461 edit_profiles_display();
00462 }
00463 }
00464
00465 static gboolean delayed_on_new_profile_toggled(gpointer data)
00466 {
00467 GtkToggleButton *button;
00468
00469 erbusy_blink();
00470 edit_profiles_create_profile();
00471
00472 button = g_newprofile_labelbutton->details->buttonList[0];
00473 gtk_toggle_button_set_active(button, FALSE);
00474
00475 return FALSE;
00476 }
00477
00478 static void on_new_profile_toggled (GtkWidget* button,
00479 GdkEventButton * event,
00480 gpointer data)
00481 {
00482 gboolean pressed;
00483
00484 CN_LOGPRINTF ("entry");
00485
00486
00487 pressed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
00488 if (pressed)
00489 {
00490
00491 select_delete_profiles_stop(TRUE);
00492
00493
00494 g_timeout_add(500, delayed_on_new_profile_toggled, data);
00495 }
00496 }
00497
00498 static gboolean delayed_on_profile_entry_selected(gpointer data)
00499 {
00500 int profileIndex = (int)data;
00501
00502 erbusy_blink();
00503 edit_profile(profileIndex);
00504 return FALSE;
00505 }
00506
00507 static void on_profile_entry_selected (GtkProfileGroup* profileGroup,
00508 guint profileIndex)
00509 {
00510 CN_LOGPRINTF ("entry");
00511
00512
00513 g_timeout_add(500,
00514 delayed_on_profile_entry_selected,
00515 (gpointer)profileIndex);
00516 }
00517
00518 gboolean on_edit_profiles_keypress(GdkEventKey *event)
00519 {
00520 CN_LOGPRINTF("entry");
00521
00522 GtkToggleButton *button;
00523 gboolean ret = FALSE;
00524
00525 switch (event->keyval)
00526 {
00527 case GDK_Return:
00528
00529
00530 if (!edit_data_reach_max_profiles() && g_newprofile_labelbutton)
00531 {
00532 button = g_newprofile_labelbutton->details->buttonList[0];
00533 gtk_toggle_button_set_active(button, TRUE);
00534 }
00535 else
00536 {
00537 erbusy_off();
00538 }
00539 ret = TRUE;
00540 break;
00541
00542 case GDK_F5:
00543
00544
00545 cmgr_up_page();
00546 ret = TRUE;
00547 break;
00548
00549 case GDK_Down:
00550 case GDK_Up:
00551 case GDK_Page_Down:
00552 case GDK_Page_Up:
00553 default:
00554 erbusy_off();
00555 break;
00556 }
00557
00558 return ret;
00559 }
00560
00561 void on_edit_profiles_icon_clicked(int iconID, int iconState)
00562 {
00563 CN_LOGPRINTF("entry iconID[%d] iconState[%d]", iconID, iconState);
00564
00565 on_icon_clicked(iconID, iconState);
00566 }
00567
00568
00569 static void edit_profile(guint profileIndex)
00570 {
00571 const networkProfile_t *settings;
00572 regNetworkProfile_t* pRegSettings = NULL;
00573
00574 CN_LOGPRINTF("entry: profileIndex [%d]", profileIndex);
00575
00576 edit_set_wizard_mode(FALSE);
00577 edit_set_back_overview(FALSE);
00578
00579
00580 settings = edit_data_get_network_profile(profileIndex);
00581
00582 if ((settings->nRegProfiles > 0)
00583 && settings->regSettingsList
00584 && ((settings->nActiveIndex >= 0)
00585 && (settings->nActiveIndex < settings->nRegProfiles)))
00586 {
00587 pRegSettings = settings->regSettingsList[settings->nActiveIndex];
00588 }
00589
00590 if (pRegSettings)
00591 {
00592 edit_set_network_settings(pRegSettings);
00593
00594 switch (pRegSettings->connection)
00595 {
00596 case wired_t:
00597 edit_goto_page(editScreenOverview_e);
00598 break;
00599 case wireless_t:
00600 edit_goto_page(editScreenWireless_e);
00601 break;
00602 case dialup_t:
00603 edit_goto_page(editScreenDialup_e);
00604 break;
00605 default:
00606 break;
00607 }
00608 }
00609 else
00610 {
00611
00612 edit_profiles_create_profile();
00613 }
00614 }
00615
00616 char *edit_profiles_default_profilename(void)
00617 {
00618 connection_t networkType;
00619 int nProfiles;
00620 char *name = NULL;
00621
00622 networkType = edit_data_get_network_type();
00623 nProfiles = edit_data_get_n_network_profiles();
00624
00625 switch (networkType)
00626 {
00627 case wired_t:
00628 name = g_strdup_printf(_("Wired %d"), nProfiles+1);
00629 break;
00630 case wireless_t:
00631 name = g_strdup_printf(_("Wireless %d"), nProfiles+1);
00632 break;
00633 case dialup_t:
00634 name = g_strdup_printf(_("Dial-up %d"), nProfiles+1);
00635 break;
00636 default:
00637 name = g_strdup("");
00638 break;
00639 }
00640
00641 CN_LOGPRINTF("return %s", name);
00642 return name;
00643 }
00644
00645 void edit_profiles_create_profile(void)
00646 {
00647 connection_t networkType;
00648 regNetworkProfile_t* settings;
00649
00650 CN_LOGPRINTF("entry");
00651
00652 networkType = edit_data_get_network_type();
00653 if ((networkType >= 0) && (networkType < connection_undefined_t))
00654 {
00655 edit_set_wizard_mode(TRUE);
00656 edit_set_back_overview(FALSE);
00657
00658
00659 settings = g_new0(regNetworkProfile_t, 1);
00660 g_assert(settings != NULL);
00661
00662 settings->name = edit_profiles_default_profilename();
00663 settings->connection = networkType;
00664 settings->proxy = FALSE;
00665 settings->addressMode = dhcp_t;
00666
00667 edit_set_network_settings(settings);
00668
00669 erRegFreeNetworkProfile(settings);
00670
00671
00672 switch (networkType)
00673 {
00674 case wired_t:
00675 edit_goto_page(editScreenOverview_e);
00676 break;
00677 case wireless_t:
00678 edit_search_restore_screen();
00679 edit_goto_page(editScreenSearch_e);
00680 break;
00681 case dialup_t:
00682 edit_goto_page(editScreenDialup_e);
00683 break;
00684 default:
00685 edit_goto_page(editScreenOverview_e);
00686 break;
00687 }
00688 }
00689 }
00690
00691 int edit_profiles_get_edited_profile_index(void)
00692 {
00693 CN_LOGPRINTF("entry");
00694
00695 int profileIndex;
00696 GtkProfileGroup* profileGroup;
00697
00698 if (edit_get_wizard_mode())
00699 {
00700 profileIndex = -1;
00701 }
00702 else
00703 {
00704 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00705 profileIndex = gtk_profile_group_get_selected_profile_index(profileGroup);
00706 }
00707
00708 CN_LOGPRINTF("profileIndex[%d]", profileIndex);
00709
00710 return profileIndex;
00711 }
00712
00714
00715
00716
00718 static void on_icon_clicked(int iconID, int iconState)
00719 {
00720 CN_LOGPRINTF("entry: iconID [%d] iconState [%d]", iconID, iconState);
00721
00722 if ( g_select.active
00723 && iconID == g_select.iconID
00724 && iconState == iconState_selected)
00725 {
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737 g_select.icon_clicked = TRUE;
00738 }
00739 else
00740 {
00741
00742 if (iconState == iconState_normal)
00743 {
00744 switch (iconID)
00745 {
00746 case iconID_trashcan:
00747 begin_select_delete_profiles(iconID_trashcan,
00748 TRUE,
00749 delete_profiles);
00750 break;
00751 default:
00752 break;
00753 }
00754 }
00755 }
00756 }
00757
00758
00759 static void begin_select_delete_profiles(int iconID,
00760 gboolean confirm_with_icon,
00761 on_item_selected_t* callback_on_selected)
00762 {
00763 GtkProfileGroup* profileGroup;
00764
00765 CN_LOGPRINTF("entry: iconID [%d]", iconID);
00766
00767 g_assert(callback_on_selected != NULL);
00768
00769 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00770
00771
00772 gtk_profile_group_set_mode(profileGroup, deleteMode_e);
00773
00774
00775 g_select.iconID = iconID;
00776 g_select.on_item_selected = callback_on_selected;
00777 g_select.confirm_with_icon = confirm_with_icon;
00778
00779
00780 toolbar_disableUpdate();
00781 toolbar_setIconState(iconID_trashcan, iconState_grey);
00782 toolbar_setIconState(iconID, iconState_selected);
00783 toolbar_enableUpdate();
00784
00785
00786 unselect_delete_profiles();
00787
00788
00789 g_select.ticks = ITEM_SELECT_TIMEOUT_TICKS;
00790 g_select.timerID = g_timeout_add(500,
00791 on_end_select_delete_profiles_timer,
00792 0);
00793 g_select.icon_clicked = FALSE;
00794 g_select.active = TRUE;
00795
00796
00797 toolbar_synchronise();
00798 }
00799
00800 static gboolean on_end_select_delete_profiles_timer(gpointer data)
00801 {
00802 int i;
00803 int item_idx[MAX_PROFILES_PER_PAGE + 1];
00804 int* ip;
00805 gboolean call_me_again = FALSE;
00806
00807 CN_LOGPRINTF("entry");
00808
00809 if (g_select.active)
00810 {
00811 if (g_select.icon_clicked)
00812 {
00813
00814 if (g_select.on_item_selected != NULL)
00815 {
00816
00817 ip = item_idx;
00818 for (i = MAX_PROFILES_PER_PAGE - 1 ; i >= 0 ; i--)
00819 {
00820 if (g_select.item_selected[i])
00821 {
00822 *ip = i;
00823 ip++;
00824 }
00825 }
00826 *ip = -1;
00827 g_select.on_item_selected(item_idx);
00828 select_delete_profiles_stop(g_select.confirm_with_icon);
00829 }
00830 else
00831 {
00832 select_delete_profiles_stop(TRUE);
00833 }
00834 }
00835 else if (g_select.ticks > 0)
00836 {
00837
00838 g_select.ticks--;
00839 call_me_again = TRUE;
00840 }
00841 else
00842 {
00843
00844 select_delete_profiles_stop(TRUE);
00845 toolbar_synchronise();
00846 }
00847 }
00848
00849 return call_me_again;
00850 }
00851
00852 static void select_delete_profiles_stop(gboolean restore_toolbar)
00853 {
00854 GtkProfileGroup* profileGroup;
00855
00856 CN_LOGPRINTF("entry");
00857
00858 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00859
00860
00861 gtk_profile_group_set_mode(profileGroup, editMode_e);
00862
00863 if (g_select.active)
00864 {
00865
00866 gtk_timeout_remove(g_select.timerID);
00867 g_select.active = FALSE;
00868
00869
00870 unselect_delete_profiles();
00871
00872 if (restore_toolbar)
00873 {
00874
00875 toolbar_disableUpdate();
00876 edit_show_trashcan();
00877 toolbar_enableUpdate();
00878 toolbar_synchronise();
00879 }
00880 }
00881 }
00882
00883 static void unselect_delete_profiles(void)
00884 {
00885 int i;
00886
00887 GtkProfileGroup* profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00888
00889 for (i = 0 ; i < MAX_PROFILES_PER_PAGE; i++)
00890 {
00891 if (g_select.item_selected[i])
00892 {
00893 gtk_profile_group_unselect_profile(profileGroup, i);
00894 g_select.item_selected[i] = FALSE;
00895 }
00896 }
00897 }
00898
00899 static gboolean on_delete_profile_selected(GtkProfileGroup* profileGroup,
00900 guint index, gboolean active)
00901 {
00902 CN_LOGPRINTF("Entry: index [%d]", index);
00903
00904 if (g_select.active)
00905 {
00906
00907
00908
00909
00910 if (active)
00911 {
00912 g_select.item_selected[index] = FALSE;
00913 gtk_profile_group_unselect_profile(profileGroup, index);
00914 }
00915 else
00916 {
00917 g_select.item_selected[index] = TRUE;
00918 gtk_profile_group_select_profile(profileGroup, index);
00919 if ( !g_select.confirm_with_icon )
00920 {
00921 g_select.icon_clicked = TRUE;
00922 }
00923 }
00924
00925
00926 g_select.ticks = ITEM_SELECT_TIMEOUT_TICKS;
00927
00928 }
00929 return TRUE;
00930 }
00931
00932 static void delete_profiles(const int* index_tbl)
00933 {
00934 int itemCount;
00935 int index;
00936 const int* indexPtr;
00937 gboolean deleted = FALSE;
00938
00939 CN_LOGPRINTF("entry: index [%d]", index_tbl[0]);
00940
00941 itemCount = edit_data_get_n_network_profiles();
00942 for (indexPtr = index_tbl ; *indexPtr >= 0 ; indexPtr++)
00943 {
00944 index = *indexPtr;
00945
00946 if (index >= 0 && index < itemCount)
00947 {
00948 CN_LOGPRINTF("index [%d] itemCount [%d]", index, itemCount);
00949
00950
00951 erbusy_blink();
00952 edit_data_remove_network_profile(index);
00953 deleted = TRUE;
00954 }
00955 }
00956
00957 if (deleted)
00958 {
00959
00960 edit_data_store_network_profiles();
00961
00962
00963 edit_data_init_network_profiles();
00964 edit_profiles_display();
00965 }
00966 }
00967