diff options
author | Mike Kestner <mkestner@ximian.com> | 2003-10-01 06:39:04 +0800 |
---|---|---|
committer | Mike Kestner <mkestner@src.gnome.org> | 2003-10-01 06:39:04 +0800 |
commit | 54869d90bd04f0a816b1786530d3555ac2b034cc (patch) | |
tree | 3b2859280d478fa6b57227a419125eadd455a615 /calendar/gui/e-select-names-editable.c | |
parent | 642e0e5abd8486793e95fab56e9fd9f3dd0394f8 (diff) | |
download | gsoc2013-evolution-54869d90bd04f0a816b1786530d3555ac2b034cc.tar.gz gsoc2013-evolution-54869d90bd04f0a816b1786530d3555ac2b034cc.tar.zst gsoc2013-evolution-54869d90bd04f0a816b1786530d3555ac2b034cc.zip |
new VOID:STRING,STRING,STRING build the new view/store/renderer/editable
2003-09-30 Mike Kestner <mkestner@ximian.com>
* cal-util/cal-util-marshal.list : new VOID:STRING,STRING,STRING
* gui/Makefile.am : build the new view/store/renderer/editable
* gui/e-select-names-renderer.* : new completion cell renderer
* gui/e-select-names-editable.* : new completion cell editable
* gui/e-meeting-model.* : killed. code reused in list-view/store
* gui/e-meeting-store.* : port of EMeetingModel to GtkTreeModel
* gui/e-meeting-list-view.* : GtkTreeView subclass for attendee lists
* gui/e-meeting-time-sel.c : Use the new store/view
* gui/e-meeting-time-sel-item.c : Use the new store/view
* gui/dialogs/Makefile.am : don't install the etspec anymore.
* gui/dialogs/event-editor.c : Use the new store/view.
* gui/dialogs/meeting-page.c : Use the new store/view.
* gui/dialogs/shedule-page.c : Use the new store/view.
* gui/dialogs/task-editor.c : Use the new store/view.
svn path=/trunk/; revision=22774
Diffstat (limited to 'calendar/gui/e-select-names-editable.c')
-rw-r--r-- | calendar/gui/e-select-names-editable.c | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/calendar/gui/e-select-names-editable.c b/calendar/gui/e-select-names-editable.c new file mode 100644 index 0000000000..2fcc93397a --- /dev/null +++ b/calendar/gui/e-select-names-editable.c @@ -0,0 +1,228 @@ +/* + * e-select-names-editable.c + * + * Author: Mike Kestner <mkestner@ximian.com> + * + * Copyright (C) 2003 Ximian Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include <gdk/gdkkeysyms.h> +#include <gtk/gtkcelleditable.h> +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-widget.h> +#include <ebook/e-destination.h> + +#include "e-select-names-editable.h" +#include "Evolution-Addressbook-SelectNames.h" + +#define SELECT_NAMES_OAFIID "OAFIID:GNOME_Evolution_Addressbook_SelectNames" + +struct _ESelectNamesEditablePriv { + GNOME_Evolution_Addressbook_SelectNames select_names; + Bonobo_Control control; + Bonobo_PropertyBag bag; +}; + +static BonoboWidgetClass *parent_class; + +static void +esne_start_editing (GtkCellEditable *cell_editable, GdkEvent *event) +{ + ESelectNamesEditable *esne = E_SELECT_NAMES_EDITABLE (cell_editable); + +} + +static void +esne_cell_editable_init (GtkCellEditableIface *iface) +{ + iface->start_editing = esne_start_editing; +} + +static void +esne_finalize (GObject *obj) +{ + ESelectNamesEditable *esne = (ESelectNamesEditable *) obj; + + if (esne->priv->select_names != CORBA_OBJECT_NIL) + bonobo_object_release_unref (esne->priv->select_names, NULL); + esne->priv->select_names = CORBA_OBJECT_NIL; + + if (esne->priv->bag != CORBA_OBJECT_NIL) + bonobo_object_release_unref (esne->priv->bag, NULL); + esne->priv->bag = CORBA_OBJECT_NIL; + + g_free (esne->priv); + + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +static void +esne_init (ESelectNamesEditable *esne) +{ + esne->priv = g_new0 (ESelectNamesEditablePriv, 1); + + esne->priv->select_names = CORBA_OBJECT_NIL; + esne->priv->control = CORBA_OBJECT_NIL; + esne->priv->bag = CORBA_OBJECT_NIL; +} + +static void +esne_class_init (GObjectClass *klass) +{ + klass->finalize = esne_finalize; + + parent_class = BONOBO_WIDGET_CLASS (g_type_class_peek_parent (klass)); +} + +GType +e_select_names_editable_get_type (void) +{ + static GType esne_type = 0; + + if (!esne_type) { + static const GTypeInfo esne_info = { + sizeof (ESelectNamesEditableClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) esne_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (ESelectNamesEditable), + 0, /* n_preallocs */ + (GInstanceInitFunc) esne_init, + }; + + static const GInterfaceInfo cell_editable_info = { + (GInterfaceInitFunc) esne_cell_editable_init, + NULL, + NULL + }; + + esne_type = g_type_register_static (BONOBO_TYPE_WIDGET, "ESelectNamesEditable", &esne_info, 0); + + g_type_add_interface_static (esne_type, GTK_TYPE_CELL_EDITABLE, &cell_editable_info); + } + + return esne_type; +} + +static void +entry_activate (BonoboListener *listener, const char *event_name, const CORBA_any *arg, CORBA_Environment *ev, gpointer esne) +{ + gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (esne)); + gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (esne)); +} + +ESelectNamesEditable * +e_select_names_editable_construct (ESelectNamesEditable *esne) +{ + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + esne->priv->select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFIID, 0, NULL, &ev); + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + return NULL; + } + + GNOME_Evolution_Addressbook_SelectNames_addSection (esne->priv->select_names, "A", "A", &ev); + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + return NULL; + } + + esne->priv->control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection ( + esne->priv->select_names, "A", &ev); + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + return NULL; + } + + bonobo_widget_construct_control_from_objref (BONOBO_WIDGET (esne), esne->priv->control, CORBA_OBJECT_NIL, &ev); + + CORBA_exception_free (&ev); + + esne->priv->bag = bonobo_control_frame_get_control_property_bag ( + bonobo_widget_get_control_frame (BONOBO_WIDGET (esne)), NULL); + bonobo_event_source_client_add_listener (esne->priv->bag, entry_activate, + "GNOME/Evolution/Addressbook/SelectNames:activate:entry", + NULL, esne); + + return esne; +} + +ESelectNamesEditable * +e_select_names_editable_new () +{ + ESelectNamesEditable *esne = g_object_new (E_TYPE_SELECT_NAMES_EDITABLE, NULL); + + if (!esne) + return NULL; + + if (!e_select_names_editable_construct (esne)) { + g_object_unref (esne); + return NULL; + } + + return esne; +} + +gchar * +e_select_names_editable_get_address (ESelectNamesEditable *esne) +{ + EDestination **dest; + gchar *dest_str; + gchar *result; + + g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); + + dest_str = bonobo_pbclient_get_string (esne->priv->bag, "destinations", NULL); + dest = e_destination_importv (dest_str); + result = g_strdup (e_destination_get_email (*dest)); + e_destination_freev (dest); + + return result; +} + +gchar * +e_select_names_editable_get_name (ESelectNamesEditable *esne) +{ + EDestination **dest; + gchar *dest_str; + gchar *result; + + g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); + + dest_str = bonobo_pbclient_get_string (esne->priv->bag, "destinations", NULL); + dest = e_destination_importv (dest_str); + result = g_strdup (e_destination_get_name (*dest)); + e_destination_freev (dest); + + return result; +} + +void +e_select_names_editable_set_address (ESelectNamesEditable *esne, const gchar *text) +{ + g_return_if_fail (E_IS_SELECT_NAMES_EDITABLE (esne)); + + bonobo_pbclient_set_string (esne->priv->bag, "addresses", text, NULL); +} + |