[glade3] * gladeui/glade-marshallers.list, gladeui/glade-placeholder.c: Make GladePlaceholder a scrollabl



commit 799a017db3f12468e719500a3fa5be5c0c078299
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat Mar 27 14:51:00 2010 -0400

    	* gladeui/glade-marshallers.list, gladeui/glade-placeholder.c:
    	  Make GladePlaceholder a scrollable widget (hypothetically) to avoid runtime warnings.
    
    	* plugins/gtk+/gtk+.xml.in: Disabled "has-separator" of GtkMessageDialog as it ignores the separator
    	  and the setting is useless (not to mention setting it causes runtime warnings: fixes bug 587288).
    
    	* gladeui/glade-project.[ch]: Expose glade_project_get_target_version()
    
    	* plugins/gtk+/glade-gtk.c:
    	  - check project target gtk+ version to decide initial state
    	    of GtkEntry::buffer.
    	  - Substitute the old manual evaluation with GPC_VERSION_CHECK()
    	  - Avoid critical warnings when setting GtkColorButton properties to NULL
    	  - Avoid critical warnings when setting GtkComboBoxEntry::text-column < 0
    
    	* gladeui/glade-property-class.h: Created convenience macro GPC_VERSION_CHECK
    
    	* gladeui/glade-utils.c: Allow loading of libraries installed in optional non-system prefixes;
    	  (so that GtkSourceView catalog is buildable and usable from your jhbuild environment)
    	  assume a path that is: ${prefix}/lib/glade3/modules/../../ and search it after the initial
    	  module search path.

 ChangeLog                      |   24 +++++++++++++
 gladeui/glade-marshallers.list |    1 +
 gladeui/glade-placeholder.c    |   14 ++++++++
 gladeui/glade-project.c        |   47 ++++++++++++++++----------
 gladeui/glade-project.h        |    4 ++
 gladeui/glade-property-class.h |   14 ++++++++
 gladeui/glade-utils.c          |   15 ++++++++-
 plugins/gtk+/glade-gtk.c       |   73 ++++++++++++++++++++++++++++++++--------
 plugins/gtk+/gtk+.xml.in       |    5 +++
 9 files changed, 164 insertions(+), 33 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2741b54..af16870 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2010-03-27  Tristan Van Berkom <tvb gnome org>
+
+	* gladeui/glade-marshallers.list, gladeui/glade-placeholder.c: 
+	  Make GladePlaceholder a scrollable widget (hypothetically) to avoid runtime warnings.
+
+	* plugins/gtk+/gtk+.xml.in: Disabled "has-separator" of GtkMessageDialog as it ignores the separator
+	  and the setting is useless (not to mention setting it causes runtime warnings: fixes bug 587288).
+
+	* gladeui/glade-project.[ch]: Expose glade_project_get_target_version()
+
+	* plugins/gtk+/glade-gtk.c: 
+	  - check project target gtk+ version to decide initial state
+	    of GtkEntry::buffer.
+	  - Substitute the old manual evaluation with GPC_VERSION_CHECK()
+	  - Avoid critical warnings when setting GtkColorButton properties to NULL
+	  - Avoid critical warnings when setting GtkComboBoxEntry::text-column < 0
+	
+	* gladeui/glade-property-class.h: Created convenience macro GPC_VERSION_CHECK
+
+	* gladeui/glade-utils.c: Allow loading of libraries installed in optional non-system prefixes;
+	  (so that GtkSourceView catalog is buildable and usable from your jhbuild environment)
+	  assume a path that is: ${prefix}/lib/glade3/modules/../../ and search it after the initial 
+	  module search path.
+
 2010-03-26  Tristan Van Berkom <tvb gnome org>
 
 	* gladeui/glade-palette.c: Left aligned and ellipsize end widget group titles (restored normal
diff --git a/gladeui/glade-marshallers.list b/gladeui/glade-marshallers.list
index 26b5c55..753a999 100644
--- a/gladeui/glade-marshallers.list
+++ b/gladeui/glade-marshallers.list
@@ -2,6 +2,7 @@ VOID:POINTER,POINTER
 VOID:POINTER
 VOID:STRING,ULONG,UINT,STRING
 VOID:OBJECT
+VOID:OBJECT,OBJECT
 VOID:OBJECT,BOOLEAN
 VOID:STRING,STRING,STRING
 OBJECT:POINTER
diff --git a/gladeui/glade-placeholder.c b/gladeui/glade-placeholder.c
index a902e7a..b35eabc 100644
--- a/gladeui/glade-placeholder.c
+++ b/gladeui/glade-placeholder.c
@@ -35,6 +35,7 @@
  */
 
 #include <gtk/gtk.h>
+#include "glade-marshallers.h"
 #include "glade.h"
 #include "glade-placeholder.h"
 #include "glade-xml-utils.h"
@@ -101,6 +102,19 @@ glade_placeholder_class_init (GladePlaceholderClass *klass)
 	widget_class->motion_notify_event = glade_placeholder_motion_notify_event;
 	widget_class->button_press_event = glade_placeholder_button_press;
 	widget_class->popup_menu = glade_placeholder_popup_menu;
+
+	/* Avoid warnings when adding placeholders to scrolled windows */
+	widget_class->set_scroll_adjustments_signal =
+		g_signal_new ("set-scroll-adjustments",
+			      G_TYPE_FROM_CLASS (klass),
+			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+			      0, /* G_STRUCT_OFFSET (GladePlaceholderClass, set_scroll_adjustments) */
+			      NULL, NULL,
+			      glade_marshal_VOID__OBJECT_OBJECT,
+			      G_TYPE_NONE, 2,
+			      GTK_TYPE_ADJUSTMENT,
+			      GTK_TYPE_ADJUSTMENT);
+
 }
 
 static void
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 599bec4..98cd437 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -169,10 +169,6 @@ static void         glade_project_set_target_version       (GladeProject *projec
 							    const gchar  *catalog,
 							    guint16       major,
 							    guint16       minor);
