GtkWidget * gimp_prop_table_new (GObject *config, GType owner_type, GimpContext *context, GimpCreatePickerFunc create_picker_func, gpointer picker_creator) { GtkWidget *table; GtkSizeGroup *size_group; GParamSpec **param_specs; guint n_param_specs; gint i; gint row = 0; GParamSpec *last_pspec = NULL; GtkAdjustment *last_x_adj = NULL; gint last_x_row = 0; g_return_val_if_fail (G_IS_OBJECT (config), NULL); g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config), &n_param_specs); size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); table = gtk_table_new (3, 1, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 2); for (i = 0; i < n_param_specs; i++) { GParamSpec *pspec = param_specs[i]; GtkWidget *widget = NULL; const gchar *label = NULL; /* ignore properties of parent classes of owner_type */ if (! g_type_is_a (pspec->owner_type, owner_type)) continue; if (G_IS_PARAM_SPEC_STRING (pspec)) { static GQuark multiline_quark = 0; if (! multiline_quark) multiline_quark = g_quark_from_static_string ("multiline"); if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec)) { widget = gimp_prop_file_chooser_button_new (config, pspec->name, g_param_spec_get_nick (pspec), GTK_FILE_CHOOSER_ACTION_OPEN); } else if (g_param_spec_get_qdata (pspec, multiline_quark)) { GtkTextBuffer *buffer; GtkWidget *view; buffer = gimp_prop_text_buffer_new (config, pspec->name, -1); view = gtk_text_view_new_with_buffer (buffer); widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (widget), view); gtk_widget_show (view); } else { widget = gimp_prop_entry_new (config, pspec->name, -1); } label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { widget = gimp_prop_check_button_new (config, pspec->name, g_param_spec_get_nick (pspec)); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget), g_param_spec_get_nick (pspec)); } else if (GEGL_IS_PARAM_SPEC_SEED (pspec)) { GtkAdjustment *adj; GtkWidget *scale; GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); scale = gimp_prop_spin_scale_new (config, pspec->name, g_param_spec_get_nick (pspec), 1.0, 10.0, 0); gtk_box_pack_start (GTK_BOX (widget), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gtk_button_new_with_label (_("New Seed")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (scale)); g_signal_connect (button, "clicked", G_CALLBACK (gimp_prop_table_new_seed_clicked), adj); } else if (G_IS_PARAM_SPEC_INT (pspec) || G_IS_PARAM_SPEC_UINT (pspec) || G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) { GtkAdjustment *adj; gdouble value; gdouble lower; gdouble upper; gdouble step = 1.0; gdouble page = 10.0; gint digits = (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0; if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec)) { GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; } else if (GEGL_IS_PARAM_SPEC_INT (pspec)) { GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; } else { _gimp_prop_widgets_get_numeric_values (config, pspec, &value, &lower, &upper, G_STRFUNC); } if ((upper - lower < 10.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.1; page = 1.0; digits = 3; } widget = gimp_prop_spin_scale_new (config, pspec->name, g_param_spec_get_nick (pspec), step, page, digits); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); if (g_str_has_suffix (pspec->name, "x") || g_str_has_suffix (pspec->name, "width")) { last_pspec = pspec; last_x_adj = adj; last_x_row = row; } else if ((g_str_has_suffix (pspec->name, "y") || g_str_has_suffix (pspec->name, "height")) && last_pspec != NULL && last_x_adj != NULL && last_x_row == row - 1) { GtkWidget *chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT); gtk_table_attach (GTK_TABLE (table), chain, 3, 4, last_x_row, row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (chain); if (gtk_adjustment_get_value (last_x_adj) == gtk_adjustment_get_value (adj)) { GBinding *binding; gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), TRUE); binding = g_object_bind_property (last_x_adj, "value", adj, "value", G_BINDING_BIDIRECTIONAL); g_object_set_data (G_OBJECT (chain), "binding", binding); } g_signal_connect (chain, "toggled", G_CALLBACK (gimp_prop_table_chain_toggled), last_x_adj); g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj); if (create_picker_func) { GtkWidget *button; gchar *pspec_name; pspec_name = g_strconcat (last_pspec->name, ":", pspec->name, NULL); button = create_picker_func (picker_creator, pspec_name, GIMP_STOCK_CURSOR, _("Pick coordinates from the image")); gtk_table_attach (GTK_TABLE (table), button, 4, 5, last_x_row, row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (button); g_object_weak_ref (G_OBJECT (button), (GWeakNotify) g_free, pspec_name); } } } else if (GIMP_IS_PARAM_SPEC_RGB (pspec)) { GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); button = gimp_prop_color_button_new (config, pspec->name, g_param_spec_get_nick (pspec), 128, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context); gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0); gtk_widget_show (button); if (create_picker_func) { button = create_picker_func (picker_creator, pspec->name, GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from the image")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); } label = g_param_spec_get_nick (pspec); } else { g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name); } if (widget) { if (label) { gimp_table_attach_aligned (GTK_TABLE (table), 0, row, label, 0.0, 0.5, widget, 2, FALSE); } else { gtk_table_attach_defaults (GTK_TABLE (table), widget, 0, 3, row, row + 1); gtk_widget_show (widget); } row++; } } g_object_unref (size_group); g_free (param_specs); return table; }
GtkWidget * gimp_prop_widget_new_from_pspec (GObject *config, GParamSpec *pspec, GimpContext *context, GimpCreatePickerFunc create_picker_func, gpointer picker_creator, const gchar **label) { GtkWidget *widget = NULL; g_return_val_if_fail (G_IS_OBJECT (config), NULL); g_return_val_if_fail (pspec != NULL, NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (label != NULL, NULL); *label = NULL; if (GEGL_IS_PARAM_SPEC_SEED (pspec)) { GtkAdjustment *adj; GtkWidget *spin; GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); spin = gimp_prop_spin_button_new (config, pspec->name, 1.0, 10.0, 0); gtk_box_pack_start (GTK_BOX (widget), spin, TRUE, TRUE, 0); gtk_widget_show (spin); button = gtk_button_new_with_label (_("New Seed")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin)); g_signal_connect (button, "clicked", G_CALLBACK (gimp_prop_widget_new_seed_clicked), adj); *label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_INT (pspec) || G_IS_PARAM_SPEC_UINT (pspec) || G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) { gdouble lower; gdouble upper; gdouble step; gdouble page; gint digits; if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec)) { GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; step = gspec->ui_step_small; page = gspec->ui_step_big; digits = gspec->ui_digits; } else if (GEGL_IS_PARAM_SPEC_INT (pspec)) { GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; step = gspec->ui_step_small; page = gspec->ui_step_big; digits = 0; } else { gdouble value; _gimp_prop_widgets_get_numeric_values (config, pspec, &value, &lower, &upper, G_STRFUNC); if ((upper - lower <= 1.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.01; page = 0.1; digits = 4; } else if ((upper - lower <= 10.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.1; page = 1.0; digits = 3; } else { step = 1.0; page = 10.0; digits = (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0; } } widget = gimp_prop_spin_scale_new (config, pspec->name, NULL, step, page, digits); if (HAS_KEY (pspec, "unit", "degree") && (upper - lower) == 360.0) { GtkWidget *hbox; GtkWidget *dial; gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); dial = gimp_prop_angle_dial_new (config, pspec->name); gtk_box_pack_start (GTK_BOX (hbox), dial, FALSE, FALSE, 0); gtk_widget_show (dial); widget = hbox; } else if (HAS_KEY (pspec, "unit", "kelvin")) { GtkWidget *hbox; GtkWidget *button; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); button = gimp_prop_kelvin_presets_new (config, pspec->name); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); widget = hbox; } } else if (G_IS_PARAM_SPEC_STRING (pspec)) { static GQuark multiline_quark = 0; if (! multiline_quark) multiline_quark = g_quark_from_static_string ("multiline"); if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec)) { widget = gimp_prop_file_chooser_button_new (config, pspec->name, g_param_spec_get_nick (pspec), GTK_FILE_CHOOSER_ACTION_OPEN); } else if (g_param_spec_get_qdata (pspec, multiline_quark)) { GtkTextBuffer *buffer; GtkWidget *view; buffer = gimp_prop_text_buffer_new (config, pspec->name, -1); view = gtk_text_view_new_with_buffer (buffer); g_object_unref (buffer); widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (widget), view); gtk_widget_show (view); } else { widget = gimp_prop_entry_new (config, pspec->name, -1); } *label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { widget = gimp_prop_check_button_new (config, pspec->name, g_param_spec_get_nick (pspec)); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget), g_param_spec_get_nick (pspec)); } else if (GIMP_IS_PARAM_SPEC_RGB (pspec)) { GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); button = gimp_prop_color_button_new (config, pspec->name, g_param_spec_get_nick (pspec), 128, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context); gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0); gtk_widget_show (button); if (create_picker_func) { button = create_picker_func (picker_creator, pspec->name, GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from the image")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); } *label = g_param_spec_get_nick (pspec); } else { g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name); } return widget; }
static void gimp_grid_editor_constructed (GObject *object) { GimpGridEditor *editor = GIMP_GRID_EDITOR (object); GtkWidget *frame; GtkWidget *hbox; GtkWidget *table; GtkWidget *style; GtkWidget *color_button; GtkWidget *sizeentry; if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (editor->grid != NULL); frame = gimp_frame_new (_("Appearance")); gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (3, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); style = gimp_prop_enum_combo_box_new (G_OBJECT (editor->grid), "style", GIMP_GRID_DOTS, GIMP_GRID_SOLID); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Line _style:"), 0.0, 0.5, style, 1, FALSE); color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "fgcolor", _("Change grid foreground color"), GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_HEIGHT, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), editor->context); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Foreground color:"), 0.0, 0.5, color_button, 1, TRUE); color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "bgcolor", _("Change grid background color"), GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_HEIGHT, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), editor->context); gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, _("_Background color:"), 0.0, 0.5, color_button, 1, TRUE); gtk_widget_show (table); frame = gimp_frame_new (_("Spacing")); gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (frame), hbox); sizeentry = gimp_prop_coordinates_new (G_OBJECT (editor->grid), "xspacing", "yspacing", "spacing-unit", "%a", GIMP_SIZE_ENTRY_UPDATE_SIZE, editor->xresolution, editor->yresolution, TRUE); gtk_table_set_col_spacings (GTK_TABLE (sizeentry), 2); gtk_table_set_row_spacings (GTK_TABLE (sizeentry), 2); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Width"), 0, 1, 0.0); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Height"), 0, 2, 0.0); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Pixels"), 1, 4, 0.0); gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0); gtk_widget_show (sizeentry); gtk_widget_show (hbox); frame = gimp_frame_new (_("Offset")); gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (frame), hbox); sizeentry = gimp_prop_coordinates_new (G_OBJECT (editor->grid), "xoffset", "yoffset", "offset-unit", "%a", GIMP_SIZE_ENTRY_UPDATE_SIZE, editor->xresolution, editor->yresolution, TRUE); gtk_table_set_col_spacings (GTK_TABLE (sizeentry), 2); gtk_table_set_row_spacings (GTK_TABLE (sizeentry), 2); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Width"), 0, 1, 0.0); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Height"), 0, 2, 0.0); gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), _("Pixels"), 1, 4, 0.0); gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0); gtk_widget_show (sizeentry); gtk_widget_show (hbox); }
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options); GtkWidget *main_vbox = gimp_tool_options_gui (tool_options); GimpAsyncSet *async_set; GtkWidget *options_vbox; GtkWidget *grid; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *entry; GtkWidget *box; GtkWidget *spinbutton; GtkWidget *combo; GtkSizeGroup *size_group; gint row = 0; async_set = gimp_data_factory_get_async_set (tool_options->tool_info->gimp->font_factory); box = gimp_busy_box_new (_("Loading fonts (this may take a while...)")); gtk_container_set_border_width (GTK_CONTAINER (box), 8); gtk_box_pack_start (GTK_BOX (main_vbox), box, FALSE, FALSE, 0); g_object_bind_property (async_set, "empty", box, "visible", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, gtk_box_get_spacing (GTK_BOX (main_vbox))); gtk_box_pack_start (GTK_BOX (main_vbox), options_vbox, FALSE, FALSE, 0); gtk_widget_show (options_vbox); g_object_bind_property (async_set, "empty", options_vbox, "sensitive", G_BINDING_SYNC_CREATE); hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), _("Font"), 2, "font-view-type", "font-view-size"); gtk_box_pack_start (GTK_BOX (options_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 2); gtk_grid_set_row_spacing (GTK_GRID (grid), 2); gtk_box_pack_start (GTK_BOX (options_vbox), grid, FALSE, FALSE, 0); gtk_widget_show (grid); entry = gimp_prop_size_entry_new (config, "font-size", FALSE, "font-size-unit", "%p", GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Size:"), 0.0, 0.5, entry, 2); options->size_entry = entry; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (options_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); button = gimp_prop_check_button_new (config, "use-editor", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (config, "antialias", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 2); gtk_grid_set_row_spacing (GTK_GRID (grid), 2); gtk_box_pack_start (GTK_BOX (options_vbox), grid, FALSE, FALSE, 0); gtk_widget_show (grid); row = 0; size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); button = gimp_prop_enum_combo_box_new (config, "hint-style", -1, -1); gtk_widget_set_halign (button, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Hinting:"), 0.0, 0.5, button, 1); gtk_size_group_add_widget (size_group, button); button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), 40, 24, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (options)); gtk_widget_set_halign (button, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Color:"), 0.0, 0.5, button, 1); gtk_size_group_add_widget (size_group, button); box = gimp_prop_enum_icon_box_new (config, "justify", "format-justify", 0, 0); gtk_widget_set_halign (box, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Justify:"), 0.0, 0.5, box, 2); gtk_size_group_add_widget (size_group, box); g_object_unref (size_group); spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_INDENT_MORE, spinbutton, 1); spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_TEXT_SPACING_LINE, spinbutton, 1); spinbutton = gimp_prop_spin_button_new (config, "letter-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gtk_widget_set_halign (spinbutton, GTK_ALIGN_START); gimp_grid_attach_icon (GTK_GRID (grid), row++, GIMP_ICON_FORMAT_TEXT_SPACING_LETTER, spinbutton, 1); combo = gimp_prop_enum_combo_box_new (config, "box-mode", 0, 0); gtk_widget_set_halign (combo, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Box:"), 0.0, 0.5, combo, 1); /* Only add the language entry if the iso-codes package is available. */ #ifdef HAVE_ISO_CODES { GtkWidget *label; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (options_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Language:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); entry = gimp_prop_language_entry_new (config, "language"); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); } #endif return main_vbox; }
static void gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) { GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool); GtkWidget *main_vbox; GtkWidget *frame; GtkWidget *vbox; GtkWidget *scale; GtkWidget *hbox; GtkWidget *button; main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); frame = gimp_frame_new (_("Select Color")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); /* Create the hue scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue", _("_Hue"), 1.0 / 230.0, 15.0 / 360.0, 0); gimp_prop_widget_set_factor (scale, 360.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the saturation scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation", _("_Saturation"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the lightness scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness", _("_Lightness"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the color button */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); button = gimp_prop_color_button_new (image_map_tool->config, "color", _("Colorize Color"), 128, 24, GIMP_COLOR_AREA_FLAT); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (col_tool))); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); button = gimp_image_map_tool_add_color_picker (image_map_tool, "colorize", GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from image")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); }
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options); GtkWidget *main_vbox = gimp_tool_options_gui (tool_options); GtkWidget *table; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *entry; GtkWidget *box; GtkWidget *spinbutton; GtkWidget *combo; GtkSizeGroup *size_group; gint row = 0; hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), _("Font"), 2, "font-view-type", "font-view-size"); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); table = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); entry = gimp_prop_size_entry_new (config, "font-size", FALSE, "font-size-unit", "%p", GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Size:"), 0.0, 0.5, entry, 2, FALSE); options->size_entry = entry; vbox = gtk_vbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); button = gimp_prop_check_button_new (config, "use-editor", _("Use editor")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (config, "antialias", _("Antialiasing")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); table = gtk_table_new (6, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); row = 0; size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); button = gimp_prop_enum_combo_box_new (config, "hint-style", -1, -1); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Hinting:"), 0.0, 0.5, button, 1, TRUE); gtk_size_group_add_widget (size_group, button); button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), 40, 24, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (options)); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Color:"), 0.0, 0.5, button, 1, TRUE); gtk_size_group_add_widget (size_group, button); box = gimp_prop_enum_stock_box_new (config, "justify", "gtk-justify", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Justify:"), 0.0, 0.5, box, 2, TRUE); gtk_size_group_add_widget (size_group, box); g_object_unref (size_group); spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GTK_STOCK_INDENT, spinbutton, 1, TRUE); spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GIMP_STOCK_LINE_SPACING, spinbutton, 1, TRUE); spinbutton = gimp_prop_spin_button_new (config, "letter-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GIMP_STOCK_LETTER_SPACING, spinbutton, 1, TRUE); combo = gimp_prop_enum_combo_box_new (config, "box-mode", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Box:"), 0.0, 0.5, combo, 1, TRUE); /* Only add the language entry if the iso-codes package is available. */ #ifdef HAVE_ISO_CODES { GtkWidget *label; vbox = gtk_vbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Language:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); entry = gimp_prop_language_entry_new (config, "language"); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); } #endif return main_vbox; }