[evolution/gtk-builder] Deal with custom widgets in contact-editor.ui.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution/gtk-builder] Deal with custom widgets in contact-editor.ui.
- Date: Tue, 3 Nov 2009 16:09:14 +0000 (UTC)
commit bbec8154207c10694fc6b636bd3b2aebfddde3b4
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Nov 2 20:29:17 2009 -0600
Deal with custom widgets in contact-editor.ui.
addressbook/gui/contact-editor/contact-editor.ui | 4 -
widgets/misc/e-image-chooser.c | 112 +++++++++++++++-------
widgets/misc/e-image-chooser.h | 3 +-
3 files changed, 79 insertions(+), 40 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 2ca8346..f2a9bc1 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -165,7 +165,6 @@
<child>
<object class="EImageChooser" type-func="e_image_chooser_get_type" id="image-chooser">
<property name="visible">True</property>
- <property name="icon-name">stock_person</property>
</object>
</child>
<child internal-child="accessible">
@@ -1035,9 +1034,6 @@
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">True</property>
- <accessibility>
-
- </accessibility>
<child>
<object class="GtkArrow" id="arrow-phone-expand">
<property name="visible">True</property>
diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c
index 6783759..5ef4e7c 100644
--- a/widgets/misc/e-image-chooser.c
+++ b/widgets/misc/e-image-chooser.c
@@ -42,11 +42,9 @@ struct _EImageChooserPrivate {
gint image_buf_size;
gint image_width;
gint image_height;
-};
-enum {
- CHANGED,
- LAST_SIGNAL
+ /* Default Image */
+ gchar *icon_name;
};
enum {
@@ -54,6 +52,11 @@ enum {
PROP_ICON_NAME
};
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
static gpointer parent_class;
static guint signals[LAST_SIGNAL];
@@ -274,28 +277,44 @@ image_drag_data_received_cb (GtkWidget *widget,
exit:
gtk_drag_finish (context, handled, FALSE, time);
}
+
static void
-image_chooser_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+image_chooser_set_icon_name (EImageChooser *chooser,
+ const gchar *icon_name)
{
- switch (property_id) {
- case PROP_ICON_NAME: {
- const gchar *icon_name;
- gchar *filename;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *icon_info;
+ const gchar *filename;
+ gint width, height;
+
+ g_return_if_fail (chooser->priv->icon_name == NULL);
+
+ chooser->priv->icon_name = g_strdup (icon_name);
- icon_name = g_value_get_string (value);
- if (icon_name) {
- filename = e_icon_factory_get_icon_filename (icon_name, GTK_ICON_SIZE_DIALOG);
+ icon_theme = gtk_icon_theme_get_default ();
+ gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, &height);
- if (filename && *filename)
- e_image_chooser_set_from_file (E_IMAGE_CHOOSER (object), filename);
+ icon_info = gtk_icon_theme_lookup_icon (
+ icon_theme, icon_name, height, 0);
+ g_return_if_fail (icon_info != NULL);
- g_free (filename);
- }
+ filename = gtk_icon_info_get_filename (icon_info);
+ e_image_chooser_set_from_file (chooser, filename);
+ gtk_icon_info_free (icon_info);
+}
+
+static void
+image_chooser_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ICON_NAME:
+ image_chooser_set_icon_name (
+ E_IMAGE_CHOOSER (object),
+ g_value_get_string (value));
return;
- }
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -303,10 +322,19 @@ image_chooser_set_property (GObject *object,
static void
image_chooser_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ switch (property_id) {
+ case PROP_ICON_NAME:
+ g_value_set_string (
+ value,
+ e_image_chooser_get_icon_name (
+ E_IMAGE_CHOOSER (object)));
+ return;
+ }
+
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -339,6 +367,7 @@ image_chooser_finalize (GObject *object)
priv = E_IMAGE_CHOOSER_GET_PRIVATE (object);
g_free (priv->image_buf);
+ g_free (priv->icon_name);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -358,6 +387,17 @@ e_image_chooser_class_init (EImageChooserClass *class)
object_class->dispose = image_chooser_dispose;
object_class->finalize = image_chooser_finalize;
+ g_object_class_install_property (
+ object_class,
+ PROP_ICON_NAME,
+ g_param_spec_string (
+ "icon-name",
+ "Icon Name",
+ NULL,
+ "stock_person",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
signals[CHANGED] = g_signal_new (
"changed",
G_OBJECT_CLASS_TYPE (object_class),
@@ -366,16 +406,6 @@ e_image_chooser_class_init (EImageChooserClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- g_object_class_install_property (
- object_class,
- PROP_ICON_NAME,
- g_param_spec_string (
- "icon-name",
- "File name of the icon to load",
- NULL,
- FALSE,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -450,10 +480,22 @@ e_image_chooser_get_type (void)
return type;
}
+const gchar *
+e_image_chooser_get_icon_name (EImageChooser *chooser)
+{
+ g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), NULL);
+
+ return chooser->priv->icon_name;
+}
+
GtkWidget *
-e_image_chooser_new (void)
+e_image_chooser_new (const gchar *icon_name)
{
- return g_object_new (E_TYPE_IMAGE_CHOOSER, NULL);
+ g_return_val_if_fail (icon_name != NULL, NULL);
+
+ return g_object_new (
+ E_TYPE_IMAGE_CHOOSER,
+ "icon-name", icon_name, NULL);
}
gboolean
diff --git a/widgets/misc/e-image-chooser.h b/widgets/misc/e-image-chooser.h
index 7116500..3338e16 100644
--- a/widgets/misc/e-image-chooser.h
+++ b/widgets/misc/e-image-chooser.h
@@ -62,7 +62,8 @@ struct _EImageChooserClass {
};
GType e_image_chooser_get_type (void);
-GtkWidget * e_image_chooser_new (void);
+GtkWidget * e_image_chooser_new (const gchar *icon_name);
+const gchar * e_image_chooser_get_icon_name (EImageChooser *chooser);
gboolean e_image_chooser_set_from_file (EImageChooser *chooser,
const gchar *filename);
gboolean e_image_chooser_set_image_data (EImageChooser *chooser,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]