Commit a21da014 authored by Johannes Schmid's avatar Johannes Schmid
Browse files

gladeui: Finish up anjuta/glade dnd integration

parent 21707f0d
......@@ -3,6 +3,17 @@
* gladeui/glade-palette.c: Dont strdup the adaptor names in the local hash table (those
strings are constant data, no need to dup them).
2011-01-20 Johannes Schmid <jhs@gnome.org>
* gladeui/glade-signal-model.c:
Add the "swapped" property of the signal to the dnd string
* gladeui/glade-signal-editor.c:
Fix creating of the rich dnd icon with proper cairo drawing
(thanks to Benjamin Otte)
* gladeui/glade-app.c: Bring back "signal-editor-created" signal
2011-01-19 Tristan Van Berkom <tristanvb@openismus.com>
* plugins/gtk+/gtk+.xml.in: Remove GtkTreeSelection from the palette, it's only available
......@@ -45,6 +56,10 @@
* gladeui/glade-editor.[ch]: Remove glade_editor_set_signal_editor()
* gladeui/glade-app.c:
* gladeui/glade-signal-editor.c:
Added "signal-editor-created" signal
2011-01-13 Javier Jardón <jjardon@gnome.org>
* glade3.doap: Update doap file to glade.doap instead glade3.doap
......
......@@ -55,6 +55,7 @@
enum
{
DOC_SEARCH,
SIGNAL_EDITOR_CREATED,
LAST_SIGNAL
};
......@@ -330,6 +331,24 @@ glade_app_class_init (GladeAppClass * klass)
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
/**
* GladeApp::signal-editor-created:
* @gladeapp: the #GladeApp which received the signal.
* @signal_editor: the new #GladeSignalEditor.
*
* Emitted when a new signal editor created.
* A tree view is created in the default handler.
* Connect your handler before the default handler for setting a custom column or renderer
* and after it for connecting to the tree view signals
*/
glade_app_signals[SIGNAL_EDITOR_CREATED] =
g_signal_new ("signal-editor-created",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
glade_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_type_class_add_private (klass, sizeof (GladeAppPrivate));
}
......
......@@ -467,30 +467,46 @@ glade_signal_editor_dispose (GObject *object)
G_OBJECT_CLASS (glade_signal_editor_parent_class)->dispose (object);
}
#define BORDER 10
static cairo_surface_t*
create_rich_drag_surface (GtkWidget* widget, const gchar* text)
{
GtkStyleContext* context = gtk_widget_get_style_context (widget);
GtkStateFlags state = gtk_widget_get_state_flags (widget);
PangoLayout* layout = pango_layout_new (gtk_widget_get_pango_context (widget));
cairo_t* cr;
cairo_surface_t* s;
gint width, height;
GdkRGBA rgba;
pango_layout_set_text (layout, text, -1);
pango_layout_get_size (layout, &width, &height);
width = PANGO_PIXELS(width) + 10;
height = PANGO_PIXELS(height) + 10;
s = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
width = PANGO_PIXELS(width) + BORDER;
height = PANGO_PIXELS(height) + BORDER;
s = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
CAIRO_CONTENT_COLOR,
width,
height);
cr = cairo_create (s);
cairo_rectangle (cr, 0, 0, 1, 1);
cairo_show_text (cr, text);
cairo_stroke (cr);
gtk_style_context_get_background_color (context, state, &rgba);
gdk_cairo_set_source_rgba (cr, &rgba);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_move_to (cr, BORDER/2, BORDER/2);
pango_cairo_show_layout (cr, layout);
cairo_rectangle (cr, 0, 0, width, height);
cairo_stroke (cr);
cairo_destroy (cr);
g_object_unref (layout);
return s;;
return s;
}
static void
......@@ -508,15 +524,21 @@ glade_signal_editor_drag_begin (GtkWidget* widget,
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gchar* handler;
gchar* text;
gtk_tree_model_get (model, &iter,
GLADE_SIGNAL_COLUMN_HANDLER, &handler, -1);
s = create_rich_drag_surface (widget, handler);
text = g_strdup_printf ("%s ()", handler);
g_free (handler);
s = create_rich_drag_surface (widget, text);
g_free (text);
}
if (s)
{
gtk_drag_set_icon_surface (context, s);
g_object_unref (s);
cairo_surface_destroy (s);
}
else
{
......@@ -524,6 +546,7 @@ glade_signal_editor_drag_begin (GtkWidget* widget,
}
}
static void
glade_signal_editor_name_cell_data_func (GtkTreeViewColumn *column,
GtkCellRenderer *renderer,
......@@ -923,6 +946,9 @@ glade_signal_editor_init (GladeSignalEditor *self)
"drag-begin",
G_CALLBACK(glade_signal_editor_drag_begin),
self);
/* Emit created signal */
g_signal_emit_by_name (glade_app_get(), "signal-editor-created", self);
gtk_widget_show_all (GTK_WIDGET(self));
}
......
......@@ -979,13 +979,19 @@ glade_signal_model_drag_data_get (GtkTreeDragSource* model,
GladeSignal* signal;
const gchar* widget = iter.user_data;
gchar* dnd_text;
const gchar* user_data;
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
GLADE_SIGNAL_COLUMN_SIGNAL, &signal, -1);
dnd_text = g_strdup_printf ("%s:%s:%s", widget, glade_signal_get_name (signal),
glade_signal_get_handler (signal));
g_message ("Sent: %s", dnd_text);
user_data = glade_signal_get_userdata (signal);
dnd_text = g_strdup_printf ("%s:%s:%s:%s:%d:%d", widget,
glade_signal_get_name (signal),
glade_signal_get_handler (signal),
user_data && strlen (user_data) ? user_data : "(none)",
glade_signal_get_swapped (signal),
glade_signal_get_after (signal));
gtk_selection_data_set (data,
gdk_atom_intern_static_string ("application/x-glade-signal"),
8,
......
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