-static void         glade_project_get_target_version       (GladeProject *project,
-							    const gchar  *catalog,
-							    gint         *major,
-							    gint         *minor);
 
 static void         glade_project_target_version_for_adaptor (GladeProject        *project, 
 							      GladeWidgetAdaptor  *adaptor,
@@ -2800,20 +2796,6 @@ adjust_naming_policy (GladeProject       *project,
                         Remaining stubs and api
  *******************************************************************/
 static void
-glade_project_get_target_version (GladeProject *project,
-				  const gchar  *catalog,
-				  gint         *major,
-				  gint         *minor)
-{
-	*major = GPOINTER_TO_INT 
-		(g_hash_table_lookup (project->priv->target_versions_major,
-				      catalog));
-	*minor = GPOINTER_TO_INT 
-		(g_hash_table_lookup (project->priv->target_versions_minor,
-				      catalog));
-}
-
-static void
 glade_project_set_target_version (GladeProject *project,
 				  const gchar  *catalog,
 				  guint16       major,
@@ -2874,6 +2856,35 @@ glade_project_set_readonly (GladeProject *project, gboolean readonly)
 	}
 }                                                                                               
 
+
+/**
+ * glade_project_get_target_version:
+ * @project: a #GladeProject
+ * @catalog: the name of the catalog @project includes
+ * @major: the return location for the target major version
+ * @minor: the return location for the target minor version
+ *
+ * Fetches the target version of the @project for @catalog.
+ *
+ */
+void
+glade_project_get_target_version (GladeProject *project,
+				  const gchar  *catalog,
+				  gint         *major,
+				  gint         *minor)
+{
+	g_return_if_fail (GLADE_IS_PROJECT (project));
+	g_return_if_fail (catalog && catalog[0]);
+	g_return_if_fail (major && minor);
+
+	*major = GPOINTER_TO_INT 
+		(g_hash_table_lookup (project->priv->target_versions_major,
+				      catalog));
+	*minor = GPOINTER_TO_INT 
+		(g_hash_table_lookup (project->priv->target_versions_minor,
+				      catalog));
+}
+
 /**
  * glade_project_get_readonly:
  * @project: a #GladeProject
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index 4a679f5..91e2ac5 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -185,6 +185,10 @@ void          glade_project_set_naming_policy      (GladeProject       *project,
 						    GladeNamingPolicy   policy);
 
 GladeNamingPolicy glade_project_get_naming_policy  (GladeProject       *project);
+void          glade_project_get_target_version     (GladeProject       *project,
+						    const gchar        *catalog,
+						    gint               *major,
+						    gint               *minor);
 
 G_END_DECLS
 
diff --git a/gladeui/glade-property-class.h b/gladeui/glade-property-class.h
index c7247d2..f2f0323 100644
--- a/gladeui/glade-property-class.h
+++ b/gladeui/glade-property-class.h
@@ -34,6 +34,20 @@ G_BEGIN_DECLS
 	 ((type) == GLADE_PAGE_QUERY   && (gpc)->query))
 
 
+/**
+ * GPC_CHECK_RUNTIME:
+ * @klass: A #GladePropertyClass
+ * @major_version: The major version to check
+ * @minor_version: The minor version to check
+ *
+ * Evaluates to %TRUE if @klass is available in its owning library version- major_verion @minor_version.
+ *
+ */
+#define GPC_VERSION_CHECK(klass, major_version, minor_version)		\
+	(GLADE_PROPERTY_CLASS (klass)->version_since_major <= major_version && \
+	 GLADE_PROPERTY_CLASS (klass)->version_since_minor <= (minor_version))
+
+
 #define GPC_OBJECT_DELIMITER ", "
 #define GPC_PROPERTY_NAMELEN 512  /* Enough space for a property name I think */
 
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index 7d9738b..16d6a3b 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -1478,12 +1478,20 @@ try_load_library (const gchar *library_path,
 GModule *
 glade_util_load_library (const gchar *library_name)
 {
+	gchar        *default_paths[] = { (gchar *)glade_app_get_modules_dir (), 
+					  NULL, /* <-- dynamically allocated */ 
+					  "/lib", 
+					  "/usr/lib", 
+					  "/usr/local/lib", 
+					  NULL };
+
 	GModule      *module = NULL;
-	const gchar  *default_paths[] = { glade_app_get_modules_dir (), "/lib", "/usr/lib", "/usr/local/lib", NULL };
 	const gchar  *search_path;
 	gchar       **split;
 	gint          i;
+
 	
+
 	if ((search_path = g_getenv (GLADE_ENV_MODULE_PATH)) != NULL)
 	{
 		if ((split = g_strsplit (search_path, ":", 0)) != NULL)
@@ -1498,9 +1506,14 @@ glade_util_load_library (const gchar *library_name)
 
 	if (!module)
 	{
+		/* Search ${prefix}/lib after searching ${prefix}/lib/glade3/modules... */
+		default_paths[1] = g_build_filename (glade_app_get_modules_dir (), "..", "..", NULL);
+
 		for (i = 0; default_paths[i] != NULL; i++)
 			if ((module = try_load_library (default_paths[i], library_name)) != NULL)
 				break;
+
+		g_free (default_paths[1]);
 	}
 
 	if (!module)
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 7df81cd..e0857dd 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -4985,8 +4985,7 @@ glade_gtk_entry_set_property (GladeWidgetAdaptor *adaptor,
 		g_signal_handlers_unblock_by_func (object, glade_gtk_entry_changed, gwidget);
 
        	}
-	else if (property->klass->version_since_major <= gtk_major_version &&
-		 property->klass->version_since_minor <= (gtk_minor_version + 1))
+	else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
 		GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
 }
 
@@ -5008,14 +5007,26 @@ glade_gtk_entry_read_widget (GladeWidgetAdaptor *adaptor,
 	{
 		property = glade_widget_get_property (widget, "text");
 		glade_widget_property_set (widget, "use-entry-buffer", FALSE);
+
+		glade_property_sync (property);
 	}
 	else
 	{
+		gint target_minor, target_major;
+
+		glade_project_get_target_version (widget->project, "gtk+", &target_major, &target_minor);
+
 		property = glade_widget_get_property (widget, "buffer");
-		glade_widget_property_set (widget, "use-entry-buffer", TRUE);
-	}
 
-	glade_property_sync (property);
+		/* Only default to the buffer setting if the project version supports it. */
+		if (GPC_VERSION_CHECK (property->klass, target_major, target_minor))
+		{
+			glade_widget_property_set (widget, "use-entry-buffer", TRUE);
+			glade_property_sync (property);
+		}
+		else
+			glade_widget_property_set (widget, "use-entry-buffer", FALSE);
+	}
 
 	if (glade_widget_property_original_default (widget, "primary-icon-name") == FALSE)
 	{
@@ -5949,6 +5960,26 @@ glade_gtk_color_button_refresh_color (GtkColorButton  *button,
 		glade_command_set_property (property, &color);
 }
 
+
+void
+glade_gtk_color_button_set_property (GladeWidgetAdaptor *adaptor,
+				     GObject            *object, 
+				     const gchar        *id,
+				     const GValue       *value)
+{
+	if (!strcmp (id, "color"))
+	{
+		if (g_value_get_boxed (value))
+			gtk_color_button_set_color (GTK_COLOR_BUTTON (object), 
+						    (GdkColor *)g_value_get_boxed (value));
+	}
+	else
+		GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor,
+							       object,
+							       id, value);
+}
+
+
 /* ----------------------------- GtkButton ------------------------------ */
 
 static void 
@@ -6112,8 +6143,7 @@ glade_gtk_button_set_property (GladeWidgetAdaptor *adaptor,
 								  id, value);
 		sync_use_appearance (widget);
 	}
-	else if (property->klass->version_since_major <= gtk_major_version &&
-		 property->klass->version_since_minor <= (gtk_minor_version + 1))
+	else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
 		GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
 								  id, value);
 }
@@ -7009,8 +7039,7 @@ glade_gtk_menu_item_set_property (GladeWidgetAdaptor *adaptor,
 		glade_gtk_menu_item_set_use_underline (object, value);
 	else if (!strcmp (id, "label"))
 		glade_gtk_menu_item_set_label (object, value);
-	else if (property->klass->version_since_major <= gtk_major_version &&
-		 property->klass->version_since_minor <= (gtk_minor_version + 1))
+	else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
 		GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
 								  id, value);
 }
@@ -7888,9 +7917,7 @@ glade_gtk_tool_item_set_property (GladeWidgetAdaptor *adaptor,
 	GladeProperty *property = glade_widget_get_property (gwidget, id);
 
 	//evaluate_activatable_property_sensitivity (object, id, value);
-
-	if (property->klass->version_since_major <= gtk_major_version &&
-	    property->klass->version_since_minor <= (gtk_minor_version + 1))
+	if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
 		GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
 								  object,
 								  id, value);
@@ -8728,8 +8755,7 @@ glade_gtk_entry_buffer_set_property (GladeWidgetAdaptor *adaptor,
 		g_signal_handlers_unblock_by_func (object, glade_gtk_entry_buffer_changed, gwidget);
 
        	}
-	else if (property->klass->version_since_major <= gtk_major_version &&
-		 property->klass->version_since_minor <= (gtk_minor_version + 1))
+	else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
 		GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
 }
 
