40#include <glib/gi18n.h>
42G_DEFINE_TYPE(LayerElement, layer_element, GTK_TYPE_LIST_BOX_ROW)
47 G_OBJECT_CLASS(layer_element_parent_class)->dispose(obj);
52 G_OBJECT_CLASS(layer_element_parent_class)->constructed(obj);
57 GObjectClass *oclass = G_OBJECT_CLASS(klass);
68 builder = gtk_builder_new_from_resource(
"/gui/layer-widget.glade");
69 glade_box = GTK_WIDGET(gtk_builder_get_object(builder,
"box"));
70 gtk_container_add(GTK_CONTAINER(self), glade_box);
73 self->priv.color = GTK_COLOR_BUTTON(gtk_builder_get_object(builder,
"color"));
74 self->priv.export = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
"export"));
75 self->priv.layer = GTK_LABEL(gtk_builder_get_object(builder,
"layer"));
76 self->priv.name = GTK_ENTRY(gtk_builder_get_object(builder,
"entry"));
77 self->priv.event_handle = GTK_EVENT_BOX(gtk_builder_get_object(builder,
"event-box"));
79 g_object_unref(builder);
89 return gtk_entry_get_text(elem->priv.name);
94 gtk_entry_set_text(elem->priv.name, name);
101 string = g_string_new_len(NULL, 100);
102 g_string_printf(
string, _(
"Layer: %d"), layer);
103 gtk_label_set_text(elem->priv.layer, (
const gchar *)string->str);
104 elem->priv.layer_num = layer;
105 g_string_free(
string, TRUE);
110 return elem->priv.layer_num;
115 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(elem->priv.export), export);
120 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(elem->priv.export));
128 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(elem->priv.color), rgba);
136 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(elem->priv.color), rgba);
145 gtk_style_context_add_class(gtk_widget_get_style_context(GTK_WIDGET(elem)),
"row");
146 gtk_drag_source_set(GTK_WIDGET(elem->priv.event_handle), GDK_BUTTON1_MASK,
148 g_signal_connect(elem->priv.event_handle,
"drag-begin", G_CALLBACK(data->
drag_begin), NULL);
149 g_signal_connect(elem->priv.event_handle,
"drag-data-get", G_CALLBACK(data->
drag_data_get), NULL);
150 g_signal_connect(elem->priv.event_handle,
"drag-end", G_CALLBACK(data->
drag_end), NULL);
const char * layer_element_get_name(LayerElement *elem)
get name of the layer
static void layer_element_constructed(GObject *obj)
void layer_element_set_color(LayerElement *elem, GdkRGBA *rgba)
Set color of layer.
static void layer_element_init(LayerElement *self)
static void layer_element_class_init(LayerElementClass *klass)
static void layer_element_dispose(GObject *obj)
int layer_element_get_layer(LayerElement *elem)
Get layer number.
void layer_element_set_layer(LayerElement *elem, int layer)
Set layer number for this layer.
#define TYPE_LAYER_ELEMENT
void layer_element_get_color(LayerElement *elem, GdkRGBA *rgba)
Get color of layer.
void layer_element_set_name(LayerElement *elem, const char *name)
layer_element_set_name
void layer_element_set_dnd_callbacks(LayerElement *elem, struct layer_element_dnd_data *data)
Setup drag and drop of elem for use in the LayerSelector.
void layer_element_set_export(LayerElement *elem, gboolean export)
Set export flag for this layer.
gboolean layer_element_get_export(LayerElement *elem)
Get export flag of layer.
GtkWidget * layer_element_new(void)
Create new layer element object.
Implementation of the layer element used for configuring layer colors etc.
This structure holds the necessary data to set up a LayerElement for Drag'n'Drop.
void(* drag_data_get)(GtkWidget *, GdkDragContext *, GtkSelectionData *, guint, guint, gpointer)
Callback fucktion for data_get event.
GtkTargetEntry * entries
Array of target entries for the DnD operation.
void(* drag_begin)(GtkWidget *, GdkDragContext *, gpointer)
Callback function for drag_begin event.
void(* drag_end)(GtkWidget *, GdkDragContext *, gpointer)
Callback function for drag_end event.
int entry_count
Count of elements in layer_element_dnd_data::entries array.