GtkWidget * gimp_editor_add_stock_box (GimpEditor *editor, GType enum_type, const gchar *stock_prefix, GCallback callback, gpointer callback_data) { GtkWidget *hbox; GtkWidget *first_button; GtkIconSize button_icon_size; GtkReliefStyle button_relief; GList *children; GList *list; g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL); g_return_val_if_fail (g_type_is_a (enum_type, G_TYPE_ENUM), NULL); g_return_val_if_fail (stock_prefix != NULL, NULL); button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief); hbox = gimp_enum_stock_box_new (enum_type, stock_prefix, button_icon_size, callback, callback_data, &first_button); children = gtk_container_get_children (GTK_CONTAINER (hbox)); for (list = children; list; list = g_list_next (list)) { GtkWidget *button = list->data; g_object_ref (button); gtk_button_set_relief (GTK_BUTTON (button), button_relief); gtk_container_remove (GTK_CONTAINER (hbox), button); gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0); g_object_unref (button); } g_list_free (children); g_object_ref_sink (hbox); g_object_unref (hbox); return first_button; }
static void gimp_brush_editor_init (GimpBrushEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); GtkWidget *frame; GtkWidget *box; gint row = 0; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0); gtk_widget_show (frame); data_editor->view = gimp_view_new_full_by_types (NULL, GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH, BRUSH_VIEW_SIZE, BRUSH_VIEW_SIZE, 0, FALSE, FALSE, TRUE); gtk_widget_set_size_request (data_editor->view, -1, BRUSH_VIEW_SIZE); gimp_view_set_expand (GIMP_VIEW (data_editor->view), TRUE); gtk_container_add (GTK_CONTAINER (frame), data_editor->view); gtk_widget_show (data_editor->view); editor->shape_group = NULL; /* table for sliders/labels */ editor->options_table = gtk_table_new (4, 3, FALSE); gtk_table_set_row_spacings (GTK_TABLE (editor->options_table), 2); gtk_table_set_col_spacings (GTK_TABLE (editor->options_table), 2); gtk_box_pack_start (GTK_BOX (editor), editor->options_table, FALSE, FALSE, 0); gtk_widget_show (editor->options_table); /* Stock Box for the brush shape */ box = gimp_enum_stock_box_new (GIMP_TYPE_BRUSH_GENERATED_SHAPE, "gimp-shape", GTK_ICON_SIZE_MENU, G_CALLBACK (gimp_brush_editor_update_shape), editor, &editor->shape_group); gimp_table_attach_aligned (GTK_TABLE (editor->options_table), 0, row++, _("Shape:"), 0.0, 0.5, box, 2, TRUE); gtk_widget_show (box); /* brush radius scale */ editor->radius_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Radius:"), -1, 5, 0.0, 0.1, 1000.0, 0.1, 1.0, 1, TRUE, 0.0, 0.0, NULL, NULL)); gimp_scale_entry_set_logarithmic (GTK_OBJECT (editor->radius_data), TRUE); g_signal_connect (editor->radius_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* number of spikes */ editor->spikes_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Spikes:"), -1, 5, 2.0, 2.0, 20.0, 1.0, 1.0, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (editor->spikes_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush hardness scale */ editor->hardness_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Hardness:"), -1, 5, 0.0, 0.0, 1.0, 0.01, 0.1, 2, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (editor->hardness_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush aspect ratio scale */ editor->aspect_ratio_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Aspect ratio:"), -1, 5, 0.0, 1.0, 20.0, 0.1, 1.0, 1, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (editor->aspect_ratio_data,"value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush angle scale */ editor->angle_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Angle:"), -1, 5, 0.0, 0.0, 180.0, 0.1, 1.0, 1, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (editor->angle_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush spacing */ editor->spacing_data = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (editor->options_table), 0, row++, _("Spacing:"), -1, 5, 0.0, 1.0, 200.0, 1.0, 10.0, 1, FALSE, 1.0, 5000.0, _("Percentage of width of brush"), NULL)); g_signal_connect (editor->spacing_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); }
static void gimp_brush_editor_init (GimpBrushEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); GtkWidget *frame; GtkWidget *hbox; GtkWidget *label; GtkWidget *box; GtkWidget *scale; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0); gtk_widget_show (frame); data_editor->view = gimp_view_new_full_by_types (NULL, GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH, BRUSH_VIEW_SIZE, BRUSH_VIEW_SIZE, 0, FALSE, FALSE, TRUE); gtk_widget_set_size_request (data_editor->view, -1, BRUSH_VIEW_SIZE); gimp_view_set_expand (GIMP_VIEW (data_editor->view), TRUE); gtk_container_add (GTK_CONTAINER (frame), data_editor->view); gtk_widget_show (data_editor->view); editor->shape_group = NULL; editor->options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (GTK_BOX (editor), editor->options_box, FALSE, FALSE, 0); gtk_widget_show (editor->options_box); /* Stock Box for the brush shape */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (editor->options_box), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Shape:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); box = gimp_enum_stock_box_new (GIMP_TYPE_BRUSH_GENERATED_SHAPE, "gimp-shape", GTK_ICON_SIZE_MENU, G_CALLBACK (gimp_brush_editor_update_shape), editor, &editor->shape_group); gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0); gtk_widget_show (box); /* brush radius scale */ editor->radius_data = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.1, 1000.0, 0.1, 1.0, 0.0)); scale = gimp_spin_scale_new (editor->radius_data, _("Radius"), 1); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); g_signal_connect (editor->radius_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* number of spikes */ editor->spikes_data = GTK_ADJUSTMENT (gtk_adjustment_new (2.0, 2.0, 20.0, 1.0, 1.0, 0.0)); scale = gimp_spin_scale_new (editor->spikes_data, _("Spikes"), 0); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); g_signal_connect (editor->spikes_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush hardness scale */ editor->hardness_data = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.1, 0.0)); scale = gimp_spin_scale_new (editor->hardness_data, _("Hardness"), 2); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); g_signal_connect (editor->hardness_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush aspect ratio scale */ editor->aspect_ratio_data = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 20.0, 0.1, 1.0, 0.0)); scale = gimp_spin_scale_new (editor->aspect_ratio_data, _("Aspect ratio"), 1); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); g_signal_connect (editor->aspect_ratio_data,"value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush angle scale */ editor->angle_data = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 180.0, 0.1, 1.0, 0.0)); scale = gimp_spin_scale_new (editor->angle_data, _("Angle"), 1); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); g_signal_connect (editor->angle_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); /* brush spacing */ editor->spacing_data = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 5000.0, 1.0, 10.0, 0.0)); scale = gimp_spin_scale_new (editor->spacing_data, _("Spacing"), 1); gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 200.0); gtk_box_pack_start (GTK_BOX (editor->options_box), scale, FALSE, FALSE, 0); gtk_widget_show (scale); gimp_help_set_help_data (scale, _("Percentage of width of brush"), NULL); g_signal_connect (editor->spacing_data, "value-changed", G_CALLBACK (gimp_brush_editor_update_brush), editor); }