2015-12-11 15:44:46 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2018-03-16 03:29:42 +00:00
|
|
|
static GdkPaintable *
|
|
|
|
get_image_paintable (GtkImage *image,
|
|
|
|
int *out_size)
|
2015-12-11 15:44:46 +00:00
|
|
|
{
|
|
|
|
GtkIconTheme *icon_theme;
|
2017-11-15 00:43:13 +00:00
|
|
|
const char *icon_name;
|
2017-11-15 04:30:58 +00:00
|
|
|
int width = 48;
|
2018-03-16 03:29:42 +00:00
|
|
|
GdkPaintable *paintable;
|
2018-03-15 01:59:03 +00:00
|
|
|
GtkIconInfo *icon_info;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
|
|
|
switch (gtk_image_get_storage_type (image))
|
|
|
|
{
|
2018-03-15 01:59:03 +00:00
|
|
|
case GTK_IMAGE_PAINTABLE:
|
|
|
|
paintable = gtk_image_get_paintable (image);
|
|
|
|
*out_size = gdk_paintable_get_intrinsic_width (paintable);
|
|
|
|
return g_object_ref (paintable);
|
2015-12-11 15:44:46 +00:00
|
|
|
case GTK_IMAGE_ICON_NAME:
|
2017-01-22 21:58:45 +00:00
|
|
|
icon_name = gtk_image_get_icon_name (image);
|
2017-10-31 01:59:06 +00:00
|
|
|
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
|
2017-10-23 03:27:01 +00:00
|
|
|
*out_size = width;
|
2018-03-15 01:59:03 +00:00
|
|
|
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, width, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
2018-03-16 03:29:42 +00:00
|
|
|
paintable = GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info));
|
2018-03-15 01:59:03 +00:00
|
|
|
g_object_unref (icon_info);
|
2018-03-16 03:29:42 +00:00
|
|
|
return paintable;
|
2015-12-11 15:44:46 +00:00
|
|
|
default:
|
|
|
|
g_warning ("Image storage type %d not handled",
|
|
|
|
gtk_image_get_storage_type (image));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
TOP_LEFT,
|
|
|
|
CENTER,
|
|
|
|
BOTTOM_RIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_drag_begin (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-11 15:44:46 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2018-03-16 03:29:42 +00:00
|
|
|
GdkPaintable *paintable;
|
2015-12-11 15:44:46 +00:00
|
|
|
gint hotspot;
|
|
|
|
gint hot_x, hot_y;
|
2017-10-23 03:27:01 +00:00
|
|
|
gint size;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2018-03-16 03:29:42 +00:00
|
|
|
paintable = get_image_paintable (GTK_IMAGE (data), &size);
|
2015-12-11 15:44:46 +00:00
|
|
|
hotspot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data), "hotspot"));
|
|
|
|
switch (hotspot)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case TOP_LEFT:
|
|
|
|
hot_x = 0;
|
|
|
|
hot_y = 0;
|
|
|
|
break;
|
|
|
|
case CENTER:
|
2017-10-23 03:27:01 +00:00
|
|
|
hot_x = size / 2;
|
|
|
|
hot_y = size / 2;
|
2015-12-11 15:44:46 +00:00
|
|
|
break;
|
|
|
|
case BOTTOM_RIGHT:
|
2017-10-23 03:27:01 +00:00
|
|
|
hot_x = size;
|
|
|
|
hot_y = size;
|
2015-12-11 15:44:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-06-29 17:34:14 +00:00
|
|
|
gtk_drag_set_icon_paintable (drag, paintable, hot_x, hot_y);
|
2018-03-16 03:29:42 +00:00
|
|
|
g_object_unref (paintable);
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
2016-04-27 00:34:24 +00:00
|
|
|
static void
|
2017-04-25 16:47:42 +00:00
|
|
|
drag_widget_destroyed (GtkWidget *image, gpointer data)
|
2016-04-27 00:34:24 +00:00
|
|
|
{
|
|
|
|
GtkWidget *widget = data;
|
|
|
|
|
|
|
|
g_print ("drag widget destroyed\n");
|
2017-04-25 16:47:42 +00:00
|
|
|
g_object_unref (image);
|
|
|
|
g_object_set_data (G_OBJECT (widget), "drag widget", NULL);
|
2016-04-27 00:34:24 +00:00
|
|
|
}
|
|
|
|
|
2016-04-21 18:21:14 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
window_drag_end (GtkWidget *widget,
|
|
|
|
GdkDrag *drag,
|
|
|
|
gpointer data)
|
2016-04-21 18:21:14 +00:00
|
|
|
{
|
|
|
|
GtkWidget *window = data;
|
|
|
|
|
|
|
|
gtk_widget_destroy (window);
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (widget, window_drag_end, data);
|
2016-04-21 18:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
window_drag_begin (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2016-04-21 18:21:14 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2018-03-16 03:29:42 +00:00
|
|
|
GdkPaintable *paintable;
|
2016-04-21 18:21:14 +00:00
|
|
|
GtkWidget *image;
|
2016-04-26 04:19:02 +00:00
|
|
|
int hotspot;
|
2017-10-23 03:27:01 +00:00
|
|
|
int size;
|
2016-04-26 04:19:02 +00:00
|
|
|
|
|
|
|
hotspot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data), "hotspot"));
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2017-04-25 16:47:42 +00:00
|
|
|
image = g_object_get_data (G_OBJECT (widget), "drag widget");
|
|
|
|
if (image == NULL)
|
2016-04-26 04:19:02 +00:00
|
|
|
{
|
2016-04-27 00:34:24 +00:00
|
|
|
g_print ("creating new drag widget\n");
|
2018-03-16 03:29:42 +00:00
|
|
|
paintable = get_image_paintable (GTK_IMAGE (data), &size);
|
|
|
|
image = gtk_image_new_from_paintable (paintable);
|
|
|
|
g_object_unref (paintable);
|
2017-04-25 16:47:42 +00:00
|
|
|
g_object_ref (image);
|
|
|
|
g_object_set_data (G_OBJECT (widget), "drag widget", image);
|
|
|
|
g_signal_connect (image, "destroy", G_CALLBACK (drag_widget_destroyed), widget);
|
2016-04-26 04:19:02 +00:00
|
|
|
}
|
2016-04-27 00:34:24 +00:00
|
|
|
else
|
|
|
|
g_print ("reusing drag widget\n");
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gtk_drag_set_icon_widget (drag, image, 0, 0);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2016-04-26 04:19:02 +00:00
|
|
|
if (hotspot == CENTER)
|
2017-04-25 16:47:42 +00:00
|
|
|
g_signal_connect (widget, "drag-end", G_CALLBACK (window_drag_end), image);
|
2016-04-21 18:21:14 +00:00
|
|
|
}
|
|
|
|
|
2015-12-11 15:44:46 +00:00
|
|
|
static void
|
2017-08-01 22:49:42 +00:00
|
|
|
update_source_target_list (GtkWidget *image)
|
2015-12-11 15:44:46 +00:00
|
|
|
{
|
2017-11-18 01:19:53 +00:00
|
|
|
GdkContentFormats *target_list;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-18 01:19:53 +00:00
|
|
|
target_list = gdk_content_formats_new (NULL, 0);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-20 02:54:42 +00:00
|
|
|
target_list = gtk_content_formats_add_image_targets (target_list, FALSE);
|
2015-12-11 15:44:46 +00:00
|
|
|
if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME)
|
2017-11-20 02:54:42 +00:00
|
|
|
target_list = gtk_content_formats_add_text_targets (target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
gtk_drag_source_set_target_list (image, target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-18 01:19:53 +00:00
|
|
|
gdk_content_formats_unref (target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-08-01 22:49:42 +00:00
|
|
|
update_dest_target_list (GtkWidget *image)
|
2015-12-11 15:44:46 +00:00
|
|
|
{
|
2017-11-18 01:19:53 +00:00
|
|
|
GdkContentFormats *target_list;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-18 01:19:53 +00:00
|
|
|
target_list = gdk_content_formats_new (NULL, 0);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-20 02:54:42 +00:00
|
|
|
target_list = gtk_content_formats_add_image_targets (target_list, FALSE);
|
|
|
|
target_list = gtk_content_formats_add_text_targets (target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
gtk_drag_dest_set_target_list (image, target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-18 01:19:53 +00:00
|
|
|
gdk_content_formats_unref (target_list);
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_drag_data_get (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-11 15:44:46 +00:00
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2018-03-16 03:29:42 +00:00
|
|
|
GdkPaintable *paintable;
|
2015-12-11 15:44:46 +00:00
|
|
|
const gchar *name;
|
2017-10-23 03:27:01 +00:00
|
|
|
int size;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-16 21:50:37 +00:00
|
|
|
if (gtk_selection_data_targets_include_image (selection_data, TRUE))
|
2015-12-11 15:44:46 +00:00
|
|
|
{
|
2018-03-16 03:29:42 +00:00
|
|
|
paintable = get_image_paintable (GTK_IMAGE (data), &size);
|
|
|
|
if (GDK_IS_TEXTURE (paintable))
|
|
|
|
gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
|
|
|
|
if (paintable)
|
|
|
|
g_object_unref (paintable);
|
2017-11-16 21:50:37 +00:00
|
|
|
}
|
|
|
|
else if (gtk_selection_data_targets_include_text (selection_data))
|
|
|
|
{
|
2016-04-21 18:21:14 +00:00
|
|
|
if (gtk_image_get_storage_type (GTK_IMAGE (data)) == GTK_IMAGE_ICON_NAME)
|
2017-01-22 21:58:45 +00:00
|
|
|
name = gtk_image_get_icon_name (GTK_IMAGE (data));
|
2016-04-21 18:21:14 +00:00
|
|
|
else
|
|
|
|
name = "Boo!";
|
2015-12-11 15:44:46 +00:00
|
|
|
gtk_selection_data_set_text (selection_data, name, -1);
|
2017-11-16 21:50:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-11 15:44:46 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_drag_data_received (GtkWidget *widget,
|
2018-05-16 02:50:24 +00:00
|
|
|
GdkDrop *drop,
|
2015-12-11 15:44:46 +00:00
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
if (gtk_selection_data_get_length (selection_data) == 0)
|
|
|
|
return;
|
|
|
|
|
2017-11-16 21:50:37 +00:00
|
|
|
if (gtk_selection_data_targets_include_image (selection_data, FALSE))
|
2015-12-11 15:44:46 +00:00
|
|
|
{
|
2018-03-15 01:59:03 +00:00
|
|
|
GdkTexture *texture;
|
|
|
|
|
|
|
|
texture = gtk_selection_data_get_texture (selection_data);
|
2018-03-16 03:29:42 +00:00
|
|
|
gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
|
2018-03-15 01:59:03 +00:00
|
|
|
|
|
|
|
g_object_unref (texture);
|
2017-11-16 21:50:37 +00:00
|
|
|
}
|
|
|
|
else if (gtk_selection_data_targets_include_text (selection_data))
|
|
|
|
{
|
2015-12-11 15:44:46 +00:00
|
|
|
text = (gchar *)gtk_selection_data_get_text (selection_data);
|
2017-11-15 00:43:13 +00:00
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (data), text);
|
2015-12-11 15:44:46 +00:00
|
|
|
g_free (text);
|
2017-11-16 21:50:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-11 15:44:46 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
make_image (const gchar *icon_name, int hotspot)
|
|
|
|
{
|
2017-08-01 22:49:42 +00:00
|
|
|
GtkWidget *image;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
image = gtk_image_new_from_icon_name (icon_name);
|
2017-11-15 02:14:47 +00:00
|
|
|
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-14 21:32:23 +00:00
|
|
|
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
2017-08-01 22:49:42 +00:00
|
|
|
update_source_target_list (image);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
|
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
|
|
|
|
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-11-14 21:32:23 +00:00
|
|
|
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
|
|
|
|
update_dest_target_list (image);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
return image;
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
2016-04-21 18:21:14 +00:00
|
|
|
GtkWidget *
|
|
|
|
make_image2 (const gchar *icon_name, int hotspot)
|
|
|
|
{
|
2017-08-01 22:49:42 +00:00
|
|
|
GtkWidget *image;
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
image = gtk_image_new_from_icon_name (icon_name);
|
2017-11-15 02:14:47 +00:00
|
|
|
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2017-11-14 21:32:23 +00:00
|
|
|
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
2017-08-01 22:49:42 +00:00
|
|
|
update_source_target_list (image);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
|
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
|
|
|
|
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2017-11-14 21:32:23 +00:00
|
|
|
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
|
|
|
|
update_dest_target_list (image);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
return image;
|
2016-04-21 18:21:14 +00:00
|
|
|
}
|
|
|
|
|
2015-12-11 15:44:46 +00:00
|
|
|
static void
|
|
|
|
spinner_drag_begin (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-11 15:44:46 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *spinner;
|
|
|
|
|
2015-12-13 21:01:05 +00:00
|
|
|
g_print ("GtkWidget::drag-begin\n");
|
2015-12-11 15:44:46 +00:00
|
|
|
spinner = g_object_new (GTK_TYPE_SPINNER,
|
|
|
|
"visible", TRUE,
|
|
|
|
"active", TRUE,
|
|
|
|
NULL);
|
2018-06-29 17:34:14 +00:00
|
|
|
gtk_drag_set_icon_widget (drag, spinner, 0, 0);
|
|
|
|
g_object_set_data (G_OBJECT (drag), "spinner", spinner);
|
2015-12-11 15:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spinner_drag_end (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-11 15:50:25 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *spinner;
|
|
|
|
|
2015-12-13 21:01:05 +00:00
|
|
|
g_print ("GtkWidget::drag-end\n");
|
2018-06-29 17:34:14 +00:00
|
|
|
spinner = g_object_get_data (G_OBJECT (drag), "spinner");
|
2015-12-11 15:50:25 +00:00
|
|
|
gtk_widget_destroy (spinner);
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 21:01:05 +00:00
|
|
|
static gboolean
|
|
|
|
spinner_drag_failed (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-13 21:01:05 +00:00
|
|
|
GtkDragResult result,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GTypeClass *class;
|
|
|
|
GEnumValue *value;
|
|
|
|
|
|
|
|
class = g_type_class_ref (GTK_TYPE_DRAG_RESULT);
|
|
|
|
value = g_enum_get_value (G_ENUM_CLASS (class), result);
|
|
|
|
g_print ("GtkWidget::drag-failed %s\n", value->value_nick);
|
|
|
|
g_type_class_unref (class);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-11 15:44:46 +00:00
|
|
|
void
|
|
|
|
spinner_drag_data_get (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2015-12-11 15:44:46 +00:00
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2015-12-13 21:01:05 +00:00
|
|
|
g_print ("GtkWidget::drag-data-get\n");
|
2015-12-11 15:44:46 +00:00
|
|
|
gtk_selection_data_set_text (selection_data, "ACTIVE", -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
make_spinner (void)
|
|
|
|
{
|
2017-08-01 22:49:42 +00:00
|
|
|
GtkWidget *spinner;
|
2015-12-11 15:44:46 +00:00
|
|
|
|
|
|
|
spinner = gtk_spinner_new ();
|
|
|
|
gtk_spinner_start (GTK_SPINNER (spinner));
|
|
|
|
|
2017-11-14 21:32:23 +00:00
|
|
|
gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
2017-08-01 22:49:42 +00:00
|
|
|
gtk_drag_source_add_text_targets (spinner);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
|
|
|
|
g_signal_connect (spinner, "drag-end", G_CALLBACK (spinner_drag_end), spinner);
|
|
|
|
g_signal_connect (spinner, "drag-failed", G_CALLBACK (spinner_drag_failed), spinner);
|
|
|
|
g_signal_connect (spinner, "drag-data-get", G_CALLBACK (spinner_drag_data_get), spinner);
|
2015-12-11 15:44:46 +00:00
|
|
|
|
2017-08-01 22:49:42 +00:00
|
|
|
return spinner;
|
2015-12-11 15:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *Argv[])
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *grid;
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2015-12-11 15:44:46 +00:00
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Drag And Drop");
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
g_object_set (grid,
|
|
|
|
"margin", 20,
|
|
|
|
"row-spacing", 20,
|
|
|
|
"column-spacing", 20,
|
|
|
|
NULL);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), grid);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_image ("dialog-warning", TOP_LEFT), 0, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_image ("process-stop", BOTTOM_RIGHT), 1, 0, 1, 1);
|
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), entry, 0, 1, 2, 1);
|
|
|
|
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_spinner (), 0, 2, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_image ("weather-clear", CENTER), 1, 2, 1, 1);
|
|
|
|
|
2016-04-27 00:34:24 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_image2 ("dialog-question", TOP_LEFT), 0, 3, 1, 1);
|
2016-04-21 18:21:14 +00:00
|
|
|
|
2016-04-27 00:34:24 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), make_image2 ("dialog-information", CENTER), 1, 3, 1, 1);
|
2016-04-26 04:19:02 +00:00
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2015-12-11 15:44:46 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|