static void on_control_dialog_ok (GtkWidget *widget, GbWidgetNewData *data) { GtkTreeView *view; GtkTreeModel *model; GtkTreeIter iter; GtkWidget *dialog; GtkTreeSelection *selection; char *moniker; GtkWidget *new_widget; dialog = gtk_widget_get_toplevel (widget); view = g_object_get_data (G_OBJECT (dialog), "tree_view"); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); gtk_tree_selection_get_selected (selection, &model, &iter); gtk_tree_model_get (model, &iter, COL_OBJID, &moniker, -1); new_widget = control_create (data, moniker, widget_get_uic (data->parent)); if (new_widget) { gb_widget_initialize (new_widget, data); data->callback (new_widget, data); } else { glade_util_show_message_box (_("Couldn't create the Bonobo control"), NULL); } gtk_widget_destroy (dialog); }
void new_spiral(float x, float y) { int inserter; ++num_ncs; ncss = realloc(ncss, sizeof(control*) * num_ncs); inserter = num_ncs - 1; const int vertices = 20; float (*pts)[2] = malloc(sizeof(float[2]) * vertices); float r = 0; float t = 0; for(int i = 0; i < vertices; ++i) { t += 3.14 / 4; r += 5; pts[i][0] = r*cos(t) + x; pts[i][1] = r*sin(t) + y; } ncss[inserter] = ncs_create(control_create(pts, vertices)); active_pt = ncss[inserter]->c->pts[ncss[inserter]->c->n-1]; active_ncs = ncss[inserter]; }
void new_cycloide(float x, float y) { int inserter; ++num_ncs; ncss = realloc(ncss, sizeof(control*) * num_ncs); inserter = num_ncs - 1; const int vertices = 20; float (*pts)[2] = malloc(sizeof(float[2]) * vertices); float p = 15; float q = 30; float t = -5*3.1415; for(int i = 0; i < vertices; ++i) { t += 31.45 / (float)(vertices); pts[i][0] = p*t-q*sin(t) + x; pts[i][1] = p-q*cos(t) + y; } ncss[inserter] = ncs_create(control_create(pts, vertices)); active_pt = ncss[inserter]->c->pts[ncss[inserter]->c->n-1]; active_ncs = ncss[inserter]; }
void new_curve(float x, float y) { int inserter; ++num_ncs; ncss = realloc(ncss, sizeof(control*) * num_ncs); inserter = num_ncs - 1; float (*pts)[2] = malloc(sizeof(float[2])); pts[0][0] = x; pts[0][1] = y; ncss[inserter] = ncs_create(control_create(pts, 1)); active_pt = ncss[inserter]->c->pts[ncss[inserter]->c->n-1]; active_ncs = ncss[inserter]; }
static GtkWidget * gb_bonobo_control_new (GbWidgetNewData * data) { GtkWidget *new_widget; if (data->action == GB_LOADING) { char *moniker; moniker = load_string (data->loading_data, Moniker); new_widget = control_create (data, moniker, widget_get_uic (data->parent)); return new_widget; } else { show_control_dialog (data); return NULL; } }
void exec_shell(struct conf *cfp, int fd, int parentfd) { int master, slave; pid_t pid; char line[MAXPATHLEN]; char *tty; #ifdef HAVE_UTMP_H struct utmp ut; #elif HAVE_UTMPX_H struct utmpx ut; struct timeval tv; #endif #if defined(HAVE_UTMP_H) || defined(HAVE_UTMPX_H) memset(&ut, 0, sizeof(ut)); #endif if (pipe(pipechld) < 0) { syslog(LOG_ERR, "exec_shell() pipe %m"); _exit(1); } (void)non_blocking(pipechld[0]); (void)non_blocking(pipechld[1]); if (openpty(&master, &slave, line, NULL, NULL) == -1) { syslog(LOG_ERR, "openpty %m"); _exit(1) ; } /* * pts/x compatible */ if ((tty = strstr(line, "/dev/"))) tty += 5; else tty = line; #if defined(HAVE_UTMP_H) || defined(HAVE_UTMPX_H) if (cfp->utmp) { if (cfp->utname) { #ifdef HAVE_UTMP_H (void)strncpy(ut.ut_name, cfp->utname, sizeof(ut.ut_name)-1); ut.ut_name[sizeof(ut.ut_name)-1] = '\0'; #elif HAVE_UTMPX_H (void)strncpy(ut.ut_user, cfp->utname, sizeof(ut.ut_user)-1); ut.ut_user[sizeof(ut.ut_user)-1] = '\0'; #endif } else { struct passwd *pw; pw = get_pwentry(cfp->havesetuser ? cfp->setuser : \ 0); #ifdef HAVE_UTMP_H (void)strncpy(ut.ut_name, pw->pw_name, sizeof(ut.ut_name)-1); ut.ut_name[sizeof(ut.ut_name)-1] = '\0'; #elif HAVE_UTMPX_H (void)strncpy(ut.ut_user, pw->pw_name, sizeof(ut.ut_user)-1); ut.ut_user[sizeof(ut.ut_user)-1] = '\0'; #endif } (void)strncpy(ut.ut_line, tty, sizeof(ut.ut_line)-1); ut.ut_line[sizeof(ut.ut_line)-1] = '\0'; if (cfp->uthost) { (void)strncpy(ut.ut_host, cfp->uthost, sizeof(ut.ut_host)-1); ut.ut_host[sizeof(ut.ut_host)-1] = '\0'; } #ifdef HAVE_UTMP_H (void)time(&ut.ut_time); #elif HAVE_UTMPX_H (void)gettimeofday(&tv, NULL); ut.ut_tv.tv_sec = tv.tv_sec; ut.ut_tv.tv_usec = tv.tv_usec; (void)strncpy(ut.ut_id, ut.ut_line, sizeof(ut.ut_id)-1); ut.ut_line[sizeof(ut.ut_line)-1] = '\0'; ut.ut_pid = getpid(); ut.ut_type = USER_PROCESS; #endif } #endif /* * overwriting signal disposition */ (void)signal(SIGCHLD, sig_chld); switch (pid = fork()) { case -1: syslog(LOG_ERR, "forkpty: %m"); _exit(1); case 0: (void)close(parentfd); (void)close(pipechld[0]); (void)close(pipechld[1]); (void)close(master); (void)close(fd); (void)login_tty(slave); #ifdef HAVE_UTMP_H login(&ut); #elif HAVE_UTMPX_H setutxent(); (void)pututxline(&ut); #endif set_privileges(cfp); /* * SUIP PROGRAM HERE */ #ifdef __NetBSD__ (void)execl(_PATH_BSHELL,"sh", "-c",cfp->suipfile,(char *)NULL); #else (void)execl(_PATH_BSHELL, "sh", "-p", "-c", cfp->suipfile, (char *)NULL); #endif _exit(127); default: { int ctrls; int exit_status = 0; (void)close(slave); /* * trying to open a control channel * control_create() returns the number of bytes which were * written * select_fd() returns -1 if errors exist you can check errno */ if (control_create(&ctrls, fd) == 1) { if (select_fd(cfp, fd, master, ctrls, parentfd) < 0) exit_status = 1; } else { syslog(LOG_ERR, "can't open ctrl chan"); exit_status = 1; } #if defined(HAVE_UTMP_H) || defined(HAVE_UTMPX_H) if (cfp->utmp) { #ifdef HAVE_UTMP_H if (!logout(tty)) { syslog(LOG_ERR, "unable to logout on %s", tty); exit_status = 1; } else logwtmp(tty, "", ""); #elif HAVE_UTMPX_H ut.ut_type = DEAD_PROCESS; (void)gettimeofday(&tv, NULL); ut.ut_tv.tv_sec = tv.tv_sec; ut.ut_tv.tv_usec = tv.tv_usec; (void)memset(&ut.ut_user, 0, sizeof(ut.ut_user)); setutxent(); if (pututxline(&ut) == NULL) { syslog(LOG_ERR, "unable to logout on %s (utmpx)", tty); exit_status = 1; } endutxent(); #endif } #endif cleanup(line); _exit(exit_status); }} /* * never reached */ _exit(1); }