[glade3/signal-tree-model: 39/43] glade-widget: Emit the add/remove/change-signal-handler signals with actual handler
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3/signal-tree-model: 39/43] glade-widget: Emit the add/remove/change-signal-handler signals with actual handler
- Date: Fri, 9 Jul 2010 20:57:33 +0000 (UTC)
commit fbc3bed1a9289cfbd9b2856517c3b7df8cd38f5f
Author: Johannes Schmid <jhs gnome org>
Date: Tue Jul 6 19:57:33 2010 +0200
glade-widget: Emit the add/remove/change-signal-handler signals with actual handler
This makes the implementation of the signal model much easier.
gladeui/glade-widget.c | 101 ++++++++++++++++++------------------------------
gladeui/glade-widget.h | 8 ++--
2 files changed, 42 insertions(+), 67 deletions(-)
---
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index a9e0136..77cb2f6 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -195,8 +195,15 @@ glade_widget_replace_child_impl (GladeWidget *widget,
glade_widget_set_packing_properties (gnew_widget, widget);
}
-static void
-glade_widget_add_signal_handler_impl (GladeWidget *widget, GladeSignal *signal_handler)
+/**
+ * glade_widget_add_signal_handler:
+ * @widget: A #GladeWidget
+ * @signal_handler: The #GladeSignal
+ *
+ * Adds a signal handler for @widget
+ */
+void
+glade_widget_add_signal_handler (GladeWidget *widget, const GladeSignal *signal_handler)
{
GPtrArray *signals;
GladeSignal *new_signal_handler;
@@ -213,12 +220,21 @@ glade_widget_add_signal_handler_impl (GladeWidget *widget, GladeSignal *signal_h
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_update_signal_support_warning (widget, new_signal_handler);
}
-static void
-glade_widget_remove_signal_handler_impl (GladeWidget *widget, GladeSignal *signal_handler)
+/**
+ * glade_widget_remove_signal_handler:
+ * @widget: A #GladeWidget
+ * @signal_handler: The #GladeSignal
+ *
+ * Removes a signal handler from @widget
+ */
+
+void
+glade_widget_remove_signal_handler(GladeWidget *widget, const GladeSignal *signal_handler)
{
GPtrArray *signals;
GladeSignal *tmp_signal_handler;
@@ -237,17 +253,26 @@ glade_widget_remove_signal_handler_impl (GladeWidget *widget, GladeSignal *signa
tmp_signal_handler = g_ptr_array_index (signals, i);
if (glade_signal_equal (tmp_signal_handler, signal_handler))
{
- glade_signal_free (tmp_signal_handler);
+ g_signal_emit (widget, glade_widget_signals[REMOVE_SIGNAL_HANDLER], 0, tmp_signal_handler);
g_ptr_array_remove_index (signals, i);
+ glade_signal_free (tmp_signal_handler);
break;
}
}
}
-static void
-glade_widget_change_signal_handler_impl (GladeWidget *widget,
- GladeSignal *old_signal_handler,
- GladeSignal *new_signal_handler)
+/**
+ * glade_widget_change_signal_handler:
+ * @widget: A #GladeWidget
+ * @old_signal_handler: the old #GladeSignal
+ * @new_signal_handler: the new #GladeSignal
+ *
+ * Changes a #GladeSignal on @widget
+ */
+void
+glade_widget_change_signal_handler (GladeWidget *widget,
+ const GladeSignal *old_signal_handler,
+ const GladeSignal *new_signal_handler)
{
GPtrArray *signals;
GladeSignal *signal_handler_iter;
@@ -290,6 +315,10 @@ glade_widget_change_signal_handler_impl (GladeWidget *widget,
signal_handler_iter->after = new_signal_handler->after;
signal_handler_iter->swapped = new_signal_handler->swapped;
+
+ g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
+ old_signal_handler, signal_handler_iter);
+
break;
}
}
@@ -1039,10 +1068,6 @@ glade_widget_class_init (GladeWidgetClass *klass)
klass->replace_child = glade_widget_replace_child_impl;
klass->event = glade_widget_event_impl;
- klass->add_signal_handler = glade_widget_add_signal_handler_impl;
- klass->remove_signal_handler = glade_widget_remove_signal_handler_impl;
- klass->change_signal_handler = glade_widget_change_signal_handler_impl;
-
klass->button_press_event = glade_widget_button_press_event_impl;
klass->button_release_event = NULL;
klass->motion_notify_event = NULL;
@@ -2485,56 +2510,6 @@ glade_widget_rebuild (GladeWidget *gwidget)
}
/**
- * glade_widget_add_signal_handler:
- * @widget: A #GladeWidget
- * @signal_handler: The #GladeSignal
- *
- * Adds a signal handler for @widget
- */
-void
-glade_widget_add_signal_handler (GladeWidget *widget, GladeSignal *signal_handler)
-{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- g_signal_emit (widget, glade_widget_signals[ADD_SIGNAL_HANDLER], 0, signal_handler);
-}
-
-
-/**
- * glade_widget_remove_signal_handler:
- * @widget: A #GladeWidget
- * @signal_handler: The #GladeSignal
- *
- * Removes a signal handler from @widget
- */
-void
-glade_widget_remove_signal_handler (GladeWidget *widget, GladeSignal *signal_handler)
-{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- g_signal_emit (widget, glade_widget_signals[REMOVE_SIGNAL_HANDLER], 0, signal_handler);
-}
-
-/**
- * glade_widget_change_signal_handler:
- * @widget: A #GladeWidget
- * @old_signal_handler: the old #GladeSignal
- * @new_signal_handler: the new #GladeSignal
- *
- * Changes a #GladeSignal on @widget
- */
-void
-glade_widget_change_signal_handler (GladeWidget *widget,
- GladeSignal *old_signal_handler,
- GladeSignal *new_signal_handler)
-{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
- old_signal_handler, new_signal_handler);
-}
-
-/**
* glade_widget_list_signal_handlers:
* @widget: a #GladeWidget
* @signal_name: the name of the signal
diff --git a/gladeui/glade-widget.h b/gladeui/glade-widget.h
index 3094d6d..a4fdef9 100644
--- a/gladeui/glade-widget.h
+++ b/gladeui/glade-widget.h
@@ -190,14 +190,14 @@ void glade_widget_show (GladeWidget *w
void glade_widget_hide (GladeWidget *widget);
void glade_widget_add_signal_handler (GladeWidget *widget,
- GladeSignal *signal_handler);
+ const GladeSignal *signal_handler);
void glade_widget_remove_signal_handler (GladeWidget *widget,
- GladeSignal *signal_handler);
+ const GladeSignal *signal_handler);
void glade_widget_change_signal_handler (GladeWidget *widget,
- GladeSignal *old_signal_handler,
- GladeSignal *new_signal_handler);
+ const GladeSignal *old_signal_handler,
+ const GladeSignal *new_signal_handler);
GPtrArray * glade_widget_list_signal_handlers (GladeWidget *widget,
const gchar *signal_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]