From 9515b98403f2f7ef77dc6c51f82505fccef08c2b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 24 Sep 2008 22:53:30 +0000 Subject: Saving progress. Experimenting with directory layout. Saving progress. Experimenting with directory layout. svn path=/branches/kill-bonobo/; revision=36446 --- Makefile.am | 1 + addressbook/gui/component/Makefile.am | 2 + addressbook/gui/component/e-book-shell-content.c | 435 ++++++++++ addressbook/gui/component/e-book-shell-content.h | 92 ++ addressbook/gui/component/e-book-shell-sidebar.c | 3 + .../gui/component/e-book-shell-view-actions.c | 138 +-- .../gui/component/e-book-shell-view-private.c | 147 +--- .../gui/component/e-book-shell-view-private.h | 10 +- addressbook/gui/component/e-book-shell-view.c | 19 +- addressbook/gui/widgets/e-addressbook-view.c | 3 + calendar/Makefile.am | 2 +- calendar/gui/Makefile.am | 379 ++++---- calendar/gui/calendar-component.c | 57 -- calendar/gui/comp-editor-factory.c | 4 - calendar/gui/dialogs/comp-editor.c | 41 +- calendar/gui/dialogs/comp-editor.h | 3 + calendar/gui/e-cal-component-memo-preview.c | 366 -------- calendar/gui/e-cal-component-memo-preview.h | 66 -- calendar/gui/e-cal-model.c | 8 +- calendar/gui/e-cal-shell-module.c | 399 --------- calendar/gui/e-cal-shell-sidebar.c | 331 ------- calendar/gui/e-cal-shell-sidebar.h | 67 -- calendar/gui/e-cal-shell-view-actions.c | 331 ------- calendar/gui/e-cal-shell-view-actions.h | 30 - calendar/gui/e-cal-shell-view-private.c | 59 -- calendar/gui/e-cal-shell-view-private.h | 81 -- calendar/gui/e-cal-shell-view.c | 174 ---- calendar/gui/e-cal-shell-view.h | 73 -- calendar/gui/e-calendar-selector.c | 63 +- calendar/gui/e-calendar-table-config.c | 282 +++--- calendar/gui/e-calendar-table-config.h | 46 +- calendar/gui/e-calendar-table.c | 955 ++++++++++++--------- calendar/gui/e-calendar-table.h | 113 +-- calendar/gui/e-calendar-view.c | 5 +- calendar/gui/e-meeting-time-sel.c | 1 - calendar/gui/e-memo-preview.c | 356 ++++++++ calendar/gui/e-memo-preview.h | 84 ++ calendar/gui/e-memo-shell-module.c | 298 ------- calendar/gui/e-memo-shell-sidebar.c | 264 ------ calendar/gui/e-memo-shell-sidebar.h | 68 -- calendar/gui/e-memo-shell-view-actions.c | 347 -------- calendar/gui/e-memo-shell-view-actions.h | 48 -- calendar/gui/e-memo-shell-view-private.c | 85 -- calendar/gui/e-memo-shell-view-private.h | 92 -- calendar/gui/e-memo-shell-view.c | 165 ---- calendar/gui/e-memo-shell-view.h | 70 -- calendar/gui/e-memo-table.c | 265 ++++-- calendar/gui/e-memo-table.h | 90 +- calendar/gui/e-memos.c | 436 ---------- calendar/gui/e-select-names-renderer.c | 4 +- calendar/gui/e-task-shell-module.c | 296 ------- calendar/gui/e-task-shell-sidebar.c | 264 ------ calendar/gui/e-task-shell-sidebar.h | 68 -- calendar/gui/e-task-shell-view-actions.c | 263 ------ calendar/gui/e-task-shell-view-actions.h | 56 -- calendar/gui/e-task-shell-view-private.c | 59 -- calendar/gui/e-task-shell-view-private.h | 80 -- calendar/gui/e-task-shell-view.c | 165 ---- calendar/gui/e-task-shell-view.h | 70 -- calendar/gui/e-tasks.c | 10 - calendar/gui/gnome-cal.c | 15 +- calendar/gui/main.c | 2 - calendar/gui/memos-component.c | 118 --- calendar/gui/tasks-component.c | 4 - calendar/gui/tasks-control.c | 141 --- calendar/modules/e-cal-shell-module.c | 399 +++++++++ calendar/modules/e-cal-shell-sidebar.c | 331 +++++++ calendar/modules/e-cal-shell-sidebar.h | 67 ++ calendar/modules/e-cal-shell-view-actions.c | 331 +++++++ calendar/modules/e-cal-shell-view-actions.h | 30 + calendar/modules/e-cal-shell-view-private.c | 73 ++ calendar/modules/e-cal-shell-view-private.h | 86 ++ calendar/modules/e-cal-shell-view.c | 175 ++++ calendar/modules/e-cal-shell-view.h | 73 ++ calendar/modules/e-memo-shell-content.c | 550 ++++++++++++ calendar/modules/e-memo-shell-content.h | 83 ++ calendar/modules/e-memo-shell-module.c | 299 +++++++ calendar/modules/e-memo-shell-sidebar.c | 265 ++++++ calendar/modules/e-memo-shell-sidebar.h | 71 ++ calendar/modules/e-memo-shell-view-actions.c | 367 ++++++++ calendar/modules/e-memo-shell-view-actions.h | 48 ++ calendar/modules/e-memo-shell-view-private.c | 316 +++++++ calendar/modules/e-memo-shell-view-private.h | 106 +++ calendar/modules/e-memo-shell-view.c | 167 ++++ calendar/modules/e-memo-shell-view.h | 70 ++ calendar/modules/e-task-shell-content.c | 550 ++++++++++++ calendar/modules/e-task-shell-content.h | 76 ++ calendar/modules/e-task-shell-module.c | 297 +++++++ calendar/modules/e-task-shell-sidebar.c | 265 ++++++ calendar/modules/e-task-shell-sidebar.h | 68 ++ calendar/modules/e-task-shell-view-actions.c | 332 +++++++ calendar/modules/e-task-shell-view-actions.h | 56 ++ calendar/modules/e-task-shell-view-private.c | 141 +++ calendar/modules/e-task-shell-view-private.h | 95 ++ calendar/modules/e-task-shell-view.c | 166 ++++ calendar/modules/e-task-shell-view.h | 70 ++ configure.in | 1 + doc/reference/shell/tmpl/e-shell-window.sgml | 10 - doc/reference/shell/tmpl/eshell-unused.sgml | 9 + shell/e-shell-content.c | 1 - shell/e-shell-content.h | 2 +- shell/e-shell-module.h | 2 +- shell/e-shell-sidebar.c | 8 + shell/e-shell-sidebar.h | 2 +- shell/e-shell-taskbar.h | 2 +- shell/e-shell-view.c | 12 +- shell/e-shell-view.h | 21 +- shell/e-shell-window-actions.c | 24 +- shell/e-shell-window-private.c | 6 +- shell/e-shell-window.c | 40 +- shell/e-shell-window.h | 6 +- shell/e-shell.h | 4 +- ui/evolution-calendars.ui | 7 + ui/evolution-memos.ui | 7 + ui/evolution-tasks.ui | 7 + 115 files changed, 8515 insertions(+), 6748 deletions(-) create mode 100644 addressbook/gui/component/e-book-shell-content.c create mode 100644 addressbook/gui/component/e-book-shell-content.h delete mode 100644 calendar/gui/e-cal-component-memo-preview.c delete mode 100644 calendar/gui/e-cal-component-memo-preview.h delete mode 100644 calendar/gui/e-cal-shell-module.c delete mode 100644 calendar/gui/e-cal-shell-sidebar.c delete mode 100644 calendar/gui/e-cal-shell-sidebar.h delete mode 100644 calendar/gui/e-cal-shell-view-actions.c delete mode 100644 calendar/gui/e-cal-shell-view-actions.h delete mode 100644 calendar/gui/e-cal-shell-view-private.c delete mode 100644 calendar/gui/e-cal-shell-view-private.h delete mode 100644 calendar/gui/e-cal-shell-view.c delete mode 100644 calendar/gui/e-cal-shell-view.h create mode 100644 calendar/gui/e-memo-preview.c create mode 100644 calendar/gui/e-memo-preview.h delete mode 100644 calendar/gui/e-memo-shell-module.c delete mode 100644 calendar/gui/e-memo-shell-sidebar.c delete mode 100644 calendar/gui/e-memo-shell-sidebar.h delete mode 100644 calendar/gui/e-memo-shell-view-actions.c delete mode 100644 calendar/gui/e-memo-shell-view-actions.h delete mode 100644 calendar/gui/e-memo-shell-view-private.c delete mode 100644 calendar/gui/e-memo-shell-view-private.h delete mode 100644 calendar/gui/e-memo-shell-view.c delete mode 100644 calendar/gui/e-memo-shell-view.h delete mode 100644 calendar/gui/e-task-shell-module.c delete mode 100644 calendar/gui/e-task-shell-sidebar.c delete mode 100644 calendar/gui/e-task-shell-sidebar.h delete mode 100644 calendar/gui/e-task-shell-view-actions.c delete mode 100644 calendar/gui/e-task-shell-view-actions.h delete mode 100644 calendar/gui/e-task-shell-view-private.c delete mode 100644 calendar/gui/e-task-shell-view-private.h delete mode 100644 calendar/gui/e-task-shell-view.c delete mode 100644 calendar/gui/e-task-shell-view.h create mode 100644 calendar/modules/e-cal-shell-module.c create mode 100644 calendar/modules/e-cal-shell-sidebar.c create mode 100644 calendar/modules/e-cal-shell-sidebar.h create mode 100644 calendar/modules/e-cal-shell-view-actions.c create mode 100644 calendar/modules/e-cal-shell-view-actions.h create mode 100644 calendar/modules/e-cal-shell-view-private.c create mode 100644 calendar/modules/e-cal-shell-view-private.h create mode 100644 calendar/modules/e-cal-shell-view.c create mode 100644 calendar/modules/e-cal-shell-view.h create mode 100644 calendar/modules/e-memo-shell-content.c create mode 100644 calendar/modules/e-memo-shell-content.h create mode 100644 calendar/modules/e-memo-shell-module.c create mode 100644 calendar/modules/e-memo-shell-sidebar.c create mode 100644 calendar/modules/e-memo-shell-sidebar.h create mode 100644 calendar/modules/e-memo-shell-view-actions.c create mode 100644 calendar/modules/e-memo-shell-view-actions.h create mode 100644 calendar/modules/e-memo-shell-view-private.c create mode 100644 calendar/modules/e-memo-shell-view-private.h create mode 100644 calendar/modules/e-memo-shell-view.c create mode 100644 calendar/modules/e-memo-shell-view.h create mode 100644 calendar/modules/e-task-shell-content.c create mode 100644 calendar/modules/e-task-shell-content.h create mode 100644 calendar/modules/e-task-shell-module.c create mode 100644 calendar/modules/e-task-shell-sidebar.c create mode 100644 calendar/modules/e-task-shell-sidebar.h create mode 100644 calendar/modules/e-task-shell-view-actions.c create mode 100644 calendar/modules/e-task-shell-view-actions.h create mode 100644 calendar/modules/e-task-shell-view-private.c create mode 100644 calendar/modules/e-task-shell-view-private.h create mode 100644 calendar/modules/e-task-shell-view.c create mode 100644 calendar/modules/e-task-shell-view.h diff --git a/Makefile.am b/Makefile.am index b176ca4baa..02f1a161f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ SUBDIRS = \ shell \ $(SMIME_DIR) \ addressbook \ + calendar \ art \ doc \ ui \ diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 974bce0a99..0df52c0336 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -34,6 +34,8 @@ libevolution_addressbook_la_SOURCES = \ autocompletion-config.h \ addressbook.c \ addressbook.h \ + e-book-shell-content.c \ + e-book-shell-content.h \ e-book-shell-module.c \ e-book-shell-sidebar.c \ e-book-shell-sidebar.h \ diff --git a/addressbook/gui/component/e-book-shell-content.c b/addressbook/gui/component/e-book-shell-content.c new file mode 100644 index 0000000000..f7a7cb88e4 --- /dev/null +++ b/addressbook/gui/component/e-book-shell-content.c @@ -0,0 +1,435 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-book-shell-content.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-book-shell-content.h" + +#include +#include + +#define E_BOOK_SHELL_CONTENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_BOOK_SHELL_CONTENT, EBookShellContentPrivate)) + +struct _EBookShellContentPrivate { + GtkWidget *paned; + GtkWidget *notebook; + GtkWidget *preview; +}; + +enum { + PROP_0, + PROP_CURRENT_VIEW, + PROP_PREVIEW_CONTACT, + PROP_PREVIEW_VISIBLE +}; + +static gpointer parent_class; + +static void +book_shell_content_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CURRENT_VIEW: + e_book_shell_content_set_current_view ( + E_BOOK_SHELL_CONTENT (object), + g_value_get_object (value)); + return; + + case PROP_PREVIEW_CONTACT: + e_book_shell_content_set_preview_contact ( + E_BOOK_SHELL_CONTENT (object), + g_value_get_object (value)); + return; + + case PROP_PREVIEW_VISIBLE: + e_book_shell_content_set_preview_visible ( + E_BOOK_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +book_shell_content_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CURRENT_VIEW: + g_value_set_object ( + value, e_book_shell_content_get_current_view ( + E_BOOK_SHELL_CONTENT (object))); + return; + + case PROP_PREVIEW_CONTACT: + g_value_set_object ( + value, e_book_shell_content_get_preview_contact ( + E_BOOK_SHELL_CONTENT (object))); + return; + + case PROP_PREVIEW_VISIBLE: + g_value_set_boolean ( + value, e_book_shell_content_get_preview_visible ( + E_BOOK_SHELL_CONTENT (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +book_shell_content_dispose (GObject *object) +{ + EBookShellContentPrivate *priv; + + priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (object); + + if (priv->paned != NULL) { + g_object_unref (priv->paned); + priv->paned = NULL; + } + + if (priv->notebook != NULL) { + g_object_unref (priv->notebook); + priv->notebook = NULL; + } + + if (priv->preview != NULL) { + g_object_unref (priv->preview); + priv->preview = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +book_shell_content_constructed (GObject *object) +{ + EBookShellContentPrivate *priv; + GConfBridge *bridge; + GtkWidget *container; + GtkWidget *widget; + const gchar *key; + + priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + container = GTK_WIDGET (object); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->paned = g_object_ref (widget); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); + gtk_paned_add1 (GTK_PANED (container), widget); + priv->notebook = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_paned_add2 (GTK_PANED (container), widget); + gtk_widget_show (widget); + + container = widget; + + widget = eab_contact_display_new (); + eab_contact_display_set_mode ( + EAB_CONTACT_DISPLAY (widget), + EAB_CONTACT_DISPLAY_RENDER_NORMAL); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->preview = g_object_ref (widget); + gtk_widget_show (widget); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (priv->paned); + key = "/apps/evolution/addressbook/display/vpane_position"; + gconf_bridge_bind_property_delayed (bridge, key, object, "position"); +} + +static void +book_shell_content_class_init (EBookShellContentClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EBookShellContentPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = book_shell_content_set_property; + object_class->get_property = book_shell_content_get_property; + object_class->dispose = book_shell_content_dispose; + object_class->constructed = book_shell_content_constructed; + + g_object_class_install_property ( + object_class, + PROP_CURRENT_VIEW, + g_param_spec_object ( + "current-view", + _("Current View"), + _("The currently selected address book view"), + E_TYPE_ADDRESSBOOK_VIEW, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_CONTACT, + g_param_spec_object ( + "preview-contact", + _("Previewed Contact"), + _("The contact being shown in the preview pane"), + E_TYPE_CONTACT, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_VISIBLE, + g_param_spec_boolean ( + "preview-visible", + _("Preview is Visible"), + _("Whether the preview pane is visible"), + TRUE, + G_PARAM_READWRITE)); +} + +static void +book_shell_content_init (EBookShellContent *book_shell_content) +{ + book_shell_content->priv = + E_BOOK_SHELL_CONTENT_GET_PRIVATE (book_shell_content); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_book_shell_content_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EBookShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) book_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EBookShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) book_shell_content_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_CONTENT, "EBookShellContent", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_book_shell_content_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_BOOK_SHELL_CONTENT, + "shell-view", shell_view, NULL); +} + +void +e_book_shell_content_insert_view (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view) +{ + GtkNotebook *notebook; + GtkWidget *child; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view)); + + notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook); + child = GTK_WIDGET (addressbook_view); + gtk_notebook_append_page (notebook, child, NULL); +} + +void +e_book_shell_content_remove_view (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view) +{ + GtkNotebook *notebook; + GtkWidget *child; + gint page_num; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view)); + + notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook); + child = GTK_WIDGET (addressbook_view); + page_num = gtk_notebook_page_num (notebook, child); + g_return_if_fail (page_num >= 0); + + gtk_notebook_remove_page (notebook, page_num); +} + +EAddressbookView * +e_book_shell_content_get_current_view (EBookShellContent *book_shell_content) +{ + GtkNotebook *notebook; + GtkWidget *widget; + gint page_num; + + g_return_val_if_fail ( + E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL); + + notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook); + page_num = gtk_notebook_get_current_page (notebook); + widget = gtk_notebook_get_nth_page (notebook, page_num); + g_return_val_if_fail (widget != NULL, NULL); + + return E_ADDRESSBOOK_VIEW (widget); +} + +void +e_book_shell_content_set_current_view (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view) +{ + GtkNotebook *notebook; + GtkWidget *child; + gint page_num; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view)); + + notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook); + child = GTK_WIDGET (addressbook_view); + page_num = gtk_notebook_page_num (notebook, child); + g_return_if_fail (page_num >= 0); + + gtk_notebook_set_current_page (notebook, page_num); + g_object_notify (G_OBJECT (book_shell_content), "current-view"); +} + +EContact * +e_book_shell_content_get_preview_contact (EBookShellContent *book_shell_content) +{ + EABContactDisplay *display; + + g_return_val_if_fail ( + E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL); + + display = EAB_CONTACT_DISPLAY (book_shell_content->priv->preview); + + return eab_contact_display_get_contact (display); +} + +void +e_book_shell_content_set_preview_contact (EBookShellContent *book_shell_content, + EContact *preview_contact) +{ + EABContactDisplay *display; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + + display = EAB_CONTACT_DISPLAY (book_shell_content->priv->preview); + + eab_contact_display_set_contact (display, preview_contact); + g_object_notify (G_OBJECT (book_shell_content), "preview-contact"); +} + +gboolean +e_book_shell_content_get_preview_visible (EBookShellContent *book_shell_content) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_val_if_fail ( + E_IS_BOOK_SHELL_CONTENT (book_shell_content), FALSE); + + paned = GTK_PANED (book_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + return GTK_WIDGET_VISIBLE (child); +} + +void +e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content, + gboolean preview_visible) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + + paned = GTK_PANED (book_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + if (preview_visible) + gtk_widget_show (child); + else + gtk_widget_hide (child); + + g_object_notify (G_OBJECT (book_shell_content), "preview-visible"); +} + +void +e_book_shell_content_clipboard_copy (EBookShellContent *book_shell_content) +{ + EAddressbookView *addressbook_view; + GtkHTML *html; + gchar *selection; + + g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content)); + + html = GTK_HTML (book_shell_content->priv->preview); + addressbook_view = + e_book_shell_content_get_current_view (book_shell_content); + g_return_if_fail (addressbook_view != NULL); + + if (!GTK_WIDGET_HAS_FOCUS (html)) { + e_addressbook_view_copy (addressbook_view); + return; + } + + selection = gtk_html_get_selection_html (html, NULL); + if (selection != NULL) + gtk_html_copy (html); + g_free (selection); +} diff --git a/addressbook/gui/component/e-book-shell-content.h b/addressbook/gui/component/e-book-shell-content.h new file mode 100644 index 0000000000..01911e79b6 --- /dev/null +++ b/addressbook/gui/component/e-book-shell-content.h @@ -0,0 +1,92 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-book-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_BOOK_SHELL_CONTENT_H +#define E_BOOK_SHELL_CONTENT_H + +#include + +#include +#include + +#include + +/* Standard GObject macros */ +#define E_TYPE_BOOK_SHELL_CONTENT \ + (e_book_shell_content_get_type ()) +#define E_BOOK_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_BOOK_SHELL_CONTENT, EBookShellContent)) +#define E_BOOK_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_BOOK_SHELL_CONTENT, EBookShellContentClass)) +#define E_IS_BOOK_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_BOOK_SHELL_CONTENT)) +#define E_IS_BOOK_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_BOOK_SHELL_CONTENT)) +#define E_BOOK_SHELL_CONTENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_BOOK_SHELL_CONTENT, EBookShellContentClass)) + +G_BEGIN_DECLS + +typedef struct _EBookShellContent EBookShellContent; +typedef struct _EBookShellContentClass EBookShellContentClass; +typedef struct _EBookShellContentPrivate EBookShellContentPrivate; + +struct _EBookShellContent { + EShellContent parent; + EBookShellContentPrivate *priv; +}; + +struct _EBookShellContentClass { + EShellContentClass parent_class; +}; + +GType e_book_shell_content_get_type (void); +GtkWidget * e_book_shell_content_new (EShellView *shell_view); +void e_book_shell_content_insert_view(EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); +void e_book_shell_content_remove_view(EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); +EAddressbookView * + e_book_shell_content_get_current_view + (EBookShellContent *book_shell_content); +void e_book_shell_content_set_current_view + (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); +EContact * e_book_shell_content_get_preview_contact + (EBookShellContent *book_shell_content); +void e_book_shell_content_set_preview_contact + (EBookShellContent *book_shell_content, + EContact *preview_contact); +gboolean e_book_shell_content_get_preview_visible + (EBookShellContent *book_shell_content); +void e_book_shell_content_set_preview_visible + (EBookShellContent *book_shell_content, + gboolean preview_visible); +void e_book_shell_content_clipboard_copy + (EBookShellContent *book_shell_content); + +G_END_DECLS + +#endif /* E_BOOK_SHELL_CONTENT_H */ diff --git a/addressbook/gui/component/e-book-shell-sidebar.c b/addressbook/gui/component/e-book-shell-sidebar.c index d801fa1325..a38396beed 100644 --- a/addressbook/gui/component/e-book-shell-sidebar.c +++ b/addressbook/gui/component/e-book-shell-sidebar.c @@ -86,6 +86,9 @@ book_shell_sidebar_constructed (GObject *object) priv = E_BOOK_SHELL_SIDEBAR_GET_PRIVATE (object); + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); book_shell_view = E_BOOK_SHELL_VIEW (shell_view); diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index e27474aac0..5dd1484c7a 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -30,10 +30,13 @@ static void action_address_book_copy_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_copy_to_folder (view, TRUE); } @@ -55,7 +58,7 @@ action_address_book_delete_cb (GtkAction *action, shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - book_shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_peek_primary_selection (selector); g_return_if_fail (source != NULL); @@ -99,10 +102,13 @@ static void action_address_book_move_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_move_to_folder (view, TRUE); } @@ -135,7 +141,7 @@ action_address_book_properties_cb (GtkAction *action, shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - book_shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_peek_primary_selection (selector); g_return_if_fail (source != NULL); @@ -169,10 +175,13 @@ static void action_address_book_save_as_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_save_as (view, TRUE); } @@ -180,10 +189,13 @@ static void action_address_book_stop_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_stop (view); } @@ -191,33 +203,23 @@ static void action_contact_clipboard_copy_cb (GtkAction *action, EBookShellView *book_shell_view) { - EAddressbookView *view; - GtkWidget *preview; - gchar *selection; - - preview = book_shell_view->priv->preview; - view = e_book_shell_view_get_current_view (book_shell_view); - g_return_if_fail (view != NULL); - - if (!GTK_WIDGET_HAS_FOCUS (preview)) { - e_addressbook_view_copy (view); - return; - } + EBookShellContent *book_shell_content; - selection = gtk_html_get_selection_html (GTK_HTML (preview), NULL); - if (selection != NULL) - gtk_html_copy (GTK_HTML (preview)); - g_free (selection); + book_shell_content = book_shell_view->priv->book_shell_content; + e_book_shell_content_clipboard_copy (book_shell_content); } static void action_contact_clipboard_cut_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_cut (view); } @@ -225,10 +227,13 @@ static void action_contact_clipboard_paste_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_paste (view); } @@ -236,10 +241,13 @@ static void action_contact_copy_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_copy_to_folder (view, FALSE); } @@ -247,10 +255,13 @@ static void action_contact_delete_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_delete_selection (view, TRUE); } @@ -258,10 +269,13 @@ static void action_contact_forward_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_send (view); } @@ -269,10 +283,13 @@ static void action_contact_move_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_move_to_folder (view, FALSE); } @@ -280,12 +297,14 @@ static void action_contact_new_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; EContact *contact; EBook *book; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); model = e_addressbook_view_get_model (view); @@ -301,12 +320,14 @@ static void action_contact_new_list_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; EContact *contact; EBook *book; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); model = e_addressbook_view_get_model (view); @@ -322,10 +343,13 @@ static void action_contact_open_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_view (view); } @@ -333,25 +357,26 @@ static void action_contact_preview_cb (GtkToggleAction *action, EBookShellView *book_shell_view) { - GtkWidget *child; - GtkWidget *paned; + EBookShellContent *book_shell_content; gboolean visible; - paned = book_shell_view->priv->paned; - child = gtk_paned_get_child2 (GTK_PANED (paned)); + book_shell_content = book_shell_view->priv->book_shell_content; visible = gtk_toggle_action_get_active (action); - g_object_set (child, "visible", visible, NULL); + e_book_shell_content_set_preview_visible (book_shell_content, visible); } static void action_contact_print_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; GtkPrintOperationAction print_action; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; e_addressbook_view_print (view, print_action); } @@ -360,11 +385,14 @@ static void action_contact_print_preview_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; GtkPrintOperationAction print_action; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; e_addressbook_view_print (view, print_action); } @@ -373,10 +401,13 @@ static void action_contact_save_as_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_save_as (view, FALSE); } @@ -384,10 +415,13 @@ static void action_contact_select_all_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_select_all (view); } @@ -395,10 +429,13 @@ static void action_contact_send_message_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); + e_addressbook_view_send_to (view); } @@ -406,6 +443,7 @@ static void action_gal_save_custom_view_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EShellView *shell_view; EAddressbookView *address_view; GalViewInstance *view_instance; @@ -414,7 +452,8 @@ action_gal_save_custom_view_cb (GtkAction *action, if (!e_shell_view_is_active (shell_view)) return; - address_view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + address_view = e_book_shell_content_get_current_view (book_shell_content); view_instance = e_addressbook_view_get_view_instance (address_view); gal_view_instance_save_as (view_instance); } @@ -423,13 +462,13 @@ static void action_search_execute_cb (GtkAction *action, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EShellView *shell_view; EShellWindow *shell_window; EShellContent *shell_content; GString *string; EAddressbookView *view; EAddressbookModel *model; - EABContactDisplay *display; FilterRule *rule; const gchar *format; const gchar *text; @@ -503,13 +542,13 @@ action_search_execute_cb (GtkAction *action, g_object_unref (rule); /* Submit the query. */ - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); model = e_addressbook_view_get_model (view); e_addressbook_model_set_query (model, query); g_free (query); - display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); - eab_contact_display_set_contact (display, NULL); + e_book_shell_content_set_preview_contact (book_shell_content, NULL); } static GtkActionEntry contact_entries[] = { @@ -806,6 +845,7 @@ e_book_shell_view_actions_update (EBookShellView *book_shell_view) EShellWindow *shell_window; EAddressbookModel *model; EAddressbookView *view; + EBookShellContent *book_shell_content; EBookShellSidebar *book_shell_sidebar; ESelectionModel *selection_model; ESourceSelector *selector; @@ -819,9 +859,11 @@ e_book_shell_view_actions_update (EBookShellView *book_shell_view) shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - view = e_book_shell_view_get_current_view (book_shell_view); - book_shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); + + book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_peek_primary_selection (selector); diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index 4dd88e7758..2cd5378c79 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -45,40 +45,40 @@ static void book_shell_view_selection_change_foreach (gint row, EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; - EABContactDisplay *display; EContact *contact; /* XXX A "foreach" function is kind of a silly way to retrieve * the one and only selected contact, but this is the only * means that ESelectionModel provides. */ - view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + view = e_book_shell_content_get_current_view (book_shell_content); model = e_addressbook_view_get_model (view); contact = e_addressbook_model_get_contact (model, row); - display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); - eab_contact_display_set_contact (display, contact); + e_book_shell_content_set_preview_contact (book_shell_content, contact); } static void selection_change (EBookShellView *book_shell_view, EAddressbookView *view) { + EBookShellContent *book_shell_content; EAddressbookView *current_view; ESelectionModel *selection_model; - EABContactDisplay *display; gint n_selected; - current_view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + current_view = e_book_shell_content_get_current_view (book_shell_content); if (view != current_view) return; e_book_shell_view_actions_update (book_shell_view); - display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); selection_model = e_addressbook_view_get_selection_model (view); n_selected = (selection_model != NULL) ? @@ -90,24 +90,27 @@ selection_change (EBookShellView *book_shell_view, book_shell_view_selection_change_foreach, book_shell_view); else - eab_contact_display_set_contact (display, NULL); + e_book_shell_content_set_preview_contact ( + book_shell_content, NULL); } static void contact_changed (EBookShellView *book_shell_view, EContact *contact) { - EABContactDisplay *display; - EContact *displayed_contact; + EBookShellContent *book_shell_content; + EContact *preview_contact; - display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); - displayed_contact = eab_contact_display_get_contact (display); + book_shell_content = book_shell_view->priv->book_shell_content; - if (contact != displayed_contact) + preview_contact = + e_book_shell_content_get_preview_contact (book_shell_content); + + if (contact != preview_contact) return; /* Re-render the same contact. */ - eab_contact_display_set_contact (display, contact); + e_book_shell_content_set_preview_contact (book_shell_content, contact); } static void @@ -115,21 +118,23 @@ contacts_removed (EBookShellView *book_shell_view, GArray *removed_indices, EAddressbookModel *model) { - EABContactDisplay *display; - EContact *displayed_contact; + EBookShellContent *book_shell_content; + EContact *preview_contact; + + book_shell_content = book_shell_view->priv->book_shell_content; - display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); - displayed_contact = eab_contact_display_get_contact (display); + preview_contact = + e_book_shell_content_get_preview_contact (book_shell_content); - if (displayed_contact == NULL) + if (preview_contact == NULL) return; /* Is the displayed contact still in the model? */ - if (e_addressbook_model_find (model, displayed_contact) < 0) + if (e_addressbook_model_find (model, preview_contact) < 0) return; /* If not, clear the contact display. */ - eab_contact_display_set_contact (display, NULL); + e_book_shell_content_set_preview_contact (book_shell_content, NULL); } static void @@ -156,19 +161,18 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, ESourceSelector *selector) { EShellView *shell_view; + EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; ESource *source; GalViewInstance *view_instance; GHashTable *hash_table; - GtkNotebook *notebook; GtkWidget *widget; const gchar *uid; gchar *view_id; - gint page_num; shell_view = E_SHELL_VIEW (book_shell_view); - notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook); + book_shell_content = book_shell_view->priv->book_shell_content; source = e_source_selector_peek_primary_selection (selector); if (source == NULL) @@ -202,9 +206,13 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, widget = e_addressbook_view_new (shell_view, source); gtk_widget_show (widget); - g_object_ref_sink (widget); - gtk_notebook_append_page (notebook, widget, NULL); - g_hash_table_insert (hash_table, g_strdup (uid), widget); + e_book_shell_content_insert_view ( + book_shell_content, + E_ADDRESSBOOK_VIEW (widget)); + + g_hash_table_insert ( + hash_table, g_strdup (uid), + g_object_ref (widget)); g_signal_connect_swapped ( widget, "popup-event", @@ -236,8 +244,8 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, G_CALLBACK (contacts_removed), book_shell_view); } - page_num = gtk_notebook_page_num (notebook, widget); - gtk_notebook_set_current_page (notebook, page_num); + e_book_shell_content_set_current_view ( + book_shell_content, E_ADDRESSBOOK_VIEW (widget)); view_instance = e_addressbook_view_get_view_instance (view); view_id = gal_view_instance_get_current_view_id (view_instance); @@ -333,11 +341,13 @@ book_shell_view_load_view_collection (EShellViewClass *shell_view_class) static void book_shell_view_notify_view_id_cb (EBookShellView *book_shell_view) { + EBookShellContent *book_shell_content; EAddressbookView *address_view; GalViewInstance *view_instance; const gchar *view_id; - address_view = e_book_shell_view_get_current_view (book_shell_view); + book_shell_content = book_shell_view->priv->book_shell_content; + address_view = e_book_shell_content_get_current_view (book_shell_content); view_instance = e_addressbook_view_get_view_instance (address_view); view_id = e_shell_view_get_view_id (E_SHELL_VIEW (book_shell_view)); @@ -399,54 +409,16 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view) EShellView *shell_view; EShellWindow *shell_window; ESourceSelector *selector; - GConfBridge *bridge; - GtkWidget *container; - GtkWidget *widget; - GObject *object; - const gchar *key; shell_view = E_SHELL_VIEW (book_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - /* Construct view widgets. */ + /* Cache these to avoid lots of awkward casting. */ + priv->book_shell_content = g_object_ref (shell_content); + priv->book_shell_sidebar = g_object_ref (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); - container = GTK_WIDGET (shell_content); - - widget = gtk_vpaned_new (); - gtk_container_add (GTK_CONTAINER (container), widget); - priv->paned = g_object_ref (widget); - gtk_widget_show (widget); - - container = widget; - - widget = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); - gtk_paned_add1 (GTK_PANED (container), widget); - priv->notebook = g_object_ref (widget); - gtk_widget_show (widget); - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_paned_add2 (GTK_PANED (container), widget); - gtk_widget_show (widget); - - container = widget; - - widget = eab_contact_display_new (); - eab_contact_display_set_mode ( - EAB_CONTACT_DISPLAY (widget), - EAB_CONTACT_DISPLAY_RENDER_NORMAL); - gtk_container_add (GTK_CONTAINER (container), widget); - priv->preview = g_object_ref (widget); - gtk_widget_show (widget); - - shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); selector = e_book_shell_sidebar_get_selector ( E_BOOK_SHELL_SIDEBAR (shell_sidebar)); @@ -477,14 +449,6 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view) e_book_shell_view_actions_init (book_shell_view); e_book_shell_view_update_search_filter (book_shell_view); book_shell_view_activate_selected_source (book_shell_view, selector); - - /* Bind GObject properties to GConf keys. */ - - bridge = gconf_bridge_get (); - - object = G_OBJECT (book_shell_view->priv->paned); - key = "/apps/evolution/addressbook/display/vpane_position"; - gconf_bridge_bind_property_delayed (bridge, key, object, "position"); } void @@ -497,9 +461,8 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view) DISPOSE (priv->contact_actions); DISPOSE (priv->filter_actions); - DISPOSE (priv->paned); - DISPOSE (priv->notebook); - DISPOSE (priv->preview); + DISPOSE (priv->book_shell_content); + DISPOSE (priv->book_shell_sidebar); g_hash_table_remove_all (priv->uid_to_view); g_hash_table_remove_all (priv->uid_to_editor); @@ -514,22 +477,6 @@ e_book_shell_view_private_finalize (EBookShellView *book_shell_view) g_hash_table_destroy (priv->uid_to_editor); } -EAddressbookView * -e_book_shell_view_get_current_view (EBookShellView *book_shell_view) -{ - GtkNotebook *notebook; - GtkWidget *widget; - gint page_num; - - g_return_val_if_fail (E_IS_BOOK_SHELL_VIEW (book_shell_view), NULL); - - notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook); - page_num = gtk_notebook_get_current_page (notebook); - widget = gtk_notebook_get_nth_page (notebook, page_num); - - return E_ADDRESSBOOK_VIEW (widget); -} - void e_book_shell_view_editor_weak_notify (EditorUidClosure *closure, GObject *where_the_object_was) diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index f4a9d25b91..00a9249c2d 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -90,9 +91,9 @@ struct _EBookShellViewPrivate { /*** Other Stuff ***/ - GtkWidget *paned; - GtkWidget *notebook; - GtkWidget *preview; + /* These are just for convenience. */ + EBookShellContent *book_shell_content; + EBookShellSidebar *book_shell_sidebar; GHashTable *uid_to_view; GHashTable *uid_to_editor; @@ -114,9 +115,6 @@ void e_book_shell_view_actions_init (EBookShellView *book_shell_view); void e_book_shell_view_actions_update (EBookShellView *book_shell_view); -EAddressbookView * - e_book_shell_view_get_current_view - (EBookShellView *book_shell_view); void e_book_shell_view_editor_weak_notify (EditorUidClosure *closure, GObject *where_the_object_was); diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index c2b8450b79..d43ef0bd96 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -20,8 +20,6 @@ #include "e-book-shell-view-private.h" -#define SEARCH_OPTIONS_PATH "/contact-search-options" - enum { PROP_0, PROP_SOURCE_LIST @@ -35,25 +33,23 @@ book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view, ESourceList *source_list) { EBookShellViewPrivate *priv = book_shell_view->priv; - GtkNotebook *notebook; + EBookShellContent *book_shell_content; GList *keys, *iter; - notebook = GTK_NOTEBOOK (priv->notebook); + book_shell_content = book_shell_view->priv->book_shell_content; keys = g_hash_table_get_keys (priv->uid_to_view); for (iter = keys; iter != NULL; iter = iter->next) { gchar *uid = iter->data; - GtkWidget *widget; - gint page_num; + EAddressbookView *view; /* If the source still exists, move on. */ if (e_source_list_peek_source_by_uid (source_list, uid)) continue; /* Remove the view for the deleted source. */ - widget = g_hash_table_lookup (priv->uid_to_view, uid); - page_num = gtk_notebook_page_num (notebook, widget); - gtk_notebook_remove_page (notebook, page_num); + view = g_hash_table_lookup (priv->uid_to_view, uid); + e_book_shell_content_remove_view (book_shell_content, view); g_hash_table_remove (priv->uid_to_view, uid); } g_list_free (keys); @@ -166,10 +162,11 @@ book_shell_view_class_init (EBookShellViewClass *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = N_("Contacts"); shell_view_class->icon_name = "x-office-address-book"; + shell_view_class->search_options = "/contact-search-options"; shell_view_class->type_module = type_module; - shell_view_class->changed = book_shell_view_changed; - shell_view_class->search_options_path = SEARCH_OPTIONS_PATH; + shell_view_class->new_shell_content = e_book_shell_content_new; shell_view_class->new_shell_sidebar = e_book_shell_sidebar_new; + shell_view_class->changed = book_shell_view_changed; g_object_class_install_property ( object_class, diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index de10df9a41..a46bddbc99 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -853,8 +853,10 @@ status_message (EAddressbookView *view, const gchar *status) { EActivity *activity; + EShellView *shell_view; activity = view->priv->activity; + shell_view = e_addressbook_view_get_shell_view (view); if (status == NULL || *status == '\0') { if (activity != NULL) { @@ -866,6 +868,7 @@ status_message (EAddressbookView *view, } else if (activity == NULL) { activity = e_activity_new (status); view->priv->activity = activity; + e_shell_view_add_activity (shell_view, activity); } else e_activity_set_primary_text (activity, status); diff --git a/calendar/Makefile.am b/calendar/Makefile.am index f9a54aff06..1083f27bbb 100644 --- a/calendar/Makefile.am +++ b/calendar/Makefile.am @@ -4,7 +4,7 @@ else CONDUIT_DIR = endif -SUBDIRS = idl common importers gui $(CONDUIT_DIR) +SUBDIRS = idl common importers gui $(CONDUIT_DIR) modules error_DATA = calendar.error errordir = $(privdatadir)/errors diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 84b7bd25dc..0651f0253f 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -34,61 +34,6 @@ INCLUDES = \ $(LIBSOUP_CFLAGS) \ $(EVOLUTION_CALENDAR_CFLAGS) -module_LTLIBRARIES = \ - libevolution-calendar.la \ - libevolution-memos.la \ - libevolution-tasks.la - -libevolution_calendar_la_SOURCES = \ - calendar-config-keys.h \ - calendar-config.c \ - calendar-config.h \ - e-cal-shell-module.c \ - e-cal-shell-sidebar.c \ - e-cal-shell-sidebar.h \ - e-cal-shell-view-actions.c \ - e-cal-shell-view-actions.h \ - e-cal-shell-view-private.c \ - e-cal-shell-view-private.h \ - e-cal-shell-view.c \ - e-cal-shell-view.h \ - e-calendar-selector.c \ - e-calendar-selector.h - -libevolution_memos_la_SOURCES = \ - calendar-config-keys.h \ - calendar-config.c \ - calendar-config.h \ - e-calendar-selector.c \ - e-calendar-selector.h \ - e-memo-shell-module.c \ - e-memo-shell-sidebar.c \ - e-memo-shell-sidebar.h \ - e-memo-shell-view-actions.c \ - e-memo-shell-view-actions.h \ - e-memo-shell-view-private.c \ - e-memo-shell-view-private.h \ - e-memo-shell-view.c \ - e-memo-shell-view.h \ - e-memos.c \ - e-memos.h - -libevolution_tasks_la_SOURCES = \ - calendar-config-keys.h \ - calendar-config.c \ - calendar-config.h \ - e-calendar-selector.c \ - e-calendar-selector.h \ - e-task-shell-module.c \ - e-task-shell-sidebar.c \ - e-task-shell-sidebar.h \ - e-task-shell-view-actions.c \ - e-task-shell-view-actions.h \ - e-task-shell-view-private.c \ - e-task-shell-view-private.h \ - e-task-shell-view.c \ - e-task-shell-view.h - glade_DATA = \ e-itip-control.glade \ goto-dialog.glade @@ -99,182 +44,150 @@ etspec_DATA = \ e-cal-list-view.etspec \ e-memo-table.etspec -#libevolution_calendar_la_SOURCES = \ -# cal-search-bar.c \ -# cal-search-bar.h \ -# calendar-config.c \ -# calendar-config.h \ -# calendar-config-keys.h \ -# calendar-commands.c \ -# calendar-commands.h \ -# calendar-component.c \ -# calendar-component.h \ -# calendar-view.c \ -# calendar-view.h \ -# calendar-view-factory.c \ -# calendar-view-factory.h \ -# comp-editor-factory.c \ -# comp-editor-factory.h \ -# comp-util.c \ -# comp-util.h \ -# control-factory.c \ -# control-factory.h \ -# e-alarm-list.c \ -# e-alarm-list.h \ -# e-cal-component-preview.c \ -# e-cal-component-preview.h \ -# e-cal-component-memo-preview.c \ -# e-cal-component-memo-preview.h \ -# e-cal-config.c \ -# e-cal-config.h \ -# e-cal-event.c \ -# e-cal-event.h \ -# e-cal-menu.c \ -# e-cal-menu.h \ -# e-cal-model-calendar.h \ -# e-cal-model-calendar.c \ -# e-cal-model-calendar.h \ -# e-cal-model-tasks.c \ -# e-cal-model-tasks.h \ -# e-cal-model.c \ -# e-cal-model.h \ -# e-cal-popup.h \ -# e-cal-popup.c \ -# e-calendar-view.c \ -# e-calendar-view.h \ -# e-cal-list-view.c \ -# e-cal-list-view.h \ -# e-cal-list-view-config.c \ -# e-cal-list-view-config.h \ -# e-cal-model-memos.c \ -# e-cal-model-memos.h \ -# e-calendar-table.c \ -# e-calendar-table.h \ -# e-calendar-table-config.c \ -# e-calendar-table-config.h \ -# e-cell-date-edit-config.c \ -# e-cell-date-edit-config.h \ -# e-cell-date-edit-text.h \ -# e-cell-date-edit-text.c \ -# e-comp-editor-registry.c \ -# e-comp-editor-registry.h \ -# e-date-edit-config.c \ -# e-date-edit-config.h \ -# e-date-time-list.c \ -# e-date-time-list.h \ -# e-day-view-config.c \ -# e-day-view-config.h \ -# e-day-view-layout.c \ -# e-day-view-layout.h \ -# e-day-view-main-item.c \ -# e-day-view-main-item.h \ -# e-day-view-time-item.c \ -# e-day-view-time-item.h \ -# e-day-view-top-item.c \ -# e-day-view-top-item.h \ -# e-day-view.c \ -# e-day-view.h \ -# e-itip-control.h \ -# e-itip-control.c \ -# e-meeting-attendee.c \ -# e-meeting-attendee.h \ -# e-meeting-list-view.c \ -# e-meeting-list-view.h \ -# e-meeting-store.c \ -# e-meeting-store.h \ -# e-meeting-time-sel.c \ -# e-meeting-time-sel.h \ -# e-meeting-time-sel-item.c \ -# e-meeting-time-sel-item.h \ -# e-meeting-types.h \ -# e-meeting-utils.c \ -# e-meeting-utils.h \ -# e-memo-table.c \ -# e-memo-table.h \ -# e-memo-table-config.c \ -# e-memo-table-config.h \ -# e-memos.c \ -# e-memos.h \ -# e-mini-calendar-config.c \ -# e-mini-calendar-config.h \ -# e-select-names-editable.c \ -# e-select-names-editable.h \ -# e-select-names-renderer.c \ -# e-select-names-renderer.h \ -# e-week-view-config.c \ -# e-week-view-config.h \ -# e-week-view-event-item.c \ -# e-week-view-event-item.h \ -# e-week-view-layout.c \ -# e-week-view-layout.h \ -# e-week-view-main-item.c \ -# e-week-view-main-item.h \ -# e-week-view-titles-item.c \ -# e-week-view-titles-item.h \ -# e-week-view.c \ -# e-week-view.h \ -# e-tasks.c \ -# e-tasks.h \ -# e-timezone-entry.c \ -# e-timezone-entry.h \ -# gnome-cal.c \ -# gnome-cal.h \ -# goto.c \ -# goto.h \ -# itip-bonobo-control.c \ -# itip-bonobo-control.h \ -# itip-utils.c \ -# itip-utils.h \ -# main.c \ -# memos-component.c \ -# memos-component.h \ -# migration.c \ -# migration.h \ -# misc.c \ -# misc.h \ -# print.c \ -# print.h \ -# tag-calendar.c \ -# tag-calendar.h \ -# tasks-component.c \ -# tasks-component.h \ -# tasks-control.c \ -# tasks-control.h \ -# weekday-picker.c \ -# weekday-picker.h - -libevolution_calendar_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - $(top_builddir)/widgets/menus/libmenus.la \ - $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/calendar/common/libevolution-calendarprivate.la \ - $(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \ - $(top_builddir)/calendar/importers/libevolution-calendar-importers.la \ - $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/filter/libfilter.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la \ - $(LIBSOUP_LIBS) \ - $(CAMEL_LIBS) \ - $(EVOLUTION_CALENDAR_LIBS) - -libevolution_memos_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - $(top_builddir)/widgets/menus/libmenus.la \ - $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/calendar/common/libevolution-calendarprivate.la \ - $(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \ - $(top_builddir)/calendar/importers/libevolution-calendar-importers.la \ - $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/filter/libfilter.la \ - $(top_builddir)/e-util/libeutil.la \ - $(LIBSOUP_LIBS) \ - $(CAMEL_LIBS) \ - $(EVOLUTION_CALENDAR_LIBS) - -libevolution_tasks_la_LIBADD = \ +privsolib_LTLIBRARIES = libcal-gui.la + +# Removed from SOURCES +# cal-search-bar.c +# cal-search-bar.h +# calendar-commands.c +# calendar-commands.h +# comp-editor-factory.c +# comp-editor-factory.h +# e-calendar-view.c +# e-calendar-view.h +# e-calendar-table.c +# e-calendar-table.h +# e-memos.c +# e-memos.h +# e-tasks.c +# e-tasks.h +# gnome-cal.c +# gnome-cal.h +# main.c +# migration.c +# migration.h +# tasks-control.c +# tasks-control.h + +libcal_gui_la_SOURCES = \ + calendar-config.c \ + calendar-config.h \ + calendar-config-keys.h \ + calendar-view.c \ + calendar-view.h \ + calendar-view-factory.c \ + calendar-view-factory.h \ + comp-util.c \ + comp-util.h \ + control-factory.c \ + control-factory.h \ + e-alarm-list.c \ + e-alarm-list.h \ + e-cal-component-preview.c \ + e-cal-component-preview.h \ + e-cal-config.c \ + e-cal-config.h \ + e-cal-event.c \ + e-cal-event.h \ + e-cal-menu.c \ + e-cal-menu.h \ + e-cal-model-calendar.h \ + e-cal-model-calendar.c \ + e-cal-model-calendar.h \ + e-cal-model-tasks.c \ + e-cal-model-tasks.h \ + e-cal-model.c \ + e-cal-model.h \ + e-cal-popup.h \ + e-cal-popup.c \ + e-cal-list-view.c \ + e-cal-list-view.h \ + e-cal-list-view-config.c \ + e-cal-list-view-config.h \ + e-cal-model-memos.c \ + e-cal-model-memos.h \ + e-calendar-table-config.c \ + e-calendar-table-config.h \ + e-cell-date-edit-config.c \ + e-cell-date-edit-config.h \ + e-cell-date-edit-text.h \ + e-cell-date-edit-text.c \ + e-comp-editor-registry.c \ + e-comp-editor-registry.h \ + e-date-edit-config.c \ + e-date-edit-config.h \ + e-date-time-list.c \ + e-date-time-list.h \ + e-day-view-config.c \ + e-day-view-config.h \ + e-day-view-layout.c \ + e-day-view-layout.h \ + e-day-view-main-item.c \ + e-day-view-main-item.h \ + e-day-view-time-item.c \ + e-day-view-time-item.h \ + e-day-view-top-item.c \ + e-day-view-top-item.h \ + e-day-view.c \ + e-day-view.h \ + e-itip-control.h \ + e-itip-control.c \ + e-meeting-attendee.c \ + e-meeting-attendee.h \ + e-meeting-list-view.c \ + e-meeting-list-view.h \ + e-meeting-store.c \ + e-meeting-store.h \ + e-meeting-time-sel.c \ + e-meeting-time-sel.h \ + e-meeting-time-sel-item.c \ + e-meeting-time-sel-item.h \ + e-meeting-types.h \ + e-meeting-utils.c \ + e-meeting-utils.h \ + e-memo-table.c \ + e-memo-table.h \ + e-memo-table-config.c \ + e-memo-table-config.h \ + e-mini-calendar-config.c \ + e-mini-calendar-config.h \ + e-select-names-editable.c \ + e-select-names-editable.h \ + e-select-names-renderer.c \ + e-select-names-renderer.h \ + e-week-view-config.c \ + e-week-view-config.h \ + e-week-view-event-item.c \ + e-week-view-event-item.h \ + e-week-view-layout.c \ + e-week-view-layout.h \ + e-week-view-main-item.c \ + e-week-view-main-item.h \ + e-week-view-titles-item.c \ + e-week-view-titles-item.h \ + e-week-view.c \ + e-week-view.h \ + e-timezone-entry.c \ + e-timezone-entry.h \ + goto.c \ + goto.h \ + itip-bonobo-control.c \ + itip-bonobo-control.h \ + itip-utils.c \ + itip-utils.h \ + misc.c \ + misc.h \ + print.c \ + print.h \ + tag-calendar.c \ + tag-calendar.h \ + weekday-picker.c \ + weekday-picker.h + +# REMOVED +# $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la + +libcal_gui_la_LIBADD = \ $(WIN32_BOOTSTRAP_LIBS) \ $(top_builddir)/widgets/menus/libmenus.la \ $(top_builddir)/shell/libeshell.la \ @@ -289,9 +202,7 @@ libevolution_tasks_la_LIBADD = \ $(CAMEL_LIBS) \ $(EVOLUTION_CALENDAR_LIBS) -libevolution_calendar_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED) -libevolution_memos_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED) -libevolution_tasks_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED) +libcal_gui_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED) @INTLTOOL_SERVER_RULE@ diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 5f81c81acc..183c339c5e 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -110,9 +110,6 @@ struct _CalendarComponentPrivate { GList *notifications; }; -/* FIXME This should be gnome cal likely */ -extern ECompEditorRegistry *comp_editor_registry; - static void calcomp_vpane_realized (GtkWidget *vpane, CalendarComponentView *view) { @@ -650,60 +647,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, g_error_free(err); } -static gboolean -update_single_object (ECal *client, icalcomponent *icalcomp) -{ - char *uid; - icalcomponent *tmp_icalcomp; - - uid = (char *) icalcomponent_get_uid (icalcomp); - - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL); - - return e_cal_create_object (client, icalcomp, &uid, NULL); -} - -static gboolean -update_objects (ECal *client, icalcomponent *icalcomp) -{ - icalcomponent *subcomp; - icalcomponent_kind kind; - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) - return update_single_object (client, icalcomp); - else if (kind != ICAL_VCALENDAR_COMPONENT) - return FALSE; - - subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); - while (subcomp) { - gboolean success; - - kind = icalcomponent_isa (subcomp); - if (kind == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, subcomp); - - success = e_cal_add_timezone (client, zone, NULL); - icaltimezone_free (zone, 1); - if (!success) - return success; - } else if (kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VEVENT_COMPONENT) { - success = update_single_object (client, subcomp); - if (!success) - return success; - } - - subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); - } - - return TRUE; -} - static void config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c index 508714dbc3..cd0f49517a 100644 --- a/calendar/gui/comp-editor-factory.c +++ b/calendar/gui/comp-editor-factory.c @@ -36,10 +36,6 @@ #include "dialogs/event-editor.h" #include "dialogs/task-editor.h" -extern ECompEditorRegistry *comp_editor_registry; - - - /* A pending request */ typedef enum { diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index ee5ad096d0..430b559948 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -214,7 +214,15 @@ enum { LAST_SIGNAL }; -static guint comp_editor_signals[LAST_SIGNAL] = { 0 }; +static guint signals[LAST_SIGNAL]; +static GList *active_editors; + +static void +comp_editor_weak_notify_cb (gpointer unused, + GObject *where_the_object_was) +{ + active_editors = g_list_remove (active_editors, where_the_object_was); +} static void attach_message(CompEditor *editor, CamelMimeMessage *msg) @@ -1704,7 +1712,7 @@ comp_editor_class_init (CompEditorClass *class) NULL, G_PARAM_READWRITE)); - comp_editor_signals[OBJECT_CREATED] = + signals[OBJECT_CREATED] = g_signal_new ("object_created", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, @@ -1724,6 +1732,12 @@ comp_editor_init (CompEditor *editor) editor->priv = priv = COMP_EDITOR_GET_PRIVATE (editor); + g_object_weak_ref ( + G_OBJECT (editor), (GWeakNotify) + comp_editor_weak_notify_cb, NULL); + + active_editors = g_list_prepend (active_editors, editor); + priv->pages = NULL; priv->changed = FALSE; priv->needs_send = FALSE; @@ -2279,7 +2293,18 @@ close_dialog (CompEditor *editor) gtk_widget_destroy (GTK_WIDGET (editor)); } - +gint +comp_editor_compare (CompEditor *editor_a, + CompEditor *editor_b) +{ + const gchar *uid_a = NULL; + const gchar *uid_b = NULL; + + e_cal_component_get_uid (editor_a->priv->comp, &uid_a); + e_cal_component_get_uid (editor_b->priv->comp, &uid_b); + + return g_strcmp0 (uid_a, uid_b); +} void comp_editor_set_existing_org (CompEditor *editor, gboolean existing_org) @@ -2547,6 +2572,16 @@ comp_editor_get_managed_widget (CompEditor *editor, return widget; } +CompEditor * +comp_editor_find_instance (const gchar *uid) +{ + g_return_val_if_fail (uid != NULL, NULL); + + return g_list_find_custom ( + active_editors, uid, + (GCompareFunc) comp_editor_compare); +} + /** * comp_editor_set_needs_send: * @editor: A component editor diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h index 9289b9ced7..23a8d3acea 100644 --- a/calendar/gui/dialogs/comp-editor.h +++ b/calendar/gui/dialogs/comp-editor.h @@ -87,6 +87,8 @@ typedef enum { } CompEditorFlags; GType comp_editor_get_type (void); +gint comp_editor_compare (CompEditor *editor_a, + CompEditor *editor_b); void comp_editor_set_changed (CompEditor *editor, gboolean changed); gboolean comp_editor_get_changed (CompEditor *editor); @@ -149,6 +151,7 @@ GtkActionGroup * const gchar *group_name); GtkWidget * comp_editor_get_managed_widget (CompEditor *editor, const gchar *widget_path); +CompEditor * comp_editor_find_instance (const gchar *uid); G_END_DECLS diff --git a/calendar/gui/e-cal-component-memo-preview.c b/calendar/gui/e-cal-component-memo-preview.c deleted file mode 100644 index f4107efe84..0000000000 --- a/calendar/gui/e-cal-component-memo-preview.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-tasks.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Authors: Federico Mena Quintero - * Damon Chaplin - * Rodrigo Moya - * Nathan Owens - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "calendar-config.h" -#include "e-cal-component-memo-preview.h" -#include "e-cal-component-preview.h" -#include - -struct _ECalComponentMemoPreviewPrivate { - GtkWidget *html; - - icaltimezone *zone; -}; - -G_DEFINE_TYPE (ECalComponentMemoPreview, e_cal_component_memo_preview, GTK_TYPE_TABLE) - - -static void -on_link_clicked (GtkHTML *html, const char *url, gpointer data) -{ - GError *err = NULL; - - gnome_url_show (url, &err); - - if (err) { - g_warning ("gnome_url_show: %s", err->message); - g_error_free (err); - } -} - -static void -on_url_cb (GtkHTML *html, const char *url, gpointer data) -{ -#if 0 - char *msg; - ECalComponentMemoPreview *preview = data; - - if (url && *url) { - msg = g_strdup_printf (_("Click to open %s"), url); - e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg); - g_free (msg); - } else - e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL); -#endif -} - -/* Converts a time_t to a string, relative to the specified timezone */ -static char * -timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone) -{ - struct icaltimetype itt; - icaltimezone *zone; - struct tm tm; - char buf[256]; - - if (dt->tzid) { - /* If we can't find the zone, we'll guess its "local" */ - if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL)) - zone = NULL; - } else if (dt->value->is_utc) { - zone = icaltimezone_get_utc_timezone (); - } else { - zone = NULL; - } - - - itt = *dt->value; - if (zone) - icaltimezone_convert_time (&itt, zone, default_zone); - tm = icaltimetype_to_tm (&itt); - - e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (), - FALSE, FALSE, buf, sizeof (buf)); - - return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); -} - -static void -write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone) -{ - ECalComponentText text; - ECalComponentDateTime dt; - gchar *str; - GSList *l; - gboolean one_added = FALSE; - - g_return_if_fail (E_IS_CAL_COMPONENT (comp)); - - /* write document header */ - e_cal_component_get_summary (comp, &text); - - if (text.value) - gtk_html_stream_printf (stream, - "

%s

", - text.value); - else - gtk_html_stream_printf (stream, - "

%s

", - _("Untitled")); - - /* write icons for the categories */ - e_cal_component_get_categories_list (comp, &l); - if (l) { - GSList *node; - GString *string = g_string_new (NULL); - - - gtk_html_stream_printf(stream, "

%s: ", _("Categories")); - - for (node = l; node != NULL; node = node->next) { - const char *icon_file; - - icon_file = e_categories_get_icon_file_for ((const char *) node->data); - if (icon_file && g_file_test(icon_file, G_FILE_TEST_EXISTS)) { - gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL); - gtk_html_stream_printf (stream, "\"%s\"", - (const char *) node->data, icon_file_uri); - g_free (icon_file_uri); - one_added = TRUE; - } - else{ - if(one_added == FALSE){ - g_string_append_printf (string, "%s", (const char *) node->data); - one_added = TRUE; - } - else{ - g_string_append_printf (string, ", %s", (const char *) node->data); - } - } - } - - if (string->len > 0) - gtk_html_stream_printf(stream, "%s", string->str); - - g_string_free (string, TRUE); - - gtk_html_stream_printf(stream, "

"); - - e_cal_component_free_categories_list (l); - } - - /* Start table */ - gtk_html_stream_printf (stream, "" - ""); - - /* write start date */ - e_cal_component_get_dtstart (comp, &dt); - if (dt.value != NULL) { - str = timet_to_str_with_zone (&dt, ecal, default_zone); - gtk_html_stream_printf (stream, "", - _("Start Date:"), str); - - g_free (str); - } - e_cal_component_free_datetime (&dt); - - /* write description and URL */ - gtk_html_stream_printf (stream, ""); - - e_cal_component_get_description_list (comp, &l); - if (l) { - GSList *node; - - gtk_html_stream_printf (stream, "", _("Description:")); - - gtk_html_stream_printf (stream, ""); - - e_cal_component_free_text_list (l); - } - - /* URL */ - e_cal_component_get_url (comp, (const char **) &str); - if (str) { - gtk_html_stream_printf (stream, "", _("Web Page:")); - gtk_html_stream_printf (stream, "", str, str); - } - - gtk_html_stream_printf (stream, "
%s%s

%s"); - - for (node = l; node != NULL; node = node->next) { - char *html; - - text = * (ECalComponentText *) node->data; - html = camel_text_to_html (text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0); - - if (html) - gtk_html_stream_printf (stream, "%s", html); - - g_free (html); - } - - gtk_html_stream_printf (stream, "
%s%s
"); - - /* close document */ - gtk_html_stream_printf (stream, ""); -} - -static void -e_cal_component_memo_preview_init (ECalComponentMemoPreview *preview) -{ - ECalComponentMemoPreviewPrivate *priv; - GtkWidget *scroll; - - priv = g_new0 (ECalComponentMemoPreviewPrivate, 1); - preview->priv = priv; - - priv->html = gtk_html_new (); - gtk_html_set_default_content_type (GTK_HTML (priv->html), "charset=utf-8"); - gtk_html_load_empty (GTK_HTML (priv->html)); - - g_signal_connect (G_OBJECT (priv->html), "url_requested", - G_CALLBACK (e_cal_comp_preview_url_requested_cb), NULL); - g_signal_connect (G_OBJECT (priv->html), "link_clicked", - G_CALLBACK (on_link_clicked), preview); - g_signal_connect (G_OBJECT (priv->html), "on_url", - G_CALLBACK (on_url_cb), preview); - - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); - - gtk_container_add (GTK_CONTAINER (scroll), priv->html); - gtk_container_add (GTK_CONTAINER (preview), scroll); - gtk_widget_show_all (scroll); - - priv->zone = icaltimezone_get_utc_timezone (); -} - -static void -e_cal_component_memo_preview_destroy (GtkObject *object) -{ - ECalComponentMemoPreview *preview; - ECalComponentMemoPreviewPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (object)); - - preview = E_CAL_COMPONENT_MEMO_PREVIEW (object); - priv = preview->priv; - - if (priv) { - - g_free (priv); - preview->priv = NULL; - } - - if (GTK_OBJECT_CLASS (e_cal_component_memo_preview_parent_class)->destroy) - (* GTK_OBJECT_CLASS (e_cal_component_memo_preview_parent_class)->destroy) (object); -} - -static void -e_cal_component_memo_preview_class_init (ECalComponentMemoPreviewClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - object_class->destroy = e_cal_component_memo_preview_destroy; -} - -GtkWidget * -e_cal_component_memo_preview_new (void) -{ - ECalComponentMemoPreview *preview; - - preview = g_object_new (e_cal_component_memo_preview_get_type (), NULL); - - return GTK_WIDGET (preview); -} - -icaltimezone * -e_cal_component_memo_preview_get_default_timezone (ECalComponentMemoPreview *preview) -{ - ECalComponentMemoPreviewPrivate *priv; - - g_return_val_if_fail (preview != NULL, NULL); - g_return_val_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview), NULL); - - priv = preview->priv; - - return priv->zone; -} - -void -e_cal_component_memo_preview_set_default_timezone (ECalComponentMemoPreview *preview, icaltimezone *zone) -{ - ECalComponentMemoPreviewPrivate *priv; - - g_return_if_fail (preview != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview)); - g_return_if_fail (zone != NULL); - - priv = preview->priv; - - priv->zone = zone; -} - -void -e_cal_component_memo_preview_display (ECalComponentMemoPreview *preview, ECal *ecal, ECalComponent *comp) -{ - ECalComponentMemoPreviewPrivate *priv; - GtkHTMLStream *stream; - - g_return_if_fail (preview != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview)); - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT (comp)); - - priv = preview->priv; - - stream = gtk_html_begin (GTK_HTML (priv->html)); - write_html (stream, ecal, comp, priv->zone); - gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); -} - -void -e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview) -{ - ECalComponentMemoPreviewPrivate *priv; - - g_return_if_fail (preview != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview)); - - priv = preview->priv; - - gtk_html_load_empty (GTK_HTML (priv->html)); -} - diff --git a/calendar/gui/e-cal-component-memo-preview.h b/calendar/gui/e-cal-component-memo-preview.h deleted file mode 100644 index 144e54fe5c..0000000000 --- a/calendar/gui/e-cal-component-memo-preview.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 - * - * - * Authors: - * Federico Mena Quintero - * Damon Chaplin - * Nathan Owens - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_CAL_COMPONENT_MEMO_PREVIEW_H_ -#define _E_CAL_COMPONENT_MEMO_PREVIEW_H_ - -#include -#include - -#define E_TYPE_CAL_COMPONENT_MEMO_PREVIEW (e_cal_component_memo_preview_get_type ()) -#define E_CAL_COMPONENT_MEMO_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW, ECalComponentMemoPreview)) -#define E_CAL_COMPONENT_MEMO_PREVIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW, \ - ECalComponentMemoPreviewClass)) -#define E_IS_CAL_COMPONENT_MEMO_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW)) -#define E_IS_CAL_COMPONENT_MEMO_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW)) - -typedef struct _ECalComponentMemoPreview ECalComponentMemoPreview; -typedef struct _ECalComponentMemoPreviewClass ECalComponentMemoPreviewClass; -typedef struct _ECalComponentMemoPreviewPrivate ECalComponentMemoPreviewPrivate; - -struct _ECalComponentMemoPreview { - GtkTable table; - - /* Private data */ - ECalComponentMemoPreviewPrivate *priv; -}; - -struct _ECalComponentMemoPreviewClass { - GtkTableClass parent_class; - - /* Notification signals */ - void (* selection_changed) (ECalComponentMemoPreview *preview, int n_selected); -}; - - -GType e_cal_component_memo_preview_get_type (void); -GtkWidget *e_cal_component_memo_preview_new (void); - -icaltimezone *e_cal_component_memo_preview_get_default_timezone (ECalComponentMemoPreview *preview); -void e_cal_component_memo_preview_set_default_timezone (ECalComponentMemoPreview *preview, icaltimezone *zone); - -void e_cal_component_memo_preview_display (ECalComponentMemoPreview *preview, ECal *ecal, ECalComponent *comp); -void e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview); - -#endif /* _E_CAL_COMPONENT_MEMO_PREVIEW_H_ */ diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 0b476a4bd5..3bd6ae38d8 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -35,8 +35,8 @@ #include "e-cal-model.h" #include "itip-utils.h" #include "misc.h" -#include "e-calendar-marshal.h" #include "calendar-config.h" +#include "e-util/e-util.h" typedef struct { ECal *client; @@ -149,7 +149,7 @@ e_cal_model_class_init (ECalModelClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, time_range_changed), NULL, NULL, - e_calendar_marshal_VOID__LONG_LONG, + e_marshal_VOID__LONG_LONG, G_TYPE_NONE, 2, G_TYPE_LONG, G_TYPE_LONG); signals[ROW_APPENDED] = @@ -176,7 +176,7 @@ e_cal_model_class_init (ECalModelClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, cal_view_progress), NULL, NULL, - e_calendar_marshal_VOID__STRING_INT_INT, + e_marshal_VOID__STRING_INT_INT, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); signals[CAL_VIEW_DONE] = g_signal_new ("cal_view_done", @@ -184,7 +184,7 @@ e_cal_model_class_init (ECalModelClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, cal_view_done), NULL, NULL, - e_calendar_marshal_VOID__INT_INT, + e_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); } diff --git a/calendar/gui/e-cal-shell-module.c b/calendar/gui/e-cal-shell-module.c deleted file mode 100644 index 7df23a92f3..0000000000 --- a/calendar/gui/e-cal-shell-module.c +++ /dev/null @@ -1,399 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-module.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#define MODULE_NAME "calendar" -#define MODULE_ALIASES "" -#define MODULE_SCHEMES "calendar" -#define MODULE_SEARCHES "caltypes.xml" -#define MODULE_SORT_ORDER 400 - -#define CONTACTS_BASE_URI "contacts://" -#define WEATHER_BASE_URI "weather://" -#define WEB_BASE_URI "webcal://" -#define PERSONAL_RELATIVE_URI "system" - -/* Module Entry Point */ -void e_shell_module_init (GTypeModule *type_module); - -static void -cal_module_ensure_sources (EShellModule *shell_module) -{ - /* XXX This is basically the same algorithm across all modules. - * Maybe we could somehow integrate this into EShellModule? */ - - ESourceList *source_list; - ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; - ESourceGroup *contacts; - ESourceGroup *weather; - ESource *birthdays; - ESource *personal; - GSList *groups, *iter; - const gchar *data_dir; - gchar *base_uri; - gchar *filename; - gchar *property; - - on_this_computer = NULL; - on_the_web = NULL; - contacts = NULL; - weather = NULL; - birthdays = NULL; - personal = NULL; - - if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) { - g_warning ("Could not get calendar sources from GConf!"); - return; - } - - /* Share the source list with all calendar views. This - * is accessible via e_cal_shell_view_get_source_list(). - * Note: EShellModule takes ownership of the reference. - * - * XXX I haven't yet decided if I want to add a proper - * EShellModule API for this. The mail module would - * not use it. */ - g_object_set_data_full ( - G_OBJECT (shell_module), "source-list", - source_list, (GDestroyNotify) g_object_unref); - - data_dir = e_shell_module_get_data_dir (shell_module); - filename = g_build_filename (data_dir, "local", NULL); - base_uri = g_filename_to_uri (filename, NULL, NULL); - g_free (filename); - - groups = e_source_list_peek_groups (source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); - - /* Compare only "file://" part. if the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; - - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; - - else if (contacts == NULL && - strcmp (CONTACTS_BASE_URI, group_base_uri) == 0) - contacts = source_group; - - else if (weather == NULL && - strcmp (WEATHER_BASE_URI, group_base_uri) == 0) - weather = source_group; - } - - if (on_this_computer != NULL) { - GSList *sources; - const gchar *group_base_uri; - - sources = e_source_group_peek_sources (on_this_computer); - group_base_uri = e_source_group_peek_base_uri (on_this_computer); - - /* Make sure this group includes a "Personal" source. */ - for (iter = sources; iter != NULL; iter = iter->next) { - ESource *source = iter->data; - const gchar *relative_uri; - - relative_uri = e_source_peek_relative_uri (source); - if (relative_uri == NULL) - continue; - - if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) - continue; - - personal = source; - break; - } - - /* Make sure we have the correct base URI. This can - * change when the user's home directory changes. */ - if (strcmp (base_uri, group_base_uri) != 0) { - e_source_group_set_base_uri ( - on_this_computer, base_uri); - - /* XXX We shouldn't need this sync call here as - * set_base_uri() results in synching to GConf, - * but that happens in an idle loop and too late - * to prevent the user from seeing a "Cannot - * Open ... because of invalid URI" error. */ - e_source_list_sync (source_list, NULL); - } - - } else { - ESourceGroup *source_group; - const gchar *name; - - name = _("On This Computer"); - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - if (personal == NULL) { - ESource *source; - GSList *selected; - const gchar *name; - gchar *primary; - - name = _("Personal"); - source = e_source_new (name, PERSONAL_RELATIVE_URI); - e_source_group_add_source (on_this_computer, source, -1); - g_object_unref (source); - - primary = calendar_config_get_primary_calendar (); - selected = calendar_config_get_calendars_selected (); - - if (primary == NULL && selected == NULL) { - const gchar *uid; - - uid = e_source_peek_uid (source); - selected = g_slist_prepend (NULL, g_strdup (uid)); - - calendar_config_set_primary_calendar (uid); - calendar_config_set_calendars_selected (selected); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - g_slist_free (selected); - g_free (primary); - } - - if (on_the_web == NULL) { - ESourceGroup *source_group; - const gchar *name; - - name = _("On The Web"); - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - if (contacts != NULL) { - GSList *sources; - - sources = e_source_group_peek_sources (contacts); - - if (sources != NULL) { - GSList *trash; - - /* There is only one source under Contacts. */ - birthdays = E_SOURCE (sources->data); - sources = g_slist_next (sources); - - /* Delete any other sources in this group. - * Earlier versions allowed you to create - * additional sources under Contacts. */ - trash = g_slist_copy (sources); - while (trash != NULL) { - ESource *source = trash->data; - e_source_group_remove_source (contacts, source); - trash = g_slist_delete_link (trash, trash); - } - - } - } else { - ESourceGroup *source_group; - const gchar *name; - - name = _("Contacts"); - source_group = e_source_group_new (name, CONTACTS_BASE_URI); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - - /* This is now a borrowed reference. */ - contacts = source_group; - } - - /* XXX e_source_group_get_property() returns a newly-allocated - * string when it could just as easily return a const string. - * Unfortunately, fixing that would break the API. */ - property = e_source_group_get_property (contacts, "create_source"); - if (property == NULL) - e_source_group_set_property (contacts, "create_source", "no"); - g_free (property); - - if (birthdays == NULL) { - ESource *source; - const gchar *name; - - name = _("Birthdays & Anniversaries"); - source = e_source_new (name, "/"); - e_source_group_add_source (contacts, source, -1); - g_object_unref (source); - - /* This is now a borrowed reference. */ - birthdays = source; - } - - if (e_source_get_property (birthdays, "delete") == NULL) - e_source_set_property (birthdays, "delete", "no"); - - if (e_source_peek_color_spec (birthdays) == NULL) - e_source_set_color_spec (birthdays, "#DDBECE"); - - if (weather == NULL) { - ESourceGroup *source_group; - const gchar *name; - - name = _("Weather"); - source_group = e_source_group_new (name, WEATHER_BASE_URI); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - g_free (base_uri); -} - -static void -action_appointment_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_appointment_all_day_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_meeting_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_calendar_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static GtkActionEntry item_entries[] = { - - { "appointment-new", - "appointment-new", - N_("_Appointment"), /* XXX Need C_() here */ - "a", - N_("Create a new appointment"), - G_CALLBACK (action_appointment_new_cb) }, - - { "appointment-all-day-new", - "stock_new-24h-appointment", - N_("All Day A_ppointment"), - NULL, - N_("Create a new all-day appointment"), - G_CALLBACK (action_appointment_all_day_new_cb) }, - - { "meeting-new", - "stock_new-meeting", - N_("M_eeting"), - "e", - N_("Create a new meeting request"), - G_CALLBACK (action_meeting_new_cb) } -}; - -static GtkActionEntry source_entries[] = { - - { "calendar-new", - "x-office-calendar", - N_("Cale_ndar"), - NULL, - N_("Create a new calendar"), - G_CALLBACK (action_calendar_new_cb) } -}; - -static gboolean -cal_module_handle_uri (EShellModule *shell_module, - const gchar *uri) -{ - /* FIXME */ - return FALSE; -} - -static void -cal_module_window_created (EShellModule *shell_module, - EShellWindow *shell_window) -{ - const gchar *module_name; - - module_name = G_TYPE_MODULE (shell_module)->name; - - e_shell_window_register_new_item_actions ( - shell_window, module_name, - item_entries, G_N_ELEMENTS (item_entries)); - - e_shell_window_register_new_source_actions ( - shell_window, module_name, - source_entries, G_N_ELEMENTS (source_entries)); -} - -static EShellModuleInfo module_info = { - - MODULE_NAME, - MODULE_ALIASES, - MODULE_SCHEMES, - MODULE_SEARCHES, - MODULE_SORT_ORDER -}; - -void -e_shell_module_init (GTypeModule *type_module) -{ - EShell *shell; - EShellModule *shell_module; - - shell_module = E_SHELL_MODULE (type_module); - shell = e_shell_module_get_shell (shell_module); - - /* Register the GType for ECalShellView. */ - e_cal_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); - - cal_module_ensure_sources (shell_module); - - g_signal_connect_swapped ( - shell, "handle-uri", - G_CALLBACK (cal_module_handle_uri), shell_module); - - g_signal_connect_swapped ( - shell, "window-created", - G_CALLBACK (cal_module_window_created), shell_module); -} diff --git a/calendar/gui/e-cal-shell-sidebar.c b/calendar/gui/e-cal-shell-sidebar.c deleted file mode 100644 index 5d14f589f0..0000000000 --- a/calendar/gui/e-cal-shell-sidebar.c +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-sidebar.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-cal-shell-sidebar.h" - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#define E_CAL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarPrivate)) - -struct _ECalShellSidebarPrivate { - GtkWidget *selector; -}; - -enum { - PROP_0, - PROP_SELECTOR -}; - -static gpointer parent_class; - -static void -cal_shell_sidebar_update (EShellSidebar *shell_sidebar) -{ - EShellView *shell_view; - GnomeCalendar *calendar; - GnomeCalendarViewType view; - time_t start_time, end_time; - struct tm start_tm, end_tm; - struct icaltimetype start_tt, end_tt; - icaltimezone *timezone; - gchar buffer[512]; - gchar end_buffer[512]; - - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - calendar = e_cal_shell_view_get_calendar ( - E_CAL_SHELL_VIEW (shell_view)); - - gnome_calendar_get_visible_time_range ( - calendar, &start_time, &end_time); - timezone = gnome_calendar_get_timezone (calendar); - view = gnome_calendar_get_view (calendar); - - start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); - start_tm.tm_year = start_tt.year - 1900; - start_tm.tm_mon = start_tt.month - 1; - start_tm.tm_mday = start_tt.day; - start_tm.tm_hour = start_tt.hour; - start_tm.tm_min = start_tt.minute; - start_tm.tm_sec = start_tt.second; - start_tm.tm_isdst = -1; - start_tm.tm_wday = time_day_of_week ( - start_tt.day, start_tt.month - 1, start_tt.year); - - /* Subtract one from end_time so we don't get an extra day. */ - end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone); - end_tm.tm_year = end_tt.year - 1900; - end_tm.tm_mon = end_tt.month - 1; - end_tm.tm_mday = end_tt.day; - end_tm.tm_hour = end_tt.hour; - end_tm.tm_min = end_tt.minute; - end_tm.tm_sec = end_tt.second; - end_tm.tm_isdst = -1; - end_tm.tm_wday = time_day_of_week ( - end_tt.day, end_tt.month - 1, end_tt.year); - - switch (view) { - case GNOME_CAL_DAY_VIEW: - case GNOME_CAL_WORK_WEEK_VIEW: - case GNOME_CAL_WEEK_VIEW: - if (start_tm.tm_year == end_tm.tm_year && - start_tm.tm_mon == end_tm.tm_mon && - start_tm.tm_mday == end_tm.tm_mday) { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%A %d %b %Y"), &start_tm); - } else if (start_tm.tm_year == end_tm.tm_year) { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%a %d %b"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%a %d %b %Y"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - - case GNOME_CAL_MONTH_VIEW: - case GNOME_CAL_LIST_VIEW: - if (start_tm.tm_year == end_tm.tm_year) { - if (start_tm.tm_mon == end_tm.tm_mon) { - e_utf8_strftime ( - buffer, - sizeof (buffer), - "%d", &start_tm); - e_utf8_strftime ( - end_buffer, - sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime ( - buffer, - sizeof (buffer), - _("%d %b"), &start_tm); - e_utf8_strftime ( - end_buffer, - sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - } else { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%d %b %Y"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - - default: - g_return_if_reached (); - } - - e_shell_sidebar_set_secondary_text (shell_sidebar, buffer); -} - -static void -cal_shell_sidebar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SELECTOR: - g_value_set_object ( - value, e_cal_shell_sidebar_get_selector ( - E_CAL_SHELL_SIDEBAR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -cal_shell_sidebar_dispose (GObject *object) -{ - ECalShellSidebarPrivate *priv; - - priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); - - if (priv->selector != NULL) { - g_object_unref (priv->selector); - priv->selector = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_shell_sidebar_constructed (GObject *object) -{ - ECalShellSidebarPrivate *priv; - EShellView *shell_view; - EShellSidebar *shell_sidebar; - ECalShellView *cal_shell_view; - ESourceList *source_list; - GtkContainer *container; - GtkWidget *widget; - GnomeCalendar *calendar; - - priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); - - shell_sidebar = E_SHELL_SIDEBAR (object); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - cal_shell_view = E_CAL_SHELL_VIEW (shell_view); - source_list = e_cal_shell_view_get_source_list (cal_shell_view); - - container = GTK_CONTAINER (shell_sidebar); - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_container_add (container, widget); - gtk_widget_show (widget); - - container = GTK_CONTAINER (widget); - - widget = e_calendar_selector_new (source_list); - e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); - gtk_container_add (container, widget); - priv->selector = g_object_ref (widget); - gtk_widget_show (widget); - - /* Setup signal handlers. */ - - calendar = e_cal_shell_view_get_calendar (cal_shell_view); - - g_signal_connect_swapped ( - calendar, "dates-shown-changed", - G_CALLBACK (cal_shell_sidebar_update), - shell_sidebar); - - cal_shell_sidebar_update (shell_sidebar); -} - -static void -cal_shell_sidebar_class_init (ECalShellSidebarClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (ECalShellSidebarPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = cal_shell_sidebar_get_property; - object_class->dispose = cal_shell_sidebar_dispose; - object_class->constructed = cal_shell_sidebar_constructed; - - g_object_class_install_property ( - object_class, - PROP_SELECTOR, - g_param_spec_object ( - "selector", - _("Source Selector Widget"), - _("This widget displays groups of calendars"), - E_TYPE_SOURCE_SELECTOR, - G_PARAM_READABLE)); -} - -static void -cal_shell_sidebar_init (ECalShellSidebar *cal_shell_sidebar) -{ - cal_shell_sidebar->priv = - E_CAL_SHELL_SIDEBAR_GET_PRIVATE (cal_shell_sidebar); - - /* Postpone widget construction until we have a shell view. */ -} - -GType -e_cal_shell_sidebar_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (ECalShellSidebarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_shell_sidebar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (ECalShellSidebar), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_shell_sidebar_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_SIDEBAR, "ECalShellSidebar", - &type_info, 0); - } - - return type; -} - -GtkWidget * -e_cal_shell_sidebar_new (EShellView *shell_view) -{ - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return g_object_new ( - E_TYPE_CAL_SHELL_SIDEBAR, - "shell-view", shell_view, NULL); -} - -GtkWidget * -e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar) -{ - g_return_val_if_fail ( - E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL); - - return cal_shell_sidebar->priv->selector; -} diff --git a/calendar/gui/e-cal-shell-sidebar.h b/calendar/gui/e-cal-shell-sidebar.h deleted file mode 100644 index 89eaee7613..0000000000 --- a/calendar/gui/e-cal-shell-sidebar.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-sidebar.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_CAL_SHELL_SIDEBAR_H -#define E_CAL_SHELL_SIDEBAR_H - -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_CAL_SHELL_SIDEBAR \ - (e_cal_shell_sidebar_get_type ()) -#define E_CAL_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebar)) -#define E_CAL_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) -#define E_IS_CAL_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_CAL_SHELL_SIDEBAR)) -#define E_IS_CAL_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_CAL_SHELL_SIDEBAR)) -#define E_CAL_SHELL_SIDEBAR_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) - -G_BEGIN_DECLS - -typedef struct _ECalShellSidebar ECalShellSidebar; -typedef struct _ECalShellSidebarClass ECalShellSidebarClass; -typedef struct _ECalShellSidebarPrivate ECalShellSidebarPrivate; - -struct _ECalShellSidebar { - EShellSidebar parent; - ECalShellSidebarPrivate *priv; -}; - -struct _ECalShellSidebarClass { - EShellSidebarClass parent_class; -}; - -GType e_cal_shell_sidebar_get_type (void); -GtkWidget * e_cal_shell_sidebar_new (EShellView *shell_view); -GtkWidget * e_cal_shell_sidebar_get_selector(ECalShellSidebar *cal_shell_sidebar); - -G_END_DECLS - -#endif /* E_CAL_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-cal-shell-view-actions.c b/calendar/gui/e-cal-shell-view-actions.c deleted file mode 100644 index e4f9d351c5..0000000000 --- a/calendar/gui/e-cal-shell-view-actions.c +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view-actions.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-cal-shell-view-private.h" - -static void -action_calendar_copy_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_delete_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_go_back_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_go_forward_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_go_today_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_jump_to_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_new_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_print_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_print_preview_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_properties_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_purge_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_calendar_view_cb (GtkRadioAction *action, - GtkRadioAction *current, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_clipboard_copy_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_clipboard_cut_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_clipboard_paste_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_delete_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_delete_occurrence_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_delete_occurrence_all_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static void -action_event_open_cb (GtkAction *action, - ECalShellView *cal_shell_view) -{ -} - -static GtkActionEntry calendar_entries[] = { - - { "calendar-copy", - GTK_STOCK_COPY, - N_("_Copy..."), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_calendar_copy_cb) }, - - { "calendar-delete", - GTK_STOCK_DELETE, - NULL, - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_calendar_delete_cb) }, - - { "calendar-go-back", - GTK_STOCK_GO_BACK, - N_("Previous"), - NULL, - N_("Go Back"), - G_CALLBACK (action_calendar_go_back_cb) }, - - { "calendar-go-forward", - GTK_STOCK_GO_FORWARD, - N_("Next"), - NULL, - N_("Go Forward"), - G_CALLBACK (action_calendar_go_forward_cb) }, - - { "calendar-go-today", - "go-today", - N_("Select _Today"), - "t", - N_("Select today"), - G_CALLBACK (action_calendar_go_today_cb) }, - - { "calendar-jump-to", - GTK_STOCK_JUMP_TO, - N_("Select _Date"), - "g", - N_("Select a specific date"), - G_CALLBACK (action_calendar_jump_to_cb) }, - - { "calendar-new", - "x-office-calendar", - N_("_New Calendar"), - NULL, - N_("Create a new calendar"), - G_CALLBACK (action_calendar_new_cb) }, - - { "calendar-print", - GTK_STOCK_PRINT, - NULL, - NULL, - N_("Print this calendar"), - G_CALLBACK (action_calendar_print_cb) }, - - { "calendar-print-preview", - GTK_STOCK_PRINT_PREVIEW, - NULL, - NULL, - N_("Preview the calendar to be printed"), - G_CALLBACK (action_calendar_print_preview_cb) }, - - { "calendar-properties", - GTK_STOCK_PROPERTIES, - NULL, - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_calendar_properties_cb) }, - - { "calendar-purge", - NULL, - N_("Purg_e"), - "e", - N_("Purge old appointments and meetings"), - G_CALLBACK (action_calendar_purge_cb) }, - - { "event-clipboard-copy", - GTK_STOCK_COPY, - NULL, - NULL, - N_("Copy the selection"), - G_CALLBACK (action_event_clipboard_copy_cb) }, - - { "event-clipboard-cut", - GTK_STOCK_CUT, - NULL, - NULL, - N_("Cut the selection"), - G_CALLBACK (action_event_clipboard_cut_cb) }, - - { "event-clipboard-paste", - GTK_STOCK_PASTE, - NULL, - NULL, - N_("Paste the clipboard"), - G_CALLBACK (action_event_clipboard_paste_cb) }, - - { "event-delete", - GTK_STOCK_DELETE, - NULL, - NULL, - N_("Delete the appointment"), - G_CALLBACK (action_event_delete_cb) }, - - { "event-delete-occurrence", - GTK_STOCK_DELETE, - N_("Delete This _Occurrence"), - NULL, - N_("Delete this occurrence"), - G_CALLBACK (action_event_delete_occurrence_cb) }, - - { "event-delete-occurrence-all", - GTK_STOCK_DELETE, - N_("Delete _All Occurrences"), - NULL, - N_("Delete all occurrences"), - G_CALLBACK (action_event_delete_occurrence_all_cb) }, - - { "event-open", - NULL, - N_("_Open Appointment"), - "o", - N_("View the current appointment"), - G_CALLBACK (action_event_open_cb) } -}; - -static GtkRadioActionEntry calendar_view_entries[] = { - - { "calendar-view-day", - "view-calendar-day", - N_("Day"), - NULL, - N_("Show one day"), - GNOME_CAL_DAY_VIEW }, - - { "calendar-view-list", - "view-calendar-list", - N_("List"), - NULL, - N_("Show as list"), - GNOME_CAL_LIST_VIEW }, - - { "calendar-view-month", - "view-calendar-month", - N_("Month"), - NULL, - N_("Show one month"), - GNOME_CAL_MONTH_VIEW }, - - { "calendar-view-week", - "view-calendar-week", - N_("Week"), - NULL, - N_("Show one week"), - GNOME_CAL_WEEK_VIEW }, - - { "calendar-view-workweek", - "view-calendar-workweek", - N_("Work Week"), - NULL, - N_("Show one work week"), - GNOME_CAL_WORK_WEEK_VIEW } -}; - -void -e_cal_shell_view_actions_init (ECalShellView *cal_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - GtkActionGroup *action_group; - GtkUIManager *manager; - const gchar *domain; - - shell_view = E_SHELL_VIEW (cal_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); - domain = GETTEXT_PACKAGE; - - e_load_ui_definition (manager, "evolution-calendars.ui"); - - action_group = cal_shell_view->priv->calendar_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_action_group_add_actions ( - action_group, calendar_entries, - G_N_ELEMENTS (calendar_entries), cal_shell_view); - gtk_action_group_add_radio_actions ( - action_group, calendar_view_entries, - G_N_ELEMENTS (calendar_view_entries), GNOME_CAL_DAY_VIEW, - G_CALLBACK (action_calendar_view_cb), cal_shell_view); - gtk_ui_manager_insert_action_group (manager, action_group, 0); -} diff --git a/calendar/gui/e-cal-shell-view-actions.h b/calendar/gui/e-cal-shell-view-actions.h deleted file mode 100644 index 9d935e4263..0000000000 --- a/calendar/gui/e-cal-shell-view-actions.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view-actions.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_CAL_SHELL_VIEW_ACTIONS_H -#define E_CAL_SHELL_VIEW_ACTIONS_H - -#include - -/* Action Groups */ -#define E_SHELL_WINDOW_ACTION_GROUP_CALS(window) \ - E_SHELL_WINDOW_ACTION_GROUP ((window), "cals") - -#endif /* E_CAL_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/gui/e-cal-shell-view-private.c b/calendar/gui/e-cal-shell-view-private.c deleted file mode 100644 index 2e7619cadc..0000000000 --- a/calendar/gui/e-cal-shell-view-private.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view-private.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-cal-shell-view-private.h" - -void -e_cal_shell_view_private_init (ECalShellView *cal_shell_view, - EShellViewClass *shell_view_class) -{ - ECalShellViewPrivate *priv = cal_shell_view->priv; - ESourceList *source_list; - GObject *object; - - object = G_OBJECT (shell_view_class->type_module); - source_list = g_object_get_data (object, "source-list"); - g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - - priv->source_list = g_object_ref (source_list); - priv->calendar_actions = gtk_action_group_new ("calendars"); -} - -void -e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) -{ - ECalShellViewPrivate *priv = cal_shell_view->priv; -} - -void -e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) -{ - ECalShellViewPrivate *priv = cal_shell_view->priv; - - DISPOSE (priv->source_list); - - DISPOSE (priv->calendar_actions); -} - -void -e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view) -{ - ECalShellViewPrivate *priv = cal_shell_view->priv; -} diff --git a/calendar/gui/e-cal-shell-view-private.h b/calendar/gui/e-cal-shell-view-private.h deleted file mode 100644 index 553dc5246c..0000000000 --- a/calendar/gui/e-cal-shell-view-private.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view-private.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_CAL_SHELL_VIEW_PRIVATE_H -#define E_CAL_SHELL_VIEW_PRIVATE_H - -#include "e-cal-shell-view.h" - -#include - -#include -#include - -#include -#include -#include - -#define E_CAL_SHELL_VIEW_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellViewPrivate)) - -/* Shorthand, requires a variable named "shell_window". */ -#define ACTION(name) \ - (E_SHELL_WINDOW_ACTION_##name (shell_window)) -#define ACTION_GROUP(name) \ - (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) - -/* For use in dispose() methods. */ -#define DISPOSE(obj) \ - G_STMT_START { \ - if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ - } G_STMT_END - -G_BEGIN_DECLS - -struct _ECalShellViewPrivate { - - /*** Module Data ***/ - - ESourceList *source_list; - - /*** UI Management ***/ - - GtkActionGroup *calendar_actions; -}; - -void e_cal_shell_view_private_init - (ECalShellView *cal_shell_view, - EShellViewClass *shell_view_class); -void e_cal_shell_view_private_constructed - (ECalShellView *cal_shell_view); -void e_cal_shell_view_private_dispose - (ECalShellView *cal_shell_view); -void e_cal_shell_view_private_finalize - (ECalShellView *cal_shell_view); - -/* Private Utilities */ - -void e_cal_shell_view_actions_init - (ECalShellView *cal_shell_view); - -G_END_DECLS - -#endif /* E_CAL_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/gui/e-cal-shell-view.c b/calendar/gui/e-cal-shell-view.c deleted file mode 100644 index 4ca7df1848..0000000000 --- a/calendar/gui/e-cal-shell-view.c +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-cal-shell-view-private.h" - -enum { - PROP_0, - PROP_SOURCE_LIST -}; - -GType e_cal_shell_view_type = 0; -static gpointer parent_class; - -static void -cal_shell_view_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SOURCE_LIST: - g_value_set_object ( - value, e_cal_shell_view_get_source_list ( - E_CAL_SHELL_VIEW (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -cal_shell_view_dispose (GObject *object) -{ - e_cal_shell_view_private_dispose (E_CAL_SHELL_VIEW (object)); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_shell_view_finalize (GObject *object) -{ - e_cal_shell_view_private_finalize (E_CAL_SHELL_VIEW (object)); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -cal_shell_view_constructed (GObject *object) -{ - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); - - e_cal_shell_view_private_constructed (E_CAL_SHELL_VIEW (object)); -} - -static void -cal_shell_view_changed (EShellView *shell_view) -{ - ECalShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; - - priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view); - - action_group = priv->calendar_actions; - visible = e_shell_view_is_selected (shell_view); - gtk_action_group_set_visible (action_group, visible); -} - -static void -cal_shell_view_class_init (ECalShellView *class, - GTypeModule *type_module) -{ - GObjectClass *object_class; - EShellViewClass *shell_view_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (ECalShellViewPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = cal_shell_view_get_property; - object_class->dispose = cal_shell_view_dispose; - object_class->finalize = cal_shell_view_finalize; - object_class->constructed = cal_shell_view_constructed; - - shell_view_class = E_SHELL_VIEW_CLASS (class); - shell_view_class->label = N_("Cals"); - shell_view_class->icon_name = "evolution-cals"; - shell_view_class->type_module = type_module; - shell_view_class->changed = cal_shell_view_changed; - shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; - - g_object_class_install_property ( - object_class, - PROP_SOURCE_LIST, - g_param_spec_object ( - "source-list", - _("Source List"), - _("The registry of calendars"), - E_TYPE_SOURCE_LIST, - G_PARAM_READABLE)); -} - -static void -cal_shell_view_init (ECalShellView *cal_shell_view, - EShellViewClass *shell_view_class) -{ - cal_shell_view->priv = - E_CAL_SHELL_VIEW_GET_PRIVATE (cal_shell_view); - - e_cal_shell_view_private_init (cal_shell_view, shell_view_class); -} - -GType -e_cal_shell_view_get_type (GTypeModule *type_module) -{ - if (e_cal_shell_view_type == 0) { - const GTypeInfo type_info = { - sizeof (ECalShellViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_shell_view_class_init, - (GClassFinalizeFunc) NULL, - type_module, - sizeof (ECalShellView), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_shell_view_init, - NULL /* value_table */ - }; - - e_cal_shell_view_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_VIEW, - "ECalShellView", &type_info, 0); - } - - return e_cal_shell_view_type; -} - -GnomeCalendar * -e_cal_shell_view_get_calendar (ECalShellView *cal_shell_view) -{ - g_return_val_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view), NULL); - - /* FIXME */ - return NULL; -} - -ESourceList * -e_cal_shell_view_get_source_list (ECalShellView *cal_shell_view) -{ - g_return_val_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view), NULL); - - return cal_shell_view->priv->source_list; -} diff --git a/calendar/gui/e-cal-shell-view.h b/calendar/gui/e-cal-shell-view.h deleted file mode 100644 index 404446f22b..0000000000 --- a/calendar/gui/e-cal-shell-view.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-cal-shell-view.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_CAL_SHELL_VIEW_H -#define E_CAL_SHELL_VIEW_H - -#include -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_CAL_SHELL_VIEW \ - (e_cal_shell_view_type) -#define E_CAL_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellView)) -#define E_CAL_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_CAL_SHELL_VIEW, ECalShellViewClass)) -#define E_IS_CAL_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_CAL_SHELL_VIEW)) -#define E_IS_CAL_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_CAL_SHELL_VIEW)) -#define E_CAL_SHELL_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellViewClass)) - -G_BEGIN_DECLS - -extern GType e_cal_shell_view_type; - -typedef struct _ECalShellView ECalShellView; -typedef struct _ECalShellViewClass ECalShellViewClass; -typedef struct _ECalShellViewPrivate ECalShellViewPrivate; - -struct _ECalShellView { - EShellView parent; - ECalShellViewPrivate *priv; -}; - -struct _ECalShellViewClass { - EShellViewClass parent_class; -}; - -GType e_cal_shell_view_get_type - (GTypeModule *type_module); -GnomeCalendar * e_cal_shell_view_get_calendar - (ECalShellView *cal_shell_view); -ESourceList * e_cal_shell_view_get_source_list - (ECalShellView *cal_shell_view); - -G_END_DECLS - -#endif /* E_CAL_SHELL_VIEW_H */ diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index b23ef1b32a..b9ebdf7f70 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -42,6 +42,67 @@ static GtkTargetEntry drag_types[] = { static gpointer parent_class; +static gboolean +calendar_selector_update_single_object (ECal *client, + icalcomponent *icalcomp) +{ + gchar *uid; + icalcomponent *tmp_icalcomp; + + uid = (gchar *) icalcomponent_get_uid (icalcomp); + + if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) + return e_cal_modify_object ( + client, icalcomp, CALOBJ_MOD_ALL, NULL); + + return e_cal_create_object (client, icalcomp, &uid, NULL); +} + +static gboolean +calendar_selector_update_objects (ECal *client, + icalcomponent *icalcomp) +{ + icalcomponent *subcomp; + icalcomponent_kind kind; + + kind = icalcomponent_isa (icalcomp); + if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) + return calendar_selector_update_single_object ( + client, icalcomp); + else if (kind != ICAL_VCALENDAR_COMPONENT) + return FALSE; + + subcomp = icalcomponent_get_first_component ( + icalcomp, ICAL_ANY_COMPONENT); + while (subcomp != NULL) { + gboolean success; + + kind = icalcomponent_isa (subcomp); + if (kind == ICAL_VTIMEZONE_COMPONENT) { + icaltimezone *zone; + + zone = icaltimezone_new (); + icaltimezone_set_component (zone, subcomp); + + success = e_cal_add_timezone (client, zone, NULL); + icaltimezone_free (zone, 1); + if (!success) + return FALSE; + } else if (kind == ICAL_VTODO_COMPONENT || + kind == ICAL_VEVENT_COMPONENT) { + success = calendar_selector_update_single_object ( + client, subcomp); + if (!success) + return FALSE; + } + + subcomp = icalcomponent_get_next_component ( + icalcomp, ICAL_ANY_COMPONENT); + } + + return TRUE; +} + static void calendar_selector_drag_leave (GtkWidget *widget, GdkDragContext *context, @@ -208,7 +269,7 @@ calendar_selector_drag_data_received (GtkWidget *widget, if (client != NULL) { if (e_cal_open (client, TRUE, NULL)) { success = TRUE; - update_objects (client, icalcomp); + calendar_selector_update_objects (client, icalcomp); } g_object_unref (client); diff --git a/calendar/gui/e-calendar-table-config.c b/calendar/gui/e-calendar-table-config.c index f8a7af9c14..6e43886dbd 100644 --- a/calendar/gui/e-calendar-table-config.c +++ b/calendar/gui/e-calendar-table-config.c @@ -24,221 +24,245 @@ #include "e-cell-date-edit-config.h" #include "e-calendar-table-config.h" +#define E_CALENDAR_TABLE_CONFIG_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigPrivate)) + struct _ECalendarTableConfigPrivate { ECalendarTable *table; - ECellDateEditConfig *cell_config; - GList *notifications; }; -/* Property IDs */ -enum props { +enum { PROP_0, PROP_TABLE }; -G_DEFINE_TYPE (ECalendarTableConfig, e_calendar_table_config, G_TYPE_OBJECT) +static gpointer parent_class; static void -e_calendar_table_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +calendar_table_config_set_timezone (ECalendarTable *table) { - ECalendarTableConfig *table_config; - - table_config = E_CALENDAR_TABLE_CONFIG (object); + ECalModel *model; + icaltimezone *zone; - switch (property_id) { - case PROP_TABLE: - e_calendar_table_config_set_table (table_config, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } + zone = calendar_config_get_icaltimezone (); + model = e_calendar_table_get_model (table); + if (model != NULL) + e_cal_model_set_timezone (model, zone); } static void -e_calendar_table_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +calendar_table_config_timezone_changed_cb (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer data) { - ECalendarTableConfig *table_config; - - table_config = E_CALENDAR_TABLE_CONFIG (object); + ECalendarTableConfig *table_config = data; - switch (property_id) { - case PROP_TABLE: - g_value_set_object (value, e_calendar_table_config_get_table (table_config)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } + calendar_table_config_set_timezone (table_config->priv->table); } static void -e_calendar_table_config_dispose (GObject *object) +calendar_table_config_set_twentyfour_hour (ECalendarTable *table) { - ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object); + ECalModel *model; + gboolean use_24_hour; - e_calendar_table_config_set_table (table_config, NULL); + use_24_hour = calendar_config_get_24_hour_format (); - if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose) - G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose (object); + model = e_calendar_table_get_model (table); + if (model != NULL) + e_cal_model_set_use_24_hour_format (model, use_24_hour); } static void -e_calendar_table_config_finalize (GObject *object) +calendar_table_config_twentyfour_hour_changed_cb (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer data) { - ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object); - ECalendarTableConfigPrivate *priv; - - priv = table_config->priv; - - g_free (priv); + ECalendarTableConfig *table_config = data; - if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize) - G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize (object); + calendar_table_config_set_twentyfour_hour (table_config->priv->table); } static void -e_calendar_table_config_class_init (ECalendarTableConfigClass *klass) +calendar_table_config_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GParamSpec *spec; - - /* Method override */ - gobject_class->set_property = e_calendar_table_config_set_property; - gobject_class->get_property = e_calendar_table_config_get_property; - gobject_class->dispose = e_calendar_table_config_dispose; - gobject_class->finalize = e_calendar_table_config_finalize; - - spec = g_param_spec_object ("table", NULL, NULL, e_calendar_table_get_type (), - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT); - g_object_class_install_property (gobject_class, PROP_TABLE, spec); + switch (property_id) { + case PROP_TABLE: + e_calendar_table_config_set_table ( + E_CALENDAR_TABLE_CONFIG (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -e_calendar_table_config_init (ECalendarTableConfig *table_config) +calendar_table_config_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - table_config->priv = g_new0 (ECalendarTableConfigPrivate, 1); + switch (property_id) { + case PROP_TABLE: + g_value_set_object ( + value, e_calendar_table_config_get_table ( + E_CALENDAR_TABLE_CONFIG (object))); + return; + } + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } -ECalendarTableConfig * -e_calendar_table_config_new (ECalendarTable *table) +static void +calendar_table_config_dispose (GObject *object) { - ECalendarTableConfig *table_config; + ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object); - table_config = g_object_new (e_calendar_table_config_get_type (), "table", table, NULL); + e_calendar_table_config_set_table (table_config, NULL); - return table_config; + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } -ECalendarTable * -e_calendar_table_config_get_table (ECalendarTableConfig *table_config) +static void +calendar_table_config_class_init (ECalendarTableConfigClass *class) { - ECalendarTableConfigPrivate *priv; - - g_return_val_if_fail (table_config != NULL, NULL); - g_return_val_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config), NULL); - - priv = table_config->priv; - - return priv->table; + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalendarTableConfigPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = calendar_table_config_set_property; + object_class->get_property = calendar_table_config_get_property; + object_class->dispose = calendar_table_config_dispose; + + g_object_class_install_property ( + object_class, + PROP_TABLE, + g_param_spec_object ( + "table", + NULL, + NULL, + E_TYPE_CALENDAR_TABLE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); } static void -set_timezone (ECalendarTable *table) +calendar_table_config_init (ECalendarTableConfig *table_config) { - ECalModel *model; - icaltimezone *zone; - - zone = calendar_config_get_icaltimezone (); - model = e_calendar_table_get_model (table); - if (model) - e_cal_model_set_timezone (model, zone); + table_config->priv = + E_CALENDAR_TABLE_CONFIG_GET_PRIVATE (table_config); } -static void -timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +GType +e_calendar_table_config_get_type (void) { - ECalendarTableConfig *table_config = data; - ECalendarTableConfigPrivate *priv; - - priv = table_config->priv; + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalendarTableConfigClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) calendar_table_config_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalendarTableConfig), + 0, /* n_preallocs */ + (GInstanceInitFunc) calendar_table_config_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + G_TYPE_OBJECT, "ECalendarTableConfig", &type_info, 0); + } - set_timezone (priv->table); + return type; } -static void -set_twentyfour_hour (ECalendarTable *table) +ECalendarTableConfig * +e_calendar_table_config_new (ECalendarTable *table) { - ECalModel *model; - gboolean use_24_hour; + g_return_val_if_fail (E_IS_CALENDAR_TABLE (table), NULL); - use_24_hour = calendar_config_get_24_hour_format (); - - model = e_calendar_table_get_model (table); - if (model) - e_cal_model_set_use_24_hour_format (model, use_24_hour); + return g_object_new ( + E_TYPE_CALENDAR_TABLE_CONFIG, + "table", table, NULL); } -static void -twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +ECalendarTable * +e_calendar_table_config_get_table (ECalendarTableConfig *table_config) { - ECalendarTableConfig *table_config = data; - ECalendarTableConfigPrivate *priv; - - priv = table_config->priv; + g_return_val_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config), NULL); - set_twentyfour_hour (priv->table); + return table_config->priv->table; } void -e_calendar_table_config_set_table (ECalendarTableConfig *table_config, ECalendarTable *table) +e_calendar_table_config_set_table (ECalendarTableConfig *table_config, + ECalendarTable *table) { ECalendarTableConfigPrivate *priv; - guint not; - GList *l; + guint notification; + GList *list, *iter; - g_return_if_fail (table_config != NULL); g_return_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config)); priv = table_config->priv; - if (priv->table) { - g_object_unref (priv->table); - priv->table = NULL; + if (table_config->priv->table) { + g_object_unref (table_config->priv->table); + table_config->priv->table = NULL; } - if (priv->cell_config) { - g_object_unref (priv->cell_config); - priv->cell_config = NULL; + if (table_config->priv->cell_config) { + g_object_unref (table_config->priv->cell_config); + table_config->priv->cell_config = NULL; } - for (l = priv->notifications; l; l = l->next) - calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); - - g_list_free (priv->notifications); - priv->notifications = NULL; + list = table_config->priv->notifications; + for (iter = list; iter != NULL; iter = iter->next) { + notification = GPOINTER_TO_UINT (iter->data); + calendar_config_remove_notification (notification); + } + g_list_free (list); + table_config->priv->notifications = NULL; - /* If the new view is NULL, return right now */ - if (!table) + if (table == NULL) return; - priv->table = g_object_ref (table); + table_config->priv->table = g_object_ref (table); /* Time zone */ - set_timezone (table); + calendar_table_config_set_timezone (table); - not = calendar_config_add_notification_timezone (timezone_changed_cb, table_config); - priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + notification = calendar_config_add_notification_timezone ( + calendar_table_config_timezone_changed_cb, table_config); + table_config->priv->notifications = g_list_prepend ( + table_config->priv->notifications, + GUINT_TO_POINTER (notification)); /* 24 Hour format */ - set_twentyfour_hour (table); + calendar_table_config_set_twentyfour_hour (table); - not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, table_config); - priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + notification = calendar_config_add_notification_24_hour_format ( + calendar_table_config_twentyfour_hour_changed_cb, table_config); + table_config->priv->notifications = g_list_prepend ( + table_config->priv->notifications, + GUINT_TO_POINTER (notification)); /* Date cell */ - priv->cell_config = e_cell_date_edit_config_new (table->dates_cell); + table_config->priv->cell_config = + e_cell_date_edit_config_new (table->dates_cell); } diff --git a/calendar/gui/e-calendar-table-config.h b/calendar/gui/e-calendar-table-config.h index 12cbc3e326..8f2284ab40 100644 --- a/calendar/gui/e-calendar-table-config.h +++ b/calendar/gui/e-calendar-table-config.h @@ -21,24 +21,38 @@ * */ -#ifndef _E_CALENDAR_TABLE_CONFIG_H_ -#define _E_CALENDAR_TABLE_CONFIG_H_ +#ifndef E_CALENDAR_TABLE_CONFIG_H +#define E_CALENDAR_TABLE_CONFIG_H #include "e-calendar-table.h" -G_BEGIN_DECLS +/* Standard GObject macros */ +#define E_TYPE_CALENDAR_TABLE_CONFIG \ + (e_calendar_table_config_get_type ()) +#define E_CALENDAR_TABLE_CONFIG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfig)) +#define E_CALENDAR_TABLE_CONFIG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigClass)) +#define E_IS_CALENDAR_TABLE_CONFIG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CALENDAR_TABLE_CONFIG)) +#define E_IS_CALENDAR_TABLE_CONFIG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CALENDAR_TABLE_CONFIG)) +#define E_CALENDAR_TABLE_CONFIG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigClass)) -#define E_CALENDAR_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_table_config_get_type (), ECalendarTableConfig) -#define E_CALENDAR_TABLE_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_table_config_get_type (), ECalendarTableConfigClass) -#define E_IS_CALENDAR_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_table_config_get_type ()) +G_BEGIN_DECLS -typedef struct _ECalendarTableConfig ECalendarTableConfig; -typedef struct _ECalendarTableConfigClass ECalendarTableConfigClass; +typedef struct _ECalendarTableConfig ECalendarTableConfig; +typedef struct _ECalendarTableConfigClass ECalendarTableConfigClass; typedef struct _ECalendarTableConfigPrivate ECalendarTableConfigPrivate; struct _ECalendarTableConfig { GObject parent; - ECalendarTableConfigPrivate *priv; }; @@ -46,11 +60,15 @@ struct _ECalendarTableConfigClass { GObjectClass parent_class; }; -GType e_calendar_table_config_get_type (void); -ECalendarTableConfig *e_calendar_table_config_new (ECalendarTable *table); -ECalendarTable *e_calendar_table_config_get_table (ECalendarTableConfig *view_config); -void e_calendar_table_config_set_table (ECalendarTableConfig *view_config, ECalendarTable *table); +GType e_calendar_table_config_get_type(void); +ECalendarTableConfig * + e_calendar_table_config_new (ECalendarTable *table); +ECalendarTable *e_calendar_table_config_get_table + (ECalendarTableConfig *table_config); +void e_calendar_table_config_set_table + (ECalendarTableConfig *table_config, + ECalendarTable *table); G_END_DECLS -#endif +#endif /* E_CALENDAR_TABLE_CONFIG_H */ diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 9e74ea2c26..ed254d0680 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -65,6 +65,16 @@ #include "e-tasks.h" #include "misc.h" +#define E_CALENDAR_TABLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTablePrivate)) + +struct _ECalendarTablePrivate { + gpointer shell_view; /* weak pointer */ + + EActivity *activity; +}; + enum TargetType{ TARGET_TYPE_VCALENDAR }; @@ -76,12 +86,6 @@ static GtkTargetEntry target_types[] = { static guint n_target_types = G_N_ELEMENTS (target_types); -extern ECompEditorRegistry *comp_editor_registry; - -static void e_calendar_table_class_init (ECalendarTableClass *class); -static void e_calendar_table_init (ECalendarTable *cal_table); -static void e_calendar_table_destroy (GtkObject *object); - static void e_calendar_table_on_double_click (ETable *table, gint row, gint col, @@ -118,7 +122,8 @@ enum { LAST_SIGNAL }; -static guint signals[LAST_SIGNAL] = { 0 }; +static gpointer parent_class; +static guint signals[LAST_SIGNAL]; /* The icons to represent the task. */ #define E_CALENDAR_MODEL_NUM_ICONS 4 @@ -129,30 +134,395 @@ static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { NULL }; static GdkAtom clipboard_atom = GDK_NONE; -G_DEFINE_TYPE (ECalendarTable, e_calendar_table, GTK_TYPE_TABLE) +static void +calendar_table_emit_user_created (ECalendarTable *cal_table) +{ + g_signal_emit (cal_table, signals[USER_CREATED], 0); +} + +static void +calendar_table_set_shell_view (ECalendarTable *cal_table, + EShellView *shell_view) +{ + g_return_if_fail (cal_table->priv->shell_view == NULL); + + cal_table->priv->shell_view = shell_view; + + g_object_add_weak_pointer ( + G_OBJECT (shell_view), + &cal_table->priv->shell_view); +} + +static void +calendar_table_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + calendar_table_set_shell_view ( + E_CALENDAR_TABLE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_table_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, e_calendar_table_get_shell_view ( + E_CALENDAR_TABLE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} static void -e_calendar_table_class_init (ECalendarTableClass *class) +calendar_table_dispose (GObject *object) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (object); + + if (cal_table->model != NULL) { + g_object_unref (cal_table->model); + cal_table->model = NULL; + } + + if (cal_table->priv->activity != NULL) { + /* XXX Activity is not cancellable. */ + e_activity_complete (cal_table->priv->activity); + g_object_unref (cal_table->priv->activity); + cal_table->priv->activity = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +calendar_table_class_init (ECalendarTableClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalendarTablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->dispose = calendar_table_dispose; + + signals[USER_CREATED] = + g_signal_new ("user_created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ECalendarTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); +} + +static void +calendar_table_init (ECalendarTable *cal_table) +{ + GtkWidget *table; + ETable *e_table; + ECell *cell, *popup_cell; + ETableExtras *extras; + gint i; + GdkPixbuf *pixbuf; + GList *strings; + AtkObject *a11y; + char *etspecfile; + + cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table); + + /* Create the model */ + + cal_table->model = (ECalModel *) e_cal_model_tasks_new (); + g_signal_connect_swapped ( + cal_table->model, "row_appended", + G_CALLBACK (calendar_table_emit_user_created), cal_table); + + /* Create the header columns */ + + extras = e_table_extras_new (); + + /* + * Normal string fields. + */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + e_table_extras_add_cell (extras, "calstring", cell); + + + /* + * Date fields. + */ + cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + popup_cell = e_cell_date_edit_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + e_table_extras_add_cell (extras, "dateedit", popup_cell); + cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); + + e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), + e_calendar_table_get_current_time, + cal_table, NULL); + + + /* + * Combo fields. + */ + + /* Classification field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Public")); + strings = g_list_append (strings, (char*) _("Private")); + strings = g_list_append (strings, (char*) _("Confidential")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "classification", popup_cell); + + /* Priority field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("High")); + strings = g_list_append (strings, (char*) _("Normal")); + strings = g_list_append (strings, (char*) _("Low")); + strings = g_list_append (strings, (char*) _("Undefined")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "priority", popup_cell); + + /* Percent field. */ + cell = e_cell_percent_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("0%")); + strings = g_list_append (strings, (char*) _("10%")); + strings = g_list_append (strings, (char*) _("20%")); + strings = g_list_append (strings, (char*) _("30%")); + strings = g_list_append (strings, (char*) _("40%")); + strings = g_list_append (strings, (char*) _("50%")); + strings = g_list_append (strings, (char*) _("60%")); + strings = g_list_append (strings, (char*) _("70%")); + strings = g_list_append (strings, (char*) _("80%")); + strings = g_list_append (strings, (char*) _("90%")); + strings = g_list_append (strings, (char*) _("100%")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "percent", popup_cell); + + /* Transparency field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Free")); + strings = g_list_append (strings, (char*) _("Busy")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "transparency", popup_cell); + + /* Status field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Not Started")); + strings = g_list_append (strings, (char*) _("In Progress")); + strings = g_list_append (strings, (char*) _("Completed")); + strings = g_list_append (strings, (char*) _("Canceled")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "calstatus", popup_cell); + + e_table_extras_add_compare (extras, "date-compare", + date_compare_cb); + e_table_extras_add_compare (extras, "percent-compare", + percent_compare_cb); + e_table_extras_add_compare (extras, "priority-compare", + priority_compare_cb); + e_table_extras_add_compare (extras, "status-compare", + status_compare_cb); + + /* Create pixmaps */ + + if (!icon_pixbufs[0]) + for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { + icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + } + + cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs); + e_table_extras_add_cell(extras, "icon", cell); + e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + + pixbuf = e_icon_factory_get_icon ("stock_check-filled", E_ICON_SIZE_LIST); + e_table_extras_add_pixbuf(extras, "complete", pixbuf); + g_object_unref(pixbuf); + + /* Create the table */ + + etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, + "e-calendar-table.etspec", + NULL); + table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model), + extras, + etspecfile, + NULL); + g_free (etspecfile); + + /* FIXME: this causes a message from GLib about 'extras' having only a floating + reference */ + /* g_object_unref (extras); */ + + cal_table->etable = table; + gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (table); + + + e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); + g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table); + g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table); + g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table); + g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table); + g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table); + gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE); + + a11y = gtk_widget_get_accessible ((GtkWidget *)e_table); + if (a11y) + atk_object_set_name (a11y, _("Tasks")); +} + +GType +e_calendar_table_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalendarTableClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) calendar_table_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalendarTable), + 0, /* n_preallocs */ + (GInstanceInitFunc) calendar_table_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_TABLE, "ECalendarTable", &type_info, 0); + } + + return type; +} + +/** + * e_calendar_table_new: + * @shell_view: an #EShellView + * + * Returns a new #ECalendarTable. + * + * Returns: a new #ECalendarTable + **/ +GtkWidget * +e_calendar_table_new (EShellView *shell_view) { - GtkObjectClass *object_class; + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - object_class = (GtkObjectClass *) class; - - /* Method override */ - object_class->destroy = e_calendar_table_destroy; + return g_object_new ( + E_TYPE_CALENDAR_TABLE, + "shell-view", shell_view, NULL); +} - signals[USER_CREATED] = - g_signal_new ("user_created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalendarTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); +EShellView * +e_calendar_table_get_shell_view (ECalendarTable *cal_table) +{ + g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - /* clipboard atom */ - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); + return cal_table->priv->shell_view; } static gint @@ -256,12 +626,6 @@ status_compare_cb (gconstpointer a, gconstpointer b) return 0; } -static void -row_appended_cb (ECalModel *model, ECalendarTable *cal_table) -{ - g_signal_emit (cal_table, signals[USER_CREATED], 0); -} - static void get_time_as_text (struct icaltimetype *tt, icaltimezone *f_zone, icaltimezone *t_zone, char *buff, int buff_len) { @@ -321,403 +685,148 @@ query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk if (!comp || !comp->icalcomp) return FALSE; - new_comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) { - g_object_unref (new_comp); - return FALSE; - } - - box = gtk_vbox_new (FALSE, 0); - - str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text); - if (!(str && *str)) { - if (free_text) - g_free ((char *)str); - free_text = FALSE; - str = _("* No Summary *"); - } - - l = gtk_label_new (NULL); - tmp = g_markup_printf_escaped ("%s", str); - gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); - gtk_label_set_markup (GTK_LABEL (l), tmp); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - w = gtk_event_box_new (); - - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); - g_free (tmp); - - if (free_text) - g_free ((char *)str); - free_text = FALSE; - - w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); - - l = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); - w = l; - - e_cal_component_get_organizer (new_comp, &organizer); - if (organizer.cn) { - char *ptr ; - ptr = strchr( organizer.value, ':'); - - if (ptr) { - ptr++; - /* To Translators: It will display "Organiser: NameOfTheUser " */ - tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); - } else { - /* With SunOne accounts, there may be no ':' in organiser.value */ - tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); - } - - l = gtk_label_new (tmp); - gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - g_free (tmp); - } - - e_cal_component_get_dtstart (new_comp, &dtstart); - e_cal_component_get_due (new_comp, &dtdue); - - default_zone = e_cal_model_get_timezone (cal_table->model); - - if (dtstart.tzid) { - zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); - if (!zone) - e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL); - if (!zone) - zone = default_zone; - } else { - zone = NULL; - } - - tmp2 = g_string_new (""); - - if (dtstart.value) { - get_time_as_text (dtstart.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - g_string_append (tmp2, _("Start: ")); - g_string_append (tmp2, buff); - } - } - - if (dtdue.value) { - get_time_as_text (dtdue.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - if (tmp2->len) - g_string_append (tmp2, "; "); - - g_string_append (tmp2, _("Due: ")); - g_string_append (tmp2, buff); - } - } - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - e_cal_component_free_datetime (&dtstart); - e_cal_component_free_datetime (&dtdue); - - tmp2 = g_string_new (""); - e_cal_component_get_description_list (new_comp, &desc); - for (len = 0, p = desc; p != NULL; p = p->next) { - ECalComponentText *text = p->data; - - if (text->value != NULL) { - len += strlen (text->value); - g_string_append (tmp2, text->value); - if (len > 1024) { - g_string_set_size (tmp2, 1020); - g_string_append (tmp2, "..."); - break; - } - } - } - e_cal_component_free_text_list (desc); - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - gtk_widget_show_all (box); - gtk_tooltip_set_custom (tooltip, box); - - g_object_unref (new_comp); - - return TRUE; -} - -static void -e_calendar_table_init (ECalendarTable *cal_table) -{ - GtkWidget *table; - ETable *e_table; - ECell *cell, *popup_cell; - ETableExtras *extras; - gint i; - GdkPixbuf *pixbuf; - GList *strings; - AtkObject *a11y; - char *etspecfile; - - /* Create the model */ - - cal_table->model = (ECalModel *) e_cal_model_tasks_new (); - g_signal_connect (cal_table->model, "row_appended", G_CALLBACK (row_appended_cb), cal_table); - - cal_table->user_created_cal = NULL; - - /* Create the header columns */ - - extras = e_table_extras_new(); - - /* - * Normal string fields. - */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); - - e_table_extras_add_cell (extras, "calstring", cell); - - - /* - * Date fields. - */ - cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); - - popup_cell = e_cell_date_edit_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - e_table_extras_add_cell (extras, "dateedit", popup_cell); - cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); - - e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), - e_calendar_table_get_current_time, - cal_table, NULL); - - - /* - * Combo fields. - */ - - /* Classification field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); - - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - - strings = NULL; - strings = g_list_append (strings, (char*) _("Public")); - strings = g_list_append (strings, (char*) _("Private")); - strings = g_list_append (strings, (char*) _("Confidential")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); - - e_table_extras_add_cell (extras, "classification", popup_cell); - - /* Priority field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); - - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - - strings = NULL; - strings = g_list_append (strings, (char*) _("High")); - strings = g_list_append (strings, (char*) _("Normal")); - strings = g_list_append (strings, (char*) _("Low")); - strings = g_list_append (strings, (char*) _("Undefined")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + new_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) { + g_object_unref (new_comp); + return FALSE; + } - e_table_extras_add_cell (extras, "priority", popup_cell); + box = gtk_vbox_new (FALSE, 0); - /* Percent field. */ - cell = e_cell_percent_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); + str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text); + if (!(str && *str)) { + if (free_text) + g_free ((char *)str); + free_text = FALSE; + str = _("* No Summary *"); + } - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + l = gtk_label_new (NULL); + tmp = g_markup_printf_escaped ("%s", str); + gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); + gtk_label_set_markup (GTK_LABEL (l), tmp); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + w = gtk_event_box_new (); - strings = NULL; - strings = g_list_append (strings, (char*) _("0%")); - strings = g_list_append (strings, (char*) _("10%")); - strings = g_list_append (strings, (char*) _("20%")); - strings = g_list_append (strings, (char*) _("30%")); - strings = g_list_append (strings, (char*) _("40%")); - strings = g_list_append (strings, (char*) _("50%")); - strings = g_list_append (strings, (char*) _("60%")); - strings = g_list_append (strings, (char*) _("70%")); - strings = g_list_append (strings, (char*) _("80%")); - strings = g_list_append (strings, (char*) _("90%")); - strings = g_list_append (strings, (char*) _("100%")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); + gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); + g_free (tmp); - e_table_extras_add_cell (extras, "percent", popup_cell); + if (free_text) + g_free ((char *)str); + free_text = FALSE; - /* Transparency field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); + w = gtk_event_box_new (); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + l = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); + w = l; - strings = NULL; - strings = g_list_append (strings, (char*) _("Free")); - strings = g_list_append (strings, (char*) _("Busy")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + e_cal_component_get_organizer (new_comp, &organizer); + if (organizer.cn) { + char *ptr ; + ptr = strchr( organizer.value, ':'); - e_table_extras_add_cell (extras, "transparency", popup_cell); + if (ptr) { + ptr++; + /* To Translators: It will display "Organiser: NameOfTheUser " */ + tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); + } else { + /* With SunOne accounts, there may be no ':' in organiser.value */ + tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); + } - /* Status field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); + l = gtk_label_new (tmp); + gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + g_free (tmp); + } - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + e_cal_component_get_dtstart (new_comp, &dtstart); + e_cal_component_get_due (new_comp, &dtdue); - strings = NULL; - strings = g_list_append (strings, (char*) _("Not Started")); - strings = g_list_append (strings, (char*) _("In Progress")); - strings = g_list_append (strings, (char*) _("Completed")); - strings = g_list_append (strings, (char*) _("Canceled")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + default_zone = e_cal_model_get_timezone (cal_table->model); - e_table_extras_add_cell (extras, "calstatus", popup_cell); + if (dtstart.tzid) { + zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); + if (!zone) + e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL); + if (!zone) + zone = default_zone; + } else { + zone = NULL; + } - e_table_extras_add_compare (extras, "date-compare", - date_compare_cb); - e_table_extras_add_compare (extras, "percent-compare", - percent_compare_cb); - e_table_extras_add_compare (extras, "priority-compare", - priority_compare_cb); - e_table_extras_add_compare (extras, "status-compare", - status_compare_cb); + tmp2 = g_string_new (""); - /* Create pixmaps */ + if (dtstart.value) { + get_time_as_text (dtstart.value, zone, default_zone, buff, 1000); - if (!icon_pixbufs[0]) - for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + if (buff [0]) { + g_string_append (tmp2, _("Start: ")); + g_string_append (tmp2, buff); } + } - cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs); - e_table_extras_add_cell(extras, "icon", cell); - e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + if (dtdue.value) { + get_time_as_text (dtdue.value, zone, default_zone, buff, 1000); - pixbuf = e_icon_factory_get_icon ("stock_check-filled", E_ICON_SIZE_LIST); - e_table_extras_add_pixbuf(extras, "complete", pixbuf); - g_object_unref(pixbuf); + if (buff [0]) { + if (tmp2->len) + g_string_append (tmp2, "; "); - /* Create the table */ + g_string_append (tmp2, _("Due: ")); + g_string_append (tmp2, buff); + } + } - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-calendar-table.etspec", - NULL); - table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model), - extras, - etspecfile, - NULL); - g_free (etspecfile); + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + } - /* FIXME: this causes a message from GLib about 'extras' having only a floating - reference */ - /* g_object_unref (extras); */ + g_string_free (tmp2, TRUE); - cal_table->etable = table; - gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); + e_cal_component_free_datetime (&dtstart); + e_cal_component_free_datetime (&dtdue); + tmp2 = g_string_new (""); + e_cal_component_get_description_list (new_comp, &desc); + for (len = 0, p = desc; p != NULL; p = p->next) { + ECalComponentText *text = p->data; - e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); - g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table); - g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table); - g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table); - g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table); - g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table); - gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE); + if (text->value != NULL) { + len += strlen (text->value); + g_string_append (tmp2, text->value); + if (len > 1024) { + g_string_set_size (tmp2, 1020); + g_string_append (tmp2, "..."); + break; + } + } + } + e_cal_component_free_text_list (desc); - a11y = gtk_widget_get_accessible ((GtkWidget *)e_table); - if (a11y) - atk_object_set_name (a11y, _("Tasks")); -} + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + } + g_string_free (tmp2, TRUE); -/** - * e_calendar_table_new: - * @Returns: a new #ECalendarTable. - * - * Creates a new #ECalendarTable. - **/ -GtkWidget * -e_calendar_table_new (void) -{ - GtkWidget *cal_table; + gtk_widget_show_all (box); + gtk_tooltip_set_custom (tooltip, box); - cal_table = GTK_WIDGET (g_object_new (e_calendar_table_get_type (), NULL)); + g_object_unref (new_comp); - return cal_table; + return TRUE; } @@ -739,21 +848,6 @@ e_calendar_table_get_model (ECalendarTable *cal_table) } -static void -e_calendar_table_destroy (GtkObject *object) -{ - ECalendarTable *cal_table; - - cal_table = E_CALENDAR_TABLE (object); - - if (cal_table->model) { - g_object_unref (cal_table->model); - cal_table->model = NULL; - } - - GTK_OBJECT_CLASS (e_calendar_table_parent_class)->destroy (object); -} - /** * e_calendar_table_get_table: * @cal_table: A calendar table. @@ -1836,20 +1930,35 @@ static char *test[] = { #endif void -e_calendar_table_set_activity_handler (ECalendarTable *cal_table, EActivityHandler *activity_handler) +e_calendar_table_set_status_message (ECalendarTable *cal_table, + const gchar *message, + gdouble percent) { - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - - cal_table->activity_handler = activity_handler; -} + EActivity *activity; + EShellView *shell_view; -void -e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *message, int percent) -{ g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - if (!cal_table->activity_handler) - return; + activity = cal_table->priv->activity; + shell_view = e_calendar_table_get_shell_view (cal_table); + + if (message == NULL || *message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + cal_table->priv->activity = NULL; + } + + } else if (activity == NULL) { + activity = e_activity_new (message); + cal_able->priv->activity = activity; + e_activity_set_percent (activity, percent); + e_shell_view_add_activity (shell_view, activity); + + } else { + e_activity_set_percent (activity, percent); + e_activity_set_primary_text (activity, message); + } if (!message || !*message) { if (cal_table->activity_id != 0) { diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index 04b2f9fa4a..6647572e89 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -23,29 +23,43 @@ #ifndef _E_CALENDAR_TABLE_H_ #define _E_CALENDAR_TABLE_H_ -#include +#include #include #include #include "e-cal-model.h" -G_BEGIN_DECLS - /* * ECalendarTable - displays the iCalendar objects in a table (an ETable). * Used for calendar events and tasks. */ -#define E_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_table_get_type (), ECalendarTable) -#define E_CALENDAR_TABLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_table_get_type (), ECalendarTableClass) -#define E_IS_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_table_get_type ()) - +/* Standard GObject macros */ +#define E_TYPE_CALENDAR_TABLE \ + (e_calendar_table_get_type ()) +#define E_CALENDAR_TABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTable)) +#define E_CALENDAR_TABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CALENDAR_TABLE, ECalendarTableClass)) +#define E_IS_CALENDAR_TABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CALENDAR_TABLE)) +#define E_IS_CALENDAR_TABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CALENDAR_TABLE)) +#define E_CALENDAR_TABLE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTableClass)) -typedef struct _ECalendarTable ECalendarTable; -typedef struct _ECalendarTableClass ECalendarTableClass; +G_BEGIN_DECLS +typedef struct _ECalendarTable ECalendarTable; +typedef struct _ECalendarTableClass ECalendarTableClass; +typedef struct _ECalendarTablePrivate ECalendarTablePrivate; struct _ECalendarTable { - GtkTable table; + GtkTable parent; /* The model that we use */ ECalModel *model; @@ -58,14 +72,9 @@ struct _ECalendarTable { /* Fields used for cut/copy/paste */ icalcomponent *tmp_vcal; -#if 0 /* KILL-BONOBO */ - /* Activity ID for the EActivityHandler (i.e. the status bar). */ - EActivityHandler *activity_handler; - guint activity_id; -#endif - - /* We should know which calendar has been used to create object, so store it here - before emitting "user_created" signal and make it NULL just after the emit. */ + /* We should know which calendar has been used to create object, + * so store it here before emitting "user_created" signal and make + * it NULL just after the emit. */ ECal *user_created_cal; }; @@ -77,42 +86,48 @@ struct _ECalendarTableClass { }; -GType e_calendar_table_get_type (void); -GtkWidget* e_calendar_table_new (void); - -ECalModel *e_calendar_table_get_model (ECalendarTable *cal_table); - -ETable *e_calendar_table_get_table (ECalendarTable *cal_table); - -void e_calendar_table_open_selected (ECalendarTable *cal_table); -void e_calendar_table_complete_selected (ECalendarTable *cal_table); -void e_calendar_table_delete_selected (ECalendarTable *cal_table); - -GSList *e_calendar_table_get_selected (ECalendarTable *cal_table); +GType e_calendar_table_get_type (void); +GtkWidget * e_calendar_table_new (void); +ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table); +ETable * e_calendar_table_get_table (ECalendarTable *cal_table); +EShellView * e_calendar_table_get_shell_view (ECalendarTable *cal_table); +void e_calendar_table_open_selected (ECalendarTable *cal_table); +void e_calendar_table_complete_selected + (ECalendarTable *cal_table); +void e_calendar_table_delete_selected(ECalendarTable *cal_table); +GSList * e_calendar_table_get_selected (ECalendarTable *cal_table); /* Clipboard related functions */ -void e_calendar_table_cut_clipboard (ECalendarTable *cal_table); -void e_calendar_table_copy_clipboard (ECalendarTable *cal_table); -void e_calendar_table_paste_clipboard (ECalendarTable *cal_table); +void e_calendar_table_cut_clipboard (ECalendarTable *cal_table); +void e_calendar_table_copy_clipboard (ECalendarTable *cal_table); +void e_calendar_table_paste_clipboard(ECalendarTable *cal_table); /* These load and save the state of the table (headers shown etc.) to/from the given file. */ -void e_calendar_table_load_state (ECalendarTable *cal_table, - gchar *filename); -void e_calendar_table_save_state (ECalendarTable *cal_table, - gchar *filename); - -void e_calendar_table_set_status_message (ECalendarTable *cal_table, - const gchar *message, - int percent); -void e_calendar_table_open_task (ECalendarTable *cal_table, - ECal *client, - icalcomponent *icalcomp, - gboolean assign); -ECalModelComponent * e_calendar_table_get_selected_comp (ECalendarTable *cal_table); -void e_calendar_table_hide_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed); - -void e_calendar_table_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed); +void e_calendar_table_load_state (ECalendarTable *cal_table, + gchar *filename); +void e_calendar_table_save_state (ECalendarTable *cal_table, + gchar *filename); + +void e_calendar_table_set_status_message + (ECalendarTable *cal_table, + const gchar *message, + gdouble percent); +void e_calendar_table_open_task (ECalendarTable *cal_table, + ECal *client, + icalcomponent *icalcomp, + gboolean assign); +ECalModelComponent * + e_calendar_table_get_selected_comp + (ECalendarTable *cal_table); +void e_calendar_table_hide_completed_tasks + (ECalendarTable *table, + GList *clients_list, + gboolean config_changed); +void e_calendar_table_process_completed_tasks + (ECalendarTable *table, + GList *clients_list, + gboolean config_changed); G_END_DECLS diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index c8be57c49d..b1c34bf8d4 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -35,7 +35,7 @@ #include #include #include -#include "e-calendar-marshal.h" +#include #include #include @@ -82,7 +82,6 @@ static void e_calendar_view_destroy (GtkObject *object); static void open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, guint32 flags); static GdkAtom clipboard_atom = GDK_NONE; -extern ECompEditorRegistry *comp_editor_registry; /* Property IDs */ enum props { @@ -194,7 +193,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalendarViewClass, timezone_changed), NULL, NULL, - e_calendar_marshal_VOID__POINTER_POINTER, + e_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); e_calendar_view_signals[EVENT_CHANGED] = diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c index a311d8da42..019b2642ff 100644 --- a/calendar/gui/e-meeting-time-sel.c +++ b/calendar/gui/e-meeting-time-sel.c @@ -46,7 +46,6 @@ #include #include -#include "calendar-component.h" #include "calendar-config.h" #include "e-meeting-utils.h" #include "e-meeting-list-view.h" diff --git a/calendar/gui/e-memo-preview.c b/calendar/gui/e-memo-preview.c new file mode 100644 index 0000000000..f5b725c02f --- /dev/null +++ b/calendar/gui/e-memo-preview.c @@ -0,0 +1,356 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-tasks.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Federico Mena Quintero + * Damon Chaplin + * Rodrigo Moya + * Nathan Owens + */ + +#include "e-memo-preview.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include "calendar-config.h" +#include "e-cal-component-preview.h" +#include + +#define E_MEMO_PREVIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewPrivate)) + +struct _EMemoPreviewPrivate { + icaltimezone *zone; +}; + +static gpointer parent_class; + +static void +memo_preview_link_clicked (GtkHTML *html, + const gchar *url) +{ + GdkScreen *screen; + GError *error = NULL; + + screen = gtk_widget_get_screen (GTK_WIDGET (html)); + gtk_show_uri (screen, url, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } +} + +static void +memo_preview_on_url (GtkHTML *html, + const gchar *url) +{ +#if 0 + char *msg; + EMemoPreview *preview = data; + + if (url && *url) { + msg = g_strdup_printf (_("Click to open %s"), url); + e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg); + g_free (msg); + } else + e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL); +#endif +} + +/* Converts a time_t to a string, relative to the specified timezone */ +static char * +timet_to_str_with_zone (ECalComponentDateTime *dt, + ECal *ecal, + icaltimezone *default_zone) +{ + struct icaltimetype itt; + icaltimezone *zone; + struct tm tm; + char buf[256]; + + if (dt->tzid) { + /* If we can't find the zone, we'll guess its "local" */ + if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL)) + zone = NULL; + } else if (dt->value->is_utc) { + zone = icaltimezone_get_utc_timezone (); + } else { + zone = NULL; + } + + + itt = *dt->value; + if (zone) + icaltimezone_convert_time (&itt, zone, default_zone); + tm = icaltimetype_to_tm (&itt); + + e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buf, sizeof (buf)); + + return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); +} + +static void +memo_preview_write_html (GtkHTMLStream *stream, + ECal *ecal, + ECalComponent *comp, + icaltimezone *default_zone) +{ + ECalComponentText text; + ECalComponentDateTime dt; + gchar *str; + GSList *l; + gboolean one_added = FALSE; + + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); + + /* write document header */ + e_cal_component_get_summary (comp, &text); + + if (text.value) + gtk_html_stream_printf (stream, + "

%s

", + text.value); + else + gtk_html_stream_printf (stream, + "

%s

", + _("Untitled")); + + /* write icons for the categories */ + e_cal_component_get_categories_list (comp, &l); + if (l) { + GSList *node; + GString *string = g_string_new (NULL); + + + gtk_html_stream_printf(stream, "

%s: ", _("Categories")); + + for (node = l; node != NULL; node = node->next) { + const char *icon_file; + + icon_file = e_categories_get_icon_file_for ((const char *) node->data); + if (icon_file && g_file_test(icon_file, G_FILE_TEST_EXISTS)) { + gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL); + gtk_html_stream_printf (stream, "\"%s\"", + (const char *) node->data, icon_file_uri); + g_free (icon_file_uri); + one_added = TRUE; + } + else{ + if(one_added == FALSE){ + g_string_append_printf (string, "%s", (const char *) node->data); + one_added = TRUE; + } + else{ + g_string_append_printf (string, ", %s", (const char *) node->data); + } + } + } + + if (string->len > 0) + gtk_html_stream_printf(stream, "%s", string->str); + + g_string_free (string, TRUE); + + gtk_html_stream_printf(stream, "

"); + + e_cal_component_free_categories_list (l); + } + + /* Start table */ + gtk_html_stream_printf (stream, "
" + ""); + + /* write start date */ + e_cal_component_get_dtstart (comp, &dt); + if (dt.value != NULL) { + str = timet_to_str_with_zone (&dt, ecal, default_zone); + gtk_html_stream_printf (stream, "", + _("Start Date:"), str); + + g_free (str); + } + e_cal_component_free_datetime (&dt); + + /* write description and URL */ + gtk_html_stream_printf (stream, ""); + + e_cal_component_get_description_list (comp, &l); + if (l) { + GSList *node; + + gtk_html_stream_printf (stream, "", _("Description:")); + + gtk_html_stream_printf (stream, ""); + + e_cal_component_free_text_list (l); + } + + /* URL */ + e_cal_component_get_url (comp, (const char **) &str); + if (str) { + gtk_html_stream_printf (stream, "", _("Web Page:")); + gtk_html_stream_printf (stream, "", str, str); + } + + gtk_html_stream_printf (stream, "
%s%s

%s"); + + for (node = l; node != NULL; node = node->next) { + char *html; + + text = * (ECalComponentText *) node->data; + html = camel_text_to_html (text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0); + + if (html) + gtk_html_stream_printf (stream, "%s", html); + + g_free (html); + } + + gtk_html_stream_printf (stream, "
%s%s
"); + + /* close document */ + gtk_html_stream_printf (stream, ""); +} + +static void +memo_preview_finalize (GObject *object) +{ + EMemoPreviewPrivate *priv; + + priv = E_MEMO_PREVIEW_GET_PRIVATE (object); + + /* XXX Nothing to do? */ + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +memo_preview_class_init (EMemoPreviewClass *class) +{ + GObjectClass *object_class; + GtkHTMLClass *gtkhtml_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoPreviewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->finalize = memo_preview_finalize; + + gtkhtml_class = GTK_HTML_CLASS (class); + gtkhtml_class->link_clicked = memo_preview_link_clicked; + gtkhtml_class->on_url = memo_preview_on_url; +} + +static void +memo_preview_init (EMemoPreview *preview) +{ + EMemoPreviewPrivate *priv; + GtkHTML *html; + + preview->priv = E_MEMO_PREVIEW_GET_PRIVATE (preview); + + html = GTK_HTML (preview); + gtk_html_set_default_content_type (html, "charset=utf-8"); + gtk_html_load_empty (html); + + priv->zone = icaltimezone_get_utc_timezone (); +} + +GType +e_memo_preview_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMemoPreviewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_preview_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMemoPreview), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_preview_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_HTML, "EMemoPreview", &type_info, 0); + } + + return type; +} + +GtkWidget * +e_memo_preview_new (void) +{ + return g_object_new (E_TYPE_MEMO_PREVIEW, NULL); +} + +icaltimezone * +e_memo_preview_get_default_timezone (EMemoPreview *preview) +{ + g_return_val_if_fail (E_IS_MEMO_PREVIEW (preview), NULL); + + return preview->priv->zone; +} + +void +e_memo_preview_set_default_timezone (EMemoPreview *preview, + icaltimezone *zone) +{ + g_return_if_fail (E_IS_MEMO_PREVIEW (preview)); + g_return_if_fail (zone != NULL); + + preview->priv->zone = zone; +} + +void +e_memo_preview_display (EMemoPreview *preview, + ECal *ecal, + ECalComponent *comp) +{ + GtkHTMLStream *stream; + + g_return_if_fail (E_IS_MEMO_PREVIEW (preview)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); + + stream = gtk_html_begin (GTK_HTML (preview)); + memo_preview_write_html (stream, ecal, comp, preview->priv->zone); + gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); +} + +void +e_memo_preview_clear (EMemoPreview *preview) +{ + g_return_if_fail (E_IS_MEMO_PREVIEW (preview)); + + gtk_html_load_empty (GTK_HTML (preview)); +} + diff --git a/calendar/gui/e-memo-preview.h b/calendar/gui/e-memo-preview.h new file mode 100644 index 0000000000..50d509e705 --- /dev/null +++ b/calendar/gui/e-memo-preview.h @@ -0,0 +1,84 @@ +/* + * 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 + * + * + * Authors: + * Federico Mena Quintero + * Damon Chaplin + * Nathan Owens + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MEMO_PREVIEW_H +#define E_MEMO_PREVIEW_H + +#include +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MEMO_PREVIEW \ + (e_memo_preview_get_type ()) +#define E_MEMO_PREVIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreview)) +#define E_MEMO_PREVIEW_CLASS(cls) \ + (G_TYPE_CHECK_INSTANCE_CAST_CLASS \ + ((cls), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass)) +#define E_IS_MEMO_PREVIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_PREVIEW)) +#define E_IS_MEMO_PREVIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_PREVIEW)) +#define E_MEMO_PREVIEW_GET_CLASS \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass)) + +G_BEGIN_DECLS + +typedef struct _EMemoPreview EMemoPreview; +typedef struct _EMemoPreviewClass EMemoPreviewClass; +typedef struct _EMemoPreviewPrivate EMemoPreviewPrivate; + +struct _EMemoPreview { + GtkHTML parent; + EMemoPreviewPrivate *priv; +}; + +struct _EMemoPreviewClass { + GtkHTMLClass parent_class; + + /* Notification signals */ + void (*selection_changed) (EMemoPreview *preview, int n_selected); +}; + + +GType e_memo_preview_get_type (void); +GtkWidget * e_memo_preview_new (void); +icaltimezone * e_memo_preview_get_default_timezone + (EMemoPreview *preview); +void e_memo_preview_set_default_timezone + (EMemoPreview *preview, + icaltimezone *zone); +void e_memo_preview_display (EMemoPreview *preview, + ECal *ecal, + ECalComponent *comp); +void e_memo_preview_clear (EMemoPreview *preview); + +G_END_DECLS + +#endif /* E_MEMO_PREVIEW_H */ diff --git a/calendar/gui/e-memo-shell-module.c b/calendar/gui/e-memo-shell-module.c deleted file mode 100644 index 05781d478f..0000000000 --- a/calendar/gui/e-memo-shell-module.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-module.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#define MODULE_NAME "memos" -#define MODULE_ALIASES "" -#define MODULE_SCHEMES "memo" -#define MODULE_SEARCHES "memotypes.xml" -#define MODULE_SORT_ORDER 500 - -#define WEB_BASE_URI "webcal://" -#define PERSONAL_RELATIVE_URI "system" - -/* Module Entry Point */ -void e_shell_module_init (GTypeModule *type_module); - -static void -memo_module_ensure_sources (EShellModule *shell_module) -{ - /* XXX This is basically the same algorithm across all modules. - * Maybe we could somehow integrate this into EShellModule? */ - - ESourceList *source_list; - ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; - ESource *personal; - GSList *groups, *iter; - const gchar *data_dir; - gchar *base_uri; - gchar *filename; - - on_this_computer = NULL; - on_the_web = NULL; - personal = NULL; - - if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { - g_warning ("Could not get memo sources from GConf!"); - return; - } - - /* Share the source list with all memo views. This is - * accessible via e_memo_shell_view_get_source_list(). - * Note: EShellModule takes ownership of the reference. - * - * XXX I haven't yet decided if I want to add a proper - * EShellModule API for this. The mail module would - * not use it. */ - g_object_set_data_full ( - G_OBJECT (shell_module), "source-list", - source_list, (GDestroyNotify) g_object_unref); - - data_dir = e_shell_module_get_data_dir (shell_module); - filename = g_build_filename (data_dir, "local", NULL); - base_uri = g_filename_to_uri (filename, NULL, NULL); - g_free (filename); - - groups = e_source_list_peek_groups (source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); - - /* Compare only "file://" part. If the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; - - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; - } - - if (on_this_computer != NULL) { - GSList *sources; - const gchar *group_base_uri; - - sources = e_source_group_peek_sources (on_this_computer); - group_base_uri = e_source_group_peek_base_uri (on_this_computer); - - /* Make sure this group includes a "Personal" source. */ - for (iter = sources; iter != NULL; iter = iter->next) { - ESource *source = iter->data; - const gchar *relative_uri; - - relative_uri = e_source_peek_relative_uri (source); - if (relative_uri == NULL) - continue; - - if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) - continue; - - personal = source; - break; - } - - /* Make sure we have the correct base URI. This can - * change when the user's home directory changes. */ - if (strcmp (base_uri, group_base_uri) != 0) { - e_source_group_set_base_uri ( - on_this_computer, base_uri); - - /* XXX We shouldn't need this sync call here as - * set_base_uri() results in synching to GConf, - * but that happens in an idle loop and too late - * to prevent the user from seeing a "Cannot - * Open ... because of invalid URI" error. */ - e_source_list_sync (source_list, NULL); - } - - } else { - ESourceGroup *source_group; - const gchar *name; - - name = _("On This Computer"); - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - if (personal == NULL) { - ESource *source; - GSList *selected; - const gchar *name; - gchar *primary; - - name = _("Personal"); - source = e_source_new (name, PERSONAL_RELATIVE_URI); - e_source_group_add_source (on_this_computer, source, -1); - g_object_unref (source); - - primary = calendar_config_get_primary_memos (); - selected = calendar_config_get_memos_selected (); - - if (primary == NULL && selected == NULL) { - const gchar *uid; - - uid = e_source_peek_uid (source); - selected = g_slist_prepend (NULL, g_strdup (uid)); - - calendar_config_set_primary_memos (uid); - calendar_config_set_memos_selected (selected); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - g_slist_free (selected); - g_free (primary); - } - - if (on_the_web == NULL) { - ESourceGroup *source_group; - const gchar *name; - - name = _("On The Web"); - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - g_free (base_uri); -} - -static void -action_memo_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_memo_shared_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_memo_list_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ - calendar_setup_new_memo_list (NULL); -} - -static GtkActionEntry item_entries[] = { - - { "memo-new", - "stock_insert-note", - N_("Mem_o"), /* XXX Need C_() here */ - "o", - N_("Create a new memo"), - G_CALLBACK (action_memo_new_cb) }, - - { "memo-shared-new", - "stock_insert-note", - N_("_Shared Memo"), - "h", - N_("Create a new shared memo"), - G_CALLBACK (action_memo_shared_new_cb) } -}; - -static GtkActionEntry source_entries[] = { - - { "memo-list-new", - "stock_notes", - N_("Memo Li_st"), - NULL, - N_("Create a new memo list"), - G_CALLBACK (action_memo_list_new_cb) } -}; - -static gboolean -memo_module_handle_uri (EShellModule *shell_module, - const gchar *uri) -{ - /* FIXME */ - return FALSE; -} - -static void -memo_module_window_created (EShellModule *shell_module, - EShellWindow *shell_window) -{ - const gchar *module_name; - - module_name = G_TYPE_MODULE (shell_module)->name; - - e_shell_window_register_new_item_actions ( - shell_window, module_name, - item_entries, G_N_ELEMENTS (item_entries)); - - e_shell_window_register_new_source_actions ( - shell_window, module_name, - source_entries, G_N_ELEMENTS (source_entries)); -} - -static EShellModuleInfo module_info = { - - MODULE_NAME, - MODULE_ALIASES, - MODULE_SCHEMES, - MODULE_SEARCHES, - MODULE_SORT_ORDER -}; - -void -e_shell_module_init (GTypeModule *type_module) -{ - EShell *shell; - EShellModule *shell_module; - - shell_module = E_SHELL_MODULE (type_module); - shell = e_shell_module_get_shell (shell_module); - - /* Register the GType for EMemoShellView. */ - e_memo_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); - - memo_module_ensure_sources (shell_module); - - g_signal_connect_swapped ( - shell, "handle-uri", - G_CALLBACK (memo_module_handle_uri), shell_module); - - g_signal_connect_swapped ( - shell, "window-created", - G_CALLBACK (memo_module_window_created), shell_module); -} diff --git a/calendar/gui/e-memo-shell-sidebar.c b/calendar/gui/e-memo-shell-sidebar.c deleted file mode 100644 index 43e61edef9..0000000000 --- a/calendar/gui/e-memo-shell-sidebar.c +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-sidebar.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-memo-shell-sidebar.h" - -#include -#include - -#include -#include -#include - -#define E_MEMO_SHELL_SIDEBAR_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarPrivate)) - -struct _EMemoShellSidebarPrivate { - GtkWidget *selector; -}; - -enum { - PROP_0, - PROP_SELECTOR -}; - -static gpointer parent_class; - -static void -memo_shell_sidebar_update (EShellSidebar *shell_sidebar) -{ - EShellView *shell_view; - EMemos *memos; - ETable *table; - ECalModel *model; - EMemoTable *memo_table; - GString *string; - const gchar *format; - gint n_rows; - gint n_selected; - - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - memos = e_memo_shell_view_get_memos (E_MEMO_SHELL_VIEW (shell_view)); - memo_table = e_memos_get_calendar_table (memos); - model = e_memo_table_get_model (memo_table); - table = e_memo_table_get_table (memo_table); - - n_rows = e_table_model_get_row_count (model); - n_selected = e_table_selected_count (table); - - string = g_string_sized_new (64); - - format = ngettext ("%d memo", "%d memos", n_rows); - g_string_append_printf (string, format, n_rows); - - if (n_selected > 0) { - format = _("%d selected"); - g_string_append_len (string, ", ", 2); - g_string_append_printf (string, format, n_selected); - } - - e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); - - g_string_free (string, TRUE); -} - -static void -memo_shell_sidebar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SELECTOR: - g_value_set_object ( - value, e_memo_shell_sidebar_get_selector ( - E_MEMO_SHELL_SIDEBAR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -memo_shell_sidebar_dispose (GObject *object) -{ - EMemoShellSidebarPrivate *priv; - - priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); - - if (priv->selector != NULL) { - g_object_unref (priv->selector); - priv->selector = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -memo_shell_sidebar_constructed (GObject *object) -{ - EMemoShellSidebarPrivate *priv; - EShellView *shell_view; - EShellSidebar *shell_sidebar; - EMemoShellView *memo_shell_view; - ESourceList *source_list; - GtkContainer *container; - GtkWidget *widget; - EMemos *memos; - ETable *table; - ECalModel *model; - EMemoTable *memo_table; - - priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); - - shell_sidebar = E_SHELL_SIDEBAR (object); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - memo_shell_view = E_MEMO_SHELL_VIEW (shell_view); - source_list = e_memo_shell_view_get_source_list (memo_shell_view); - - container = GTK_CONTAINER (shell_sidebar); - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_container_add (container, widget); - gtk_widget_show (widget); - - container = GTK_CONTAINER (widget); - - widget = e_calendar_selector_new (source_list); - e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); - gtk_container_add (container, widget); - priv->selector = g_object_ref (widget); - gtk_widget_show (widget); - - /* Setup signal handlers. */ - - memos = e_memo_shell_view_get_memos (memo_shell_view); - memo_table = e_memos_get_calendar_table (memos); - model = e_memo_table_get_model (memo_table); - table = e_memo_table_get_table (memo_table); - - g_signal_connect_swapped ( - model, "model-changed", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-deleted", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-inserted", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "selection-change", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); - - memo_shell_sidebar_update (shell_sidebar); -} - -static void -memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (EMemoShellSidebarPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = memo_shell_sidebar_get_property; - object_class->dispose = memo_shell_sidebar_dispose; - object_class->constructed = memo_shell_sidebar_constructed; - - g_object_class_install_property ( - object_class, - PROP_SELECTOR, - g_param_spec_object ( - "selector", - _("Source Selector Widget"), - _("This widget displays groups of memo lists"), - E_TYPE_SOURCE_SELECTOR, - G_PARAM_READABLE)); -} - -static void -memo_shell_sidebar_init (EMemoShellSidebar *memo_shell_sidebar) -{ - memo_shell_sidebar->priv = - E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (memo_shell_sidebar); - - /* Postpone widget construction until we have a shell view. */ -} - -GType -e_memo_shell_sidebar_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMemoShellSidebarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) memo_shell_sidebar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMemoShellSidebar), - 0, /* n_preallocs */ - (GInstanceInitFunc) memo_shell_sidebar_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_SIDEBAR, "EMemoShellSidebar", - &type_info, 0); - } - - return type; -} - -GtkWidget * -e_memo_shell_sidebar_new (EShellView *shell_view) -{ - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return g_object_new ( - E_TYPE_MEMO_SHELL_SIDEBAR, - "shell-view", shell_view, NULL); -} - -GtkWidget * -e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar) -{ - g_return_val_if_fail ( - E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar), NULL); - - return memo_shell_sidebar->priv->selector; -} diff --git a/calendar/gui/e-memo-shell-sidebar.h b/calendar/gui/e-memo-shell-sidebar.h deleted file mode 100644 index ee487b07cb..0000000000 --- a/calendar/gui/e-memo-shell-sidebar.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-sidebar.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_MEMO_SHELL_SIDEBAR_H -#define E_MEMO_SHELL_SIDEBAR_H - -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_MEMO_SHELL_SIDEBAR \ - (e_memo_shell_sidebar_get_type ()) -#define E_MEMO_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebar)) -#define E_MEMO_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) -#define E_IS_MEMO_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_MEMO_SHELL_SIDEBAR)) -#define E_IS_MEMO_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_MEMO_SHELL_SIDEBAR)) -#define E_MEMO_SHELL_SIDEBAR_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) - -G_BEGIN_DECLS - -typedef struct _EMemoShellSidebar EMemoShellSidebar; -typedef struct _EMemoShellSidebarClass EMemoShellSidebarClass; -typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate; - -struct _EMemoShellSidebar { - EShellSidebar parent; - EMemoShellSidebarPrivate *priv; -}; - -struct _EMemoShellSidebarClass { - EShellSidebarClass parent_class; -}; - -GType e_memo_shell_sidebar_get_type (void); -GtkWidget * e_memo_shell_sidebar_new (EShellView *shell_view); -GtkWidget * e_memo_shell_sidebar_get_selector - (EMemoShellSidebar *memo_shell_sidebar); - -G_END_DECLS - -#endif /* E_MEMO_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-memo-shell-view-actions.c b/calendar/gui/e-memo-shell-view-actions.c deleted file mode 100644 index 1835cd144f..0000000000 --- a/calendar/gui/e-memo-shell-view-actions.c +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view-actions.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-memo-shell-view-private.h" - -#include - -#include "print.h" - -static void -action_memo_clipboard_copy_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - EMemoTable *memo_table; - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - e_memo_table_copy_clipboard (memo_table); -} - -static void -action_memo_clipboard_cut_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - EMemoTable *memo_table; - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - e_memo_table_cut_clipboard (memo_table); -} - -static void -action_memo_clipboard_paste_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - EMemoTable *memo_table; - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - e_memo_table_paste_clipboard (memo_table); -} - -static void -action_memo_delete_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - - memos = E_MEMOS (memo_shell_view->priv->memos); - e_memos_delete_selected (memos); -} - -static void -action_memo_list_copy_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - /* FIXME */ -} - -static void -action_memo_list_delete_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - /* FIXME */ -} - -static void -action_memo_list_new_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - calendar_setup_new_memo_list (GTK_WINDOW (shell_window)); -} - -static void -action_memo_list_properties_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - ESource *source; - ESourceSelector *selector; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - selector = E_SOURCE_SELECTOR (memo_shell_view->priv->selector); - source = e_source_selector_peek_primary_selection (selector); - g_return_if_fail (source != NULL); - - calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source); -} - -static void -action_memo_open_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - - memos = E_MEMOS (memo_shell_view->priv->memos); - e_memos_open_memo (memos); -} - -static void -action_memo_preview_cb (GtkToggleAction *action, - EMemoShellView *memo_shell_view) -{ - /* FIXME */ -} - -static void -action_memo_print_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - ETable *table; - EMemoTable *memo_table; - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - table = e_memo_table_get_table (memo_table); - - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); -} - -static void -action_memo_print_preview_cb (GtkAction *action, - EMemoShellView *memo_shell_view) -{ - EMemos *memos; - ETable *table; - EMemoTable *memo_table; - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - table = e_memo_table_get_table (memo_table); - - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); -} - -static GtkActionEntry memo_entries[] = { - - { "memo-clipboard-copy", - GTK_STOCK_COPY, - NULL, - NULL, - N_("Copy selected memo"), - G_CALLBACK (action_memo_clipboard_copy_cb) }, - - { "memo-clipboard-cut", - GTK_STOCK_CUT, - NULL, - NULL, - N_("Cut selected memo"), - G_CALLBACK (action_memo_clipboard_cut_cb) }, - - { "memo-clipboard-paste", - GTK_STOCK_PASTE, - NULL, - NULL, - N_("Paste memo from the clipboard"), - G_CALLBACK (action_memo_clipboard_paste_cb) }, - - { "memo-delete", - GTK_STOCK_DELETE, - NULL, - NULL, - N_("Delete selected memos"), - G_CALLBACK (action_memo_delete_cb) }, - - { "memo-list-copy", - GTK_STOCK_COPY, - N_("_Copy..."), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_memo_list_copy_cb) }, - - { "memo-list-delete", - GTK_STOCK_DELETE, - N_("_Delete"), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_memo_list_delete_cb) }, - - { "memo-list-new", - "stock_notes", - N_("_New Memo List"), - NULL, - N_("Create a new memo list"), - G_CALLBACK (action_memo_list_new_cb) }, - - { "memo-list-properties", - GTK_STOCK_PROPERTIES, - NULL, - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_memo_list_properties_cb) }, - - { "memo-open", - NULL, - N_("Open Memo"), - "o", - N_("View the selected memo"), - G_CALLBACK (action_memo_open_cb) }, - - { "memo-print", - GTK_STOCK_PRINT, - NULL, - NULL, - N_("Print the list of memos"), - G_CALLBACK (action_memo_print_cb) }, - - { "memo-print-preview", - GTK_STOCK_PRINT_PREVIEW, - NULL, - NULL, - N_("Preview the list of memos to be printed"), - G_CALLBACK (action_memo_print_preview_cb) }, -}; - -static GtkToggleActionEntry memo_toggle_entries[] = { - - { "memo-preview", - NULL, - N_("Memo _Preview"), - "m", - N_("Show memo preview pane"), - G_CALLBACK (action_memo_preview_cb), - TRUE } -}; - -void -e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - GtkActionGroup *action_group; - GtkUIManager *manager; - GConfBridge *bridge; - GObject *object; - const gchar *domain; - const gchar *key; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); - domain = GETTEXT_PACKAGE; - - e_load_ui_definition (manager, "evolution-memos.ui"); - - action_group = memo_shell_view->priv->memo_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_action_group_add_actions ( - action_group, memo_entries, - G_N_ELEMENTS (memo_entries), memo_shell_view); - gtk_action_group_add_toggle_actions ( - action_group, memo_toggle_entries, - G_N_ELEMENTS (memo_toggle_entries), memo_shell_view); - gtk_ui_manager_insert_action_group (manager, action_group, 0); - - /* Bind GObject properties to GConf keys. */ - - bridge = gconf_bridge_get (); - - object = G_OBJECT (ACTION (MEMO_PREVIEW)); - key = "/apps/evolution/calendar/display/show_memo_preview"; - gconf_bridge_bind_property (bridge, key, object, "active"); -} - -void -e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) -{ - ECal *cal; - EMemos *memos; - ETable *table; - ECalModel *model; - EMemoTable *memo_table; - EShellView *shell_view; - EShellWindow *shell_window; - GtkAction *action; - gboolean read_only = TRUE; - gboolean sensitive; - gint n_selected; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - memos = E_MEMOS (memo_shell_view->priv->memos); - memo_table = e_memos_get_calendar_table (memos); - - model = e_memo_table_get_model (memo_table); - cal = e_cal_model_get_default_client (model); - - table = e_memo_table_get_table (memo_table); - n_selected = e_table_selected_count (table); - - if (cal != NULL) - e_cal_is_read_only (cal, &read_only, NULL); - - action = ACTION (MEMO_OPEN); - sensitive = (n_selected == 1); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_CLIPBOARD_COPY); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_CLIPBOARD_CUT); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_CLIPBOARD_PASTE); - sensitive = !read_only; - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_DELETE); - sensitive = (n_selected > 0) && !read_only; - gtk_action_set_sensitive (action, sensitive); -} diff --git a/calendar/gui/e-memo-shell-view-actions.h b/calendar/gui/e-memo-shell-view-actions.h deleted file mode 100644 index 4ac71c2083..0000000000 --- a/calendar/gui/e-memo-shell-view-actions.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view-actions.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_MEMO_SHELL_VIEW_ACTIONS_H -#define E_MEMO_SHELL_VIEW_ACTIONS_H - -#include - -/* Memo Actions */ -#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_COPY(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-copy") -#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_CUT(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-cut") -#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_PASTE(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-paste") -#define E_SHELL_WINDOW_ACTION_MEMO_DELETE(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-delete") -#define E_SHELL_WINDOW_ACTION_MEMO_OPEN(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-open") -#define E_SHELL_WINDOW_ACTION_MEMO_PREVIEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-preview") -#define E_SHELL_WINDOW_ACTION_MEMO_PRINT(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-print") -#define E_SHELL_WINDOW_ACTION_MEMO_PRINT_PREVIEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "memo-print-preview") - -/* Action Groups */ -#define E_SHELL_WINDOW_ACTION_GROUP_MEMOS(window) \ - E_SHELL_WINDOW_ACTION_GROUP ((window), "memos") - -#endif /* E_MEMO_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/gui/e-memo-shell-view-private.c b/calendar/gui/e-memo-shell-view-private.c deleted file mode 100644 index 36defa31af..0000000000 --- a/calendar/gui/e-memo-shell-view-private.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view-private.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-memo-shell-view-private.h" - -void -e_memo_shell_view_private_init (EMemoShellView *memo_shell_view, - EShellViewClass *shell_view_class) -{ - EMemoShellViewPrivate *priv = memo_shell_view->priv; - ESourceList *source_list; - GObject *object; - - object = G_OBJECT (shell_view_class->type_module); - source_list = g_object_get_data (object, "source-list"); - g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - - priv->source_list = g_object_ref (source_list); - priv->memo_actions = gtk_action_group_new ("memos"); - priv->activity_handler = e_activity_handler_new (); -} - -void -e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) -{ - EMemoShellViewPrivate *priv = memo_shell_view->priv; - EShellContent *shell_content; - EShellTaskbar *shell_taskbar; - EShellView *shell_view; - GtkWidget *container; - GtkWidget *widget; - - shell_view = E_SHELL_VIEW (memo_shell_view); - - /* Construct view widgets. */ - - widget = e_memos_new (); - shell_content = e_shell_view_get_content (shell_view); - gtk_container_add (GTK_CONTAINER (shell_content), widget); - priv->memos = g_object_ref (widget); - gtk_widget_show (widget); - - shell_taskbar = e_shell_view_get_taskbar (shell_view); - e_activity_handler_attach_task_bar ( - priv->activity_handler, shell_taskbar); - - e_memo_shell_view_actions_update (memo_shell_view); -} - -void -e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) -{ - EMemoShellViewPrivate *priv = memo_shell_view->priv; - - DISPOSE (priv->source_list); - - DISPOSE (priv->memo_actions); - - DISPOSE (priv->memos); - - DISPOSE (priv->activity_handler); -} - -void -e_memo_shell_view_private_finalize (EMemoShellView *memo_shell_view) -{ - EMemoShellViewPrivate *priv = memo_shell_view->priv; -} diff --git a/calendar/gui/e-memo-shell-view-private.h b/calendar/gui/e-memo-shell-view-private.h deleted file mode 100644 index c53e55c487..0000000000 --- a/calendar/gui/e-memo-shell-view-private.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view-private.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_MEMO_SHELL_VIEW_PRIVATE_H -#define E_MEMO_SHELL_VIEW_PRIVATE_H - -#include "e-memo-shell-view.h" - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define E_MEMO_SHELL_VIEW_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewPrivate)) - -/* Shorthand, requires a variable named "shell_window". */ -#define ACTION(name) \ - (E_SHELL_WINDOW_ACTION_##name (shell_window)) -#define ACTION_GROUP(name) \ - (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) - -/* For use in dispose() methods. */ -#define DISPOSE(obj) \ - G_STMT_START { \ - if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ - } G_STMT_END - -G_BEGIN_DECLS - -struct _EMemoShellViewPrivate { - - /*** Module Data ***/ - - ESourceList *source_list; - - /*** UI Management ***/ - - GtkActionGroup *memo_actions; - - /*** Other Stuff ***/ - - GtkWidget *memos; - - EActivityHandler *activity_handler; -}; - -void e_memo_shell_view_private_init - (EMemoShellView *memo_shell_view, - EShellViewClass *shell_view_class); -void e_memo_shell_view_private_constructed - (EMemoShellView *memo_shell_view); -void e_memo_shell_view_private_dispose - (EMemoShellView *memo_shell_view); -void e_memo_shell_view_private_finalize - (EMemoShellView *memo_shell_view); - -/* Private Utilities */ - -void e_memo_shell_view_actions_init - (EMemoShellView *memo_shell_view); -void e_memo_shell_view_actions_update - (EMemoShellView *memo_shell_view); - -G_END_DECLS - -#endif /* E_MEMO_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/gui/e-memo-shell-view.c b/calendar/gui/e-memo-shell-view.c deleted file mode 100644 index 2f083ea23e..0000000000 --- a/calendar/gui/e-memo-shell-view.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-memo-shell-view-private.h" - -enum { - PROP_0, - PROP_SOURCE_LIST -}; - -GType e_memo_shell_view_type = 0; -static gpointer parent_class; - -static void -memo_shell_view_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SOURCE_LIST: - g_value_set_object ( - value, e_memo_shell_view_get_source_list ( - E_MEMO_SHELL_VIEW (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -memo_shell_view_dispose (GObject *object) -{ - e_memo_shell_view_private_dispose (E_MEMO_SHELL_VIEW (object)); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -memo_shell_view_finalize (GObject *object) -{ - e_memo_shell_view_private_finalize (E_MEMO_SHELL_VIEW (object)); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -memo_shell_view_constructed (GObject *object) -{ - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); - - e_memo_shell_view_private_constructed (E_MEMO_SHELL_VIEW (object)); -} - -static void -memo_shell_view_changed (EShellView *shell_view) -{ - EMemoShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; - - priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view); - - action_group = priv->memo_actions; - visible = e_shell_view_is_selected (shell_view); - gtk_action_group_set_visible (action_group, visible); -} - -static void -memo_shell_view_class_init (EMemoShellView *class, - GTypeModule *type_module) -{ - GObjectClass *object_class; - EShellViewClass *shell_view_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (EMemoShellViewPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = memo_shell_view_get_property; - object_class->dispose = memo_shell_view_dispose; - object_class->finalize = memo_shell_view_finalize; - object_class->constructed = memo_shell_view_constructed; - - shell_view_class = E_SHELL_VIEW_CLASS (class); - shell_view_class->label = N_("Memos"); - shell_view_class->icon_name = "evolution-memos"; - shell_view_class->type_module = type_module; - shell_view_class->changed = memo_shell_view_changed; - shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new; - - g_object_class_install_property ( - object_class, - PROP_SOURCE_LIST, - g_param_spec_object ( - "source-list", - _("Source List"), - _("The registry of memo lists"), - E_TYPE_SOURCE_LIST, - G_PARAM_READABLE)); -} - -static void -memo_shell_view_init (EMemoShellView *memo_shell_view, - EShellViewClass *shell_view_class) -{ - memo_shell_view->priv = - E_MEMO_SHELL_VIEW_GET_PRIVATE (memo_shell_view); - - e_memo_shell_view_private_init (memo_shell_view, shell_view_class); -} - -GType -e_memo_shell_view_get_type (GTypeModule *type_module) -{ - if (e_memo_shell_view_type == 0) { - const GTypeInfo type_info = { - sizeof (EMemoShellViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) memo_shell_view_class_init, - (GClassFinalizeFunc) NULL, - type_module, - sizeof (EMemoShellView), - 0, /* n_preallocs */ - (GInstanceInitFunc) memo_shell_view_init, - NULL /* value_table */ - }; - - e_memo_shell_view_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_VIEW, - "EMemoShellView", &type_info, 0); - } - - return e_memo_shell_view_type; -} - -ESourceList * -e_memo_shell_view_get_source_list (EMemoShellView *memo_shell_view) -{ - g_return_val_if_fail (E_IS_MEMO_SHELL_VIEW (memo_shell_view), NULL); - - return memo_shell_view->priv->source_list; -} diff --git a/calendar/gui/e-memo-shell-view.h b/calendar/gui/e-memo-shell-view.h deleted file mode 100644 index c6faa8382c..0000000000 --- a/calendar/gui/e-memo-shell-view.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-memo-shell-view.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_MEMO_SHELL_VIEW_H -#define E_MEMO_SHELL_VIEW_H - -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_MEMO_SHELL_VIEW \ - (e_memo_shell_view_type) -#define E_MEMO_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellView)) -#define E_MEMO_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewClass)) -#define E_IS_MEMO_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_MEMO_SHELL_VIEW)) -#define E_IS_MEMO_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_MEMO_SHELL_VIEW)) -#define E_MEMO_SHELL_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewClass)) - -G_BEGIN_DECLS - -extern GType e_memo_shell_view_type; - -typedef struct _EMemoShellView EMemoShellView; -typedef struct _EMemoShellViewClass EMemoShellViewClass; -typedef struct _EMemoShellViewPrivate EMemoShellViewPrivate; - -struct _EMemoShellView { - EShellView parent; - EMemoShellViewPrivate *priv; -}; - -struct _EMemoShellViewClass { - EShellViewClass parent_class; -}; - -GType e_memo_shell_view_get_type - (GTypeModule *type_module); -ESourceList * e_memo_shell_view_get_source_list - (EMemoShellView *memo_shell_view); - -G_END_DECLS - -#endif /* E_MEMO_SHELL_VIEW_H */ diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 98f17a7121..8f495a000d 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -54,12 +54,26 @@ #include "e-cal-model-memos.h" #include "e-memo-table.h" #include "e-cell-date-edit-text.h" -#include "e-comp-editor-registry.h" #include "print.h" #include #include #include "e-cal-popup.h" +#define E_MEMO_TABLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_TABLE, EMemoTablePrivate)) + +struct _EMemoTablePrivate { + gpointer shell_view; /* weak pointer */ + + EActivity *activity; +}; + +enum { + PROP_0, + PROP_SHELL_VIEW +}; + enum TargetType{ TARGET_TYPE_VCALENDAR }; @@ -72,12 +86,6 @@ static GtkTargetEntry target_types[] = { static guint n_target_types = G_N_ELEMENTS (target_types); -extern ECompEditorRegistry *comp_editor_registry; - -static void e_memo_table_class_init (EMemoTableClass *klass); -static void e_memo_table_init (EMemoTable *memo_table); -static void e_memo_table_destroy (GtkObject *object); - static void e_memo_table_on_double_click (ETable *table, gint row, gint col, @@ -111,7 +119,8 @@ enum { LAST_SIGNAL }; -static guint signals[LAST_SIGNAL] = { 0 }; +static gpointer parent_class; +static guint signals[LAST_SIGNAL]; /* The icons to represent the task. */ #define E_MEMO_MODEL_NUM_ICONS 2 @@ -122,35 +131,14 @@ static GdkPixbuf* icon_pixbufs[E_MEMO_MODEL_NUM_ICONS] = { NULL }; static GdkAtom clipboard_atom = GDK_NONE; -G_DEFINE_TYPE (EMemoTable, e_memo_table, GTK_TYPE_TABLE) - - static void -e_memo_table_class_init (EMemoTableClass *klass) +memo_table_emit_user_created (EMemoTable *memo_table) { - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - /* Method override */ - object_class->destroy = e_memo_table_destroy; - - signals[USER_CREATED] = - g_signal_new ("user_created", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMemoTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* clipboard atom */ - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); + g_signal_emit (memo_table, signals[USER_CREATED], 0); } static gint -date_compare_cb (gconstpointer a, gconstpointer b) +memo_table_date_compare_cb (gconstpointer a, gconstpointer b) { ECellDateEditValue *dv1 = (ECellDateEditValue *) a; ECellDateEditValue *dv2 = (ECellDateEditValue *) b; @@ -178,13 +166,102 @@ date_compare_cb (gconstpointer a, gconstpointer b) } static void -row_appended_cb (ECalModel *model, EMemoTable *memo_table) +memo_table_set_shell_view (EMemoTable *memo_table, + EShellView *shell_view) { - g_signal_emit (memo_table, signals[USER_CREATED], 0); + g_return_if_fail (memo_table->priv->shell_view == NULL); + + memo_table->priv->shell_view = shell_view; + + g_object_add_weak_pointer ( + G_OBJECT (shell_view), + &memo_table->priv->shell_view); +} + +static void +memo_table_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + memo_table_set_shell_view ( + E_MEMO_TABLE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_table_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, e_memo_table_get_shell_view ( + E_MEMO_TABLE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -e_memo_table_init (EMemoTable *memo_table) +memo_table_dispose (GObject *object) +{ + EMemoTable *memo_table; + + memo_table = E_MEMO_TABLE (object); + + if (memo_table->model != NULL) { + g_object_unref (memo_table->model); + memo_table->model = NULL; + } + + if (memo_table->priv->activity != NULL) { + /* XXX Activity is not cancellable. */ + e_activity_complete (memo_table->priv->activity); + g_object_unref (memo_table->priv->activity); + memo_table->priv->activity = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_table_class_init (EMemoTableClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoTablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = memo_table_set_property; + object_class->get_property = memo_table_get_property; + object_class->dispose = memo_table_dispose; + + signals[USER_CREATED] = + g_signal_new ("user_created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EMemoTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); +} + +static void +memo_table_init (EMemoTable *memo_table) { GtkWidget *table; ETable *e_table; @@ -194,16 +271,18 @@ e_memo_table_init (EMemoTable *memo_table) AtkObject *a11y; gchar *etspecfile; + memo_table->priv = E_MEMO_TABLE_GET_PRIVATE (memo_table); + /* Create the model */ memo_table->model = (ECalModel *) e_cal_model_memos_new (); - g_signal_connect (memo_table->model, "row_appended", G_CALLBACK (row_appended_cb), memo_table); - - memo_table->user_created_cal = NULL; + g_signal_connect_swapped ( + memo_table->model, "row_appended", + G_CALLBACK (memo_table_emit_user_created), memo_table); /* Create the header columns */ - extras = e_table_extras_new(); + extras = e_table_extras_new (); /* * Normal string fields. @@ -235,7 +314,7 @@ e_memo_table_init (EMemoTable *memo_table) /* Sorting */ e_table_extras_add_compare (extras, "date-compare", - date_compare_cb); + memo_table_date_compare_cb); /* Create pixmaps */ @@ -280,23 +359,57 @@ e_memo_table_init (EMemoTable *memo_table) atk_object_set_name (a11y, _("Memos")); } +GType +e_memo_table_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMemoTableClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_table_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMemoTable), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_table_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_TABLE, "EMemoTable", &type_info, 0); + } + + return type; +} /** * e_memo_table_new: - * @Returns: a new #EMemoTable. + * @shell_view: an #EShellView + * + * Returns a new #EMemoTable. * - * Creates a new #EMemoTable. + * Returns: a new #EMemoTable **/ GtkWidget * -e_memo_table_new (void) +e_memo_table_new (EShellView *shell_view) { - GtkWidget *memo_table; - - memo_table = GTK_WIDGET (g_object_new (e_memo_table_get_type (), NULL)); + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return memo_table; + return g_object_new ( + E_TYPE_MEMO_TABLE, + "shell-view", shell_view, NULL); } +EShellView * +e_memo_table_get_shell_view (EMemoTable *memo_table) +{ + g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL); + + return memo_table->priv->shell_view; +} /** * e_memo_table_get_model: @@ -316,21 +429,6 @@ e_memo_table_get_model (EMemoTable *memo_table) } -static void -e_memo_table_destroy (GtkObject *object) -{ - EMemoTable *memo_table; - - memo_table = E_MEMO_TABLE (object); - - if (memo_table->model) { - g_object_unref (memo_table->model); - memo_table->model = NULL; - } - - GTK_OBJECT_CLASS (e_memo_table_parent_class)->destroy (object); -} - /** * e_memo_table_get_table: * @memo_table: A calendar table. @@ -749,7 +847,7 @@ open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data) uid = icalcomponent_get_uid (comp_data->icalcomp); - medit = e_comp_editor_registry_find (comp_editor_registry, uid); + medit = comp_editor_find_instance (uid); if (medit == NULL) { ECalComponent *comp; CompEditorFlags flags = 0; @@ -767,8 +865,6 @@ open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data) comp_editor_edit_comp (medit, comp); g_object_unref (comp); - - e_comp_editor_registry_add (comp_editor_registry, medit, FALSE); } gtk_window_present (GTK_WINDOW (medit)); @@ -1096,34 +1192,29 @@ static char *test[] = { #endif void -e_memo_table_set_activity_handler (EMemoTable *memo_table, EActivityHandler *activity_handler) +e_memo_table_set_status_message (EMemoTable *memo_table, + const gchar *message) { - g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); + EActivity *activity; + EShellView *shell_view; - memo_table->activity_handler = activity_handler; -} - -void -e_memo_table_set_status_message (EMemoTable *memo_table, const gchar *message) -{ g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - if (!memo_table->activity_handler) - return; + activity = memo_table->priv->activity; + shell_view = e_memo_table_get_shell_view (memo_table); - if (!message || !*message) { - if (memo_table->activity_id != 0) { - e_activity_handler_operation_finished (memo_table->activity_handler, memo_table->activity_id); - memo_table->activity_id = 0; + if (message == NULL || *message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + memo_table->priv->activity = NULL; } - } else if (memo_table->activity_id == 0) { - char *client_id = g_strdup_printf ("%p", memo_table); - memo_table->activity_id = e_activity_handler_operation_started ( - memo_table->activity_handler, client_id, message, TRUE); + } else if (activity == NULL) { + activity = e_activity_new (message); + memo_table->priv->activity = activity; + e_shell_view_add_activity (shell_view, activity); - g_free (client_id); - } else { - e_activity_handler_operation_progressing (memo_table->activity_handler, memo_table->activity_id, message, -1.0); - } + } else + e_activity_set_primary_text (activity, message); } diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h index 58f398bfb5..2c31ee5b02 100644 --- a/calendar/gui/e-memo-table.h +++ b/calendar/gui/e-memo-table.h @@ -25,31 +25,43 @@ #ifndef _E_MEMO_TABLE_H_ #define _E_MEMO_TABLE_H_ -#include -#include +#include +#include #include -#include "e-activity-handler.h" #include "e-cal-model.h" -G_BEGIN_DECLS - /* * EMemoTable - displays the iCalendar objects in a table (an ETable). * Used for memo events and tasks. */ +/* Standard GObject macros */ +#define E_TYPE_MEMO_TABLE \ + (e_memo_table_get_type ()) +#define E_MEMO_TABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_TABLE, EMemoTable)) +#define E_MEMO_TABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MEMO_TABLE, EMemoTableClass)) +#define E_IS_MEMO_TABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_TABLE)) +#define E_IS_MEMO_TABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_TABLE)) +#define E_MEMO_TABLE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_TABLE, EMemoTableClass)) -#define E_MEMO_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_memo_table_get_type (), EMemoTable) -#define E_MEMO_TABLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_memo_table_get_type (), EMemoTableClass) -#define E_IS_MEMO_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_memo_table_get_type ()) - - -typedef struct _EMemoTable EMemoTable; -typedef struct _EMemoTableClass EMemoTableClass; +G_BEGIN_DECLS +typedef struct _EMemoTable EMemoTable; +typedef struct _EMemoTableClass EMemoTableClass; +typedef struct _EMemoTablePrivate EMemoTablePrivate; struct _EMemoTable { - GtkTable table; + GtkTable parent; /* The model that we use */ ECalModel *model; @@ -62,13 +74,12 @@ struct _EMemoTable { /* Fields used for cut/copy/paste */ icalcomponent *tmp_vcal; - /* Activity ID for the EActivityHandler (i.e. the status bar). */ - EActivityHandler *activity_handler; - guint activity_id; - - /* We should know which calendar has been used to create object, so store it here - before emitting "user_created" signal and make it NULL just after the emit. */ + /* We should know which calendar has been used to create object, + * so store it here before emitting "user_created" signal and make + * it NULL just after the emit. */ ECal *user_created_cal; + + EMemoTablePrivate *priv; }; struct _EMemoTableClass { @@ -79,34 +90,29 @@ struct _EMemoTableClass { }; -GType e_memo_table_get_type (void); -GtkWidget* e_memo_table_new (void); - -ECalModel *e_memo_table_get_model (EMemoTable *memo_table); - -ETable *e_memo_table_get_table (EMemoTable *memo_table); - -void e_memo_table_open_selected (EMemoTable *memo_table); -void e_memo_table_delete_selected (EMemoTable *memo_table); - -GSList *e_memo_table_get_selected (EMemoTable *memo_table); +GType e_memo_table_get_type (void); +GtkWidget * e_memo_table_new (EShellView *shell_view); +ECalModel * e_memo_table_get_model (EMemoTable *memo_table); +ETable * e_memo_table_get_table (EMemoTable *memo_table); +EShellView * e_memo_table_get_shell_view (EMemoTable *memo_table); +void e_memo_table_open_selected (EMemoTable *memo_table); +void e_memo_table_delete_selected (EMemoTable *memo_table); +GSList * e_memo_table_get_selected (EMemoTable *memo_table); /* Clipboard related functions */ -void e_memo_table_cut_clipboard (EMemoTable *memo_table); -void e_memo_table_copy_clipboard (EMemoTable *memo_table); -void e_memo_table_paste_clipboard (EMemoTable *memo_table); +void e_memo_table_cut_clipboard (EMemoTable *memo_table); +void e_memo_table_copy_clipboard (EMemoTable *memo_table); +void e_memo_table_paste_clipboard (EMemoTable *memo_table); /* These load and save the state of the table (headers shown etc.) to/from the given file. */ -void e_memo_table_load_state (EMemoTable *memo_table, - gchar *filename); -void e_memo_table_save_state (EMemoTable *memo_table, - gchar *filename); - -void e_memo_table_set_activity_handler (EMemoTable *memo_table, - EActivityHandler *activity_handler); -void e_memo_table_set_status_message (EMemoTable *memo_table, - const gchar *message); +void e_memo_table_load_state (EMemoTable *memo_table, + gchar *filename); +void e_memo_table_save_state (EMemoTable *memo_table, + gchar *filename); + +void e_memo_table_set_status_message (EMemoTable *memo_table, + const gchar *message); G_END_DECLS diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c index cc033942b4..5e162f8a28 100644 --- a/calendar/gui/e-memos.c +++ b/calendar/gui/e-memos.c @@ -69,9 +69,6 @@ struct _EMemosPrivate { /* Calendar search bar for memos */ GtkWidget *search_bar; - /* Paned widget */ - GtkWidget *paned; - /* The preview */ GtkWidget *preview; @@ -90,7 +87,6 @@ static void e_memos_destroy (GtkObject *object); static void update_view (EMemos *memos); static void categories_changed_cb (gpointer object, gpointer user_data); -static void backend_error_cb (ECal *client, const char *message, gpointer data); /* Signal IDs */ enum { @@ -100,100 +96,10 @@ enum { LAST_SIGNAL }; -enum DndTargetType { - TARGET_VCALENDAR -}; - -static GtkTargetEntry list_drag_types[] = { - { "text/calendar", 0, TARGET_VCALENDAR }, - { "text/x-calendar", 0, TARGET_VCALENDAR } -}; -static const int num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]); - static guint e_memos_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (EMemos, e_memos, GTK_TYPE_TABLE) -/* Callback used when the cursor changes in the table */ -static void -table_cursor_change_cb (ETable *etable, int row, gpointer data) -{ - EMemos *memos; - EMemosPrivate *priv; - ECalModel *model; - ECalModelComponent *comp_data; - ECalComponent *comp; - const char *uid; - - int n_selected; - - memos = E_MEMOS (data); - priv = memos->priv; - - n_selected = e_table_selected_count (etable); - - /* update the HTML widget */ - if (n_selected != 1) { - e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview)); - - return; - } - - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - - comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable)); - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - - e_cal_component_memo_preview_display (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), comp_data->client, comp); - - e_cal_component_get_uid (comp, &uid); - if (priv->current_uid) - g_free (priv->current_uid); - priv->current_uid = g_strdup (uid); - - g_object_unref (comp); -} - -/* Callback used when the selection changes in the table. */ -static void -table_selection_change_cb (ETable *etable, gpointer data) -{ - EMemos *memos; - int n_selected; - - memos = E_MEMOS (data); - - n_selected = e_table_selected_count (etable); - g_signal_emit (memos, e_memos_signals[SELECTION_CHANGED], 0, n_selected); - - if (n_selected != 1) - e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (memos->priv->preview)); - -} - -static void -user_created_cb (GtkWidget *view, EMemos *memos) -{ - EMemosPrivate *priv; - EMemoTable *memo_table; - ECal *ecal; - - priv = memos->priv; - memo_table = E_MEMO_TABLE (priv->memos_view); - - if (memo_table->user_created_cal) - ecal = memo_table->user_created_cal; - else { - ECalModel *model; - - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - ecal = e_cal_model_get_default_client (model); - } - - e_memos_add_memo_source (memos, e_cal_get_source (ecal)); -} - /* Callback used when the sexp in the search bar changes */ static void search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer data) @@ -227,14 +133,6 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category, e_cal_model_set_default_category (model, category); } -static gboolean -vpaned_resized_cb (GtkWidget *widget, GdkEventButton *event, EMemos *memos) -{ - calendar_config_set_task_vpane_pos (gtk_paned_get_position (GTK_PANED (widget))); - - return FALSE; -} - static void set_timezone (EMemos *memos) { @@ -284,33 +182,6 @@ update_view (EMemos *memos) e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview)); } -static void -model_row_changed_cb (ETableModel *etm, int row, gpointer data) -{ - EMemos *memos; - EMemosPrivate *priv; - ECalModelComponent *comp_data; - - memos = E_MEMOS (data); - priv = memos->priv; - - if (priv->current_uid) { - const char *uid; - - comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), row); - if (comp_data) { - uid = icalcomponent_get_uid (comp_data->icalcomp); - if (!strcmp (uid ? uid : "", priv->current_uid)) { - ETable *etable; - - etable = e_table_scrolled_get_table ( - E_TABLE_SCROLLED (E_MEMO_TABLE (priv->memos_view)->etable)); - table_cursor_change_cb (etable, 0, memos); - } - } - } -} - static void setup_config (EMemos *memos) { @@ -446,35 +317,6 @@ table_drag_data_get (ETable *table, } } -static void -table_drag_data_delete (ETable *table, - int row, - int col, - GdkDragContext *context, - EMemos *memos) -{ - /* Moved components are deleted from source immediately when moved, - because some of them can be part of destination source, and we - don't want to delete not-moved tasks. There is no such information - which event has been moved and which not, so skip this method. - */ -} - -#define E_MEMOS_TABLE_DEFAULT_STATE \ - "" \ - "" \ - "" \ - "" \ - "" \ - "" \ - "" - -static void -pane_realized (GtkWidget *widget, EMemos *memos) -{ - gtk_paned_set_position ((GtkPaned *)widget, calendar_config_get_task_vpane_pos ()); -} - static void setup_widgets (EMemos *memos) { @@ -496,51 +338,12 @@ setup_widgets (EMemos *memos) GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0, 0); gtk_widget_show (priv->search_bar); - /* add the paned widget for the memo list and memo detail areas */ - priv->paned = gtk_vpaned_new (); - g_signal_connect (priv->paned, "realize", G_CALLBACK (pane_realized), memos); - - g_signal_connect (G_OBJECT (priv->paned), "button_release_event", - G_CALLBACK (vpaned_resized_cb), memos); - gtk_table_attach (GTK_TABLE (memos), priv->paned, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (priv->paned); - /* create the memo list */ priv->memos_view = e_memo_table_new (); priv->memos_view_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memos_view)); - g_signal_connect (priv->memos_view, "user_created", G_CALLBACK (user_created_cb), memos); - - etable = e_table_scrolled_get_table ( - E_TABLE_SCROLLED (E_MEMO_TABLE (priv->memos_view)->etable)); - e_table_set_state (etable, E_MEMOS_TABLE_DEFAULT_STATE); - - gtk_paned_add1 (GTK_PANED (priv->paned), priv->memos_view); - gtk_widget_show (priv->memos_view); - - - e_table_drag_source_set (etable, GDK_BUTTON1_MASK, - list_drag_types, num_list_drag_types, - GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_ASK); - g_signal_connect (etable, "table_drag_data_get", G_CALLBACK(table_drag_data_get), memos); - g_signal_connect (etable, "table_drag_data_delete", - G_CALLBACK(table_drag_data_delete), memos); - - g_signal_connect (etable, "cursor_change", G_CALLBACK (table_cursor_change_cb), memos); - g_signal_connect (etable, "selection_change", G_CALLBACK (table_selection_change_cb), memos); - - /* create the memo detail */ - priv->preview = e_cal_component_memo_preview_new (); - e_cal_component_memo_preview_set_default_timezone (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), calendar_config_get_icaltimezone ()); - gtk_paned_add2 (GTK_PANED (priv->paned), priv->preview); - gtk_widget_show (priv->preview); - - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - g_signal_connect (G_OBJECT (model), "model_row_changed", - G_CALLBACK (model_row_changed_cb), memos); } /* Class initialization function for the gnome calendar */ @@ -675,10 +478,6 @@ e_memos_destroy (GtkObject *object) g_hash_table_destroy (priv->clients); g_list_free (priv->clients_list); - if (priv->default_client) - g_object_unref (priv->default_client); - priv->default_client = NULL; - if (priv->current_uid) { g_free (priv->current_uid); priv->current_uid = NULL; @@ -725,56 +524,6 @@ set_status_message (EMemos *memos, const char *message, ...) e_memo_table_set_status_message (E_MEMO_TABLE (priv->memos_view), msg_string); } -/* Callback from the calendar client when an error occurs in the backend */ -static void -backend_error_cb (ECal *client, const char *message, gpointer data) -{ - EMemos *memos; - GtkWidget *dialog; - char *urinopwd; - - memos = E_MEMOS (data); - - urinopwd = get_uri_without_password (e_cal_get_uri (client)); - - dialog = gtk_message_dialog_new ( - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Error on %s:\n %s"), urinopwd, message); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (urinopwd); -} - -/* Callback from the calendar client when the backend dies */ -static void -backend_died_cb (ECal *client, gpointer data) -{ - EMemos *memos; - EMemosPrivate *priv; - ESource *source; - - memos = E_MEMOS (data); - priv = memos->priv; - - source = g_object_ref (e_cal_get_source (client)); - - priv->clients_list = g_list_remove (priv->clients_list, client); - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source); - - e_memo_table_set_status_message (E_MEMO_TABLE (e_memos_get_calendar_table (memos)), NULL); - - e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))), - "calendar:memos-crashed", NULL); - - g_object_unref (source); -} - /* Callback from the calendar client when the calendar is opened */ static void client_cal_opened_cb (ECal *ecal, ECalendarStatus status, EMemos *memos) @@ -880,21 +629,6 @@ open_ecal (EMemos *memos, ECal *cal, gboolean only_if_exists, open_func of) return TRUE; } -void -e_memos_open_memo (EMemos *memos) -{ - EMemoTable *cal_table; - - cal_table = e_memos_get_calendar_table (memos); - e_memo_table_open_selected (cal_table); -} - -void -e_memos_new_memo (EMemos *memos) -{ - /* used for click_to_add ?? Can't figure out anything else it's used for */ -} - gboolean e_memos_add_memo_source (EMemos *memos, ESource *source) { @@ -1024,173 +758,3 @@ e_memos_get_default_client (EMemos *memos) return e_cal_model_get_default_client (e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view))); } - - -/** - * e_memos_delete_selected: - * @memos: A memos control widget. - * - * Deletes the selected memos in the memo list. - **/ -void -e_memos_delete_selected (EMemos *memos) -{ - EMemosPrivate *priv; - EMemoTable *cal_table; - - g_return_if_fail (memos != NULL); - g_return_if_fail (E_IS_MEMOS (memos)); - - priv = memos->priv; - - cal_table = E_MEMO_TABLE (priv->memos_view); - set_status_message (memos, _("Deleting selected objects...")); - e_memo_table_delete_selected (cal_table); - set_status_message (memos, NULL); - - e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview)); -} - - -/* Callback used from the view collection when we need to display a new view */ -static void -display_view_cb (GalViewInstance *instance, GalView *view, gpointer data) -{ - EMemos *memos; - - memos = E_MEMOS (data); - - if (GAL_IS_VIEW_ETABLE (view)) { - gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), e_table_scrolled_get_table (E_TABLE_SCROLLED (E_MEMO_TABLE (memos->priv->memos_view)->etable))); - } - - gtk_paned_set_position ((GtkPaned *)memos->priv->paned, calendar_config_get_task_vpane_pos ()); -} - -/** - * e_memos_setup_view_menus: - * @memos: A memos widget. - * @uic: UI controller to use for the menus. - * - * Sets up the #GalView menus for a memos control. This function should be - * called from the Bonobo control activation callback for this memos control. - * Also, the menus should be discarded using e_memos_discard_view_menus(). - */ -void -e_memos_setup_view_menus (EMemos *memos, BonoboUIComponent *uic) -{ - EMemosPrivate *priv; - GalViewFactory *factory; - ETableSpecification *spec; - char *dir0, *dir1, *filename; - static GalViewCollection *collection = NULL; - - g_return_if_fail (memos != NULL); - g_return_if_fail (E_IS_MEMOS (memos)); - g_return_if_fail (uic != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - - priv = memos->priv; - - g_return_if_fail (priv->view_instance == NULL); - - g_return_if_fail (priv->view_instance == NULL); - g_return_if_fail (priv->view_menus == NULL); - - /* Create the view instance */ - - if (collection == NULL) { - collection = gal_view_collection_new (); - - gal_view_collection_set_title (collection, _("Memos")); - - dir0 = g_build_filename (EVOLUTION_GALVIEWSDIR, - "memos", - NULL); - dir1 = g_build_filename (memos_component_peek_base_directory (memos_component_peek ()), - "views", NULL); - gal_view_collection_set_storage_directories (collection, - dir0, - dir1); - g_free (dir1); - g_free (dir0); - - /* Create the views */ - - spec = e_table_specification_new (); - filename = g_build_filename (EVOLUTION_ETSPECDIR, - "e-memo-table.etspec", - NULL); - if (!e_table_specification_load_from_file (spec, filename)) - g_error ("Unable to load ETable specification file " - "for memos"); - g_free (filename); - - factory = gal_view_factory_etable_new (spec); - g_object_unref (spec); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - - /* Load the collection and create the menus */ - - gal_view_collection_load (collection); - } - - priv->view_instance = gal_view_instance_new (collection, NULL); - - priv->view_menus = gal_view_menus_new (priv->view_instance); - gal_view_menus_apply (priv->view_menus, uic, NULL); - g_signal_connect (priv->view_instance, "display_view", G_CALLBACK (display_view_cb), memos); - display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), memos); -} - -/** - * e_memos_discard_view_menus: - * @memos: A memos widget. - * - * Discards the #GalView menus used by a memos control. This function should be - * called from the Bonobo control deactivation callback for this memos control. - * The menus should have been set up with e_memos_setup_view_menus(). - **/ -void -e_memos_discard_view_menus (EMemos *memos) -{ - EMemosPrivate *priv; - - g_return_if_fail (memos != NULL); - g_return_if_fail (E_IS_MEMOS (memos)); - - priv = memos->priv; - - g_return_if_fail (priv->view_instance != NULL); - - g_return_if_fail (priv->view_instance != NULL); - g_return_if_fail (priv->view_menus != NULL); - - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - - g_object_unref (priv->view_menus); - priv->view_menus = NULL; -} - -/** - * e_memos_get_calendar_table: - * @memos: A memos widget. - * - * Queries the #EMemoTable contained in a memos widget. - * - * Return value: The #EMemoTable that the memos widget uses to display its - * information. - **/ -EMemoTable * -e_memos_get_calendar_table (EMemos *memos) -{ - EMemosPrivate *priv; - - g_return_val_if_fail (memos != NULL, NULL); - g_return_val_if_fail (E_IS_MEMOS (memos), NULL); - - priv = memos->priv; - return E_MEMO_TABLE (priv->memos_view); -} diff --git a/calendar/gui/e-select-names-renderer.c b/calendar/gui/e-select-names-renderer.c index fb742bf5c7..357eba4c5b 100644 --- a/calendar/gui/e-select-names-renderer.c +++ b/calendar/gui/e-select-names-renderer.c @@ -22,7 +22,7 @@ #include -#include "e-calendar-marshal.h" +#include "e-util/e-util.h" #include "e-select-names-editable.h" #include "e-select-names-renderer.h" @@ -192,7 +192,7 @@ e_select_names_renderer_class_init (ESelectNamesRendererClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ESelectNamesRendererClass, cell_edited), NULL, NULL, - e_calendar_marshal_VOID__STRING_POINTER_POINTER, + e_marshal_VOID__STRING_POINTER_POINTER, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); } diff --git a/calendar/gui/e-task-shell-module.c b/calendar/gui/e-task-shell-module.c deleted file mode 100644 index 7dee36a9cc..0000000000 --- a/calendar/gui/e-task-shell-module.c +++ /dev/null @@ -1,296 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-module.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#define MODULE_NAME "tasks" -#define MODULE_ALIASES "" -#define MODULE_SCHEMES "task" -#define MODULE_SEARCHES "tasktypes.xml" -#define MODULE_SORT_ORDER 600 - -#define WEB_BASE_URI "webcal://" -#define PERSONAL_RELATIVE_URI "system" - -/* Module Entry Point */ -void e_shell_module_init (GTypeModule *type_module); - -static void -task_module_ensure_sources (EShellModule *shell_module) -{ - /* XXX This is basically the same algorithm across all modules. - * Maybe we could somehow integrate this into EShellModule? */ - - ESourceList *source_list; - ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; - ESource *personal; - GSList *groups, *iter; - const gchar *data_dir; - gchar *base_uri; - gchar *filename; - - on_this_computer = NULL; - on_the_web = NULL; - personal = NULL; - - if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_TODO, NULL)) { - g_warning ("Could not get task sources from GConf!"); - return; - } - - /* Share the source list with all task views. This is - * accessible via e_task_shell_view_get_source_list(). - * Note: EShellModule takes ownership of the reference. - * - * XXX I haven't yet decided if I want to add a proper - * EShellModule API for this. The mail module would - * not use it. */ - g_object_set_data_full ( - G_OBJECT (shell_module), "source-list", - source_list, (GDestroyNotify) g_object_unref); - - data_dir = e_shell_module_get_data_dir (shell_module); - filename = g_build_filename (data_dir, "local", NULL); - base_uri = g_filename_to_uri (filename, NULL, NULL); - g_free (filename); - - groups = e_source_list_peek_groups (source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); - - /* Compare only "file://" part. If the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; - - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; - } - - if (on_this_computer != NULL) { - GSList *sources; - const gchar *group_base_uri; - - sources = e_source_group_peek_sources (on_this_computer); - group_base_uri = e_source_group_peek_base_uri (on_this_computer); - - /* Make sure this group includes a "Personal" source. */ - for (iter = sources; iter != NULL; iter = iter->next) { - ESource *source = iter->data; - const gchar *relative_uri; - - relative_uri = e_source_peek_relative_uri (source); - if (relative_uri == NULL) - continue; - - if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) - continue; - - personal = source; - break; - } - - /* Make sure we have the correct base URI. This can - * change when the user's home directory changes. */ - if (strcmp (base_uri, group_base_uri) != 0) { - e_source_group_set_base_uri ( - on_this_computer, base_uri); - - /* XXX We shouldn't need this sync call here as - * set_base_uri() results in synching to GConf, - * but that happens in an idle loop and too late - * to prevent the user from seeing a "Cannot - * Open ... because of invalid URI" error. */ - e_source_list_sync (source_list, NULL); - } - - } else { - ESourceGroup *source_group; - const gchar *name; - - name = _("On This Computer"); - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - if (personal == NULL) { - ESource *source; - GSList *selected; - const gchar *name; - gchar *primary; - - name = _("Personal"); - source = e_source_new (name, PERSONAL_RELATIVE_URI); - e_source_group_add_source (on_this_computer, source, -1); - g_object_unref (source); - - primary = calendar_config_get_primary_tasks (); - selected = calendar_config_get_tasks_selected (); - - if (primary == NULL && selected == NULL) { - const gchar *uid; - - uid = e_source_peek_uid (source); - selected = g_slist_prepend (NULL, g_strdup (uid)); - - calendar_config_set_primary_tasks (uid); - calendar_config_set_tasks_selected (selected); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - g_slist_free (selected); - g_free (primary); - } - - if (on_the_web == NULL) { - ESourceGroup *source_group; - const gchar *name; - - name = _("On The Web"); - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (source_list, source_group, -1); - g_object_unref (source_group); - } - - g_free (base_uri); -} - -static void -action_task_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_task_assigned_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static void -action_task_list_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ -} - -static GtkActionEntry item_entries[] = { - - { "task-new", - "stock_task", - N_("_Task"), /* XXX Need C_() here */ - "t", - N_("Create a new task"), - G_CALLBACK (action_task_new_cb) }, - - { "task-assigned-new", - "stock_task", - N_("Assigne_d Task"), - NULL, - N_("Create a new assigned task"), - G_CALLBACK (action_task_assigned_new_cb) } -}; - -static GtkActionEntry source_entries[] = { - - { "task-list-new", - "stock_todo", - N_("Tas_k List"), - NULL, - N_("Create a new task list"), - G_CALLBACK (action_task_list_new_cb) } -}; - -static gboolean -task_module_handle_uri (EShellModule *shell_module, - const gchar *uri) -{ - /* FIXME */ - return FALSE; -} - -static void -task_module_window_created (EShellModule *shell_module, - EShellWindow *shell_window) -{ - const gchar *module_name; - - module_name = G_TYPE_MODULE (shell_module)->name; - - e_shell_window_register_new_item_actions ( - shell_window, module_name, - item_entries, G_N_ELEMENTS (item_entries)); - - e_shell_window_register_new_source_actions ( - shell_window, module_name, - source_entries, G_N_ELEMENTS (source_entries)); -} - -static EShellModuleInfo module_info = { - - MODULE_NAME, - MODULE_ALIASES, - MODULE_SCHEMES, - MODULE_SEARCHES, - MODULE_SORT_ORDER -}; - -void -e_shell_module_init (GTypeModule *type_module) -{ - EShell *shell; - EShellModule *shell_module; - - shell_module = E_SHELL_MODULE (type_module); - shell = e_shell_module_get_shell (shell_module); - - /* Register the GType for ETaskShellView. */ - e_task_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); - - task_module_ensure_sources (shell_module); - - g_signal_connect_swapped ( - shell, "handle-uri", - G_CALLBACK (task_module_handle_uri), shell_module); - - g_signal_connect_swapped ( - shell, "window-created", - G_CALLBACK (task_module_window_created), shell_module); -} diff --git a/calendar/gui/e-task-shell-sidebar.c b/calendar/gui/e-task-shell-sidebar.c deleted file mode 100644 index 0b0668df86..0000000000 --- a/calendar/gui/e-task-shell-sidebar.c +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-sidebar.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-task-shell-sidebar.h" - -#include -#include - -#include -#include -#include - -#define E_TASK_SHELL_SIDEBAR_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarPrivate)) - -struct _ETaskShellSidebarPrivate { - GtkWidget *selector; -}; - -enum { - PROP_0, - PROP_SELECTOR -}; - -static gpointer parent_class; - -static void -task_shell_sidebar_update (EShellSidebar *shell_sidebar) -{ - EShellView *shell_view; - ETasks *tasks; - ETable *table; - ECalModel *model; - ECalendarTable *cal_table; - GString *string; - const gchar *format; - gint n_rows; - gint n_selected; - - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - tasks = e_task_shell_view_get_tasks (E_TASK_SHELL_VIEW (shell_view)); - cal_table = e_tasks_get_calendar_table (tasks); - model = e_calendar_table_get_model (cal_table); - table = e_calendar_table_get_table (cal_table); - - n_rows = e_table_model_get_row_count (model); - n_selected = e_table_selected_count (table); - - string = g_string_sized_new (64); - - format = ngettext ("%d task", "%d tasks", n_rows); - g_string_append_printf (string, format, n_rows); - - if (n_selected > 0) { - format = _("%d selected"); - g_string_append_len (string, ", ", 2); - g_string_append_printf (string, format, n_selected); - } - - e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); - - g_string_free (string, TRUE); -} - -static void -task_shell_sidebar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SELECTOR: - g_value_set_object ( - value, e_task_shell_sidebar_get_selector ( - E_TASK_SHELL_SIDEBAR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -task_shell_sidebar_dispose (GObject *object) -{ - ETaskShellSidebarPrivate *priv; - - priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); - - if (priv->selector != NULL) { - g_object_unref (priv->selector); - priv->selector = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -task_shell_sidebar_constructed (GObject *object) -{ - ETaskShellSidebarPrivate *priv; - EShellView *shell_view; - EShellSidebar *shell_sidebar; - ETaskShellView *task_shell_view; - ESourceList *source_list; - GtkContainer *container; - GtkWidget *widget; - ETasks *tasks; - ETable *table; - ECalModel *model; - ECalendarTable *cal_table; - - priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); - - shell_sidebar = E_SHELL_SIDEBAR (object); - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - task_shell_view = E_TASK_SHELL_VIEW (shell_view); - source_list = e_task_shell_view_get_source_list (task_shell_view); - - container = GTK_CONTAINER (shell_sidebar); - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_container_add (container, widget); - gtk_widget_show (widget); - - container = GTK_CONTAINER (widget); - - widget = e_calendar_selector_new (source_list); - e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); - gtk_container_add (container, widget); - priv->selector = g_object_ref (widget); - gtk_widget_show (widget); - - /* Setup signal handlers. */ - - tasks = e_task_shell_view_get_tasks (task_shell_view); - cal_table = e_tasks_get_calendar_table (tasks); - model = e_calendar_table_get_model (cal_table); - table = e_calendar_table_get_table (cal_table); - - g_signal_connect_swapped ( - model, "model-changed", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-deleted", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-inserted", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "selection-change", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - task_shell_sidebar_update (shell_sidebar); -} - -static void -task_shell_sidebar_class_init (ETaskShellSidebarClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (ETaskShellSidebarPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = task_shell_sidebar_get_property; - object_class->dispose = task_shell_sidebar_dispose; - object_class->constructed = task_shell_sidebar_constructed; - - g_object_class_install_property ( - object_class, - PROP_SELECTOR, - g_param_spec_object ( - "selector", - _("Source Selector Widget"), - _("This widget displays groups of task lists"), - E_TYPE_SOURCE_SELECTOR, - G_PARAM_READABLE)); -} - -static void -task_shell_sidebar_init (ETaskShellSidebar *task_shell_sidebar) -{ - task_shell_sidebar->priv = - E_TASK_SHELL_SIDEBAR_GET_PRIVATE (task_shell_sidebar); - - /* Postpone widget construction until we have a shell view. */ -} - -GType -e_task_shell_sidebar_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (ETaskShellSidebarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) task_shell_sidebar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (ETaskShellSidebar), - 0, /* n_preallocs */ - (GInstanceInitFunc) task_shell_sidebar_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_SIDEBAR, "ETaskShellSidebar", - &type_info, 0); - } - - return type; -} - -GtkWidget * -e_task_shell_sidebar_new (EShellView *shell_view) -{ - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return g_object_new ( - E_TYPE_TASK_SHELL_SIDEBAR, - "shell-view", shell_view, NULL); -} - -GtkWidget * -e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar) -{ - g_return_val_if_fail ( - E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar), NULL); - - return task_shell_sidebar->priv->selector; -} diff --git a/calendar/gui/e-task-shell-sidebar.h b/calendar/gui/e-task-shell-sidebar.h deleted file mode 100644 index c50fde5d3c..0000000000 --- a/calendar/gui/e-task-shell-sidebar.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-sidebar.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_TASK_SHELL_SIDEBAR_H -#define E_TASK_SHELL_SIDEBAR_H - -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_TASK_SHELL_SIDEBAR \ - (e_task_shell_sidebar_get_type ()) -#define E_TASK_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebar)) -#define E_TASK_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) -#define E_IS_TASK_SHELL_SIDEBAR(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_TASK_SHELL_SIDEBAR)) -#define E_IS_TASK_SHELL_SIDEBAR_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TASK_SHELL_SIDEBAR)) -#define E_TASK_SHELL_SIDEBAR_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) - -G_BEGIN_DECLS - -typedef struct _ETaskShellSidebar ETaskShellSidebar; -typedef struct _ETaskShellSidebarClass ETaskShellSidebarClass; -typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate; - -struct _ETaskShellSidebar { - EShellSidebar parent; - ETaskShellSidebarPrivate *priv; -}; - -struct _ETaskShellSidebarClass { - EShellSidebarClass parent_class; -}; - -GType e_task_shell_sidebar_get_type (void); -GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); -GtkWidget * e_task_shell_sidebar_get_selector - (ETaskShellSidebar *task_shell_sidebar); - -G_END_DECLS - -#endif /* E_TASK_SHELL_SIDEBAR_H */ diff --git a/calendar/gui/e-task-shell-view-actions.c b/calendar/gui/e-task-shell-view-actions.c deleted file mode 100644 index ccdf86cdd1..0000000000 --- a/calendar/gui/e-task-shell-view-actions.c +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view-actions.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-task-shell-view-private.h" - -static void -action_task_assign_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_clipboard_copy_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_clipboard_cut_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_clipboard_paste_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_delete_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_forward_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_list_copy_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_list_delete_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_list_new_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_list_properties_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_mark_complete_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_open_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_preview_cb (GtkToggleAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_print_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_print_preview_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static void -action_task_purge_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ -} - -static GtkActionEntry task_entries[] = { - - { "task-assign", - NULL, - N_("_Assign Task"), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_assign_cb) }, - - { "task-clipboard-copy", - GTK_STOCK_COPY, - NULL, - NULL, - N_("Copy selected tasks"), - G_CALLBACK (action_task_clipboard_copy_cb) }, - - { "task-clipboard-cut", - GTK_STOCK_CUT, - NULL, - NULL, - N_("Cut selected tasks"), - G_CALLBACK (action_task_clipboard_cut_cb) }, - - { "task-clipboard-paste", - GTK_STOCK_PASTE, - NULL, - NULL, - N_("Paste tasks from the clipboard"), - G_CALLBACK (action_task_clipboard_paste_cb) }, - - { "task-delete", - GTK_STOCK_DELETE, - NULL, - NULL, - N_("Delete selected tasks"), - G_CALLBACK (action_task_delete_cb) }, - - { "task-forward", - "mail-forward", - N_("_Forward as iCalendar"), - "f", - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_forward_cb) }, - - { "task-list-copy", - GTK_STOCK_COPY, - N_("Copy..."), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_list_copy_cb) }, - - { "task-list-delete", - GTK_STOCK_DELETE, - N_("_Delete"), - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_list_delete_cb) }, - - { "task-list-new", - "stock_todo", - N_("_New Task List"), - NULL, - N_("Create a new task list"), - G_CALLBACK (action_task_list_new_cb) }, - - { "task-list-properties", - GTK_STOCK_PROPERTIES, - NULL, - NULL, - NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_list_properties_cb) }, - - { "task-mark-complete", - NULL, - N_("Mar_k as Complete"), - "k", - N_("Mark selected tasks as complete"), - G_CALLBACK (action_task_mark_complete_cb) }, - - { "task-open", - NULL, - N_("_Open Task"), - "o", - N_("View the selected task"), - G_CALLBACK (action_task_open_cb) }, - - { "task-print", - GTK_STOCK_PRINT, - NULL, - NULL, - N_("Print the list of tasks"), - G_CALLBACK (action_task_print_cb) }, - - { "task-print-preview", - GTK_STOCK_PRINT_PREVIEW, - NULL, - NULL, - N_("Preview the list of tasks to be printed"), - G_CALLBACK (action_task_print_preview_cb) }, - - { "task-purge", - NULL, - N_("Purg_e"), - "e", - N_("Delete completed tasks"), - G_CALLBACK (action_task_purge_cb) } -}; - -static GtkToggleActionEntry task_toggle_entries[] = { - - { "task-preview", - NULL, - N_("Task _Preview"), - "m", - N_("Show task preview pane"), - G_CALLBACK (action_task_preview_cb), - TRUE } -}; - -void -e_task_shell_view_actions_init (ETaskShellView *task_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - GtkActionGroup *action_group; - GtkUIManager *manager; - const gchar *domain; - - shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); - domain = GETTEXT_PACKAGE; - - e_load_ui_definition (manager, "evolution-tasks.ui"); - - action_group = task_shell_view->priv->task_actions; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_action_group_add_actions ( - action_group, task_entries, - G_N_ELEMENTS (task_entries), task_shell_view); - gtk_action_group_add_toggle_actions ( - action_group, task_toggle_entries, - G_N_ELEMENTS (task_toggle_entries), task_shell_view); - gtk_ui_manager_insert_action_group (manager, action_group, 0); -} diff --git a/calendar/gui/e-task-shell-view-actions.h b/calendar/gui/e-task-shell-view-actions.h deleted file mode 100644 index 9c31590814..0000000000 --- a/calendar/gui/e-task-shell-view-actions.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view-actions.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_TASK_SHELL_VIEW_ACTIONS_H -#define E_TASK_SHELL_VIEW_ACTIONS_H - -#include - -/* Task Actions */ -#define E_SHELL_WINDOW_ACTION_TASK_ASSIGN(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-assign") -#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_COPY(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-clipboard-copy") -#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_CUT(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-clibpard-cut") -#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_PASTE(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-clipboard-paste") -#define E_SHELL_WINDOW_ACTION_TASK_DELETE(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-delete") -#define E_SHELL_WINDOW_ACTION_TASK_FORWARD(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-forward") -#define E_SHELL_WINDOW_ACTION_TASK_MARK_COMPLETE(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-mark-complete") -#define E_SHELL_WINDOW_ACTION_TASK_OPEN(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-open") -#define E_SHELL_WINDOW_ACTION_TASK_PREVIEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-preview") -#define E_SHELL_WINDOW_ACTION_TASK_PRINT(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-print") -#define E_SHELL_WINDOW_ACTION_TASK_PRINT_PREVIEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-print-preview") -#define E_SHELL_WINDOW_ACTION_TASK_PURGE(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-purge") - -/* Action Groups */ -#define E_SHELL_WINDOW_ACTION_GROUP_TASKS(window) \ - E_SHELL_WINDOW_ACTION_GROUP ((window), "tasks") - -#endif /* E_TASK_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/gui/e-task-shell-view-private.c b/calendar/gui/e-task-shell-view-private.c deleted file mode 100644 index e41b1fb5bc..0000000000 --- a/calendar/gui/e-task-shell-view-private.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view-private.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-task-shell-view-private.h" - -void -e_task_shell_view_private_init (ETaskShellView *task_shell_view, - EShellViewClass *shell_view_class) -{ - ETaskShellViewPrivate *priv = task_shell_view->priv; - ESourceList *source_list; - GObject *object; - - object = G_OBJECT (shell_view_class->type_module); - source_list = g_object_get_data (object, "source-list"); - g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - - priv->source_list = g_object_ref (source_list); - priv->task_actions = gtk_action_group_new ("tasks"); -} - -void -e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) -{ - ETaskShellViewPrivate *priv = task_shell_view->priv; -} - -void -e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) -{ - ETaskShellViewPrivate *priv = task_shell_view->priv; - - DISPOSE (priv->source_list); - - DISPOSE (priv->task_actions); -} - -void -e_task_shell_view_private_finalize (ETaskShellView *task_shell_view) -{ - ETaskShellViewPrivate *priv = task_shell_view->priv; -} diff --git a/calendar/gui/e-task-shell-view-private.h b/calendar/gui/e-task-shell-view-private.h deleted file mode 100644 index 0c7f90c3be..0000000000 --- a/calendar/gui/e-task-shell-view-private.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view-private.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_TASK_SHELL_VIEW_PRIVATE_H -#define E_TASK_SHELL_VIEW_PRIVATE_H - -#include "e-task-shell-view.h" - -#include - -#include -#include - -#include -#include - -#define E_TASK_SHELL_VIEW_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewPrivate)) - -/* Shorthand, requires a variable named "shell_window". */ -#define ACTION(name) \ - (E_SHELL_WINDOW_ACTION_##name (shell_window)) -#define ACTION_GROUP(name) \ - (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) - -/* For use in dispose() methods. */ -#define DISPOSE(obj) \ - G_STMT_START { \ - if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ - } G_STMT_END - -G_BEGIN_DECLS - -struct _ETaskShellViewPrivate { - - /*** Module Data ***/ - - ESourceList *source_list; - - /*** UI Management ***/ - - GtkActionGroup *task_actions; -}; - -void e_task_shell_view_private_init - (ETaskShellView *task_shell_view, - EShellViewClass *shell_view_class); -void e_task_shell_view_private_constructed - (ETaskShellView *task_shell_view); -void e_task_shell_view_private_dispose - (ETaskShellView *task_shell_view); -void e_task_shell_view_private_finalize - (ETaskShellView *task_shell_view); - -/* Private Utilities */ - -void e_task_shell_view_actions_init - (ETaskShellView *task_shell_view); - -G_END_DECLS - -#endif /* E_TASK_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/gui/e-task-shell-view.c b/calendar/gui/e-task-shell-view.c deleted file mode 100644 index 6be8b48a4c..0000000000 --- a/calendar/gui/e-task-shell-view.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "e-task-shell-view-private.h" - -enum { - PROP_0, - PROP_SOURCE_LIST -}; - -GType e_task_shell_view_type = 0; -static gpointer parent_class; - -static void -task_shell_view_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SOURCE_LIST: - g_value_set_object ( - value, e_task_shell_view_get_source_list ( - E_TASK_SHELL_VIEW (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -task_shell_view_dispose (GObject *object) -{ - e_task_shell_view_private_dispose (E_TASK_SHELL_VIEW (object)); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -task_shell_view_finalize (GObject *object) -{ - e_task_shell_view_private_finalize (E_TASK_SHELL_VIEW (object)); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -task_shell_view_constructed (GObject *object) -{ - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); - - e_task_shell_view_private_constructed (E_TASK_SHELL_VIEW (object)); -} - -static void -task_shell_view_changed (EShellView *shell_view) -{ - ETaskShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; - - priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view); - - action_group = priv->task_actions; - visible = e_shell_view_is_selected (shell_view); - gtk_action_group_set_visible (action_group, visible); -} - -static void -task_shell_view_class_init (ETaskShellView *class, - GTypeModule *type_module) -{ - GObjectClass *object_class; - EShellViewClass *shell_view_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (ETaskShellViewPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->get_property = task_shell_view_get_property; - object_class->dispose = task_shell_view_dispose; - object_class->finalize = task_shell_view_finalize; - object_class->constructed = task_shell_view_constructed; - - shell_view_class = E_SHELL_VIEW_CLASS (class); - shell_view_class->label = N_("Tasks"); - shell_view_class->icon_name = "evolution-tasks"; - shell_view_class->type_module = type_module; - shell_view_class->changed = task_shell_view_changed; - shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new; - - g_object_class_install_property ( - object_class, - PROP_SOURCE_LIST, - g_param_spec_object ( - "source-list", - _("Source List"), - _("The registry of task lists"), - E_TYPE_SOURCE_LIST, - G_PARAM_READABLE)); -} - -static void -task_shell_view_init (ETaskShellView *task_shell_view, - EShellViewClass *shell_view_class) -{ - task_shell_view->priv = - E_TASK_SHELL_VIEW_GET_PRIVATE (task_shell_view); - - e_task_shell_view_private_init (task_shell_view, shell_view_class); -} - -GType -e_task_shell_view_get_type (GTypeModule *type_module) -{ - if (e_task_shell_view_type == 0) { - const GTypeInfo type_info = { - sizeof (ETaskShellViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) task_shell_view_class_init, - (GClassFinalizeFunc) NULL, - type_module, - sizeof (ETaskShellView), - 0, /* n_preallocs */ - (GInstanceInitFunc) task_shell_view_init, - NULL /* value_table */ - }; - - e_task_shell_view_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_VIEW, - "ETaskShellView", &type_info, 0); - } - - return e_task_shell_view_type; -} - -ESourceList * -e_task_shell_view_get_source_list (ETaskShellView *task_shell_view) -{ - g_return_val_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view), NULL); - - return task_shell_view->priv->source_list; -} diff --git a/calendar/gui/e-task-shell-view.h b/calendar/gui/e-task-shell-view.h deleted file mode 100644 index 785a3585b1..0000000000 --- a/calendar/gui/e-task-shell-view.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-shell-view.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef E_TASK_SHELL_VIEW_H -#define E_TASK_SHELL_VIEW_H - -#include -#include - -/* Standard GObject macros */ -#define E_TYPE_TASK_SHELL_VIEW \ - (e_task_shell_view_type) -#define E_TASK_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellView)) -#define E_TASK_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewClass)) -#define E_IS_TASK_SHELL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_TASK_SHELL_VIEW)) -#define E_IS_TASK_SHELL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TASK_SHELL_VIEW)) -#define E_TASK_SHELL_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewClass)) - -G_BEGIN_DECLS - -extern GType e_task_shell_view_type; - -typedef struct _ETaskShellView ETaskShellView; -typedef struct _ETaskShellViewClass ETaskShellViewClass; -typedef struct _ETaskShellViewPrivate ETaskShellViewPrivate; - -struct _ETaskShellView { - EShellView parent; - ETaskShellViewPrivate *priv; -}; - -struct _ETaskShellViewClass { - EShellViewClass parent_class; -}; - -GType e_task_shell_view_get_type - (GTypeModule *type_module); -ESourceList * e_task_shell_view_get_source_list - (ETaskShellView *task_shell_view); - -G_END_DECLS - -#endif /* E_TASK_SHELL_VIEW_H */ diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index b866439413..732f031c1c 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -109,16 +109,6 @@ enum { LAST_SIGNAL }; -enum DndTargetType { - TARGET_VCALENDAR -}; - -static GtkTargetEntry list_drag_types[] = { - { "text/calendar", 0, TARGET_VCALENDAR }, - { "text/x-calendar", 0, TARGET_VCALENDAR } -}; -static const int num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]); - static guint e_tasks_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (ETasks, e_tasks, GTK_TYPE_TABLE) diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 4d65f094b8..b20781186f 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -44,12 +44,10 @@ #include #include -#include "shell/e-user-creatable-items-handler.h" #include #include #include #include -#include "widgets/menus/gal-view-menus.h" #include "e-util/e-error.h" #include "e-util/e-util-private.h" #include "e-comp-editor-registry.h" @@ -57,7 +55,6 @@ #include "dialogs/event-editor.h" #include "dialogs/task-editor.h" #include "comp-util.h" -#include "e-calendar-marshal.h" #include "e-cal-model-calendar.h" #include "e-day-view.h" #include "e-day-view-config.h" @@ -69,10 +66,7 @@ #include "e-mini-calendar-config.h" #include "e-calendar-table-config.h" #include "e-memo-table-config.h" -#include "evolution-calendar.h" #include "gnome-cal.h" -#include "calendar-component.h" -#include "memos-component.h" #include "cal-search-bar.h" #include "calendar-commands.h" #include "calendar-config.h" @@ -86,11 +80,6 @@ #include "e-cal-menu.h" #include "e-cal-model-tasks.h" -/* FIXME glib 2.4 and above has this */ -#ifndef G_MAXINT32 -#define G_MAXINT32 ((gint32) 0x7fffffff) -#endif - #define d(x) x /* Private part of the GnomeCalendar structure */ @@ -369,7 +358,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GnomeCalendarClass, source_added), NULL, NULL, - e_calendar_marshal_VOID__INT_OBJECT, + e_marshal_VOID__INT_OBJECT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_OBJECT); @@ -380,7 +369,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GnomeCalendarClass, source_removed), NULL, NULL, - e_calendar_marshal_VOID__INT_OBJECT, + e_marshal_VOID__INT_OBJECT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_OBJECT); diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 820c29c9f9..2a3fab8b42 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -62,8 +62,6 @@ #define CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_ConfigControl:" BASE_VERSION #define COMP_EDITOR_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_CompEditorFactory:" BASE_VERSION -ECompEditorRegistry *comp_editor_registry = NULL; - /* The component editor factory */ static CompEditorFactory *comp_editor_factory = NULL; diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index 4927dde9db..fb3bb451d9 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -65,10 +65,6 @@ static BonoboObjectClass *parent_class = NULL; -/* Memos should have their own registry */ -extern ECompEditorRegistry *comp_editor_registry; - - typedef struct _MemosComponentView { ESourceList *source_list; @@ -79,7 +75,6 @@ typedef struct _MemosComponentView ETable *table; ETableModel *model; - EInfoLabel *info_label; GtkWidget *source_selector; BonoboControl *view_control; @@ -88,9 +83,6 @@ typedef struct _MemosComponentView GList *notifications; - EUserCreatableItemsHandler *creatable_items_handler; - - EActivityHandler *activity_handler; } MemosComponentView; struct _MemosComponentPrivate { @@ -733,15 +725,6 @@ create_local_item_cb (EUserCreatableItemsHandler *handler, const char *item_type priv = memos_component->priv; - for (l = priv->views; l; l = l->next) { - component_view = l->data; - - if (component_view->creatable_items_handler == handler) - break; - - component_view = NULL; - } - if (strcmp (item_type_name, CREATE_MEMO_ID) == 0) { create_new_memo (memos_component, FALSE, component_view); } else if (strcmp (item_type_name, CREATE_SHARED_MEMO_ID) == 0) { @@ -787,8 +770,6 @@ create_component_view (MemosComponent *memos_component) g_signal_connect (component_view->memos, "source_removed", G_CALLBACK (source_removed_cb), component_view); - e_memo_table_set_activity_handler (e_memos_get_calendar_table (component_view->memos), component_view->activity_handler); - /* connect after setting the initial selections, or we'll get unwanted calls to calendar_control_sensitize_calendar_commands */ g_signal_connect (component_view->source_selector, "selection_changed", @@ -820,68 +801,9 @@ destroy_component_view (MemosComponentView *component_view) calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); g_list_free (component_view->notifications); - if (component_view->creatable_items_handler) - g_object_unref (component_view->creatable_items_handler); - - if (component_view->activity_handler) - g_object_unref (component_view->activity_handler); - g_free (component_view); } -static void -view_destroyed_cb (gpointer data, GObject *where_the_object_was) -{ - MemosComponent *memos_component = data; - MemosComponentPrivate *priv; - GList *l; - - priv = memos_component->priv; - - for (l = priv->views; l; l = l->next) { - MemosComponentView *component_view = l->data; - - if (G_OBJECT (component_view->view_control) == where_the_object_was) { - priv->views = g_list_remove (priv->views, component_view); - destroy_component_view (component_view); - - break; - } - } -} - -static GNOME_Evolution_ComponentView -impl_createView (PortableServer_Servant servant, - GNOME_Evolution_ShellView parent, - CORBA_boolean select_item, - CORBA_Environment *ev) -{ - MemosComponent *component = MEMOS_COMPONENT (bonobo_object_from_servant (servant)); - MemosComponentPrivate *priv; - MemosComponentView *component_view; - EComponentView *ecv; - - priv = component->priv; - - /* Create the calendar component view */ - component_view = create_component_view (component); - if (!component_view) { - /* FIXME Should we describe the problem in a control? */ - bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); - - return CORBA_OBJECT_NIL; - } - - g_object_weak_ref (G_OBJECT (component_view->view_control), view_destroyed_cb, component); - priv->views = g_list_append (priv->views, component_view); - - /* TODO: Make CalendarComponentView just subclass EComponentView */ - ecv = e_component_view_new_controls (parent, "memos", component_view->sidebar_control, - component_view->view_control, component_view->statusbar_control); - - return BONOBO_OBJREF(ecv); -} - static void impl_requestCreateItem (PortableServer_Servant servant, const CORBA_char *item_type_name, @@ -928,14 +850,6 @@ impl_dispose (GObject *object) priv->create_ecal = NULL; } - for (l = priv->views; l; l = l->next) { - MemosComponentView *component_view = l->data; - - g_object_weak_unref (G_OBJECT (component_view->view_control), view_destroyed_cb, memos_component); - } - g_list_free (priv->views); - priv->views = NULL; - for (l = priv->notifications; l; l = l->next) calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); g_list_free (priv->notifications); @@ -944,24 +858,6 @@ impl_dispose (GObject *object) (* G_OBJECT_CLASS (parent_class)->dispose) (object); } -static void -impl_finalize (GObject *object) -{ - MemosComponentPrivate *priv = MEMOS_COMPONENT (object)->priv; - GList *l; - - for (l = priv->views; l; l = l->next) { - MemosComponentView *component_view = l->data; - - destroy_component_view (component_view); - } - g_list_free (priv->views); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - static void memos_component_class_init (MemosComponentClass *klass) { @@ -971,21 +867,7 @@ memos_component_class_init (MemosComponentClass *klass) parent_class = g_type_class_peek_parent (klass); epv->upgradeFromVersion = impl_upgradeFromVersion; - epv->createView = impl_createView; epv->requestCreateItem = impl_requestCreateItem; object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; } - -static void -memos_component_init (MemosComponent *component, MemosComponentClass *klass) -{ - MemosComponentPrivate *priv; - - priv = g_new0 (MemosComponentPrivate, 1); - - component->priv = priv; -} - -BONOBO_TYPE_FUNC_FULL (MemosComponent, GNOME_Evolution_Component, PARENT_TYPE, memos_component) diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 9100183048..83e65d4966 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -64,10 +64,6 @@ static BonoboObjectClass *parent_class = NULL; -/* Tasks should have their own registry */ -extern ECompEditorRegistry *comp_editor_registry; - - typedef struct { ESourceList *source_list; diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index 40e5c1e107..fbd1f6676a 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -56,36 +56,15 @@ static void tasks_control_activate_cb (BonoboControl *control, gboolean activate, gpointer user_data); -static void tasks_control_open_task_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); static void tasks_control_new_task_cmd (BonoboUIComponent *uic, gpointer data, const char *path); -static void tasks_control_cut_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void tasks_control_copy_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void tasks_control_paste_cmd (BonoboUIComponent *uic, - gpointer data, - const gchar *path); -static void tasks_control_delete_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); static void tasks_control_complete_cmd (BonoboUIComponent *uic, gpointer data, const char *path); static void tasks_control_purge_cmd (BonoboUIComponent *uic, gpointer data, const char *path); -static void tasks_control_print_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); -static void tasks_control_print_preview_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path); static void tasks_control_assign_cmd (BonoboUIComponent *uic, gpointer data, const char *path); @@ -94,12 +73,6 @@ static void tasks_control_forward_cmd (BonoboUIComponent *uic, gpointer data, const char *path); -static void tasks_control_view_preview (BonoboUIComponent *uic, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - void *data); - BonoboControl * tasks_control_new (void) { @@ -234,16 +207,9 @@ selection_changed_cb (ETasks *tasks, int n_selected, gpointer data) } static BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("TasksOpenTask", tasks_control_open_task_cmd), BONOBO_UI_VERB ("TasksNewTask", tasks_control_new_task_cmd), - BONOBO_UI_VERB ("TasksCut", tasks_control_cut_cmd), - BONOBO_UI_VERB ("TasksCopy", tasks_control_copy_cmd), - BONOBO_UI_VERB ("TasksPaste", tasks_control_paste_cmd), - BONOBO_UI_VERB ("TasksDelete", tasks_control_delete_cmd), BONOBO_UI_VERB ("TasksMarkComplete", tasks_control_complete_cmd), BONOBO_UI_VERB ("TasksPurge", tasks_control_purge_cmd), - BONOBO_UI_VERB ("TasksPrint", tasks_control_print_cmd), - BONOBO_UI_VERB ("TasksPrintPreview", tasks_control_print_preview_cmd), BONOBO_UI_VERB ("TasksAssign", tasks_control_assign_cmd), BONOBO_UI_VERB ("TasksForward", tasks_control_forward_cmd), BONOBO_UI_VERB_END @@ -329,16 +295,6 @@ tasks_control_deactivate (BonoboControl *control, ETasks *tasks) bonobo_ui_component_unset_container (uic, NULL); } -static void tasks_control_open_task_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - - tasks = E_TASKS (data); - e_tasks_open_task (tasks); -} - static void tasks_control_new_task_cmd (BonoboUIComponent *uic, gpointer data, @@ -350,56 +306,6 @@ tasks_control_new_task_cmd (BonoboUIComponent *uic, e_tasks_new_task (tasks); } -static void -tasks_control_cut_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - ECalendarTable *cal_table; - - tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - e_calendar_table_cut_clipboard (cal_table); -} - -static void -tasks_control_copy_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - ECalendarTable *cal_table; - - tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - e_calendar_table_copy_clipboard (cal_table); -} - -static void -tasks_control_paste_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - ECalendarTable *cal_table; - - tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - e_calendar_table_paste_clipboard (cal_table); -} - -static void -tasks_control_delete_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - - tasks = E_TASKS (data); - e_tasks_delete_selected (tasks); -} - static void tasks_control_complete_cmd (BonoboUIComponent *uic, gpointer data, @@ -457,39 +363,6 @@ tasks_control_purge_cmd (BonoboUIComponent *uic, e_tasks_delete_completed (tasks); } -/* File/Print callback */ -static void -tasks_control_print_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks = E_TASKS (data); - ETable *table; - - table = e_calendar_table_get_table ( - E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks))); - - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); -} - -static void -tasks_control_print_preview_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks = E_TASKS (data); - ETable *table; - - table = e_calendar_table_get_table ( - E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks))); - - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); -} - static void tasks_control_assign_cmd (BonoboUIComponent *uic, gpointer data, @@ -526,17 +399,3 @@ tasks_control_forward_cmd (BonoboUIComponent *uic, g_object_unref (comp); } } - -static void -tasks_control_view_preview (BonoboUIComponent *uic, const char *path, Bonobo_UIComponent_EventType type, const char *state, void *data) -{ - ETasks *tasks; - - if (type != Bonobo_UIComponent_STATE_CHANGED) - return; - - tasks = E_TASKS (data); - - calendar_config_set_preview_state (state[0] != '0'); - e_tasks_show_preview (tasks, state[0] != '0'); -} diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c new file mode 100644 index 0000000000..7df23a92f3 --- /dev/null +++ b/calendar/modules/e-cal-shell-module.c @@ -0,0 +1,399 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-module.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#define MODULE_NAME "calendar" +#define MODULE_ALIASES "" +#define MODULE_SCHEMES "calendar" +#define MODULE_SEARCHES "caltypes.xml" +#define MODULE_SORT_ORDER 400 + +#define CONTACTS_BASE_URI "contacts://" +#define WEATHER_BASE_URI "weather://" +#define WEB_BASE_URI "webcal://" +#define PERSONAL_RELATIVE_URI "system" + +/* Module Entry Point */ +void e_shell_module_init (GTypeModule *type_module); + +static void +cal_module_ensure_sources (EShellModule *shell_module) +{ + /* XXX This is basically the same algorithm across all modules. + * Maybe we could somehow integrate this into EShellModule? */ + + ESourceList *source_list; + ESourceGroup *on_this_computer; + ESourceGroup *on_the_web; + ESourceGroup *contacts; + ESourceGroup *weather; + ESource *birthdays; + ESource *personal; + GSList *groups, *iter; + const gchar *data_dir; + gchar *base_uri; + gchar *filename; + gchar *property; + + on_this_computer = NULL; + on_the_web = NULL; + contacts = NULL; + weather = NULL; + birthdays = NULL; + personal = NULL; + + if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) { + g_warning ("Could not get calendar sources from GConf!"); + return; + } + + /* Share the source list with all calendar views. This + * is accessible via e_cal_shell_view_get_source_list(). + * Note: EShellModule takes ownership of the reference. + * + * XXX I haven't yet decided if I want to add a proper + * EShellModule API for this. The mail module would + * not use it. */ + g_object_set_data_full ( + G_OBJECT (shell_module), "source-list", + source_list, (GDestroyNotify) g_object_unref); + + data_dir = e_shell_module_get_data_dir (shell_module); + filename = g_build_filename (data_dir, "local", NULL); + base_uri = g_filename_to_uri (filename, NULL, NULL); + g_free (filename); + + groups = e_source_list_peek_groups (source_list); + for (iter = groups; iter != NULL; iter = iter->next) { + ESourceGroup *source_group = iter->data; + const gchar *group_base_uri; + + group_base_uri = e_source_group_peek_base_uri (source_group); + + /* Compare only "file://" part. if the user's home + * changes, we do not want to create another group. */ + if (on_this_computer == NULL && + strncmp (base_uri, group_base_uri, 7) == 0) + on_this_computer = source_group; + + else if (on_the_web == NULL && + strcmp (WEB_BASE_URI, group_base_uri) == 0) + on_the_web = source_group; + + else if (contacts == NULL && + strcmp (CONTACTS_BASE_URI, group_base_uri) == 0) + contacts = source_group; + + else if (weather == NULL && + strcmp (WEATHER_BASE_URI, group_base_uri) == 0) + weather = source_group; + } + + if (on_this_computer != NULL) { + GSList *sources; + const gchar *group_base_uri; + + sources = e_source_group_peek_sources (on_this_computer); + group_base_uri = e_source_group_peek_base_uri (on_this_computer); + + /* Make sure this group includes a "Personal" source. */ + for (iter = sources; iter != NULL; iter = iter->next) { + ESource *source = iter->data; + const gchar *relative_uri; + + relative_uri = e_source_peek_relative_uri (source); + if (relative_uri == NULL) + continue; + + if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) + continue; + + personal = source; + break; + } + + /* Make sure we have the correct base URI. This can + * change when the user's home directory changes. */ + if (strcmp (base_uri, group_base_uri) != 0) { + e_source_group_set_base_uri ( + on_this_computer, base_uri); + + /* XXX We shouldn't need this sync call here as + * set_base_uri() results in synching to GConf, + * but that happens in an idle loop and too late + * to prevent the user from seeing a "Cannot + * Open ... because of invalid URI" error. */ + e_source_list_sync (source_list, NULL); + } + + } else { + ESourceGroup *source_group; + const gchar *name; + + name = _("On This Computer"); + source_group = e_source_group_new (name, base_uri); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + if (personal == NULL) { + ESource *source; + GSList *selected; + const gchar *name; + gchar *primary; + + name = _("Personal"); + source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_group_add_source (on_this_computer, source, -1); + g_object_unref (source); + + primary = calendar_config_get_primary_calendar (); + selected = calendar_config_get_calendars_selected (); + + if (primary == NULL && selected == NULL) { + const gchar *uid; + + uid = e_source_peek_uid (source); + selected = g_slist_prepend (NULL, g_strdup (uid)); + + calendar_config_set_primary_calendar (uid); + calendar_config_set_calendars_selected (selected); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + g_slist_free (selected); + g_free (primary); + } + + if (on_the_web == NULL) { + ESourceGroup *source_group; + const gchar *name; + + name = _("On The Web"); + source_group = e_source_group_new (name, WEB_BASE_URI); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + if (contacts != NULL) { + GSList *sources; + + sources = e_source_group_peek_sources (contacts); + + if (sources != NULL) { + GSList *trash; + + /* There is only one source under Contacts. */ + birthdays = E_SOURCE (sources->data); + sources = g_slist_next (sources); + + /* Delete any other sources in this group. + * Earlier versions allowed you to create + * additional sources under Contacts. */ + trash = g_slist_copy (sources); + while (trash != NULL) { + ESource *source = trash->data; + e_source_group_remove_source (contacts, source); + trash = g_slist_delete_link (trash, trash); + } + + } + } else { + ESourceGroup *source_group; + const gchar *name; + + name = _("Contacts"); + source_group = e_source_group_new (name, CONTACTS_BASE_URI); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + + /* This is now a borrowed reference. */ + contacts = source_group; + } + + /* XXX e_source_group_get_property() returns a newly-allocated + * string when it could just as easily return a const string. + * Unfortunately, fixing that would break the API. */ + property = e_source_group_get_property (contacts, "create_source"); + if (property == NULL) + e_source_group_set_property (contacts, "create_source", "no"); + g_free (property); + + if (birthdays == NULL) { + ESource *source; + const gchar *name; + + name = _("Birthdays & Anniversaries"); + source = e_source_new (name, "/"); + e_source_group_add_source (contacts, source, -1); + g_object_unref (source); + + /* This is now a borrowed reference. */ + birthdays = source; + } + + if (e_source_get_property (birthdays, "delete") == NULL) + e_source_set_property (birthdays, "delete", "no"); + + if (e_source_peek_color_spec (birthdays) == NULL) + e_source_set_color_spec (birthdays, "#DDBECE"); + + if (weather == NULL) { + ESourceGroup *source_group; + const gchar *name; + + name = _("Weather"); + source_group = e_source_group_new (name, WEATHER_BASE_URI); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + g_free (base_uri); +} + +static void +action_appointment_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_appointment_all_day_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_meeting_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_calendar_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static GtkActionEntry item_entries[] = { + + { "appointment-new", + "appointment-new", + N_("_Appointment"), /* XXX Need C_() here */ + "a", + N_("Create a new appointment"), + G_CALLBACK (action_appointment_new_cb) }, + + { "appointment-all-day-new", + "stock_new-24h-appointment", + N_("All Day A_ppointment"), + NULL, + N_("Create a new all-day appointment"), + G_CALLBACK (action_appointment_all_day_new_cb) }, + + { "meeting-new", + "stock_new-meeting", + N_("M_eeting"), + "e", + N_("Create a new meeting request"), + G_CALLBACK (action_meeting_new_cb) } +}; + +static GtkActionEntry source_entries[] = { + + { "calendar-new", + "x-office-calendar", + N_("Cale_ndar"), + NULL, + N_("Create a new calendar"), + G_CALLBACK (action_calendar_new_cb) } +}; + +static gboolean +cal_module_handle_uri (EShellModule *shell_module, + const gchar *uri) +{ + /* FIXME */ + return FALSE; +} + +static void +cal_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window) +{ + const gchar *module_name; + + module_name = G_TYPE_MODULE (shell_module)->name; + + e_shell_window_register_new_item_actions ( + shell_window, module_name, + item_entries, G_N_ELEMENTS (item_entries)); + + e_shell_window_register_new_source_actions ( + shell_window, module_name, + source_entries, G_N_ELEMENTS (source_entries)); +} + +static EShellModuleInfo module_info = { + + MODULE_NAME, + MODULE_ALIASES, + MODULE_SCHEMES, + MODULE_SEARCHES, + MODULE_SORT_ORDER +}; + +void +e_shell_module_init (GTypeModule *type_module) +{ + EShell *shell; + EShellModule *shell_module; + + shell_module = E_SHELL_MODULE (type_module); + shell = e_shell_module_get_shell (shell_module); + + /* Register the GType for ECalShellView. */ + e_cal_shell_view_get_type (type_module); + + e_shell_module_set_info (shell_module, &module_info); + + cal_module_ensure_sources (shell_module); + + g_signal_connect_swapped ( + shell, "handle-uri", + G_CALLBACK (cal_module_handle_uri), shell_module); + + g_signal_connect_swapped ( + shell, "window-created", + G_CALLBACK (cal_module_window_created), shell_module); +} diff --git a/calendar/modules/e-cal-shell-sidebar.c b/calendar/modules/e-cal-shell-sidebar.c new file mode 100644 index 0000000000..5d14f589f0 --- /dev/null +++ b/calendar/modules/e-cal-shell-sidebar.c @@ -0,0 +1,331 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-sidebar.h" + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define E_CAL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarPrivate)) + +struct _ECalShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +static void +cal_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + GnomeCalendar *calendar; + GnomeCalendarViewType view; + time_t start_time, end_time; + struct tm start_tm, end_tm; + struct icaltimetype start_tt, end_tt; + icaltimezone *timezone; + gchar buffer[512]; + gchar end_buffer[512]; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + calendar = e_cal_shell_view_get_calendar ( + E_CAL_SHELL_VIEW (shell_view)); + + gnome_calendar_get_visible_time_range ( + calendar, &start_time, &end_time); + timezone = gnome_calendar_get_timezone (calendar); + view = gnome_calendar_get_view (calendar); + + start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); + start_tm.tm_year = start_tt.year - 1900; + start_tm.tm_mon = start_tt.month - 1; + start_tm.tm_mday = start_tt.day; + start_tm.tm_hour = start_tt.hour; + start_tm.tm_min = start_tt.minute; + start_tm.tm_sec = start_tt.second; + start_tm.tm_isdst = -1; + start_tm.tm_wday = time_day_of_week ( + start_tt.day, start_tt.month - 1, start_tt.year); + + /* Subtract one from end_time so we don't get an extra day. */ + end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone); + end_tm.tm_year = end_tt.year - 1900; + end_tm.tm_mon = end_tt.month - 1; + end_tm.tm_mday = end_tt.day; + end_tm.tm_hour = end_tt.hour; + end_tm.tm_min = end_tt.minute; + end_tm.tm_sec = end_tt.second; + end_tm.tm_isdst = -1; + end_tm.tm_wday = time_day_of_week ( + end_tt.day, end_tt.month - 1, end_tt.year); + + switch (view) { + case GNOME_CAL_DAY_VIEW: + case GNOME_CAL_WORK_WEEK_VIEW: + case GNOME_CAL_WEEK_VIEW: + if (start_tm.tm_year == end_tm.tm_year && + start_tm.tm_mon == end_tm.tm_mon && + start_tm.tm_mday == end_tm.tm_mday) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%A %d %b %Y"), &start_tm); + } else if (start_tm.tm_year == end_tm.tm_year) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + case GNOME_CAL_MONTH_VIEW: + case GNOME_CAL_LIST_VIEW: + if (start_tm.tm_year == end_tm.tm_year) { + if (start_tm.tm_mon == end_tm.tm_mon) { + e_utf8_strftime ( + buffer, + sizeof (buffer), + "%d", &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, + sizeof (buffer), + _("%d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + default: + g_return_if_reached (); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, buffer); +} + +static void +cal_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_cal_shell_sidebar_get_selector ( + E_CAL_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_shell_sidebar_dispose (GObject *object) +{ + ECalShellSidebarPrivate *priv; + + priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +cal_shell_sidebar_constructed (GObject *object) +{ + ECalShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + ECalShellView *cal_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + GnomeCalendar *calendar; + + priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + cal_shell_view = E_CAL_SHELL_VIEW (shell_view); + source_list = e_cal_shell_view_get_source_list (cal_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + + /* Setup signal handlers. */ + + calendar = e_cal_shell_view_get_calendar (cal_shell_view); + + g_signal_connect_swapped ( + calendar, "dates-shown-changed", + G_CALLBACK (cal_shell_sidebar_update), + shell_sidebar); + + cal_shell_sidebar_update (shell_sidebar); +} + +static void +cal_shell_sidebar_class_init (ECalShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = cal_shell_sidebar_get_property; + object_class->dispose = cal_shell_sidebar_dispose; + object_class->constructed = cal_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of calendars"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +cal_shell_sidebar_init (ECalShellSidebar *cal_shell_sidebar) +{ + cal_shell_sidebar->priv = + E_CAL_SHELL_SIDEBAR_GET_PRIVATE (cal_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_cal_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) cal_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) cal_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "ECalShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_cal_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_CAL_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +GtkWidget * +e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL); + + return cal_shell_sidebar->priv->selector; +} diff --git a/calendar/modules/e-cal-shell-sidebar.h b/calendar/modules/e-cal-shell-sidebar.h new file mode 100644 index 0000000000..89eaee7613 --- /dev/null +++ b/calendar/modules/e-cal-shell-sidebar.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_SIDEBAR_H +#define E_CAL_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_CAL_SHELL_SIDEBAR \ + (e_cal_shell_sidebar_get_type ()) +#define E_CAL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebar)) +#define E_CAL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) +#define E_IS_CAL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR)) +#define E_IS_CAL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CAL_SHELL_SIDEBAR)) +#define E_CAL_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _ECalShellSidebar ECalShellSidebar; +typedef struct _ECalShellSidebarClass ECalShellSidebarClass; +typedef struct _ECalShellSidebarPrivate ECalShellSidebarPrivate; + +struct _ECalShellSidebar { + EShellSidebar parent; + ECalShellSidebarPrivate *priv; +}; + +struct _ECalShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_cal_shell_sidebar_get_type (void); +GtkWidget * e_cal_shell_sidebar_new (EShellView *shell_view); +GtkWidget * e_cal_shell_sidebar_get_selector(ECalShellSidebar *cal_shell_sidebar); + +G_END_DECLS + +#endif /* E_CAL_SHELL_SIDEBAR_H */ diff --git a/calendar/modules/e-cal-shell-view-actions.c b/calendar/modules/e-cal-shell-view-actions.c new file mode 100644 index 0000000000..e4f9d351c5 --- /dev/null +++ b/calendar/modules/e-cal-shell-view-actions.c @@ -0,0 +1,331 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view-actions.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-view-private.h" + +static void +action_calendar_copy_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_delete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_go_back_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_go_forward_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_go_today_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_jump_to_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_new_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_print_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_print_preview_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_properties_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_purge_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_calendar_view_cb (GtkRadioAction *action, + GtkRadioAction *current, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_clipboard_copy_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_clipboard_cut_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_clipboard_paste_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_delete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_delete_occurrence_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_delete_occurrence_all_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static void +action_event_open_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ +} + +static GtkActionEntry calendar_entries[] = { + + { "calendar-copy", + GTK_STOCK_COPY, + N_("_Copy..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_copy_cb) }, + + { "calendar-delete", + GTK_STOCK_DELETE, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_delete_cb) }, + + { "calendar-go-back", + GTK_STOCK_GO_BACK, + N_("Previous"), + NULL, + N_("Go Back"), + G_CALLBACK (action_calendar_go_back_cb) }, + + { "calendar-go-forward", + GTK_STOCK_GO_FORWARD, + N_("Next"), + NULL, + N_("Go Forward"), + G_CALLBACK (action_calendar_go_forward_cb) }, + + { "calendar-go-today", + "go-today", + N_("Select _Today"), + "t", + N_("Select today"), + G_CALLBACK (action_calendar_go_today_cb) }, + + { "calendar-jump-to", + GTK_STOCK_JUMP_TO, + N_("Select _Date"), + "g", + N_("Select a specific date"), + G_CALLBACK (action_calendar_jump_to_cb) }, + + { "calendar-new", + "x-office-calendar", + N_("_New Calendar"), + NULL, + N_("Create a new calendar"), + G_CALLBACK (action_calendar_new_cb) }, + + { "calendar-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print this calendar"), + G_CALLBACK (action_calendar_print_cb) }, + + { "calendar-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the calendar to be printed"), + G_CALLBACK (action_calendar_print_preview_cb) }, + + { "calendar-properties", + GTK_STOCK_PROPERTIES, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_properties_cb) }, + + { "calendar-purge", + NULL, + N_("Purg_e"), + "e", + N_("Purge old appointments and meetings"), + G_CALLBACK (action_calendar_purge_cb) }, + + { "event-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy the selection"), + G_CALLBACK (action_event_clipboard_copy_cb) }, + + { "event-clipboard-cut", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut the selection"), + G_CALLBACK (action_event_clipboard_cut_cb) }, + + { "event-clipboard-paste", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste the clipboard"), + G_CALLBACK (action_event_clipboard_paste_cb) }, + + { "event-delete", + GTK_STOCK_DELETE, + NULL, + NULL, + N_("Delete the appointment"), + G_CALLBACK (action_event_delete_cb) }, + + { "event-delete-occurrence", + GTK_STOCK_DELETE, + N_("Delete This _Occurrence"), + NULL, + N_("Delete this occurrence"), + G_CALLBACK (action_event_delete_occurrence_cb) }, + + { "event-delete-occurrence-all", + GTK_STOCK_DELETE, + N_("Delete _All Occurrences"), + NULL, + N_("Delete all occurrences"), + G_CALLBACK (action_event_delete_occurrence_all_cb) }, + + { "event-open", + NULL, + N_("_Open Appointment"), + "o", + N_("View the current appointment"), + G_CALLBACK (action_event_open_cb) } +}; + +static GtkRadioActionEntry calendar_view_entries[] = { + + { "calendar-view-day", + "view-calendar-day", + N_("Day"), + NULL, + N_("Show one day"), + GNOME_CAL_DAY_VIEW }, + + { "calendar-view-list", + "view-calendar-list", + N_("List"), + NULL, + N_("Show as list"), + GNOME_CAL_LIST_VIEW }, + + { "calendar-view-month", + "view-calendar-month", + N_("Month"), + NULL, + N_("Show one month"), + GNOME_CAL_MONTH_VIEW }, + + { "calendar-view-week", + "view-calendar-week", + N_("Week"), + NULL, + N_("Show one week"), + GNOME_CAL_WEEK_VIEW }, + + { "calendar-view-workweek", + "view-calendar-workweek", + N_("Work Week"), + NULL, + N_("Show one work week"), + GNOME_CAL_WORK_WEEK_VIEW } +}; + +void +e_cal_shell_view_actions_init (ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *manager; + const gchar *domain; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + manager = e_shell_window_get_ui_manager (shell_window); + domain = GETTEXT_PACKAGE; + + e_load_ui_definition (manager, "evolution-calendars.ui"); + + action_group = cal_shell_view->priv->calendar_actions; + gtk_action_group_set_translation_domain (action_group, domain); + gtk_action_group_add_actions ( + action_group, calendar_entries, + G_N_ELEMENTS (calendar_entries), cal_shell_view); + gtk_action_group_add_radio_actions ( + action_group, calendar_view_entries, + G_N_ELEMENTS (calendar_view_entries), GNOME_CAL_DAY_VIEW, + G_CALLBACK (action_calendar_view_cb), cal_shell_view); + gtk_ui_manager_insert_action_group (manager, action_group, 0); +} diff --git a/calendar/modules/e-cal-shell-view-actions.h b/calendar/modules/e-cal-shell-view-actions.h new file mode 100644 index 0000000000..9d935e4263 --- /dev/null +++ b/calendar/modules/e-cal-shell-view-actions.h @@ -0,0 +1,30 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view-actions.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_VIEW_ACTIONS_H +#define E_CAL_SHELL_VIEW_ACTIONS_H + +#include + +/* Action Groups */ +#define E_SHELL_WINDOW_ACTION_GROUP_CALS(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "cals") + +#endif /* E_CAL_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/modules/e-cal-shell-view-private.c b/calendar/modules/e-cal-shell-view-private.c new file mode 100644 index 0000000000..262e31497c --- /dev/null +++ b/calendar/modules/e-cal-shell-view-private.c @@ -0,0 +1,73 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view-private.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-view-private.h" + +void +e_cal_shell_view_private_init (ECalShellView *cal_shell_view, + EShellViewClass *shell_view_class) +{ + ECalShellViewPrivate *priv = cal_shell_view->priv; + ESourceList *source_list; + GObject *object; + + object = G_OBJECT (shell_view_class->type_module); + source_list = g_object_get_data (object, "source-list"); + g_return_if_fail (E_IS_SOURCE_LIST (source_list)); + + priv->source_list = g_object_ref (source_list); + priv->calendar_actions = gtk_action_group_new ("calendars"); +} + +void +e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) +{ + ECalShellViewPrivate *priv = cal_shell_view->priv; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + /* Cache these to avoid lots of awkward casting. */ + priv->cal_shell_content = g_object_ref (shell_content); + priv->cal_shell_sidebar = g_object_ref (shell_sidebar); +} + +void +e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) +{ + ECalShellViewPrivate *priv = cal_shell_view->priv; + + DISPOSE (priv->source_list); + + DISPOSE (priv->calendar_actions); + + DISPOSE (priv->cal_shell_content); + DISPOSE (priv->cal_shell_sidebar); +} + +void +e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view) +{ + ECalShellViewPrivate *priv = cal_shell_view->priv; +} diff --git a/calendar/modules/e-cal-shell-view-private.h b/calendar/modules/e-cal-shell-view-private.h new file mode 100644 index 0000000000..d80d0d2f27 --- /dev/null +++ b/calendar/modules/e-cal-shell-view-private.h @@ -0,0 +1,86 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view-private.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_VIEW_PRIVATE_H +#define E_CAL_SHELL_VIEW_PRIVATE_H + +#include "e-cal-shell-view.h" + +#include + +#include +#include + +#include +#include +#include +#include + +#define E_CAL_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellViewPrivate)) + +/* Shorthand, requires a variable named "shell_window". */ +#define ACTION(name) \ + (E_SHELL_WINDOW_ACTION_##name (shell_window)) +#define ACTION_GROUP(name) \ + (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) + +/* For use in dispose() methods. */ +#define DISPOSE(obj) \ + G_STMT_START { \ + if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ + } G_STMT_END + +G_BEGIN_DECLS + +struct _ECalShellViewPrivate { + + /*** Module Data ***/ + + ESourceList *source_list; + + /*** UI Management ***/ + + GtkActionGroup *calendar_actions; + + /* These are just for convenience. */ + ECalShellContent *cal_shell_content; + ECalShellSidebar *cal_shell_sidebar; +}; + +void e_cal_shell_view_private_init + (ECalShellView *cal_shell_view, + EShellViewClass *shell_view_class); +void e_cal_shell_view_private_constructed + (ECalShellView *cal_shell_view); +void e_cal_shell_view_private_dispose + (ECalShellView *cal_shell_view); +void e_cal_shell_view_private_finalize + (ECalShellView *cal_shell_view); + +/* Private Utilities */ + +void e_cal_shell_view_actions_init + (ECalShellView *cal_shell_view); + +G_END_DECLS + +#endif /* E_CAL_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/modules/e-cal-shell-view.c b/calendar/modules/e-cal-shell-view.c new file mode 100644 index 0000000000..67d32de362 --- /dev/null +++ b/calendar/modules/e-cal-shell-view.c @@ -0,0 +1,175 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-view-private.h" + +enum { + PROP_0, + PROP_SOURCE_LIST +}; + +GType e_cal_shell_view_type = 0; +static gpointer parent_class; + +static void +cal_shell_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SOURCE_LIST: + g_value_set_object ( + value, e_cal_shell_view_get_source_list ( + E_CAL_SHELL_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_shell_view_dispose (GObject *object) +{ + e_cal_shell_view_private_dispose (E_CAL_SHELL_VIEW (object)); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +cal_shell_view_finalize (GObject *object) +{ + e_cal_shell_view_private_finalize (E_CAL_SHELL_VIEW (object)); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +cal_shell_view_constructed (GObject *object) +{ + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + e_cal_shell_view_private_constructed (E_CAL_SHELL_VIEW (object)); +} + +static void +cal_shell_view_changed (EShellView *shell_view) +{ + ECalShellViewPrivate *priv; + GtkActionGroup *action_group; + gboolean visible; + + priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view); + + action_group = priv->calendar_actions; + visible = e_shell_view_is_active (shell_view); + gtk_action_group_set_visible (action_group, visible); +} + +static void +cal_shell_view_class_init (ECalShellView *class, + GTypeModule *type_module) +{ + GObjectClass *object_class; + EShellViewClass *shell_view_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalShellViewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = cal_shell_view_get_property; + object_class->dispose = cal_shell_view_dispose; + object_class->finalize = cal_shell_view_finalize; + object_class->constructed = cal_shell_view_constructed; + + shell_view_class = E_SHELL_VIEW_CLASS (class); + shell_view_class->label = N_("Cals"); + shell_view_class->icon_name = "evolution-cals"; + shell_view_class->search_options = "/calendar-search-options"; + shell_view_class->type_module = type_module; + shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; + shell_view_class->changed = cal_shell_view_changed; + + g_object_class_install_property ( + object_class, + PROP_SOURCE_LIST, + g_param_spec_object ( + "source-list", + _("Source List"), + _("The registry of calendars"), + E_TYPE_SOURCE_LIST, + G_PARAM_READABLE)); +} + +static void +cal_shell_view_init (ECalShellView *cal_shell_view, + EShellViewClass *shell_view_class) +{ + cal_shell_view->priv = + E_CAL_SHELL_VIEW_GET_PRIVATE (cal_shell_view); + + e_cal_shell_view_private_init (cal_shell_view, shell_view_class); +} + +GType +e_cal_shell_view_get_type (GTypeModule *type_module) +{ + if (e_cal_shell_view_type == 0) { + const GTypeInfo type_info = { + sizeof (ECalShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) cal_shell_view_class_init, + (GClassFinalizeFunc) NULL, + type_module, + sizeof (ECalShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) cal_shell_view_init, + NULL /* value_table */ + }; + + e_cal_shell_view_type = + g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "ECalShellView", &type_info, 0); + } + + return e_cal_shell_view_type; +} + +GnomeCalendar * +e_cal_shell_view_get_calendar (ECalShellView *cal_shell_view) +{ + g_return_val_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view), NULL); + + /* FIXME */ + return NULL; +} + +ESourceList * +e_cal_shell_view_get_source_list (ECalShellView *cal_shell_view) +{ + g_return_val_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view), NULL); + + return cal_shell_view->priv->source_list; +} diff --git a/calendar/modules/e-cal-shell-view.h b/calendar/modules/e-cal-shell-view.h new file mode 100644 index 0000000000..404446f22b --- /dev/null +++ b/calendar/modules/e-cal-shell-view.h @@ -0,0 +1,73 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-view.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_VIEW_H +#define E_CAL_SHELL_VIEW_H + +#include +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_CAL_SHELL_VIEW \ + (e_cal_shell_view_type) +#define E_CAL_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellView)) +#define E_CAL_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CAL_SHELL_VIEW, ECalShellViewClass)) +#define E_IS_CAL_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CAL_SHELL_VIEW)) +#define E_IS_CAL_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CAL_SHELL_VIEW)) +#define E_CAL_SHELL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CAL_SHELL_VIEW, ECalShellViewClass)) + +G_BEGIN_DECLS + +extern GType e_cal_shell_view_type; + +typedef struct _ECalShellView ECalShellView; +typedef struct _ECalShellViewClass ECalShellViewClass; +typedef struct _ECalShellViewPrivate ECalShellViewPrivate; + +struct _ECalShellView { + EShellView parent; + ECalShellViewPrivate *priv; +}; + +struct _ECalShellViewClass { + EShellViewClass parent_class; +}; + +GType e_cal_shell_view_get_type + (GTypeModule *type_module); +GnomeCalendar * e_cal_shell_view_get_calendar + (ECalShellView *cal_shell_view); +ESourceList * e_cal_shell_view_get_source_list + (ECalShellView *cal_shell_view); + +G_END_DECLS + +#endif /* E_CAL_SHELL_VIEW_H */ diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c new file mode 100644 index 0000000000..a3a3104b47 --- /dev/null +++ b/calendar/modules/e-memo-shell-content.c @@ -0,0 +1,550 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-content.h" + +#include + +#include "e-util/gconf-bridge.h" + +#include "calendar/gui/calendar-config.h" +#include "calendar/gui/e-memo-table.h" +#include "calendar/gui/e-memo-table-config.h" + +#include "widgets/menus/gal-view-etable.h" + +#define E_MEMO_SHELL_CONTENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_SHELL_CONTENT, EMemoShellContentPrivate)) + +#define E_MEMO_TABLE_DEFAULT_STATE \ + "" \ + "" \ + " " \ + " " \ + " " \ + " " \ + "" + +struct _EMemoShellContentPrivate { + GtkWidget *paned; + GtkWidget *memo_table; + GtkWidget *memo_preview; + + EMemoTableConfig *table_config; + GalViewInstance *view_instance; + + gchar *current_uid; +}; + +enum { + PROP_0, + PROP_PREVIEW_VISIBLE +}; + +enum { + TARGET_VCALENDAR +}; + +static GtkTargetEntry drag_types[] = { + { "text/calendar", 0, TARGET_VCALENDAR }, + { "text/x-calendar", 0, TARGET_VCALENDAR } +}; + +static gpointer parent_class; + +static void +memo_shell_content_changed_cb (EMemoShellContent *memo_shell_content, + GalViewInstance *view_instance) +{ + EShellView *shell_view; + EShellContent *shell_content; + gchar *view_id; + + shell_content = E_SHELL_CONTENT (memo_shell_content); + shell_view = e_shell_content_get_shell_view (shell_content); + view_id = gal_view_instance_get_current_view_id (view_instance); + e_shell_view_set_view_id (shell_view, view_id); + g_free (view_id); +} + +static void +memo_shell_content_display_view_cb (EMemoShellContent *memo_shell_content, + GalView *gal_view) +{ + EMemoTable *memo_table; + ETableScrolled *table_scrolled; + ETable *table; + + if (!GAL_IS_VIEW_ETABLE (gal_view)) + return; + + memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + table_scrolled = E_TABLE_SCROLLED (memo_table->etable); + table = e_table_scrolled_get_table (table_scrolled); + + gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); +} + +static void +memo_shell_content_table_drag_data_get_cb (EMemoShellContent *memo_shell_content, + gint row, + gint col, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint info, + guint time) +{ + /* FIXME */ +} + +static void +memo_shell_content_table_drag_data_delete_cb (EMemoShellContent *memo_shell_content, + gint row, + gint col, + GdkDragContext *context) +{ + /* Moved components are deleted from source immediately when moved, + * because some of them can be part of destination source, and we + * don't want to delete not-moved tasks. There is no such information + * which event has been moved and which not, so skip this method. */ +} + +static void +memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content, + gint row, + ETable *table) +{ + EMemoPreview *memo_preview; + EMemoTable *memo_table; + ECalModel *model; + ECalModelComponent *comp_data; + ECalComponent *comp; + const gchar *uid; + + memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); + memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + + if (e_table_selected_count (table) != 1) { + e_memo_preview_clear (memo_preview); + return; + } + + model = e_memo_table_get_model (memo_table); + row = e_table_get_cursor_row (table); + comp_data = e_cal_model_get_component_at (model, row); + + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent ( + comp, icalcomponent_new_clone (comp_data->icalcomp)); + e_memo_preview_display (memo_preview, comp_data->client, comp); + + e_cal_component_get_uid (comp, &uid); + g_free (memo_shell_content->priv->current_uid); + memo_shell_content->priv->current_uid = g_strdup (uid); + + g_object_unref (comp); +} + +static void +memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content, + ETable *table) +{ + EMemoPreview *memo_preview; + + memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); + + /* XXX Old code emits a "selection-changed" signal here. */ + + if (e_table_selected_count (table) != 1) + e_memo_preview_clear (memo_preview); +} + +static void +memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content, + gint row, + ETableModel *model) +{ + ECalModelComponent *comp_data; + EMemoTable *memo_table; + ETableScrolled *table_scrolled; + ETable *table; + const gchar *current_uid; + const gchar *uid; + + current_uid = memo_shell_content->priv->current_uid; + if (current_uid == NULL) + return; + + comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); + if (comp_data == NULL) + return; + + uid = icalcomponent_get_uid (comp_data->icalcomp); + if (g_strcmp0 (uid, current_uid) != 0) + return; + + memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + table_scrolled = E_TABLE_SCROLLED (memo_table->etable); + table = e_table_scrolled_get_table (table_scrolled); + + memo_shell_content_cursor_change_cb (memo_shell_content, 0, table); +} + +static void +memo_shell_content_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + e_memo_shell_content_set_preview_visible ( + E_MEMO_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_shell_content_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + g_value_set_boolean ( + value, e_memo_shell_content_get_preview_visible ( + E_MEMO_SHELL_CONTENT (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_shell_content_dispose (GObject *object) +{ + EMemoShellContentPrivate *priv; + + priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object); + + if (priv->paned != NULL) { + g_object_unref (priv->paned); + priv->paned = NULL; + } + + if (priv->memo_table != NULL) { + g_object_unref (priv->memo_table); + priv->memo_table = NULL; + } + + if (priv->memo_preview != NULL) { + g_object_unref (priv->memo_preview); + priv->memo_preview = NULL; + } + + if (priv->table_config != NULL) { + g_object_unref (priv->table_config); + priv->table_config = NULL; + } + + if (priv->view_instance != NULL) { + g_object_unref (priv->view_instance); + priv->view_instance = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_shell_content_finalize (GObject *object) +{ + EMemoShellContentPrivate *priv; + + priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object); + + g_free (priv->current_uid); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +memo_shell_content_constructed (GObject *object) +{ + EMemoShellContentPrivate *priv; + EShellContent *shell_content; + EShellView *shell_view; + EShellViewClass *shell_view_class; + GalViewCollection *view_collection; + GalViewInstance *view_instance; + ECalModel *model; + ETable *table; + GConfBridge *bridge; + GtkWidget *container; + GtkWidget *widget; + const gchar *key; + + priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + shell_content = E_SHELL_CONTENT (object); + shell_view = e_shell_content_get_shell_view (shell_content); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + view_collection = shell_view_class->view_collection; + + /* Load the view instance. */ + + view_instance = gal_view_instance_new (view_collection, NULL); + g_signal_connect_swapped ( + view_instance, "changed", + G_CALLBACK (memo_shell_content_changed_cb), + object); + g_signal_connect_swapped ( + view_instance, "display-view", + G_CALLBACK (memo_shell_content_display_view_cb), + object); + gal_view_instance_load (view_instance); + priv->view_instance = view_instance; + + /* Build content widgets. */ + + container = GTK_WIDGET (object); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->paned = g_object_ref (widget); + gtk_widget_show (widget); + + container = widget; + + widget = e_memo_table_new (shell_view); + gtk_paned_add1 (GTK_PANED (container), widget); + priv->memo_table = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_paned_add2 (GTK_PANED (container), widget); + + container = widget; + + widget = e_memo_preview_new (); + e_memo_preview_set_default_timezone ( + E_MEMO_PREVIEW (widget), + calendar_config_get_icaltimezone ()); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->memo_preview = g_object_ref (widget); + gtk_widget_show (widget); + + /* Configure the memo table. */ + + widget = E_MEMO_TABLE (priv->memo_table)->etable; + table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); + model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo_table)); + + priv->table_config = e_memo_table_config_new ( + E_MEMO_TABLE (priv->memo_table)); + + e_table_set_state (table, E_MEMO_TABLE_DEFAULT_STATE); + + e_table_drag_source_set ( + table, GDK_BUTTON1_MASK, + drag_types, G_N_ELEMENTS (drag_types), + GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK); + + g_signal_connect_swapped ( + table, "table-drag-data-get", + G_CALLBACK (memo_shell_content_table_drag_data_get_cb), + object); + + g_signal_connect_swapped ( + table, "table-drag-data-delete", + G_CALLBACK (memo_shell_content_table_drag_data_delete_cb), + object); + + g_signal_connect_swapped ( + table, "cursor-change", + G_CALLBACK (memo_shell_content_cursor_change_cb), + object); + + g_signal_connect_swapped ( + table, "selection-change", + G_CALLBACK (memo_shell_content_selection_change_cb), + object); + + g_signal_connect_swapped ( + model, "model-row-changed", + G_CALLBACK (memo_shell_content_model_row_changed_cb), + object); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (priv->paned); + key = "/apps/evolution/calendar/display/memo_vpane_position"; + gconf_bridge_bind_property_delayed (bridge, key, object, "position"); +} + +static void +memo_shell_content_class_init (EMemoShellContentClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoShellContentPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = memo_shell_content_set_property; + object_class->get_property = memo_shell_content_get_property; + object_class->dispose = memo_shell_content_dispose; + object_class->finalize = memo_shell_content_finalize; + object_class->constructed = memo_shell_content_constructed; + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_VISIBLE, + g_param_spec_boolean ( + "preview-visible", + _("Preview is Visible"), + _("Whether the preview pane is visible"), + TRUE, + G_PARAM_READWRITE)); +} + +static void +memo_shell_content_init (EMemoShellContent *memo_shell_content) +{ + memo_shell_content->priv = + E_MEMO_SHELL_CONTENT_GET_PRIVATE (memo_shell_content); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_memo_shell_content_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMemoShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMemoShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_shell_content_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_CONTENT, "EMemoShellContent", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_memo_shell_content_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_MEMO_SHELL_CONTENT, + "shell-view", shell_view, NULL); +} + +EMemoPreview * +e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); + + return E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); +} + +EMemoTable * +e_memo_shell_content_get_memo_table (EMemoShellContent *memo_shell_content) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); + + return E_MEMO_TABLE (memo_shell_content->priv->memo_table); +} + +GalViewInstance * +e_memo_shell_content_get_view_instance (EMemoShellContent *memo_shell_content) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); + + return memo_shell_content->priv->view_instance; +} + +gboolean +e_memo_shell_content_get_preview_visible (EMemoShellContent *memo_shell_content) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_val_if_fail ( + E_IS_MEMO_SHELL_CONTENT (memo_shell_content), FALSE); + + paned = GTK_PANED (memo_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + return GTK_WIDGET_VISIBLE (child); +} + +void +e_memo_shell_content_set_preview_visible (EMemoShellContent *memo_shell_content, + gboolean preview_visible) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_if_fail (E_IS_MEMO_SHELL_CONTENT (memo_shell_content)); + + paned = GTK_PANED (memo_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + if (preview_visible) + gtk_widget_show (child); + else + gtk_widget_hide (child); + + g_object_notify (G_OBJECT (memo_shell_content), "preview-visible"); +} diff --git a/calendar/modules/e-memo-shell-content.h b/calendar/modules/e-memo-shell-content.h new file mode 100644 index 0000000000..3b8bb341f1 --- /dev/null +++ b/calendar/modules/e-memo-shell-content.h @@ -0,0 +1,83 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_CONTENT_H +#define E_MEMO_SHELL_CONTENT_H + +#include +#include + +#include +#include + +#include + +/* Standard GObject macros */ +#define E_TYPE_MEMO_SHELL_CONTENT \ + (e_memo_shell_content_get_type ()) +#define E_MEMO_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_SHELL_CONTENT, EMemoShellContent)) +#define E_MEMO_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MEMO_SHELL_CONTENT, EMemoShellContentClass)) +#define E_IS_MEMO_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_SHELL_CONTENT)) +#define E_IS_MEMO_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_SHELL_CONTENT)) +#define E_MEMO_SHELL_CONTENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_SHELL_CONTENT, EMemoShellContentClass)) + +G_BEGIN_DECLS + +typedef struct _EMemoShellContent EMemoShellContent; +typedef struct _EMemoShellContentClass EMemoShellContentClass; +typedef struct _EMemoShellContentPrivate EMemoShellContentPrivate; + +struct _EMemoShellContent { + EShellContent parent; + EMemoShellContentPrivate *priv; +}; + +struct _EMemoShellContentClass { + EShellContentClass parent_class; +}; + +GType e_memo_shell_content_get_type (void); +GtkWidget * e_memo_shell_content_new (EShellView *shell_view); +EMemoPreview * e_memo_shell_content_get_memo_preview + (EMemoShellContent *memo_shell_content); +EMemoTable * e_memo_shell_content_get_memo_table + (EMemoShellContent *memo_shell_content); +GalViewInstance * + e_memo_shell_content_get_view_instance + (EMemoShellContent *memo_shell_content); +gboolean e_memo_shell_content_get_preview_visible + (EMemoShellContent *memo_shell_content); +void e_memo_shell_content_set_preview_visible + (EMemoShellContent *memo_shell_content, + gboolean preview_visible); + +G_END_DECLS + +#endif /* E_MEMO_SHELL_CONTENT_H */ diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c new file mode 100644 index 0000000000..fe8c8fe35a --- /dev/null +++ b/calendar/modules/e-memo-shell-module.c @@ -0,0 +1,299 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-module.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include "shell/e-shell.h" +#include "shell/e-shell-module.h" +#include "shell/e-shell-window.h" + +#include "calendar/gui/calendar-config.h" +#include "calendar/gui/dialogs/calendar-setup.h" + +#include "e-memo-shell-view.h" + +#define MODULE_NAME "memos" +#define MODULE_ALIASES "" +#define MODULE_SCHEMES "memo" +#define MODULE_SEARCHES "memotypes.xml" +#define MODULE_SORT_ORDER 500 + +#define WEB_BASE_URI "webcal://" +#define PERSONAL_RELATIVE_URI "system" + +/* Module Entry Point */ +void e_shell_module_init (GTypeModule *type_module); + +static void +memo_module_ensure_sources (EShellModule *shell_module) +{ + /* XXX This is basically the same algorithm across all modules. + * Maybe we could somehow integrate this into EShellModule? */ + + ESourceList *source_list; + ESourceGroup *on_this_computer; + ESourceGroup *on_the_web; + ESource *personal; + GSList *groups, *iter; + const gchar *data_dir; + gchar *base_uri; + gchar *filename; + + on_this_computer = NULL; + on_the_web = NULL; + personal = NULL; + + if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { + g_warning ("Could not get memo sources from GConf!"); + return; + } + + /* Share the source list with all memo views. This is + * accessible via e_memo_shell_view_get_source_list(). + * Note: EShellModule takes ownership of the reference. + * + * XXX I haven't yet decided if I want to add a proper + * EShellModule API for this. The mail module would + * not use it. */ + g_object_set_data_full ( + G_OBJECT (shell_module), "source-list", + source_list, (GDestroyNotify) g_object_unref); + + data_dir = e_shell_module_get_data_dir (shell_module); + filename = g_build_filename (data_dir, "local", NULL); + base_uri = g_filename_to_uri (filename, NULL, NULL); + g_free (filename); + + groups = e_source_list_peek_groups (source_list); + for (iter = groups; iter != NULL; iter = iter->next) { + ESourceGroup *source_group = iter->data; + const gchar *group_base_uri; + + group_base_uri = e_source_group_peek_base_uri (source_group); + + /* Compare only "file://" part. If the user's home + * changes, we do not want to create another group. */ + if (on_this_computer == NULL && + strncmp (base_uri, group_base_uri, 7) == 0) + on_this_computer = source_group; + + else if (on_the_web == NULL && + strcmp (WEB_BASE_URI, group_base_uri) == 0) + on_the_web = source_group; + } + + if (on_this_computer != NULL) { + GSList *sources; + const gchar *group_base_uri; + + sources = e_source_group_peek_sources (on_this_computer); + group_base_uri = e_source_group_peek_base_uri (on_this_computer); + + /* Make sure this group includes a "Personal" source. */ + for (iter = sources; iter != NULL; iter = iter->next) { + ESource *source = iter->data; + const gchar *relative_uri; + + relative_uri = e_source_peek_relative_uri (source); + if (relative_uri == NULL) + continue; + + if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) + continue; + + personal = source; + break; + } + + /* Make sure we have the correct base URI. This can + * change when the user's home directory changes. */ + if (strcmp (base_uri, group_base_uri) != 0) { + e_source_group_set_base_uri ( + on_this_computer, base_uri); + + /* XXX We shouldn't need this sync call here as + * set_base_uri() results in synching to GConf, + * but that happens in an idle loop and too late + * to prevent the user from seeing a "Cannot + * Open ... because of invalid URI" error. */ + e_source_list_sync (source_list, NULL); + } + + } else { + ESourceGroup *source_group; + const gchar *name; + + name = _("On This Computer"); + source_group = e_source_group_new (name, base_uri); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + if (personal == NULL) { + ESource *source; + GSList *selected; + const gchar *name; + gchar *primary; + + name = _("Personal"); + source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_group_add_source (on_this_computer, source, -1); + g_object_unref (source); + + primary = calendar_config_get_primary_memos (); + selected = calendar_config_get_memos_selected (); + + if (primary == NULL && selected == NULL) { + const gchar *uid; + + uid = e_source_peek_uid (source); + selected = g_slist_prepend (NULL, g_strdup (uid)); + + calendar_config_set_primary_memos (uid); + calendar_config_set_memos_selected (selected); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + g_slist_free (selected); + g_free (primary); + } + + if (on_the_web == NULL) { + ESourceGroup *source_group; + const gchar *name; + + name = _("On The Web"); + source_group = e_source_group_new (name, WEB_BASE_URI); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + g_free (base_uri); +} + +static void +action_memo_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_memo_shared_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_memo_list_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ + calendar_setup_new_memo_list (NULL); +} + +static GtkActionEntry item_entries[] = { + + { "memo-new", + "stock_insert-note", + N_("Mem_o"), /* XXX Need C_() here */ + "o", + N_("Create a new memo"), + G_CALLBACK (action_memo_new_cb) }, + + { "memo-shared-new", + "stock_insert-note", + N_("_Shared Memo"), + "h", + N_("Create a new shared memo"), + G_CALLBACK (action_memo_shared_new_cb) } +}; + +static GtkActionEntry source_entries[] = { + + { "memo-list-new", + "stock_notes", + N_("Memo Li_st"), + NULL, + N_("Create a new memo list"), + G_CALLBACK (action_memo_list_new_cb) } +}; + +static gboolean +memo_module_handle_uri (EShellModule *shell_module, + const gchar *uri) +{ + /* FIXME */ + return FALSE; +} + +static void +memo_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window) +{ + const gchar *module_name; + + module_name = G_TYPE_MODULE (shell_module)->name; + + e_shell_window_register_new_item_actions ( + shell_window, module_name, + item_entries, G_N_ELEMENTS (item_entries)); + + e_shell_window_register_new_source_actions ( + shell_window, module_name, + source_entries, G_N_ELEMENTS (source_entries)); +} + +static EShellModuleInfo module_info = { + + MODULE_NAME, + MODULE_ALIASES, + MODULE_SCHEMES, + MODULE_SEARCHES, + MODULE_SORT_ORDER +}; + +void +e_shell_module_init (GTypeModule *type_module) +{ + EShell *shell; + EShellModule *shell_module; + + shell_module = E_SHELL_MODULE (type_module); + shell = e_shell_module_get_shell (shell_module); + + /* Register the GType for EMemoShellView. */ + e_memo_shell_view_get_type (type_module); + + e_shell_module_set_info (shell_module, &module_info); + + memo_module_ensure_sources (shell_module); + + g_signal_connect_swapped ( + shell, "handle-uri", + G_CALLBACK (memo_module_handle_uri), shell_module); + + g_signal_connect_swapped ( + shell, "window-created", + G_CALLBACK (memo_module_window_created), shell_module); +} diff --git a/calendar/modules/e-memo-shell-sidebar.c b/calendar/modules/e-memo-shell-sidebar.c new file mode 100644 index 0000000000..23ab9491fa --- /dev/null +++ b/calendar/modules/e-memo-shell-sidebar.c @@ -0,0 +1,265 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-sidebar.h" + +#include + +#include "calendar/gui/e-calendar-selector.h" + +#include "e-memo-shell-view.h" + +#define E_MEMO_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarPrivate)) + +struct _EMemoShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +#if 0 /* MOVE THIS TO EMemoShellView */ +static void +memo_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + EMemos *memos; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + memos = e_memo_shell_view_get_memos (E_MEMO_SHELL_VIEW (shell_view)); + memo_table = e_memos_get_calendar_table (memos); + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + n_rows = e_table_model_get_row_count (model); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d memo", "%d memos", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} +#endif + +static void +memo_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_memo_shell_sidebar_get_selector ( + E_MEMO_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_shell_sidebar_dispose (GObject *object) +{ + EMemoShellSidebarPrivate *priv; + + priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_shell_sidebar_constructed (GObject *object) +{ + EMemoShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + EMemoShellView *memo_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + + priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + memo_shell_view = E_MEMO_SHELL_VIEW (shell_view); + source_list = e_memo_shell_view_get_source_list (memo_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + +#if 0 /* MOVE THIS TO EMemoShellView */ + + /* Setup signal handlers. */ + + memos = e_memo_shell_view_get_memos (memo_shell_view); + memo_table = e_memos_get_calendar_table (memos); + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "selection-change", + G_CALLBACK (memo_shell_sidebar_update), + shell_sidebar); + + memo_shell_sidebar_update (shell_sidebar); + +#endif +} + +static void +memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = memo_shell_sidebar_get_property; + object_class->dispose = memo_shell_sidebar_dispose; + object_class->constructed = memo_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of memo lists"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +memo_shell_sidebar_init (EMemoShellSidebar *memo_shell_sidebar) +{ + memo_shell_sidebar->priv = + E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (memo_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_memo_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMemoShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMemoShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "EMemoShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_memo_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_MEMO_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +ESourceSelector * +e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar), NULL); + + return E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); +} diff --git a/calendar/modules/e-memo-shell-sidebar.h b/calendar/modules/e-memo-shell-sidebar.h new file mode 100644 index 0000000000..47985d3402 --- /dev/null +++ b/calendar/modules/e-memo-shell-sidebar.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_SIDEBAR_H +#define E_MEMO_SHELL_SIDEBAR_H + +#include + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MEMO_SHELL_SIDEBAR \ + (e_memo_shell_sidebar_get_type ()) +#define E_MEMO_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebar)) +#define E_MEMO_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) +#define E_IS_MEMO_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR)) +#define E_IS_MEMO_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_SHELL_SIDEBAR)) +#define E_MEMO_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _EMemoShellSidebar EMemoShellSidebar; +typedef struct _EMemoShellSidebarClass EMemoShellSidebarClass; +typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate; + +struct _EMemoShellSidebar { + EShellSidebar parent; + EMemoShellSidebarPrivate *priv; +}; + +struct _EMemoShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_memo_shell_sidebar_get_type (void); +GtkWidget * e_memo_shell_sidebar_new (EShellView *shell_view); +ESourceSelector * + e_memo_shell_sidebar_get_selector + (EMemoShellSidebar *memo_shell_sidebar); + +G_END_DECLS + +#endif /* E_MEMO_SHELL_SIDEBAR_H */ diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c new file mode 100644 index 0000000000..e20ec46949 --- /dev/null +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -0,0 +1,367 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view-actions.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-view-private.h" + +#include "e-util/gconf-bridge.h" + +#include "calendar/gui/print.h" + +static void +action_memo_clipboard_copy_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_copy_clipboard (memo_table); +} + +static void +action_memo_clipboard_cut_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_cut_clipboard (memo_table); +} + +static void +action_memo_clipboard_paste_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_paste_clipboard (memo_table); +} + +static void +action_memo_delete_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoPreview *memo_preview; + EMemoTable *memo_table; + const gchar *status_message; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content); + + status_message = _("Deleting selected memos..."); + e_memo_shell_view_set_status_message (memo_shell_view, status_message); + e_memo_table_delete_selected (memo_table); + e_memo_shell_view_set_status_message (memo_shell_view, NULL); + + e_memo_preview_clear (memo_preview); +} + +static void +action_memo_list_copy_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + /* FIXME */ +} + +static void +action_memo_list_delete_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + /* FIXME */ +} + +static void +action_memo_list_new_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + calendar_setup_new_memo_list (GTK_WINDOW (shell_window)); +} + +static void +action_memo_list_properties_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellSidebar *memo_shell_sidebar; + EShellView *shell_view; + EShellWindow *shell_window; + ESource *source; + ESourceSelector *selector; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (source != NULL); + + calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source); +} + +static void +action_memo_open_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_open_selected (memo_table); +} + +static void +action_memo_preview_cb (GtkToggleAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + gboolean visible; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + visible = gtk_toggle_action_get_active (action); + e_memo_shell_content_set_preview_visible (memo_shell_content, visible); +} + +static void +action_memo_print_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ETable *table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + table = e_memo_table_get_table (memo_table); + + print_table ( + table, _("Print Memos"), _("Memos"), + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +} + +static void +action_memo_print_preview_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ETable *table; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + table = e_memo_table_get_table (memo_table); + + print_table ( + table, _("Print Memos"), _("Memos"), + GTK_PRINT_OPERATION_ACTION_PREVIEW); +} + +static GtkActionEntry memo_entries[] = { + + { "memo-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy selected memo"), + G_CALLBACK (action_memo_clipboard_copy_cb) }, + + { "memo-clipboard-cut", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut selected memo"), + G_CALLBACK (action_memo_clipboard_cut_cb) }, + + { "memo-clipboard-paste", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste memo from the clipboard"), + G_CALLBACK (action_memo_clipboard_paste_cb) }, + + { "memo-delete", + GTK_STOCK_DELETE, + NULL, + NULL, + N_("Delete selected memos"), + G_CALLBACK (action_memo_delete_cb) }, + + { "memo-list-copy", + GTK_STOCK_COPY, + N_("_Copy..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_list_copy_cb) }, + + { "memo-list-delete", + GTK_STOCK_DELETE, + N_("_Delete"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_list_delete_cb) }, + + { "memo-list-new", + "stock_notes", + N_("_New Memo List"), + NULL, + N_("Create a new memo list"), + G_CALLBACK (action_memo_list_new_cb) }, + + { "memo-list-properties", + GTK_STOCK_PROPERTIES, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_list_properties_cb) }, + + { "memo-open", + NULL, + N_("Open Memo"), + "o", + N_("View the selected memo"), + G_CALLBACK (action_memo_open_cb) }, + + { "memo-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the list of memos"), + G_CALLBACK (action_memo_print_cb) }, + + { "memo-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the list of memos to be printed"), + G_CALLBACK (action_memo_print_preview_cb) }, +}; + +static GtkToggleActionEntry memo_toggle_entries[] = { + + { "memo-preview", + NULL, + N_("Memo _Preview"), + "m", + N_("Show memo preview pane"), + G_CALLBACK (action_memo_preview_cb), + TRUE } +}; + +void +e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *manager; + GConfBridge *bridge; + GObject *object; + const gchar *domain; + const gchar *key; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + manager = e_shell_window_get_ui_manager (shell_window); + domain = GETTEXT_PACKAGE; + + e_load_ui_definition (manager, "evolution-memos.ui"); + + action_group = memo_shell_view->priv->memo_actions; + gtk_action_group_set_translation_domain (action_group, domain); + gtk_action_group_add_actions ( + action_group, memo_entries, + G_N_ELEMENTS (memo_entries), memo_shell_view); + gtk_action_group_add_toggle_actions ( + action_group, memo_toggle_entries, + G_N_ELEMENTS (memo_toggle_entries), memo_shell_view); + gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (ACTION (MEMO_PREVIEW)); + key = "/apps/evolution/calendar/display/show_memo_preview"; + gconf_bridge_bind_property (bridge, key, object, "active"); +} + +void +e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + ECal *client; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + EShellView *shell_view; + EShellWindow *shell_window; + GtkAction *action; + gboolean read_only = TRUE; + gboolean sensitive; + gint n_selected; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + + model = e_memo_table_get_model (memo_table); + client = e_cal_model_get_default_client (model); + + table = e_memo_table_get_table (memo_table); + n_selected = e_table_selected_count (table); + + if (client != NULL) + e_cal_is_read_only (client, &read_only, NULL); + + action = ACTION (MEMO_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_CUT); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_PASTE); + sensitive = !read_only; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_DELETE); + sensitive = (n_selected > 0) && !read_only; + gtk_action_set_sensitive (action, sensitive); +} diff --git a/calendar/modules/e-memo-shell-view-actions.h b/calendar/modules/e-memo-shell-view-actions.h new file mode 100644 index 0000000000..4ac71c2083 --- /dev/null +++ b/calendar/modules/e-memo-shell-view-actions.h @@ -0,0 +1,48 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view-actions.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_VIEW_ACTIONS_H +#define E_MEMO_SHELL_VIEW_ACTIONS_H + +#include + +/* Memo Actions */ +#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_CUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-cut") +#define E_SHELL_WINDOW_ACTION_MEMO_CLIPBOARD_PASTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-clipboard-paste") +#define E_SHELL_WINDOW_ACTION_MEMO_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-delete") +#define E_SHELL_WINDOW_ACTION_MEMO_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-open") +#define E_SHELL_WINDOW_ACTION_MEMO_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-preview") +#define E_SHELL_WINDOW_ACTION_MEMO_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-print") +#define E_SHELL_WINDOW_ACTION_MEMO_PRINT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-print-preview") + +/* Action Groups */ +#define E_SHELL_WINDOW_ACTION_GROUP_MEMOS(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "memos") + +#endif /* E_MEMO_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c new file mode 100644 index 0000000000..a6ce81a560 --- /dev/null +++ b/calendar/modules/e-memo-shell-view-private.c @@ -0,0 +1,316 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view-private.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-view-private.h" + +#include + +static void +memo_shell_view_backend_died_cb (EMemoShellView *memo_shell_view, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GHashTable *client_table; + ESource *source; + const gchar *uid; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + source = e_cal_get_source (client); + uid = e_source_peek_uid (source); + + g_object_ref (source); + + g_hash_table_remove (client_table, uid); + e_memo_shell_view_set_status_message (memo_shell_view, NULL); + + e_error_run ( + GTK_WINDOW (shell_window), + "calendar:memos-crashed", NULL); + + g_object_unref (source); +} + +static void +memo_shell_view_backend_error_cb (EMemoShellView *memo_shell_view, + const gchar *message, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkWidget *dialog; + const gchar *uri; + gchar *uri_no_passwd; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + uri = e_cal_get_uri (client); + uri_no_passwd = get_uri_without_password (uri); + + dialog = gtk_message_dialog_new ( + GTK_WINDOW (shell_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + _("Error on %s:\n%s"), + uri_no_passwd, message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + + g_free (uri_no_passwd); +} + +static void +memo_shell_view_client_opened_cb (EMemoShellView *memo_shell_view, + ECalendarStatus status, + ECal *client) +{ + /* FIXME */ +} + +static gboolean +memo_shell_view_add_source (EMemoShellView *memo_shell_view, + ESource *source) +{ + GHashTable *client_table; + ECal *default_client; + ECal *client; + const gchar *uid; + const gchar *uri; + gchar *status_message; + + client_table = memo_shell_view->priv->client_table; + default_client = memo_shell_view->priv->default_client; + + uid = e_source_peek_uid (source); + client = g_hash_table_lookup (client_table, uid); + + if (client != NULL) + return TRUE; + + if (default_client != NULL) { + ESource *default_source; + const gchar *default_uid; + + default_source = e_cal_get_source (default_client); + default_uid = e_source_peek_uid (default_source); + + if (strcmp (uid, default_uid) == 0) + client = g_object_ref (default_client); + } + + if (client == NULL) + client = auth_new_cal_from_source ( + source, E_CAL_SOURCE_TYPE_JOURNAL); + + if (client == NULL) + return FALSE; + + g_signal_connect_swapped ( + client, "backend-died", + G_CALLBACK (memo_shell_view_backend_died_cb), + memo_shell_view); + + g_signal_connect_swapped ( + client, "backend-error", + G_CALLBACK (memo_shell_view_backend_error_cb), + memo_shell_view); + + g_hash_table_insert (client_table, g_strdup (uid), client); + + uri = e_cal_get_uri (client); + + status_message = g_strdup_printf (_("Opening memos at %s"), uri); + e_memo_shell_view_set_status_message (memo_shell_view, status_message); + g_free (status_message); + + g_signal_connect_swapped ( + client, "cal-opened", + G_CALLBACK (memo_shell_view_client_opened_cb), + memo_shell_view); + + e_cal_open_async (client, FALSE); + + return TRUE; +} + +static void +memo_shell_view_user_created_cb (EMemoShellView *memo_shell_view, + EMemoTable *memo_table) +{ + ECal *client; + ESource *source; + + if (memo_table->user_created_cal != NULL) + client = memo_table->user_created_cal; + else { + ECalModel *model; + + model = e_memo_table_get_model (memo_table); + client = e_cal_model_get_default_client (model); + } + + source = e_cal_get_source (client); + memo_shell_view_add_source (memo_shell_view, source); +} + +static void +memo_shell_view_load_view_collection (EShellViewClass *shell_view_class) +{ + GalViewCollection *collection; + GalViewFactory *factory; + ETableSpecification *spec; + const gchar *base_dir; + gchar *filename; + + collection = shell_view_class->view_collection; + + base_dir = EVOLUTION_ETSPECDIR; + spec = e_table_specification_new (); + filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL); + if (!e_table_specification_load_from_file (spec, filename)) + g_critical ("Unable to load ETable specification file " + "for memos"); + g_free (filename); + + factory = gal_view_factory_etable_new (spec); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + g_object_unref (spec); + + gal_view_collection_load (collection); +} + +static void +memo_shell_view_notify_view_id_cb (EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + GalViewInstance *view_instance; + const gchar *view_id; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + view_instance = + e_memo_shell_content_get_view_instance (memo_shell_content); + view_id = e_shell_view_get_view_id (E_SHELL_VIEW (memo_shell_view)); + + /* A NULL view ID implies we're in a custom view. But you can + * only get to a custom view via the "Define Views" dialog, which + * would have already modified the view instance appropriately. + * Furthermore, there's no way to refer to a custom view by ID + * anyway, since custom views have no IDs. */ + if (view_id == NULL) + return; + + gal_view_instance_set_current_view_id (view_instance, view_id); +} + +void +e_memo_shell_view_private_init (EMemoShellView *memo_shell_view, + EShellViewClass *shell_view_class) +{ + EMemoShellViewPrivate *priv = memo_shell_view->priv; + ESourceList *source_list; + GHashTable *client_table; + GObject *object; + + object = G_OBJECT (shell_view_class->type_module); + source_list = g_object_get_data (object, "source-list"); + g_return_if_fail (E_IS_SOURCE_LIST (source_list)); + + client_table = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_object_unref); + + priv->source_list = g_object_ref (source_list); + priv->memo_actions = gtk_action_group_new ("memos"); + priv->client_table = client_table; + + if (!gal_view_collection_loaded (shell_view_class->view_collection)) + memo_shell_view_load_view_collection (shell_view_class); + + g_signal_connect ( + memo_shell_view, "notify::view-id", + G_CALLBACK (memo_shell_view_notify_view_id_cb), NULL); +} + +void +e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) +{ + EMemoShellViewPrivate *priv = memo_shell_view->priv; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EShellView *shell_view; + EMemoTable *memo_table; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + /* Cache these to avoid lots of awkward casting. */ + priv->memo_shell_content = g_object_ref (shell_content); + priv->memo_shell_sidebar = g_object_ref (shell_sidebar); + + memo_table = e_memo_shell_content_get_memo_table ( + priv->memo_shell_content); + + g_signal_connect_swapped ( + memo_table, "user-created", + G_CALLBACK (memo_shell_view_user_created_cb), + memo_shell_view); + + e_memo_shell_view_actions_update (memo_shell_view); +} + +void +e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) +{ + EMemoShellViewPrivate *priv = memo_shell_view->priv; + + DISPOSE (priv->source_list); + + DISPOSE (priv->memo_actions); + + DISPOSE (priv->memo_shell_content); + DISPOSE (priv->memo_shell_sidebar); + + g_hash_table_remove_all (priv->client_table); + DISPOSE (priv->default_client); +} + +void +e_memo_shell_view_private_finalize (EMemoShellView *memo_shell_view) +{ + EMemoShellViewPrivate *priv = memo_shell_view->priv; + + g_hash_table_destroy (priv->client_table); +} + +void +e_memo_shell_view_set_status_message (EMemoShellView *memo_shell_view, + const gchar *status_message) +{ + g_return_if_fail (E_IS_MEMO_SHELL_VIEW (memo_shell_view)); + + /* FIXME */ +} diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h new file mode 100644 index 0000000000..1fb44c12a6 --- /dev/null +++ b/calendar/modules/e-memo-shell-view-private.h @@ -0,0 +1,106 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view-private.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_VIEW_PRIVATE_H +#define E_MEMO_SHELL_VIEW_PRIVATE_H + +#include "e-memo-shell-view.h" + +#include +#include + +#include "e-util/e-error.h" +#include "e-util/e-util.h" + +#include "calendar/gui/misc.h" +#include "calendar/gui/e-calendar-selector.h" +#include "calendar/gui/e-memo-preview.h" +#include "calendar/common/authentication.h" +#include "calendar/gui/dialogs/calendar-setup.h" + +#include "e-memo-shell-content.h" +#include "e-memo-shell-sidebar.h" +#include "e-memo-shell-view-actions.h" + +#define E_MEMO_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewPrivate)) + +/* Shorthand, requires a variable named "shell_window". */ +#define ACTION(name) \ + (E_SHELL_WINDOW_ACTION_##name (shell_window)) +#define ACTION_GROUP(name) \ + (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) + +/* For use in dispose() methods. */ +#define DISPOSE(obj) \ + G_STMT_START { \ + if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ + } G_STMT_END + +/* ETable Specifications */ +#define ETSPEC_FILENAME "e-memo-table.etspec" + +G_BEGIN_DECLS + +struct _EMemoShellViewPrivate { + + /*** Module Data ***/ + + ESourceList *source_list; + + /*** UI Management ***/ + + GtkActionGroup *memo_actions; + + /*** Other Stuff ***/ + + /* These are just for convenience. */ + EMemoShellContent *memo_shell_content; + EMemoShellSidebar *memo_shell_sidebar; + + /* UID -> ECal */ + GHashTable *client_table; + ECal *default_client; +}; + +void e_memo_shell_view_private_init + (EMemoShellView *memo_shell_view, + EShellViewClass *shell_view_class); +void e_memo_shell_view_private_constructed + (EMemoShellView *memo_shell_view); +void e_memo_shell_view_private_dispose + (EMemoShellView *memo_shell_view); +void e_memo_shell_view_private_finalize + (EMemoShellView *memo_shell_view); + +/* Private Utilities */ + +void e_memo_shell_view_actions_init + (EMemoShellView *memo_shell_view); +void e_memo_shell_view_actions_update + (EMemoShellView *memo_shell_view); +void e_memo_shell_view_set_status_message + (EMemoShellView *memo_shell_view, + const gchar *status_message); + +G_END_DECLS + +#endif /* E_MEMO_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c new file mode 100644 index 0000000000..f50c877c9a --- /dev/null +++ b/calendar/modules/e-memo-shell-view.c @@ -0,0 +1,167 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-memo-shell-view-private.h" + +enum { + PROP_0, + PROP_SOURCE_LIST +}; + +GType e_memo_shell_view_type = 0; +static gpointer parent_class; + +static void +memo_shell_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SOURCE_LIST: + g_value_set_object ( + value, e_memo_shell_view_get_source_list ( + E_MEMO_SHELL_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_shell_view_dispose (GObject *object) +{ + e_memo_shell_view_private_dispose (E_MEMO_SHELL_VIEW (object)); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_shell_view_finalize (GObject *object) +{ + e_memo_shell_view_private_finalize (E_MEMO_SHELL_VIEW (object)); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +memo_shell_view_constructed (GObject *object) +{ + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + e_memo_shell_view_private_constructed (E_MEMO_SHELL_VIEW (object)); +} + +static void +memo_shell_view_changed (EShellView *shell_view) +{ + EMemoShellViewPrivate *priv; + GtkActionGroup *action_group; + gboolean visible; + + priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view); + + action_group = priv->memo_actions; + visible = e_shell_view_is_active (shell_view); + gtk_action_group_set_visible (action_group, visible); +} + +static void +memo_shell_view_class_init (EMemoShellView *class, + GTypeModule *type_module) +{ + GObjectClass *object_class; + EShellViewClass *shell_view_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoShellViewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = memo_shell_view_get_property; + object_class->dispose = memo_shell_view_dispose; + object_class->finalize = memo_shell_view_finalize; + object_class->constructed = memo_shell_view_constructed; + + shell_view_class = E_SHELL_VIEW_CLASS (class); + shell_view_class->label = N_("Memos"); + shell_view_class->icon_name = "evolution-memos"; + shell_view_class->search_options = "/memo-search-options"; + shell_view_class->type_module = type_module; + shell_view_class->new_shell_content = e_memo_shell_content_new; + shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new; + shell_view_class->changed = memo_shell_view_changed; + + g_object_class_install_property ( + object_class, + PROP_SOURCE_LIST, + g_param_spec_object ( + "source-list", + _("Source List"), + _("The registry of memo lists"), + E_TYPE_SOURCE_LIST, + G_PARAM_READABLE)); +} + +static void +memo_shell_view_init (EMemoShellView *memo_shell_view, + EShellViewClass *shell_view_class) +{ + memo_shell_view->priv = + E_MEMO_SHELL_VIEW_GET_PRIVATE (memo_shell_view); + + e_memo_shell_view_private_init (memo_shell_view, shell_view_class); +} + +GType +e_memo_shell_view_get_type (GTypeModule *type_module) +{ + if (e_memo_shell_view_type == 0) { + const GTypeInfo type_info = { + sizeof (EMemoShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) memo_shell_view_class_init, + (GClassFinalizeFunc) NULL, + type_module, + sizeof (EMemoShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) memo_shell_view_init, + NULL /* value_table */ + }; + + e_memo_shell_view_type = + g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "EMemoShellView", &type_info, 0); + } + + return e_memo_shell_view_type; +} + +ESourceList * +e_memo_shell_view_get_source_list (EMemoShellView *memo_shell_view) +{ + g_return_val_if_fail (E_IS_MEMO_SHELL_VIEW (memo_shell_view), NULL); + + return memo_shell_view->priv->source_list; +} diff --git a/calendar/modules/e-memo-shell-view.h b/calendar/modules/e-memo-shell-view.h new file mode 100644 index 0000000000..dc41d5f9f0 --- /dev/null +++ b/calendar/modules/e-memo-shell-view.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-memo-shell-view.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_MEMO_SHELL_VIEW_H +#define E_MEMO_SHELL_VIEW_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MEMO_SHELL_VIEW \ + (e_memo_shell_view_type) +#define E_MEMO_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellView)) +#define E_MEMO_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewClass)) +#define E_IS_MEMO_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MEMO_SHELL_VIEW)) +#define E_IS_MEMO_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MEMO_SHELL_VIEW)) +#define E_MEMO_SHELL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MEMO_SHELL_VIEW, EMemoShellViewClass)) + +G_BEGIN_DECLS + +extern GType e_memo_shell_view_type; + +typedef struct _EMemoShellView EMemoShellView; +typedef struct _EMemoShellViewClass EMemoShellViewClass; +typedef struct _EMemoShellViewPrivate EMemoShellViewPrivate; + +struct _EMemoShellView { + EShellView parent; + EMemoShellViewPrivate *priv; +}; + +struct _EMemoShellViewClass { + EShellViewClass parent_class; +}; + +GType e_memo_shell_view_get_type + (GTypeModule *type_module); +ESourceList * e_memo_shell_view_get_source_list + (EMemoShellView *memo_shell_view); + +G_END_DECLS + +#endif /* E_MEMO_SHELL_VIEW_H */ diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c new file mode 100644 index 0000000000..8f7e45f175 --- /dev/null +++ b/calendar/modules/e-task-shell-content.c @@ -0,0 +1,550 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-content.h" + +#include + +#include "e-util/gconf-bridge.h" + +#include "calendar/gui/e-calendar-table.h" +#include "calendar/gui/e-calendar-table-config.h" + +#include "widgets/menus/gal-view-etable.h" + +#define E_TASK_SHELL_CONTENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContentPrivate)) + +#define E_TASK_TABLE_DEFAULT_STATE \ + "" \ + "" \ + " " \ + " " \ + " " \ + " " \ + " + "" + +struct _ETaskShellContentPrivate { + GtkWidget *paned; + GtkWidget *task_table; + GtkWidget *task_preview; + + ETaskTableConfig *table_config; + GalViewInstance *view_instance; + + gchar *current_uid; +}; + +enum { + PROP_0, + PROP_PREVIEW_VISIBLE +}; + +enum { + TARGET_VCALENDAR +}; + +static GtkTargetEntry drag_types[] = { + { "text/calendar", 0, TARGET_VCALENDAR }, + { "text/x-calendar", 0, TARGET_VCALENDAR } +}; + +static gpointer parent_class; + +static void +task_shell_content_changed_cb (ETaskShellContent *task_shell_content, + GalViewInstance *view_instance) +{ + EShellView *shell_view; + EShellContent *shell_content; + gchar *view_id; + + shell_content = E_SHELL_CONTENT (task_shell_content); + shell_view = e_shell_content_get_shell_view (shell_content); + view_id = gal_view_instance_get_current_view_id (view_instance); + e_shell_view_set_view_id (shell_view, view_id); + g_free (view_id); +} + +static void +task_shell_content_display_view_cb (ETaskShellContent *task_shell_content, + GalView *gal_view) +{ + ECalendarTable *task_table; + ETableScrolled *table_scrolled; + ETable *table; + + if (!GAL_IS_VIEW_ETABLE (gal_view)) + return; + + task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); + table_scrolled = E_TABLE_SCROLLED (task_table->etable); + table = e_table_scrolled_get_table (table_scrolled); + + gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); +} + +static void +task_shell_content_table_drag_data_get_cb (ETaskShellContent *task_shell_content, + gint row, + gint col, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint info, + guint time) +{ + /* FIXME */ +} + +static void +task_shell_content_table_drag_data_delete_cb (ETaskShellContent *task_shell_content, + gint row, + gint col, + GdkDragContext *context) +{ + /* Moved components are deleted from source immediately when moved, + * because some of them can be part of destination source, and we + * don't want to delete not-moved tasks. There is no such information + * which event has been moved and which not, so skip this method. */ +} + +static void +task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, + gint row, + ETable *table) +{ + ETaskPreview *task_preview; + ETaskTable *task_table; + ECalModel *model; + ECalModelComponent *comp_data; + ECalComponent *comp; + const gchar *uid; + + task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview); + task_table = E_TASK_TABLE (task_shell_content->priv->task_table); + + if (e_table_selected_count (table) != 1) { + e_task_preview_clear (task_preview); + return; + } + + model = e_task_table_get_model (task_table); + row = e_table_get_cursor_row (table); + comp_data = e_cal_model_get_component_at (model, row); + + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent ( + comp, icalcomponent_new_clone (comp_data->icalcomp)); + e_task_preview_display (task_preview, comp_data->client, comp); + + e_cal_component_get_uid (comp, &uid); + g_free (task_shell_content->priv->current_uid); + task_shell_content->priv->current_uid = g_strdup (uid); + + g_object_unref (comp); +} + +static void +task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content, + ETable *table) +{ + ETaskPreview *task_preview; + + task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview); + + /* XXX Old code emits a "selection-changed" signal here. */ + + if (e_table_selected_count (table) != 1) + e_task_preview_clear (task_preview); +} + +static void +task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, + gint row, + ETableModel *model) +{ + ECalModelComponent *comp_data; + ETaskTable *task_table; + ETableScrolled *table_scrolled; + ETable *table; + const gchar *current_uid; + const gchar *uid; + + current_uid = task_shell_content->priv->current_uid; + if (current_uid == NULL) + return; + + comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); + if (comp_data == NULL) + return; + + uid = icalcomponent_get_uid (comp_data->icalcomp); + if (g_strcmp0 (uid, current_uid) != 0) + return; + + task_table = E_TASK_TABLE (task_shell_content->priv->task_table); + table_scrolled = E_TABLE_SCROLLED (task_table->etable); + table = e_table_scrolled_get_table (table_scrolled); + + task_shell_content_cursor_change_cb (task_shell_content, 0, table); +} + +static void +task_shell_content_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + e_task_shell_content_set_preview_visible ( + E_TASK_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_shell_content_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + g_value_set_boolean ( + value, e_task_shell_content_get_preview_visible ( + E_TASK_SHELL_CONTENT (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_shell_content_dispose (GObject *object) +{ + ETaskShellContentPrivate *priv; + + priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (object); + + if (priv->paned != NULL) { + g_object_unref (priv->paned); + priv->paned = NULL; + } + + if (priv->task_table != NULL) { + g_object_unref (priv->task_table); + priv->task_table = NULL; + } + + if (priv->task_preview != NULL) { + g_object_unref (priv->task_preview); + priv->task_preview = NULL; + } + + if (priv->table_config != NULL) { + g_object_unref (priv->table_config); + priv->table_config = NULL; + } + + if (priv->view_instance != NULL) { + g_object_unref (priv->view_instance); + priv->view_instance = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +task_shell_content_finalize (GObject *object) +{ + ETaskShellContentPrivate *priv; + + priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (object); + + g_free (priv->current_uid); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +task_shell_content_constructed (GObject *object) +{ + ETaskShellContentPrivate *priv; + EShellContent *shell_content; + EShellView *shell_view; + EShellViewClass *shell_view_class; + GalViewCollection *view_collection; + GalViewInstance *view_instance; + ECalModel *model; + ETable *table; + GConfBridge *bridge; + GtkWidget *container; + GtkWidget *widget; + const gchar *key; + + priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + shell_content = E_SHELL_CONTENT (object); + shell_view = e_shell_content_get_shell_view (shell_content); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + view_collection = shell_view_class->view_collection; + + /* Load the view instance. */ + + view_instance = gal_view_instance_new (view_collection, NULL); + g_signal_connect_swapped ( + view_instance, "changed", + G_CALLBACK (task_shell_content_changed_cb), + object); + g_signal_connect_swapped ( + view_instance, "display-view", + G_CALLBACK (task_shell_content_display_view_cb), + object); + gal_view_instance_load (view_instance); + priv->view_instance = view_instance; + + /* Build content widgets. */ + + container = GTK_WIDGET (object); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->paned = g_object_ref (widget); + gtk_widget_show (widget); + + container = widget; + + widget = e_task_table_new (shell_view); + gtk_paned_add1 (GTK_PANED (container), widget); + priv->task_table = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_paned_add2 (GTK_PANED (container), widget); + + container = widget; + + widget = e_task_preview_new (); + e_task_preview_set_default_timezone ( + E_TASK_PREVIEW (widget), + calendar_config_get_icaltimezone ()); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->task_preview = g_object_ref (widget); + gtk_widget_show (widget); + + /* Configure the task table. */ + + widget = E_TASK_TABLE (priv->task_table)->etable; + table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); + model = e_task_table_get_model (E_TASK_TABLE (priv->task_table)); + + priv->table_config = e_task_table_config_new ( + E_TASK_TABLE (priv->task_table)); + + e_table_set_state (table, E_TASK_TABLE_DEFAULT_STATE); + + e_table_drag_source_set ( + table, GDK_BUTTON1_MASK, + drag_types, G_N_ELEMENTS (drag_types), + GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK); + + g_signal_connect_swapped ( + table, "table-drag-data-get", + G_CALLBACK (task_shell_content_table_drag_data_get_cb), + object); + + g_signal_connect_swapped ( + table, "table-drag-data-delete", + G_CALLBACK (task_shell_content_table_drag_data_delete_cb), + object); + + g_signal_connect_swapped ( + table, "cursor-change", + G_CALLBACK (task_shell_content_cursor_change_cb), + object); + + g_signal_connect_swapped ( + table, "selection-change", + G_CALLBACK (task_shell_content_selection_change_cb), + object); + + g_signal_connect_swapped ( + model, "model-row-changed", + G_CALLBACK (task_shell_content_model_row_changed_cb), + object); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (priv->paned); + key = "/apps/evolution/calendar/display/task_vpane_position"; + gconf_bridge_bind_property_delayed (bridge, key, object, "position"); +} + +static void +task_shell_content_class_init (ETaskShellContentClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ETaskShellContentPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = task_shell_content_set_property; + object_class->get_property = task_shell_content_get_property; + object_class->dispose = task_shell_content_dispose; + object_class->finalize = task_shell_content_finalize; + object_class->constructed = task_shell_content_constructed; + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_VISIBLE, + g_param_spec_boolean ( + "preview-visible", + _("Preview is Visible"), + _("Whether the preview pane is visible"), + TRUE, + G_PARAM_READWRITE)); +} + +static void +task_shell_content_init (ETaskShellContent *task_shell_content) +{ + task_shell_content->priv = + E_TASK_SHELL_CONTENT_GET_PRIVATE (task_shell_content); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_task_shell_content_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ETaskShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) task_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ETaskShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) task_shell_content_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_CONTENT, "ETaskShellContent", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_task_shell_content_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_TASK_SHELL_CONTENT, + "shell-view", shell_view, NULL); +} + +ETaskPreview * +e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); + + return E_TASK_PREVIEW (task_shell_content->priv->task_preview); +} + +ETaskTable * +e_task_shell_content_get_task_table (ETaskShellContent *task_shell_content) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); + + return E_TASK_TABLE (task_shell_content->priv->task_table); +} + +GalViewInstance * +e_task_shell_content_get_view_instance (ETaskShellContent *task_shell_content) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); + + return task_shell_content->priv->view_instance; +} + +gboolean +e_task_shell_content_get_preview_visible (ETaskShellContent *task_shell_content) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_val_if_fail ( + E_IS_TASK_SHELL_CONTENT (task_shell_content), FALSE); + + paned = GTK_PANED (task_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + return GTK_WIDGET_VISIBLE (child); +} + +void +e_task_shell_content_set_preview_visible (ETaskShellContent *task_shell_content, + gboolean preview_visible) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_if_fail (E_IS_TASK_SHELL_CONTENT (task_shell_content)); + + paned = GTK_PANED (task_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + if (preview_visible) + gtk_widget_show (child); + else + gtk_widget_hide (child); + + g_object_notify (G_OBJECT (task_shell_content), "preview-visible"); +} diff --git a/calendar/modules/e-task-shell-content.h b/calendar/modules/e-task-shell-content.h new file mode 100644 index 0000000000..0bf91254c1 --- /dev/null +++ b/calendar/modules/e-task-shell-content.h @@ -0,0 +1,76 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_CONTENT_H +#define E_TASK_SHELL_CONTENT_H + +#include +#include + +#include + +/* Standard GObject macros */ +#define E_TYPE_TASK_SHELL_CONTENT \ + (e_task_shell_content_get_type ()) +#define E_TASK_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContent)) +#define E_TASK_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContentClass)) +#define E_IS_TASK_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_TASK_SHELL_CONTENT)) +#define E_IS_TASK_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_TASK_SHELL_CONTENT)) +#define E_TASK_SHELL_CONTENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContentClass)) + +G_BEGIN_DECLS + +typedef struct _ETaskShellContent ETaskShellContent; +typedef struct _ETaskShellContentClass ETaskShellContentClass; +typedef struct _ETaskShellContentPrivate ETaskShellContentPrivate; + +struct _ETaskShellContent { + EShellContent parent; + ETaskShellContentPrivate *priv; +}; + +struct _ETaskShellContentClass { + EShellContentClass parent_class; +}; + +GType e_task_shell_content_get_type (void); +GtkWidget * e_task_shell_content_new (EShellView *shell_view); +GalViewInstance * + e_task_shell_content_get_view_instance + (ETaskShellContent *task_shell_content); +gboolean e_task_shell_content_get_preview_visible + (ETaskShellContent *task_shell_content); +void e_task_shell_content_set_preview_visible + (ETaskShellContent *task_shell_content, + gboolean preview_visible); + +G_END_DECLS + +#endif /* E_TASK_SHELL_CONTENT_H */ diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c new file mode 100644 index 0000000000..93b3871581 --- /dev/null +++ b/calendar/modules/e-task-shell-module.c @@ -0,0 +1,297 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-module.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include "shell/e-shell.h" +#include "shell/e-shell-module.h" +#include "shell/e-shell-window.h" + +#include "calendar/gui/calendar-config.h" + +#include "e-task-shell-view.h" + +#define MODULE_NAME "tasks" +#define MODULE_ALIASES "" +#define MODULE_SCHEMES "task" +#define MODULE_SEARCHES "tasktypes.xml" +#define MODULE_SORT_ORDER 600 + +#define WEB_BASE_URI "webcal://" +#define PERSONAL_RELATIVE_URI "system" + +/* Module Entry Point */ +void e_shell_module_init (GTypeModule *type_module); + +static void +task_module_ensure_sources (EShellModule *shell_module) +{ + /* XXX This is basically the same algorithm across all modules. + * Maybe we could somehow integrate this into EShellModule? */ + + ESourceList *source_list; + ESourceGroup *on_this_computer; + ESourceGroup *on_the_web; + ESource *personal; + GSList *groups, *iter; + const gchar *data_dir; + gchar *base_uri; + gchar *filename; + + on_this_computer = NULL; + on_the_web = NULL; + personal = NULL; + + if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_TODO, NULL)) { + g_warning ("Could not get task sources from GConf!"); + return; + } + + /* Share the source list with all task views. This is + * accessible via e_task_shell_view_get_source_list(). + * Note: EShellModule takes ownership of the reference. + * + * XXX I haven't yet decided if I want to add a proper + * EShellModule API for this. The mail module would + * not use it. */ + g_object_set_data_full ( + G_OBJECT (shell_module), "source-list", + source_list, (GDestroyNotify) g_object_unref); + + data_dir = e_shell_module_get_data_dir (shell_module); + filename = g_build_filename (data_dir, "local", NULL); + base_uri = g_filename_to_uri (filename, NULL, NULL); + g_free (filename); + + groups = e_source_list_peek_groups (source_list); + for (iter = groups; iter != NULL; iter = iter->next) { + ESourceGroup *source_group = iter->data; + const gchar *group_base_uri; + + group_base_uri = e_source_group_peek_base_uri (source_group); + + /* Compare only "file://" part. If the user's home + * changes, we do not want to create another group. */ + if (on_this_computer == NULL && + strncmp (base_uri, group_base_uri, 7) == 0) + on_this_computer = source_group; + + else if (on_the_web == NULL && + strcmp (WEB_BASE_URI, group_base_uri) == 0) + on_the_web = source_group; + } + + if (on_this_computer != NULL) { + GSList *sources; + const gchar *group_base_uri; + + sources = e_source_group_peek_sources (on_this_computer); + group_base_uri = e_source_group_peek_base_uri (on_this_computer); + + /* Make sure this group includes a "Personal" source. */ + for (iter = sources; iter != NULL; iter = iter->next) { + ESource *source = iter->data; + const gchar *relative_uri; + + relative_uri = e_source_peek_relative_uri (source); + if (relative_uri == NULL) + continue; + + if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0) + continue; + + personal = source; + break; + } + + /* Make sure we have the correct base URI. This can + * change when the user's home directory changes. */ + if (strcmp (base_uri, group_base_uri) != 0) { + e_source_group_set_base_uri ( + on_this_computer, base_uri); + + /* XXX We shouldn't need this sync call here as + * set_base_uri() results in synching to GConf, + * but that happens in an idle loop and too late + * to prevent the user from seeing a "Cannot + * Open ... because of invalid URI" error. */ + e_source_list_sync (source_list, NULL); + } + + } else { + ESourceGroup *source_group; + const gchar *name; + + name = _("On This Computer"); + source_group = e_source_group_new (name, base_uri); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + if (personal == NULL) { + ESource *source; + GSList *selected; + const gchar *name; + gchar *primary; + + name = _("Personal"); + source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_group_add_source (on_this_computer, source, -1); + g_object_unref (source); + + primary = calendar_config_get_primary_tasks (); + selected = calendar_config_get_tasks_selected (); + + if (primary == NULL && selected == NULL) { + const gchar *uid; + + uid = e_source_peek_uid (source); + selected = g_slist_prepend (NULL, g_strdup (uid)); + + calendar_config_set_primary_tasks (uid); + calendar_config_set_tasks_selected (selected); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + g_slist_free (selected); + g_free (primary); + } + + if (on_the_web == NULL) { + ESourceGroup *source_group; + const gchar *name; + + name = _("On The Web"); + source_group = e_source_group_new (name, WEB_BASE_URI); + e_source_list_add_group (source_list, source_group, -1); + g_object_unref (source_group); + } + + g_free (base_uri); +} + +static void +action_task_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_task_assigned_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static void +action_task_list_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ +} + +static GtkActionEntry item_entries[] = { + + { "task-new", + "stock_task", + N_("_Task"), /* XXX Need C_() here */ + "t", + N_("Create a new task"), + G_CALLBACK (action_task_new_cb) }, + + { "task-assigned-new", + "stock_task", + N_("Assigne_d Task"), + NULL, + N_("Create a new assigned task"), + G_CALLBACK (action_task_assigned_new_cb) } +}; + +static GtkActionEntry source_entries[] = { + + { "task-list-new", + "stock_todo", + N_("Tas_k List"), + NULL, + N_("Create a new task list"), + G_CALLBACK (action_task_list_new_cb) } +}; + +static gboolean +task_module_handle_uri (EShellModule *shell_module, + const gchar *uri) +{ + /* FIXME */ + return FALSE; +} + +static void +task_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window) +{ + const gchar *module_name; + + module_name = G_TYPE_MODULE (shell_module)->name; + + e_shell_window_register_new_item_actions ( + shell_window, module_name, + item_entries, G_N_ELEMENTS (item_entries)); + + e_shell_window_register_new_source_actions ( + shell_window, module_name, + source_entries, G_N_ELEMENTS (source_entries)); +} + +static EShellModuleInfo module_info = { + + MODULE_NAME, + MODULE_ALIASES, + MODULE_SCHEMES, + MODULE_SEARCHES, + MODULE_SORT_ORDER +}; + +void +e_shell_module_init (GTypeModule *type_module) +{ + EShell *shell; + EShellModule *shell_module; + + shell_module = E_SHELL_MODULE (type_module); + shell = e_shell_module_get_shell (shell_module); + + /* Register the GType for ETaskShellView. */ + e_task_shell_view_get_type (type_module); + + e_shell_module_set_info (shell_module, &module_info); + + task_module_ensure_sources (shell_module); + + g_signal_connect_swapped ( + shell, "handle-uri", + G_CALLBACK (task_module_handle_uri), shell_module); + + g_signal_connect_swapped ( + shell, "window-created", + G_CALLBACK (task_module_window_created), shell_module); +} diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c new file mode 100644 index 0000000000..b3d0c487bc --- /dev/null +++ b/calendar/modules/e-task-shell-sidebar.c @@ -0,0 +1,265 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-sidebar.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-sidebar.h" + +#include + +#include "calendar/gui/e-calendar-selector.h" + +#include "e-task-shell-view.h" + +#define E_TASK_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarPrivate)) + +struct _ETaskShellSidebarPrivate { + GtkWidget *selector; +}; + +enum { + PROP_0, + PROP_SELECTOR +}; + +static gpointer parent_class; + +#if 0 /* MOVE THIS TO ETaskShellView */ +static void +task_shell_sidebar_update (EShellSidebar *shell_sidebar) +{ + EShellView *shell_view; + ETasks *tasks; + ETable *table; + ECalModel *model; + ECalendarTable *cal_table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + tasks = e_task_shell_view_get_tasks (E_TASK_SHELL_VIEW (shell_view)); + cal_table = e_tasks_get_calendar_table (tasks); + model = e_calendar_table_get_model (cal_table); + table = e_calendar_table_get_table (cal_table); + + n_rows = e_table_model_get_row_count (model); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d task", "%d tasks", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} +#endif + +static void +task_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SELECTOR: + g_value_set_object ( + value, e_task_shell_sidebar_get_selector ( + E_TASK_SHELL_SIDEBAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_shell_sidebar_dispose (GObject *object) +{ + ETaskShellSidebarPrivate *priv; + + priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + + if (priv->selector != NULL) { + g_object_unref (priv->selector); + priv->selector = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +task_shell_sidebar_constructed (GObject *object) +{ + ETaskShellSidebarPrivate *priv; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + ETaskShellView *task_shell_view; + ESourceList *source_list; + GtkContainer *container; + GtkWidget *widget; + + priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + + shell_sidebar = E_SHELL_SIDEBAR (object); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + task_shell_view = E_TASK_SHELL_VIEW (shell_view); + source_list = e_task_shell_view_get_source_list (task_shell_view); + + container = GTK_CONTAINER (shell_sidebar); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_container_add (container, widget); + gtk_widget_show (widget); + + container = GTK_CONTAINER (widget); + + widget = e_calendar_selector_new (source_list); + e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); + gtk_container_add (container, widget); + priv->selector = g_object_ref (widget); + gtk_widget_show (widget); + +#if 0 /* MOVE THIS TO ETaskShellView */ + + /* Setup signal handlers. */ + + tasks = e_task_shell_view_get_tasks (task_shell_view); + cal_table = e_tasks_get_calendar_table (tasks); + model = e_calendar_table_get_model (cal_table); + table = e_calendar_table_get_table (cal_table); + + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + g_signal_connect_swapped ( + model, "selection-change", + G_CALLBACK (task_shell_sidebar_update), + shell_sidebar); + + task_shell_sidebar_update (shell_sidebar); + +#endif +} + +static void +task_shell_sidebar_class_init (ETaskShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ETaskShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = task_shell_sidebar_get_property; + object_class->dispose = task_shell_sidebar_dispose; + object_class->constructed = task_shell_sidebar_constructed; + + g_object_class_install_property ( + object_class, + PROP_SELECTOR, + g_param_spec_object ( + "selector", + _("Source Selector Widget"), + _("This widget displays groups of task lists"), + E_TYPE_SOURCE_SELECTOR, + G_PARAM_READABLE)); +} + +static void +task_shell_sidebar_init (ETaskShellSidebar *task_shell_sidebar) +{ + task_shell_sidebar->priv = + E_TASK_SHELL_SIDEBAR_GET_PRIVATE (task_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_task_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ETaskShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) task_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ETaskShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) task_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "ETaskShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_task_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_TASK_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} + +GtkWidget * +e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar), NULL); + + return task_shell_sidebar->priv->selector; +} diff --git a/calendar/modules/e-task-shell-sidebar.h b/calendar/modules/e-task-shell-sidebar.h new file mode 100644 index 0000000000..2d992dbc82 --- /dev/null +++ b/calendar/modules/e-task-shell-sidebar.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-sidebar.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_SIDEBAR_H +#define E_TASK_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_TASK_SHELL_SIDEBAR \ + (e_task_shell_sidebar_get_type ()) +#define E_TASK_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebar)) +#define E_TASK_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) +#define E_IS_TASK_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR)) +#define E_IS_TASK_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_TASK_SHELL_SIDEBAR)) +#define E_TASK_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _ETaskShellSidebar ETaskShellSidebar; +typedef struct _ETaskShellSidebarClass ETaskShellSidebarClass; +typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate; + +struct _ETaskShellSidebar { + EShellSidebar parent; + ETaskShellSidebarPrivate *priv; +}; + +struct _ETaskShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_task_shell_sidebar_get_type (void); +GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); +GtkWidget * e_task_shell_sidebar_get_selector + (ETaskShellSidebar *task_shell_sidebar); + +G_END_DECLS + +#endif /* E_TASK_SHELL_SIDEBAR_H */ diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c new file mode 100644 index 0000000000..2668522aee --- /dev/null +++ b/calendar/modules/e-task-shell-view-actions.c @@ -0,0 +1,332 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view-actions.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-view-private.h" + +static void +action_task_assign_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static void +action_task_clipboard_copy_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + e_task_table_copy_clipboard (task_table); +} + +static void +action_task_clipboard_cut_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + e_task_table_cut_clipboard (task_table); +} + +static void +action_task_clipboard_paste_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + e_task_table_paste_clipboard (task_table); +} + +static void +action_task_delete_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskPreview *task_preview; + ETaskTable *task_table; + const gchar *status_message; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + task_preview = e_task_shell_content_get_task_preview (task_shell_content); + + status_message = _("Deleting selected tasks..."); + e_task_shell_view_set_status_message (task_shell_view, status_message); + e_task_table_delete_selected (task_table); + e_task_shell_view_set_status_message (task_shell_view, NULL); + + e_task_preview_clear (task_preview); +} + +static void +action_task_forward_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static void +action_task_list_copy_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + /* FIXME */ +} + +static void +action_task_list_delete_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + /* FIXME */ +} + +static void +action_task_list_new_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static void +action_task_list_properties_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static void +action_task_mark_complete_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static void +action_task_open_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + e_task_table_open_selected (task_table); +} + +static void +action_task_preview_cb (GtkToggleAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + gboolean visible; + + task_shell_content = task_shell_view->priv->task_shell_content; + visible = gtk_toggle_action_get_active (action); + e_task_shell_content_set_preview_visible (task_shell_content, visible); +} + +static void +action_task_print_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ETable *table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + table = e_task_table_get_table (task_table); + + print_table ( + table, _("Print Tasks"), _("Tasks"), + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +} + +static void +action_task_print_preview_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ETable *table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + table = e_task_table_get_table (task_table); + + print_table ( + table, _("Print Tasks"), _("Tasks"), + GTK_PRINT_OPERATION_ACTION_PREVIEW); +} + +static void +action_task_purge_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ +} + +static GtkActionEntry task_entries[] = { + + { "task-assign", + NULL, + N_("_Assign Task"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_assign_cb) }, + + { "task-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy selected tasks"), + G_CALLBACK (action_task_clipboard_copy_cb) }, + + { "task-clipboard-cut", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut selected tasks"), + G_CALLBACK (action_task_clipboard_cut_cb) }, + + { "task-clipboard-paste", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste tasks from the clipboard"), + G_CALLBACK (action_task_clipboard_paste_cb) }, + + { "task-delete", + GTK_STOCK_DELETE, + NULL, + NULL, + N_("Delete selected tasks"), + G_CALLBACK (action_task_delete_cb) }, + + { "task-forward", + "mail-forward", + N_("_Forward as iCalendar"), + "f", + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_forward_cb) }, + + { "task-list-copy", + GTK_STOCK_COPY, + N_("Copy..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_list_copy_cb) }, + + { "task-list-delete", + GTK_STOCK_DELETE, + N_("_Delete"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_list_delete_cb) }, + + { "task-list-new", + "stock_todo", + N_("_New Task List"), + NULL, + N_("Create a new task list"), + G_CALLBACK (action_task_list_new_cb) }, + + { "task-list-properties", + GTK_STOCK_PROPERTIES, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_list_properties_cb) }, + + { "task-mark-complete", + NULL, + N_("Mar_k as Complete"), + "k", + N_("Mark selected tasks as complete"), + G_CALLBACK (action_task_mark_complete_cb) }, + + { "task-open", + NULL, + N_("_Open Task"), + "o", + N_("View the selected task"), + G_CALLBACK (action_task_open_cb) }, + + { "task-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the list of tasks"), + G_CALLBACK (action_task_print_cb) }, + + { "task-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the list of tasks to be printed"), + G_CALLBACK (action_task_print_preview_cb) }, + + { "task-purge", + NULL, + N_("Purg_e"), + "e", + N_("Delete completed tasks"), + G_CALLBACK (action_task_purge_cb) } +}; + +static GtkToggleActionEntry task_toggle_entries[] = { + + { "task-preview", + NULL, + N_("Task _Preview"), + "m", + N_("Show task preview pane"), + G_CALLBACK (action_task_preview_cb), + TRUE } +}; + +void +e_task_shell_view_actions_init (ETaskShellView *task_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *manager; + const gchar *domain; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + manager = e_shell_window_get_ui_manager (shell_window); + domain = GETTEXT_PACKAGE; + + e_load_ui_definition (manager, "evolution-tasks.ui"); + + action_group = task_shell_view->priv->task_actions; + gtk_action_group_set_translation_domain (action_group, domain); + gtk_action_group_add_actions ( + action_group, task_entries, + G_N_ELEMENTS (task_entries), task_shell_view); + gtk_action_group_add_toggle_actions ( + action_group, task_toggle_entries, + G_N_ELEMENTS (task_toggle_entries), task_shell_view); + gtk_ui_manager_insert_action_group (manager, action_group, 0); +} diff --git a/calendar/modules/e-task-shell-view-actions.h b/calendar/modules/e-task-shell-view-actions.h new file mode 100644 index 0000000000..9c31590814 --- /dev/null +++ b/calendar/modules/e-task-shell-view-actions.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view-actions.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_VIEW_ACTIONS_H +#define E_TASK_SHELL_VIEW_ACTIONS_H + +#include + +/* Task Actions */ +#define E_SHELL_WINDOW_ACTION_TASK_ASSIGN(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-assign") +#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_CUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-clibpard-cut") +#define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_PASTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-clipboard-paste") +#define E_SHELL_WINDOW_ACTION_TASK_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-delete") +#define E_SHELL_WINDOW_ACTION_TASK_FORWARD(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-forward") +#define E_SHELL_WINDOW_ACTION_TASK_MARK_COMPLETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-mark-complete") +#define E_SHELL_WINDOW_ACTION_TASK_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-open") +#define E_SHELL_WINDOW_ACTION_TASK_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-preview") +#define E_SHELL_WINDOW_ACTION_TASK_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-print") +#define E_SHELL_WINDOW_ACTION_TASK_PRINT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-print-preview") +#define E_SHELL_WINDOW_ACTION_TASK_PURGE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-purge") + +/* Action Groups */ +#define E_SHELL_WINDOW_ACTION_GROUP_TASKS(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "tasks") + +#endif /* E_TASK_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c new file mode 100644 index 0000000000..465f715ecd --- /dev/null +++ b/calendar/modules/e-task-shell-view-private.c @@ -0,0 +1,141 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view-private.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-view-private.h" + +#include + +static void +task_shell_view_load_view_collection (EShellViewClass *shell_view_class) +{ + GalViewCollection *collection; + GalViewFactory *factory; + ETableSpecification *spec; + const gchar *base_dir; + gchar *filename; + + collection = shell_view_class->view_collection; + + base_dir = EVOLUTION_ETSPECDIR; + spec = e_table_specification_new (); + filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL); + if (!e_table_specification_load_from_file (spec, filename)) + g_critical ("Unable to load ETable specification file " + "for tasks"); + g_free (filename); + + factory = gal_view_factory_etable_new (spec); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + g_object_unref (spec); + + gal_view_collection_load (collection); +} + +static void +task_shell_view_notify_view_id_cb (ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + GalViewInstance *view_instance; + const gchar *view_id; + + task_shell_content = task_shell_view->priv->task_shell_content; + view_instance = + e_task_shell_content_get_view_instance (task_shell_content); + view_id = e_shell_view_get_view_id (E_SHELL_VIEW (task_shell_view)); + + /* A NULL view ID implies we're in a custom view. But you can + * only get to a custom view via the "Define Views" dialog, which + * would have already modified the view instance appropriately. + * Furthermore, there's no way to refer to a custom view by ID + * anyway, since custom views have no IDs. */ + if (view_id == NULL) + return; + + gal_view_instance_set_current_view_id (view_instance, view_id); +} + +void +e_task_shell_view_private_init (ETaskShellView *task_shell_view, + EShellViewClass *shell_view_class) +{ + ETaskShellViewPrivate *priv = task_shell_view->priv; + ESourceList *source_list; + GObject *object; + + object = G_OBJECT (shell_view_class->type_module); + source_list = g_object_get_data (object, "source-list"); + g_return_if_fail (E_IS_SOURCE_LIST (source_list)); + + priv->source_list = g_object_ref (source_list); + priv->task_actions = gtk_action_group_new ("tasks"); + + if (!gal_view_collection_loaded (shell_view_class->view_collection)) + task_shell_view_load_view_collection (shell_view_class); + + g_signal_connect ( + task_shell_view, "notify::view-id", + G_CALLBACK (task_shell_view_notify_view_id_cb), NULL); +} + +void +e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) +{ + ETaskShellViewPrivate *priv = task_shell_view->priv; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + /* Cache these to avoid lots of awkward casting. */ + priv->task_shell_content = g_object_ref (shell_content); + priv->task_shell_sidebar = g_object_ref (shell_sidebar); +} + +void +e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) +{ + ETaskShellViewPrivate *priv = task_shell_view->priv; + + DISPOSE (priv->source_list); + + DISPOSE (priv->task_actions); + + DISPOSE (priv->task_shell_content); + DISPOSE (priv->task_shell_sidebar); +} + +void +e_task_shell_view_private_finalize (ETaskShellView *task_shell_view) +{ + ETaskShellViewPrivate *priv = task_shell_view->priv; +} + +void +e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, + const gchar *status_message) +{ + g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); + + /* FIXME */ +} diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h new file mode 100644 index 0000000000..697ec7a120 --- /dev/null +++ b/calendar/modules/e-task-shell-view-private.h @@ -0,0 +1,95 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view-private.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_VIEW_PRIVATE_H +#define E_TASK_SHELL_VIEW_PRIVATE_H + +#include "e-task-shell-view.h" + +#include +#include + +#include "e-util/e-util.h" + +#include "e-task-shell-content.h" +#include "e-task-shell-sidebar.h" +#include "e-task-shell-view-actions.h" + +#define E_TASK_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewPrivate)) + +/* Shorthand, requires a variable named "shell_window". */ +#define ACTION(name) \ + (E_SHELL_WINDOW_ACTION_##name (shell_window)) +#define ACTION_GROUP(name) \ + (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) + +/* For use in dispose() methods. */ +#define DISPOSE(obj) \ + G_STMT_START { \ + if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ + } G_STMT_END + +/* ETable Specifications */ +#define ETSPEC_FILENAME "e-calendar-table.etspec" + +G_BEGIN_DECLS + +struct _ETaskShellViewPrivate { + + /*** Module Data ***/ + + ESourceList *source_list; + + /*** UI Management ***/ + + GtkActionGroup *task_actions; + + /*** Other Stuff ***/ + + /* These are just for convenience. */ + ETaskShellContent *task_shell_content; + ETaskShellSidebar *task_shell_sidebar; +}; + +void e_task_shell_view_private_init + (ETaskShellView *task_shell_view, + EShellViewClass *shell_view_class); +void e_task_shell_view_private_constructed + (ETaskShellView *task_shell_view); +void e_task_shell_view_private_dispose + (ETaskShellView *task_shell_view); +void e_task_shell_view_private_finalize + (ETaskShellView *task_shell_view); + +/* Private Utilities */ + +void e_task_shell_view_actions_init + (ETaskShellView *task_shell_view); +void e_task_shell_view_actions_update + (ETaskShellView *task_shell_view); +void e_task_shell_view_set_status_message + (ETaskShellView *task_shell_view, + const gchar *status_message); + +G_END_DECLS + +#endif /* E_TASK_SHELL_VIEW_PRIVATE_H */ diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c new file mode 100644 index 0000000000..6b85d1ed45 --- /dev/null +++ b/calendar/modules/e-task-shell-view.c @@ -0,0 +1,166 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-task-shell-view-private.h" + +enum { + PROP_0, + PROP_SOURCE_LIST +}; + +GType e_task_shell_view_type = 0; +static gpointer parent_class; + +static void +task_shell_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SOURCE_LIST: + g_value_set_object ( + value, e_task_shell_view_get_source_list ( + E_TASK_SHELL_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_shell_view_dispose (GObject *object) +{ + e_task_shell_view_private_dispose (E_TASK_SHELL_VIEW (object)); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +task_shell_view_finalize (GObject *object) +{ + e_task_shell_view_private_finalize (E_TASK_SHELL_VIEW (object)); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +task_shell_view_constructed (GObject *object) +{ + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + e_task_shell_view_private_constructed (E_TASK_SHELL_VIEW (object)); +} + +static void +task_shell_view_changed (EShellView *shell_view) +{ + ETaskShellViewPrivate *priv; + GtkActionGroup *action_group; + gboolean visible; + + priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view); + + action_group = priv->task_actions; + visible = e_shell_view_is_active (shell_view); + gtk_action_group_set_visible (action_group, visible); +} + +static void +task_shell_view_class_init (ETaskShellView *class, + GTypeModule *type_module) +{ + GObjectClass *object_class; + EShellViewClass *shell_view_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ETaskShellViewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = task_shell_view_get_property; + object_class->dispose = task_shell_view_dispose; + object_class->finalize = task_shell_view_finalize; + object_class->constructed = task_shell_view_constructed; + + shell_view_class = E_SHELL_VIEW_CLASS (class); + shell_view_class->label = N_("Tasks"); + shell_view_class->icon_name = "evolution-tasks"; + shell_view_class->search_options = "/task-search-options"; + shell_view_class->type_module = type_module; + shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new; + shell_view_class->changed = task_shell_view_changed; + + g_object_class_install_property ( + object_class, + PROP_SOURCE_LIST, + g_param_spec_object ( + "source-list", + _("Source List"), + _("The registry of task lists"), + E_TYPE_SOURCE_LIST, + G_PARAM_READABLE)); +} + +static void +task_shell_view_init (ETaskShellView *task_shell_view, + EShellViewClass *shell_view_class) +{ + task_shell_view->priv = + E_TASK_SHELL_VIEW_GET_PRIVATE (task_shell_view); + + e_task_shell_view_private_init (task_shell_view, shell_view_class); +} + +GType +e_task_shell_view_get_type (GTypeModule *type_module) +{ + if (e_task_shell_view_type == 0) { + const GTypeInfo type_info = { + sizeof (ETaskShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) task_shell_view_class_init, + (GClassFinalizeFunc) NULL, + type_module, + sizeof (ETaskShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) task_shell_view_init, + NULL /* value_table */ + }; + + e_task_shell_view_type = + g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "ETaskShellView", &type_info, 0); + } + + return e_task_shell_view_type; +} + +ESourceList * +e_task_shell_view_get_source_list (ETaskShellView *task_shell_view) +{ + g_return_val_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view), NULL); + + return task_shell_view->priv->source_list; +} diff --git a/calendar/modules/e-task-shell-view.h b/calendar/modules/e-task-shell-view.h new file mode 100644 index 0000000000..cd58d1b6f8 --- /dev/null +++ b/calendar/modules/e-task-shell-view.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-task-shell-view.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_TASK_SHELL_VIEW_H +#define E_TASK_SHELL_VIEW_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_TASK_SHELL_VIEW \ + (e_task_shell_view_type) +#define E_TASK_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellView)) +#define E_TASK_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewClass)) +#define E_IS_TASK_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_TASK_SHELL_VIEW)) +#define E_IS_TASK_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_TASK_SHELL_VIEW)) +#define E_TASK_SHELL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_TASK_SHELL_VIEW, ETaskShellViewClass)) + +G_BEGIN_DECLS + +extern GType e_task_shell_view_type; + +typedef struct _ETaskShellView ETaskShellView; +typedef struct _ETaskShellViewClass ETaskShellViewClass; +typedef struct _ETaskShellViewPrivate ETaskShellViewPrivate; + +struct _ETaskShellView { + EShellView parent; + ETaskShellViewPrivate *priv; +}; + +struct _ETaskShellViewClass { + EShellViewClass parent_class; +}; + +GType e_task_shell_view_get_type + (GTypeModule *type_module); +ESourceList * e_task_shell_view_get_source_list + (ETaskShellView *task_shell_view); + +G_END_DECLS + +#endif /* E_TASK_SHELL_VIEW_H */ diff --git a/configure.in b/configure.in index b95da74c32..0a02d9321f 100644 --- a/configure.in +++ b/configure.in @@ -1985,6 +1985,7 @@ calendar/conduits/memo/Makefile calendar/gui/Makefile calendar/gui/alarm-notify/Makefile calendar/gui/dialogs/Makefile +calendar/modules/Makefile composer/Makefile mail/Makefile mail/default/Makefile diff --git a/doc/reference/shell/tmpl/e-shell-window.sgml b/doc/reference/shell/tmpl/e-shell-window.sgml index a410267107..988e2f039c 100644 --- a/doc/reference/shell/tmpl/e-shell-window.sgml +++ b/doc/reference/shell/tmpl/e-shell-window.sgml @@ -48,16 +48,6 @@ EShellWindow @Returns: - - - - - -@shell_window: -@view_name: -@Returns: - - diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml index b18730bd1e..edf7adfdea 100644 --- a/doc/reference/shell/tmpl/eshell-unused.sgml +++ b/doc/reference/shell/tmpl/eshell-unused.sgml @@ -1914,6 +1914,15 @@ intelligent @shell_window: @Returns: + + + + + +@shell_window: +@view_name: +@Returns: + diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index c16344ac15..e1871da412 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -96,7 +96,6 @@ action_search_execute_cb (GtkAction *action, EShellView *shell_view; EShellWindow *shell_window; EIconEntry *icon_entry; - GtkWidget *child; GtkStateType visual_state; const gchar *search_text; diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h index 1763bf4b22..defeb0a403 100644 --- a/shell/e-shell-content.h +++ b/shell/e-shell-content.h @@ -21,7 +21,7 @@ #ifndef E_SHELL_CONTENT_H #define E_SHELL_CONTENT_H -#include +#include #include #include diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index 40f2bbb4c9..b28b2f048a 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -21,7 +21,7 @@ #ifndef E_SHELL_MODULE_H #define E_SHELL_MODULE_H -#include +#include #include /* Standard GObject macros */ diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 9d33024702..0ce80d9e54 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -202,6 +202,13 @@ shell_sidebar_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +shell_sidebar_constructed (GObject *object) +{ + /* XXX This is here to let subclasses safely chain up. + * GObject does not define a constructed() method. */ +} + static void shell_sidebar_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -309,6 +316,7 @@ shell_sidebar_class_init (EShellSidebarClass *class) object_class->get_property = shell_sidebar_get_property; object_class->dispose = shell_sidebar_dispose; object_class->finalize = shell_sidebar_finalize; + object_class->constructed = shell_sidebar_constructed; widget_class = GTK_WIDGET_CLASS (class); widget_class->size_request = shell_sidebar_size_request; diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h index 9a27cba6b5..7bc26e965b 100644 --- a/shell/e-shell-sidebar.h +++ b/shell/e-shell-sidebar.h @@ -21,7 +21,7 @@ #ifndef E_SHELL_SIDEBAR_H #define E_SHELL_SIDEBAR_H -#include +#include /* Standard GObject macros */ #define E_TYPE_SHELL_SIDEBAR \ diff --git a/shell/e-shell-taskbar.h b/shell/e-shell-taskbar.h index 9aaac20018..466750dd77 100644 --- a/shell/e-shell-taskbar.h +++ b/shell/e-shell-taskbar.h @@ -21,7 +21,7 @@ #ifndef E_SHELL_TASKBAR_H #define E_SHELL_TASKBAR_H -#include +#include /* Standard GObject macros */ #define E_TYPE_SHELL_TASKBAR \ diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 2d1919b2a7..f2d7b0ec0c 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -579,28 +579,28 @@ e_shell_view_get_page_num (EShellView *shell_view) return shell_view->priv->page_num; } -gpointer +EShellContent * e_shell_view_get_shell_content (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return shell_view->priv->shell_content; + return E_SHELL_CONTENT (shell_view->priv->shell_content); } -gpointer +EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return shell_view->priv->shell_sidebar; + return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar); } -gpointer +EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return shell_view->priv->shell_taskbar; + return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar); } void diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 92382a9a49..5f12840c12 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -22,8 +22,11 @@ #ifndef E_SHELL_VIEW_H #define E_SHELL_VIEW_H -#include -#include +#include +#include +#include +#include +#include #include #include @@ -61,10 +64,13 @@ struct _EShellView { struct _EShellViewClass { GObjectClass parent_class; - /* Initial GtkRadioAction values */ + /* Initial switcher action values. */ const gchar *label; const gchar *icon_name; + /* Path to the search entry popup menu. */ + const gchar *search_options; + /* Subclasses should set this via the "class_data" field in * the GTypeInfo they pass to g_type_module_register_type(). */ GTypeModule *type_module; @@ -72,9 +78,6 @@ struct _EShellViewClass { /* A unique instance is created for each subclass. */ GalViewCollection *view_collection; - /* Path to the search entry popup menu. */ - const gchar *search_options_path; - /* Factory Methods */ GtkWidget * (*new_shell_content) (EShellView *shell_view); GtkWidget * (*new_shell_sidebar) (EShellView *shell_view); @@ -97,9 +100,9 @@ gboolean e_shell_view_is_active (EShellView *shell_view); void e_shell_view_add_activity (EShellView *shell_view, EActivity *activity); gint e_shell_view_get_page_num (EShellView *shell_view); -gpointer e_shell_view_get_shell_content (EShellView *shell_view); -gpointer e_shell_view_get_shell_sidebar (EShellView *shell_view); -gpointer e_shell_view_get_shell_taskbar (EShellView *shell_view); +EShellContent * e_shell_view_get_shell_content (EShellView *shell_view); +EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view); +EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view); EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view); void e_shell_view_changed (EShellView *shell_view); diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 5375774702..c03e60eecf 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -686,7 +686,7 @@ action_custom_rule_cb (GtkAction *action, g_return_if_fail (rule != NULL); view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); rule = g_object_get_data (G_OBJECT (action), "rule"); @@ -735,7 +735,7 @@ action_gal_define_views_cb (GtkAction *action, const gchar *view_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); view_collection = shell_view_class->view_collection; g_return_if_fail (view_collection != NULL); @@ -758,7 +758,7 @@ action_gal_view_cb (GtkRadioAction *action, const gchar *view_id; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); view_id = g_object_get_data (G_OBJECT (current), "view-id"); e_shell_view_set_view_id (shell_view, view_id); } @@ -869,7 +869,7 @@ action_search_advanced_cb (GtkAction *action, const gchar *view_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_run_advanced_search_dialog (shell_content); @@ -885,7 +885,7 @@ action_search_clear_cb (GtkAction *action, const gchar *view_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_set_search_rule (shell_content, NULL); @@ -905,7 +905,7 @@ action_search_edit_cb (GtkAction *action, const gchar *view_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_run_edit_searches_dialog (shell_content); @@ -922,10 +922,10 @@ action_search_options_cb (GtkAction *action, const gchar *widget_path; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); - widget_path = shell_view_class->search_options_path; + widget_path = shell_view_class->search_options; e_shell_window_show_popup_menu (shell_window, widget_path, NULL); } @@ -938,7 +938,7 @@ action_search_save_cb (GtkAction *action, const gchar *view_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); e_shell_content_run_save_search_dialog (shell_content); @@ -1777,7 +1777,7 @@ e_shell_window_update_view_menu (EShellWindow *shell_window) ui_manager = e_shell_window_get_ui_manager (shell_window); view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); view_collection = shell_view_class->view_collection; view_id = e_shell_view_get_view_id (shell_view); @@ -1880,7 +1880,7 @@ e_shell_window_update_search_menu (EShellWindow *shell_window) ui_manager = e_shell_window_get_ui_manager (shell_window); view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); shell_content = e_shell_view_get_shell_content (shell_view); context = e_shell_content_get_search_context (shell_content); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); @@ -1892,7 +1892,7 @@ e_shell_window_update_search_menu (EShellWindow *shell_window) gtk_action_set_sensitive (ACTION (SEARCH_CLEAR), sensitive); gtk_action_set_sensitive (ACTION (SEARCH_SAVE), sensitive); - sensitive = (shell_view_class->search_options_path != NULL); + sensitive = (shell_view_class->search_options != NULL); gtk_action_set_sensitive (ACTION (SEARCH_OPTIONS), sensitive); /* Add custom rules to the Search menu. */ diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 782616cea4..79cdeb94a8 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -410,7 +410,7 @@ e_shell_window_switch_to_view (EShellWindow *shell_window, GList *list; gint page_num; - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); page_num = e_shell_view_get_page_num (shell_view); g_return_if_fail (page_num >= 0); @@ -448,7 +448,7 @@ e_shell_window_update_icon (EShellWindow *shell_window) gchar *icon_name; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); action = e_shell_view_get_action (shell_view); g_object_get (action, "icon-name", &icon_name, NULL); @@ -465,7 +465,7 @@ e_shell_window_update_title (EShellWindow *shell_window) gchar *window_title; view_name = e_shell_window_get_active_view (shell_window); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); view_title = e_shell_view_get_title (shell_view); /* Translators: This is used for the main window title. */ diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 422101d549..a316fd7680 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -347,7 +347,23 @@ e_shell_window_new (EShell *shell, } /** - * e_shell_window_get_view: + * e_shell_window_get_shell: + * @shell_window: an #EShellWindow + * + * Returns the #EShell that was passed to e_shell_window_new(). + * + * Returns: the #EShell + **/ +EShell * +e_shell_window_get_shell (EShellWindow *shell_window) +{ + g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); + + return shell_window->priv->shell; +} + +/** + * e_shell_window_get_shell_view: * @shell_window: an #EShellWindow * @view_name: name of a shell view * @@ -363,8 +379,8 @@ e_shell_window_new (EShell *shell, * registered **/ gpointer -e_shell_window_get_view (EShellWindow *shell_window, - const gchar *view_name) +e_shell_window_get_shell_view (EShellWindow *shell_window, + const gchar *view_name) { GHashTable *loaded_views; EShellView *shell_view; @@ -409,22 +425,6 @@ e_shell_window_get_view (EShellWindow *shell_window, return shell_view; } -/** - * e_shell_window_get_shell: - * @shell_window: an #EShellWindow - * - * Returns the #EShell that was passed to e_shell_window_new(). - * - * Returns: the #EShell - **/ -EShell * -e_shell_window_get_shell (EShellWindow *shell_window) -{ - g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); - - return shell_window->priv->shell; -} - /** * e_shell_window_get_ui_manager: * @shell_window: an #EShellWindow @@ -590,7 +590,7 @@ e_shell_window_set_active_view (EShellWindow *shell_window, g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); g_return_if_fail (view_name != NULL); - shell_view = e_shell_window_get_view (shell_window, view_name); + shell_view = e_shell_window_get_shell_view (shell_window, view_name); g_return_if_fail (shell_view != NULL); action = e_shell_view_get_action (shell_view); diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index bbc137dd07..caf403319b 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -24,7 +24,7 @@ #ifndef E_SHELL_WINDOW_H #define E_SHELL_WINDOW_H -#include +#include /* Standard GObject macros */ #define E_TYPE_SHELL_WINDOW \ @@ -63,9 +63,9 @@ struct _EShellWindowClass { GType e_shell_window_get_type (void); GtkWidget * e_shell_window_new (EShell *shell, gboolean safe_mode); -gpointer e_shell_window_get_view (EShellWindow *shell_window, - const gchar *view_name); EShell * e_shell_window_get_shell (EShellWindow *shell_window); +gpointer e_shell_window_get_shell_view (EShellWindow *shell_window, + const gchar *view_name); GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window); GtkAction * e_shell_window_get_action (EShellWindow *shell_window, const gchar *action_name); diff --git a/shell/e-shell.h b/shell/e-shell.h index 1500c2bcb4..5b804b3f4a 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -23,8 +23,8 @@ #ifndef E_SHELL_H #define E_SHELL_H -#include -#include +#include +#include /* Standard GObject macros */ #define E_TYPE_SHELL \ diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui index 4643eefd7c..a32cf182bc 100644 --- a/ui/evolution-calendars.ui +++ b/ui/evolution-calendars.ui @@ -54,4 +54,11 @@ + + + + + + + diff --git a/ui/evolution-memos.ui b/ui/evolution-memos.ui index 24b9ebf3cf..8bee554ae0 100644 --- a/ui/evolution-memos.ui +++ b/ui/evolution-memos.ui @@ -38,4 +38,11 @@ + + + + + + + diff --git a/ui/evolution-tasks.ui b/ui/evolution-tasks.ui index 83dc37c45d..9646a13655 100644 --- a/ui/evolution-tasks.ui +++ b/ui/evolution-tasks.ui @@ -47,4 +47,11 @@ + + + + + + + -- cgit v1.2.3