summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schmid <jhs@gnome.org>2011-01-09 14:42:41 +0100
committerJohannes Schmid <jhs@gnome.org>2011-01-09 14:42:41 +0100
commitde236c5b7221296aeb34c2c1ca1da7b78e0227d9 (patch)
treeb50de7cbf7abe1c16bc9a66d09d2b42a45b031ad
parent937a5c800de64eed2afe03920679378f9de2bbec (diff)
downloadglade-de236c5b7221296aeb34c2c1ca1da7b78e0227d9.tar.gz
gladeui: Implemented devhelp column in signal-editor, fixed some bugs.
-rw-r--r--gladeui/glade-signal-editor.c128
-rw-r--r--gladeui/glade-signal-model.c97
-rw-r--r--gladeui/glade-signal-model.h1
3 files changed, 159 insertions, 67 deletions
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index f61bd2c7..fb3ce2ac 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -200,39 +200,44 @@ glade_signal_editor_user_data_activate (GtkCellRenderer * icon_renderer,
GList *selected = NULL;
GList *exception = NULL;
+ gboolean not_dummy = FALSE;
+
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
+ GLADE_SIGNAL_COLUMN_NOT_DUMMY, &not_dummy,
GLADE_SIGNAL_COLUMN_SIGNAL, &signal, -1);
- project = glade_widget_get_project (priv->widget);
-
- if (glade_signal_get_userdata (signal))
+ if (not_dummy)
{
- project_object =
- glade_project_get_widget_by_name (project, NULL,
- glade_signal_get_userdata (signal));
- selected = g_list_prepend (selected, project_object);
- }
-
- exception = g_list_prepend (exception, priv->widget);
-
- if (glade_editor_property_show_object_dialog (project,
- _("Select an object to pass to the handler"),
- gtk_widget_get_toplevel (GTK_WIDGET (editor)),
- G_TYPE_OBJECT, priv->widget,
- &project_object))
- {
- GladeSignal *old_signal = signal;
- GladeSignal *new_signal = glade_signal_clone (signal);
-
- glade_signal_set_userdata (new_signal,
- project_object ? glade_widget_get_name (project_object) : NULL);
-
- glade_command_change_signal (priv->widget, old_signal, new_signal);
- g_object_unref (new_signal);
- g_object_unref (old_signal);
- }
+ project = glade_widget_get_project (priv->widget);
+
+ if (glade_signal_get_userdata (signal))
+ {
+ project_object =
+ glade_project_get_widget_by_name (project, NULL,
+ glade_signal_get_userdata (signal));
+ selected = g_list_prepend (selected, project_object);
+ }
+
+ exception = g_list_prepend (exception, priv->widget);
+
+ if (glade_editor_property_show_object_dialog (project,
+ _("Select an object to pass to the handler"),
+ gtk_widget_get_toplevel (GTK_WIDGET (editor)),
+ G_TYPE_OBJECT, priv->widget,
+ &project_object))
+ {
+ GladeSignal *old_signal = signal;
+ GladeSignal *new_signal = glade_signal_clone (signal);
+
+ glade_signal_set_userdata (new_signal,
+ project_object ? glade_widget_get_name (project_object) : NULL);
+ glade_command_change_signal (priv->widget, old_signal, new_signal);
+ g_object_unref (new_signal);
+ }
+ }
+ g_object_unref (signal);
gtk_tree_path_free (path);
}
@@ -267,7 +272,8 @@ on_swap_toggled (GtkCellRendererToggle* renderer,
glade_command_change_signal (self->priv->widget, old_signal, new_signal);
g_object_unref (new_signal);
-
+ g_object_unref (old_signal);
+
gtk_tree_path_free (tree_path);
}
@@ -302,10 +308,45 @@ on_after_toggled (GtkCellRendererToggle* renderer,
glade_command_change_signal (self->priv->widget, old_signal, new_signal);
g_object_unref (new_signal);
+ g_object_unref (old_signal);
gtk_tree_path_free (tree_path);
}
+static void
+glade_signal_editor_devhelp (GtkCellRenderer * cell,
+ const gchar * path_str,
+ GladeSignalEditor * editor)
+{
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeModel *model = priv->model;
+ GtkTreeIter iter;
+ GladeWidgetAdaptor *adaptor;
+ const GladeSignalClass *signal_class;
+ GladeSignal *signal;
+ gchar *book;
+ gchar *search;
+
+ g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
+ gtk_tree_path_free (path);
+
+ gtk_tree_model_get (model, &iter,
+ GLADE_SIGNAL_COLUMN_SIGNAL, &signal,
+ -1);
+ signal_class = glade_signal_get_class (signal);
+ adaptor = glade_signal_class_get_adaptor (signal_class);
+ g_object_get (adaptor, "book", &book, NULL);
+
+ search = g_strdup_printf ("The %s signal", glade_signal_get_name (signal));
+
+ glade_app_search_docs (book, glade_widget_adaptor_get_name (adaptor), search);
+
+ g_free (search);
+ g_free (book);
+ g_object_unref (signal);
+}
+
/**
* glade_signal_editor_new:
*
@@ -503,13 +544,13 @@ glade_signal_editor_init (GladeSignalEditor *self)
/* Signal handler */
renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer,
- "editable", TRUE, NULL);
g_signal_connect (renderer, "edited", G_CALLBACK(on_handler_edited), self);
g_signal_connect (renderer, "editing-started", G_CALLBACK (on_handler_editing_started), self);
priv->column_handler = gtk_tree_view_column_new_with_attributes (_("Handler"),
renderer,
"text", GLADE_SIGNAL_COLUMN_HANDLER,
+ "editable", GLADE_SIGNAL_COLUMN_IS_HANDLER,
+ "visible", GLADE_SIGNAL_COLUMN_IS_HANDLER,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->signal_tree), priv->column_handler);
@@ -528,6 +569,7 @@ glade_signal_editor_init (GladeSignalEditor *self)
priv->renderer_userdata,
"text", GLADE_SIGNAL_COLUMN_OBJECT,
"sensitive", GLADE_SIGNAL_COLUMN_NOT_DUMMY,
+ "visible", GLADE_SIGNAL_COLUMN_IS_HANDLER,
NULL);
@@ -547,6 +589,7 @@ glade_signal_editor_init (GladeSignalEditor *self)
_("User data"));
gtk_tree_view_column_set_attributes (priv->column_userdata, renderer,
"sensitive", GLADE_SIGNAL_COLUMN_NOT_DUMMY,
+ "visible", GLADE_SIGNAL_COLUMN_IS_HANDLER,
NULL);
gtk_tree_view_column_set_resizable (priv->column_userdata, TRUE);
@@ -559,6 +602,7 @@ glade_signal_editor_init (GladeSignalEditor *self)
priv->column_swap = gtk_tree_view_column_new_with_attributes (_("Swap"),
renderer,
"active", GLADE_SIGNAL_COLUMN_SWAP,
+ "visible", GLADE_SIGNAL_COLUMN_IS_HANDLER,
"sensitive", GLADE_SIGNAL_COLUMN_NOT_DUMMY,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->signal_tree), priv->column_swap);
@@ -569,10 +613,34 @@ glade_signal_editor_init (GladeSignalEditor *self)
priv->column_after = gtk_tree_view_column_new_with_attributes (_("After"),
renderer,
"active", GLADE_SIGNAL_COLUMN_AFTER,
+ "visible", GLADE_SIGNAL_COLUMN_IS_HANDLER,
"sensitive", GLADE_SIGNAL_COLUMN_NOT_DUMMY,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->signal_tree), priv->column_after);
+ /* Devhelp */
+ if (glade_util_have_devhelp ())
+ {
+ renderer = glade_cell_renderer_icon_new ();
+
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+
+ if (gtk_icon_theme_has_icon
+ (gtk_icon_theme_get_default (), GLADE_DEVHELP_ICON_NAME))
+ g_object_set (G_OBJECT (renderer), "icon-name", GLADE_DEVHELP_ICON_NAME,
+ NULL);
+ else
+ g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_INFO, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "activate",
+ G_CALLBACK (glade_signal_editor_devhelp), self);
+
+ gtk_tree_view_column_pack_end (priv->column_after, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (priv->column_after, renderer,
+ "visible", GLADE_SIGNAL_COLUMN_SHOW_DEVHELP, NULL);
+
+ }
+
/* Tooltips */
gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (self->priv->signal_tree),
GLADE_SIGNAL_COLUMN_TOOLTIP);
diff --git a/gladeui/glade-signal-model.c b/gladeui/glade-signal-model.c
index 2ce0418d..681ebe16 100644
--- a/gladeui/glade-signal-model.c
+++ b/gladeui/glade-signal-model.c
@@ -254,6 +254,8 @@ glade_signal_model_get_column_type (GtkTreeModel* model,
return G_TYPE_BOOLEAN;
case GLADE_SIGNAL_COLUMN_TOOLTIP:
return G_TYPE_STRING;
+ case GLADE_SIGNAL_COLUMN_SHOW_DEVHELP:
+ return G_TYPE_BOOLEAN;
case GLADE_SIGNAL_COLUMN_SIGNAL:
return G_TYPE_OBJECT;
default:
@@ -268,6 +270,21 @@ enum
ITER_SIGNAL = 1,
};
+static gboolean
+glade_signal_model_is_dummy_handler (GladeSignalModel* model,
+ GladeSignal* signal)
+{
+ GladeSignal* dummy;
+
+ dummy = g_hash_table_lookup (model->priv->dummy_signals,
+ glade_signal_get_name (signal));
+
+ if (dummy && (signal == dummy))
+ return TRUE;
+
+ return FALSE;
+}
+
static GladeSignal*
glade_signal_model_get_dummy_handler (GladeSignalModel* model,
const GladeSignalClass* sig_class)
@@ -291,19 +308,6 @@ glade_signal_model_get_dummy_handler (GladeSignalModel* model,
return signal;
}
-static gboolean
-glade_signal_model_not_dummy_handler (GladeSignalModel* model,
- GtkTreeIter* iter)
-{
- const gchar* widget = iter->user_data;
- GladeSignal* handler = iter->user_data2;
-
- if (widget && handler)
- return handler != glade_signal_model_get_dummy_handler (model,
- glade_signal_get_class (handler));
- return FALSE;
-}
-
static void
glade_signal_model_create_widget_iter (GladeSignalModel* sig_model,
const gchar* widget,
@@ -547,18 +551,18 @@ glade_signal_model_get_value (GtkTreeModel* model,
switch (column)
{
case GLADE_SIGNAL_COLUMN_NAME:
- if (widget && handler)
+ if (handler)
{
g_value_set_static_string (value,
glade_signal_get_name (handler));
-
+ break;
}
- else if (widget)
+ else
g_value_set_static_string (value,
widget);
break;
case GLADE_SIGNAL_COLUMN_SHOW_NAME:
- if (widget && handler)
+ if (handler)
{
GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->signals,
glade_signal_get_name (handler));
@@ -568,13 +572,14 @@ glade_signal_model_get_value (GtkTreeModel* model,
else
g_value_set_boolean (value,
FALSE);
+ break;
}
else if (widget)
g_value_set_boolean (value,
TRUE);
break;
case GLADE_SIGNAL_COLUMN_HANDLER:
- if (widget && handler)
+ if (handler)
g_value_set_static_string (value,
glade_signal_get_handler (handler));
else
@@ -582,22 +587,23 @@ glade_signal_model_get_value (GtkTreeModel* model,
"");
break;
case GLADE_SIGNAL_COLUMN_OBJECT:
- if (widget && handler)
- {
- const gchar* userdata = glade_signal_get_userdata (handler);
- if (userdata && strlen (userdata))
- g_value_set_static_string (value,
- userdata);
- else
- g_value_set_static_string (value,
- USERDATA_DEFAULT);
- }
+ if (handler)
+ {
+ const gchar* userdata = glade_signal_get_userdata (handler);
+ if (userdata && strlen (userdata))
+ g_value_set_static_string (value,
+ userdata);
+ else
+ g_value_set_static_string (value,
+ USERDATA_DEFAULT);
+ break;
+ }
else
g_value_set_static_string (value,
"");
break;
case GLADE_SIGNAL_COLUMN_SWAP:
- if (widget && handler)
+ if (handler)
g_value_set_boolean (value,
glade_signal_get_swapped (handler));
else
@@ -605,7 +611,7 @@ glade_signal_model_get_value (GtkTreeModel* model,
FALSE);
break;
case GLADE_SIGNAL_COLUMN_AFTER:
- if (widget && handler)
+ if (handler)
g_value_set_boolean (value,
glade_signal_get_after (handler));
else
@@ -614,13 +620,18 @@ glade_signal_model_get_value (GtkTreeModel* model,
break;
case GLADE_SIGNAL_COLUMN_IS_HANDLER:
g_value_set_boolean (value,
- widget && handler);
+ handler != NULL);
break;
case GLADE_SIGNAL_COLUMN_NOT_DUMMY:
+ {
+ gboolean is_dummy = handler ?
+ glade_signal_model_is_dummy_handler (sig_model,
+ handler) :
+ TRUE;
g_value_set_boolean (value,
- glade_signal_model_not_dummy_handler (sig_model,
- iter));
+ !is_dummy);
break;
+ }
case GLADE_SIGNAL_COLUMN_VERSION_WARNING:
{
gboolean warn = FALSE;
@@ -630,8 +641,8 @@ glade_signal_model_get_value (GtkTreeModel* model,
warn = warning && strlen (warning);
}
g_value_set_boolean (value, warn);
- }
break;
+ }
case GLADE_SIGNAL_COLUMN_TOOLTIP:
if (handler)
g_value_set_string (value,
@@ -639,6 +650,20 @@ glade_signal_model_get_value (GtkTreeModel* model,
else
g_value_set_static_string (value, NULL);
break;
+ case GLADE_SIGNAL_COLUMN_SHOW_DEVHELP:
+ if (handler)
+ {
+ const GladeSignalClass* class = glade_signal_get_class (handler);
+ GladeWidgetAdaptor* adaptor = glade_signal_class_get_adaptor (class);
+ gchar* book;
+
+ g_object_get (adaptor, "book", &book, NULL);
+ g_value_set_boolean (value, book != NULL);
+ g_free (book);
+ break;
+ }
+ g_value_set_boolean (value, FALSE);
+ break;
case GLADE_SIGNAL_COLUMN_SIGNAL:
g_value_set_object (value, handler);
break;
@@ -715,9 +740,7 @@ glade_signal_model_iter_next (GtkTreeModel* model,
GList* signal = g_list_find (signals, sig_class);
GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->signals,
glade_signal_class_get_name (sig_class));
- GladeSignal* dummy = glade_signal_model_get_dummy_handler (sig_model,
- sig_class);
- if (handler == dummy)
+ if (glade_signal_model_is_dummy_handler (sig_model, handler))
{
return glade_signal_model_iter_next_signal (sig_model, widget, iter, signal);
}
diff --git a/gladeui/glade-signal-model.h b/gladeui/glade-signal-model.h
index 52072446..970717a0 100644
--- a/gladeui/glade-signal-model.h
+++ b/gladeui/glade-signal-model.h
@@ -47,6 +47,7 @@ typedef enum
GLADE_SIGNAL_COLUMN_NOT_DUMMY,
GLADE_SIGNAL_COLUMN_VERSION_WARNING,
GLADE_SIGNAL_COLUMN_TOOLTIP,
+ GLADE_SIGNAL_COLUMN_SHOW_DEVHELP,
GLADE_SIGNAL_COLUMN_SIGNAL,
GLADE_SIGNAL_N_COLUMNS
} GladeSignalModelColumns;