static void pgd_form_field_view_set_field (GtkWidget *field_view, PopplerFormField *field) { GtkWidget *alignment; GtkWidget *table; GEnumValue *enum_value; gchar *text; gint row = 0; alignment = gtk_bin_get_child (GTK_BIN (field_view)); if (alignment) { gtk_container_remove (GTK_CONTAINER (field_view), alignment); } alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 12, 5); gtk_container_add (GTK_CONTAINER (field_view), alignment); gtk_widget_show (alignment); if (!field) return; table = gtk_table_new (13, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); text = poppler_form_field_get_name (field); if (text) { pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", text, &row); g_free (text); } text = poppler_form_field_get_partial_name (field); if (text) { pgd_table_add_property (GTK_TABLE (table), "<b>Partial Name:</b>", text, &row); g_free (text); } text = poppler_form_field_get_mapping_name (field); if (text) { pgd_table_add_property (GTK_TABLE (table), "<b>Mapping Name:</b>", text, &row); g_free (text); } switch (poppler_form_field_get_field_type (field)) { case POPPLER_FORM_FIELD_BUTTON: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_BUTTON_TYPE), poppler_form_field_button_get_button_type (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Button Type:</b>", enum_value->value_name, &row); pgd_table_add_property (GTK_TABLE (table), "<b>Button State:</b>", poppler_form_field_button_get_state (field) ? "Active" : "Inactive", &row); break; case POPPLER_FORM_FIELD_TEXT: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_TEXT_TYPE), poppler_form_field_text_get_text_type (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Text Type:</b>", enum_value->value_name, &row); text = poppler_form_field_text_get_text (field); pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row); g_free (text); text = g_strdup_printf ("%d", poppler_form_field_text_get_max_len (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Max Length:</b>", text, &row); g_free (text); pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>", poppler_form_field_text_do_spell_check (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Do scroll:</b>", poppler_form_field_text_do_scroll (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Rich Text:</b>", poppler_form_field_text_is_rich_text (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Pasword type:</b>", poppler_form_field_text_is_password (field) ? "Yes" : "No", &row); break; case POPPLER_FORM_FIELD_CHOICE: { gchar *item; gint selected; enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_CHOICE_TYPE), poppler_form_field_choice_get_choice_type (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Choice Type:</b>", enum_value->value_name, &row); pgd_table_add_property (GTK_TABLE (table), "<b>Editable:</b>", poppler_form_field_choice_is_editable (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Multiple Selection:</b>", poppler_form_field_choice_can_select_multiple (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>", poppler_form_field_choice_do_spell_check (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Commit on Change:</b>", poppler_form_field_choice_commit_on_change (field) ? "Yes" : "No", &row); text = g_strdup_printf ("%d", poppler_form_field_choice_get_n_items (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Number of items:</b>", text, &row); g_free (text); pgd_form_field_view_add_choice_items (GTK_TABLE (table), field, &selected, &row); if (poppler_form_field_choice_get_n_items (field) > selected) { item = poppler_form_field_choice_get_item (field, selected); text = g_strdup_printf ("%d (%s)", selected, item); g_free (item); pgd_table_add_property (GTK_TABLE (table), "<b>Selected item:</b>", text, &row); g_free (text); } text = poppler_form_field_choice_get_text (field); pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row); g_free (text); } break; case POPPLER_FORM_FIELD_SIGNATURE: case POPPLER_FORM_FIELD_UNKNOWN: break; default: g_assert_not_reached (); } gtk_container_add (GTK_CONTAINER (alignment), table); gtk_widget_show (table); }
static void sp_paint_server_class_init(SPPaintServerClass *psc) { psc->pattern_new = sp_paint_server_create_dummy_pattern; parent_class = static_cast<SPObjectClass *>(g_type_class_ref(SP_TYPE_OBJECT)); }
/** * pyg_flags_get_value: * @flag_type: the GType of the flag. * @obj: a Python object representing the flag value * @val: a pointer to the location to store the integer representation of the flag. * * Converts a Python object to the integer equivalent. The conversion * will depend on the type of the Python object. If the object is an * integer, it is passed through directly. If it is a string, it will * be treated as a full or short flag name as defined in the GType. * If it is a tuple, then the items are treated as strings and ORed * together. * * Returns: 0 on success or -1 on failure */ gint pyg_flags_get_value(GType flag_type, PyObject *obj, guint *val) { GFlagsClass *fclass = NULL; gint res = -1; g_return_val_if_fail(val != NULL, -1); if (!obj) { *val = 0; res = 0; } else if (PYGLIB_PyLong_Check(obj)) { *val = PYGLIB_PyLong_AsUnsignedLong(obj); res = 0; } else if (PyLong_Check(obj)) { *val = PyLong_AsLongLong(obj); res = 0; } else if (PYGLIB_PyUnicode_Check(obj)) { GFlagsValue *info; char *str = PYGLIB_PyUnicode_AsString(obj); if (flag_type != G_TYPE_NONE) fclass = G_FLAGS_CLASS(g_type_class_ref(flag_type)); else { PyErr_SetString(PyExc_TypeError, "could not convert string to flag because there is no GType associated to look up the value"); res = -1; } info = g_flags_get_value_by_name(fclass, str); g_type_class_unref(fclass); if (!info) info = g_flags_get_value_by_nick(fclass, str); if (info) { *val = info->value; res = 0; } else { PyErr_SetString(PyExc_TypeError, "could not convert string"); res = -1; } } else if (PyTuple_Check(obj)) { int i, len; len = PyTuple_Size(obj); *val = 0; res = 0; if (flag_type != G_TYPE_NONE) fclass = G_FLAGS_CLASS(g_type_class_ref(flag_type)); else { PyErr_SetString(PyExc_TypeError, "could not convert string to flag because there is no GType associated to look up the value"); res = -1; } for (i = 0; i < len; i++) { PyObject *item = PyTuple_GetItem(obj, i); char *str = PYGLIB_PyUnicode_AsString(item); GFlagsValue *info = g_flags_get_value_by_name(fclass, str); if (!info) info = g_flags_get_value_by_nick(fclass, str); if (info) { *val |= info->value; } else { PyErr_SetString(PyExc_TypeError, "could not convert string"); res = -1; break; } } g_type_class_unref(fclass); } else { PyErr_SetString(PyExc_TypeError, "flag values must be strings, ints, longs, or tuples"); res = -1; } return res; }
static void test_photography_settings (GstElement * cam) { #ifdef HAVE_GST_PHOTO_IFACE_H GTypeClass *tclass; if (!GST_IS_PHOTOGRAPHY (cam)) { GST_WARNING ("omitting photography test"); return; } gfloat ev_comp, orig_ev_comp; for (ev_comp = -3.0; ev_comp <= 3.0; ev_comp += 0.5) { orig_ev_comp = ev_comp; gst_photography_set_ev_compensation (GST_PHOTOGRAPHY (cam), ev_comp); gst_photography_get_ev_compensation (GST_PHOTOGRAPHY (cam), &ev_comp); fail_if (orig_ev_comp != ev_comp, "setting photography ev compensation failed"); ev_comp = orig_ev_comp; g_usleep (PHOTO_SETTING_DELAY_US); } /* FIXME: what are the actual iso values? */ guint iso_speed = 100, orig_iso_speed; for (iso_speed = 100; iso_speed <= 800; iso_speed *= 2) { orig_iso_speed = iso_speed; gst_photography_set_iso_speed (GST_PHOTOGRAPHY (cam), iso_speed); gst_photography_get_iso_speed (GST_PHOTOGRAPHY (cam), &iso_speed); fail_if (orig_iso_speed != iso_speed, "setting photography iso speed failed"); iso_speed = orig_iso_speed; g_usleep (PHOTO_SETTING_DELAY_US); } tclass = g_type_class_ref (GST_TYPE_FLASH_MODE); GstFlashMode flash, orig_flash; for (flash = 0; flash < G_ENUM_CLASS (tclass)->n_values; flash++) { orig_flash = flash; gst_photography_set_flash_mode (GST_PHOTOGRAPHY (cam), flash); gst_photography_get_flash_mode (GST_PHOTOGRAPHY (cam), &flash); fail_if (orig_flash != flash, "setting photography flash failed"); flash = orig_flash; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_WHITE_BALANCE_MODE); GstWhiteBalanceMode wb, orig_wb; for (wb = 0; wb < G_ENUM_CLASS (tclass)->n_values; wb++) { orig_wb = wb; gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY (cam), wb); gst_photography_get_white_balance_mode (GST_PHOTOGRAPHY (cam), &wb); fail_if (orig_wb != wb, "setting photography white balance mode failed"); wb = orig_wb; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_COLOUR_TONE_MODE); GstColourToneMode ct, orig_ct; for (ct = 0; ct < G_ENUM_CLASS (tclass)->n_values; ct++) { orig_ct = ct; gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY (cam), ct); gst_photography_get_colour_tone_mode (GST_PHOTOGRAPHY (cam), &ct); fail_if (orig_ct != ct, "setting photography colour tone mode failed"); ct = orig_ct; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_SCENE_MODE); GstSceneMode sm, orig_sm; for (sm = 0; sm < G_ENUM_CLASS (tclass)->n_values; sm++) { orig_sm = sm; gst_photography_set_scene_mode (GST_PHOTOGRAPHY (cam), sm); gst_photography_get_scene_mode (GST_PHOTOGRAPHY (cam), &sm); fail_if (orig_sm != sm, "setting photography scene mode failed"); sm = orig_sm; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); gfloat zoom, orig_zoom; gst_photography_set_zoom (GST_PHOTOGRAPHY (cam), zoom); for (zoom = 1.0; zoom <= 10.0; zoom += 1.0) { orig_zoom = zoom; gst_photography_set_zoom (GST_PHOTOGRAPHY (cam), zoom); gst_photography_get_zoom (GST_PHOTOGRAPHY (cam), &zoom); fail_if (orig_zoom != zoom, "setting photography zoom failed"); zoom = orig_zoom; g_usleep (PHOTO_SETTING_DELAY_US); } #else GST_DEBUG ("omitting photography test"); #endif }