Commit 9f6a6732 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

added GladeDesignLayout::widget-event signal. Patch by Pavel Kostyuchenko

* gladeui/glade-design-layout.[ch]: added GladeDesignLayout::widget-event
  signal. Patch by Pavel Kostyuchenko (bug 542337).

* gladeui/glade-accumulators.[ch]: added glade_integer_handled_accumulator()

* gladeui/glade-signal-editor.[ch], gladeui/glade-signal-editor.[ch],
  gladeui/glade-app.[ch], src/glade-window.c: 
  "Improvement of GladeSignalEditor" Bug 540691 by Pavel Kostyuchenko.

* plugins/gnome/glade-gnome.c: Fixed compiler warnings in
  glade_gnome_bonobodockitem_get_props()

svn path=/trunk/; revision=2094
parent ba8042e3
2009-01-20 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-design-layout.[ch]: added GladeDesignLayout::widget-event
signal. Patch by Pavel Kostyuchenko (bug 542337).
* gladeui/glade-accumulators.[ch]: added glade_integer_handled_accumulator()
* gladeui/glade-signal-editor.[ch], gladeui/glade-signal-editor.[ch],
gladeui/glade-app.[ch], src/glade-window.c:
"Improvement of GladeSignalEditor" Bug 540691 by Pavel Kostyuchenko.
* plugins/gnome/glade-gnome.c: Fixed compiler warnings in
glade_gnome_bonobodockitem_get_props()
2009-01-19 Tristan Van Berkom <tvb@gnome.org>
* NEWS, configure.ac: Rolling Glade 3.5.6
......
......@@ -42,6 +42,22 @@ glade_single_object_accumulator (GSignalInvocationHint *ihint,
return (object == NULL);
}
gboolean
glade_integer_handled_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer dummy)
{
gboolean continue_emission;
gint retval;
retval = g_value_get_int (handler_return);
g_value_set_int (return_accu, retval >> 1);
continue_emission = !(retval & 1);
return continue_emission;
}
/* From gtkmain.c */
gboolean
glade_boolean_handled_accumulator (GSignalInvocationHint *ihint,
......
......@@ -10,6 +10,11 @@ gboolean glade_single_object_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer dummy);
gboolean glade_integer_handled_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer dummy);
gboolean glade_boolean_handled_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
......
......@@ -56,6 +56,7 @@
enum
{
UPDATE_UI,
SIGNAL_EDITOR_CREATED,
LAST_SIGNAL
};
......@@ -288,6 +289,12 @@ glade_app_update_ui_default (GladeApp *app)
glade_app_refresh_undo_redo_button (app, list->data, FALSE);
}
static void
glade_app_signal_editor_created_default (GladeApp *app, GladeSignalEditor *signal_editor)
{
glade_signal_editor_construct_signals_list (signal_editor);
}
static gboolean
clipboard_view_on_delete_cb (GtkWidget *clipboard_view, GdkEvent *e, GladeApp *app)
{
......@@ -396,6 +403,8 @@ glade_app_init (GladeApp *app)
static gboolean initialized = FALSE;
app->priv = GLADE_APP_GET_PRIVATE (app);
singleton_app = app;
glade_init_check ();
......@@ -453,6 +462,7 @@ glade_app_class_init (GladeAppClass * klass)
object_class->set_property = glade_app_set_property;
klass->update_ui_signal = glade_app_update_ui_default;
klass->signal_editor_created = glade_app_signal_editor_created_default;
klass->show_properties = NULL;
klass->hide_properties = NULL;
......@@ -472,6 +482,26 @@ glade_app_class_init (GladeAppClass * klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* 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,
G_STRUCT_OFFSET (GladeAppClass,
signal_editor_created),
NULL, NULL,
glade_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_object_class_install_property
(object_class, PROP_ACTIVE_PROJECT,
g_param_spec_object
......
......@@ -82,6 +82,7 @@ struct _GladeAppClass
/* signals */
void (* update_ui_signal) (GladeApp *app);
void (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
};
......
......@@ -27,6 +27,8 @@
#include "glade.h"
#include "glade-design-layout.h"
#include "glade-accumulators.h"
#include "glade-marshallers.h"
#include <gtk/gtk.h>
......@@ -56,6 +58,12 @@ typedef enum
REGION_OUTSIDE
} PointerRegion;
enum
{
WIDGET_EVENT,
LAST_SIGNAL
};
struct _GladeDesignLayoutPrivate
{
GdkWindow *event_window;
......@@ -73,6 +81,8 @@ struct _GladeDesignLayoutPrivate
gint new_height; /* user's new requested height */
};
static guint glade_design_layout_signals[LAST_SIGNAL] = {0};
G_DEFINE_TYPE (GladeDesignLayout, glade_design_layout, GTK_TYPE_BIN)
static PointerRegion
......@@ -839,7 +849,8 @@ glade_design_layout_widget_event (GladeDesignLayout *layout,
/* Then we try a GladeWidget */
if (gwidget)
{
retval = glade_widget_event (gwidget, event);
g_signal_emit_by_name (layout, "widget-event",
gwidget, event, &retval);
if (retval)
return retval;
......@@ -848,6 +859,19 @@ glade_design_layout_widget_event (GladeDesignLayout *layout,
return FALSE;
}
static gboolean
glade_design_layout_widget_event_impl (GladeProject *project,
GladeWidget *gwidget,
GdkEvent *event)
{
if (glade_widget_event (gwidget, event))
return GLADE_WIDGET_EVENT_STOP_EMISSION |
GLADE_WIDGET_EVENT_RETURN_TRUE;
else
return 0;
}
static void
glade_design_layout_init (GladeDesignLayout *layout)
{
......@@ -899,6 +923,36 @@ glade_design_layout_class_init (GladeDesignLayoutClass *klass)
widget_class->size_request = glade_design_layout_size_request;
widget_class->size_allocate = glade_design_layout_size_allocate;
klass->widget_event = glade_design_layout_widget_event_impl;
/**
* GladeDesignLayout::widget-event:
* @glade_design_layout: the #GladeDesignLayout containing the #GladeWidget.
* @signal_editor: the #GladeWidget which received the signal.
* @event: the #GdkEvent
*
* Emitted when a widget event received.
* Connect before the default handler to block glade logic,
* such as selecting or resizing, by returning #GLADE_WIDGET_EVENT_STOP_EMISSION.
* If you want to handle the event after it passed the glade logic,
* but before it reaches the widget, you should connect after the default handler.
*
* Returns: #GLADE_WIDGET_EVENT_STOP_EMISSION flag to abort futher emission of the signal.
* #GLADE_WIDGET_EVENT_RETURN_TRUE flag in the last handler
* to stop propagating of the event to the appropriate widget.
*/
glade_design_layout_signals[WIDGET_EVENT] =
g_signal_new ("widget-event",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GladeDesignLayoutClass, widget_event),
glade_integer_handled_accumulator, NULL,
glade_marshal_INT__OBJECT_BOXED,
G_TYPE_INT,
2,
GLADE_TYPE_WIDGET,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
g_type_class_add_private (object_class, sizeof (GladeDesignLayoutPrivate));
}
......
......@@ -40,6 +40,12 @@ typedef struct _GladeDesignLayout GladeDesignLayout;
typedef struct _GladeDesignLayoutPrivate GladeDesignLayoutPrivate;
typedef struct _GladeDesignLayoutClass GladeDesignLayoutClass;
enum
{
GLADE_WIDGET_EVENT_STOP_EMISSION = 1 << 0,
GLADE_WIDGET_EVENT_RETURN_TRUE = 1 << 1
};
struct _GladeDesignLayout
{
GtkBin parent_instance;
......@@ -50,6 +56,9 @@ struct _GladeDesignLayout
struct _GladeDesignLayoutClass
{
GtkBinClass parent_class;
gboolean (*widget_event) (GladeProject *project,
GladeWidget *gwidget,
GdkEvent *event);
};
......
......@@ -580,6 +580,18 @@ glade_editor_load_editable_in_page (GladeEditor *editor,
return editable;
}
void
glade_editor_set_signal_editor (GladeEditor *editor, GladeSignalEditor *signal_editor)
{
if (editor->signal_editor) {
gtk_container_remove (GTK_CONTAINER (editor->page_signals),
glade_signal_editor_get_widget (editor->signal_editor));
}
editor->signal_editor = signal_editor;
gtk_container_add (GTK_CONTAINER (editor->page_signals),
glade_signal_editor_get_widget (editor->signal_editor));
}
static void
glade_editor_load_signal_page (GladeEditor *editor)
{
......
......@@ -154,7 +154,7 @@ void glade_editor_search_doc_search (GladeEditor *editor,
const gchar *book,
const gchar *page,
const gchar *search);
void glade_editor_set_signal_editor (GladeEditor *editor, GladeSignalEditor *signal_editor);
G_END_DECLS
......
......@@ -14,4 +14,7 @@ BOOLEAN:OBJECT,BOOLEAN
BOOLEAN:OBJECT,UINT
BOOLEAN:OBJECT,OBJECT
BOOLEAN:OBJECT,STRING
BOOLEAN:STRING,STRING,STRING,BOXED
BOOLEAN:STRING,BOXED,OBJECT
STRING:OBJECT
INT:OBJECT,BOXED
This diff is collapsed.
......@@ -6,18 +6,43 @@
G_BEGIN_DECLS
#define GLADE_SIGNAL_EDITOR(e) ((GladeSignalEditor *)e)
#define GLADE_IS_SIGNAL_EDITOR(e) (e != NULL)
#define GLADE_TYPE_SIGNAL_EDITOR (glade_signal_editor_get_type ())
#define GLADE_SIGNAL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_SIGNAL_EDITOR, GladeSignalEditor))
#define GLADE_SIGNAL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_SIGNAL_EDITOR, GladeSignalEditorClass))
#define GLADE_IS_SIGNAL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_SIGNAL_EDITOR))
#define GLADE_IS_SIGNAL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_SIGNAL_EDITOR))
#define GLADE_SIGNAL_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_SIGNAL_EDITOR, GladeSignalEditorClass))
typedef struct _GladeSignalEditor GladeSignalEditor;
typedef struct _GladeSignalEditorClass GladeSignalEditorClass;
typedef gboolean (*IsVoidFunc) (const gchar *signal_handler);
enum
{
GSE_COLUMN_SIGNAL,
GSE_COLUMN_HANDLER,
GSE_COLUMN_AFTER,
GSE_COLUMN_USERDATA,
GSE_COLUMN_LOOKUP,
GSE_COLUMN_USERDATA_SLOT,
GSE_COLUMN_LOOKUP_VISIBLE,
GSE_COLUMN_AFTER_VISIBLE,
GSE_COLUMN_HANDLER_EDITABLE,
GSE_COLUMN_USERDATA_EDITABLE,
GSE_COLUMN_SLOT, /* if this row contains a "<Type...>" label */
GSE_COLUMN_BOLD,
GSE_NUM_COLUMNS
};
/* The GladeSignalEditor is used to house the signal editor interface and
* associated functionality.
*/
struct _GladeSignalEditor
{
GObject parent;
GtkWidget *main_window; /* A vbox where all the widgets are added */
GladeWidget *widget;
......@@ -28,22 +53,62 @@ struct _GladeSignalEditor
GtkWidget *signals_list;
GtkTreeStore *model;
GtkTreeView *tree_view;
GtkListStore *handler_store; /* This store contains all the posible handler names */
GtkEntryCompletion *completion;
GtkTreeIter iters[2];
};
GtkTreeModel *handler_store, *userdata_store;
GtkCellRenderer *handler_renderer, *userdata_renderer;
GtkTreeViewColumn *handler_column, *userdata_column;
IsVoidFunc is_void_handler, is_void_userdata;
};
GtkWidget *glade_signal_editor_get_widget (GladeSignalEditor *editor);
struct _GladeSignalEditorClass
{
GObjectClass parent_class;
gboolean (*handler_editing_done) (GladeSignalEditor *self,
gchar *signal_name,
gchar *old_handler,
gchar *new_handler,
GtkTreeIter *iter);
gboolean (*userdata_editing_done) (GladeSignalEditor *self,
gchar *signal_name,
gchar *old_userdata,
gchar *new_userdata,
GtkTreeIter *iter);
gboolean (*handler_editing_started) (GladeSignalEditor *self,
gchar *signal_name,
GtkTreeIter *iter,
GtkCellEditable *editable);
gboolean (*userdata_editing_started) (GladeSignalEditor *self,
gchar *signal_name,
GtkTreeIter *iter,
GtkCellEditable *editable);
};
GType glade_signal_editor_get_type (void) G_GNUC_CONST;
GladeSignalEditor *glade_signal_editor_new (gpointer *editor);
void glade_signal_editor_construct_signals_list (GladeSignalEditor *editor);
GtkWidget *glade_signal_editor_get_widget (GladeSignalEditor *editor);
void glade_signal_editor_load_widget (GladeSignalEditor *editor, GladeWidget *widget);
gboolean
glade_signal_editor_handler_editing_started_default_impl (GladeSignalEditor *editor,
gchar *signal_name,
GtkTreeIter *iter,
GtkCellEditable *editable,
gpointer user_data);
gboolean
glade_signal_editor_userdata_editing_started_default_impl (GladeSignalEditor *editor,
gchar *signal_name,
GtkTreeIter *iter,
GtkCellEditable *editable,
gpointer user_data);
G_END_DECLS
......
......@@ -1605,7 +1605,9 @@ glade_gnome_bonobodockitem_get_props (BonoboDock *doc,
return TRUE;
}
}
g_warning ("Item not found in BonoboDock");
return FALSE;
}
......@@ -1638,41 +1640,44 @@ glade_gnome_bonobodock_set_child_property (GladeWidgetAdaptor *adaptor,
}
wchild = GTK_WIDGET (child);
glade_gnome_bonobodockitem_get_props (dock, item, &placement, &band_num,
&band_position, &offset);
if (strcmp ("placement", property_name) == 0)
placement = g_value_get_enum (value);
else if (strcmp ("position", property_name) == 0)
band_position = g_value_get_int (value);
else if (strcmp ("band", property_name) == 0)
band_num = g_value_get_int (value);
else if (strcmp ("offset", property_name) == 0)
offset = g_value_get_int (value);
else
{
g_warning ("No BonoboDock set packing property support for '%s'.", property_name);
return;
}
if ((band = glade_gnome_bd_get_band (dock, wchild)))
{
g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (band), wchild);
if (band->num_children == 0)
if (glade_gnome_bonobodockitem_get_props (dock, item, &placement, &band_num,
&band_position, &offset))
{
if (strcmp ("placement", property_name) == 0)
placement = g_value_get_enum (value);
else if (strcmp ("position", property_name) == 0)
band_position = g_value_get_int (value);
else if (strcmp ("band", property_name) == 0)
band_num = g_value_get_int (value);
else if (strcmp ("offset", property_name) == 0)
offset = g_value_get_int (value);
else
{
new_band = TRUE;
gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET(band));
g_warning ("No BonoboDock set packing property support for '%s'.", property_name);
return;
}
if ((band = glade_gnome_bd_get_band (dock, wchild)))
{
g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (band), wchild);
bonobo_dock_add_item (dock, item, placement, band_num,
band_position, offset, new_band);
bonobo_dock_item_set_behavior (item, item->behavior);
g_object_unref (child);
if (band->num_children == 0)
{
new_band = TRUE;
gtk_container_remove (GTK_CONTAINER (container),
GTK_WIDGET(band));
}
bonobo_dock_add_item (dock, item, placement, band_num,
band_position, offset, new_band);
bonobo_dock_item_set_behavior (item, item->behavior);
g_object_unref (child);
}
else
g_warning ("BonoboDockItem's band not found.\n");
}
else
g_warning ("BonoboDockItem's band not found.\n");
}
void
......@@ -1699,19 +1704,20 @@ glade_gnome_bonobodock_get_child_property (GladeWidgetAdaptor *adaptor,
return;
}
glade_gnome_bonobodockitem_get_props (BONOBO_DOCK (container),
BONOBO_DOCK_ITEM (child),
&placement, &band_num,
&band_position, &offset);
if (strcmp ("placement", property_name) == 0)
g_value_set_enum (value, placement);
else if (strcmp ("position", property_name) == 0)
g_value_set_int (value, band_position);
else if (strcmp ("band", property_name) == 0)
g_value_set_int (value, band_num);
else if (strcmp ("offset", property_name) == 0)
g_value_set_int (value, offset);
if (glade_gnome_bonobodockitem_get_props (BONOBO_DOCK (container),
BONOBO_DOCK_ITEM (child),
&placement, &band_num,
&band_position, &offset))
{
if (strcmp ("placement", property_name) == 0)
g_value_set_enum (value, placement);
else if (strcmp ("position", property_name) == 0)
g_value_set_int (value, band_position);
else if (strcmp ("band", property_name) == 0)
g_value_set_int (value, band_num);
else if (strcmp ("offset", property_name) == 0)
g_value_set_int (value, offset);
}
}
void
......
......@@ -3045,6 +3045,16 @@ glade_window_init (GladeWindow *window)
show_dock_first_time (window, DOCK_INSPECTOR, "DockInspector");
show_dock_first_time (window, DOCK_EDITOR, "DockEditor");
/* signal editor */
g_signal_connect (G_OBJECT (glade_app_get_editor()->signal_editor),
"handler-editing-started",
G_CALLBACK (glade_signal_editor_handler_editing_started_default_impl),
NULL);
g_signal_connect (G_OBJECT (glade_app_get_editor()->signal_editor),
"userdata-editing-started",
G_CALLBACK (glade_signal_editor_userdata_editing_started_default_impl),
NULL);
/* status bar */
priv->statusbar = gtk_statusbar_new ();
priv->statusbar_menu_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
......
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