void sync_select_callback(GObject* obj, gpointer user_data) { GtkTreePath* path; gtk_tree_view_get_cursor(GTK_TREE_VIEW(obj), &path, NULL); if (!path) return; size_t index = gtk_tree_path_get_indices(path)[0]; inspect_sync_t* sync = get_inspect_sync_vec(inspector->syncs, index); if (!sync) return; GtkTreeView* tree = GTK_TREE_VIEW(gtk_builder_get_object(builder, "sync_treeview")); GtkTreeStore* store = GTK_TREE_STORE(gtk_tree_view_get_model(tree)); gtk_tree_store_clear(store); GtkTreeIter row; gtk_tree_store_append(store, &row, NULL); gtk_tree_store_set(store, &row, 0, "Type", 1, get_enum_str(NULL, sync->type), -1); gtk_tree_store_append(store, &row, NULL); gtk_tree_store_set(store, &row, 0, "Condition", 1, get_enum_str(NULL, sync->condition), -1); gtk_tree_store_append(store, &row, NULL); gtk_tree_store_set(store, &row, 0, "Flags", 1, static_format("%u", sync->flags), -1); }
static void help(const apr_getopt_option_t *options, apr_pool_t *pool) { svn_error_clear (svn_cmdline_fprintf (stdout, pool, _("usage: svnraisetreeconflict [OPTIONS] WC_PATH NODE_KIND OPERATION ACTION REASON REPOS_URL1 PATH_IN_REPOS1 PEG_REV1 NODE_KIND1 REPOS_URL2 PATH_IN_REPOS2 PEG_REV2 NODE_KIND2\n\n" " Mark the working-copy node WC_PATH as being the victim of a tree conflict.\n" "\n" " WC_PATH's parent directory must be a working copy, otherwise a\n" " tree conflict cannot be raised.\n" "\n" "Valid options:\n"))); while (options->description) { const char *optstr; svn_opt_format_option(&optstr, options, TRUE, pool); svn_error_clear(svn_cmdline_fprintf(stdout, pool, " %s\n", optstr)); ++options; } svn_error_clear(svn_cmdline_fprintf(stdout, pool, _("\n" "Valid enum argument values:\n" " NODE_KIND, NODE_KIND1, NODE_KIND2:\n" " "))); print_enum_map(node_kind_map, pool); svn_error_clear(svn_cmdline_fprintf(stdout, pool, _("\n" " OPERATION:\n" " "))); print_enum_map(operation_map, pool); svn_error_clear(svn_cmdline_fprintf(stdout, pool, _("\n" " ACTION (what svn tried to do):\n" " "))); print_enum_map(action_map, pool); svn_error_clear(svn_cmdline_fprintf(stdout, pool, _("\n" " REASON (what local change made svn fail):\n" " "))); print_enum_map(reason_map, pool); svn_error_clear(svn_cmdline_fprintf(stdout, pool, _("\n" " REPOS_URL1, REPOS_URL2:\n" " The URL of the repository itself, e.g.: file://usr/repos\n" " PATH_IN_REPOS1, PATH_IN_REPOS2:\n" " The complete path of the node in the repository, e.g.: sub/dir/foo\n" " PEG_REV1, PEG_REV2:\n" " The revision number at which the given path is relevant.\n" "\n" "Example:\n" " svnraisetreeconflict ./foo %s %s %s %s file://usr/repos sub/dir/foo 1 %s file://usr/repos sub/dir/foo 3 %s\n\n"), get_enum_str(node_kind_map, svn_node_file), get_enum_str(operation_map, svn_wc_operation_update), get_enum_str(action_map, svn_wc_conflict_action_delete), get_enum_str(reason_map, svn_wc_conflict_reason_deleted), get_enum_str(node_kind_map, svn_node_file), get_enum_str(node_kind_map, svn_node_none) )); }
static int mixers_prt_cinfo(FILE *sfp, int tofile, mlist_t *mlistp, cinfo_t *cinfop, int vopt) { int mfd = mlistp->mfd; char *devnm = mlistp->cdi.shortname; oss_mixer_value cval; char *str; int i; int idx = -1; int rv = -1; char valbuf[COL_VAL_SZ + 1]; char selbuf[COL_SEL_SZ + 1]; col_prt_t col; cval.dev = -1; cval.ctrl = cinfop->ci.ctrl; if (ctype_valid(cinfop->ci.type)) { if (ioctl(mfd, SNDCTL_MIX_READ, &cval) < 0) { rv = errno; perror(_("Error reading control\n")); return (rv); } } else { /* if verbose, then continue to display the "pseudo" ctrls */ if (vopt < 2 || tofile) return (0); } /* * convert the control value into a string */ switch (cinfop->ci.type) { case MIXT_ONOFF: (void) snprintf(valbuf, sizeof (valbuf), "%s", cval.value ? _("on") : _("off")); break; case MIXT_MONOSLIDER: (void) snprintf(valbuf, sizeof (valbuf), "%d", cval.value & 0xff); break; case MIXT_STEREOSLIDER: (void) snprintf(valbuf, sizeof (valbuf), "%d:%d", (int)AUDIO_CTRL_STEREO_LEFT(cval.value), (int)AUDIO_CTRL_STEREO_RIGHT(cval.value)); break; case MIXT_ENUM: str = get_enum_str(cinfop, cval.value); if (str == NULL) { warn(_("Bad enum index %d for control '%s'\n"), cval.value, cinfop->ci.extname); return (EINVAL); } (void) snprintf(valbuf, sizeof (valbuf), "%s", str); break; default: (void) snprintf(valbuf, sizeof (valbuf), "-"); } /* * possible control values (range/selection) */ switch (cinfop->ci.type) { case MIXT_ONOFF: (void) snprintf(selbuf, sizeof (selbuf), _("on,off")); break; case MIXT_MONOSLIDER: (void) snprintf(selbuf, sizeof (selbuf), "%d-%d", cinfop->ci.minvalue, cinfop->ci.maxvalue); break; case MIXT_STEREOSLIDER: (void) snprintf(selbuf, sizeof (selbuf), "%d-%d:%d-%d", cinfop->ci.minvalue, cinfop->ci.maxvalue, cinfop->ci.minvalue, cinfop->ci.maxvalue); break; case MIXT_ENUM: /* * display the first choice on the same line, then display * the rest on multiple lines */ selbuf[0] = 0; for (i = 0; i < cinfop->ci.maxvalue; i++) { str = get_enum_str(cinfop, i); if (str == NULL) continue; if ((strlen(str) + 1 + strlen(selbuf)) >= sizeof (selbuf)) { break; } if (strlen(selbuf)) { (void) strlcat(selbuf, ",", sizeof (selbuf)); } (void) strlcat(selbuf, str, sizeof (selbuf)); } idx = i; break; default: (void) snprintf(selbuf, sizeof (selbuf), "-"); } col.col_dv = devnm; col.col_nm = strlen(cinfop->ci.extname) ? cinfop->ci.extname : cinfop->ci.id; while (strchr(col.col_nm, '_') != NULL) { col.col_nm = strchr(col.col_nm, '_') + 1; } col.col_val = valbuf; col.col_typ = ctype_str(cinfop->ci.type); col.col_sel = selbuf; mixers_prt_ctl_line(sfp, tofile, &col, vopt); /* print leftover enum value selections */ while ((!tofile) && (idx >= 0) && (idx < cinfop->ci.maxvalue)) { selbuf[0] = 0; for (i = idx; i < cinfop->ci.maxvalue; i++) { str = get_enum_str(cinfop, i); if (str == NULL) continue; if ((strlen(str) + 1 + strlen(selbuf)) >= sizeof (selbuf)) { break; } if (strlen(selbuf)) { (void) strlcat(selbuf, ",", sizeof (selbuf)); } (void) strlcat(selbuf, str, sizeof (selbuf)); } idx = i; col.col_dv = NULL; col.col_nm = NULL; col.col_val = NULL; col.col_typ = NULL; col.col_sel = selbuf; mixers_prt_ctl_line(sfp, tofile, &col, vopt); } return (0); }
static int mixers_set_cinfo(mlist_t *mlistp, cinfo_t *cinfop, char *wstr, int vopt) { int mfd = mlistp->mfd; oss_mixer_value cval; int wlen = strlen(wstr); int lval, rval; char *lstr, *rstr; char *str; int i; int rv = -1; cval.dev = -1; cval.ctrl = cinfop->ci.ctrl; cval.value = 0; switch (cinfop->ci.type) { case MIXT_ONOFF: cval.value = (strncmp(_("on"), wstr, wlen) == 0) ? 1 : 0; break; case MIXT_MONOSLIDER: cval.value = atoi(wstr); break; case MIXT_STEREOSLIDER: lstr = wstr; rstr = strchr(wstr, ':'); if (rstr != NULL) { *rstr = '\0'; rstr++; rval = atoi(rstr); lval = atoi(lstr); rstr--; *rstr = ':'; } else { lval = atoi(lstr); rval = lval; } cval.value = AUDIO_CTRL_STEREO_VAL(lval, rval); break; case MIXT_ENUM: for (i = 0; i < cinfop->ci.maxvalue; i++) { str = get_enum_str(cinfop, i); if (str == NULL) continue; if (strncmp(wstr, str, wlen) == 0) { cval.value = i; break; } } if (i >= cinfop->ci.maxvalue) { warn(_("Invalid enumeration value")); return (EINVAL); } break; default: warn(_("Unsupported control type\n")); return (EINVAL); } if (vopt) { msg(_("%s: '%s' set to '%s'\n"), mlistp->cdi.shortname, cinfop->ci.extname, wstr); } if (ioctl(mfd, SNDCTL_MIX_WRITE, &cval) < 0) { rv = errno; perror(_("Error writing control")); return (rv); } rv = 0; return (rv); }
void texture_select_callback(GObject* obj, gpointer user_data) { GtkTreeView* param_tree = GTK_TREE_VIEW(gtk_builder_get_object(builder, "selected_texture_treeview")); GtkTreeStore* param_store = GTK_TREE_STORE(gtk_tree_view_get_model(param_tree)); GtkTreeView* image_tree = GTK_TREE_VIEW(gtk_builder_get_object(builder, "selected_texture_images")); GtkTreeStore* image_store = GTK_TREE_STORE(gtk_tree_view_get_model(image_tree)); if (!param_store) return; if (!image_store) return; gtk_tree_store_clear(image_store); gtk_tree_store_clear(param_store); GtkTreePath* path; GtkSpinButton* layer_spinbutton = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "layer_spinbutton")); gtk_tree_view_get_cursor(GTK_TREE_VIEW(obj), &path, NULL); if (!path) { gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(layer_spinbutton), 0); return; } //Initialize params size_t tex_index = gtk_tree_path_get_indices(path)[0]; inspect_texture_t* tex = get_inspect_tex_vec(inspector->textures, tex_index); if (!tex) return; gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(layer_spinbutton), tex->layer_count-1); inspect_gl_tex_params_t params = tex->params; GtkTreeIter row; #define VAL(name, val) gtk_tree_store_append(param_store, &row, NULL);\ gtk_tree_store_set(param_store, &row, 0, (name), 1, (val), -1); if (tex->type) { VAL("Type", static_format("%s", get_enum_str("TextureTarget", tex->type))); VAL("Depth Stencil Mode", static_format("%s", get_enum_str(NULL, params.depth_stencil_mode))); VAL("Min Filter", static_format("%s", get_enum_str("TextureMinFilter", params.min_filter))); VAL("Mag Filter", static_format("%s", get_enum_str("TextureMagFilter", params.mag_filter))); VAL("Min LOD", static_format("%s", format_float(params.min_lod))); VAL("Max LOD", static_format("%s", format_float(params.max_lod))); VAL("LOD bias", static_format("%s", format_float(params.lod_bias))); VAL("Base Level", static_format("%d", params.base_level)); VAL("Max Level", static_format("%d", params.max_level)); VAL("Swizzle", static_format("[%s, %s, %s, %s]", get_enum_str(NULL, params.swizzle[0]), get_enum_str(NULL, params.swizzle[1]), get_enum_str(NULL, params.swizzle[2]), get_enum_str(NULL, params.swizzle[3]))); VAL("Wrap S", static_format("%s", get_enum_str("TextureWrapMode", params.wrap[0]))); VAL("Wrap T", static_format("%s", get_enum_str("TextureWrapMode", params.wrap[0]))); VAL("Wrap R", static_format("%s", get_enum_str("TextureWrapMode", params.wrap[0]))); VAL("Border Color", static_format("[%s, %s, %s, %s]", format_float(params.border_color[0]), format_float(params.border_color[1]), format_float(params.border_color[2]), format_float(params.border_color[3]))); VAL("Compare Mode", static_format("%s", get_enum_str(NULL, params.compare_mode))); VAL("Compare Func", static_format("%s", get_enum_str("DepthFunction", params.compare_func))); VAL("View Min Level", static_format("%d", params.view_min_level)); VAL("View Num Levels", static_format("%u", params.view_num_levels)); VAL("View Min Layer", static_format("%d", params.view_min_layer)); VAL("View Num Layers", static_format("%u", params.view_num_layers)); VAL("Immutable levels", static_format("%u", params.immutable_levels)); VAL("Image Format Compat Type", static_format("%s", get_enum_str(NULL, params.image_format_compatibility_type))); VAL("Immutable Format", static_format("%s", get_enum_str(NULL, params.immutable_format))); } if (tex->mipmaps) { VAL("Width", static_format("%zu", tex->width)); VAL("Height", static_format("%zu", tex->height)); VAL("Depth", static_format("%zu", tex->depth)); VAL("Mipmap Count", static_format("%zu", tex->mipmap_count)); VAL("Layer Count", static_format("%zu", tex->layer_count)); #undef VAL GtkSpinButton* layer_button = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "layer_spinbutton")); uint32_t layer = gtk_spin_button_get_value(GTK_SPIN_BUTTON(layer_button)); GtkComboBox* face_combobox = GTK_COMBO_BOX(gtk_builder_get_object(builder, "face_combobox")); gint face = gtk_combo_box_get_active(GTK_COMBO_BOX(face_combobox)); //Initialize images size_t w = tex->width; size_t h = tex->height; for (size_t level = 0; level < tex->mipmap_count; level++) { inspect_image_t* img = inspect_get_tex_mipmap(tex, level, layer, face); if (img->has_data) { uint32_t* data = (uint32_t*)malloc(w*h*4); inspect_get_image_data(img, data); GtkTreeIter row; gtk_tree_store_append(image_store, &row, NULL); GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h); uint32_t* dest = (uint32_t*)gdk_pixbuf_get_pixels(pixbuf); for (size_t y = 0; y < h; y++) { for (size_t x = 0; x < w; x++) { dest[(h-1-y)*w+x] = data[y*w+x]; } } gtk_tree_store_set(image_store, &row, 0, static_format("%u", level), 1, pixbuf, -1); g_object_unref(pixbuf); free(data); } w /= 2; h /= 2; } } }