diff options
Diffstat (limited to 'composer/e-composer-header.c')
-rw-r--r-- | composer/e-composer-header.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c index 4719d6db7e..8bd75f8a3c 100644 --- a/composer/e-composer-header.c +++ b/composer/e-composer-header.c @@ -1,3 +1,5 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + /* * * This program is free software; you can redistribute it and/or @@ -28,6 +30,8 @@ enum { PROP_0, PROP_BUTTON, PROP_LABEL, + PROP_ADDACTION, + PROP_ADDACTION_TEXT, PROP_SENSITIVE, PROP_VISIBLE }; @@ -41,6 +45,8 @@ enum { struct _EComposerHeaderPrivate { gchar *label; gboolean button; + gchar *addaction_text; + gboolean addaction; /*For Add button.*/ guint sensitive : 1; guint visible : 1; @@ -57,6 +63,20 @@ composer_header_button_clicked_cb (GtkButton *button, g_signal_emit (header, signal_ids[CLICKED], 0); } +static void +composer_header_addaction_clicked_cb (GtkButton *button, + EComposerHeader *header) +{ + gtk_widget_hide ((GtkWidget *)button); + e_composer_header_set_visible (header, TRUE); +} + +static void +link_clicked_cb (GtkLinkButton *button, const gchar *link_, gpointer user_data) +{ + return; +} + static GObject * composer_header_constructor (GType type, guint n_construct_properties, @@ -84,6 +104,27 @@ composer_header_constructor (GType type, gtk_label_set_mnemonic_widget ( GTK_LABEL (widget), header->input_widget); } + + if (header->priv->addaction) { + GtkWidget *box, *tmp; + char *str; + + header->action_widget = gtk_button_new (); + box = gtk_hbox_new (FALSE, 0); + tmp = gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3); + tmp = gtk_label_new (NULL); + str = g_strdup_printf ("<span foreground='blue' underline='single' underline_color='blue' >%s</span>", header->priv->addaction_text); + gtk_label_set_markup((GtkLabel *)tmp, str); + gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3); + gtk_container_add((GtkContainer *)header->action_widget, box); + gtk_widget_show_all(header->action_widget); + g_signal_connect ( + header->action_widget, "clicked", + G_CALLBACK (composer_header_addaction_clicked_cb), + header); + } + header->title_widget = g_object_ref_sink (widget); g_free (header->priv->label); @@ -107,6 +148,14 @@ composer_header_set_property (GObject *object, priv->button = g_value_get_boolean (value); return; + case PROP_ADDACTION: /* construct only */ + priv->addaction = g_value_get_boolean (value); + return; + + case PROP_ADDACTION_TEXT:/* construct only */ + priv->addaction_text = g_value_dup_string (value); + return; + case PROP_LABEL: /* construct only */ priv->label = g_value_dup_string (value); return; @@ -127,6 +176,15 @@ composer_header_set_property (GObject *object, G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } +void +e_composer_header_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + composer_header_set_property (object, property_id, value, pspec); +} + static void composer_header_get_property (GObject *object, guint property_id, @@ -142,6 +200,15 @@ composer_header_get_property (GObject *object, g_value_set_boolean (value, priv->button); return; + case PROP_ADDACTION: /* construct only */ + g_value_set_boolean (value, priv->button); + return; + + case PROP_ADDACTION_TEXT: /* construct only */ + g_value_take_string ( + value, priv->addaction_text); + return; + case PROP_LABEL: /* construct only */ g_value_take_string ( value, e_composer_header_get_label ( @@ -210,6 +277,28 @@ composer_header_class_init (EComposerHeaderClass *class) g_object_class_install_property ( object_class, + PROP_ADDACTION, + g_param_spec_boolean ( + "addaction", + NULL, + NULL, + FALSE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, + PROP_ADDACTION_TEXT, + g_param_spec_string ( + "addaction_text", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, PROP_LABEL, g_param_spec_string ( "label", |