Commit 0c784559 authored by Michael Natterer's avatar Michael Natterer 😴

app: improve the layout of GimpBufferSourceBox

and add a label with the selected pickable's name.
parent 16a04218
......@@ -624,6 +624,7 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *icon_name)
{
GimpImageMapTool *im_tool;
GtkSizeGroup *size_group = NULL;
gint aux;
g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool));
......@@ -685,7 +686,11 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (gegl_node_has_pad (im_tool->operation, pad))
{
AuxInput *input;
AuxInput *input;
GtkWidget *toggle;
if (! size_group)
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
input = gimp_operation_tool_aux_input_new (tool,
im_tool->operation, pad,
......@@ -693,6 +698,9 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
tool->aux_inputs = g_list_append (tool->aux_inputs, input);
toggle = gimp_buffer_source_box_get_toggle (GIMP_BUFFER_SOURCE_BOX (input->box));
gtk_size_group_add_widget (size_group, toggle);
if (tool->options_box)
{
gtk_box_pack_start (GTK_BOX (tool->options_box), input->box,
......@@ -706,6 +714,9 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
}
}
if (size_group)
g_object_unref (size_group);
if (im_tool->config)
{
tool->options_gui =
......
......@@ -35,13 +35,15 @@
#include "gimpbuffersourcebox.h"
#include "gimppickablebutton.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_CONTEXT,
PROP_SOURCE_NODE,
PROP_LABEL,
PROP_NAME,
PROP_PICKABLE,
PROP_ENABLED
};
......@@ -50,12 +52,13 @@ struct _GimpBufferSourceBoxPrivate
{
GimpContext *context;
GeglNode *source_node;
gchar *label;
gchar *name;
GimpPickable *pickable;
gboolean enabled;
GtkWidget *button;
GtkWidget *toggle;
GtkWidget *button;
GtkWidget *label;
};
......@@ -105,8 +108,8 @@ gimp_buffer_source_box_class_init (GimpBufferSourceBoxClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_LABEL,
g_param_spec_string ("label", NULL, NULL,
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name", NULL, NULL,
NULL,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
......@@ -135,17 +138,23 @@ gimp_buffer_source_box_init (GimpBufferSourceBox *box)
gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
GTK_ORIENTATION_HORIZONTAL);
gtk_box_set_spacing (GTK_BOX (box), 2);
}
static void
gimp_buffer_source_box_constructed (GObject *object)
{
GimpBufferSourceBox *box = GIMP_BUFFER_SOURCE_BOX (object);
GtkWidget *alignment;
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (box), alignment, FALSE, FALSE, 0);
gtk_widget_show (alignment);
box->priv->toggle = gtk_check_button_new_with_mnemonic (box->priv->label);
box->priv->toggle = gtk_check_button_new_with_mnemonic (box->priv->name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->priv->toggle),
box->priv->enabled);
gtk_box_pack_start (GTK_BOX (box), box->priv->toggle, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), box->priv->toggle);
gtk_widget_show (box->priv->toggle);
g_signal_connect_object (box->priv->toggle, "toggled",
......@@ -159,6 +168,12 @@ gimp_buffer_source_box_constructed (GObject *object)
gtk_box_pack_start (GTK_BOX (box), box->priv->button, FALSE, FALSE, 0);
gtk_widget_show (box->priv->button);
box->priv->label = gtk_label_new (_("(none)"));
gtk_misc_set_alignment (GTK_MISC (box->priv->label), 0.0, 0.5);
gtk_label_set_ellipsize (GTK_LABEL (box->priv->label), PANGO_ELLIPSIZE_END);
gtk_box_pack_start (GTK_BOX (box), box->priv->label, TRUE, TRUE, 0);
gtk_widget_show (box->priv->label);
g_signal_connect_object (box->priv->button, "notify::pickable",
G_CALLBACK (gimp_buffer_source_box_notify_pickable),
box, 0);
......@@ -183,10 +198,10 @@ gimp_buffer_source_box_finalize (GObject *object)
box->priv->source_node = NULL;
}
if (box->priv->label)
if (box->priv->name)
{
g_free (box->priv->label);
box->priv->label = NULL;
g_free (box->priv->name);
box->priv->name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -210,8 +225,8 @@ gimp_buffer_source_box_set_property (GObject *object,
box->priv->source_node = g_value_dup_object (value);
break;
case PROP_LABEL:
box->priv->label = g_value_dup_string (value);
case PROP_NAME:
box->priv->name = g_value_dup_string (value);
break;
case PROP_PICKABLE:
......@@ -252,8 +267,8 @@ gimp_buffer_source_box_get_property (GObject *object,
g_value_set_object (value, box->priv->source_node);
break;
case PROP_LABEL:
g_value_set_string (value, box->priv->label);
case PROP_NAME:
g_value_set_string (value, box->priv->name);
break;
case PROP_PICKABLE:
......@@ -275,9 +290,23 @@ gimp_buffer_source_box_update_node (GimpBufferSourceBox *box)
{
GeglBuffer *buffer = NULL;
if (box->priv->pickable && box->priv->enabled)
if (box->priv->pickable)
{
gchar *desc;
if (box->priv->enabled)
{
buffer = gimp_pickable_get_buffer (box->priv->pickable);
}
desc = gimp_viewable_get_description (GIMP_VIEWABLE (box->priv->pickable),
NULL);
gtk_label_set_text (GTK_LABEL (box->priv->label), desc);
g_free (desc);
}
else
{
buffer = gimp_pickable_get_buffer (box->priv->pickable);
gtk_label_set_text (GTK_LABEL (box->priv->label), _("(none)"));
}
gegl_node_set (box->priv->source_node,
......@@ -314,15 +343,23 @@ gimp_buffer_source_box_enable_toggled (GtkToggleButton *button,
GtkWidget *
gimp_buffer_source_box_new (GimpContext *context,
GeglNode *source_node,
const gchar *label)
const gchar *name)
{
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GEGL_IS_NODE (source_node), NULL);
g_return_val_if_fail (label != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
return g_object_new (GIMP_TYPE_BUFFER_SOURCE_BOX,
"context", context,
"source-node", source_node,
"label", label,
"name", name,
NULL);
}
GtkWidget *
gimp_buffer_source_box_get_toggle (GimpBufferSourceBox *box)
{
g_return_val_if_fail (GIMP_IS_BUFFER_SOURCE_BOX (box), NULL);
return box->priv->toggle;
}
......@@ -48,9 +48,11 @@ struct _GimpBufferSourceBoxClass
GType gimp_buffer_source_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_buffer_source_box_new (GimpContext *context,
GeglNode *source_node,
const gchar *label);
GtkWidget * gimp_buffer_source_box_new (GimpContext *context,
GeglNode *source_node,
const gchar *name);
GtkWidget * gimp_buffer_source_box_get_toggle (GimpBufferSourceBox *box);
#endif /* __GIMP_BUFFER_SOURCE_BOX_H__ */
......@@ -441,6 +441,7 @@ app/widgets/gimpactionview.c
app/widgets/gimpbrusheditor.c
app/widgets/gimpbrushfactoryview.c
app/widgets/gimpbrushselect.c
app/widgets/gimpbuffersourcebox.c
app/widgets/gimpbufferview.c
app/widgets/gimpchanneltreeview.c
app/widgets/gimpclipboard.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment