Commit 0a649c0e authored by Tristan Van Berkom's avatar Tristan Van Berkom

Fixed loading of images and only set image data when in the correct edit


	* plugins/gtk+/glade-gtk.c: Fixed loading of images and only set image
	data when in the correct edit mode.

	* plugins/gtk+/glade-convert.c: Fixed toolbutton conversions to search
	icon factories from the beginning of the object list and not the current
	list position.

	* gladeui/glade-project.c: When changing resource paths, reload all pixbuf
	properties automagically (this wont work for custom pixbufs like icon factory
	has).


svn path=/trunk/; revision=2024
parent a5c32c73
2008-11-12 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-gtk.c: Fixed loading of images and only set image
data when in the correct edit mode.
* plugins/gtk+/glade-convert.c: Fixed toolbutton conversions to search
icon factories from the beginning of the object list and not the current
list position.
* gladeui/glade-project.c: When changing resource paths, reload all pixbuf
properties automagically (this wont work for custom pixbufs like icon factory
has).
2008-11-08 Kjartan Maraas <kmaraas@gnome.org>
* gladeui/glade-utils.c: (glade_utils_get_pspec_from_funcname),
......
......@@ -1068,6 +1068,48 @@ glade_project_read_resource_path_from_comment (GladeXmlNode *comment)
return path;
}
static void
update_project_for_resource_path (GladeProject *project)
{
GladeWidget *widget;
GladeProperty *property;
GList *l, *list;
for (l = project->priv->objects; l; l = l->next)
{
widget = glade_widget_get_from_gobject (l->data);
for (list = widget->properties; list; list = list->next)
{
property = list->data;
/* XXX We should have a "resource" flag on properties that need
* to be loaded from the resource path, but that would require
* that they can serialize both ways (custom properties are only
* required to generate unique strings for value comparisons).
*/
if (property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
{
GValue *value;
gchar *string;
string = glade_property_class_make_string_from_gvalue
(property->klass, property->value, project->priv->format);
value = glade_property_class_make_gvalue_from_string
(property->klass, string, project, widget);
glade_property_set_value (property, value);
g_value_unset (value);
g_free (value);
g_free (string);
}
}
}
}
/* This function assumes ownership of 'path'. */
static void
......@@ -1077,6 +1119,7 @@ glade_project_set_resource_path (GladeProject *project,
g_free (project->priv->resource_path);
project->priv->resource_path = path;
update_project_for_resource_path (project);
update_prefs_for_resource_path (project);
}
......
......@@ -32,6 +32,7 @@
#include "glade-column-types.h"
#include "glade-model-data.h"
#include "glade-icon-sources.h"
#include "glade-tool-button-editor.h"
#include <gladeui/glade.h>
......@@ -602,6 +603,10 @@ convert_toolbuttons_finished (GladeProject *project,
filename = g_strdup_printf ("generated-icon-%s", tdata->text);
glade_util_replace (filename, '.', '-');
/* Set edit mode to stock for newly generated icon */
property = glade_widget_get_property (tdata->widget, "image-mode");
glade_command_set_property (property, GLADE_TB_MODE_STOCK);
/* Set stock-id for newly generated icon */
property = glade_widget_get_property (tdata->widget, "stock-id");
glade_command_set_property (property, filename);
......@@ -618,6 +623,10 @@ convert_toolbuttons_finished (GladeProject *project,
{
tdata = list->data;
/* Set edit mode to icon for converted icon */
property = glade_widget_get_property (tdata->widget, "image-mode");
glade_command_set_property (property, GLADE_TB_MODE_FILENAME);
value = glade_utils_value_from_string (GDK_TYPE_PIXBUF,
tdata->text,
project, tdata->widget);
......@@ -689,11 +698,12 @@ convert_toolbuttons (GladeProject *project,
*/
property = glade_widget_get_property (widget, "stock-id");
glade_property_get (property, &stock_id);
if (!stock_id)
continue;
if ((element =
g_list_find_custom ((GList *)objects, NULL,
g_list_find_custom ((GList *)glade_project_get_objects (project), NULL,
(GCompareFunc)find_icon_factory)) != NULL)
{
gfactory = glade_widget_get_from_gobject (element->data);
......@@ -709,6 +719,7 @@ convert_toolbuttons (GladeProject *project,
"GladeFileName");
if (filename)
{
tdata = g_new0 (TextData, 1);
tdata->widget = widget;
tdata->text = g_strdup (filename);
......
......@@ -5380,6 +5380,8 @@ glade_gtk_image_read_widget (GladeWidgetAdaptor *adaptor,
GladeWidget *widget,
GladeXmlNode *node)
{
GladeProperty *property;
if (!glade_xml_node_verify
(node, GLADE_XML_TAG_WIDGET (glade_project_get_format (widget->project))))
return;
......@@ -5388,13 +5390,24 @@ glade_gtk_image_read_widget (GladeWidgetAdaptor *adaptor,
GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
if (glade_widget_property_original_default (widget, "icon-name") == FALSE)
{
property = glade_widget_get_property (widget, "icon-name");
glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_ICON);
else if (glade_widget_property_original_default (widget, "stock") == FALSE)
glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK);
}
else if (glade_widget_property_original_default (widget, "pixbuf") == FALSE)
{
property = glade_widget_get_property (widget, "pixbuf");
glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_FILENAME);
else
glade_widget_property_reset (widget, "image-mode");
}
else/* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
{
property = glade_widget_get_property (widget, "stock");
glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK);
}
glade_property_sync (property);
}
......@@ -5438,8 +5451,8 @@ glade_gtk_image_write_widget (GladeWidgetAdaptor *adaptor,
static void
glade_gtk_image_set_image_mode (GObject *object, const GValue *value)
{
GladeWidget *gwidget;
GladeGtkImageType type;
GladeWidget *gwidget;
GladeImageEditMode type;
gwidget = glade_widget_get_from_gobject (object);
g_return_if_fail (GTK_IS_IMAGE (object));
......@@ -5510,8 +5523,36 @@ glade_gtk_image_set_property (GladeWidgetAdaptor *adaptor,
g_value_unset (&int_value);
}
else
{
GladeWidget *widget = glade_widget_get_from_gobject (object);
GladeImageEditMode mode = 0;
glade_widget_property_get (widget, "image-mode", &mode);
/* avoid setting properties in the wrong mode... */
switch (mode)
{
case GLADE_IMAGE_MODE_STOCK:
if (!strcmp (id, "icon-name") ||
!strcmp (id, "pixbuf"))
return;
break;
case GLADE_IMAGE_MODE_ICON:
if (!strcmp (id, "stock") ||
!strcmp (id, "pixbuf"))
return;
break;
case GLADE_IMAGE_MODE_FILENAME:
if (!strcmp (id, "stock") ||
!strcmp (id, "icon-name"))
return;
default:
break;
}
GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object,
id, value);
}
}
......
......@@ -7,26 +7,7 @@
/* Types */
typedef enum {
GLADEGTK_IMAGE_FILENAME = 0,
GLADEGTK_IMAGE_STOCK,
GLADEGTK_IMAGE_ICONTHEME
} GladeGtkImageType;
typedef enum {
GLADEGTK_BUTTON_LABEL = 0,
GLADEGTK_BUTTON_STOCK,
GLADEGTK_BUTTON_CONTAINER
} GladeGtkButtonType;
GType glade_gtk_image_type_get_type (void);
GType glade_gtk_button_type_get_type (void);
GParamSpec *glade_gtk_gnome_ui_info_spec (void);
GParamSpec *glade_gtk_image_type_spec (void);
GParamSpec *glade_gtk_button_type_spec (void);
#endif /* __GLADE_GTK_H__ */
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