int prerun(GList **config) { // fix gtk graphical bug : forward button is clicked in set_page_completed(); set_page_incompleted(); long long *compsize = (long long*)data_get(*config,"compsizepkg"); if(compsize != NULL) compressedsize = *compsize; makepath(TARGETDIR "/dev"); fw_system("mount /dev -o bind " TARGETDIR "/dev"); if(data_get(*config, "srcdev") != NULL) { if(install_pkgs_discs((GList*)data_get(*config, "packages"), (char*)data_get(*config, "srcdev")) == -1) { fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)")); return -1; } } else { if(install_pkgs((GList*)data_get(*config, "packages")) == -1) { fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)")); return -1; } } gtk_label_set_label(GTK_LABEL(labelpkg), _("Packages installation completed")); set_page_completed(); return 0; }
/* delete a custom mirror to the list */ void remove_mirror(GtkWidget *widget, gpointer data) { GtkTreeIter iter; GtkTreeView *treeview = (GtkTreeView *)data; GtkTreeModel *model = gtk_tree_view_get_model (treeview); GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { GtkTreePath *path; gchar *from; gtk_tree_model_get (model, &iter, COLUMN_FROM, &from, -1); /* don't delete default mirrors */ if(strcmp(from, "CUSTOM")) { fwife_error(_("Can't delete default mirrors")); return; } path = gtk_tree_model_get_path (model, &iter); gtk_list_store_remove (GTK_LIST_STORE (model), &iter); gtk_tree_path_free (path); } return; }
//* Load next plugin *// int show_help(GtkWidget *w, gpointer user_data) { if((plugin_active->load_help_widget) != NULL) { GtkWidget *helpwidget = plugin_active->load_help_widget(); GtkWidget *pBoite = gtk_dialog_new_with_buttons(_("Plugin help"), GTK_WINDOW(assistant), GTK_DIALOG_MODAL, GTK_STOCK_OK,GTK_RESPONSE_OK, NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), helpwidget, TRUE, TRUE, 5); gtk_widget_show_all(GTK_DIALOG(pBoite)->vbox); gtk_dialog_run(GTK_DIALOG(pBoite)); gtk_widget_destroy(pBoite); } else { fwife_error(_("No help available for this plugin")); } return 0; }
//* Load next plugin *// int plugin_next(GtkWidget *w, gpointer user_data) { if(plugin_active->run(&config) == -1) { LOG("Error when running plugin %s\n", plugin_active->name); fwife_error("Error when running plugin. Please report"); } // next plugin plugin_active = g_list_nth_data(plugin_list, g_list_index(plugin_list, (gconstpointer)plugin_active)+1); // prerun if(plugin_active->prerun) plugin_active->prerun(&config); return 0; }
int run_discs_config(GList **config) { int ret = fwife_question(_("Do you want to search for a installation CD/DVD?\n\n" "If you want an installation from a CD/DVD, you should answer 'Yes'.\n" "Otherwise if you want a network installation, you should answer 'No'")); /* if the user whant a cd/dvd install */ if(ret == GTK_RESPONSE_YES) { if(run_discs_detection(config)) { char *pacbindir = g_strdup_printf("%s/frugalware-%s", SOURCEDIR, ARCH); disable_cache(pacbindir); FREE(pacbindir); skip_to_next_plugin(); return 1; } else { fwife_error("No package database found.\nPerforming a network installation."); } } return 0; }
void x_config(GtkWidget *button, gpointer data) { GtkWidget* pBoite; GtkWidget *pEntryRes, *pEntryDepth; char* sRes, *sDepth, *mdev, *sDms, *ptr; int ret; GtkWidget *pVBox; GtkWidget *pFrame; GtkWidget *pVBoxFrame; GtkWidget *pLabel; GtkWidget *combo; GtkTreeIter iter; GtkListStore *store; GtkTreeModel *model; extern GtkWidget *assistant; //* Check if all necessary x files are present *// if(checkx() == -1) { fwife_error(_("Corrupted X installation. Missing file, see log for more details")); return; } pBoite = gtk_dialog_new_with_buttons(_("Configuring X11"), NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK,GTK_RESPONSE_OK, GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, NULL); gtk_window_set_transient_for(GTK_WINDOW(pBoite), GTK_WINDOW(assistant)); gtk_window_set_position(GTK_WINDOW(pBoite), GTK_WIN_POS_CENTER_ON_PARENT); pVBox = gtk_vbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), pVBox, TRUE, FALSE, 5); /* Creation du premier GtkFrame */ pFrame = gtk_frame_new(_("X11 Configuration")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); /* Creation et insertion d une boite pour le premier GtkFrame */ pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); /* Creation et insertion des elements contenus dans le premier GtkFrame */ pLabel = gtk_label_new(_("Resolution :")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pEntryRes = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(pEntryRes), "1024x768"); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryRes, TRUE, FALSE, 0); pLabel = gtk_label_new(_("Color depth :")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pEntryDepth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(pEntryDepth), "24"); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryDepth, TRUE, FALSE, 0); /* Creation du deuxieme GtkFrame */ pFrame = gtk_frame_new(_("Select your default display manager : ")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); /* Creation et insertion d une boite pour le deuxieme GtkFrame */ pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (GTK_TREE_MODEL (store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 0, NULL); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 1, NULL); //* Find Desktop managers installed *// checkdms(store); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); gtk_box_pack_start(GTK_BOX(pVBoxFrame), combo, TRUE, FALSE, 0); gtk_widget_show_all(pBoite); //* Run dialog box *// switch (gtk_dialog_run(GTK_DIALOG(pBoite))) { case GTK_RESPONSE_OK: sRes = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryRes))); sDepth = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryDepth))); gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); gtk_tree_model_get (model, &iter, 0, &sDms, -1); if((sRes == NULL) || !strcmp(sRes, "") || (sDepth == NULL) || !strcmp(sDepth, "")) return; pid_t pid = fork(); if(pid == -1) { LOG("Error when forking process (X11 config)"); } else if (pid == 0) { chroot(TARGETDIR); mdev = fwx_get_mousedev(); if(fwx_doprobe()) { exit(-1); } fwx_doconfig(mdev, sRes, sDepth); unlink("/root/xorg.conf.new"); ret = fwx_dotest(); //* create /sysconfig/desktop file *// write_dms(sDms); exit(ret); } else { wait(&ret); //* change keyboard localisation *// ptr = g_strdup_printf("%s/xkeybchange %s %s %s", SCRIPTDIR, xlayout, xvariant, TARGETDIR); fw_system(ptr); FREE(ptr); gtk_widget_destroy(pBoite); if(ret) x_config(button, data); else gtk_label_set_text(GTK_LABEL(data), g_strdup_printf("%s %s bpp", sRes, sDepth)); } break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_NONE: default: gtk_widget_destroy(pBoite); break; } FREE(sRes); FREE(sDepth); return; }
/* Dialog box for a personalized keyboard */ void add_keyboard(GtkWidget *button, gpointer data) { GtkWidget* pBoite; GtkWidget *pComboCons, *pEntryName, *pComboModel, *pComboVar; char* sName, *sCons, *sModel, *sVar; GtkWidget *pVBox; GtkWidget *pFrame; GtkWidget *pVBoxFrame; GtkWidget *pLabel; GtkWidget *image; GtkTreeIter iter; int i = 0; pBoite = gtk_dialog_new_with_buttons(_("Personalized keyboard"), NULL, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_transient_for(GTK_WINDOW(pBoite), GTK_WINDOW(assistant)); gtk_window_set_position(GTK_WINDOW(pBoite), GTK_WIN_POS_CENTER_ON_PARENT); pVBox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), pVBox, FALSE, FALSE, 5); char *imgpath = g_strdup_printf("%s/key48.png", IMAGEDIR); image = gtk_image_new_from_file(imgpath); gtk_box_pack_start(GTK_BOX(pVBox), image, FALSE, FALSE, 0); free(imgpath); pFrame = gtk_frame_new(_("Name")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); pEntryName = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryName, TRUE, TRUE, 0); pFrame = gtk_frame_new(_("Console Keymap")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); /* Combo for console layouts */ pComboCons = gtk_combo_box_new_text(); /* add items to combo */ for(i = 0; i < g_list_length(consolekeymap); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(pComboCons), g_list_nth_data(consolekeymap, i)); } gtk_combo_box_set_active(GTK_COMBO_BOX(pComboCons), 0); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pComboCons, TRUE, TRUE, 0); pFrame = gtk_frame_new(_("X Keymap (Used only if X server installed)")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 5); pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); /* Combo for X keyboards models */ pLabel = gtk_label_new(_("Model")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pComboModel = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pComboModel, TRUE, FALSE, 0); /* Combo for variants */ pLabel = gtk_label_new(_("Variant")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pComboVar = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pComboVar, TRUE, FALSE, 0); g_signal_connect (pComboModel, "changed", G_CALLBACK (model_changed),(gpointer)pComboVar); /* add items to model combo */ for(i = 0; i < g_list_length(xkeymap); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(pComboModel), g_list_nth_data(xkeymap, i)); } gtk_combo_box_set_active(GTK_COMBO_BOX(pComboModel), 0); gtk_widget_show_all(pBoite); switch (gtk_dialog_run(GTK_DIALOG(pBoite))) { case GTK_RESPONSE_OK: sName = (char*)gtk_entry_get_text(GTK_ENTRY(pEntryName)); sCons = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(pComboCons)); sModel = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(pComboModel)); sVar = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(pComboVar)); /* error if name is empty */ if(!strcmp(sName, "")) { fwife_error(_("You must enter a name for this keyboard")); gtk_widget_destroy(pBoite); break; } // add the new keyboard to the list gtk_tree_store_append(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(viewlayout))), &iter, NULL); gtk_tree_store_set(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(viewlayout))), &iter, 0, sName, 1, sModel, 2, sVar, 3, sCons, -1); gtk_widget_destroy(pBoite); break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_NONE: default: gtk_widget_destroy(pBoite); break; } }
int add_interface(GtkWidget *button, gpointer data) { fwnet_interface_t *newinterface = NULL; GtkWidget *cellview; GdkPixbuf *connectimg; char *ptr=NULL; char *nettype=NULL; char *iface=NULL; GtkTreeIter iter; GtkTreeModel *model; gtk_combo_box_get_active_iter(GTK_COMBO_BOX(intercombo), &iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(intercombo)); gtk_tree_model_get (model, &iter, 0, &iface, -1); int i; for(i=0;i<g_list_length(interfaceslist); i+=2) { if(!strcmp((char*)g_list_nth_data(interfaceslist, i), iface)) { fwife_error("This interface has been already configured!"); return -1; } } if((newinterface = (fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL) return(-1); memset(newinterface, 0, sizeof(fwnet_interface_t)); snprintf(newinterface->name, IF_NAMESIZE, iface); nettype = ask_nettype(); if(nettype == NULL) return -1; if(strcmp(nettype, "lo")) { interfaceslist = g_list_append(interfaceslist, strdup(iface)); interfaceslist = g_list_append(interfaceslist, newinterface); GtkTreeView *treeview = (GtkTreeView *)data; model = gtk_tree_view_get_model (treeview); cellview = gtk_cell_view_new (); connectimg = gtk_widget_render_icon (cellview, GTK_STOCK_NETWORK, GTK_ICON_SIZE_BUTTON, NULL); gtk_widget_destroy (cellview); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IMAGE, connectimg, COLUMN_NET_NAME, iface, -1); } if(strcmp(nettype, "lo") && fwnet_is_wireless_device(iface)) { switch(fwife_question(_("It seems that this network card has a wireless extension.\n\nConfigure your wireless now?"))) { case GTK_RESPONSE_YES: configure_wireless(newinterface); break; case GTK_RESPONSE_NO: break; } } if(!strcmp(nettype, "dhcp")) { ptr = fwife_entry(_("Set DHCP hostname"), _("Some network providers require that the DHCP hostname be\n" "set in order to connect.\n If so, they'll have assigned a hostname to your machine.\n If you were" "assigned a DHCP hostname, please enter it below.\n If you do not have a DHCP hostname, just" "hit enter."), NULL); if(strlen(ptr)) snprintf(newinterface->dhcp_opts, PATH_MAX, "-t 10 -h %s\n", ptr); else newinterface->dhcp_opts[0]='\0'; newinterface->options = g_list_append(newinterface->options, strdup("dhcp")); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IP, "dhcp", COLUMN_NET_NAMESERV, ptr, -1); FREE(ptr); } else if(!strcmp(nettype, "static")) { configure_static(newinterface, iter); } return 0; }
int dsl_config(fwnet_profile_t *profile) { extern GtkWidget *assistant; GtkWidget *phboxtemp, *labeltemp; int i; char *uname, *passwd, *passverify, *iface; GtkTreeIter iter; GtkTreeModel *model; GtkWidget *pBoite = gtk_dialog_new_with_buttons(_("Configure DSL connexion"), GTK_WINDOW(assistant), GTK_DIALOG_MODAL, GTK_STOCK_OK,GTK_RESPONSE_OK, GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, NULL); GtkWidget *labelinfo = gtk_label_new(_("Enter DSL parameters")); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), labelinfo, FALSE, FALSE, 5); phboxtemp = gtk_hbox_new(FALSE, 0); labeltemp = gtk_label_new(_("PPPOE username : "******"PPPOE password : "******"Re-enter PPPOE password : "******"Associate with interface : ")); gtk_box_pack_start(GTK_BOX(phboxtemp), labeltemp, FALSE, FALSE, 5); GtkWidget *intercombodsl = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(phboxtemp), intercombodsl, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), phboxtemp, FALSE, FALSE, 5); if(iflist != NULL) { gtk_combo_box_append_text(GTK_COMBO_BOX(intercombodsl), ""); for(i=0; i<g_list_length(iflist); i+=2) { gtk_combo_box_append_text(GTK_COMBO_BOX(intercombodsl), (char*)g_list_nth_data(iflist, i)); } } /* Affichage des elements de la boite de dialogue */ gtk_widget_show_all(GTK_DIALOG(pBoite)->vbox); /* On lance la boite de dialogue et on recupere la reponse */ switch (gtk_dialog_run(GTK_DIALOG(pBoite))) { /* L utilisateur valide */ case GTK_RESPONSE_OK: uname = (char*)gtk_entry_get_text(GTK_ENTRY(pEntryName)); passwd = (char*)gtk_entry_get_text(GTK_ENTRY(pEntryPass)); passverify = (char*)gtk_entry_get_text(GTK_ENTRY(pEntryVerify)); gtk_combo_box_get_active_iter(GTK_COMBO_BOX(intercombo), &iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(intercombo)); gtk_tree_model_get (model, &iter, 0, &iface, -1); if(strcmp(passverify, passwd)) { fwife_error("Passwords do not match! Try again."); gtk_widget_destroy(pBoite); dsl_config(profile); return 0; } else { snprintf(profile->adsl_username, PATH_MAX, uname); snprintf(profile->adsl_password, PATH_MAX, passwd); if(strcmp(iface, "")) snprintf(profile->adsl_interface, IF_NAMESIZE, iface); } break; /* L utilisateur annule */ case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_NONE: default: break; } /* Destruction de la boite de dialogue */ gtk_widget_destroy(pBoite); return 0; }
int install_pkgs(GList *pkgs) { int i = 0, questret; PM_LIST *pdata = NULL, *pkgsl; char *ptr, *file; /* nothing to install */ if(pkgs == NULL) return 0; if(pacman_initialize(TARGETDIR) == -1) { LOG("Failed to initialize pacman library (%s)\n", pacman_strerror(pm_errno)); return -1; } if (pacman_parse_config("/etc/pacman-g2.conf", NULL, "") == -1) { LOG("Failed to parse pacman-g2 configuration file (%s)", pacman_strerror(pm_errno)); pacman_release(); return(-1); } //* Set pacman options *// #ifndef NDEBUG pacman_set_option(PM_OPT_LOGMASK, -1); #else pacman_set_option(PM_OPT_LOGMASK, PM_LOG_ERROR | PM_LOG_WARNING); #endif pacman_set_option(PM_OPT_LOGCB, (long)cb_log); pacman_set_option (PM_OPT_DLCB, (long)progress_update); pacman_set_option (PM_OPT_DLOFFSET, (long)&offset); pacman_set_option (PM_OPT_DLRATE, (long)&rate); pacman_set_option (PM_OPT_DLFNM, (long)reponame); pacman_set_option (PM_OPT_DLHOWMANY, (long)&howmany); pacman_set_option (PM_OPT_DLREMAIN, (long)&remains); pacman_set_option (PM_OPT_DLT0, (long)&t0); pacman_set_option (PM_OPT_DLT0, (long)&t); pacman_set_option (PM_OPT_DLXFERED1, (long)&xferred1); PM_DB *db_local = pacman_db_register("local"); if(db_local == NULL) { LOG("Could not register 'local' database (%s)\n", pacman_strerror(pm_errno)); pacman_release(); return -1; } retry: if(pacman_trans_init(PM_TRANS_TYPE_SYNC, PM_TRANS_FLAG_FORCE|PM_TRANS_FLAG_NODEPS, progress_event, progress_conv, progress_install) == -1) { if (pm_errno == PM_ERR_HANDLE_LOCK) { file = g_strdup_printf("%s/tmp/pacman-g2.lck", TARGETDIR); g_remove (file); free(file); goto retry; } LOG("Failed to initialize transaction %s\n", pacman_strerror (pm_errno)); pacman_release(); return -1; } for (i = 0; i<g_list_length(pkgs); i++) { ptr = strdup((char*)g_list_nth_data(pkgs, i)); if(pacman_trans_addtarget(strdup(drop_version(ptr))) == -1) LOG("Error adding packet %s", pacman_strerror (pm_errno)); free(ptr); } //* prepare transaction *// if(pacman_trans_prepare(&pdata) == -1) { LOG("Failed to prepare transaction (%s)", pacman_strerror (pm_errno)); pacman_list_free(pdata); pacman_trans_release(); pacman_release(); return -1; } pkgsl = pacman_trans_getinfo (PM_TRANS_PACKAGES); if (pkgsl == NULL) { LOG("Error getting transaction info %s\n", pacman_strerror (pm_errno)); pacman_trans_release(); pacman_release(); return -1; } /* commit transaction */ if (pacman_trans_commit(&pdata) == -1) { switch(pm_errno) { case PM_ERR_DISK_FULL: fwife_error(_("Disk full, cannot install more packages")); break; case PM_ERR_PKG_CORRUPTED: questret = fwife_question(_("Some packages seems corrupted, do you want to download them again?")); if(questret == GTK_RESPONSE_YES) { pacman_list_free(pdata); pacman_trans_release(); goto retry; } break; case PM_ERR_RETRIEVE: fwife_error(_("Failed to retrieve packages")); break; default: break; } LOG("Failed to commit transaction (%s)\n", pacman_strerror (pm_errno)); pacman_list_free(pdata); pacman_trans_release(); pacman_release(); return -1; } /* release the transaction */ pacman_trans_release(); pacman_release(); return 0; }