Commit cd730730 authored by Tristan Van Berkom's avatar Tristan Van Berkom

* gladeui/glade-signal.[ch], gladeui/glade-project.c, gladeui/glade-widget.c,

	gladeui/glade-signal-editor.c, gladeui/glade-command.c: Made GladeSignal an
	opaque structure with accessors.
parent a3877e63
......@@ -5,6 +5,10 @@
Added glade-signal-class.[ch] as an opaque type.
* gladeui/glade-signal.[ch], gladeui/glade-project.c, gladeui/glade-widget.c,
gladeui/glade-signal-editor.c, gladeui/glade-command.c: Made GladeSignal an
opaque structure with accessors.
2011-01-04 Johannes Schmid <jhs@gnome.org>
* data/gladeui-2.0.pc.in: Fix include paths and library name
......
......@@ -1861,7 +1861,8 @@ glade_command_add_remove_change_signal (GladeWidget * glade_widget,
cmd->description =
g_strdup_printf (type == GLADE_ADD ? _("Add signal handler %s") :
type == GLADE_REMOVE ? _("Remove signal handler %s") :
_("Change signal handler %s"), signal->handler);
_("Change signal handler %s"),
glade_signal_get_handler ((GladeSignal *)signal));
glade_command_check_group (GLADE_COMMAND (me));
......
......@@ -1393,7 +1393,8 @@ glade_project_introspect_signal_versions (GladeSignal *signal,
gboolean is_gtk_adaptor = FALSE;
signal_class =
glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (data->widget), signal->name);
glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (data->widget),
glade_signal_get_name (signal));
/* unknown signal... can it happen ? */
if (!signal_class)
......@@ -2252,7 +2253,8 @@ glade_project_verify_signal_internal (GladeWidget * widget,
gchar *catalog;
signal_class =
glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (widget), signal->name);
glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (widget),
glade_signal_get_name (signal));
if (!signal_class)
return;
......@@ -2282,7 +2284,7 @@ glade_project_verify_signal_internal (GladeWidget * widget,
g_string_append_printf (string,
SIGNAL_VERSION_CONFLICT_FMT,
path_name,
signal->name,
glade_signal_get_name (signal),
glade_widget_adaptor_get_title (adaptor),
catalog,
glade_signal_class_since_major (signal_class),
......
......@@ -55,7 +55,7 @@ glade_signal_class_new (GladeWidgetAdaptor *adaptor,
* exist no matter what.
*/
g_signal_query (signal_id, &(class->query));
if (class->query.signal_id != 0)
if (class->query.signal_id == 0)
{
g_critical ("glade_signal_class_new() called with an invalid signal id");
......
......@@ -244,7 +244,8 @@ append_slot (GladeSignalEditor * self, GtkTreeIter * iter_signal,
GSE_COLUMN_USERDATA_SLOT, TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, FALSE,
GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
GSE_COLUMN_TOOLTIP, glade_signal_get_support_warning (sig),
-1);
gtk_tree_model_iter_parent (model, &iter_class, iter_signal);
/* mark the signal & class name as bold */
......@@ -1251,8 +1252,8 @@ glade_signal_editor_load_widget (GladeSignalEditor * editor,
GSE_COLUMN_SLOT, TRUE,
GSE_COLUMN_USERDATA_SLOT, TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, sig->support_warning != NULL,
GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
GSE_COLUMN_WARN, glade_signal_get_support_warning (sig) != NULL,
GSE_COLUMN_TOOLTIP, glade_signal_get_support_warning (sig), -1);
}
else
{
......@@ -1273,51 +1274,53 @@ glade_signal_editor_load_widget (GladeSignalEditor * editor,
gtk_tree_path_free (path_parent_class);
gtk_tree_store_set
(priv->model, &parent_signal,
GSE_COLUMN_SIGNAL, glade_signal_class_get_name (signal),
GSE_COLUMN_HANDLER, widget_signal->handler,
GSE_COLUMN_AFTER, widget_signal->after,
GSE_COLUMN_USERDATA,
widget_signal->userdata ?
widget_signal->userdata : USERDATA_DEFAULT,
GSE_COLUMN_SWAPPED, widget_signal->swapped,
GSE_COLUMN_SWAPPED_VISIBLE,
widget_signal->userdata ? TRUE : FALSE,
GSE_COLUMN_AFTER_VISIBLE, TRUE,
GSE_COLUMN_HANDLER_EDITABLE, TRUE,
GSE_COLUMN_USERDATA_EDITABLE, TRUE,
GSE_COLUMN_SLOT, FALSE,
GSE_COLUMN_USERDATA_SLOT,
widget_signal->userdata ? FALSE : TRUE,
GSE_COLUMN_BOLD, TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, widget_signal->support_warning != NULL,
GSE_COLUMN_TOOLTIP, widget_signal->support_warning, -1);
(priv->model, &parent_signal,
GSE_COLUMN_SIGNAL, glade_signal_class_get_name (signal),
GSE_COLUMN_HANDLER, glade_signal_get_handler (widget_signal),
GSE_COLUMN_AFTER, glade_signal_get_after (widget_signal),
GSE_COLUMN_USERDATA,
glade_signal_get_userdata (widget_signal) ?
glade_signal_get_userdata (widget_signal) : USERDATA_DEFAULT,
GSE_COLUMN_SWAPPED, glade_signal_get_swapped (widget_signal),
GSE_COLUMN_SWAPPED_VISIBLE,
glade_signal_get_userdata (widget_signal) ? TRUE : FALSE,
GSE_COLUMN_AFTER_VISIBLE, TRUE,
GSE_COLUMN_HANDLER_EDITABLE, TRUE,
GSE_COLUMN_USERDATA_EDITABLE, TRUE,
GSE_COLUMN_SLOT, FALSE,
GSE_COLUMN_USERDATA_SLOT,
glade_signal_get_userdata (widget_signal) ? FALSE : TRUE,
GSE_COLUMN_BOLD, TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, glade_signal_get_support_warning (widget_signal) != NULL,
GSE_COLUMN_TOOLTIP, glade_signal_get_support_warning (widget_signal),
-1);
for (i = 1; i < signals->len; i++)
{
widget_signal = (GladeSignal *) g_ptr_array_index (signals, i);
gtk_tree_store_append (priv->model, &iter, &parent_signal);
gtk_tree_store_set
(priv->model, &iter,
GSE_COLUMN_HANDLER, widget_signal->handler,
GSE_COLUMN_AFTER, widget_signal->after,
GSE_COLUMN_USERDATA,
widget_signal->userdata ?
widget_signal->userdata : USERDATA_DEFAULT,
GSE_COLUMN_SWAPPED, widget_signal->swapped,
GSE_COLUMN_SWAPPED_VISIBLE,
widget_signal->userdata ? TRUE : FALSE,
GSE_COLUMN_AFTER_VISIBLE, TRUE,
GSE_COLUMN_HANDLER_EDITABLE, TRUE,
GSE_COLUMN_USERDATA_EDITABLE, TRUE,
GSE_COLUMN_SLOT, FALSE,
GSE_COLUMN_USERDATA_SLOT,
widget_signal->userdata ? FALSE : TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, FALSE,
GSE_COLUMN_TOOLTIP, widget_signal->support_warning, -1);
(priv->model, &iter,
GSE_COLUMN_HANDLER, glade_signal_get_handler (widget_signal),
GSE_COLUMN_AFTER, glade_signal_get_after (widget_signal),
GSE_COLUMN_USERDATA,
glade_signal_get_userdata (widget_signal) ?
glade_signal_get_userdata (widget_signal) : USERDATA_DEFAULT,
GSE_COLUMN_SWAPPED, glade_signal_get_swapped (widget_signal),
GSE_COLUMN_SWAPPED_VISIBLE,
glade_signal_get_userdata (widget_signal) ? TRUE : FALSE,
GSE_COLUMN_AFTER_VISIBLE, TRUE,
GSE_COLUMN_HANDLER_EDITABLE, TRUE,
GSE_COLUMN_USERDATA_EDITABLE, TRUE,
GSE_COLUMN_SLOT, FALSE,
GSE_COLUMN_USERDATA_SLOT,
glade_signal_get_userdata (widget_signal) ? FALSE : TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, FALSE,
GSE_COLUMN_TOOLTIP, glade_signal_get_support_warning (widget_signal),
-1);
}
/* add the <Type...> slot */
......@@ -1336,7 +1339,7 @@ glade_signal_editor_load_widget (GladeSignalEditor * editor,
GSE_COLUMN_USERDATA_SLOT, TRUE,
GSE_COLUMN_CONTENT, TRUE,
GSE_COLUMN_WARN, FALSE,
GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
GSE_COLUMN_TOOLTIP, glade_signal_get_support_warning (sig), -1);
}
glade_signal_free (sig);
......
......@@ -30,6 +30,18 @@
#include "glade-signal.h"
#include "glade-xml-utils.h"
struct _GladeSignal
{
gchar *name; /* Signal name eg "clicked" */
gchar *handler; /* Handler function eg "gtk_main_quit" */
gchar *userdata; /* User data signal handler argument */
gchar *support_warning;/* Message to inform the user about signals introduced in future versions */
guint8 after : 1; /* Connect after TRUE or FALSE */
guint8 swapped : 1; /* Connect swapped TRUE or FALSE (GtkBuilder only) */
};
/**
* glade_signal_new:
* @name: a name for the signal
......@@ -118,7 +130,9 @@ glade_signal_clone (const GladeSignal * signal)
dup = glade_signal_new (signal->name,
signal->handler,
signal->userdata, signal->after, signal->swapped);
signal->userdata,
signal->after,
signal->swapped);
glade_signal_set_support_warning (dup, signal->support_warning);
......@@ -222,8 +236,108 @@ glade_signal_read (GladeXmlNode * node)
}
void
glade_signal_set_support_warning (GladeSignal * signal,
const gchar * support_warning)
glade_signal_set_name (GladeSignal *signal,
const gchar *name)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
if (g_strcmp0 (signal->name, name))
{
g_free (signal->name);
signal->name =
name ? g_strdup (name) : NULL;
}
}
G_CONST_RETURN gchar *
glade_signal_get_name (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
return signal->name;
}
void
glade_signal_set_handler (GladeSignal *signal,
const gchar *handler)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
if (g_strcmp0 (signal->handler, handler))
{
g_free (signal->handler);
signal->handler =
handler ? g_strdup (handler) : NULL;
}
}
G_CONST_RETURN gchar *
glade_signal_get_handler (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
return signal->handler;
}
void
glade_signal_set_userdata (GladeSignal *signal,
const gchar *userdata)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
if (g_strcmp0 (signal->userdata, userdata))
{
g_free (signal->userdata);
signal->userdata =
userdata ? g_strdup (userdata) : NULL;
}
}
G_CONST_RETURN gchar *
glade_signal_get_userdata (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
return signal->userdata;
}
void
glade_signal_set_after (GladeSignal *signal,
gboolean after)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
signal->after = after;
}
gboolean
glade_signal_get_after (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), FALSE);
return signal->after;
}
void
glade_signal_set_swapped (GladeSignal *signal,
gboolean swapped)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
signal->swapped = swapped;
}
gboolean
glade_signal_get_swapped (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), FALSE);
return signal->swapped;
}
void
glade_signal_set_support_warning (GladeSignal *signal,
const gchar *support_warning)
{
g_return_if_fail (GLADE_IS_SIGNAL (signal));
......@@ -234,3 +348,11 @@ glade_signal_set_support_warning (GladeSignal * signal,
support_warning ? g_strdup (support_warning) : NULL;
}
}
G_CONST_RETURN gchar *
glade_signal_get_support_warning (GladeSignal *signal)
{
g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
return signal->support_warning;
}
......@@ -5,43 +5,43 @@
G_BEGIN_DECLS
#define GLADE_SIGNAL(s) ((GladeSignal *)s)
#define GLADE_IS_SIGNAL(s) (s != NULL)
typedef struct _GladeSignal GladeSignal;
struct _GladeSignal
{
gchar *name; /* Signal name eg "clicked" */
gchar *handler; /* Handler function eg "gtk_main_quit" */
gchar *userdata; /* User data signal handler argument */
gchar *support_warning;/* Message to inform the user about signals introduced in future versions */
guint8 after : 1; /* Connect after TRUE or FALSE */
guint8 swapped : 1; /* Connect swapped TRUE or FALSE (GtkBuilder only) */
};
GladeSignal *glade_signal_new (const gchar *name,
const gchar *handler,
const gchar *userdata,
gboolean after,
gboolean swapped);
GladeSignal *glade_signal_clone (const GladeSignal *signal);
void glade_signal_free (GladeSignal *signal);
gboolean glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2);
GladeSignal *glade_signal_read (GladeXmlNode *node);
void glade_signal_write (GladeSignal *signal,
GladeXmlContext *context,
GladeXmlNode *node);
void glade_signal_set_support_warning (GladeSignal *signal,
const gchar *support_warning);
GladeSignal *glade_signal_new (const gchar *name,
const gchar *handler,
const gchar *userdata,
gboolean after,
gboolean swapped);
GladeSignal *glade_signal_clone (const GladeSignal *signal);
void glade_signal_free (GladeSignal *signal);
gboolean glade_signal_equal (GladeSignal *sig1,
GladeSignal *sig2);
GladeSignal *glade_signal_read (GladeXmlNode *node);
void glade_signal_write (GladeSignal *signal,
GladeXmlContext *context,
GladeXmlNode *node);
void glade_signal_set_name (GladeSignal *signal,
const gchar *name);
G_CONST_RETURN gchar *glade_signal_get_name (GladeSignal *signal);
void glade_signal_set_handler (GladeSignal *signal,
const gchar *handler);
G_CONST_RETURN gchar *glade_signal_get_handler (GladeSignal *signal);
void glade_signal_set_userdata (GladeSignal *signal,
const gchar *userdata);
G_CONST_RETURN gchar *glade_signal_get_userdata (GladeSignal *signal);
void glade_signal_set_after (GladeSignal *signal,
gboolean after);
gboolean glade_signal_get_after (GladeSignal *signal);
void glade_signal_set_swapped (GladeSignal *signal,
gboolean swapped);
gboolean glade_signal_get_swapped (GladeSignal *signal);
void glade_signal_set_support_warning (GladeSignal *signal,
const gchar *support_warning);
G_CONST_RETURN gchar *glade_signal_get_support_warning (GladeSignal *signal);
G_END_DECLS
......
......@@ -313,11 +313,12 @@ glade_widget_add_signal_handler_impl (GladeWidget * widget,
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
signals = glade_widget_list_signal_handlers (widget, glade_signal_get_name (signal_handler));
if (!signals)
{
signals = g_ptr_array_new ();
g_hash_table_insert (widget->priv->signals, g_strdup (signal_handler->name),
g_hash_table_insert (widget->priv->signals,
g_strdup (glade_signal_get_name (signal_handler)),
signals);
}
......@@ -338,7 +339,7 @@ glade_widget_remove_signal_handler_impl (GladeWidget * widget,
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
signals = glade_widget_list_signal_handlers (widget, glade_signal_get_name (signal_handler));
/* trying to remove an inexistent signal? */
g_assert (signals);
......@@ -367,11 +368,11 @@ glade_widget_change_signal_handler_impl (GladeWidget * widget,
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_return_if_fail (GLADE_IS_SIGNAL (old_signal_handler));
g_return_if_fail (GLADE_IS_SIGNAL (new_signal_handler));
g_return_if_fail (strcmp (old_signal_handler->name, new_signal_handler->name)
== 0);
g_return_if_fail (strcmp (glade_signal_get_name (old_signal_handler),
glade_signal_get_name (new_signal_handler)) == 0);
signals =
glade_widget_list_signal_handlers (widget, old_signal_handler->name);
glade_widget_list_signal_handlers (widget, glade_signal_get_name (old_signal_handler));
/* trying to remove an inexistent signal? */
g_assert (signals);
......@@ -381,27 +382,19 @@ glade_widget_change_signal_handler_impl (GladeWidget * widget,
signal_handler_iter = g_ptr_array_index (signals, i);
if (glade_signal_equal (signal_handler_iter, old_signal_handler))
{
if (strcmp (old_signal_handler->handler,
new_signal_handler->handler) != 0)
{
g_free (signal_handler_iter->handler);
signal_handler_iter->handler =
g_strdup (new_signal_handler->handler);
}
/* Handler */
if (signal_handler_iter->handler)
g_free (signal_handler_iter->handler);
signal_handler_iter->handler = g_strdup (new_signal_handler->handler);
glade_signal_set_handler (signal_handler_iter,
glade_signal_get_handler (new_signal_handler));
/* Object */
if (signal_handler_iter->userdata)
g_free (signal_handler_iter->userdata);
signal_handler_iter->userdata =
g_strdup (new_signal_handler->userdata);
signal_handler_iter->after = new_signal_handler->after;
signal_handler_iter->swapped = new_signal_handler->swapped;
glade_signal_set_userdata (signal_handler_iter,
glade_signal_get_userdata (new_signal_handler));
/* Flags */
glade_signal_set_after (signal_handler_iter,
glade_signal_get_after (new_signal_handler));
glade_signal_set_swapped (signal_handler_iter,
glade_signal_get_swapped (new_signal_handler));
break;
}
}
......
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