Commit 949ee164 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

GladeProject: add handler signals

Add add, remove, change and activate handler signals.

These signals can be used to easily track signal changes in a project
instead of connecting callbacks to every widget.
parent 8553bf03
......@@ -5,6 +5,7 @@ VOID:OBJECT
VOID:STRING
VOID:INT,INT
VOID:OBJECT,OBJECT
VOID:OBJECT,OBJECT,OBJECT
VOID:OBJECT,BOOLEAN
VOID:STRING,STRING,STRING
OBJECT:POINTER
......
......@@ -44,6 +44,21 @@ GList *_glade_widget_peek_prop_refs (GladeWidget *widget);
GladeCatalog *_glade_catalog_get_catalog (const gchar *name);
GList *_glade_catalog_tsort (GList *catalogs);
/* glade-project.c */
void
_glade_project_emit_add_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
void
_glade_project_emit_remove_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
void
_glade_project_emit_change_signal_handler (GladeWidget *widget,
const GladeSignal *old_signal,
const GladeSignal *new_signal);
void
_glade_project_emit_activate_signal_handler (GladeWidget *widget,
const GladeSignal *signal);
/* glade-project-properties.c */
void
......
......@@ -180,6 +180,10 @@ enum
TARGETS_CHANGED,
LOAD_PROGRESS,
WIDGET_VISIBILITY_CHANGED,
ADD_SIGNAL_HANDLER,
REMOVE_SIGNAL_HANDLER,
CHANGE_SIGNAL_HANDLER,
ACTIVATE_SIGNAL_HANDLER,
LAST_SIGNAL
};
......@@ -952,6 +956,80 @@ glade_project_class_init (GladeProjectClass *klass)
_glade_marshal_VOID__OBJECT_BOOLEAN,
G_TYPE_NONE, 2, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
/**
* GladeProject::add-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was added to @gladewidget.
*/
glade_project_signals[ADD_SIGNAL_HANDLER] =
g_signal_new ("add-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::remove-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was removed from @gladewidget.
*/
glade_project_signals[REMOVE_SIGNAL_HANDLER] =
g_signal_new ("remove-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::change-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @old_signal: the old #GladeSignal that changed
* @new_signal: the new #GladeSignal
*/
glade_project_signals[CHANGE_SIGNAL_HANDLER] =
g_signal_new ("change-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT_OBJECT,
G_TYPE_NONE,
3,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL,
GLADE_TYPE_SIGNAL);
/**
* GladeProject::activate-signal-handler:
* @gladeproject: the #GladeProject which received the signal.
* @gladewidget: the #GladeWidget
* @signal: the #GladeSignal that was activated
*/
glade_project_signals[ACTIVATE_SIGNAL_HANDLER] =
g_signal_new ("activate-signal-handler",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_glade_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
GLADE_TYPE_WIDGET,
GLADE_TYPE_SIGNAL);
glade_project_props[PROP_MODIFIED] =
g_param_spec_boolean ("modified",
"Modified",
......@@ -5383,3 +5461,53 @@ glade_project_command_delete (GladeProject *project)
if (widgets)
g_list_free (widgets);
}
/* Private */
void
_glade_project_emit_add_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[ADD_SIGNAL_HANDLER], 0,
widget, signal);
}
void
_glade_project_emit_remove_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[REMOVE_SIGNAL_HANDLER], 0,
widget, signal);
}
void
_glade_project_emit_change_signal_handler (GladeWidget *widget,
const GladeSignal *old_signal,
const GladeSignal *new_signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[CHANGE_SIGNAL_HANDLER], 0,
widget, old_signal, new_signal);
}
void
_glade_project_emit_activate_signal_handler (GladeWidget *widget,
const GladeSignal *signal)
{
GladeProject *project = glade_widget_get_project (widget);
if (project)
g_signal_emit (project, glade_project_signals[ACTIVATE_SIGNAL_HANDLER], 0,
widget, signal);
}
......@@ -342,6 +342,7 @@ glade_widget_add_signal_handler (GladeWidget *widget,
new_signal_handler = glade_signal_clone (signal_handler);
g_ptr_array_add (signals, new_signal_handler);
g_signal_emit (widget, glade_widget_signals[ADD_SIGNAL_HANDLER], 0, new_signal_handler);
_glade_project_emit_add_signal_handler (widget, new_signal_handler);
glade_project_verify_signal (widget, new_signal_handler);
......@@ -388,6 +389,7 @@ glade_widget_remove_signal_handler (GladeWidget *widget,
break;
}
}
_glade_project_emit_remove_signal_handler (widget, signal_handler);
}
/**
......@@ -444,10 +446,12 @@ glade_widget_change_signal_handler (GladeWidget *widget,
g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
signal_handler_iter);
break;
}
}
_glade_project_emit_change_signal_handler (widget,
old_signal_handler,
new_signal_handler);
}
static gboolean
......@@ -1474,8 +1478,7 @@ glade_widget_class_init (GladeWidgetClass *klass)
/**
* GladeWidget::change-signal-handler:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the old #GladeSignal
* @arg2: the new #GladeSignal
* @arg1: the #GladeSignal that changed
*/
glade_widget_signals[CHANGE_SIGNAL_HANDLER] =
g_signal_new ("change-signal-handler",
......
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