Conflicts: a11y/widgets/ea-combo-button.c a11y/widgets/ea-combo-button.h addressbook/gui/component/addressbook-component.c addressbook/gui/component/addressbook-component.h addressbook/gui/component/addressbook-view.c addressbook/gui/component/addressbook-view.h addressbook/gui/component/component-factory.c addressbook/gui/widgets/e-addressbook-view.c addressbook/gui/widgets/eab-contact-display.c addressbook/gui/widgets/eab-gui-util.h addressbook/gui/widgets/eab-menu.c addressbook/gui/widgets/eab-menu.h addressbook/gui/widgets/eab-popup-control.c addressbook/gui/widgets/eab-popup-control.h addressbook/gui/widgets/eab-popup.c addressbook/gui/widgets/eab-popup.h calendar/gui/cal-search-bar.c calendar/gui/calendar-commands.c calendar/gui/calendar-component.c calendar/gui/comp-editor-factory.c calendar/gui/comp-editor-factory.h calendar/gui/control-factory.c calendar/gui/dialogs/comp-editor.c calendar/gui/e-cal-component-memo-preview.c calendar/gui/e-cal-component-memo-preview.h calendar/gui/e-calendar-table.c calendar/gui/e-memo-table.c calendar/gui/e-memos.c calendar/gui/e-tasks.c calendar/gui/gnome-cal.c calendar/gui/gnome-cal.h calendar/gui/itip-bonobo-control.c calendar/gui/itip-bonobo-control.h calendar/gui/main.c calendar/gui/memos-component.c calendar/gui/memos-control.c calendar/gui/memos-control.h calendar/gui/migration.c calendar/gui/migration.h calendar/gui/tasks-component.c calendar/gui/tasks-control.c calendar/importers/main.c composer/Makefile.am composer/e-composer-header-table.c composer/e-composer-header.c composer/e-composer-header.h composer/e-composer-name-header.c composer/e-composer-private.c composer/e-composer-text-header.c composer/e-msg-composer.c composer/e-msg-composer.h e-util/e-corba-utils.h e-util/e-logger.c e-util/e-logger.h e-util/e-util-labels.c e-util/e-util-labels.h em-format/em-format.c mail/Makefile.am mail/e-mail-shell-migrate.c mail/em-account-editor.c mail/em-account-editor.h mail/em-composer-prefs.c mail/em-composer-utils.c mail/em-composer-utils.h mail/em-folder-browser.c mail/em-folder-tree-model.c mail/em-folder-tree.c mail/em-folder-tree.h mail/em-folder-utils.c mail/em-folder-utils.h mail/em-folder-view.c mail/em-format-html-display.c mail/em-format-html.c mail/em-mailer-prefs.c mail/em-mailer-prefs.h mail/em-message-browser.c mail/em-message-browser.h mail/em-network-prefs.h mail/em-popup.c mail/em-utils.c mail/importers/Makefile.am mail/mail-component-factory.c mail/mail-component.c mail/mail-config-factory.c mail/mail-config-factory.h mail/mail-config.c mail/mail-dialogs.glade mail/mail-types.h plugins/calendar-weather/calendar-weather.c plugins/mail-account-disable/mail-account-disable.c plugins/select-one-source/select-one-source.c po/POTFILES.in shell/e-component-registry.c shell/e-component-registry.h shell/e-component-view.c shell/e-component-view.h shell/e-corba-config-page.c shell/e-corba-config-page.h shell/e-shell-constants.h shell/e-shell-settings-dialog.c shell/e-shell-settings-dialog.h shell/e-shell-window-commands.c shell/e-shell-window.c shell/e-shell.h shell/e-sidebar.c shell/e-sidebar.h shell/e-user-creatable-items-handler.c shell/e-user-creatable-items-handler.h shell/es-menu.c shell/es-menu.h shell/evolution-component.h shell/evolution-config-control.c shell/evolution-config-control.h shell/evolution-listener.c shell/evolution-listener.h shell/evolution-shell-component-utils.c shell/evolution-shell-component-utils.h shell/importer/evolution-importer-client.c shell/importer/evolution-importer-client.h shell/importer/evolution-importer-listener.c shell/importer/evolution-importer-listener.h shell/importer/evolution-importer.c shell/importer/evolution-importer.h shell/importer/evolution-intelligent-importer.c shell/importer/evolution-intelligent-importer.h shell/importer/intelligent.c shell/main.c shell/test/evolution-test-component.c shell/test/evolution-test-component.h widgets/menus/gal-view-instance.c widgets/menus/gal-view-menus.c widgets/menus/gal-view-menus.h widgets/misc/Makefile.am widgets/misc/e-activity-handler.c widgets/misc/e-activity-handler.h widgets/misc/e-charset-picker.c widgets/misc/e-combo-button.c widgets/misc/e-combo-button.h widgets/misc/e-config-page.h widgets/misc/e-dropdown-button.c widgets/misc/e-dropdown-button.h widgets/misc/e-filter-bar.c widgets/misc/e-info-label.c widgets/misc/e-info-label.h widgets/misc/e-multi-config-dialog.c widgets/misc/e-multi-config-dialog.h widgets/misc/e-search-bar.c widgets/misc/e-search-bar.h widgets/misc/e-task-bar.c widgets/misc/e-task-bar.h widgets/misc/e-task-widget.c widgets/misc/e-task-widget.h widgets/misc/test-dropdown-button.c widgets/misc/test-error.c widgets/misc/test-info-label.c widgets/table/e-table-example-1.c
368 lines
10 KiB
C
368 lines
10 KiB
C
/*
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) version 3.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
|
*
|
|
*
|
|
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
|
*
|
|
*/
|
|
|
|
#include "e-composer-name-header.h"
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
/* XXX Temporary kludge */
|
|
#include "addressbook/gui/contact-editor/e-contact-editor.h"
|
|
#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
|
|
|
|
#define E_COMPOSER_NAME_HEADER_GET_PRIVATE(obj) \
|
|
(G_TYPE_INSTANCE_GET_PRIVATE \
|
|
((obj), E_TYPE_COMPOSER_NAME_HEADER, EComposerNameHeaderPrivate))
|
|
|
|
/* Convenience macro */
|
|
#define E_COMPOSER_NAME_HEADER_GET_ENTRY(header) \
|
|
(E_NAME_SELECTOR_ENTRY (E_COMPOSER_HEADER (header)->input_widget))
|
|
|
|
enum {
|
|
PROP_0,
|
|
PROP_NAME_SELECTOR
|
|
};
|
|
|
|
struct _EComposerNameHeaderPrivate {
|
|
ENameSelector *name_selector;
|
|
guint destination_index;
|
|
};
|
|
|
|
static gpointer parent_class;
|
|
|
|
static void
|
|
composer_name_header_entry_changed_cb (ENameSelectorEntry *entry,
|
|
EComposerNameHeader *header)
|
|
{
|
|
g_signal_emit_by_name (header, "changed");
|
|
}
|
|
|
|
static gboolean
|
|
composer_name_header_entry_query_tooltip_cb (GtkEntry *entry,
|
|
gint x,
|
|
gint y,
|
|
gboolean keyboard_mode,
|
|
GtkTooltip *tooltip)
|
|
{
|
|
const gchar *text;
|
|
|
|
text = gtk_entry_get_text (entry);
|
|
|
|
if (keyboard_mode || text == NULL || *text == '\0')
|
|
return FALSE;
|
|
|
|
gtk_tooltip_set_text (tooltip, text);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static GObject *
|
|
composer_name_header_constructor (GType type,
|
|
guint n_construct_properties,
|
|
GObjectConstructParam *construct_properties)
|
|
{
|
|
EComposerNameHeaderPrivate *priv;
|
|
ENameSelectorModel *model;
|
|
ENameSelectorEntry *entry;
|
|
GObject *object;
|
|
gchar *label;
|
|
|
|
/* Chain up to parent's constructor() method. */
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (
|
|
type, n_construct_properties, construct_properties);
|
|
|
|
priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object);
|
|
g_assert (E_IS_NAME_SELECTOR (priv->name_selector));
|
|
|
|
model = e_name_selector_peek_model (priv->name_selector);
|
|
label = e_composer_header_get_label (E_COMPOSER_HEADER (object));
|
|
g_assert (label != NULL);
|
|
|
|
/* XXX Peeking at private data. */
|
|
priv->destination_index = model->sections->len;
|
|
e_name_selector_model_add_section (model, label, label, NULL);
|
|
|
|
e_composer_header_set_title_tooltip (
|
|
E_COMPOSER_HEADER (object),
|
|
_("Click here for the address book"));
|
|
|
|
entry = E_NAME_SELECTOR_ENTRY (
|
|
e_name_selector_peek_section_list (
|
|
priv->name_selector, label));
|
|
|
|
e_name_selector_entry_set_contact_editor_func (
|
|
entry, e_contact_editor_new);
|
|
e_name_selector_entry_set_contact_list_editor_func (
|
|
entry, e_contact_list_editor_new);
|
|
|
|
g_signal_connect (
|
|
entry, "changed",
|
|
G_CALLBACK (composer_name_header_entry_changed_cb), object);
|
|
g_signal_connect (
|
|
entry, "query-tooltip",
|
|
G_CALLBACK (composer_name_header_entry_query_tooltip_cb),
|
|
NULL);
|
|
E_COMPOSER_HEADER (object)->input_widget = g_object_ref_sink (entry);
|
|
|
|
return object;
|
|
}
|
|
|
|
static void
|
|
composer_name_header_set_property (GObject *object,
|
|
guint property_id,
|
|
const GValue *value,
|
|
GParamSpec *pspec)
|
|
{
|
|
EComposerNameHeaderPrivate *priv;
|
|
|
|
priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object);
|
|
|
|
switch (property_id) {
|
|
case PROP_NAME_SELECTOR: /* construct only */
|
|
g_assert (priv->name_selector == NULL);
|
|
priv->name_selector = g_value_dup_object (value);
|
|
return;
|
|
}
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
}
|
|
|
|
static void
|
|
composer_name_header_get_property (GObject *object,
|
|
guint property_id,
|
|
GValue *value,
|
|
GParamSpec *pspec)
|
|
{
|
|
switch (property_id) {
|
|
case PROP_NAME_SELECTOR: /* construct only */
|
|
g_value_set_object (
|
|
value,
|
|
e_composer_name_header_get_name_selector (
|
|
E_COMPOSER_NAME_HEADER (object)));
|
|
return;
|
|
}
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
}
|
|
|
|
static void
|
|
composer_name_header_dispose (GObject *object)
|
|
{
|
|
EComposerNameHeaderPrivate *priv;
|
|
|
|
priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object);
|
|
|
|
if (priv->name_selector != NULL) {
|
|
g_object_unref (priv->name_selector);
|
|
priv->name_selector = NULL;
|
|
}
|
|
|
|
/* Chain up to parent's dispose() method. */
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
}
|
|
|
|
static void
|
|
composer_name_header_clicked (EComposerHeader *header)
|
|
{
|
|
EComposerNameHeaderPrivate *priv;
|
|
ENameSelectorDialog *dialog;
|
|
|
|
priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header);
|
|
|
|
dialog = e_name_selector_peek_dialog (priv->name_selector);
|
|
e_name_selector_dialog_set_destination_index (
|
|
dialog, priv->destination_index);
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
|
}
|
|
|
|
static void
|
|
composer_name_header_class_init (EComposerNameHeaderClass *class)
|
|
{
|
|
GObjectClass *object_class;
|
|
EComposerHeaderClass *header_class;
|
|
|
|
parent_class = g_type_class_peek_parent (class);
|
|
g_type_class_add_private (class, sizeof (EComposerNameHeaderPrivate));
|
|
|
|
object_class = G_OBJECT_CLASS (class);
|
|
object_class->constructor = composer_name_header_constructor;
|
|
object_class->set_property = composer_name_header_set_property;
|
|
object_class->get_property = composer_name_header_get_property;
|
|
object_class->dispose = composer_name_header_dispose;
|
|
|
|
header_class = E_COMPOSER_HEADER_CLASS (class);
|
|
header_class->clicked = composer_name_header_clicked;
|
|
|
|
g_object_class_install_property (
|
|
object_class,
|
|
PROP_NAME_SELECTOR,
|
|
g_param_spec_object (
|
|
"name-selector",
|
|
NULL,
|
|
NULL,
|
|
E_TYPE_NAME_SELECTOR,
|
|
G_PARAM_READWRITE |
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
}
|
|
|
|
static void
|
|
composer_name_header_init (EComposerNameHeader *header)
|
|
{
|
|
header->priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header);
|
|
}
|
|
|
|
GType
|
|
e_composer_name_header_get_type (void)
|
|
{
|
|
static GType type = 0;
|
|
|
|
if (G_UNLIKELY (type == 0)) {
|
|
static const GTypeInfo type_info = {
|
|
sizeof (EComposerNameHeaderClass),
|
|
(GBaseInitFunc) NULL,
|
|
(GBaseFinalizeFunc) NULL,
|
|
(GClassInitFunc) composer_name_header_class_init,
|
|
(GClassFinalizeFunc) NULL,
|
|
NULL, /* class_data */
|
|
sizeof (EComposerNameHeader),
|
|
0, /* n_preallocs */
|
|
(GInstanceInitFunc) composer_name_header_init,
|
|
NULL /* value_table */
|
|
};
|
|
|
|
type = g_type_register_static (
|
|
E_TYPE_COMPOSER_HEADER, "EComposerNameHeader",
|
|
&type_info, 0);
|
|
}
|
|
|
|
return type;
|
|
}
|
|
|
|
EComposerHeader *
|
|
e_composer_name_header_new (const gchar *label,
|
|
ENameSelector *name_selector)
|
|
{
|
|
g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
|
|
|
|
return g_object_new (
|
|
E_TYPE_COMPOSER_NAME_HEADER, "label", label,
|
|
"button", TRUE, "name-selector", name_selector, NULL);
|
|
}
|
|
|
|
EComposerHeader *
|
|
e_composer_name_header_new_with_label (const gchar *label,
|
|
ENameSelector *name_selector)
|
|
{
|
|
return g_object_new (
|
|
E_TYPE_COMPOSER_NAME_HEADER, "label", label,
|
|
"button", TRUE, "name-selector", name_selector,
|
|
"addaction", FALSE, "visible", TRUE, NULL);
|
|
}
|
|
|
|
EComposerHeader *
|
|
e_composer_name_header_new_with_action (const gchar *label,
|
|
const gchar *action_label,
|
|
ENameSelector *name_selector)
|
|
{
|
|
g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
|
|
|
|
return g_object_new (
|
|
E_TYPE_COMPOSER_NAME_HEADER, "label", label,
|
|
"button", TRUE, "name-selector", name_selector,
|
|
"addaction_text", action_label,
|
|
"addaction", action_label != NULL, NULL);
|
|
}
|
|
|
|
ENameSelector *
|
|
e_composer_name_header_get_name_selector (EComposerNameHeader *header)
|
|
{
|
|
g_return_val_if_fail (E_IS_COMPOSER_NAME_HEADER (header), NULL);
|
|
|
|
return header->priv->name_selector;
|
|
}
|
|
|
|
EDestination **
|
|
e_composer_name_header_get_destinations (EComposerNameHeader *header)
|
|
{
|
|
EDestinationStore *store;
|
|
EDestination **destinations;
|
|
ENameSelectorEntry *entry;
|
|
GList *list, *iter;
|
|
gint ii = 0;
|
|
|
|
g_return_val_if_fail (E_IS_COMPOSER_NAME_HEADER (header), NULL);
|
|
|
|
entry = E_COMPOSER_NAME_HEADER_GET_ENTRY (header);
|
|
store = e_name_selector_entry_peek_destination_store (entry);
|
|
|
|
list = e_destination_store_list_destinations (store);
|
|
destinations = g_new0 (EDestination *, g_list_length (list) + 1);
|
|
|
|
for (iter = list; iter != NULL; iter = iter->next)
|
|
destinations[ii++] = g_object_ref (iter->data);
|
|
|
|
g_list_free (list);
|
|
|
|
return destinations; /* free with e_destination_freev() */
|
|
}
|
|
|
|
void
|
|
e_composer_name_header_add_destinations (EComposerNameHeader *header,
|
|
EDestination **destinations)
|
|
{
|
|
EDestinationStore *store;
|
|
ENameSelectorEntry *entry;
|
|
gint ii;
|
|
|
|
g_return_if_fail (E_IS_COMPOSER_NAME_HEADER (header));
|
|
|
|
entry = E_COMPOSER_NAME_HEADER_GET_ENTRY (header);
|
|
store = e_name_selector_entry_peek_destination_store (entry);
|
|
|
|
if (destinations == NULL)
|
|
return;
|
|
|
|
for (ii = 0; destinations[ii] != NULL; ii++)
|
|
e_destination_store_append_destination (
|
|
store, destinations[ii]);
|
|
}
|
|
|
|
void
|
|
e_composer_name_header_set_destinations (EComposerNameHeader *header,
|
|
EDestination **destinations)
|
|
{
|
|
EDestinationStore *store;
|
|
ENameSelectorEntry *entry;
|
|
GList *list, *iter;
|
|
|
|
g_return_if_fail (E_IS_COMPOSER_NAME_HEADER (header));
|
|
|
|
entry = E_COMPOSER_NAME_HEADER_GET_ENTRY (header);
|
|
store = e_name_selector_entry_peek_destination_store (entry);
|
|
|
|
/* Clear the destination store. */
|
|
list = e_destination_store_list_destinations (store);
|
|
for (iter = list; iter != NULL; iter = iter->next)
|
|
e_destination_store_remove_destination (store, iter->data);
|
|
g_list_free (list);
|
|
|
|
e_composer_name_header_add_destinations (header, destinations);
|
|
}
|