/** * gimp_scale_entry_set_sensitive: * @adjustment: a #GtkAdjustment returned by gimp_scale_entry_new() * @sensitive: a boolean value with the same semantics as the @sensitive * parameter of gtk_widget_set_sensitive() * * Sets the sensitivity of the scale_entry's #GtkLabel, #GtkHScale and * #GtkSpinButton. **/ void gimp_scale_entry_set_sensitive (GtkObject *adjustment, gboolean sensitive) { GtkWidget *widget; g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); widget = GIMP_SCALE_ENTRY_LABEL (adjustment); if (widget) gtk_widget_set_sensitive (widget, sensitive); widget = GIMP_SCALE_ENTRY_SCALE (adjustment); if (widget) gtk_widget_set_sensitive (widget, sensitive); widget = GIMP_SCALE_ENTRY_SPINBUTTON (adjustment); if (widget) gtk_widget_set_sensitive (widget, sensitive); }
void callback_combo_set_sensitive (GtkWidget * button, gpointer data) { ToggleData *t_data = TOGGLE_DATA (data); gboolean button_status = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); gtk_widget_set_sensitive (t_data->combo, button_status); gtk_widget_set_sensitive (t_data->combo_label, button_status); if (t_data->scale) { gtk_widget_set_sensitive (GIMP_SCALE_ENTRY_LABEL (t_data->scale), button_status); gtk_widget_set_sensitive (GIMP_SCALE_ENTRY_SCALE (t_data->scale), button_status); gtk_widget_set_sensitive (GIMP_SCALE_ENTRY_SPINBUTTON (t_data->scale), button_status); } if (t_data->guess_label) { gtk_widget_set_sensitive (t_data->guess_label, button_status); } if (t_data->guess_button_hor) { gtk_widget_set_sensitive (t_data->guess_button_hor, button_status); } if (t_data->guess_button_ver) { gtk_widget_set_sensitive (t_data->guess_button_ver, button_status); } if (t_data->edit_button) { gtk_widget_set_sensitive (t_data->edit_button, button_status); } *(t_data->status) = button_status; }
static gint alienmap2_dialog (void) { GtkWidget *dialog; GtkWidget *main_vbox; GtkWidget *top_table; GtkWidget *frame; GtkWidget *toggle; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *table; GtkObject *adj; gboolean run; gimp_ui_init (PLUG_IN_BINARY, TRUE); dialog = gimp_dialog_new (_("Alien Map"), 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)); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), main_vbox, TRUE, TRUE, 0); gtk_widget_show (main_vbox); preview = gimp_zoom_preview_new (drawable); gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0); gtk_widget_show (preview); g_signal_connect_swapped (preview, "invalidated", G_CALLBACK (dialog_update_preview), drawable); top_table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (top_table), 12); gtk_table_set_row_spacings (GTK_TABLE (top_table), 12); gtk_box_pack_start (GTK_BOX (main_vbox), top_table, FALSE, FALSE, 0); gtk_widget_show (top_table); /* Controls */ table = gtk_table_new (6, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_attach (GTK_TABLE (top_table), table, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show (table); entry_freq_rh = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.redfrequency, 0, 20.0, 0.1, 1, 2, TRUE, 0, 0, _("Number of cycles covering full value range"), NULL); label_freq_rh = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.redfrequency); entry_phase_rh = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.redangle, 0, 360.0, 1, 15, 2, TRUE, 0, 0, _("Phase angle, range 0-360"), NULL); label_phase_rh = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.redangle); entry_freq_gs = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.greenfrequency, 0, 20.0, 0.1, 1, 2, TRUE, 0, 0, _("Number of cycles covering full value range"), NULL); label_freq_gs = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.greenfrequency); entry_phase_gs = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.redangle, 0, 360.0, 1, 15, 2, TRUE, 0, 0, _("Phase angle, range 0-360"), NULL); label_phase_gs = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.greenangle); entry_freq_bl = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 4, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.bluefrequency, 0, 20.0, 0.1, 1, 2, TRUE, 0, 0, _("Number of cycles covering full value range"), NULL); label_freq_bl = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.bluefrequency); entry_phase_bl = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 5, NULL, SCALE_WIDTH, ENTRY_WIDTH, wvals.blueangle, 0, 360.0, 1, 15, 2, TRUE, 0, 0, _("Phase angle, range 0-360"), NULL); label_phase_bl = GIMP_SCALE_ENTRY_LABEL (adj); g_signal_connect (adj, "value-changed", G_CALLBACK (dialog_scale_update), &wvals.blueangle); /* Mode toggle box */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_table_attach (GTK_TABLE (top_table), hbox, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); gtk_widget_show (hbox); frame = gimp_int_radio_group_new (TRUE, _("Mode"), G_CALLBACK (alienmap2_radio_update), &wvals.colormodel, wvals.colormodel, _("_RGB color model"), RGB_MODEL, NULL, _("_HSL color model"), HSL_MODEL, NULL, NULL); gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); toggle_modify_rh = toggle = gtk_check_button_new_with_mnemonic (NULL); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.redmode); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (alienmap2_toggle_update), &wvals.redmode); toggle_modify_gs = toggle = gtk_check_button_new_with_mnemonic (NULL); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.greenmode); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (alienmap2_toggle_update), &wvals.greenmode); toggle_modify_bl = toggle = gtk_check_button_new_with_mnemonic (NULL); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.bluemode); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (alienmap2_toggle_update), &wvals.bluemode); gtk_widget_show (frame); gtk_widget_show (dialog); alienmap2_get_label_size (); alienmap2_set_labels (); alienmap2_set_sensitive (); run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); gtk_widget_destroy (dialog); return run; }
void create_brushpage (GtkNotebook *notebook) { GtkWidget *box1, *box2, *box3, *thispage; GtkWidget *view; GtkWidget *tmpw, *table; GtkWidget *frame; GtkWidget *combo; GtkWidget *label; GtkSizeGroup *group; GtkTreeSelection *selection; label = gtk_label_new_with_mnemonic (_("_Brush")); 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, TRUE,TRUE,0); gtk_widget_show (box1); view = create_one_column_list (box1, brush_select_file); brush_list = view; brush_list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view))); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0); gtk_widget_show (frame); brush_preview = tmpw = gimp_preview_area_new (); gtk_widget_set_size_request (brush_preview, 100, 100); gtk_container_add (GTK_CONTAINER (frame), tmpw); gtk_widget_show (tmpw); g_signal_connect (brush_preview, "size-allocate", G_CALLBACK (brush_preview_size_allocate), NULL); box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_end (GTK_BOX (box2), box3, FALSE, FALSE,0); gtk_widget_show (box3); tmpw = gtk_label_new (_("Gamma:")); gtk_misc_set_alignment (GTK_MISC (tmpw), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE,0); gtk_widget_show (tmpw); brush_gamma_adjust = GTK_ADJUSTMENT (gtk_adjustment_new (pcvals.brushgamma, 0.5, 3.0, 0.1, 0.1, 1.0)); tmpw = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, brush_gamma_adjust); gtk_widget_set_size_request (GTK_WIDGET (tmpw), 100, 30); gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE); gtk_scale_set_digits (GTK_SCALE (tmpw), 2); gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE, 0); gtk_widget_show (tmpw); g_signal_connect_swapped (brush_gamma_adjust, "value-changed", G_CALLBACK (update_brush_preview), pcvals.selected_brush); gimp_help_set_help_data (tmpw, _("Changes the gamma (brightness) of the selected brush"), NULL); box3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (thispage), box3, FALSE, FALSE,0); gtk_widget_show (box3); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); tmpw = gtk_label_new (_("Select:")); gtk_misc_set_alignment (GTK_MISC (tmpw), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE, 0); gtk_widget_show (tmpw); gtk_size_group_add_widget (group, tmpw); g_object_unref (group); combo = gimp_drawable_combo_box_new (validdrawable, NULL); gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), -1, G_CALLBACK (brushdmenuselect), NULL); gtk_box_pack_start (GTK_BOX (box3), combo, TRUE, TRUE, 0); gtk_widget_show (combo); tmpw = gtk_button_new_from_stock (GTK_STOCK_SAVE_AS); gtk_box_pack_start (GTK_BOX (box3),tmpw, FALSE, FALSE, 0); g_signal_connect (tmpw, "clicked", G_CALLBACK (savebrush), NULL); gtk_widget_show (tmpw); table = gtk_table_new (2, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_box_pack_start (GTK_BOX (thispage), table, FALSE, FALSE, 0); gtk_widget_show (table); brush_aspect_adjust = (GtkAdjustment *) gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("Aspect ratio:"), 150, -1, pcvals.brush_aspect, -1.0, 1.0, 0.1, 0.1, 2, TRUE, 0, 0, _("Specifies the aspect ratio of the brush"), NULL); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (brush_aspect_adjust)); g_signal_connect (brush_aspect_adjust, "value-changed", G_CALLBACK (brush_asepct_adjust_cb), &pcvals.brush_aspect); brush_relief_adjust = (GtkAdjustment *) gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("Relief:"), 150, -1, pcvals.brush_relief, 0.0, 100.0, 1.0, 10.0, 1, TRUE, 0, 0, _("Specifies the amount of embossing to apply to the image (in percent)"), NULL); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (brush_relief_adjust)); g_signal_connect (brush_relief_adjust, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &pcvals.brush_relief); brush_select (selection, FALSE); readdirintolist ("Brushes", view, pcvals.selected_brush); /* * This is so the "changed signal won't get sent to the brushes' list * and reset the gamma and stuff. * */ gtk_widget_grab_focus (brush_list); gtk_notebook_append_page_menu (notebook, thispage, label, NULL); }
/* show our dialog */ static gboolean exchange_dialog (GimpDrawable *drawable) { GtkWidget *dialog; GtkWidget *main_vbox; GtkWidget *hbox; GtkWidget *frame; GtkWidget *preview; GtkWidget *table; GtkWidget *threshold; GtkWidget *colorbutton; GtkObject *adj; GtkSizeGroup *group; gint framenumber; gboolean run; gimp_ui_init (PLUG_IN_BINARY, TRUE); dialog = gimp_dialog_new (_("Color Exchange"), 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)); /* do some boxes here */ main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), main_vbox, TRUE, TRUE, 0); gtk_widget_show (main_vbox); frame = gimp_frame_new (_("Middle-Click Inside Preview to " "Pick \"From Color\"")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); preview = gimp_drawable_preview_new (drawable, NULL); gtk_container_add (GTK_CONTAINER (frame), preview); gtk_widget_show (preview); g_signal_connect_swapped (preview, "invalidated", G_CALLBACK (exchange), drawable); g_signal_connect (GIMP_PREVIEW (preview)->area, "event", G_CALLBACK (preview_event_handler), preview); /* a hidden color_button to handle the threshold more easily */ threshold = gimp_color_button_new (NULL, 1, 1, &xargs.threshold, GIMP_COLOR_AREA_FLAT); g_signal_connect (threshold, "color-changed", G_CALLBACK (gimp_color_button_get_color), &xargs.threshold); g_signal_connect (threshold, "color-changed", G_CALLBACK (color_button_callback), &xargs.threshold); g_signal_connect_swapped (threshold, "color-changed", G_CALLBACK (gimp_preview_invalidate), preview); /* and our scales */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); for (framenumber = 0; framenumber < 2; framenumber++) { GtkWidget *vbox; GtkWidget *image; gint row = 0; frame = gimp_frame_new (framenumber ? _("To Color") : _("From Color")); gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); table = gtk_table_new (framenumber ? 4 : 8, 4, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 12); if (! framenumber) { gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 3, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 5, 2); } gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); colorbutton = gimp_color_button_new (framenumber ? _("Color Exchange: To Color") : _("Color Exchange: From Color"), SCALE_WIDTH / 2, 16, (framenumber ? &xargs.to : &xargs.from), GIMP_COLOR_AREA_FLAT); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, NULL, 0.0, 0.0, colorbutton, 1, FALSE); g_signal_connect (colorbutton, "color-changed", G_CALLBACK (gimp_color_button_get_color), framenumber ? &xargs.to : &xargs.from); g_signal_connect (colorbutton, "color-changed", G_CALLBACK (color_button_callback), framenumber ? &xargs.to : &xargs.from); g_signal_connect_swapped (colorbutton, "color-changed", G_CALLBACK (gimp_preview_invalidate), preview); if (! framenumber) from_colorbutton = colorbutton; /* Red */ image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_RED, GTK_ICON_SIZE_BUTTON); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5); gtk_table_attach (GTK_TABLE (table), image, 0, 1, row, row + 1 + (framenumber ? 0 : 1), GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (image); adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("_Red:"), SCALE_WIDTH, 0, framenumber ? xargs.to.r : xargs.from.r, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", colorbutton); g_object_set_data (G_OBJECT (colorbutton), "red", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), framenumber ? &xargs.to.r : &xargs.from.r); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), framenumber ? &xargs.to : &xargs.from); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); if (! framenumber) { adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("R_ed threshold:"), SCALE_WIDTH, 0, xargs.threshold.r, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", threshold); g_object_set_data (G_OBJECT (threshold), "red", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &xargs.threshold.r); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), &xargs.threshold); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); } /* Green */ image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_GREEN, GTK_ICON_SIZE_BUTTON); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5); gtk_table_attach (GTK_TABLE (table), image, 0, 1, row, row + 1 + (framenumber ? 0 : 1), GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (image); adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("_Green:"), SCALE_WIDTH, 0, framenumber ? xargs.to.g : xargs.from.g, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", colorbutton); g_object_set_data (G_OBJECT (colorbutton), "green", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), framenumber ? &xargs.to.g : &xargs.from.g); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), framenumber ? &xargs.to : &xargs.from); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); if (! framenumber) { adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("G_reen threshold:"), SCALE_WIDTH, 0, xargs.threshold.g, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", threshold); g_object_set_data (G_OBJECT (threshold), "green", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &xargs.threshold.g); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), &xargs.threshold); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); } /* Blue */ image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_BLUE, GTK_ICON_SIZE_BUTTON); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5); gtk_table_attach (GTK_TABLE (table), image, 0, 1, row, row + 1 + (framenumber ? 0 : 1), GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (image); adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("_Blue:"), SCALE_WIDTH, 0, framenumber ? xargs.to.b : xargs.from.b, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", colorbutton); g_object_set_data (G_OBJECT (colorbutton), "blue", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), framenumber ? &xargs.to.b : &xargs.from.b); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), framenumber ? &xargs.to : &xargs.from); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); if (! framenumber) { adj = gimp_scale_entry_new (GTK_TABLE (table), 1, row++, _("B_lue threshold:"), SCALE_WIDTH, 0, xargs.threshold.b, 0.0, 1.0, 0.01, 0.1, 3, TRUE, 0, 0, NULL, NULL); g_object_set_data (G_OBJECT (adj), "colorbutton", threshold); g_object_set_data (G_OBJECT (threshold), "blue", adj); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_double_adjustment_update), &xargs.threshold.b); g_signal_connect (adj, "value-changed", G_CALLBACK (scale_callback), &xargs.threshold); g_signal_connect_swapped (adj, "value-changed", G_CALLBACK (gimp_preview_invalidate), preview); gtk_size_group_add_widget (group, GIMP_SCALE_ENTRY_LABEL (adj)); } if (! framenumber) { GtkWidget *button; button = gtk_check_button_new_with_mnemonic (_("Lock _thresholds")); gtk_table_attach (GTK_TABLE (table), button, 2, 4, row, row + 1, GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), lock_threshold); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_toggle_button_update), &lock_threshold); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gimp_preview_invalidate), preview); } } g_object_unref (group); /* show everything */ gtk_widget_show (dialog); run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); gtk_widget_destroy (dialog); return run; }
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) { GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool); GimpHueSaturationConfig *config = hs_tool->config; GtkWidget *main_vbox; GtkWidget *vbox; GtkWidget *abox; GtkWidget *table; GtkWidget *button; GtkWidget *frame; GtkWidget *hbox; GtkObject *data; GtkSizeGroup *label_group; GtkSizeGroup *spinner_group; GSList *group = NULL; gint i; const struct { const gchar *label; const gchar *tooltip; gint label_col; gint label_row; gint frame_col; gint frame_row; } hue_range_table[] = { { N_("M_aster"), N_("Adjust all colors"), 2, 3, 0, 0 }, { N_("_R"), N_("Red"), 2, 1, 2, 0 }, { N_("_Y"), N_("Yellow"), 1, 2, 0, 2 }, { N_("_G"), N_("Green"), 1, 4, 0, 4 }, { N_("_C"), N_("Cyan"), 2, 5, 2, 6 }, { N_("_B"), N_("Blue"), 3, 4, 4, 4 }, { N_("_M"), N_("Magenta"), 3, 2, 4, 2 } }; main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); frame = gimp_frame_new (_("Select Primary Color to Adjust")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0); gtk_widget_show (abox); /* The table containing hue ranges */ table = gtk_table_new (7, 5, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); gtk_table_set_col_spacing (GTK_TABLE (table), 3, 4); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 5, 2); gtk_container_add (GTK_CONTAINER (abox), table); /* the radio buttons for hue ranges */ for (i = 0; i < G_N_ELEMENTS (hue_range_table); i++) { button = gtk_radio_button_new_with_mnemonic (group, gettext (hue_range_table[i].label)); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); g_object_set_data (G_OBJECT (button), "gimp-item-data", GINT_TO_POINTER (i)); gimp_help_set_help_data (button, gettext (hue_range_table[i].tooltip), NULL); if (i == 0) { gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); hs_tool->range_radio = button; } gtk_table_attach (GTK_TABLE (table), button, hue_range_table[i].label_col, hue_range_table[i].label_col + 1, hue_range_table[i].label_row, hue_range_table[i].label_row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); if (i > 0) { GimpRGB color = { 0.0 }; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_table_attach (GTK_TABLE (table), frame, hue_range_table[i].frame_col, hue_range_table[i].frame_col + 1, hue_range_table[i].frame_row, hue_range_table[i].frame_row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (frame); hs_tool->hue_range_color_area[i - 1] = gimp_color_area_new (&color, GIMP_COLOR_AREA_FLAT, 0); gtk_widget_set_size_request (hs_tool->hue_range_color_area[i - 1], DA_WIDTH, DA_HEIGHT); gtk_container_add (GTK_CONTAINER (frame), hs_tool->hue_range_color_area[i - 1]); gtk_widget_show (hs_tool->hue_range_color_area[i - 1]); } g_signal_connect (button, "toggled", G_CALLBACK (hue_saturation_range_callback), hs_tool); gtk_widget_show (button); } gtk_widget_show (table); label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); spinner_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /* Create the 'Overlap' option slider */ table = gtk_table_new (3, 1, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Overlap:"), SLIDER_WIDTH, -1, config->overlap * 100.0, 0.0, 100.0, 1.0, 15.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->overlap_data = GTK_ADJUSTMENT (data); gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data)); gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data)); g_object_unref (label_group); g_object_unref (spinner_group); g_signal_connect (data, "value-changed", G_CALLBACK (hue_saturation_overlap_changed), hs_tool); frame = gimp_frame_new (_("Adjust Selected Color")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* The table containing sliders */ vbox = gtk_vbox_new (FALSE, 4); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); table = gtk_table_new (3, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); /* Create the hue scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Hue:"), SLIDER_WIDTH, -1, config->hue[config->range] * 180.0, -180.0, 180.0, 1.0, 15.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->hue_data = GTK_ADJUSTMENT (data); gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data)); gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data)); g_signal_connect (data, "value-changed", G_CALLBACK (hue_saturation_hue_changed), hs_tool); /* Create the lightness scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("_Lightness:"), SLIDER_WIDTH, -1, config->lightness[config->range] * 100.0, -100.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->lightness_data = GTK_ADJUSTMENT (data); gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data)); gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data)); g_signal_connect (data, "value-changed", G_CALLBACK (hue_saturation_lightness_changed), hs_tool); /* Create the saturation scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, _("_Saturation:"), SLIDER_WIDTH, -1, config->saturation[config->range] * 100.0, -100.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->saturation_data = GTK_ADJUSTMENT (data); gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data)); gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data)); g_signal_connect (hs_tool->saturation_data, "value-changed", G_CALLBACK (hue_saturation_saturation_changed), hs_tool); hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); button = gtk_button_new_with_mnemonic (_("R_eset Color")); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (hue_saturation_range_reset_callback), hs_tool); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio), config->range); hue_saturation_update_color_areas (hs_tool); }