Compare commits
No commits in common. "64508104bc6e60a05770a9130e478710b17077a4" and "19b26a3c26ffe503bfb7c772888abd43719dbcfa" have entirely different histories.
64508104bc
...
19b26a3c26
@ -59,61 +59,6 @@ static GtkTargetEntry entries[] = {
|
||||
{ "GTK_LIST_BOX_ROW", GTK_TARGET_SAME_APP, 0 }
|
||||
};
|
||||
|
||||
static void sel_layer_element_drag_begin(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *row;
|
||||
GtkAllocation alloc;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int x, y;
|
||||
(void)data;
|
||||
|
||||
row = gtk_widget_get_ancestor(widget, GTK_TYPE_LIST_BOX_ROW);
|
||||
gtk_widget_get_allocation(row, &alloc);
|
||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, alloc.width, alloc.height);
|
||||
cr = cairo_create(surface);
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context(row), "drag-icon");
|
||||
gtk_widget_draw (row, cr);
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-icon");
|
||||
|
||||
gtk_widget_translate_coordinates (widget, row, 0, 0, &x, &y);
|
||||
cairo_surface_set_device_offset (surface, -x, -y);
|
||||
gtk_drag_set_icon_surface (context, surface);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
g_object_set_data(G_OBJECT(gtk_widget_get_parent(row)), "drag-row", row);
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(row), "drag-row");
|
||||
}
|
||||
|
||||
static void sel_layer_element_drag_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
|
||||
{
|
||||
GtkWidget *row;
|
||||
(void)context;
|
||||
(void)data;
|
||||
|
||||
row = gtk_widget_get_ancestor(widget, GTK_TYPE_LIST_BOX_ROW);
|
||||
g_object_set_data(G_OBJECT(gtk_widget_get_parent(row)), "drag-row", NULL);
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-row");
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-hover");
|
||||
}
|
||||
|
||||
static void sel_layer_element_drag_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
guint info, guint time, gpointer data)
|
||||
{
|
||||
(void)context;
|
||||
(void)info;
|
||||
(void)time;
|
||||
(void)data;
|
||||
|
||||
gtk_selection_data_set(selection_data, gdk_atom_intern_static_string("GTK_LIST_BOX_ROW"),
|
||||
32, (const guchar *)&widget, sizeof(gpointer));
|
||||
}
|
||||
|
||||
static GtkListBoxRow *layer_selector_get_last_row (GtkListBox *list)
|
||||
{
|
||||
int i;
|
||||
@ -439,14 +384,6 @@ static gboolean layer_selector_check_if_layer_widget_exists(LayerSelector *self,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void sel_layer_element_setup_dnd_callbacks(LayerElement *element)
|
||||
{
|
||||
layer_element_set_dnd_callbacks(element, entries, 1,
|
||||
sel_layer_element_drag_begin,
|
||||
sel_layer_element_drag_data_get,
|
||||
sel_layer_element_drag_end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Analyze \p cell and append used layers to list box
|
||||
* @param listbox listbox to add layer
|
||||
@ -464,7 +401,6 @@ static void layer_selector_analyze_cell_layers(LayerSelector *self, struct gds_c
|
||||
layer = (int)gfx->layer;
|
||||
if (layer_selector_check_if_layer_widget_exists(self, layer) == FALSE) {
|
||||
le = layer_element_new();
|
||||
sel_layer_element_setup_dnd_callbacks(LAYER_ELEMENT(le));
|
||||
layer_element_set_layer(LAYER_ELEMENT(le), layer);
|
||||
gtk_list_box_insert(self->list_box, le, -1);
|
||||
gtk_widget_show(le);
|
||||
@ -741,7 +677,7 @@ void layer_selector_force_sort(LayerSelector *selector, enum layer_selector_sort
|
||||
if (!box)
|
||||
return;
|
||||
|
||||
/* Set sorting function, sort, and disable sorting function */
|
||||
/* Set dorting function, sort, and disable sorting function */
|
||||
gtk_list_box_set_sort_func(box, layer_selector_sort_func, (gpointer)&sort_function, NULL);
|
||||
gtk_list_box_invalidate_sort(box);
|
||||
gtk_list_box_set_sort_func(box, NULL, NULL, NULL);
|
||||
|
2
main.c
2
main.c
@ -38,7 +38,7 @@ static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_d
|
||||
GList *list_iter;
|
||||
GdsRenderGui *gui;
|
||||
|
||||
/* Dispose all GUIs */
|
||||
/* Dispose all Guis */
|
||||
for (list_iter = appdata->gui_list; list_iter != NULL; list_iter = g_list_next(list_iter)) {
|
||||
gui = RENDERER_GUI(list_iter->data);
|
||||
g_object_unref(gui);
|
||||
|
@ -57,6 +57,65 @@ static void layer_element_class_init(LayerElementClass *klass)
|
||||
oclass->constructed = layer_element_constructed;
|
||||
}
|
||||
|
||||
static GtkTargetEntry entries[] = {
|
||||
{ "GTK_LIST_BOX_ROW", GTK_TARGET_SAME_APP, 0 }
|
||||
};
|
||||
|
||||
static void layer_element_drag_begin(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *row;
|
||||
GtkAllocation alloc;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int x, y;
|
||||
(void)data;
|
||||
|
||||
row = gtk_widget_get_ancestor(widget, GTK_TYPE_LIST_BOX_ROW);
|
||||
gtk_widget_get_allocation(row, &alloc);
|
||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, alloc.width, alloc.height);
|
||||
cr = cairo_create(surface);
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context(row), "drag-icon");
|
||||
gtk_widget_draw (row, cr);
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-icon");
|
||||
|
||||
gtk_widget_translate_coordinates (widget, row, 0, 0, &x, &y);
|
||||
cairo_surface_set_device_offset (surface, -x, -y);
|
||||
gtk_drag_set_icon_surface (context, surface);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
g_object_set_data(G_OBJECT(gtk_widget_get_parent(row)), "drag-row", row);
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(row), "drag-row");
|
||||
}
|
||||
|
||||
static void layer_element_drag_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
|
||||
{
|
||||
GtkWidget *row;
|
||||
(void)context;
|
||||
(void)data;
|
||||
|
||||
row = gtk_widget_get_ancestor(widget, GTK_TYPE_LIST_BOX_ROW);
|
||||
g_object_set_data(G_OBJECT(gtk_widget_get_parent(row)), "drag-row", NULL);
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-row");
|
||||
gtk_style_context_remove_class(gtk_widget_get_style_context(row), "drag-hover");
|
||||
}
|
||||
|
||||
static void layer_element_drag_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
guint info, guint time, gpointer data)
|
||||
{
|
||||
(void)context;
|
||||
(void)info;
|
||||
(void)time;
|
||||
(void)data;
|
||||
|
||||
gtk_selection_data_set(selection_data, gdk_atom_intern_static_string("GTK_LIST_BOX_ROW"),
|
||||
32, (const guchar *)&widget, sizeof(gpointer));
|
||||
}
|
||||
|
||||
static void layer_element_init(LayerElement *self)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
@ -72,6 +131,13 @@ static void layer_element_init(LayerElement *self)
|
||||
self->priv.name = GTK_ENTRY(gtk_builder_get_object(builder, "entry"));
|
||||
self->priv.event_handle = GTK_EVENT_BOX(gtk_builder_get_object(builder, "event-box"));
|
||||
|
||||
/* Setup drag and drop */
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context(GTK_WIDGET(self)), "row");
|
||||
gtk_drag_source_set(GTK_WIDGET(self->priv.event_handle), GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
|
||||
g_signal_connect(self->priv.event_handle, "drag-begin", G_CALLBACK(layer_element_drag_begin), NULL);
|
||||
g_signal_connect(self->priv.event_handle, "drag-data-get", G_CALLBACK(layer_element_drag_data_get), NULL);
|
||||
g_signal_connect(self->priv.event_handle, "drag-end", G_CALLBACK(layer_element_drag_end), NULL);
|
||||
|
||||
g_object_unref(builder);
|
||||
}
|
||||
|
||||
@ -128,19 +194,4 @@ void layer_element_set_color(LayerElement *elem, GdkRGBA *rgba)
|
||||
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(elem->priv.color), rgba);
|
||||
}
|
||||
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, GtkTargetEntry *entries, int entry_count,
|
||||
void (*drag_begin)(GtkWidget *, GdkDragContext *, gpointer),
|
||||
void (*drag_data_get)(GtkWidget *, GdkDragContext *,
|
||||
GtkSelectionData *, guint , guint, gpointer),
|
||||
void (*drag_end)(GtkWidget *, GdkDragContext *, gpointer))
|
||||
{
|
||||
/* Setup drag and drop */
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context(GTK_WIDGET(elem)), "row");
|
||||
gtk_drag_source_set(GTK_WIDGET(elem->priv.event_handle), GDK_BUTTON1_MASK, entries, entry_count, GDK_ACTION_MOVE);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-begin", G_CALLBACK(drag_begin), NULL);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-data-get", G_CALLBACK(drag_data_get), NULL);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-end", G_CALLBACK(drag_end), NULL);
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -118,18 +118,6 @@ void layer_element_get_color(LayerElement *elem, GdkRGBA *rgba);
|
||||
*/
|
||||
void layer_element_set_color(LayerElement *elem, GdkRGBA *rgba);
|
||||
|
||||
/**
|
||||
* @brief layer_element_set_dnd_callbacks
|
||||
* @param elem
|
||||
* @param entries
|
||||
* @param entry_count
|
||||
*/
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, GtkTargetEntry *entries, int entry_count,
|
||||
void (*drag_begin)(GtkWidget *, GdkDragContext *, gpointer),
|
||||
void (*drag_data_get)(GtkWidget *, GdkDragContext *,
|
||||
GtkSelectionData *, guint , guint, gpointer),
|
||||
void (*drag_end)(GtkWidget *, GdkDragContext *, gpointer));
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LAYER_ELEMENT_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user