glade3 r1982 - in trunk: . doc gladeui plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r1982 - in trunk: . doc gladeui plugins/gtk+
- Date: Tue, 21 Oct 2008 02:16:28 +0000 (UTC)
Author: tvb
Date: Tue Oct 21 02:16:28 2008
New Revision: 1982
URL: http://svn.gnome.org/viewvc/glade3?rev=1982&view=rev
Log:
* plugins/gtk+/glade-cell-renderer-button.[ch], plugins/gtk+/glade-text-button.[ch]:
Now can optionally make the entry non editable.
* plugins/gtk+/glade-model-data.c: Added pixbuf editing support.
* doc/widgetclasses.sgml, doc/properties.sgml: Clarified docs.
* gladeui/glade-editor-property.[ch]: Removed resource editor, edit pixbuf with
string editor.
* gladeui/glade-widget-adaptor.c, gladeui/glade-property-class.c,
gladeui/glade-project.[ch]: Completely removed concept of resources, glade
no longer copies along pixbufs, pixbuf properties can include full paths
or relative paths, in the glade runtime; any pixbufs are only ever loaded
from the glade project directory (only the basename is used).
Modified:
trunk/ChangeLog
trunk/doc/properties.sgml
trunk/doc/widgetclasses.sgml
trunk/gladeui/glade-editor-property.c
trunk/gladeui/glade-editor-property.h
trunk/gladeui/glade-project.c
trunk/gladeui/glade-project.h
trunk/gladeui/glade-property-class.c
trunk/gladeui/glade-property-class.h
trunk/gladeui/glade-widget-adaptor.c
trunk/plugins/gtk+/glade-cell-renderer-button.c
trunk/plugins/gtk+/glade-gtk.c
trunk/plugins/gtk+/glade-model-data.c
trunk/plugins/gtk+/glade-text-button.c
Modified: trunk/doc/properties.sgml
==============================================================================
--- trunk/doc/properties.sgml (original)
+++ trunk/doc/properties.sgml Tue Oct 21 02:16:28 2008
@@ -168,17 +168,6 @@
</varlistentry>
<varlistentry>
- <term>resource</term>
- <listitem>
- <para>
-Depicts string properties that represent filenames that are packaged with
-the glade file (like pixbufs); you can set this to "True" and the string
-property will be treated like a resource.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
<term>themed-icon</term>
<listitem>
<para>
Modified: trunk/doc/widgetclasses.sgml
==============================================================================
--- trunk/doc/widgetclasses.sgml (original)
+++ trunk/doc/widgetclasses.sgml Tue Oct 21 02:16:28 2008
@@ -445,7 +445,8 @@
<term>string-from-value-function</term>
<listitem>
<para>
-A #GladeStringFromValueFunc to create a string from a #GValue.
+A #GladeStringFromValueFunc to create a string from a #GValue, these strings must
+be unique and comparable for undo/redo to work properly.
</para>
</listitem>
</varlistentry>
Modified: trunk/gladeui/glade-editor-property.c
==============================================================================
--- trunk/gladeui/glade-editor-property.c (original)
+++ trunk/gladeui/glade-editor-property.c Tue Oct 21 02:16:28 2008
@@ -1558,10 +1558,17 @@
if (GTK_IS_ENTRY (eprop_text->text_entry))
{
GtkEntry *entry = GTK_ENTRY (eprop_text->text_entry);
- const gchar *text = g_value_get_string (property->value);
+ const gchar *text = NULL;
+ if (G_VALUE_TYPE (property->value) == G_TYPE_STRING)
+ text = g_value_get_string (property->value);
+ else if (G_VALUE_TYPE (property->value) == GDK_TYPE_PIXBUF)
+ {
+ GObject *object = g_value_get_object (property->value);
+ if (object)
+ text = g_object_get_data (object, "GladeFileName");
+ }
gtk_entry_set_text (entry, text ? text : "");
-
}
else if (GTK_IS_TEXT_VIEW (eprop_text->text_entry))
{
@@ -1599,10 +1606,12 @@
gchar *prop_text;
if (eprop->property->klass->pspec->value_type == G_TYPE_STRV ||
- eprop->property->klass->pspec->value_type == G_TYPE_VALUE_ARRAY)
+ eprop->property->klass->pspec->value_type == G_TYPE_VALUE_ARRAY ||
+ eprop->property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
{
val = glade_property_class_make_gvalue_from_string
- (eprop->property->klass, text, NULL, NULL);
+ (eprop->property->klass, text,
+ eprop->property->widget->project, eprop->property->widget);
}
else
{
@@ -2202,164 +2211,6 @@
}
/*******************************************************************************
- GladeEditorPropertyResourceClass
- *******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
-
- GtkWidget *entry, *button;
-} GladeEPropResource;
-
-GLADE_MAKE_EPROP (GladeEPropResource, glade_eprop_resource)
-#define GLADE_EPROP_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_RESOURCE, GladeEPropResource))
-#define GLADE_EPROP_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_RESOURCE, GladeEPropResourceClass))
-#define GLADE_IS_EPROP_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_RESOURCE))
-#define GLADE_IS_EPROP_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_RESOURCE))
-#define GLADE_EPROP_RESOURCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_RESOURCE, GladeEPropResourceClass))
-
-static void
-glade_eprop_resource_finalize (GObject *object)
-{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
-}
-
-static void
-glade_eprop_resource_entry_activate (GtkEntry *entry, GladeEditorProperty *eprop)
-{
- GladeProject *project = glade_widget_get_project (eprop->property->widget);
- GValue *value = glade_property_class_make_gvalue_from_string
- (eprop->klass, gtk_entry_get_text(entry), project, eprop->property->widget);
-
- /* Set project resource here where we still have the fullpath.
- */
- glade_project_set_resource (project, eprop->property,
- gtk_entry_get_text(entry));
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
-}
-
-static gboolean
-glade_eprop_resource_entry_focus_out (GtkWidget *entry,
- GdkEventFocus *event,
- GladeEditorProperty *eprop)
-{
- glade_eprop_resource_entry_activate (GTK_ENTRY (entry), eprop);
- return FALSE;
-}
-
-static void
-glade_eprop_resource_select_file (GtkButton *button, GladeEditorProperty *eprop)
-{
- GladeProject *project = glade_widget_get_project (eprop->property->widget);
- GtkWidget *dialog;
- GtkFileFilter *filter;
- GValue *value;
- gchar *file, *basename;
-
- if (eprop->loading) return;
-
- dialog = gtk_file_chooser_dialog_new ("Select a File",
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
-
- if (eprop->klass->pspec->value_type == GDK_TYPE_PIXBUF)
- {
- filter = gtk_file_filter_new ();
- gtk_file_filter_add_pixbuf_formats (filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
- }
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
- /* Set project resource here where we still have the fullpath.
- */
- glade_project_set_resource (project, eprop->property, file);
- basename = g_path_get_basename (file);
-
- value = glade_property_class_make_gvalue_from_string
- (eprop->klass, basename, project, eprop->property->widget);
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- g_free (file);
- g_free (basename);
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-glade_eprop_resource_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeProjectFormat fmt;
- GladeEPropResource *eprop_resource = GLADE_EPROP_RESOURCE (eprop);
- gchar *file;
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property == NULL) return;
-
- fmt = glade_project_get_format (property->widget->project);
-
- file = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
- eprop->klass, property->value, fmt);
- if (file)
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_resource->entry), file);
- g_free (file);
- }
- else
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_resource->entry), "");
- }
-}
-
-static GtkWidget *
-glade_eprop_resource_create_input (GladeEditorProperty *eprop)
-{
- GladeEPropResource *eprop_resource = GLADE_EPROP_RESOURCE (eprop);
- GtkWidget *hbox;
-
- hbox = gtk_hbox_new (FALSE, 0);
-
- eprop_resource->entry = gtk_entry_new ();
- gtk_widget_show (eprop_resource->entry);
-
- eprop_resource->button = gtk_button_new_with_label ("...");
- gtk_widget_show (eprop_resource->button);
-
- gtk_box_pack_start (GTK_BOX (hbox), eprop_resource->entry, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_resource->button, FALSE, FALSE, 0);
-
- g_signal_connect (G_OBJECT (eprop_resource->entry), "activate",
- G_CALLBACK (glade_eprop_resource_entry_activate),
- eprop);
- g_signal_connect (G_OBJECT (eprop_resource->entry), "focus-out-event",
- G_CALLBACK (glade_eprop_resource_entry_focus_out),
- eprop);
- g_signal_connect (G_OBJECT (eprop_resource->button), "clicked",
- G_CALLBACK (glade_eprop_resource_select_file),
- eprop);
-
- return hbox;
-}
-
-
-/*******************************************************************************
GladeEditorPropertyObjectClass
*******************************************************************************/
enum {
Modified: trunk/gladeui/glade-editor-property.h
==============================================================================
--- trunk/gladeui/glade-editor-property.h (original)
+++ trunk/gladeui/glade-editor-property.h Tue Oct 21 02:16:28 2008
@@ -174,7 +174,6 @@
#define GLADE_TYPE_EPROP_TEXT (glade_eprop_text_get_type())
#define GLADE_TYPE_EPROP_BOOL (glade_eprop_bool_get_type())
#define GLADE_TYPE_EPROP_UNICHAR (glade_eprop_unichar_get_type())
-#define GLADE_TYPE_EPROP_RESOURCE (glade_eprop_resource_get_type())
#define GLADE_TYPE_EPROP_OBJECT (glade_eprop_object_get_type())
#define GLADE_TYPE_EPROP_OBJECTS (glade_eprop_objects_get_type())
#define GLADE_TYPE_EPROP_ADJUSTMENT (glade_eprop_adjustment_get_type())
@@ -186,7 +185,6 @@
GType glade_eprop_text_get_type (void) G_GNUC_CONST;
GType glade_eprop_bool_get_type (void) G_GNUC_CONST;
GType glade_eprop_unichar_get_type (void) G_GNUC_CONST;
-GType glade_eprop_resource_get_type (void) G_GNUC_CONST;
GType glade_eprop_object_get_type (void) G_GNUC_CONST;
GType glade_eprop_objects_get_type (void) G_GNUC_CONST;
GType glade_eprop_adjustment_get_type (void) G_GNUC_CONST;
Modified: trunk/gladeui/glade-project.c
==============================================================================
--- trunk/gladeui/glade-project.c (original)
+++ trunk/gladeui/glade-project.c Tue Oct 21 02:16:28 2008
@@ -59,8 +59,6 @@
WIDGET_NAME_CHANGED,
SELECTION_CHANGED,
CLOSE,
- RESOURCE_ADDED,
- RESOURCE_REMOVED,
CHANGED,
PARSE_FINISHED,
CONVERT_FINISHED,
@@ -123,8 +121,6 @@
*/
GtkAccelGroup *accel_group;
-
- GHashTable *resources; /* resource filenames & thier associated properties */
gchar *comment; /* XML comment, Glade will preserve whatever comment was
* in file, so users can delete or change it.
@@ -190,16 +186,7 @@
gboolean forwidget,
GladeSupportMask *mask);
-static void glade_project_move_resources (GladeProject *project,
- const gchar *old_dir,
- const gchar *new_dir);
-
-static void glade_project_sync_resources_for_widget (GladeProject *project,
- GladeProject *prev_project,
- GladeWidget *gwidget,
- gboolean remove);
-
-GladeWidget *search_ancestry_by_name (GladeWidget *toplevel,
+static GladeWidget *search_ancestry_by_name (GladeWidget *toplevel,
const gchar *name);
static GtkWidget *glade_project_build_prefs_dialog (GladeProject *project);
@@ -311,7 +298,6 @@
if (project->priv->unsaved_number > 0)
glade_id_allocator_release (get_unsaved_number_allocator (), project->priv->unsaved_number);
- g_hash_table_destroy (project->priv->resources);
g_hash_table_destroy (project->priv->target_versions_major);
g_hash_table_destroy (project->priv->target_versions_minor);
g_hash_table_destroy (project->priv->target_radios);
@@ -605,10 +591,6 @@
priv->accel_group = NULL;
- priv->resources = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL, g_free);
-
priv->unsaved_number = glade_id_allocator_allocate (get_unsaved_number_allocator ());
priv->format = GLADE_PROJECT_FORMAT_GTKBUILDER;
@@ -662,8 +644,6 @@
klass->widget_name_changed = NULL;
klass->selection_changed = NULL;
klass->close = NULL;
- klass->resource_added = NULL;
- klass->resource_removed = NULL;
klass->changed = glade_project_changed_impl;
/**
@@ -756,45 +736,6 @@
G_TYPE_NONE,
0);
-
- /**
- * GladeProject::resource-added:
- * @gladeproject: the #GladeProject which received the signal.
- * @arg1: the file's basename (in the project path).
- *
- * Emitted when a resource file required by a #GladeProperty is
- * added to @gladeproject
- */
- glade_project_signals[RESOURCE_ADDED] =
- g_signal_new ("resource-added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, resource_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
-
- /**
- * GladeProject::resource-removed:
- * @gladeproject: the #GladeProject which received the signal.
- * @arg1: the file's basename
- *
- * Emitted when a resource file is removed from @gladeproject
- */
- glade_project_signals[RESOURCE_REMOVED] =
- g_signal_new ("resource-removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, resource_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
-
-
/**
* GladeProject::changed:
* @gladeproject: the #GladeProject which received the signal.
@@ -1662,19 +1603,8 @@
if (project->priv->path == NULL ||
strcmp (canonical_path, project->priv->path))
{
- gchar *old_dir, *new_dir, *name, *title;
-
- if (project->priv->path)
- {
- old_dir = g_path_get_dirname (project->priv->path);
- new_dir = g_path_get_dirname (canonical_path);
+ gchar *name, *title;
- glade_project_move_resources (project,
- old_dir,
- new_dir);
- g_free (old_dir);
- g_free (new_dir);
- }
project->priv->path = (g_free (project->priv->path),
g_strdup (canonical_path));
@@ -2203,7 +2133,7 @@
}
/*******************************************************************
- Project object tracking code, name exclusivity, resources etc...
+ Project object tracking code, name exclusivity etc...
*******************************************************************/
static GladeNameContext *
name_context_by_widget (GladeProject *project,
@@ -2225,7 +2155,7 @@
return NULL;
}
-GladeWidget *
+static GladeWidget *
search_ancestry_by_name (GladeWidget *toplevel, const gchar *name)
{
GladeWidget *widget = NULL, *iter;
@@ -2475,7 +2405,6 @@
GladeNameContext *context;
GladeWidget *gwidget;
GList *list, *children;
- static gint reentrancy_count = 0;
gchar *name;
g_return_if_fail (GLADE_IS_PROJECT (project));
@@ -2519,9 +2448,6 @@
glade_name_context_add_name (context, gwidget->name);
if (!gwidget->parent)
glade_name_context_add_name (project->priv->toplevel_names, gwidget->name);
-
- /* Code body starts here */
- reentrancy_count++;
if ((children = glade_widget_adaptor_get_children
(gwidget->adaptor, gwidget->object)) != NULL)
@@ -2542,13 +2468,6 @@
/* Update user visible compatability info */
glade_project_verify_properties (gwidget);
-
- /* Run this once at the end for every recursive call */
- if (--reentrancy_count == 0)
- {
- glade_project_sync_resources_for_widget
- (project, old_project, gwidget, FALSE);
- }
}
/**
@@ -2583,7 +2502,6 @@
{
GladeWidget *gwidget;
GList *link, *list, *children;
- static gint reentrancy_count = 0;
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (G_IS_OBJECT (object));
@@ -2593,9 +2511,6 @@
if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
return;
-
- /* Code body starts here */
- reentrancy_count++;
if ((children =
glade_widget_adaptor_get_children (gwidget->adaptor,
@@ -2620,10 +2535,6 @@
glade_project_signals [REMOVE_WIDGET],
0,
gwidget);
-
- /* Call this once at the end for every recursive call */
- if (--reentrancy_count == 0)
- glade_project_sync_resources_for_widget (project, NULL, gwidget, TRUE);
}
static void
@@ -3294,269 +3205,41 @@
project->priv->accel_group = accel_group;
}
-
-
-
-static void
-gp_sync_resources (GladeProject *project,
- GladeProject *prev_project,
- GladeWidget *gwidget,
- gboolean remove)
-{
- GList *prop_list, *l;
- GladeProperty *property;
- gchar *resource, *full_resource;
-
- prop_list = g_list_copy (gwidget->properties);
- prop_list = g_list_concat
- (prop_list, g_list_copy (gwidget->packing_properties));
-
- for (l = prop_list; l; l = l->next)
- {
- property = l->data;
- if (property->klass->resource)
- {
- GValue value = { 0, };
-
- if (remove)
- {
- glade_project_set_resource (project, property, NULL);
- continue;
- }
-
- glade_property_get_value (property, &value);
-
- if ((resource = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, &value, project->priv->format)) != NULL)
- {
- full_resource = glade_project_resource_fullpath
- (prev_project ? prev_project : project, resource);
-
- /* Use a full path here so that the current
- * working directory isnt used.
- */
- glade_project_set_resource (project,
- property,
- full_resource);
-
- g_free (full_resource);
- g_free (resource);
- }
- g_value_unset (&value);
- }
- }
- g_list_free (prop_list);
-}
-
-static void
-glade_project_sync_resources_for_widget (GladeProject *project,
- GladeProject *prev_project,
- GladeWidget *gwidget,
- gboolean remove)
-{
- GList *children, *l;
- GladeWidget *gchild;
-
- children = glade_widget_adaptor_get_children
- (gwidget->adaptor, gwidget->object);
-
- for (l = children; l; l = l->next)
- if ((gchild =
- glade_widget_get_from_gobject (l->data)) != NULL)
- glade_project_sync_resources_for_widget
- (project, prev_project, gchild, remove);
- if (children)
- g_list_free (children);
-
- gp_sync_resources (project, prev_project, gwidget, remove);
-}
-
-static void
-glade_project_move_resources (GladeProject *project,
- const gchar *old_dir,
- const gchar *new_dir)
-{
- GList *list, *resources;
- gchar *old_name, *new_name;
-
- if (old_dir == NULL || /* <-- Cant help you :( */
- new_dir == NULL) /* <-- Unlikely */
- return;
-
- if ((resources = /* Nothing to do here */
- glade_project_list_resources (project)) == NULL)
- return;
-
- for (list = resources; list; list = list->next)
- {
- old_name = g_build_filename
- (old_dir, (gchar *)list->data, NULL);
- new_name = g_build_filename
- (new_dir, (gchar *)list->data, NULL);
- glade_util_copy_file (old_name, new_name);
- g_free (old_name);
- g_free (new_name);
- }
- g_list_free (resources);
-}
-
/**
* glade_project_resource_fullpath:
* @project: The #GladeProject.
* @resource: The resource basename
*
+ * Project resource strings may be relative or fullpaths, but glade
+ * always expects a copy in the glade file directory, this function
+ * is used to make a local path to the file.
+ *
* Returns: A newly allocated string holding the
- * full path the the project resource.
+ * local path the the project resource.
*/
gchar *
glade_project_resource_fullpath (GladeProject *project,
const gchar *resource)
{
- gchar *fullpath, *project_dir;
+ gchar *fullpath, *project_dir = NULL, *basename;
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- if (project->priv->path == NULL)
- return g_strdup (resource);
-
- project_dir = g_path_get_dirname (project->priv->path);
- fullpath = g_build_filename (project_dir, resource, NULL);
- g_free (project_dir);
-
- return fullpath;
-}
-
-
-static gboolean
-find_resource_by_resource (GladeProperty *key,
- const gchar *resource,
- const gchar *resource_cmp)
-{
- g_assert (resource);
- g_assert (resource_cmp);
- return (!strcmp (resource, resource_cmp));
-}
-
-
-
-/**
- * glade_project_set_resource:
- * @project: A #GladeProject
- * @property: The #GladeProperty this resource is required by
- * @resource: The resource file basename to be found in the same
- * directory as the glade file.
- *
- * Adds/Modifies/Removes a resource from a project; any project resources
- * will be copied when using "Save As...", when moving widgets across projects
- * and will be copied into the project's directory when selected.
- */
-void
-glade_project_set_resource (GladeProject *project,
- GladeProperty *property,
- const gchar *resource)
-{
- gchar *last_resource, *last_resource_dup = NULL, *base_resource = NULL;
- gchar *fullpath, *dirname;
-
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_PROPERTY (property));
-
- if ((last_resource =
- g_hash_table_lookup (project->priv->resources, property)) != NULL)
- last_resource_dup = g_strdup (last_resource);
-
- /* Get dependable input */
- if (resource && resource[0] != '\0' && strcmp (resource, "."))
- base_resource = g_path_get_basename (resource);
-
- /* If the resource has been removed or the base name has changed
- * then remove from hash and emit removed.
- */
- if (last_resource_dup &&
- (base_resource == NULL || strcmp (last_resource_dup, base_resource)))
- {
- g_hash_table_remove (project->priv->resources, property);
+ basename = g_path_get_basename (resource);
- if (g_hash_table_find (project->priv->resources,
- (GHRFunc)find_resource_by_resource,
- last_resource_dup) == NULL)
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [RESOURCE_REMOVED],
- 0, last_resource_dup);
- }
-
- /* Copy files when importing widgets with resources.
- */
- if (project->priv->path)
- {
- dirname = g_path_get_dirname (project->priv->path);
- fullpath = g_build_filename (dirname, base_resource, NULL);
-
- if (resource && project->priv->path &&
- g_file_test (resource, G_FILE_TEST_IS_REGULAR) &&
- strcmp (fullpath, resource))
- {
- /* FIXME: In the case of copy/pasting widgets
- * across projects we should ask the user about
- * copying any resources.
- */
- glade_util_copy_file (resource, fullpath);
- }
- g_free (fullpath);
- g_free (dirname);
- }
-
- if (base_resource)
+ if (project->priv->path == NULL)
{
-
- /* If the resource has been added or the base name has
- * changed then emit added.
- */
- if ((last_resource_dup == NULL ||
- strcmp (last_resource_dup, base_resource)) &&
- g_hash_table_find (project->priv->resources,
- (GHRFunc)find_resource_by_resource,
- base_resource) == NULL)
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [RESOURCE_ADDED],
- 0, base_resource);
-
- g_hash_table_insert (project->priv->resources, property, base_resource);
-
+ project_dir = g_path_get_dirname (project->priv->path);
+ fullpath = g_build_filename (project_dir, basename, NULL);
}
- g_free (last_resource_dup);
-}
-
-static void
-list_resources_accum (GladeProperty *key,
- gchar *value,
- GList **list)
-{
- *list = g_list_prepend (*list, value);
-}
-
+ else
+ fullpath = g_strdup (basename);
+ if (project_dir)
+ g_free (project_dir);
+ g_free (basename);
-/**
- * glade_project_list_resources:
- * @project: A #GladeProject
- *
- * Returns: A newly allocated #GList of file basenames
- * of resources in this project, note that the
- * strings are not allocated and are unsafe to
- * use once the projects state changes.
- * The returned list should be freed with g_list_free.
- */
-GList *
-glade_project_list_resources (GladeProject *project)
-{
- GList *list = NULL;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
-
- g_hash_table_foreach (project->priv->resources,
- (GHFunc)list_resources_accum, &list);
- return list;
+ return fullpath;
}
const gchar *
Modified: trunk/gladeui/glade-project.h
==============================================================================
--- trunk/gladeui/glade-project.h (original)
+++ trunk/gladeui/glade-project.h Tue Oct 21 02:16:28 2008
@@ -61,10 +61,6 @@
void (*selection_changed) (GladeProject *project);
void (*close) (GladeProject *project);
- void (*resource_added) (GladeProject *project,
- const gchar *resource);
- void (*resource_removed) (GladeProject *project,
- const gchar *resource);
void (*parse_finished) (GladeProject *project);
};
@@ -161,12 +157,6 @@
void glade_project_set_accel_group (GladeProject *project,
GtkAccelGroup *accel_group);
-void glade_project_set_resource (GladeProject *project,
- GladeProperty *property,
- const gchar *resource);
-
-GList *glade_project_list_resources (GladeProject *project);
-
gchar *glade_project_resource_fullpath (GladeProject *project,
const gchar *resource);
Modified: trunk/gladeui/glade-property-class.c
==============================================================================
--- trunk/gladeui/glade-property-class.c (original)
+++ trunk/gladeui/glade-property-class.c Tue Oct 21 02:16:28 2008
@@ -86,7 +86,6 @@
property_class->save_always = FALSE;
property_class->ignore = FALSE;
property_class->needs_sync = FALSE;
- property_class->resource = FALSE;
property_class->themed_icon = FALSE;
property_class->translatable = FALSE;
property_class->atk = FALSE;
@@ -318,11 +317,10 @@
if (!object) return NULL;
- /* XXX Are pixbufs handled the same in both formats ?? */
if (property_class->pspec->value_type == GDK_TYPE_PIXBUF)
{
if ((filename = g_object_get_data (object, "GladeFileName")) != NULL)
- string = g_path_get_basename (filename);
+ string = g_strdup (filename);
}
else if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE &&
property_class->pspec->value_type == GTK_TYPE_ADJUSTMENT)
@@ -483,11 +481,7 @@
}
else if (G_IS_PARAM_SPEC_STRING(property_class->pspec))
{
- if (property_class->resource && g_value_get_string (value) != NULL)
- string = g_path_get_basename
- (g_value_get_string (value));
- else
- string = g_value_dup_string (value);
+ string = g_value_dup_string (value);
}
else if (G_IS_PARAM_SPEC_CHAR(property_class->pspec))
string = g_strdup_printf ("%c", g_value_get_char (value));
@@ -644,7 +638,7 @@
if (*string == '\0') return NULL;
fullpath = glade_project_resource_fullpath (project, string);
-
+
if ((pixbuf = gdk_pixbuf_new_from_file (fullpath, NULL)) == NULL)
{
static GdkPixbuf *icon = NULL;
@@ -736,7 +730,7 @@
GladeWidget *widget)
{
GValue *value = g_new0 (GValue, 1);
- gchar **strv, *fullpath;
+ gchar **strv;
GdkColor color = { 0, };
g_value_init (value, property_class->pspec->value_type);
@@ -804,20 +798,7 @@
else if (G_IS_PARAM_SPEC_DOUBLE(property_class->pspec))
g_value_set_double (value, g_ascii_strtod (string, NULL));
else if (G_IS_PARAM_SPEC_STRING(property_class->pspec))
- {
- /* This can be called when loading defaults from
- * catalog files... it wont happen and we cant do
- * anything for it.
- */
- if (property_class->resource && project)
- {
- fullpath = g_build_filename
- (glade_project_get_path (project), string, NULL);
- g_value_set_string (value, fullpath);
- g_free (fullpath);
- }
- else g_value_set_string (value, string);
- }
+ g_value_set_string (value, string);
else if (G_IS_PARAM_SPEC_CHAR(property_class->pspec))
g_value_set_char (value, string[0]);
else if (G_IS_PARAM_SPEC_UCHAR(property_class->pspec))
@@ -1523,7 +1504,6 @@
klass->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, klass->visible);
klass->ignore = glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, klass->ignore);
klass->needs_sync = glade_xml_get_property_boolean (node, GLADE_TAG_NEEDS_SYNC, klass->needs_sync);
- klass->resource = glade_xml_get_property_boolean (node, GLADE_TAG_RESOURCE, klass->resource);
klass->themed_icon = glade_xml_get_property_boolean (node, GLADE_TAG_THEMED_ICON, klass->themed_icon);
klass->weight = glade_xml_get_property_double (node, GLADE_TAG_WEIGHT, klass->weight);
klass->transfer_on_paste = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSFER_ON_PASTE, klass->transfer_on_paste);
@@ -1534,19 +1514,9 @@
glade_xml_get_property_boolean (node, GLADE_TAG_LIBGLADE_UNSUPPORTED,
klass->libglade_unsupported);
- /* Special case pixbuf here.
- */
- if (klass->pspec->value_type == GDK_TYPE_PIXBUF)
- klass->resource = TRUE;
-
if ((buf = glade_xml_get_property_string
(node, GLADE_TAG_FACTORY_STOCK_ID)) != NULL)
{
- if (!klass->resource) /* Assert the early in the game */
- g_error ("%s only supported on properties that are marked as %s",
- GLADE_TAG_FACTORY_STOCK_ID,
- GLADE_TAG_RESOURCE);
-
if (klass->factory_stock_id)
g_free (klass->factory_stock_id);
klass->factory_stock_id = buf;
Modified: trunk/gladeui/glade-property-class.h
==============================================================================
--- trunk/gladeui/glade-property-class.h (original)
+++ trunk/gladeui/glade-property-class.h Tue Oct 21 02:16:28 2008
@@ -142,13 +142,6 @@
gboolean is_modified; /* If true, this property_class has been "modified" from the
* the standard property by a xml file. */
- gboolean resource; /* Some property types; such as some file specifying
- * string properties or GDK_TYPE_PIXBUF properties; are
- * resource files and are treated specialy (a filechooser
- * popup is used and the resource is copied to the project
- * directory).
- */
-
gboolean themed_icon; /* Some GParamSpecString properties reffer to icon names
* in the icon theme... these need to be specified in the
* property class definition if proper editing tools are to
Modified: trunk/gladeui/glade-widget-adaptor.c
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.c (original)
+++ trunk/gladeui/glade-widget-adaptor.c Tue Oct 21 02:16:28 2008
@@ -1094,7 +1094,7 @@
else if (G_IS_PARAM_SPEC_OBJECT(pspec))
{
if (pspec->value_type == GDK_TYPE_PIXBUF)
- type = GLADE_TYPE_EPROP_RESOURCE;
+ type = GLADE_TYPE_EPROP_TEXT;
else if (pspec->value_type == GTK_TYPE_ADJUSTMENT)
type = GLADE_TYPE_EPROP_ADJUSTMENT;
else
@@ -1119,10 +1119,6 @@
*/
if ((type = glade_widget_adaptor_get_eprop_type (klass->pspec)) == 0)
return NULL;
-
- /* special case for resource specs which are hand specified in the catalog. */
- if (klass->resource)
- type = GLADE_TYPE_EPROP_RESOURCE;
/* special case for string specs that denote themed application icons. */
if (klass->themed_icon)
Modified: trunk/plugins/gtk+/glade-cell-renderer-button.c
==============================================================================
--- trunk/plugins/gtk+/glade-cell-renderer-button.c (original)
+++ trunk/plugins/gtk+/glade-cell-renderer-button.c Tue Oct 21 02:16:28 2008
@@ -32,6 +32,7 @@
typedef struct
{
+ gboolean entry_editable;
gchar *button_text;
} GladeCellRendererButtonPrivate;
@@ -55,6 +56,7 @@
GtkCellRendererState flags);
enum {
PROP_0,
+ PROP_ENTRY_EDITABLE,
PROP_BUTTON_TEXT
};
@@ -84,6 +86,14 @@
g_object_class_install_property (object_class,
PROP_BUTTON_TEXT,
+ g_param_spec_boolean ("entry-editable",
+ _("Entry Editable"),
+ _("Whether the entry is editable"),
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_BUTTON_TEXT,
g_param_spec_string ("button-text",
_("Button Text"),
_("The text to display in the button"),
@@ -109,6 +119,7 @@
priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (self);
+ priv->entry_editable = TRUE;
priv->button_text = NULL;
}
@@ -140,6 +151,9 @@
switch (prop_id)
{
+ case PROP_ENTRY_EDITABLE:
+ g_value_set_boolean (value, priv->entry_editable);
+ break;
case PROP_BUTTON_TEXT:
g_value_set_string (value, priv->button_text);
break;
@@ -151,9 +165,9 @@
static void
glade_cell_renderer_button_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GladeCellRendererButton *renderer;
GladeCellRendererButtonPrivate *priv;
@@ -163,6 +177,9 @@
switch (prop_id)
{
+ case PROP_ENTRY_EDITABLE:
+ priv->entry_editable = g_value_get_boolean (value);
+ break;
case PROP_BUTTON_TEXT:
if (priv->button_text)
g_free (priv->button_text);
@@ -246,6 +263,7 @@
text_button = (GladeTextButton *)glade_text_button_new ();
gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text);
+ gtk_entry_set_editable (GTK_ENTRY (text_button->entry), priv->entry_editable);
gtk_button_set_label (GTK_BUTTON (text_button->button), priv->button_text);
g_object_set (text_button->entry,
Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c (original)
+++ trunk/plugins/gtk+/glade-gtk.c Tue Oct 21 02:16:28 2008
@@ -8764,8 +8764,19 @@
str = glade_utils_string_from_value (&data->value, fmt);
is_last = !row->next && !iter->next;
- g_string_append_printf (string, !is_last ? "%s[%d]:%s|" : "%s[%d]:%s",
+ g_string_append_printf (string, "%s[%d]:%s",
data->name, rownum, str);
+
+ if (data->i18n_translatable)
+ g_string_append_printf (string, " translatable");
+ if (data->i18n_context)
+ g_string_append_printf (string, " i18n-context:%s", data->i18n_context);
+ if (data->i18n_comment)
+ g_string_append_printf (string, " i18n-comment:%s", data->i18n_comment);
+
+ if (!is_last)
+ g_string_append_printf (string, "|");
+
g_free (str);
}
}
Modified: trunk/plugins/gtk+/glade-model-data.c
==============================================================================
--- trunk/plugins/gtk+/glade-model-data.c (original)
+++ trunk/plugins/gtk+/glade-model-data.c Tue Oct 21 02:16:28 2008
@@ -519,7 +519,7 @@
GArray *gtypes = g_array_new (FALSE, TRUE, sizeof (GType));
GtkTreeIter iter;
gint column_num, row_num;
- GType index_type = G_TYPE_INT;
+ GType index_type = G_TYPE_INT, string_type = G_TYPE_STRING;
glade_property_get (eprop->property, &data_tree);
@@ -531,7 +531,10 @@
for (iter_node = data_tree->children->children; iter_node; iter_node = iter_node->next)
{
iter_data = iter_node->data;
- g_array_append_val (gtypes, G_VALUE_TYPE (&iter_data->value));
+ if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
+ g_array_append_val (gtypes, string_type);
+ else
+ g_array_append_val (gtypes, G_VALUE_TYPE (&iter_data->value));
}
store = gtk_list_store_newv (gtypes->len, (GType *)gtypes->data);
g_array_free (gtypes, TRUE);
@@ -549,7 +552,21 @@
column_num++, iter_node = iter_node->next)
{
iter_data = iter_node->data;
- gtk_list_store_set_value (store, &iter, column_num, &iter_data->value);
+
+ /* Special case, show the filename in the cellrenderertext */
+ if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
+ {
+ GObject *object = g_value_get_object (&iter_data->value);
+ gchar *filename = NULL;
+ if (object)
+ filename = g_object_get_data (object, "GladeFileName");
+
+ gtk_list_store_set (store, &iter,
+ column_num, filename,
+ -1);
+ }
+ else
+ gtk_list_store_set_value (store, &iter, column_num, &iter_data->value);
}
}
return store;
@@ -644,6 +661,9 @@
eprop_data->pending_data_tree = data_tree;
g_idle_add ((GSourceFunc)update_data_tree_idle, eprop);
}
+ else
+ glade_model_data_tree_free (data_tree);
+
g_free (new_text);
}
@@ -659,6 +679,7 @@
gint row;
GNode *data_tree = NULL;
GladeModelData *data;
+ GValue *value;
if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
return;
@@ -677,36 +698,13 @@
data = glade_model_data_tree_get_data (data_tree, row, colnum);
- /* cellrenderertext */
- if (G_VALUE_TYPE (&data->value) == G_TYPE_STRING)
- g_value_set_string (&data->value, new_text);
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_CHAR)
- g_value_set_char (&data->value, new_text ? new_text[0] : '\0');
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_UCHAR)
- g_value_set_uchar (&data->value, new_text ? new_text[0] : '\0');
- /* cellrendererspin */
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_INT)
- g_value_set_int (&data->value, g_ascii_strtoll (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_UINT)
- g_value_set_uint (&data->value, g_ascii_strtoull (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_LONG)
- g_value_set_long (&data->value, g_ascii_strtoll (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_ULONG)
- g_value_set_ulong (&data->value, g_ascii_strtoull (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_INT64)
- g_value_set_int64 (&data->value, g_ascii_strtoll (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_UINT64)
- g_value_set_uint64 (&data->value, g_ascii_strtoull (new_text, NULL, 10));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_FLOAT)
- g_value_set_float (&data->value, (float) g_ascii_strtod (new_text, NULL));
- else if (G_VALUE_TYPE (&data->value) == G_TYPE_DOUBLE)
- g_value_set_double (&data->value, g_ascii_strtod (new_text, NULL));
- else if (G_TYPE_IS_ENUM (G_VALUE_TYPE (&data->value)))
- g_value_set_enum (&data->value,
- glade_utils_enum_value_from_string (G_VALUE_TYPE (&data->value), new_text));
- else if (G_TYPE_IS_FLAGS (G_VALUE_TYPE (&data->value)))
- g_value_set_enum (&data->value,
- glade_utils_flags_value_from_string (G_VALUE_TYPE (&data->value), new_text));
+ /* Translate string and update value in tree. */
+ value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text,
+ eprop->property->widget->project,
+ eprop->property->widget);
+ g_value_copy (value, &data->value);
+ g_value_unset (value);
+ g_free (value);
if (eprop_data->pending_data_tree)
glade_model_data_tree_free (eprop_data->pending_data_tree);
@@ -732,7 +730,8 @@
/* Support enum and flag types, and a hardcoded list of fundamental types */
if (type == G_TYPE_CHAR ||
type == G_TYPE_UCHAR ||
- type == G_TYPE_STRING)
+ type == G_TYPE_STRING ||
+ type == GDK_TYPE_PIXBUF)
{
/* Text renderer */
if (type == G_TYPE_STRING)
@@ -743,9 +742,7 @@
else
renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", TRUE,
- NULL);
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer,
"text", NUM_COLUMNS + colnum,
@@ -768,8 +765,6 @@
}
}
-
- /* Text renderer single char */
else if (type == G_TYPE_BOOLEAN)
{
/* Toggle renderer */
Modified: trunk/plugins/gtk+/glade-text-button.c
==============================================================================
--- trunk/plugins/gtk+/glade-text-button.c (original)
+++ trunk/plugins/gtk+/glade-text-button.c Tue Oct 21 02:16:28 2008
@@ -28,17 +28,20 @@
#include "glade-text-button.h"
-#define GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererButtonPrivate))
+#define GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeTextButtonPrivate))
typedef struct
{
gchar *button_text;
-} GladeCellRendererButtonPrivate;
+} GladeTextButtonPrivate;
-static void glade_text_button_finalize (GObject *object);
+static void glade_text_button_finalize (GObject *object);
static void glade_text_button_cell_editable_init (GtkCellEditableIface *iface);
+static void glade_text_button_grab_focus (GtkWidget *widget);
+
+
G_DEFINE_TYPE_WITH_CODE (GladeTextButton, glade_text_button, GTK_TYPE_ALIGNMENT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
glade_text_button_cell_editable_init));
@@ -48,8 +51,12 @@
glade_text_button_class_init (GladeTextButtonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
object_class->finalize = glade_text_button_finalize;
+ widget_class->grab_focus = glade_text_button_grab_focus;
+
+ g_type_class_add_private (object_class, sizeof (GladeTextButtonPrivate));
}
static void
@@ -66,7 +73,6 @@
self->button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (self->hbox), self->button, FALSE, FALSE, 0);
-
}
static void
@@ -77,7 +83,6 @@
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
}
-
/* GtkCellEditable method implementations
*/
static void
@@ -136,6 +141,14 @@
G_OBJECT_CLASS (glade_text_button_parent_class)->finalize (object);
}
+static void
+glade_text_button_grab_focus (GtkWidget *widget)
+{
+ GladeTextButton *text_button = GLADE_TEXT_BUTTON (widget);
+
+ gtk_widget_grab_focus (text_button->entry);
+}
+
/**
* glade_text_button_new:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]