[gimp] app: add a brush selector to the MyPaint brush options
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add a brush selector to the MyPaint brush options
- Date: Mon, 28 Dec 2015 19:05:00 +0000 (UTC)
commit 8fa6e261d0a737d5826da94795bb882c729fd441
Author: Michael Natterer <mitch gimp org>
Date: Mon Dec 28 20:04:29 2015 +0100
app: add a brush selector to the MyPaint brush options
app/tools/gimpmybrushoptions-gui.c | 9 ++++
app/widgets/gimpviewablebox.c | 75 ++++++++++++++++++++++++++++++++++--
app/widgets/gimpviewablebox.h | 11 +++++
3 files changed, 91 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimpmybrushoptions-gui.c b/app/tools/gimpmybrushoptions-gui.c
index ac78765..109d0c4 100644
--- a/app/tools/gimpmybrushoptions-gui.c
+++ b/app/tools/gimpmybrushoptions-gui.c
@@ -33,6 +33,7 @@
#include "paint/gimpmybrushoptions.h"
#include "widgets/gimppropwidgets.h"
+#include "widgets/gimpviewablebox.h"
#include "gimpmybrushoptions-gui.h"
#include "gimppaintoptions-gui.h"
@@ -45,8 +46,16 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
+ GtkWidget *button;
GtkWidget *scale;
+ /* the brush */
+ button = gimp_prop_mybrush_box_new (NULL, GIMP_CONTEXT (tool_options),
+ _("Brush"), 2,
+ NULL, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
/* radius */
scale = gimp_prop_spin_scale_new (config, "radius",
_("Radius"),
diff --git a/app/widgets/gimpviewablebox.c b/app/widgets/gimpviewablebox.c
index 28da83e..6fdc7b0 100644
--- a/app/widgets/gimpviewablebox.c
+++ b/app/widgets/gimpviewablebox.c
@@ -133,6 +133,7 @@ gimp_prop_brush_box_new (GimpContainer *container,
view_type_prop, view_size_prop);
}
+
/* dynamics boxes */
static GtkWidget *
@@ -198,6 +199,69 @@ gimp_prop_dynamics_box_new (GimpContainer *container,
}
+/* brush boxes */
+
+static GtkWidget *
+mybrush_box_new (GimpContainer *container,
+ GimpContext *context,
+ const gchar *label,
+ gint spacing,
+ GimpViewType view_type,
+ GimpViewSize view_size)
+{
+ if (! container)
+ container = gimp_data_factory_get_container (context->gimp->mybrush_factory);
+
+ return gimp_viewable_box_new (container, context, label, spacing,
+ view_type, GIMP_VIEW_SIZE_LARGE, view_size,
+ "gimp-mypaint-brush-grid|gimp-mypaint-brush-list",
+ GIMP_STOCK_BRUSH,
+ _("Open the MyPaint brush selection dialog"),
+ NULL);
+}
+
+GtkWidget *
+gimp_mybrush_box_new (GimpContainer *container,
+ GimpContext *context,
+ const gchar *label,
+ gint spacing)
+{
+ g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
+ NULL);
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+ return mybrush_box_new (container, context, label, spacing,
+ GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_LARGE);
+}
+
+GtkWidget *
+gimp_prop_mybrush_box_new (GimpContainer *container,
+ GimpContext *context,
+ const gchar *label,
+ gint spacing,
+ const gchar *view_type_prop,
+ const gchar *view_size_prop)
+{
+ GimpViewType view_type = GIMP_VIEW_TYPE_GRID;
+ GimpViewSize view_size = GIMP_VIEW_SIZE_LARGE;
+
+ g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
+ NULL);
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+ if (view_type_prop && view_size_prop)
+ g_object_get (context,
+ view_type_prop, &view_type,
+ view_size_prop, &view_size,
+ NULL);
+
+ return view_props_connect (mybrush_box_new (container, context, label, spacing,
+ view_type, view_size),
+ context,
+ view_type_prop, view_size_prop);
+}
+
+
/* pattern boxes */
static GtkWidget *
@@ -614,10 +678,13 @@ view_props_connect (GtkWidget *box,
{
GtkWidget *button = g_object_get_data (G_OBJECT (box), "viewable-button");
- gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
- view_type_prop, "popup-view-type");
- gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
- view_size_prop, "popup-view-size");
+ if (view_type_prop)
+ gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
+ view_type_prop, "popup-view-type");
+
+ if (view_size_prop)
+ gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
+ view_size_prop, "popup-view-size");
return box;
}
diff --git a/app/widgets/gimpviewablebox.h b/app/widgets/gimpviewablebox.h
index a3838fc..f434d73 100644
--- a/app/widgets/gimpviewablebox.h
+++ b/app/widgets/gimpviewablebox.h
@@ -42,6 +42,17 @@ GtkWidget * gimp_prop_dynamics_box_new (GimpContainer *container,
const gchar *view_size_prop,
const gchar *editor_id);
+GtkWidget * gimp_mybrush_box_new (GimpContainer *container,
+ GimpContext *context,
+ const gchar *label,
+ gint spacing);
+GtkWidget * gimp_prop_mybrush_box_new (GimpContainer *container,
+ GimpContext *context,
+ const gchar *label,
+ gint spacing,
+ const gchar *view_type_prop,
+ const gchar *view_size_prop);
+
GtkWidget * gimp_pattern_box_new (GimpContainer *container,
GimpContext *context,
const gchar *label,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]