[glade3/signal-tree-model: 338/358] gladeui: Implement version warning and tooltips in signal-model



commit c0c8184fe306a01861e1853f2de47d1603203afa
Author: Johannes Schmid <jhs gnome org>
Date:   Wed Jan 5 12:29:35 2011 +0100

    gladeui: Implement version warning and tooltips in signal-model

 gladeui/glade-signal-editor.c |   29 +++++++++++++++++++++++++----
 gladeui/glade-signal-model.c  |   37 ++++++++++++++++++++++++++++---------
 gladeui/glade-signal-model.h  |    3 ++-
 3 files changed, 55 insertions(+), 14 deletions(-)
---
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 0284f8f..8b7df2e 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -466,12 +466,29 @@ glade_signal_editor_init (GladeSignalEditor *self)
 
 	/* Create columns */
 	/* Signal name */
+	priv->column_name = gtk_tree_view_column_new ();
+
+	/* version warning */
+	renderer = gtk_cell_renderer_pixbuf_new ();
+	g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_DIALOG_WARNING,
+                NULL);
+	gtk_tree_view_column_pack_start (priv->column_name, renderer, FALSE);
+	gtk_tree_view_column_set_attributes (priv->column_name, renderer,
+	                                     "visible", GLADE_SIGNAL_COLUMN_VERSION_WARNING,
+	                                     NULL);
+	/* signal name */
 	renderer = gtk_cell_renderer_text_new ();
-	priv->column_name = gtk_tree_view_column_new_with_attributes (_("Signal"),
-	                                                              renderer,
-	                                                              NULL);
+	g_object_set (G_OBJECT (renderer),
+                "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 20, NULL);
+	gtk_tree_view_column_pack_end (priv->column_name, renderer, TRUE);
+
 	gtk_tree_view_column_set_cell_data_func (priv->column_name, renderer,
 	                                         name_cell_data_func, self, NULL);
+  
+	gtk_tree_view_column_set_resizable (priv->column_name, TRUE);
+	gtk_tree_view_column_set_expand (priv->column_name, TRUE);
+  
+	gtk_tree_view_column_set_title (priv->column_name, _("Signal")),
 	gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->signal_tree), priv->column_name);
 
 	/* Signal handler */
@@ -520,7 +537,11 @@ glade_signal_editor_init (GladeSignalEditor *self)
 	                                                               "sensitive", GLADE_SIGNAL_COLUMN_NOT_DUMMY,
 	                                                               NULL);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->signal_tree), priv->column_after);
-	
+
+	/* Tooltips */
+	gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (self->priv->signal_tree),
+	                                  GLADE_SIGNAL_COLUMN_TOOLTIP);
+  
 	/* Create scrolled window */
 	scroll = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
diff --git a/gladeui/glade-signal-model.c b/gladeui/glade-signal-model.c
index deb0cde..058b64b 100644
--- a/gladeui/glade-signal-model.c
+++ b/gladeui/glade-signal-model.c
@@ -20,6 +20,7 @@
 #endif
 
 #include "glade-signal-model.h"
+#include "glade-project.h"
 
 #include <glib/gi18n-lib.h>
 #include <string.h>
@@ -214,8 +215,6 @@ glade_signal_model_get_column_type (GtkTreeModel* model,
 {
 	switch (column)
 	{
-		case GLADE_SIGNAL_COLUMN_VERSION_WARNING:
-			return GDK_TYPE_PIXBUF;
 		case GLADE_SIGNAL_COLUMN_NAME:
 			return G_TYPE_STRING;
 		case GLADE_SIGNAL_COLUMN_HANDLER:
@@ -232,6 +231,10 @@ glade_signal_model_get_column_type (GtkTreeModel* model,
 			return G_TYPE_BOOLEAN;
 		case GLADE_SIGNAL_COLUMN_HAS_HANDLERS:
 			return G_TYPE_BOOLEAN;
+		case GLADE_SIGNAL_COLUMN_VERSION_WARNING:
+			return G_TYPE_BOOLEAN;
+		case GLADE_SIGNAL_COLUMN_TOOLTIP:
+			return G_TYPE_STRING;
 		case GLADE_SIGNAL_COLUMN_SIGNAL:
 			return G_TYPE_POINTER;
 		default:
@@ -298,12 +301,14 @@ static void
 glade_signal_model_create_handler_iter (GladeSignalModel* sig_model,
                                         const gchar* widget,
                                         GladeSignalClass* signal_class,
-                                        const GladeSignal* signal,
+                                        GladeSignal* signal,
                                         GtkTreeIter* iter)
 {
 	glade_signal_model_create_widget_iter (sig_model, widget, iter);
 	iter->user_data2 = signal_class;
-	iter->user_data3 = (GladeSignal*) signal;
+	iter->user_data3 = signal;
+  	/* Check the version warning here */
+    glade_project_verify_signal (sig_model->priv->widget, signal);
 }
 
 static void
@@ -389,7 +394,7 @@ glade_signal_model_iter_for_signal (GladeSignalModel* model, const GladeSignal*
 			glade_signal_model_create_handler_iter (model,
 			                                        glade_signal_class_get_type (sig_class),
 			                                        sig_class,
-			                                        signal,
+			                                        (GladeSignal*) signal,
 			                                        iter);
 			return TRUE;
 		}		
@@ -654,10 +659,6 @@ glade_signal_model_get_value (GtkTreeModel* model,
 	
 	switch (column)
 	{
-		case GLADE_SIGNAL_COLUMN_VERSION_WARNING:
-			/* TODO */
-			g_value_set_boolean (value, FALSE);
-			break;
 		case GLADE_SIGNAL_COLUMN_NAME:
 			if (widget && sig_class && handler)
 				g_value_set_static_string (value,
@@ -722,6 +723,24 @@ glade_signal_model_get_value (GtkTreeModel* model,
 			                     glade_signal_model_has_handlers (sig_model,
 			                                                      iter));
 			break;
+		case GLADE_SIGNAL_COLUMN_VERSION_WARNING:
+      {
+        gboolean warn = FALSE;
+			  if (handler)
+        {
+          const gchar* warning = glade_signal_get_support_warning (handler);
+				  warn = warning && strlen (warning);
+        }
+				g_value_set_boolean (value, warn);
+      }
+			break;
+		case GLADE_SIGNAL_COLUMN_TOOLTIP:
+			if (handler)
+				g_value_set_string (value,
+                            glade_signal_get_support_warning (handler));
+      else
+			  g_value_set_static_string (value, NULL);
+			break;
 		case GLADE_SIGNAL_COLUMN_SIGNAL:
 			g_value_set_pointer (value, handler);
 			break;
diff --git a/gladeui/glade-signal-model.h b/gladeui/glade-signal-model.h
index 98b2e51..19f63dc 100644
--- a/gladeui/glade-signal-model.h
+++ b/gladeui/glade-signal-model.h
@@ -44,8 +44,9 @@ typedef enum
 	GLADE_SIGNAL_COLUMN_AFTER,
 	GLADE_SIGNAL_COLUMN_IS_HANDLER,
 	GLADE_SIGNAL_COLUMN_NOT_DUMMY,
-	GLADE_SIGNAL_COLUMN_VERSION_WARNING,
 	GLADE_SIGNAL_COLUMN_HAS_HANDLERS,
+    GLADE_SIGNAL_COLUMN_VERSION_WARNING,
+    GLADE_SIGNAL_COLUMN_TOOLTIP,
 	GLADE_SIGNAL_COLUMN_SIGNAL,
 	GLADE_SIGNAL_N_COLUMNS
 } GladeSignalModelColumns;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]