static gboolean gimp_message_box_update (gpointer data) { GimpMessageBox *box = data; gchar *message; box->idle_id = 0; message = g_strdup_printf (ngettext ("Message repeated once.", "Message repeated %d times.", box->repeat), box->repeat); if (box->label[2]) { gtk_label_set_text (GTK_LABEL (box->label[2]), message); } else { GtkWidget *label = box->label[2] = gtk_label_new (message); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_OBLIQUE, -1); gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_widget_show (label); } g_free (message); return G_SOURCE_REMOVE; }
static GtkWidget * gimp_image_prop_view_add_label (GtkTable *table, gint row, const gchar *text) { GtkWidget *label; GtkWidget *desc; desc = g_object_new (GTK_TYPE_LABEL, "label", text, "xalign", 1.0, "yalign", 0.5, NULL); gimp_label_set_attributes (GTK_LABEL (desc), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_table_attach (table, desc, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (desc); label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0, "yalign", 0.5, "selectable", TRUE, NULL); gtk_table_attach (table, label, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); return label; }
static void cdisplay_lcms_attach_labelled (GtkTable *table, gint row, const gchar *text, GtkWidget *widget) { GtkWidget *label; label = g_object_new (GTK_TYPE_LABEL, "label", text, "xalign", 1.0, "yalign", 0.5, NULL); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_table_attach (table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); if (GTK_IS_LABEL (widget)) gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); gtk_table_attach (table, widget, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (widget); }
gint gimp_message_box_repeat (GimpMessageBox *box) { gchar *message; g_return_val_if_fail (GIMP_IS_MESSAGE_BOX (box), 0); box->repeat++; if (box->repeat > 1) message = g_strdup_printf (_("Message repeated %d times."), box->repeat); else message = g_strdup (_("Message repeated once.")); if (box->label[2]) { gtk_label_set_text (GTK_LABEL (box->label[2]), message); } else { GtkWidget *label = box->label[2] = gtk_label_new (message); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_OBLIQUE, -1); gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_widget_show (label); } g_free (message); return box->repeat; }
static void gimp_viewable_dialog_init (GimpViewableDialog *dialog) { GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); GtkWidget *frame; GtkWidget *hbox; GtkWidget *vbox; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); gtk_box_pack_start (GTK_BOX (content_area), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_widget_show (hbox); dialog->icon = gtk_image_new (); gtk_misc_set_alignment (GTK_MISC (dialog->icon), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), dialog->icon, FALSE, FALSE, 0); gtk_widget_show (dialog->icon); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); dialog->desc_label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (dialog->desc_label), 0.0, 0.5); gimp_label_set_attributes (GTK_LABEL (dialog->desc_label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (vbox), dialog->desc_label, FALSE, FALSE, 0); gtk_widget_show (dialog->desc_label); dialog->viewable_label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0, "yalign", 0.5, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gimp_label_set_attributes (GTK_LABEL (dialog->viewable_label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); gtk_box_pack_start (GTK_BOX (vbox), dialog->viewable_label, FALSE, FALSE, 0); gtk_widget_show (dialog->viewable_label); }
static void about_dialog_add_unstable_message (GtkWidget *vbox) { GtkWidget *label; label = gtk_label_new (_("This is an unstable development release.")); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (vbox), label, 2); gtk_widget_show (label); }
static GtkWidget * lcms_icc_profile_src_label_new (gint32 image, cmsHPROFILE profile) { GtkWidget *vbox; GtkWidget *label; gchar *name; gchar *desc; gchar *text; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); name = gimp_image_get_name (image); text = g_strdup_printf (_("The image '%s' has an embedded color profile:"), name); g_free (name); label = g_object_new (GTK_TYPE_LABEL, "label", text, "wrap", TRUE, "justify", GTK_JUSTIFY_LEFT, "xalign", 0.0, "yalign", 0.0, NULL); g_free (text); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); desc = lcms_icc_profile_get_desc (profile); label = g_object_new (GTK_TYPE_LABEL, "label", desc, "wrap", TRUE, "justify", GTK_JUSTIFY_LEFT, "xalign", 0.0, "yalign", 0.0, "xpad", 24, NULL); g_free (desc); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); return vbox; }
static gboolean gimp_help_menu_item_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) { GtkWidget *vbox; GtkWidget *label; gchar *text; gboolean use_markup = TRUE; text = gtk_widget_get_tooltip_markup (widget); if (! text) { text = gtk_widget_get_tooltip_text (widget); use_markup = FALSE; } if (! text) return FALSE; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); label = gtk_label_new (text); gtk_label_set_use_markup (GTK_LABEL (label), use_markup); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); gtk_widget_show (label); g_free (text); label = gtk_label_new (_("Press F1 for more help")); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); gtk_label_set_xalign (GTK_LABEL (label), 1.0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_tooltip_set_custom (tooltip, vbox); return TRUE; }
static void gimp_message_box_init (GimpMessageBox *box) { gint i; gtk_orientable_set_orientation (GTK_ORIENTABLE (box), GTK_ORIENTATION_VERTICAL); gtk_box_set_spacing (GTK_BOX (box), 12); gtk_container_set_border_width (GTK_CONTAINER (box), 12); /* Unset the focus chain to keep the labels from being in the focus * chain. Users of GimpMessageBox that add focusable widgets should * either unset the focus chain or (better) explicitly set one. */ gtk_container_set_focus_chain (GTK_CONTAINER (box), NULL); for (i = 0; i < 2; i++) { GtkWidget *label = g_object_new (GTK_TYPE_LABEL, "wrap", TRUE, "wrap-mode", PANGO_WRAP_WORD_CHAR, "max-width-chars", 80, "selectable", TRUE, "xalign", 0.0, "yalign", 0.5, NULL); if (i == 0) gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); box->label[i] = label; } box->repeat = 0; box->label[2] = NULL; box->idle_id = 0; }
static void shoot_dialog_add_hint (GtkNotebook *notebook, ShootType type, const gchar *hint) { GtkWidget *label; label = g_object_new (GTK_TYPE_LABEL, "label", hint, "wrap", TRUE, "justify", GTK_JUSTIFY_LEFT, "xalign", 0.0, "yalign", 0.0, NULL); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_notebook_insert_page (notebook, label, NULL, type); gtk_widget_show (label); }
static void gimp_editor_init (GimpEditor *editor) { gtk_orientable_set_orientation (GTK_ORIENTABLE (editor), GTK_ORIENTATION_VERTICAL); editor->menu_factory = NULL; editor->menu_identifier = NULL; editor->ui_manager = NULL; editor->ui_path = NULL; editor->popup_data = editor; editor->button_box = NULL; editor->show_button_bar = TRUE; editor->name_label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0, "yalign", 0.5, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gimp_label_set_attributes (GTK_LABEL (editor->name_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (editor), editor->name_label, FALSE, FALSE, 0); }
GtkWidget * gimp_proc_view_new (const gchar *name, const gchar *menu_path, const gchar *blurb, const gchar *help, const gchar *author, const gchar *copyright, const gchar *date, GimpPDBProcType type, gint n_params, gint n_return_vals, GimpParamDef *params, GimpParamDef *return_vals) { GtkWidget *main_vbox; GtkWidget *frame; GtkWidget *vbox; GtkWidget *table; GtkWidget *label; GtkSizeGroup *name_group; GtkSizeGroup *type_group; GtkSizeGroup *desc_group; const gchar *type_str; gint row; if (blurb && strlen (blurb) < 2) blurb = NULL; if (help && strlen (help) < 2) help = NULL; if (author && strlen (author) < 2) author = NULL; if (date && strlen (date) < 2) date = NULL; if (copyright && strlen (copyright) < 2) copyright = NULL; if (blurb && help && ! strcmp (blurb, help)) help = NULL; main_vbox = gtk_vbox_new (FALSE, 12); /* show the name */ frame = gimp_frame_new (name); label = gtk_frame_get_label_widget (GTK_FRAME (frame)); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_vbox_new (FALSE, 8); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); if (! gimp_enum_get_value (GIMP_TYPE_PDB_PROC_TYPE, type, NULL, NULL, &type_str, NULL)) type_str = "UNKNOWN"; label = gtk_label_new (type_str); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); if (menu_path) { label = gtk_label_new_with_mnemonic (menu_path); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); } if (blurb) { label = gtk_label_new (blurb); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); } name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); type_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); desc_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /* in parameters */ if (n_params) { frame = gimp_frame_new (_("Parameters")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gimp_proc_view_create_params (params, n_params, name_group, type_group, desc_group); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); } /* out parameters */ if (n_return_vals) { frame = gimp_frame_new (_("Return Values")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gimp_proc_view_create_params (return_vals, n_return_vals, name_group, type_group, desc_group); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); } if (! help && ! author && ! date && ! copyright) return main_vbox; frame = gimp_frame_new (_("Additional Information")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_vbox_new (FALSE, 8); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); /* show the help */ if (help) { label = gtk_label_new (help); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); } /* show the author & the copyright */ if (! author && ! date && ! copyright) return main_vbox; table = gtk_table_new ((author != 0) + (date != 0) + (copyright != 0), 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); row = 0; if (author) { label = gtk_label_new (author); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Author:"), 0.0, 0.0, label, 3, FALSE); } if (date) { label = gtk_label_new (date); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Date:"), 0.0, 0.0, label, 3, FALSE); } if (copyright) { label = gtk_label_new (copyright); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Copyright:"), 0.0, 0.0, label, 3, FALSE); } return main_vbox; }
GtkWidget * gimp_prop_gui_new (GObject *config, GType owner_type, GimpContext *context, GimpCreatePickerFunc create_picker_func, gpointer picker_creator) { GtkWidget *gui = NULL; GParamSpec **param_specs; guint n_param_specs; gint i, j; g_return_val_if_fail (G_IS_OBJECT (config), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config), &n_param_specs); for (i = 0, j = 0; i < n_param_specs; i++) { GParamSpec *pspec = param_specs[i]; /* ignore properties of parent classes of owner_type */ if (! g_type_is_a (pspec->owner_type, owner_type)) continue; if (HAS_KEY (pspec, "role", "output-extent")) continue; param_specs[j] = param_specs[i]; j++; } n_param_specs = j; if (n_param_specs > 0) { const gchar *config_type_name = G_OBJECT_TYPE_NAME (config); for (i = 0; i < G_N_ELEMENTS (gui_new_funcs); i++) { if (! gui_new_funcs[i].config_type || ! strcmp (gui_new_funcs[i].config_type, config_type_name)) { g_printerr ("GUI new func match: %s\n", gui_new_funcs[i].config_type ? gui_new_funcs[i].config_type : "generic fallback"); gui = gui_new_funcs[i].gui_new_func (config, param_specs, n_param_specs, context, create_picker_func, picker_creator); break; } } } else { gui = gtk_label_new (_("This operation has no editable properties")); gimp_label_set_attributes (GTK_LABEL (gui), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_misc_set_padding (GTK_MISC (gui), 0, 4); } g_free (param_specs); return gui; }
static gboolean jpeg_exif_rotate_query_dialog (gint32 image_ID) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *label; GtkWidget *toggle; GdkPixbuf *pixbuf; gint response; dialog = gimp_dialog_new (_("Rotate Image?"), PLUG_IN_BINARY, NULL, 0, NULL, NULL, _("_Keep Orientation"), GTK_RESPONSE_CANCEL, GIMP_STOCK_TOOL_ROTATE, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gimp_window_set_transient (GTK_WINDOW (dialog)); hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); pixbuf = gimp_image_get_thumbnail (image_ID, THUMBNAIL_SIZE, THUMBNAIL_SIZE, GIMP_PIXBUF_SMALL_CHECKS); if (pixbuf) { GtkWidget *image; gchar *name; image = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0); gtk_widget_show (image); name = gimp_image_get_name (image_ID); label = gtk_label_new (name); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (name); } vbox = gtk_vbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); label = g_object_new (GTK_TYPE_LABEL, "label", _("According to the EXIF data, " "this image is rotated."), "wrap", TRUE, "justify", GTK_JUSTIFY_LEFT, "xalign", 0.0, "yalign", 0.5, NULL); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); label = g_object_new (GTK_TYPE_LABEL, "label", _("Would you like GIMP to rotate it " "into the standard orientation?"), "wrap", TRUE, "justify", GTK_JUSTIFY_LEFT, "xalign", 0.0, "yalign", 0.5, NULL); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); toggle = gtk_check_button_new_with_mnemonic (_("_Don't ask me again")); gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), FALSE); gtk_widget_show (toggle); response = gimp_dialog_run (GIMP_DIALOG (dialog)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle))) { GimpParasite *parasite; const gchar *str = (response == GTK_RESPONSE_OK) ? "yes" : "no"; parasite = gimp_parasite_new (JPEG_EXIF_ROTATE_PARASITE, GIMP_PARASITE_PERSISTENT, strlen (str), str); gimp_parasite_attach (parasite); gimp_parasite_free (parasite); } gtk_widget_destroy (dialog); return (response == GTK_RESPONSE_OK); }
gboolean maze_dialog (void) { GtkWidget *dialog; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *table; GtkWidget *table2; GtkWidget *tilecheck; GtkWidget *width_entry; GtkWidget *height_entry; GtkWidget *hbox; GtkWidget *frame; GtkSizeGroup *group; gboolean run; gint trow = 0; gimp_ui_init (PLUG_IN_BINARY, FALSE); dialog = gimp_dialog_new (_("Maze"), PLUG_IN_ROLE, NULL, 0, gimp_standard_help_func, PLUG_IN_PROC, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gimp_window_set_transient (GTK_WINDOW (dialog)); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, FALSE, FALSE, 0); /* The maze size frame */ frame = gimp_frame_new (_("Maze Size")); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); table = gtk_table_new (6, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /* entscale == Entry and Scale pair function found in pixelize.c */ width_entry = entscale_int_new (table, 0, trow, _("Width (pixels):"), &mvals.width, 1, sel_w/4, TRUE, (EntscaleIntCallback) height_width_callback, &width_entry); trow++; /* Number of Divisions entry */ hbox = divbox_new (&sel_w, width_entry, &width_entry); g_snprintf (buffer, BUFSIZE, "%d", (sel_w / mvals.width)); gtk_entry_set_text (GTK_ENTRY (width_entry), buffer); gimp_table_attach_aligned (GTK_TABLE (table), 0, trow, _("Pieces:"), 0.0, 0.5, hbox, 1, TRUE); gtk_table_set_row_spacing (GTK_TABLE (table), trow, 12); trow++; height_entry = entscale_int_new (table, 0, trow, _("Height (pixels):"), &mvals.height, 1, sel_h/4, TRUE, (EntscaleIntCallback) height_width_callback, &height_entry); trow++; hbox = divbox_new (&sel_h, height_entry, &height_entry); g_snprintf (buffer, BUFSIZE, "%d", (sel_h / mvals.height)); gtk_entry_set_text (GTK_ENTRY (height_entry), buffer); gimp_table_attach_aligned (GTK_TABLE (table), 0, trow, _("Pieces:"), 0.0, 0.5, hbox, 1, TRUE); gtk_table_set_row_spacing (GTK_TABLE (table), trow, 12); trow++; g_object_unref (group); /* The maze algorithm frame */ frame = gimp_frame_new (_("Algorithm")); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); /* Seed input box */ table2 = gtk_table_new (3, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table2), 6); gtk_table_set_row_spacings (GTK_TABLE (table2), 6); gtk_box_pack_start (GTK_BOX (vbox2), table2, FALSE, FALSE, 0); gtk_widget_show (table2); hbox = gimp_random_seed_new (&mvals.seed, &mvals.random_seed); gimp_table_attach_aligned (GTK_TABLE (table2), 0, 0, _("Seed:"), 0.0, 0.5, hbox, 1, TRUE); /* Algorithm Choice */ frame = gimp_int_radio_group_new (FALSE, NULL, G_CALLBACK (gimp_radio_button_update), &mvals.algorithm, mvals.algorithm, _("Depth first"), DEPTH_FIRST, NULL, _("Prim's algorithm"), PRIMS_ALGORITHM, NULL, NULL); gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); /* Tileable checkbox */ tilecheck = gtk_check_button_new_with_label (_("Tileable")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tilecheck), mvals.tile); g_signal_connect (tilecheck, "clicked", G_CALLBACK (gimp_toggle_button_update), &mvals.tile); gtk_box_pack_start (GTK_BOX (vbox2), tilecheck, FALSE, FALSE, 0); msg_label = gtk_label_new (NULL); gimp_label_set_attributes (GTK_LABEL (msg_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), msg_label, FALSE, FALSE, 0); gtk_widget_show_all (dialog); run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); gtk_widget_destroy (dialog); return run; }
gboolean save_dialog (void) { JpegSaveGui pg; GtkWidget *dialog; GtkWidget *vbox; GtkObject *entry; GtkWidget *table; GtkWidget *table2; GtkWidget *tabledefaults; GtkWidget *expander; GtkWidget *frame; GtkWidget *toggle; GtkWidget *spinbutton; GtkWidget *label; GtkWidget *combo; GtkWidget *text_view; GtkTextBuffer *text_buffer; GtkWidget *scrolled_window; GtkWidget *button; gchar *text; gint row; dialog = gimp_export_dialog_new (_("JPEG"), PLUG_IN_BINARY, SAVE_PROC); g_signal_connect (dialog, "response", G_CALLBACK (save_dialog_response), &pg); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); table = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); pg.quality = entry = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Quality:"), SCALE_WIDTH, 0, jsvals.quality, 0.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, _("JPEG quality parameter"), "file-jpeg-save-quality"); g_signal_connect (entry, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &jsvals.quality); g_signal_connect (entry, "value-changed", G_CALLBACK (make_preview), NULL); preview_size = gtk_label_new (_("File size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (preview_size), PANGO_ELLIPSIZE_END); gimp_label_set_attributes (GTK_LABEL (preview_size), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); gimp_help_set_help_data (preview_size, _("Enable preview to obtain the file size."), NULL); pg.preview = toggle = gtk_check_button_new_with_mnemonic (_("Sho_w preview in image window")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.preview); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.preview); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); text = g_strdup_printf ("<b>%s</b>", _("_Advanced Options")); expander = gtk_expander_new_with_mnemonic (text); gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE); g_free (text); gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0); gtk_widget_show (expander); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_add (GTK_CONTAINER (expander), vbox); gtk_widget_show (vbox); frame = gimp_frame_new ("<expander>"); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (4, 8, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacing (GTK_TABLE (table), 1, 12); gtk_container_add (GTK_CONTAINER (frame), table); table2 = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table2), 6); gtk_table_attach (GTK_TABLE (table), table2, 2, 6, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (table2); pg.smoothing = entry = gimp_scale_entry_new (GTK_TABLE (table2), 0, 0, _("S_moothing:"), 100, 0, jsvals.smoothing, 0.0, 1.0, 0.01, 0.1, 2, TRUE, 0.0, 0.0, NULL, "file-jpeg-save-smoothing"); g_signal_connect (entry, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &jsvals.smoothing); g_signal_connect (entry, "value-changed", G_CALLBACK (make_preview), NULL); restart_markers_label = gtk_label_new (_("Interval (MCU rows):")); gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), restart_markers_label, 4, 5, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (restart_markers_label); pg.scale_data = (GtkAdjustment *) gtk_adjustment_new (((jsvals.restart == 0) ? DEFAULT_RESTART_MCU_ROWS : jsvals.restart), 1.0, 64.0, 1.0, 1.0, 0); pg.restart = restart_markers_scale = spinbutton = gtk_spin_button_new (pg.scale_data, 1.0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_table_attach (GTK_TABLE (table), spinbutton, 5, 6, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (spinbutton); pg.use_restart_markers = toggle = gtk_check_button_new_with_mnemonic (_("Use _restart markers")); gtk_table_attach (GTK_TABLE (table), toggle, 2, 4, 1, 2, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.restart); gtk_widget_set_sensitive (restart_markers_label, jsvals.restart); gtk_widget_set_sensitive (restart_markers_scale, jsvals.restart); g_signal_connect (pg.scale_data, "value-changed", G_CALLBACK (save_restart_update), toggle); pg.handler_id_restart = g_signal_connect_swapped (toggle, "toggled", G_CALLBACK (save_restart_update), pg.scale_data); row = 0; /* Optimize */ pg.optimize = toggle = gtk_check_button_new_with_mnemonic (_("_Optimize")); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.optimize); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); if (arithc_supported) gtk_widget_set_sensitive (toggle, !jsvals.arithmetic_coding); row++; if (arithc_supported) { /* Arithmetic coding */ pg.arithmetic_coding = toggle = gtk_check_button_new_with_mnemonic (_("Use arithmetic _coding")); gtk_widget_set_tooltip_text (toggle, _("Older software may have trouble opening " "arithmetic-coded images")); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.arithmetic_coding); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_arithmetic_coding), pg.optimize); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.arithmetic_coding); row++; } /* Progressive */ pg.progressive = toggle = gtk_check_button_new_with_mnemonic (_("_Progressive")); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.progressive); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.progressive); row++; /* Save EXIF data */ pg.save_exif = toggle = gtk_check_button_new_with_mnemonic (_("Save _Exif data")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.save_exif); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.save_exif); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); gtk_widget_set_sensitive (toggle, TRUE); row++; /* Save thumbnail */ pg.save_thumbnail = toggle = gtk_check_button_new_with_mnemonic (_("Save _thumbnail")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.save_thumbnail); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.save_thumbnail); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); row++; /* XMP metadata */ pg.save_xmp = toggle = gtk_check_button_new_with_mnemonic (_("Save _XMP data")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.save_xmp); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.save_xmp); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); gtk_widget_set_sensitive (toggle, TRUE); row++; /* IPTC metadata */ pg.save_iptc = toggle = gtk_check_button_new_with_mnemonic (_("Save _IPTC data")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.save_iptc); gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.save_iptc); g_signal_connect (toggle, "toggled", G_CALLBACK (make_preview), NULL); gtk_widget_set_sensitive (toggle, TRUE); row++; /* custom quantization tables - now used also for original quality */ pg.use_orig_quality = toggle = gtk_check_button_new_with_mnemonic (_("_Use quality settings from original " "image")); gtk_table_attach (GTK_TABLE (table), toggle, 0, 4, row, row + 1, GTK_FILL, 0, 0, 0); gtk_widget_show (toggle); gimp_help_set_help_data (toggle, _("If the original image was loaded from a JPEG " "file using non-standard quality settings " "(quantization tables), enable this option to " "get almost the same quality and file size."), NULL); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &jsvals.use_orig_quality); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.use_orig_quality && (orig_quality > 0)); gtk_widget_set_sensitive (toggle, (orig_quality > 0)); /* changing quality disables custom quantization tables, and vice-versa */ g_signal_connect (pg.quality, "value-changed", G_CALLBACK (quality_changed), pg.use_orig_quality); g_signal_connect (pg.use_orig_quality, "toggled", G_CALLBACK (use_orig_qual_changed), pg.quality); /* Subsampling */ label = gtk_label_new_with_mnemonic (_("Su_bsampling:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); pg.subsmp = combo = gimp_int_combo_box_new (_("4:4:4 (best quality)"), JPEG_SUBSAMPLING_1x1_1x1_1x1, _("4:2:2 horizontal (chroma halved)"), JPEG_SUBSAMPLING_2x1_1x1_1x1, _("4:2:2 vertical (chroma halved)"), JPEG_SUBSAMPLING_1x2_1x1_1x1, _("4:2:0 (chroma quartered)"), JPEG_SUBSAMPLING_2x2_1x1_1x1, NULL); gtk_table_attach (GTK_TABLE (table), combo, 3, 6, 2, 3, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); if (gimp_drawable_is_rgb (drawable_ID_global)) { gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), jsvals.subsmp, G_CALLBACK (subsampling_changed), entry); g_signal_connect (pg.use_orig_quality, "toggled", G_CALLBACK (use_orig_qual_changed2), pg.subsmp); } else { gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), JPEG_SUBSAMPLING_1x1_1x1_1x1); gtk_widget_set_sensitive (combo, FALSE); } /* DCT method */ label = gtk_label_new_with_mnemonic (_("_DCT method:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); pg.dct = combo = gimp_int_combo_box_new (_("Fast Integer"), 1, _("Integer"), 0, _("Floating-Point"), 2, NULL); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), jsvals.dct); gtk_table_attach (GTK_TABLE (table), combo, 3, 6, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); g_signal_connect (combo, "changed", G_CALLBACK (gimp_int_combo_box_get_active), &jsvals.dct); g_signal_connect (combo, "changed", G_CALLBACK (make_preview), NULL); frame = gimp_frame_new (_("Comment")); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request (scrolled_window, 250, 50); gtk_container_add (GTK_CONTAINER (frame), scrolled_window); gtk_widget_show (scrolled_window); pg.text_buffer = text_buffer = gtk_text_buffer_new (NULL); if (image_comment) gtk_text_buffer_set_text (text_buffer, image_comment, -1); text_view = gtk_text_view_new_with_buffer (text_buffer); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD); gtk_container_add (GTK_CONTAINER (scrolled_window), text_view); gtk_widget_show (text_view); g_object_unref (text_buffer); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); tabledefaults = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (tabledefaults), 6); gtk_box_pack_start (GTK_BOX (vbox), tabledefaults, FALSE, FALSE, 0); gtk_widget_show (tabledefaults); button = gtk_button_new_with_mnemonic (_("_Load Defaults")); gtk_table_attach (GTK_TABLE (tabledefaults), button, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); gtk_widget_show (button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (load_gui_defaults), &pg); button = gtk_button_new_with_mnemonic (_("Sa_ve Defaults")); gtk_table_attach (GTK_TABLE (tabledefaults), button, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); gtk_widget_show (button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (save_defaults), &pg); gtk_widget_show (frame); gtk_widget_show (table); gtk_widget_show (dialog); make_preview (); pg.run = FALSE; gtk_main (); destroy_preview (); return pg.run; }
static GimpExportReturn export_dialog (GSList *actions, const gchar *format_name) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *image; GtkWidget *main_vbox; GtkWidget *label; GSList *list; gchar *text; GimpExportReturn retval; g_return_val_if_fail (actions != NULL, GIMP_EXPORT_CANCEL); g_return_val_if_fail (format_name != NULL, GIMP_EXPORT_CANCEL); dialog = gimp_dialog_new (_("Export File"), "gimp-export-image", NULL, 0, gimp_standard_help_func, "gimp-export-dialog", _("_Ignore"), GTK_RESPONSE_NO, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Export"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_NO, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gimp_window_set_transient (GTK_WINDOW (dialog)); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); gtk_widget_show (hbox); image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_widget_show (image); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0); gtk_widget_show (main_vbox); /* the headline */ text = g_strdup_printf (_("Your image should be exported before it " "can be saved as %s for the following reasons:"), format_name); label = gtk_label_new (text); g_free (text); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, -1); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); for (list = actions; list; list = g_slist_next (list)) { ExportAction *action = list->data; GtkWidget *frame; GtkWidget *vbox; text = g_strdup_printf (gettext (action->reason), format_name); frame = gimp_frame_new (text); g_free (text); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); if (action->possibilities[0] && action->possibilities[1]) { GtkWidget *button; GSList *radio_group = NULL; button = gtk_radio_button_new_with_label (radio_group, gettext (action->possibilities[0])); gtk_label_set_justify (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), GTK_JUSTIFY_LEFT); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); g_signal_connect (button, "toggled", G_CALLBACK (export_toggle_callback), &action->choice); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (action->choice == 0)); gtk_widget_show (button); button = gtk_radio_button_new_with_label (radio_group, gettext (action->possibilities[1])); gtk_label_set_justify (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), GTK_JUSTIFY_LEFT); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (action->choice == 1)); gtk_widget_show (button); } else if (action->possibilities[0]) { label = gtk_label_new (gettext (action->possibilities[0])); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); action->choice = 0; } gtk_widget_show (vbox); } /* the footline */ label = gtk_label_new (_("The export conversion won't modify your " "original image.")); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_widget_show (dialog); switch (gimp_dialog_run (GIMP_DIALOG (dialog))) { case GTK_RESPONSE_OK: retval = GIMP_EXPORT_EXPORT; break; case GTK_RESPONSE_NO: retval = GIMP_EXPORT_IGNORE; break; default: retval = GIMP_EXPORT_CANCEL; break; } gtk_widget_destroy (dialog); return retval; }
/** * resolution_calibrate_dialog: * @resolution_entry: a #GimpSizeEntry to connect the dialog to * @pixbuf: an optional #GdkPixbuf for the upper left corner * * Displays a dialog that allows the user to interactively determine * her monitor resolution. This dialog runs it's own GTK main loop and * is connected to a #GimpSizeEntry handling the resolution to be set. **/ void resolution_calibrate_dialog (GtkWidget *resolution_entry, GdkPixbuf *pixbuf) { GtkWidget *dialog; GtkWidget *table; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *ruler; GtkWidget *label; GdkScreen *screen; GdkRectangle rect; gint monitor; g_return_if_fail (GIMP_IS_SIZE_ENTRY (resolution_entry)); g_return_if_fail (GTK_WIDGET_REALIZED (resolution_entry)); g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); /* this dialog can only exist once */ if (calibrate_entry) return; dialog = gimp_dialog_new (_("Calibrate Monitor Resolution"), "gimp-resolution-calibration", gtk_widget_get_toplevel (resolution_entry), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); screen = gtk_widget_get_screen (dialog); monitor = gdk_screen_get_monitor_at_window (screen, resolution_entry->window); gdk_screen_get_monitor_geometry (screen, monitor, &rect); ruler_width = rect.width - 300 - (rect.width % 100); ruler_height = rect.height - 300 - (rect.height % 100); table = gtk_table_new (4, 4, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), 12); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table); gtk_widget_show (table); if (pixbuf) { GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf); gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 4, 4); gtk_widget_show (image); } ruler = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL); gtk_widget_set_size_request (ruler, ruler_width, 32); gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_width, ruler_width); gtk_table_attach (GTK_TABLE (table), ruler, 1, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0); gtk_widget_show (ruler); ruler = gimp_ruler_new (GTK_ORIENTATION_VERTICAL); gtk_widget_set_size_request (ruler, 32, ruler_height); gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_height, ruler_height); gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 3, GTK_SHRINK, GTK_SHRINK, 0, 0); gtk_widget_show (ruler); vbox = gtk_vbox_new (FALSE, 12); gtk_table_attach (GTK_TABLE (table), vbox, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0); gtk_widget_show (vbox); label = gtk_label_new (_("Measure the rulers and enter their lengths:")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); calibrate_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 0); calibrate_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1); calibrate_entry = gimp_coordinates_new (GIMP_UNIT_INCH, "%p", FALSE, FALSE, 10, GIMP_SIZE_ENTRY_UPDATE_SIZE, FALSE, FALSE, _("_Horizontal:"), ruler_width, calibrate_xres, 1, GIMP_MAX_IMAGE_SIZE, 0, 0, _("_Vertical:"), ruler_height, calibrate_yres, 1, GIMP_MAX_IMAGE_SIZE, 0, 0); gtk_widget_hide (GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (calibrate_entry))); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &calibrate_entry); gtk_box_pack_end (GTK_BOX (hbox), calibrate_entry, FALSE, FALSE, 0); gtk_widget_show (calibrate_entry); gtk_widget_show (dialog); switch (gimp_dialog_run (GIMP_DIALOG (dialog))) { case GTK_RESPONSE_OK: { GtkWidget *chain_button; gdouble x, y; x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (calibrate_entry), 0); y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (calibrate_entry), 1); calibrate_xres = (gdouble) ruler_width * calibrate_xres / x; calibrate_yres = (gdouble) ruler_height * calibrate_yres / y; chain_button = GIMP_COORDINATES_CHAINBUTTON (resolution_entry); if (ABS (x - y) > GIMP_MIN_RESOLUTION) gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), FALSE); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (resolution_entry), 0, calibrate_xres); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (resolution_entry), 1, calibrate_yres); } default: break; } gtk_widget_destroy (dialog); }
static void gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool) { GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool); GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (image_map_tool); GtkListStore *store; GtkCellRenderer *cell; GtkWidget *main_vbox; GtkWidget *hbox; GtkWidget *combo; GList *opclasses; GList *iter; GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->dialog (image_map_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); /* The operation combo box */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (main_vbox), hbox, 0); gtk_widget_show (hbox); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); opclasses = gimp_get_geglopclasses (); for (iter = opclasses; iter; iter = iter->next) { GeglOperationClass *opclass = GEGL_OPERATION_CLASS (iter->data); const gchar *stock_id; const gchar *label; if (g_str_has_prefix (opclass->name, "gegl:")) { label = opclass->name + strlen ("gegl:"); stock_id = GIMP_STOCK_GEGL; } else { label = opclass->name; stock_id = NULL; } gtk_list_store_insert_with_values (store, NULL, -1, COLUMN_NAME, opclass->name, COLUMN_LABEL, label, COLUMN_STOCK_ID, stock_id, -1); } g_list_free (opclasses); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (store); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell, "stock-id", COLUMN_STOCK_ID); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_LABEL); g_signal_connect (combo, "changed", G_CALLBACK (gimp_gegl_tool_operation_changed), tool); tool->operation_combo = combo; tool->description_label = gtk_label_new (""); gtk_label_set_line_wrap (GTK_LABEL (tool->description_label), TRUE); gtk_misc_set_alignment (GTK_MISC (tool->description_label), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (main_vbox), tool->description_label, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (main_vbox), tool->description_label, 1); /* The options vbox */ o_tool->options_table = gtk_label_new (_("Select an operation from the list above")); gimp_label_set_attributes (GTK_LABEL (o_tool->options_table), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_misc_set_padding (GTK_MISC (o_tool->options_table), 0, 4); gtk_container_add (GTK_CONTAINER (o_tool->options_box), o_tool->options_table); gtk_widget_show (o_tool->options_table); }
static void gimp_resolution_entry_field_init (GimpResolutionEntry *gre, GimpResolutionEntryField *gref, GimpResolutionEntryField *corresponding, guint changed_signal, gdouble initial_val, GimpUnit initial_unit, gboolean size, gint spinbutton_width) { gint digits; g_return_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre)); gref->gre = gre; gref->corresponding = corresponding; gref->changed_signal = gimp_resolution_entry_signals[changed_signal]; if (size) { gref->value = initial_val / gimp_unit_get_factor (initial_unit) * corresponding->value * gimp_unit_get_factor (gre->unit); gref->phy_size = initial_val / gimp_unit_get_factor (initial_unit); } else { gref->value = initial_val; } gref->min_value = GIMP_MIN_RESOLUTION; gref->max_value = GIMP_MAX_RESOLUTION; gref->adjustment = NULL; gref->stop_recursion = 0; gref->size = size; if (size) { gref->label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0, "yalign", 0.5, NULL); gimp_label_set_attributes (GTK_LABEL (gref->label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gimp_resolution_entry_format_label (gre, gref->label, gref->phy_size); } digits = size ? 0 : MIN (gimp_unit_get_digits (initial_unit), 5) + 1; gref->spinbutton = gimp_spin_button_new (&gref->adjustment, gref->value, gref->min_value, gref->max_value, 1.0, 10.0, 0.0, 1.0, digits); if (spinbutton_width > 0) { if (spinbutton_width < 17) gtk_entry_set_width_chars (GTK_ENTRY (gref->spinbutton), spinbutton_width); else gtk_widget_set_size_request (gref->spinbutton, spinbutton_width, -1); } }
void create_presetpage (GtkNotebook *notebook) { GtkWidget *vbox, *hbox, *box1, *box2, *thispage; GtkWidget *view; GtkWidget *tmpw; GtkWidget *label; GtkTreeSelection *selection; label = gtk_label_new_with_mnemonic (_("_Presets")); thispage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (thispage), 12); gtk_widget_show (thispage); box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (thispage), box1, FALSE, FALSE, 0); gtk_widget_show (box1); presetnameentry = tmpw = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (box1), tmpw, FALSE, FALSE, 0); gtk_widget_set_size_request (tmpw, 200, -1); gtk_widget_show (tmpw); presetsavebutton = tmpw = gtk_button_new_with_label ( _("Save Current...")); gtk_button_set_image (GTK_BUTTON (presetsavebutton), gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON)); gtk_box_pack_start (GTK_BOX (box1), tmpw, FALSE, FALSE, 0); gtk_widget_show (tmpw); g_signal_connect (tmpw, "clicked", G_CALLBACK (create_save_preset), NULL); gimp_help_set_help_data (tmpw, _("Save the current settings to the specified file"), NULL); box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (thispage), box1, TRUE, TRUE, 0); gtk_widget_show (box1); presetlist = view = create_presets_list (box1); store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view))); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); add_factory_defaults (); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (box1), 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); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (hbox), box2, FALSE, FALSE, 0); gtk_widget_show (box2); tmpw = gtk_button_new_from_stock (GTK_STOCK_APPLY); gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0); gtk_widget_show (tmpw); g_signal_connect (tmpw, "clicked", G_CALLBACK (apply_preset), selection); gimp_help_set_help_data (tmpw, _("Reads the selected Preset into memory"), NULL); tmpw = delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE); gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE,0); gtk_widget_show (tmpw); g_signal_connect (tmpw, "clicked", G_CALLBACK (delete_preset), selection); gimp_help_set_help_data (tmpw, _("Deletes the selected Preset"), NULL); tmpw = gtk_button_new_from_stock (GTK_STOCK_REFRESH); gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE,0); gtk_widget_show (tmpw); g_signal_connect (tmpw, "clicked", G_CALLBACK (preset_refresh_presets), NULL); gimp_help_set_help_data (tmpw, _("Reread the folder of Presets"), NULL); presetdesclabel = tmpw = gtk_label_new (NULL); gimp_label_set_attributes (GTK_LABEL (tmpw), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_label_set_line_wrap (GTK_LABEL (tmpw), TRUE); /* * Make sure the label's width is reasonable and it won't stretch * the dialog more than its width. * */ gtk_widget_set_size_request (tmpw, 240, -1); gtk_misc_set_alignment (GTK_MISC (tmpw), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), tmpw, TRUE, TRUE, 0); gtk_widget_show (tmpw); preset_read_dir_into_list (); gtk_notebook_append_page_menu (notebook, thispage, label, NULL); }
GtkWidget * gimp_thumb_box_new (GimpContext *context) { GimpThumbBox *box; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *ebox; GtkWidget *hbox; GtkWidget *button; GtkWidget *label; gchar *str; gint h, v; GtkRequisition info_requisition; GtkRequisition progress_requisition; g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); box = g_object_new (GIMP_TYPE_THUMB_BOX, NULL); box->context = context; ebox = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (box), ebox); gtk_widget_show (ebox); g_signal_connect (ebox, "button-press-event", G_CALLBACK (gimp_thumb_box_ebox_button_press), box); str = g_strdup_printf (_("Click to update preview\n" "%s%sClick to force update even " "if preview is up-to-date"), gimp_get_mod_string (GDK_CONTROL_MASK), gimp_get_mod_separator ()); gimp_help_set_help_data (ebox, str, NULL); g_free (str); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (ebox), vbox); gtk_widget_show (vbox); button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); label = gtk_label_new_with_mnemonic (_("Pr_eview")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_container_add (GTK_CONTAINER (button), label); gtk_widget_show (label); g_signal_connect (button, "button-press-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (button, "button-release-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (button, "enter-notify-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (button, "leave-notify-event", G_CALLBACK (gtk_true), NULL); vbox2 = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2); gtk_container_add (GTK_CONTAINER (vbox), vbox2); gtk_widget_show (vbox2); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); box->imagefile = gimp_imagefile_new (context->gimp, NULL); g_signal_connect (box->imagefile, "info-changed", G_CALLBACK (gimp_thumb_box_imagefile_info_changed), box); g_signal_connect (box->imagefile->thumbnail, "notify::thumb-state", G_CALLBACK (gimp_thumb_box_thumb_state_notify), box); gimp_view_renderer_get_frame_size (&h, &v); box->preview = gimp_view_new (context, GIMP_VIEWABLE (box->imagefile), /* add padding for the shadow frame */ context->gimp->config->thumbnail_size + MAX (h, v), 0, FALSE); gtk_box_pack_start (GTK_BOX (hbox), box->preview, TRUE, FALSE, 2); gtk_widget_show (box->preview); gtk_label_set_mnemonic_widget (GTK_LABEL (label), box->preview); g_signal_connect (box->preview, "clicked", G_CALLBACK (gimp_thumb_box_thumbnail_clicked), box); box->filename = gtk_label_new (_("No selection")); gtk_label_set_ellipsize (GTK_LABEL (box->filename), PANGO_ELLIPSIZE_MIDDLE); gtk_label_set_justify (GTK_LABEL (box->filename), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (box->filename), PANGO_ATTR_STYLE, PANGO_STYLE_OBLIQUE, -1); gtk_box_pack_start (GTK_BOX (vbox2), box->filename, FALSE, FALSE, 0); gtk_widget_show (box->filename); box->info = gtk_label_new (" \n \n \n "); gtk_misc_set_alignment (GTK_MISC (box->info), 0.5, 0.0); gtk_label_set_justify (GTK_LABEL (box->info), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (box->info), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); gtk_box_pack_start (GTK_BOX (vbox2), box->info, FALSE, FALSE, 0); gtk_widget_show (box->info); box->progress = gtk_progress_bar_new (); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (box->progress), "Fog"); gtk_box_pack_end (GTK_BOX (vbox2), box->progress, FALSE, FALSE, 0); gtk_widget_set_no_show_all (box->progress, TRUE); /* don't gtk_widget_show (box->progress); */ /* eek */ gtk_widget_size_request (box->info, &info_requisition); gtk_widget_size_request (box->progress, &progress_requisition); gtk_widget_set_size_request (box->info, progress_requisition.width, info_requisition.height); gtk_widget_set_size_request (box->filename, progress_requisition.width, -1); gtk_widget_set_size_request (box->progress, -1, progress_requisition.height); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (box->progress), ""); return GTK_WIDGET (box); }
static void gimp_tool_preset_editor_constructed (GObject *object) { GimpToolPresetEditor *editor = GIMP_TOOL_PRESET_EDITOR (object); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); GimpToolPreset *preset; GtkWidget *hbox; GtkWidget *label; GtkWidget *button; if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); preset = editor->tool_preset_model = g_object_new (GIMP_TYPE_TOOL_PRESET, "gimp", data_editor->context->gimp, NULL); g_signal_connect (preset, "notify", G_CALLBACK (gimp_tool_preset_editor_notify_model), editor); hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (data_editor), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); editor->tool_icon = gtk_image_new (); gtk_box_pack_start (GTK_BOX (hbox), editor->tool_icon, FALSE, FALSE, 0); gtk_widget_show (editor->tool_icon); editor->tool_label = gtk_label_new (""); gimp_label_set_attributes (GTK_LABEL (editor->tool_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (hbox), editor->tool_label, FALSE, FALSE, 0); gtk_widget_show (editor->tool_label); hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (data_editor), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Icon:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); button = gimp_prop_icon_picker_new (G_OBJECT (preset), "stock-id", data_editor->context->gimp); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-fg-bg", _("Apply stored FG/BG")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-brush", _("Apply stored brush")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-dynamics", _("Apply stored dynamics")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-gradient", _("Apply stored gradient")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-pattern", _("Apply stored pattern")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-palette", _("Apply stored palette")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (G_OBJECT (preset), "use-font", _("Apply stored font")); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); }
GimpPDBStatusType script_fu_interface (SFScript *script, gint start_arg) { GtkWidget *dialog; GtkWidget *menu; GtkWidget *vbox; GtkWidget *vbox2; GtkSizeGroup *group; GSList *list; gchar *title; gint i; static gboolean gtk_initted = FALSE; /* Simply return if there is already an interface. This is an * ugly workaround for the fact that we can not process two * scripts at a time. */ if (sf_interface != NULL) { gchar *message = g_strdup_printf ("%s\n\n%s", _("Script-Fu cannot process two scripts " "at the same time."), _("You are already running the \"%s\" script.")); g_message (message, sf_interface->title); g_free (message); return GIMP_PDB_CANCEL; } g_return_val_if_fail (script != NULL, FALSE); if (!gtk_initted) { INIT_I18N(); gimp_ui_init ("script-fu", TRUE); gtk_initted = TRUE; } sf_status = GIMP_PDB_SUCCESS; sf_interface = g_slice_new0 (SFInterface); sf_interface->widgets = g_new0 (GtkWidget *, script->n_args); sf_interface->title = script_fu_script_get_title (script); title = g_strdup_printf (_("Script-Fu: %s"), sf_interface->title); sf_interface->dialog = dialog = gimp_dialog_new (title, "script-fu", NULL, 0, gimp_standard_help_func, script->name, GIMP_STOCK_RESET, RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), RESPONSE_RESET, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gimp_window_set_transient (GTK_WINDOW (dialog)); g_signal_connect (dialog, "response", G_CALLBACK (script_fu_response), script); g_signal_connect_swapped (dialog, "destroy", G_CALLBACK (script_fu_interface_quit), script); gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); /* The argument table */ sf_interface->table = gtk_table_new (script->n_args - start_arg, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (sf_interface->table), 6); gtk_table_set_row_spacings (GTK_TABLE (sf_interface->table), 6); gtk_box_pack_start (GTK_BOX (vbox), sf_interface->table, FALSE, FALSE, 0); gtk_widget_show (sf_interface->table); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); for (i = start_arg; i < script->n_args; i++) { GtkWidget *widget = NULL; GtkObject *adj; gchar *label_text; gfloat label_yalign = 0.5; gint *ID_ptr = NULL; gint row = i; gboolean left_align = FALSE; SFArg *arg = &script->args[i]; row -= start_arg; /* we add a colon after the label; * some languages want an extra space here */ label_text = g_strdup_printf (_("%s:"), gettext (arg->label)); switch (arg->type) { case SF_IMAGE: case SF_DRAWABLE: case SF_LAYER: case SF_CHANNEL: case SF_VECTORS: switch (arg->type) { case SF_IMAGE: widget = gimp_image_combo_box_new (NULL, NULL); ID_ptr = &arg->value.sfa_image; break; case SF_DRAWABLE: widget = gimp_drawable_combo_box_new (NULL, NULL); ID_ptr = &arg->value.sfa_drawable; break; case SF_LAYER: widget = gimp_layer_combo_box_new (NULL, NULL); ID_ptr = &arg->value.sfa_layer; break; case SF_CHANNEL: widget = gimp_channel_combo_box_new (NULL, NULL); ID_ptr = &arg->value.sfa_channel; break; case SF_VECTORS: widget = gimp_vectors_combo_box_new (NULL, NULL); ID_ptr = &arg->value.sfa_vectors; break; default: menu = NULL; break; } gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (widget), *ID_ptr, G_CALLBACK (gimp_int_combo_box_get_active), ID_ptr); break; case SF_COLOR: left_align = TRUE; widget = gimp_color_button_new (_("Script-Fu Color Selection"), COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT, &arg->value.sfa_color, GIMP_COLOR_AREA_FLAT); gimp_color_button_set_update (GIMP_COLOR_BUTTON (widget), TRUE); g_signal_connect (widget, "color-changed", G_CALLBACK (gimp_color_button_get_color), &arg->value.sfa_color); break; case SF_TOGGLE: g_free (label_text); label_text = NULL; widget = gtk_check_button_new_with_mnemonic (gettext (arg->label)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), arg->value.sfa_toggle); g_signal_connect (widget, "toggled", G_CALLBACK (gimp_toggle_button_update), &arg->value.sfa_toggle); break; case SF_VALUE: case SF_STRING: widget = gtk_entry_new (); gtk_widget_set_size_request (widget, TEXT_WIDTH, -1); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_text (GTK_ENTRY (widget), arg->value.sfa_value); break; case SF_TEXT: { GtkWidget *view; GtkTextBuffer *buffer; widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request (widget, TEXT_WIDTH, -1); view = gtk_text_view_new (); gtk_container_add (GTK_CONTAINER (widget), view); gtk_widget_show (view); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE); gtk_text_buffer_set_text (buffer, arg->value.sfa_value, -1); label_yalign = 0.0; } break; case SF_ADJUSTMENT: switch (arg->default_value.sfa_adjustment.type) { case SF_SLIDER: arg->value.sfa_adjustment.adj = (GtkAdjustment *) gimp_scale_entry_new (GTK_TABLE (sf_interface->table), 0, row, label_text, SLIDER_WIDTH, -1, arg->value.sfa_adjustment.value, arg->default_value.sfa_adjustment.lower, arg->default_value.sfa_adjustment.upper, arg->default_value.sfa_adjustment.step, arg->default_value.sfa_adjustment.page, arg->default_value.sfa_adjustment.digits, TRUE, 0.0, 0.0, NULL, NULL); gtk_entry_set_activates_default (GIMP_SCALE_ENTRY_SPINBUTTON (arg->value.sfa_adjustment.adj), TRUE); break; default: g_warning ("unexpected adjustment type: %d", arg->default_value.sfa_adjustment.type); /* fallthrough */ case SF_SPINNER: left_align = TRUE; widget = gimp_spin_button_new (&adj, arg->value.sfa_adjustment.value, arg->default_value.sfa_adjustment.lower, arg->default_value.sfa_adjustment.upper, arg->default_value.sfa_adjustment.step, arg->default_value.sfa_adjustment.page, 0, 0, arg->default_value.sfa_adjustment.digits); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); arg->value.sfa_adjustment.adj = GTK_ADJUSTMENT (adj); break; } g_signal_connect (arg->value.sfa_adjustment.adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &arg->value.sfa_adjustment.value); break; case SF_FILENAME: case SF_DIRNAME: if (arg->type == SF_FILENAME) widget = gtk_file_chooser_button_new (_("Script-Fu File Selection"), GTK_FILE_CHOOSER_ACTION_OPEN); else widget = gtk_file_chooser_button_new (_("Script-Fu Folder Selection"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); if (arg->value.sfa_file.filename) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), arg->value.sfa_file.filename); g_signal_connect (widget, "selection-changed", G_CALLBACK (script_fu_file_callback), &arg->value.sfa_file); break; case SF_FONT: widget = gimp_font_select_button_new (_("Script-Fu Font Selection"), arg->value.sfa_font); g_signal_connect_swapped (widget, "font-set", G_CALLBACK (script_fu_font_callback), &arg->value.sfa_font); break; case SF_PALETTE: widget = gimp_palette_select_button_new (_("Script-Fu Palette Selection"), arg->value.sfa_palette); g_signal_connect_swapped (widget, "palette-set", G_CALLBACK (script_fu_palette_callback), &arg->value.sfa_palette); break; case SF_PATTERN: left_align = TRUE; widget = gimp_pattern_select_button_new (_("Script-Fu Pattern Selection"), arg->value.sfa_pattern); g_signal_connect_swapped (widget, "pattern-set", G_CALLBACK (script_fu_pattern_callback), &arg->value.sfa_pattern); break; case SF_GRADIENT: left_align = TRUE; widget = gimp_gradient_select_button_new (_("Script-Fu Gradient Selection"), arg->value.sfa_gradient); g_signal_connect_swapped (widget, "gradient-set", G_CALLBACK (script_fu_gradient_callback), &arg->value.sfa_gradient); break; case SF_BRUSH: left_align = TRUE; widget = gimp_brush_select_button_new (_("Script-Fu Brush Selection"), arg->value.sfa_brush.name, arg->value.sfa_brush.opacity, arg->value.sfa_brush.spacing, arg->value.sfa_brush.paint_mode); g_signal_connect_swapped (widget, "brush-set", G_CALLBACK (script_fu_brush_callback), &arg->value.sfa_brush); break; case SF_OPTION: #if GTK_CHECK_VERSION (2, 24, 0) widget = gtk_combo_box_text_new (); #else widget = gtk_combo_box_new_text (); #endif for (list = arg->default_value.sfa_option.list; list; list = g_slist_next (list)) { #if GTK_CHECK_VERSION (2, 24, 0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), gettext (list->data)); #else gtk_combo_box_append_text (GTK_COMBO_BOX (widget), gettext (list->data)); #endif } gtk_combo_box_set_active (GTK_COMBO_BOX (widget), arg->value.sfa_option.history); g_signal_connect (widget, "changed", G_CALLBACK (script_fu_combo_callback), &arg->value.sfa_option); break; case SF_ENUM: widget = gimp_enum_combo_box_new (g_type_from_name (arg->default_value.sfa_enum.type_name)); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), arg->value.sfa_enum.history); g_signal_connect (widget, "changed", G_CALLBACK (gimp_int_combo_box_get_active), &arg->value.sfa_enum.history); break; case SF_DISPLAY: break; } if (widget) { if (label_text) { gimp_table_attach_aligned (GTK_TABLE (sf_interface->table), 0, row, label_text, 0.0, label_yalign, widget, 2, left_align); g_free (label_text); } else { gtk_table_attach (GTK_TABLE (sf_interface->table), widget, 0, 3, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (widget); } if (left_align) gtk_size_group_add_widget (group, widget); } sf_interface->widgets[i] = widget; } g_object_unref (group); /* the script progress bar */ vbox2 = gtk_vbox_new (FALSE, 6); gtk_box_pack_end (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); gtk_widget_show (vbox2); sf_interface->progress_bar = gimp_progress_bar_new (); gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress_bar, FALSE, FALSE, 0); gtk_widget_show (sf_interface->progress_bar); sf_interface->progress_label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (sf_interface->progress_label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (sf_interface->progress_label), PANGO_ELLIPSIZE_MIDDLE); gimp_label_set_attributes (GTK_LABEL (sf_interface->progress_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress_label, FALSE, FALSE, 0); gtk_widget_show (sf_interface->progress_label); gtk_widget_show (dialog); gtk_main (); return sf_status; }
GtkWidget * palette_import_dialog_new (GimpContext *context) { ImportDialog *dialog; GimpGradient *gradient; GtkWidget *button; GtkWidget *main_hbox; GtkWidget *frame; GtkWidget *vbox; GtkWidget *table; GtkWidget *abox; GtkSizeGroup *size_group; GSList *group = NULL; g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); gradient = gimp_context_get_gradient (context); dialog = g_slice_new0 (ImportDialog); dialog->import_type = GRADIENT_IMPORT; dialog->context = gimp_context_new (context->gimp, "Palette Import", context); dialog->dialog = gimp_dialog_new (_("Import a New Palette"), "gimp-palette-import", NULL, 0, gimp_standard_help_func, GIMP_HELP_PALETTE_IMPORT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); button = gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), _("_Import"), GTK_RESPONSE_OK); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("gtk-convert", GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_object_set_data_full (G_OBJECT (dialog->dialog), "palette-import-dialog", dialog, (GDestroyNotify) palette_import_free); g_signal_connect (dialog->dialog, "response", G_CALLBACK (palette_import_response), dialog); gimp_dnd_viewable_dest_add (dialog->dialog, GIMP_TYPE_GRADIENT, import_dialog_drop_callback, dialog); gimp_dnd_viewable_dest_add (dialog->dialog, GIMP_TYPE_IMAGE, import_dialog_drop_callback, dialog); main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))), main_hbox, TRUE, TRUE, 0); gtk_widget_show (main_hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); /* The "Source" frame */ frame = gimp_frame_new (_("Select Source")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (5, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); dialog->gradient_radio = gtk_radio_button_new_with_mnemonic (group, _("_Gradient")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->gradient_radio)); gtk_table_attach (GTK_TABLE (table), dialog->gradient_radio, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->gradient_radio); g_signal_connect (dialog->gradient_radio, "toggled", G_CALLBACK (palette_import_grad_callback), dialog); dialog->image_radio = gtk_radio_button_new_with_mnemonic (group, _("I_mage")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio)); gtk_table_attach (GTK_TABLE (table), dialog->image_radio, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->image_radio); g_signal_connect (dialog->image_radio, "toggled", G_CALLBACK (palette_import_image_callback), dialog); gtk_widget_set_sensitive (dialog->image_radio, ! gimp_container_is_empty (context->gimp->images)); dialog->sample_merged_toggle = gtk_check_button_new_with_mnemonic (_("Sample _Merged")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle), TRUE); gtk_table_attach (GTK_TABLE (table), dialog->sample_merged_toggle, 1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->sample_merged_toggle); g_signal_connect_swapped (dialog->sample_merged_toggle, "toggled", G_CALLBACK (palette_import_make_palette), dialog); dialog->selection_only_toggle = gtk_check_button_new_with_mnemonic (_("_Selected Pixels only")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->selection_only_toggle), FALSE); gtk_table_attach (GTK_TABLE (table), dialog->selection_only_toggle, 1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->selection_only_toggle); g_signal_connect_swapped (dialog->selection_only_toggle, "toggled", G_CALLBACK (palette_import_make_palette), dialog); dialog->file_radio = gtk_radio_button_new_with_mnemonic (group, _("Palette _file")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio)); gtk_table_attach (GTK_TABLE (table), dialog->file_radio, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->file_radio); g_signal_connect (dialog->file_radio, "toggled", G_CALLBACK (palette_import_file_callback), dialog); size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); /* The gradient menu */ dialog->gradient_combo = gimp_container_combo_box_new (gimp_data_factory_get_container (context->gimp->gradient_factory), dialog->context, 24, 1); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->gradient_combo); /* The image menu */ dialog->image_combo = gimp_container_combo_box_new (context->gimp->images, dialog->context, 24, 1); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->image_combo); /* Palette file name entry */ dialog->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"), GTK_FILE_CHOOSER_ACTION_OPEN); gimp_table_attach_aligned (GTK_TABLE (table), 0, 4, NULL, 0.0, 0.5, dialog->file_chooser, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->file_chooser); g_object_unref (size_group); /* The "Import" frame */ frame = gimp_frame_new (_("Import Options")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (4, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); /* The source's name */ dialog->entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (dialog->entry), gradient ? gimp_object_get_name (gradient) : _("New import")); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Palette _name:"), 0.0, 0.5, dialog->entry, 2, FALSE); /* The # of colors */ dialog->num_colors = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("N_umber of colors:"), -1, 5, 256, 2, 10000, 1, 10, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect_swapped (dialog->num_colors, "value-changed", G_CALLBACK (palette_import_make_palette), dialog); /* The columns */ dialog->columns = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 2, _("C_olumns:"), -1, 5, 16, 0, 64, 1, 8, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (dialog->columns, "value-changed", G_CALLBACK (palette_import_columns_changed), dialog); /* The interval */ dialog->threshold = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 3, _("I_nterval:"), -1, 5, 1, 1, 128, 1, 8, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect_swapped (dialog->threshold, "value-changed", G_CALLBACK (palette_import_make_palette), dialog); /* The "Preview" frame */ frame = gimp_frame_new (_("Preview")); gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0); gtk_widget_show (abox); dialog->preview = gimp_view_new_full_by_types (dialog->context, GIMP_TYPE_VIEW, GIMP_TYPE_PALETTE, 192, 192, 1, TRUE, FALSE, FALSE); gtk_container_add (GTK_CONTAINER (abox), dialog->preview); gtk_widget_show (dialog->preview); dialog->no_colors_label = gtk_label_new (_("The selected source contains no colors.")); gtk_widget_set_size_request (dialog->no_colors_label, 194, -1); gtk_label_set_line_wrap (GTK_LABEL (dialog->no_colors_label), TRUE); gimp_label_set_attributes (GTK_LABEL (dialog->no_colors_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), dialog->no_colors_label, FALSE, FALSE, 0); gtk_widget_show (dialog->no_colors_label); /* keep the dialog up-to-date */ g_signal_connect (context->gimp->images, "add", G_CALLBACK (palette_import_image_add), dialog); g_signal_connect (context->gimp->images, "remove", G_CALLBACK (palette_import_image_remove), dialog); g_signal_connect (dialog->context, "gradient-changed", G_CALLBACK (palette_import_gradient_changed), dialog); g_signal_connect (dialog->context, "image-changed", G_CALLBACK (palette_import_image_changed), dialog); g_signal_connect (dialog->file_chooser, "selection-changed", G_CALLBACK (palette_import_filename_changed), dialog); palette_import_grad_callback (dialog->gradient_radio, dialog); return dialog->dialog; }
static GimpExportReturn confirm_save_dialog (const gchar *message, const gchar *format_name) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *image; GtkWidget *main_vbox; GtkWidget *label; gchar *text; GimpExportReturn retval; g_return_val_if_fail (message != NULL, GIMP_EXPORT_CANCEL); g_return_val_if_fail (format_name != NULL, GIMP_EXPORT_CANCEL); dialog = gimp_dialog_new (_("Confirm Save"), "gimp-export-image-confirm", NULL, 0, gimp_standard_help_func, "gimp-export-confirm-dialog", GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Confirm"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gimp_window_set_transient (GTK_WINDOW (dialog)); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); gtk_widget_show (hbox); image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_widget_show (image); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0); gtk_widget_show (main_vbox); text = g_strdup_printf (message, format_name); label = gtk_label_new (text); g_free (text); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_LARGE, PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_widget_show (dialog); switch (gimp_dialog_run (GIMP_DIALOG (dialog))) { case GTK_RESPONSE_OK: retval = GIMP_EXPORT_EXPORT; break; default: retval = GIMP_EXPORT_CANCEL; break; } gtk_widget_destroy (dialog); return retval; }
void gimp_tools_restore (Gimp *gimp) { GimpContainer *gimp_list; GimpObject *object; GFile *file; GList *list; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE); file = gimp_directory_file ("toolrc", NULL); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file, NULL, NULL)) { gint n = gimp_container_get_n_children (gimp->tool_info_list); gint i; gimp_list_reverse (GIMP_LIST (gimp_list)); for (list = GIMP_LIST (gimp_list)->list, i = 0; list; list = g_list_next (list), i++) { const gchar *name; name = gimp_object_get_name (list->data); object = gimp_container_get_child_by_name (gimp->tool_info_list, name); if (object) { g_object_set (object, "visible", GIMP_TOOL_INFO (list->data)->visible, NULL); gimp_container_reorder (gimp->tool_info_list, object, MIN (i, n - 1)); } } } g_object_unref (file); g_object_unref (gimp_list); /* make the generic operation tool invisible by default */ object = gimp_container_get_child_by_name (gimp->tool_info_list, "gimp-operation-tool"); if (object) g_object_set (object, "visible", FALSE, NULL); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); /* get default values from prefs (see bug #120832) */ gimp_config_reset (GIMP_CONFIG (tool_info->tool_options)); } if (! gimp_contexts_load (gimp, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } /* make sure there is always a tool active, so broken config files * can't leave us with no initial tool */ if (! gimp_context_get_tool (gimp_get_user_context (gimp))) { gimp_context_set_tool (gimp_get_user_context (gimp), gimp_get_tool_info_iter (gimp)->data); } for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); GimpToolOptionsGUIFunc options_gui_func; GtkWidget *options_gui; /* copy all context properties except those the tool actually * uses, because the subsequent deserialize() on the tool * options will only set the properties that were set to * non-default values at the time of saving, and we want to * keep these default values as if they have been saved. * (see bug #541586). */ gimp_context_copy_properties (gimp_get_user_context (gimp), GIMP_CONTEXT (tool_info->tool_options), GIMP_CONTEXT_PROP_MASK_ALL &~ (tool_info->context_props | GIMP_CONTEXT_PROP_MASK_TOOL | GIMP_CONTEXT_PROP_MASK_PAINT_INFO)); gimp_tool_options_deserialize (tool_info->tool_options, NULL); options_gui_func = g_object_get_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func"); if (options_gui_func) { options_gui = (* options_gui_func) (tool_info->tool_options); } else { GtkWidget *label; options_gui = gimp_tool_options_gui (tool_info->tool_options); label = gtk_label_new (_("This tool has\nno options.")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6); gtk_widget_show (label); } gimp_tools_set_tool_options_gui (tool_info->tool_options, g_object_ref_sink (options_gui)); } }
static void gimp_page_selector_init (GimpPageSelector *selector) { GimpPageSelectorPrivate *priv; GtkWidget *vbox; GtkWidget *sw; GtkWidget *hbox; GtkWidget *hbbox; GtkWidget *button; GtkWidget *label; GtkWidget *combo; selector->priv = G_TYPE_INSTANCE_GET_PRIVATE (selector, GIMP_TYPE_PAGE_SELECTOR, GimpPageSelectorPrivate); priv = GIMP_PAGE_SELECTOR_GET_PRIVATE (selector); priv->n_pages = 0; priv->target = GIMP_PAGE_SELECTOR_TARGET_LAYERS; gtk_orientable_set_orientation (GTK_ORIENTABLE (selector), GTK_ORIENTATION_VERTICAL); gtk_box_set_spacing (GTK_BOX (selector), 12); /* Pages */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (selector), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); gtk_widget_show (sw); priv->store = gtk_list_store_new (4, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); priv->view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (priv->store)); gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->view), COLUMN_LABEL); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->view), COLUMN_THUMBNAIL); gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (priv->view), GTK_SELECTION_MULTIPLE); gtk_container_add (GTK_CONTAINER (sw), priv->view); gtk_widget_show (priv->view); g_signal_connect (priv->view, "selection-changed", G_CALLBACK (gimp_page_selector_selection_changed), selector); g_signal_connect (priv->view, "item-activated", G_CALLBACK (gimp_page_selector_item_activated), selector); /* Count label */ priv->count_label = gtk_label_new (_("Nothing selected")); gtk_misc_set_alignment (GTK_MISC (priv->count_label), 0.0, 0.5); gimp_label_set_attributes (GTK_LABEL (priv->count_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), priv->count_label, FALSE, FALSE, 0); gtk_widget_show (priv->count_label); /* Select all button & range entry */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); gtk_widget_show (hbbox); button = gtk_button_new_with_mnemonic (_("Select _All")); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gimp_page_selector_select_all), selector); priv->range_entry = gtk_entry_new (); gtk_widget_set_size_request (priv->range_entry, 80, -1); gtk_box_pack_end (GTK_BOX (hbox), priv->range_entry, TRUE, TRUE, 0); gtk_widget_show (priv->range_entry); g_signal_connect (priv->range_entry, "focus-out-event", G_CALLBACK (gimp_page_selector_range_focus_out), selector); g_signal_connect (priv->range_entry, "activate", G_CALLBACK (gimp_page_selector_range_activate), selector); label = gtk_label_new_with_mnemonic (_("Select _range:")); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->range_entry); /* Target combo */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Open _pages as")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); combo = gimp_prop_enum_combo_box_new (G_OBJECT (selector), "target", -1, -1); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); priv->default_thumbnail = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "text-x-generic", 32, 0, NULL); }
static void colorsel_cmyk_init (ColorselCmyk *module) { GtkWidget *table; GtkObject *adj; gint i; static const gchar * const cmyk_labels[] = { /* Cyan */ N_("_C"), /* Magenta */ N_("_M"), /* Yellow */ N_("_Y"), /* Key (Black) */ N_("_K") }; static const gchar * const cmyk_tips[] = { N_("Cyan"), N_("Magenta"), N_("Yellow"), N_("Black") }; module->config = NULL; module->rgb2cmyk = NULL; module->cmyk2rgb = NULL; gtk_box_set_spacing (GTK_BOX (module), 6); table = gtk_table_new (4, 4, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 1); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0); gtk_box_pack_start (GTK_BOX (module), table, FALSE, FALSE, 0); gtk_widget_show (table); for (i = 0; i < 4; i++) { adj = gimp_scale_entry_new (GTK_TABLE (table), 1, i, gettext (cmyk_labels[i]), -1, -1, 0.0, 0.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, gettext (cmyk_tips[i]), NULL); g_signal_connect (adj, "value-changed", G_CALLBACK (colorsel_cmyk_adj_update), module); module->adj[i] = GTK_ADJUSTMENT (adj); } module->name_label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (module->name_label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (module->name_label), PANGO_ELLIPSIZE_END); gimp_label_set_attributes (GTK_LABEL (module->name_label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); gtk_box_pack_start (GTK_BOX (module), module->name_label, FALSE, FALSE, 0); gtk_widget_show (module->name_label); }
static void gimp_levels_tool_dialog (GimpImageMapTool *im_tool) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool); GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (im_tool); GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config); GtkListStore *store; GtkWidget *main_vbox; GtkWidget *frame_vbox; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *vbox3; GtkWidget *hbox; GtkWidget *hbox2; GtkWidget *label; GtkWidget *main_frame; GtkWidget *frame; GtkWidget *button; GtkWidget *spinbutton; GtkAdjustment *adjustment; GtkWidget *bar; GtkWidget *handle_bar; gint border; g_signal_connect (im_tool->settings_box, "file-dialog-setup", G_CALLBACK (gimp_levels_tool_export_setup), im_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool); /* The combo box for selecting channels */ main_frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (main_vbox), main_frame, TRUE, TRUE, 0); gtk_widget_show (main_frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_frame_set_label_widget (GTK_FRAME (main_frame), hbox); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Cha_nnel:")); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL, GIMP_HISTOGRAM_VALUE, GIMP_HISTOGRAM_ALPHA); tool->channel_menu = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)); g_object_unref (store); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (tool->channel_menu), "gimp-channel"); gtk_box_pack_start (GTK_BOX (hbox), tool->channel_menu, FALSE, FALSE, 0); gtk_widget_show (tool->channel_menu); g_signal_connect (tool->channel_menu, "changed", G_CALLBACK (levels_channel_callback), tool); gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->channel_menu); button = gtk_button_new_with_mnemonic (_("R_eset Channel")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_channel_reset_callback), tool); hbox2 = gimp_prop_enum_icon_box_new (G_OBJECT (tool_options), "histogram-scale", "gimp-histogram", 0, 0); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); frame_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (main_frame), frame_vbox); gtk_widget_show (frame_vbox); /* Input levels frame */ frame = gimp_frame_new (_("Input Levels")); gtk_box_pack_start (GTK_BOX (frame_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); tool->histogram_view = gimp_histogram_view_new (FALSE); gtk_box_pack_start (GTK_BOX (vbox2), tool->histogram_view, TRUE, TRUE, 0); gtk_widget_show (GTK_WIDGET (tool->histogram_view)); gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options), GIMP_HISTOGRAM_VIEW (tool->histogram_view)); g_object_get (tool->histogram_view, "border-width", &border, NULL); vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox3), border); gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0); gtk_widget_show (vbox3); tool->input_bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (tool->input_bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), tool->input_bar, FALSE, FALSE, 0); gtk_widget_show (tool->input_bar); bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), bar, FALSE, FALSE, 0); gtk_widget_show (bar); handle_bar = g_object_new (GIMP_TYPE_HANDLE_BAR, NULL); gtk_widget_set_size_request (handle_bar, -1, CONTROL_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox3), handle_bar, FALSE, FALSE, 0); gtk_widget_show (handle_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), tool->input_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), bar); /* Horizontal box for input levels spinbuttons */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low input spin */ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, PICK_LOW_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); tool->low_input_spinbutton = spinbutton = gimp_prop_spin_button_new (im_tool->config, "low-input", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->low_input = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 0, tool->low_input); /* input gamma spin */ spinbutton = gimp_prop_spin_button_new (im_tool->config, "gamma", 0.01, 0.1, 2); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0); gimp_help_set_help_data (spinbutton, _("Gamma"), NULL); gtk_widget_show (spinbutton); tool->gamma = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); tool->gamma_linear = GTK_ADJUSTMENT (gtk_adjustment_new (127, 0, 255, 0.1, 1.0, 0.0)); g_signal_connect (tool->gamma_linear, "value-changed", G_CALLBACK (levels_linear_gamma_changed), tool); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 1, tool->gamma_linear); g_object_unref (tool->gamma_linear); /* high input spin */ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, PICK_HIGH_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); spinbutton = gimp_prop_spin_button_new (im_tool->config, "high-input", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->high_input_spinbutton = spinbutton; tool->high_input = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 2, tool->high_input); /* Output levels frame */ frame = gimp_frame_new (_("Output Levels")); gtk_box_pack_start (GTK_BOX (frame_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); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox2), border); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); tool->output_bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (tool->output_bar, -1, GRADIENT_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox2), tool->output_bar, FALSE, FALSE, 0); gtk_widget_show (tool->output_bar); handle_bar = g_object_new (GIMP_TYPE_HANDLE_BAR, NULL); gtk_widget_set_size_request (handle_bar, -1, CONTROL_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox2), handle_bar, FALSE, FALSE, 0); gtk_widget_show (handle_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), tool->output_bar); /* Horizontal box for levels spin widgets */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low output spin */ tool->low_output_spinbutton = spinbutton = gimp_prop_spin_button_new (im_tool->config, "low-output", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 0, adjustment); /* high output spin */ tool->high_output_spinbutton = spinbutton = gimp_prop_spin_button_new (im_tool->config, "high-output", 0.01, 0.1, 1); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 2, adjustment); /* all channels frame */ main_frame = gimp_frame_new (_("All Channels")); gtk_box_pack_start (GTK_BOX (main_vbox), main_frame, FALSE, FALSE, 0); gtk_widget_show (main_frame); frame_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (main_frame), frame_vbox); gtk_widget_show (frame_vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); button = gtk_button_new_with_mnemonic (_("_Auto Input Levels")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gimp_help_set_help_data (button, _("Adjust levels for all channels automatically"), NULL); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_stretch_callback), tool); button = gimp_levels_tool_color_picker_new (tool, PICK_HIGH_INPUT | PICK_ALL_CHANNELS); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, PICK_GAMMA | PICK_ALL_CHANNELS); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, PICK_LOW_INPUT | PICK_ALL_CHANNELS); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_icon_button_new (GIMP_STOCK_TOOL_CURVES, _("Edit these Settings as Curves")); gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_to_curves_callback), tool); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), config->channel); }