Commit ffd323a7 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/glade-signal-model.c: Watch the "support-changed" signal on GladeWidget and

	  update support warnings on dummy rows as well as emit "row-changed" for all rows

	* gladeui/glade-signal-editor.c: Left align the warning icon and expand the first
	  row of the signal tree when loading a widget.
parent f690d3a8
2011-01-13 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-signal-model.c: Watch the "support-changed" signal on GladeWidget and
update support warnings on dummy rows as well as emit "row-changed" for all rows
* gladeui/glade-signal-editor.c: Left align the warning icon and expand the first
row of the signal tree when loading a widget.
2011-01-12 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-palette.c: Fixed leaking project (set_project NULL when
......
......@@ -395,6 +395,8 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
GladeWidget *widget)
{
GladeSignalEditorPrivate *priv = editor->priv;
GtkTreePath *path;
GtkTreeIter iter;
if (priv->widget != widget)
{
......@@ -416,6 +418,13 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
priv->model = glade_widget_get_signal_model (widget);
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->signal_tree), priv->model);
if (gtk_tree_model_iter_children (priv->model, &iter, NULL))
{
path = gtk_tree_model_get_path (priv->model, &iter);
gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->signal_tree), path, FALSE);
gtk_tree_path_free (path);
}
}
/**
......@@ -751,7 +760,9 @@ glade_signal_editor_init (GladeSignalEditor *self)
/* version warning */
renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_DIALOG_WARNING,
g_object_set (G_OBJECT (renderer),
"icon-name", GTK_STOCK_DIALOG_WARNING,
"xalign", 0.0,
NULL);
gtk_tree_view_column_set_cell_data_func (priv->column_name, renderer,
glade_signal_editor_warning_cell_data_func,
......
......@@ -56,6 +56,7 @@ static void on_glade_signal_model_removed (GladeWidget* widget, const GladeSigna
GladeSignalModel* model);
static void on_glade_signal_model_changed (GladeWidget* widget, const GladeSignal* signal,
GladeSignalModel* model);
static void on_glade_widget_support_changed (GladeWidget *widget, GladeSignalModel* model);
G_DEFINE_TYPE_WITH_CODE (GladeSignalModel, glade_signal_model, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
......@@ -133,12 +134,12 @@ glade_signal_model_set_property (GObject *object, guint prop_id, const GValue *v
g_signal_connect (sig_model->priv->widget,
"add-signal-handler",
G_CALLBACK (on_glade_signal_model_added), sig_model);
g_signal_connect (sig_model->priv->widget,
"remove-signal-handler",
g_signal_connect (sig_model->priv->widget, "remove-signal-handler",
G_CALLBACK (on_glade_signal_model_removed), sig_model);
g_signal_connect (sig_model->priv->widget,
"change-signal-handler",
G_CALLBACK (on_glade_signal_model_changed), sig_model);
g_signal_connect (sig_model->priv->widget, "change-signal-handler",
G_CALLBACK (on_glade_signal_model_changed), sig_model);
g_signal_connect (sig_model->priv->widget, "support-changed",
G_CALLBACK (on_glade_widget_support_changed), sig_model);
break;
case PROP_SIGNALS:
sig_model->priv->signals = g_value_get_pointer (value);
......@@ -294,6 +295,8 @@ glade_signal_model_get_dummy_handler (GladeSignalModel* model,
g_hash_table_insert (model->priv->dummy_signals,
(gpointer) glade_signal_class_get_name (sig_class),
signal);
glade_project_verify_signal (model->priv->widget, signal);
}
return signal;
}
......@@ -389,14 +392,12 @@ on_glade_signal_model_changed (GladeWidget* widget, const GladeSignal* signal,
{
GtkTreeIter iter;
GtkTreePath* path;
const GladeSignalClass* sig_class =
glade_signal_get_class (signal);
const GladeSignalClass* sig_class = glade_signal_get_class (signal);
glade_signal_model_create_signal_iter (model,
glade_signal_class_get_type (sig_class),
signal,
&iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model),
&iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (model),
path,
&iter);
......@@ -404,6 +405,42 @@ on_glade_signal_model_changed (GladeWidget* widget, const GladeSignal* signal,
model->priv->stamp++;
}
static void
verify_dummies (const gchar *signal_name,
GladeSignal *signal,
GladeSignalModel *model)
{
glade_project_verify_signal (model->priv->widget, signal);
on_glade_signal_model_changed (model->priv->widget, signal, model);
}
static void
emit_changed (const gchar *signal_name,
GPtrArray *signals,
GladeSignalModel *model)
{
gint i;
GladeSignal *signal;
for (i = 0; i < signals->len; i++)
{
signal = (GladeSignal *)signals->pdata[i];
on_glade_signal_model_changed (model->priv->widget, signal, model);
}
}
static void
on_glade_widget_support_changed (GladeWidget *widget,
GladeSignalModel *model)
{
/* Update support warning on dummy signals */
g_hash_table_foreach (model->priv->dummy_signals, (GHFunc)verify_dummies, model);
/* row changed on every row */
g_hash_table_foreach (model->priv->signals, (GHFunc)emit_changed, model);
}
static gboolean
glade_signal_model_get_iter (GtkTreeModel* model,
GtkTreeIter* iter,
......
......@@ -238,6 +238,8 @@ glade_signal_new (const GladeSignalClass* sig_class,
gboolean after,
gboolean swapped)
{
g_return_if_fail (sig_class != NULL);
return (GladeSignal *)g_object_new (GLADE_TYPE_SIGNAL,
"class", sig_class,
"handler", 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