VOID userconfig_set_adapter(USERCONFIG *userconfig, CHAR *name) { int i, count; ETHCARD_INFO ethcards[16]; count = get_ethcards(ethcards, sizeof(ethcards)); strcpy(userconfig->szAdaptor, name); for (i = 0; i < count; i++) if (strcmp(ethcards[i].name, name) == 0) { strcpy(userconfig->szMac, ethcards[i].mac); strcpy(userconfig->szIp, ethcards[i].ip); break; } }
/* * gtunet_init_gui * * Add the components that are not in the xml file. */ void gtunet_init_gui () { int i; GtkListStore *liststore_adapter; GtkListStore *liststore_limitation; GtkTreeIter treeiter; GtkCellRenderer *renderer; renderer = gtk_cell_renderer_text_new(); /* * 1. Init combobox_adapter */ /* Get number of ethercards using mytunet API */ ethcard_count = (int)get_ethcards(ethcards, sizeof(ethcards)); liststore_adapter = (GtkListStore *)gtk_builder_get_object (builder, "liststore_adapter"); /* Add the ethercards to the combobox */ for (i = 0; i < ethcard_count; i++) { gtk_list_store_append(liststore_adapter, &treeiter); gtk_list_store_set(liststore_adapter, &treeiter, 0, ethcards[i].desc, -1); } /* Render */ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox_adapter), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox_adapter), renderer, "text", 0, NULL); /* Set the first adapter to be active, usually is lo */ if (ethcard_count != 0) { gtk_combo_box_set_active(combobox_adapter, 0); } /* * 2. Init entry_username and entry_password */ gtk_entry_set_text(entry_username, user_config.szUsername); if (save_password) { gtk_entry_set_text(entry_password, user_config.szMD5Password); } /* * 3. Init combobox_limitation */ liststore_limitation = (GtkListStore *)gtk_builder_get_object (builder, "liststore_limitation"); gtk_list_store_append(liststore_limitation, &treeiter); gtk_list_store_set(liststore_limitation, &treeiter, 0, "Campus", -1); gtk_list_store_append(liststore_limitation, &treeiter); gtk_list_store_set(liststore_limitation, &treeiter, 0, "Domestic", -1); gtk_list_store_append(liststore_limitation, &treeiter); gtk_list_store_set(liststore_limitation, &treeiter, 0, "None", -1); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox_limitation), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox_limitation), renderer, "text", 0, NULL); gtk_combo_box_set_active(combobox_limitation, 1); /* * 4. Init checkbutton_savepassword */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_savepassword), save_password); /* * 5. Init tray_icon and tray_menu */ tray_icon = gtunet_create_tray_icon(); tray_menu = gtunet_create_tray_menu(); /* * 6. Init image_status */ gtunet_set_status_from_pixbuf(pixbuf_status_none); /* * 7. Init textview_info */ textmark_info = gtk_text_buffer_get_insert(textbuffer_info); /* * 8. Set window default icon */ gtk_window_set_default_icon(pixbuf_gtunet); gtk_about_dialog_set_logo(about_dialog, pixbuf_gtunet); }