@@ -8983,6 +9009,25 @@ glade_gtk_combo_box_entry_get_internal_child (GladeWidgetAdaptor *adaptor,
 	return child;
 }
 
+
+void
+glade_gtk_combo_box_entry_set_property (GladeWidgetAdaptor *adaptor,
+					GObject            *object, 
+					const gchar        *id,
+					const GValue       *value)
+{
+	if (!strcmp (id, "text-column"))
+	{
+		if (g_value_get_int (value) >= 0)
+			gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (object), 
+							     g_value_get_int (value));
+	}
+	else
+		GWA_GET_CLASS (GTK_TYPE_COMBO_BOX)->set_property (adaptor,
+								  object,
+								  id, value);
+}
+
 /* ----------------------------- GtkSpinButton ------------------------------ */
 static void
 glade_gtk_spin_button_set_adjustment (GObject *object, const GValue *value)
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 57673e0..049396b 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -876,6 +876,7 @@ embedded in another object</_tooltip>
 	  <_tooltip>Set the text in the view's text buffer</_tooltip>
 	  <visible-lines>2</visible-lines>
 	</property>
+      	<property id="im-module" disabled="True"/>
       	<property id="wrap-mode">
   	  <displayable-values>
 	    <value id="GTK_WRAP_NONE" _name="None"/>
@@ -1070,6 +1071,7 @@ embedded in another object</_tooltip>
 
     <glade-widget-class name="GtkColorButton" generic-name="colorbutton" _title="Color Button">
       <create-editable-function>glade_gtk_container_create_editable</create-editable-function>
+      <set-property-function>glade_gtk_color_button_set_property</set-property-function>
       <properties>
 	<property id="title" translatable="True"/>
 	<property id="color" default="Black"/>
@@ -1153,6 +1155,7 @@ embedded in another object</_tooltip>
     <glade-widget-class name="GtkComboBoxEntry" generic-name="comboboxentry" _title="Combo Box Entry">
       <post-create-function>glade_gtk_combo_box_entry_post_create</post-create-function>
       <get-internal-child-function>glade_gtk_combo_box_entry_get_internal_child</get-internal-child-function>
+      <set-property-function>glade_gtk_combo_box_entry_set_property</set-property-function>
     </glade-widget-class>
 
     <glade-widget-class name="GtkProgressBar" generic-name="progressbar" _title="Progress Bar">
@@ -1659,6 +1662,8 @@ embedded in another object</_tooltip>
       <verify-function>glade_gtk_message_dialog_verify_property</verify-function>
 
       <properties>
+        <property id="has-separator"  disabled="True"/>
+
 	<property id="default-width"  default="400" optional="True" optional-default="False"/>
 	<property id="default-height" default="115" optional="True" optional-default="False"/>
 



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