aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-12-10 21:09:59 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-12-13 03:33:43 +0800
commitd09d8de870b6697c8a8b262e7e077b871a69b315 (patch)
tree3b718882e7a0bb0a996daf2967a033d91714c9b5 /widgets/misc
parentb61331ed03ac1c7a9b8614e25510040b9c60ae02 (diff)
downloadgsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.gz
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.bz2
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.lz
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.xz
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.zst
gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.zip
Consolidate base utility libraries into libeutil.
Evolution consists of entirely too many small utility libraries, which increases linking and loading time, places a burden on higher layers of the application (e.g. modules) which has to remember to link to all the small in-tree utility libraries, and makes it difficult to generate API documentation for these utility libraries in one Gtk-Doc module. Merge the following utility libraries under the umbrella of libeutil, and enforce a single-include policy on libeutil so we can reorganize the files as desired without disrupting its pseudo-public API. libemail-utils/libemail-utils.la libevolution-utils/libevolution-utils.la filter/libfilter.la widgets/e-timezone-dialog/libetimezonedialog.la widgets/menus/libmenus.la widgets/misc/libemiscwidgets.la widgets/table/libetable.la widgets/text/libetext.la This also merges libedataserverui from the Evolution-Data-Server module, since Evolution is its only consumer nowadays, and I'd like to make some improvements to those APIs without concern for backward-compatibility. And finally, start a Gtk-Doc module for libeutil. It's going to be a project just getting all the symbols _listed_ much less _documented_. But the skeletal structure is in place and I'm off to a good start.
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/Makefile.am289
-rw-r--r--widgets/misc/e-action-combo-box.c578
-rw-r--r--widgets/misc/e-action-combo-box.h85
-rw-r--r--widgets/misc/e-activity-bar.c366
-rw-r--r--widgets/misc/e-activity-bar.h67
-rw-r--r--widgets/misc/e-activity-proxy.c381
-rw-r--r--widgets/misc/e-activity-proxy.h70
-rw-r--r--widgets/misc/e-alarm-selector.c94
-rw-r--r--widgets/misc/e-alarm-selector.h63
-rw-r--r--widgets/misc/e-alert-bar.c390
-rw-r--r--widgets/misc/e-alert-bar.h67
-rw-r--r--widgets/misc/e-attachment-bar.c778
-rw-r--r--widgets/misc/e-attachment-bar.h79
-rw-r--r--widgets/misc/e-attachment-button.c868
-rw-r--r--widgets/misc/e-attachment-button.h87
-rw-r--r--widgets/misc/e-attachment-dialog.c425
-rw-r--r--widgets/misc/e-attachment-dialog.h73
-rw-r--r--widgets/misc/e-attachment-handler-image.c248
-rw-r--r--widgets/misc/e-attachment-handler-image.h65
-rw-r--r--widgets/misc/e-attachment-handler-sendto.c229
-rw-r--r--widgets/misc/e-attachment-handler-sendto.h62
-rw-r--r--widgets/misc/e-attachment-handler.c133
-rw-r--r--widgets/misc/e-attachment-handler.h80
-rw-r--r--widgets/misc/e-attachment-icon-view.c570
-rw-r--r--widgets/misc/e-attachment-icon-view.h67
-rw-r--r--widgets/misc/e-attachment-paned.c904
-rw-r--r--widgets/misc/e-attachment-paned.h95
-rw-r--r--widgets/misc/e-attachment-store.c1281
-rw-r--r--widgets/misc/e-attachment-store.h133
-rw-r--r--widgets/misc/e-attachment-tree-view.c623
-rw-r--r--widgets/misc/e-attachment-tree-view.h66
-rw-r--r--widgets/misc/e-attachment-view.c1907
-rw-r--r--widgets/misc/e-attachment-view.h240
-rw-r--r--widgets/misc/e-attachment.c2883
-rw-r--r--widgets/misc/e-attachment.h155
-rw-r--r--widgets/misc/e-auth-combo-box.c266
-rw-r--r--widgets/misc/e-auth-combo-box.h71
-rw-r--r--widgets/misc/e-autocomplete-selector.c96
-rw-r--r--widgets/misc/e-autocomplete-selector.h64
-rw-r--r--widgets/misc/e-book-source-config.c287
-rw-r--r--widgets/misc/e-book-source-config.h67
-rw-r--r--widgets/misc/e-buffer-tagger.c691
-rw-r--r--widgets/misc/e-buffer-tagger.h35
-rw-r--r--widgets/misc/e-cal-source-config.c431
-rw-r--r--widgets/misc/e-cal-source-config.h72
-rw-r--r--widgets/misc/e-calendar-item.c3772
-rw-r--r--widgets/misc/e-calendar-item.h390
-rw-r--r--widgets/misc/e-calendar.c848
-rw-r--r--widgets/misc/e-calendar.h108
-rw-r--r--widgets/misc/e-canvas-background.c279
-rw-r--r--widgets/misc/e-canvas-background.h70
-rw-r--r--widgets/misc/e-canvas-utils.c222
-rw-r--r--widgets/misc/e-canvas-utils.h55
-rw-r--r--widgets/misc/e-canvas-vbox.c411
-rw-r--r--widgets/misc/e-canvas-vbox.h85
-rw-r--r--widgets/misc/e-canvas.c882
-rw-r--r--widgets/misc/e-canvas.h137
-rw-r--r--widgets/misc/e-charset-combo-box.c407
-rw-r--r--widgets/misc/e-charset-combo-box.h69
-rw-r--r--widgets/misc/e-contact-map-window.c500
-rw-r--r--widgets/misc/e-contact-map-window.h77
-rw-r--r--widgets/misc/e-contact-map.c407
-rw-r--r--widgets/misc/e-contact-map.h106
-rw-r--r--widgets/misc/e-contact-marker.c624
-rw-r--r--widgets/misc/e-contact-marker.h84
-rw-r--r--widgets/misc/e-dateedit.c2498
-rw-r--r--widgets/misc/e-dateedit.h215
-rw-r--r--widgets/misc/e-focus-tracker.c886
-rw-r--r--widgets/misc/e-focus-tracker.h100
-rw-r--r--widgets/misc/e-image-chooser.c562
-rw-r--r--widgets/misc/e-image-chooser.h76
-rw-r--r--widgets/misc/e-import-assistant.c1436
-rw-r--r--widgets/misc/e-import-assistant.h68
-rw-r--r--widgets/misc/e-interval-chooser.c214
-rw-r--r--widgets/misc/e-interval-chooser.h68
-rw-r--r--widgets/misc/e-mail-identity-combo-box.c385
-rw-r--r--widgets/misc/e-mail-identity-combo-box.h71
-rw-r--r--widgets/misc/e-mail-signature-combo-box.c668
-rw-r--r--widgets/misc/e-mail-signature-combo-box.h91
-rw-r--r--widgets/misc/e-mail-signature-editor.c914
-rw-r--r--widgets/misc/e-mail-signature-editor.h82
-rw-r--r--widgets/misc/e-mail-signature-manager.c708
-rw-r--r--widgets/misc/e-mail-signature-manager.h88
-rw-r--r--widgets/misc/e-mail-signature-preview.c358
-rw-r--r--widgets/misc/e-mail-signature-preview.h79
-rw-r--r--widgets/misc/e-mail-signature-script-dialog.c731
-rw-r--r--widgets/misc/e-mail-signature-script-dialog.h90
-rw-r--r--widgets/misc/e-mail-signature-tree-view.c395
-rw-r--r--widgets/misc/e-mail-signature-tree-view.h76
-rw-r--r--widgets/misc/e-map.c1430
-rw-r--r--widgets/misc/e-map.h151
-rw-r--r--widgets/misc/e-menu-tool-action.c59
-rw-r--r--widgets/misc/e-menu-tool-action.h71
-rw-r--r--widgets/misc/e-menu-tool-button.c273
-rw-r--r--widgets/misc/e-menu-tool-button.h73
-rw-r--r--widgets/misc/e-online-button.c210
-rw-r--r--widgets/misc/e-online-button.h65
-rw-r--r--widgets/misc/e-paned.c503
-rw-r--r--widgets/misc/e-paned.h78
-rw-r--r--widgets/misc/e-picture-gallery.c437
-rw-r--r--widgets/misc/e-picture-gallery.h67
-rw-r--r--widgets/misc/e-popup-action.c408
-rw-r--r--widgets/misc/e-popup-action.h92
-rw-r--r--widgets/misc/e-port-entry.c549
-rw-r--r--widgets/misc/e-port-entry.h87
-rw-r--r--widgets/misc/e-preferences-window.c642
-rw-r--r--widgets/misc/e-preferences-window.h84
-rw-r--r--widgets/misc/e-preview-pane.c323
-rw-r--r--widgets/misc/e-preview-pane.h75
-rw-r--r--widgets/misc/e-printable.c226
-rw-r--r--widgets/misc/e-printable.h89
-rw-r--r--widgets/misc/e-search-bar.c771
-rw-r--r--widgets/misc/e-search-bar.h84
-rw-r--r--widgets/misc/e-selectable.c168
-rw-r--r--widgets/misc/e-selectable.h80
-rw-r--r--widgets/misc/e-selection-model-array.c647
-rw-r--r--widgets/misc/e-selection-model-array.h91
-rw-r--r--widgets/misc/e-selection-model-simple.c119
-rw-r--r--widgets/misc/e-selection-model-simple.h66
-rw-r--r--widgets/misc/e-selection-model.c813
-rw-r--r--widgets/misc/e-selection-model.h205
-rw-r--r--widgets/misc/e-send-options.c767
-rw-r--r--widgets/misc/e-send-options.h127
-rw-r--r--widgets/misc/e-send-options.ui949
-rw-r--r--widgets/misc/e-source-config-backend.c140
-rw-r--r--widgets/misc/e-source-config-backend.h94
-rw-r--r--widgets/misc/e-source-config-dialog.c394
-rw-r--r--widgets/misc/e-source-config-dialog.h65
-rw-r--r--widgets/misc/e-source-config.c1448
-rw-r--r--widgets/misc/e-source-config.h116
-rw-r--r--widgets/misc/e-spell-entry.c866
-rw-r--r--widgets/misc/e-spell-entry.h59
-rw-r--r--widgets/misc/e-url-entry.c157
-rw-r--r--widgets/misc/e-url-entry.h56
-rw-r--r--widgets/misc/e-web-view-gtkhtml.c2318
-rw-r--r--widgets/misc/e-web-view-gtkhtml.h173
-rw-r--r--widgets/misc/e-web-view-preview.c474
-rw-r--r--widgets/misc/e-web-view-preview.h111
-rw-r--r--widgets/misc/e-web-view.c2946
-rw-r--r--widgets/misc/e-web-view.h220
-rw-r--r--widgets/misc/ea-calendar-cell.c405
-rw-r--r--widgets/misc/ea-calendar-cell.h86
-rw-r--r--widgets/misc/ea-calendar-item.c1372
-rw-r--r--widgets/misc/ea-calendar-item.h67
-rw-r--r--widgets/misc/ea-cell-table.c215
-rw-r--r--widgets/misc/ea-cell-table.h59
-rw-r--r--widgets/misc/ea-widgets.c36
-rw-r--r--widgets/misc/ea-widgets.h32
-rw-r--r--widgets/misc/test-calendar.c146
-rw-r--r--widgets/misc/test-dateedit.c299
-rw-r--r--widgets/misc/test-mail-signatures.c199
-rw-r--r--widgets/misc/test-preferences-window.c108
-rw-r--r--widgets/misc/test-source-config.c57
-rw-r--r--widgets/misc/widgets.error.xml28
154 files changed, 0 insertions, 60598 deletions
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
deleted file mode 100644
index 4f4a5a17b1..0000000000
--- a/widgets/misc/Makefile.am
+++ /dev/null
@@ -1,289 +0,0 @@
-privsolib_LTLIBRARIES = libemiscwidgets.la
-
-widgetsincludedir = $(privincludedir)/misc
-
-ui_DATA = e-send-options.ui
-
-widgetsinclude_HEADERS = \
- e-action-combo-box.h \
- e-activity-bar.h \
- e-activity-proxy.h \
- e-alarm-selector.h \
- e-alert-bar.h \
- e-attachment.h \
- e-attachment-bar.h \
- e-attachment-button.h \
- e-attachment-dialog.h \
- e-attachment-handler.h \
- e-attachment-handler-image.h \
- e-attachment-handler-sendto.h \
- e-attachment-icon-view.h \
- e-attachment-paned.h \
- e-attachment-store.h \
- e-attachment-tree-view.h \
- e-attachment-view.h \
- e-auth-combo-box.h \
- e-autocomplete-selector.h \
- e-book-source-config.h \
- e-buffer-tagger.h \
- e-cal-source-config.h \
- e-calendar.h \
- e-calendar-item.h \
- e-canvas.h \
- e-canvas-background.h \
- e-canvas-utils.h \
- e-canvas-vbox.h \
- e-charset-combo-box.h \
- e-contact-map.h \
- e-contact-map-window.h \
- e-contact-marker.h \
- e-dateedit.h \
- e-focus-tracker.h \
- e-image-chooser.h \
- e-import-assistant.h \
- e-interval-chooser.h \
- e-mail-identity-combo-box.h \
- e-mail-signature-combo-box.h \
- e-mail-signature-editor.h \
- e-mail-signature-manager.h \
- e-mail-signature-preview.h \
- e-mail-signature-script-dialog.h \
- e-mail-signature-tree-view.h \
- e-map.h \
- e-menu-tool-action.h \
- e-menu-tool-button.h \
- e-online-button.h \
- e-paned.h \
- e-picture-gallery.h \
- e-popup-action.h \
- e-port-entry.h \
- e-preferences-window.h \
- e-preview-pane.h \
- e-printable.h \
- e-search-bar.h \
- e-selectable.h \
- e-selection-model.h \
- e-selection-model-array.h \
- e-selection-model-simple.h \
- e-send-options.h \
- e-source-config.h \
- e-source-config-backend.h \
- e-source-config-dialog.h \
- e-spell-entry.h \
- e-url-entry.h \
- e-web-view.h \
- e-web-view-gtkhtml.h \
- e-web-view-preview.h \
- ea-calendar-cell.h \
- ea-calendar-item.h \
- ea-cell-table.h \
- ea-widgets.h
-
-libemiscwidgets_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/filter \
- -I$(top_srcdir)/widgets \
- -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
- -DEVOLUTION_UIDIR=\""$(uidir)"\" \
- -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
- -DG_LOG_DOMAIN=__FILE__ \
- $(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS) \
- $(CHAMPLAIN_CFLAGS) \
- $(GEO_CFLAGS) \
- $(CLUTTER_CFLAGS)
-
-libemiscwidgets_la_SOURCES = \
- $(widgetsinclude_HEADERS) \
- e-action-combo-box.c \
- e-activity-bar.c \
- e-activity-proxy.c \
- e-alarm-selector.c \
- e-alert-bar.c \
- e-attachment.c \
- e-attachment-bar.c \
- e-attachment-button.c \
- e-attachment-dialog.c \
- e-attachment-handler.c \
- e-attachment-handler-image.c \
- e-attachment-handler-sendto.c \
- e-attachment-icon-view.c \
- e-attachment-paned.c \
- e-attachment-store.c \
- e-attachment-tree-view.c \
- e-attachment-view.c \
- e-auth-combo-box.c \
- e-autocomplete-selector.c \
- e-book-source-config.c \
- e-buffer-tagger.c \
- e-cal-source-config.c \
- e-calendar.c \
- e-calendar-item.c \
- e-canvas.c \
- e-canvas-background.c \
- e-canvas-utils.c \
- e-canvas-vbox.c \
- e-charset-combo-box.c \
- e-contact-map.c \
- e-contact-map-window.c \
- e-contact-marker.c \
- e-dateedit.c \
- e-focus-tracker.c \
- e-image-chooser.c \
- e-import-assistant.c \
- e-interval-chooser.c \
- e-mail-identity-combo-box.c \
- e-mail-signature-combo-box.c \
- e-mail-signature-editor.c \
- e-mail-signature-manager.c \
- e-mail-signature-preview.c \
- e-mail-signature-script-dialog.c \
- e-mail-signature-tree-view.c \
- e-map.c \
- e-menu-tool-action.c \
- e-menu-tool-button.c \
- e-online-button.c \
- e-paned.c \
- e-picture-gallery.c \
- e-popup-action.c \
- e-port-entry.c \
- e-preferences-window.c \
- e-preview-pane.c \
- e-printable.c \
- e-search-bar.c \
- e-selectable.c \
- e-selection-model.c \
- e-selection-model-array.c \
- e-selection-model-simple.c \
- e-send-options.c \
- e-source-config.c \
- e-source-config-backend.c \
- e-source-config-dialog.c \
- e-spell-entry.c \
- e-url-entry.c \
- e-web-view.c \
- e-web-view-gtkhtml.c \
- e-web-view-preview.c \
- ea-calendar-cell.c \
- ea-calendar-item.c \
- ea-cell-table.c \
- ea-widgets.c
-
-libemiscwidgets_la_LDFLAGS = -avoid-version $(NO_UNDEFINED)
-
-libemiscwidgets_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(top_builddir)/a11y/libevolution-a11y.la \
- $(top_builddir)/libgnomecanvas/libgnomecanvas.la \
- $(top_builddir)/libemail-utils/libemail-utils.la \
- $(top_builddir)/libevolution-utils/libevolution-utils.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(MATH_LIB) \
- $(ICONV_LIBS) \
- $(CHAMPLAIN_LIBS) \
- $(GEO_LIBS) \
- $(CLUTTER_LIBS) \
- $(GTKHTML_LIBS)
-
-error_DATA = widgets.error
-errordir = $(privdatadir)/errors
-# provides error rules too
-@EVO_PLUGIN_RULE@
-
-noinst_PROGRAMS = \
- test-calendar \
- test-dateedit \
- test-mail-signatures \
- test-preferences-window \
- test-source-config
-
-test_widgets_misc_CPPFLAGS= \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/filter \
- -I$(top_srcdir)/widgets \
- -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
- -DG_LOG_DOMAIN=__FILE__ \
- $(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS)
-
-# test-calendar
-
-test_calendar_CPPFLAGS = $(test_widgets_misc_CPPFLAGS)
-
-test_calendar_SOURCES = test-calendar.c
-
-test_calendar_LDADD = \
- libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS)
-
-# test-dateedit
-
-test_dateedit_CPPFLAGS = $(test_widgets_misc_CPPFLAGS)
-
-test_dateedit_SOURCES = test-dateedit.c
-
-test_dateedit_LDADD = \
- libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS)
-
-# test-mail-signatures
-
-test_mail_signatures_CPPFLAGS = \
- $(test_widgets_misc_CPPFLAGS) \
- $(GTKHTML_CFLAGS)
-
-test_mail_signatures_SOURCES = test-mail-signatures.c
-
-test_mail_signatures_LDADD = \
- libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(top_builddir)/libevolution-utils/libevolution-utils.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
-
-# test-preferences-window
-
-test_preferences_window_CPPFLAGS = $(test_widgets_misc_CPPFLAGS)
-
-test_preferences_window_SOURCES = test-preferences-window.c
-
-test_preferences_window_LDADD = \
- libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS)
-
-# test-source-config
-
-test_source_config_CPPFLAGS = $(test_widgets_misc_CPPFLAGS)
-
-test_source_config_SOURCES = test-source-config.c
-
-test_source_config_LDADD = \
- libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS)
-
-BUILT_SOURCES = $(error_DATA)
-
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = $(ui_DATA) widgets.error.xml
-
--include $(top_srcdir)/git.mk
diff --git a/widgets/misc/e-action-combo-box.c b/widgets/misc/e-action-combo-box.c
deleted file mode 100644
index 0747a6ed27..0000000000
--- a/widgets/misc/e-action-combo-box.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-action-combo-box.c
- *
- * Copyright (C) 2008 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser 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 Lesser General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-action-combo-box.h"
-
-#include <glib/gi18n.h>
-
-#define E_ACTION_COMBO_BOX_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ACTION_COMBO_BOX, EActionComboBoxPrivate))
-
-enum {
- COLUMN_ACTION,
- COLUMN_SORT
-};
-
-enum {
- PROP_0,
- PROP_ACTION
-};
-
-struct _EActionComboBoxPrivate {
- GtkRadioAction *action;
- GtkActionGroup *action_group;
- GHashTable *index;
- guint changed_handler_id; /* action::changed */
- guint group_sensitive_handler_id; /* action-group::sensitive */
- guint group_visible_handler_id; /* action-group::visible */
- gboolean group_has_icons : 1;
-};
-
-G_DEFINE_TYPE (
- EActionComboBox,
- e_action_combo_box,
- GTK_TYPE_COMBO_BOX)
-
-static void
-action_combo_box_action_changed_cb (GtkRadioAction *action,
- GtkRadioAction *current,
- EActionComboBox *combo_box)
-{
- GtkTreeRowReference *reference;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gboolean valid;
-
- reference = g_hash_table_lookup (
- combo_box->priv->index, GINT_TO_POINTER (
- gtk_radio_action_get_current_value (current)));
- g_return_if_fail (reference != NULL);
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
- valid = gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- g_return_if_fail (valid);
-
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
-}
-
-static void
-action_combo_box_action_group_notify_cb (GtkActionGroup *action_group,
- GParamSpec *pspec,
- EActionComboBox *combo_box)
-{
- g_object_set (
- combo_box, "sensitive",
- gtk_action_group_get_sensitive (action_group), "visible",
- gtk_action_group_get_visible (action_group), NULL);
-}
-
-static void
-action_combo_box_render_pixbuf (GtkCellLayout *layout,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EActionComboBox *combo_box)
-{
- GtkRadioAction *action;
- gchar *icon_name;
- gchar *stock_id;
- gboolean sensitive;
- gboolean visible;
- gint width;
-
- gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
-
- /* Do any of the actions have an icon? */
- if (!combo_box->priv->group_has_icons)
- return;
-
- /* A NULL action means the row is a separator. */
- if (action == NULL)
- return;
-
- g_object_get (
- G_OBJECT (action),
- "icon-name", &icon_name,
- "sensitive", &sensitive,
- "stock-id", &stock_id,
- "visible", &visible,
- NULL);
-
- /* Keep the pixbuf renderer a fixed size for proper alignment. */
- gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
-
- /* We can't set both "icon-name" and "stock-id" because setting
- * one unsets the other. So pick the one that has a non-NULL
- * value. If both are non-NULL, "stock-id" wins. */
-
- if (stock_id != NULL)
- g_object_set (
- G_OBJECT (renderer),
- "sensitive", sensitive,
- "icon-name", NULL,
- "stock-id", stock_id,
- "stock-size", GTK_ICON_SIZE_MENU,
- "visible", visible,
- "width", width,
- NULL);
- else
- g_object_set (
- G_OBJECT (renderer),
- "sensitive", sensitive,
- "icon-name", icon_name,
- "stock-id", NULL,
- "stock-size", GTK_ICON_SIZE_MENU,
- "visible", visible,
- "width", width,
- NULL);
-
- g_free (icon_name);
- g_free (stock_id);
-}
-
-static void
-action_combo_box_render_text (GtkCellLayout *layout,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EActionComboBox *combo_box)
-{
- GtkRadioAction *action;
- gchar **strv;
- gchar *label;
- gboolean sensitive;
- gboolean visible;
- gint xpad;
-
- gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
-
- /* A NULL action means the row is a separator. */
- if (action == NULL)
- return;
-
- g_object_get (
- G_OBJECT (action),
- "label", &label,
- "sensitive", &sensitive,
- "visible", &visible,
- NULL);
-
- /* Strip out underscores. */
- strv = g_strsplit (label, "_", -1);
- g_free (label);
- label = g_strjoinv (NULL, strv);
- g_strfreev (strv);
-
- xpad = combo_box->priv->group_has_icons ? 3 : 0;
-
- g_object_set (
- G_OBJECT (renderer),
- "sensitive", sensitive,
- "text", label,
- "visible", visible,
- "xpad", xpad,
- NULL);
-
- g_free (label);
-}
-
-static gboolean
-action_combo_box_is_row_separator (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- GtkAction *action;
- gboolean separator;
-
- /* NULL actions are rendered as separators. */
- gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
- separator = (action == NULL);
- if (action != NULL)
- g_object_unref (action);
-
- return separator;
-}
-
-static void
-action_combo_box_update_model (EActionComboBox *combo_box)
-{
- GtkListStore *list_store;
- GSList *list;
-
- g_hash_table_remove_all (combo_box->priv->index);
-
- if (combo_box->priv->action == NULL) {
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), NULL);
- return;
- }
-
- /* We store values in the sort column as floats so that we can
- * insert separators in between consecutive integer values and
- * still maintain the proper ordering. */
- list_store = gtk_list_store_new (
- 2, GTK_TYPE_RADIO_ACTION, G_TYPE_FLOAT);
-
- list = gtk_radio_action_get_group (combo_box->priv->action);
- combo_box->priv->group_has_icons = FALSE;
-
- while (list != NULL) {
- GtkTreeRowReference *reference;
- GtkRadioAction *action = list->data;
- GtkTreePath *path;
- GtkTreeIter iter;
- gchar *icon_name;
- gchar *stock_id;
- gint value;
-
- g_object_get (
- action, "icon-name", &icon_name,
- "stock-id", &stock_id, NULL);
- combo_box->priv->group_has_icons |=
- (icon_name != NULL || stock_id != NULL);
- g_free (icon_name);
- g_free (stock_id);
-
- gtk_list_store_append (list_store, &iter);
- g_object_get (action, "value", &value, NULL);
- gtk_list_store_set (
- list_store, &iter, COLUMN_ACTION,
- list->data, COLUMN_SORT, (gfloat) value, -1);
-
- path = gtk_tree_model_get_path (
- GTK_TREE_MODEL (list_store), &iter);
- reference = gtk_tree_row_reference_new (
- GTK_TREE_MODEL (list_store), path);
- g_hash_table_insert (
- combo_box->priv->index,
- GINT_TO_POINTER (value), reference);
- gtk_tree_path_free (path);
-
- list = g_slist_next (list);
- }
-
- gtk_tree_sortable_set_sort_column_id (
- GTK_TREE_SORTABLE (list_store),
- COLUMN_SORT, GTK_SORT_ASCENDING);
- gtk_combo_box_set_model (
- GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store));
-
- action_combo_box_action_changed_cb (
- combo_box->priv->action,
- combo_box->priv->action,
- combo_box);
-}
-
-static void
-action_combo_box_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTION:
- e_action_combo_box_set_action (
- E_ACTION_COMBO_BOX (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-action_combo_box_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTION:
- g_value_set_object (
- value, e_action_combo_box_get_action (
- E_ACTION_COMBO_BOX (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-action_combo_box_dispose (GObject *object)
-{
- EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX_GET_PRIVATE (object);
-
- if (priv->action != NULL) {
- g_object_unref (priv->action);
- priv->action = NULL;
- }
-
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
- g_hash_table_remove_all (priv->index);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_action_combo_box_parent_class)->dispose (object);
-}
-
-static void
-action_combo_box_finalize (GObject *object)
-{
- EActionComboBoxPrivate *priv = E_ACTION_COMBO_BOX_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->index);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_action_combo_box_parent_class)->finalize (object);
-}
-
-static void
-action_combo_box_constructed (GObject *object)
-{
- GtkComboBox *combo_box;
- GtkCellRenderer *renderer;
-
- combo_box = GTK_COMBO_BOX (object);
-
- /* This needs to happen after constructor properties are set
- * so that GtkCellLayout.get_area() returns something valid. */
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (
- GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
- gtk_cell_layout_set_cell_data_func (
- GTK_CELL_LAYOUT (combo_box), renderer,
- (GtkCellLayoutDataFunc) action_combo_box_render_pixbuf,
- combo_box, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (
- GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
- gtk_cell_layout_set_cell_data_func (
- GTK_CELL_LAYOUT (combo_box), renderer,
- (GtkCellLayoutDataFunc) action_combo_box_render_text,
- combo_box, NULL);
-
- gtk_combo_box_set_row_separator_func (
- combo_box, (GtkTreeViewRowSeparatorFunc)
- action_combo_box_is_row_separator, NULL, NULL);
-}
-
-static void
-action_combo_box_changed (GtkComboBox *combo_box)
-{
- GtkRadioAction *action;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gint value;
-
- /* This method is virtual, so no need to chain up. */
-
- if (!gtk_combo_box_get_active_iter (combo_box, &iter))
- return;
-
- model = gtk_combo_box_get_model (combo_box);
- gtk_tree_model_get (model, &iter, COLUMN_ACTION, &action, -1);
- g_object_get (action, "value", &value, NULL);
- gtk_radio_action_set_current_value (action, value);
-}
-
-static void
-e_action_combo_box_class_init (EActionComboBoxClass *class)
-{
- GObjectClass *object_class;
- GtkComboBoxClass *combo_box_class;
-
- g_type_class_add_private (class, sizeof (EActionComboBoxPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = action_combo_box_set_property;
- object_class->get_property = action_combo_box_get_property;
- object_class->dispose = action_combo_box_dispose;
- object_class->finalize = action_combo_box_finalize;
- object_class->constructed = action_combo_box_constructed;
-
- combo_box_class = GTK_COMBO_BOX_CLASS (class);
- combo_box_class->changed = action_combo_box_changed;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTION,
- g_param_spec_object (
- "action",
- "Action",
- "A GtkRadioAction",
- GTK_TYPE_RADIO_ACTION,
- G_PARAM_READWRITE));
-}
-
-static void
-e_action_combo_box_init (EActionComboBox *combo_box)
-{
- combo_box->priv = E_ACTION_COMBO_BOX_GET_PRIVATE (combo_box);
-
- combo_box->priv->index = g_hash_table_new_full (
- g_direct_hash, g_direct_equal,
- (GDestroyNotify) NULL,
- (GDestroyNotify) gtk_tree_row_reference_free);
-}
-
-GtkWidget *
-e_action_combo_box_new (void)
-{
- return e_action_combo_box_new_with_action (NULL);
-}
-
-GtkWidget *
-e_action_combo_box_new_with_action (GtkRadioAction *action)
-{
- return g_object_new (E_TYPE_ACTION_COMBO_BOX, "action", action, NULL);
-}
-
-GtkRadioAction *
-e_action_combo_box_get_action (EActionComboBox *combo_box)
-{
- g_return_val_if_fail (E_ACTION_IS_COMBO_BOX (combo_box), NULL);
-
- return combo_box->priv->action;
-}
-
-void
-e_action_combo_box_set_action (EActionComboBox *combo_box,
- GtkRadioAction *action)
-{
- g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
-
- if (action != NULL)
- g_return_if_fail (GTK_IS_RADIO_ACTION (action));
-
- if (combo_box->priv->action != NULL) {
- g_signal_handler_disconnect (
- combo_box->priv->action,
- combo_box->priv->changed_handler_id);
- g_object_unref (combo_box->priv->action);
- }
-
- if (combo_box->priv->action_group != NULL) {
- g_signal_handler_disconnect (
- combo_box->priv->action_group,
- combo_box->priv->group_sensitive_handler_id);
- g_signal_handler_disconnect (
- combo_box->priv->action_group,
- combo_box->priv->group_visible_handler_id);
- g_object_unref (combo_box->priv->action_group);
- combo_box->priv->action_group = NULL;
- }
-
- if (action != NULL)
- g_object_get (
- g_object_ref (action), "action-group",
- &combo_box->priv->action_group, NULL);
-
- combo_box->priv->action = action;
- action_combo_box_update_model (combo_box);
-
- if (combo_box->priv->action != NULL)
- combo_box->priv->changed_handler_id = g_signal_connect (
- combo_box->priv->action, "changed",
- G_CALLBACK (action_combo_box_action_changed_cb),
- combo_box);
-
- if (combo_box->priv->action_group != NULL) {
- g_object_ref (combo_box->priv->action_group);
- combo_box->priv->group_sensitive_handler_id =
- g_signal_connect (
- combo_box->priv->action_group,
- "notify::sensitive", G_CALLBACK (
- action_combo_box_action_group_notify_cb),
- combo_box);
- combo_box->priv->group_visible_handler_id =
- g_signal_connect (
- combo_box->priv->action_group,
- "notify::visible", G_CALLBACK (
- action_combo_box_action_group_notify_cb),
- combo_box);
- }
-
- g_object_notify (G_OBJECT (combo_box), "action");
-}
-
-gint
-e_action_combo_box_get_current_value (EActionComboBox *combo_box)
-{
- g_return_val_if_fail (E_ACTION_IS_COMBO_BOX (combo_box), 0);
- g_return_val_if_fail (combo_box->priv->action != NULL, 0);
-
- return gtk_radio_action_get_current_value (combo_box->priv->action);
-}
-
-void
-e_action_combo_box_set_current_value (EActionComboBox *combo_box,
- gint current_value)
-{
- g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
- g_return_if_fail (combo_box->priv->action != NULL);
-
- gtk_radio_action_set_current_value (
- combo_box->priv->action, current_value);
-}
-
-void
-e_action_combo_box_add_separator_before (EActionComboBox *combo_box,
- gint action_value)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
-
- /* NULL actions are rendered as separators. */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter, COLUMN_ACTION,
- NULL, COLUMN_SORT, (gfloat) action_value - 0.5, -1);
-}
-
-void
-e_action_combo_box_add_separator_after (EActionComboBox *combo_box,
- gint action_value)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- g_return_if_fail (E_ACTION_IS_COMBO_BOX (combo_box));
-
- /* NULL actions are rendered as separators. */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter, COLUMN_ACTION,
- NULL, COLUMN_SORT, (gfloat) action_value + 0.5, -1);
-}
diff --git a/widgets/misc/e-action-combo-box.h b/widgets/misc/e-action-combo-box.h
deleted file mode 100644
index 300338639a..0000000000
--- a/widgets/misc/e-action-combo-box.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-action-combo-box.h
- *
- * Copyright (C) 2008 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser 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 Lesser General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef E_ACTION_COMBO_BOX_H
-#define E_ACTION_COMBO_BOX_H
-
-/* This is a GtkComboBox that is driven by a group of GtkRadioActions.
- * Just plug in a GtkRadioAction and the widget will handle the rest.
- * (Based on GtkhtmlComboBox.) */
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ACTION_COMBO_BOX \
- (e_action_combo_box_get_type ())
-#define E_ACTION_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ACTION_COMBO_BOX, EActionComboBox))
-#define E_ACTION_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ACTION_COMBO_BOX, EActionComboBoxClass))
-#define E_ACTION_IS_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ACTION_COMBO_BOX))
-#define E_ACTION_IS_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ACTION_COMBO_BOX))
-#define E_ACTION_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ACTION_COMBO_BOX, EActionComboBoxClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EActionComboBox EActionComboBox;
-typedef struct _EActionComboBoxClass EActionComboBoxClass;
-typedef struct _EActionComboBoxPrivate EActionComboBoxPrivate;
-
-struct _EActionComboBox {
- GtkComboBox parent;
- EActionComboBoxPrivate *priv;
-};
-
-struct _EActionComboBoxClass {
- GtkComboBoxClass parent_class;
-};
-
-GType e_action_combo_box_get_type (void);
-GtkWidget * e_action_combo_box_new (void);
-GtkWidget * e_action_combo_box_new_with_action
- (GtkRadioAction *action);
-GtkRadioAction *e_action_combo_box_get_action (EActionComboBox *combo_box);
-void e_action_combo_box_set_action (EActionComboBox *combo_box,
- GtkRadioAction *action);
-gint e_action_combo_box_get_current_value
- (EActionComboBox *combo_box);
-void e_action_combo_box_set_current_value
- (EActionComboBox *combo_box,
- gint current_value);
-void e_action_combo_box_add_separator_before
- (EActionComboBox *combo_box,
- gint action_value);
-void e_action_combo_box_add_separator_after
- (EActionComboBox *combo_box,
- gint action_value);
-
-G_END_DECLS
-
-#endif /* E_ACTION_COMBO_BOX_H */
diff --git a/widgets/misc/e-activity-bar.c b/widgets/misc/e-activity-bar.c
deleted file mode 100644
index f85b403bd7..0000000000
--- a/widgets/misc/e-activity-bar.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * e-activity-bar.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-activity-bar.h"
-
-#define E_ACTIVITY_BAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ACTIVITY_BAR, EActivityBarPrivate))
-
-#define FEEDBACK_PERIOD 1 /* seconds */
-#define COMPLETED_ICON_NAME "emblem-default"
-
-struct _EActivityBarPrivate {
- EActivity *activity; /* weak reference */
- GtkWidget *image; /* not referenced */
- GtkWidget *label; /* not referenced */
- GtkWidget *cancel; /* not referenced */
- GtkWidget *spinner; /* not referenced */
-
- /* If the user clicks the Cancel button, keep the cancelled
- * EActivity object alive for a short duration so the user
- * gets some visual feedback that cancellation worked. */
- guint timeout_id;
-};
-
-enum {
- PROP_0,
- PROP_ACTIVITY
-};
-
-G_DEFINE_TYPE (
- EActivityBar,
- e_activity_bar,
- GTK_TYPE_INFO_BAR)
-
-static void
-activity_bar_feedback (EActivityBar *bar)
-{
- EActivity *activity;
- EActivityState state;
-
- activity = e_activity_bar_get_activity (bar);
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- state = e_activity_get_state (activity);
- if (state != E_ACTIVITY_CANCELLED && state != E_ACTIVITY_COMPLETED)
- return;
-
- if (bar->priv->timeout_id > 0)
- g_source_remove (bar->priv->timeout_id);
-
- /* Hold a reference on the EActivity for a short
- * period so the activity bar stays visible. */
- bar->priv->timeout_id = g_timeout_add_seconds_full (
- G_PRIORITY_LOW, FEEDBACK_PERIOD, (GSourceFunc) gtk_false,
- g_object_ref (activity), (GDestroyNotify) g_object_unref);
-}
-
-static void
-activity_bar_update (EActivityBar *bar)
-{
- EActivity *activity;
- EActivityState state;
- GCancellable *cancellable;
- const gchar *icon_name;
- gboolean sensitive;
- gboolean visible;
- gchar *description;
-
- activity = e_activity_bar_get_activity (bar);
-
- if (activity == NULL) {
- gtk_widget_hide (GTK_WIDGET (bar));
- return;
- }
-
- cancellable = e_activity_get_cancellable (activity);
- icon_name = e_activity_get_icon_name (activity);
- state = e_activity_get_state (activity);
-
- description = e_activity_describe (activity);
- gtk_label_set_text (GTK_LABEL (bar->priv->label), description);
-
- if (state == E_ACTIVITY_CANCELLED) {
- PangoAttribute *attr;
- PangoAttrList *attr_list;
-
- attr_list = pango_attr_list_new ();
-
- attr = pango_attr_strikethrough_new (TRUE);
- pango_attr_list_insert (attr_list, attr);
-
- gtk_label_set_attributes (
- GTK_LABEL (bar->priv->label), attr_list);
-
- pango_attr_list_unref (attr_list);
- } else
- gtk_label_set_attributes (
- GTK_LABEL (bar->priv->label), NULL);
-
- if (state == E_ACTIVITY_COMPLETED)
- icon_name = COMPLETED_ICON_NAME;
-
- if (state == E_ACTIVITY_CANCELLED) {
- gtk_image_set_from_stock (
- GTK_IMAGE (bar->priv->image),
- GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (bar->priv->image);
- } else if (icon_name != NULL) {
- gtk_image_set_from_icon_name (
- GTK_IMAGE (bar->priv->image),
- icon_name, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (bar->priv->image);
- } else {
- gtk_widget_hide (bar->priv->image);
- }
-
- visible = (cancellable != NULL);
- gtk_widget_set_visible (bar->priv->cancel, visible);
-
- sensitive = (state == E_ACTIVITY_RUNNING);
- gtk_widget_set_sensitive (bar->priv->cancel, sensitive);
-
- visible = (description != NULL && *description != '\0');
- gtk_widget_set_visible (GTK_WIDGET (bar), visible);
-
- g_free (description);
-}
-
-static void
-activity_bar_cancel (EActivityBar *bar)
-{
- EActivity *activity;
- GCancellable *cancellable;
-
- activity = e_activity_bar_get_activity (bar);
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- cancellable = e_activity_get_cancellable (activity);
- g_cancellable_cancel (cancellable);
-
- activity_bar_update (bar);
-}
-
-static void
-activity_bar_weak_notify_cb (EActivityBar *bar,
- GObject *where_the_object_was)
-{
- g_return_if_fail (E_IS_ACTIVITY_BAR (bar));
-
- bar->priv->activity = NULL;
- e_activity_bar_set_activity (bar, NULL);
-}
-
-static void
-activity_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVITY:
- e_activity_bar_set_activity (
- E_ACTIVITY_BAR (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-activity_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVITY:
- g_value_set_object (
- value, e_activity_bar_get_activity (
- E_ACTIVITY_BAR (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-activity_bar_dispose (GObject *object)
-{
- EActivityBarPrivate *priv;
-
- priv = E_ACTIVITY_BAR_GET_PRIVATE (object);
-
- if (priv->timeout_id > 0) {
- g_source_remove (priv->timeout_id);
- priv->timeout_id = 0;
- }
-
- if (priv->activity != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->activity, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_weak_unref (
- G_OBJECT (priv->activity), (GWeakNotify)
- activity_bar_weak_notify_cb, object);
- priv->activity = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_activity_bar_parent_class)->dispose (object);
-}
-
-static void
-e_activity_bar_class_init (EActivityBarClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EActivityBarPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = activity_bar_set_property;
- object_class->get_property = activity_bar_get_property;
- object_class->dispose = activity_bar_dispose;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTIVITY,
- g_param_spec_object (
- "activity",
- NULL,
- NULL,
- E_TYPE_ACTIVITY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_activity_bar_init (EActivityBar *bar)
-{
- GtkWidget *container;
- GtkWidget *widget;
-
- bar->priv = E_ACTIVITY_BAR_GET_PRIVATE (bar);
-
- container = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
-
- widget = gtk_hbox_new (FALSE, 12);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->image = widget;
-
- widget = gtk_spinner_new ();
- gtk_spinner_start (GTK_SPINNER (widget));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->spinner = widget;
-
- /* The spinner is only visible when the image is not. */
- g_object_bind_property (
- bar->priv->image, "visible",
- bar->priv->spinner, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE |
- G_BINDING_INVERT_BOOLEAN);
-
- widget = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- bar->priv->label = widget;
- gtk_widget_show (widget);
-
- /* This is only shown if the EActivity has a GCancellable. */
- widget = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_info_bar_add_action_widget (
- GTK_INFO_BAR (bar), widget, GTK_RESPONSE_CANCEL);
- bar->priv->cancel = widget;
- gtk_widget_hide (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (activity_bar_cancel), bar);
-}
-
-GtkWidget *
-e_activity_bar_new (void)
-{
- return g_object_new (E_TYPE_ACTIVITY_BAR, NULL);
-}
-
-EActivity *
-e_activity_bar_get_activity (EActivityBar *bar)
-{
- g_return_val_if_fail (E_IS_ACTIVITY_BAR (bar), NULL);
-
- return bar->priv->activity;
-}
-
-void
-e_activity_bar_set_activity (EActivityBar *bar,
- EActivity *activity)
-{
- g_return_if_fail (E_IS_ACTIVITY_BAR (bar));
-
- if (activity != NULL)
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- if (bar->priv->timeout_id > 0) {
- g_source_remove (bar->priv->timeout_id);
- bar->priv->timeout_id = 0;
- }
-
- if (bar->priv->activity != NULL) {
- g_signal_handlers_disconnect_matched (
- bar->priv->activity, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, bar);
- g_object_weak_unref (
- G_OBJECT (bar->priv->activity),
- (GWeakNotify) activity_bar_weak_notify_cb, bar);
- }
-
- bar->priv->activity = activity;
-
- if (activity != NULL) {
- g_object_weak_ref (
- G_OBJECT (activity), (GWeakNotify)
- activity_bar_weak_notify_cb, bar);
-
- g_signal_connect_swapped (
- activity, "notify::state",
- G_CALLBACK (activity_bar_feedback), bar);
-
- g_signal_connect_swapped (
- activity, "notify",
- G_CALLBACK (activity_bar_update), bar);
- }
-
- activity_bar_update (bar);
-
- g_object_notify (G_OBJECT (bar), "activity");
-}
diff --git a/widgets/misc/e-activity-bar.h b/widgets/misc/e-activity-bar.h
deleted file mode 100644
index 24f56eca53..0000000000
--- a/widgets/misc/e-activity-bar.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * e-activity-bar.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_ACTIVITY_BAR_H
-#define E_ACTIVITY_BAR_H
-
-#include <gtk/gtk.h>
-#include <e-util/e-activity.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ACTIVITY_BAR \
- (e_activity_bar_get_type ())
-#define E_ACTIVITY_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ACTIVITY_BAR, EActivityBar))
-#define E_ACTIVITY_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ACTIVITY_BAR, EActivityBarClass))
-#define E_IS_ACTIVITY_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ACTIVITY_BAR))
-#define E_IS_ACTIVITY_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ACTIVITY_BAR))
-#define E_ACTIVITY_BAR_GET_CLASS(obj) \
- (G_TYPE_CHECK_INSTANCE_GET_TYPE \
- ((obj), E_TYPE_ACTIVITY_BAR, EActivityBarClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EActivityBar EActivityBar;
-typedef struct _EActivityBarClass EActivityBarClass;
-typedef struct _EActivityBarPrivate EActivityBarPrivate;
-
-struct _EActivityBar {
- GtkInfoBar parent;
- EActivityBarPrivate *priv;
-};
-
-struct _EActivityBarClass {
- GtkInfoBarClass parent_class;
-};
-
-GType e_activity_bar_get_type (void);
-GtkWidget * e_activity_bar_new (void);
-EActivity * e_activity_bar_get_activity (EActivityBar *bar);
-void e_activity_bar_set_activity (EActivityBar *bar,
- EActivity *activity);
-
-G_END_DECLS
-
-#endif /* E_ACTIVITY_BAR_H */
diff --git a/widgets/misc/e-activity-proxy.c b/widgets/misc/e-activity-proxy.c
deleted file mode 100644
index 7547088aac..0000000000
--- a/widgets/misc/e-activity-proxy.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * e-activity-proxy.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-activity-proxy.h"
-
-#include <glib/gi18n.h>
-
-#define E_ACTIVITY_PROXY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxyPrivate))
-
-#define FEEDBACK_PERIOD 1 /* seconds */
-#define COMPLETED_ICON_NAME "emblem-default"
-
-struct _EActivityProxyPrivate {
- EActivity *activity; /* weak reference */
- GtkWidget *image; /* not referenced */
- GtkWidget *label; /* not referenced */
- GtkWidget *cancel; /* not referenced */
- GtkWidget *spinner; /* not referenced */
-
- /* If the user clicks the Cancel button, keep the cancelled
- * EActivity object alive for a short duration so the user
- * gets some visual feedback that cancellation worked. */
- guint timeout_id;
-};
-
-enum {
- PROP_0,
- PROP_ACTIVITY
-};
-
-G_DEFINE_TYPE (
- EActivityProxy,
- e_activity_proxy,
- GTK_TYPE_FRAME)
-
-static void
-activity_proxy_feedback (EActivityProxy *proxy)
-{
- EActivity *activity;
- EActivityState state;
-
- activity = e_activity_proxy_get_activity (proxy);
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- state = e_activity_get_state (activity);
- if (state != E_ACTIVITY_CANCELLED)
- return;
-
- if (proxy->priv->timeout_id > 0)
- g_source_remove (proxy->priv->timeout_id);
-
- /* Hold a reference on the EActivity for a short
- * period so the activity proxy stays visible. */
- proxy->priv->timeout_id = g_timeout_add_seconds_full (
- G_PRIORITY_LOW, FEEDBACK_PERIOD, (GSourceFunc) gtk_false,
- g_object_ref (activity), (GDestroyNotify) g_object_unref);
-}
-
-static void
-activity_proxy_update (EActivityProxy *proxy)
-{
- EActivity *activity;
- EActivityState state;
- GCancellable *cancellable;
- const gchar *icon_name;
- gboolean sensitive;
- gboolean visible;
- gchar *description;
-
- activity = e_activity_proxy_get_activity (proxy);
-
- if (activity == NULL) {
- gtk_widget_hide (GTK_WIDGET (proxy));
- return;
- }
-
- cancellable = e_activity_get_cancellable (activity);
- icon_name = e_activity_get_icon_name (activity);
- state = e_activity_get_state (activity);
-
- description = e_activity_describe (activity);
- gtk_widget_set_tooltip_text (GTK_WIDGET (proxy), description);
- gtk_label_set_text (GTK_LABEL (proxy->priv->label), description);
-
- if (state == E_ACTIVITY_CANCELLED) {
- PangoAttribute *attr;
- PangoAttrList *attr_list;
-
- attr_list = pango_attr_list_new ();
-
- attr = pango_attr_strikethrough_new (TRUE);
- pango_attr_list_insert (attr_list, attr);
-
- gtk_label_set_attributes (
- GTK_LABEL (proxy->priv->label), attr_list);
-
- pango_attr_list_unref (attr_list);
- } else
- gtk_label_set_attributes (
- GTK_LABEL (proxy->priv->label), NULL);
-
- if (state == E_ACTIVITY_COMPLETED)
- icon_name = COMPLETED_ICON_NAME;
-
- if (state == E_ACTIVITY_CANCELLED) {
- gtk_image_set_from_stock (
- GTK_IMAGE (proxy->priv->image),
- GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (proxy->priv->image);
- } else if (icon_name != NULL) {
- gtk_image_set_from_icon_name (
- GTK_IMAGE (proxy->priv->image),
- icon_name, GTK_ICON_SIZE_MENU);
- gtk_widget_show (proxy->priv->image);
- } else {
- gtk_widget_hide (proxy->priv->image);
- }
-
- visible = (cancellable != NULL);
- gtk_widget_set_visible (proxy->priv->cancel, visible);
-
- sensitive = (state == E_ACTIVITY_RUNNING);
- gtk_widget_set_sensitive (proxy->priv->cancel, sensitive);
-
- visible = (description != NULL && *description != '\0');
- gtk_widget_set_visible (GTK_WIDGET (proxy), visible);
-
- g_free (description);
-}
-
-static void
-activity_proxy_cancel (EActivityProxy *proxy)
-{
- EActivity *activity;
- GCancellable *cancellable;
-
- activity = e_activity_proxy_get_activity (proxy);
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- cancellable = e_activity_get_cancellable (activity);
- g_cancellable_cancel (cancellable);
-
- activity_proxy_update (proxy);
-}
-
-static void
-activity_proxy_weak_notify_cb (EActivityProxy *proxy,
- GObject *where_the_object_was)
-{
- g_return_if_fail (E_IS_ACTIVITY_PROXY (proxy));
-
- proxy->priv->activity = NULL;
- e_activity_proxy_set_activity (proxy, NULL);
-}
-
-static void
-activity_proxy_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVITY:
- e_activity_proxy_set_activity (
- E_ACTIVITY_PROXY (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-activity_proxy_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVITY:
- g_value_set_object (
- value, e_activity_proxy_get_activity (
- E_ACTIVITY_PROXY (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-activity_proxy_dispose (GObject *object)
-{
- EActivityProxyPrivate *priv;
-
- priv = E_ACTIVITY_PROXY_GET_PRIVATE (object);
-
- if (priv->timeout_id > 0) {
- g_source_remove (priv->timeout_id);
- priv->timeout_id = 0;
- }
-
- if (priv->activity != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->activity, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_weak_unref (
- G_OBJECT (priv->activity), (GWeakNotify)
- activity_proxy_weak_notify_cb, object);
- priv->activity = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_activity_proxy_parent_class)->dispose (object);
-}
-
-static void
-e_activity_proxy_class_init (EActivityProxyClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EActivityProxyPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = activity_proxy_set_property;
- object_class->get_property = activity_proxy_get_property;
- object_class->dispose = activity_proxy_dispose;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTIVITY,
- g_param_spec_object (
- "activity",
- NULL,
- NULL,
- E_TYPE_ACTIVITY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_activity_proxy_init (EActivityProxy *proxy)
-{
- GtkWidget *container;
- GtkWidget *widget;
-
- proxy->priv = E_ACTIVITY_PROXY_GET_PRIVATE (proxy);
-
- gtk_frame_set_shadow_type (GTK_FRAME (proxy), GTK_SHADOW_IN);
-
- container = GTK_WIDGET (proxy);
-
- widget = gtk_hbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- proxy->priv->image = widget;
-
- widget = gtk_spinner_new ();
- gtk_spinner_start (GTK_SPINNER (widget));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 3);
- proxy->priv->spinner = widget;
-
- /* The spinner is only visible when the image is not. */
- g_object_bind_property (
- proxy->priv->image, "visible",
- proxy->priv->spinner, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE |
- G_BINDING_INVERT_BOOLEAN);
-
- widget = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- proxy->priv->label = widget;
- gtk_widget_show (widget);
-
- /* This is only shown if the EActivity has a GCancellable. */
- widget = gtk_button_new ();
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_stock (
- GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU));
- gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_set_tooltip_text (widget, _("Cancel"));
- proxy->priv->cancel = widget;
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (activity_proxy_cancel), proxy);
-}
-
-GtkWidget *
-e_activity_proxy_new (EActivity *activity)
-{
- g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
-
- return g_object_new (
- E_TYPE_ACTIVITY_PROXY, "activity", activity, NULL);
-}
-
-EActivity *
-e_activity_proxy_get_activity (EActivityProxy *proxy)
-{
- g_return_val_if_fail (E_IS_ACTIVITY_PROXY (proxy), NULL);
-
- return proxy->priv->activity;
-}
-
-void
-e_activity_proxy_set_activity (EActivityProxy *proxy,
- EActivity *activity)
-{
- g_return_if_fail (E_IS_ACTIVITY_PROXY (proxy));
-
- if (activity != NULL)
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- if (proxy->priv->timeout_id > 0) {
- g_source_remove (proxy->priv->timeout_id);
- proxy->priv->timeout_id = 0;
- }
-
- if (proxy->priv->activity != NULL) {
- g_signal_handlers_disconnect_matched (
- proxy->priv->activity, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, proxy);
- g_object_weak_unref (
- G_OBJECT (proxy->priv->activity),
- (GWeakNotify) activity_proxy_weak_notify_cb, proxy);
- }
-
- proxy->priv->activity = activity;
-
- if (activity != NULL) {
- g_object_weak_ref (
- G_OBJECT (activity), (GWeakNotify)
- activity_proxy_weak_notify_cb, proxy);
-
- g_signal_connect_swapped (
- activity, "notify::state",
- G_CALLBACK (activity_proxy_feedback), proxy);
-
- g_signal_connect_swapped (
- activity, "notify",
- G_CALLBACK (activity_proxy_update), proxy);
- }
-
- activity_proxy_update (proxy);
-
- g_object_notify (G_OBJECT (proxy), "activity");
-}
diff --git a/widgets/misc/e-activity-proxy.h b/widgets/misc/e-activity-proxy.h
deleted file mode 100644
index 975cd6ff05..0000000000
--- a/widgets/misc/e-activity-proxy.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * e-activity-proxy.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ACTIVITY_PROXY_H
-#define E_ACTIVITY_PROXY_H
-
-#include <gtk/gtk.h>
-#include <e-util/e-activity.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ACTIVITY_PROXY \
- (e_activity_proxy_get_type ())
-#define E_ACTIVITY_PROXY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxy))
-#define E_ACTIVITY_PROXY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ACTIVITY_PROXY, EActivityProxyClass))
-#define E_IS_ACTIVITY_PROXY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ACTIVITY_PROXY))
-#define E_IS_ACTIVITY_PROXY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ACTIVITY_PROXY))
-#define E_ACTIVITY_PROXY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxyClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EActivityProxy EActivityProxy;
-typedef struct _EActivityProxyClass EActivityProxyClass;
-typedef struct _EActivityProxyPrivate EActivityProxyPrivate;
-
-struct _EActivityProxy {
- GtkFrame parent;
- EActivityProxyPrivate *priv;
-};
-
-struct _EActivityProxyClass {
- GtkFrameClass parent_class;
-};
-
-GType e_activity_proxy_get_type (void);
-GtkWidget * e_activity_proxy_new (EActivity *activity);
-EActivity * e_activity_proxy_get_activity (EActivityProxy *proxy);
-void e_activity_proxy_set_activity (EActivityProxy *proxy,
- EActivity *activity);
-
-G_END_DECLS
-
-#endif /* E_ACTIVITY_PROXY_H */
diff --git a/widgets/misc/e-alarm-selector.c b/widgets/misc/e-alarm-selector.c
deleted file mode 100644
index bdc1b7e35e..0000000000
--- a/widgets/misc/e-alarm-selector.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * e-alarm-selector.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-alarm-selector.h"
-
-G_DEFINE_TYPE (
- EAlarmSelector,
- e_alarm_selector,
- E_TYPE_SOURCE_SELECTOR)
-
-static gboolean
-alarm_selector_get_source_selected (ESourceSelector *selector,
- ESource *source)
-{
- ESourceAlarms *extension;
- const gchar *extension_name;
-
- /* Make sure this source is a calendar. */
- extension_name = e_source_selector_get_extension_name (selector);
- if (!e_source_has_extension (source, extension_name))
- return FALSE;
-
- extension_name = E_SOURCE_EXTENSION_ALARMS;
- extension = e_source_get_extension (source, extension_name);
- g_return_val_if_fail (E_IS_SOURCE_ALARMS (extension), FALSE);
-
- return e_source_alarms_get_include_me (extension);
-}
-
-static void
-alarm_selector_set_source_selected (ESourceSelector *selector,
- ESource *source,
- gboolean selected)
-{
- ESourceAlarms *extension;
- const gchar *extension_name;
-
- /* Make sure this source is a calendar. */
- extension_name = e_source_selector_get_extension_name (selector);
- if (!e_source_has_extension (source, extension_name))
- return;
-
- extension_name = E_SOURCE_EXTENSION_ALARMS;
- extension = e_source_get_extension (source, extension_name);
- g_return_if_fail (E_IS_SOURCE_ALARMS (extension));
-
- if (selected != e_source_alarms_get_include_me (extension)) {
- e_source_alarms_set_include_me (extension, selected);
- e_source_selector_queue_write (selector, source);
- }
-}
-
-static void
-e_alarm_selector_class_init (EAlarmSelectorClass *class)
-{
- ESourceSelectorClass *source_selector_class;
-
- source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
- source_selector_class->get_source_selected =
- alarm_selector_get_source_selected;
- source_selector_class->set_source_selected =
- alarm_selector_set_source_selected;
-}
-
-static void
-e_alarm_selector_init (EAlarmSelector *selector)
-{
-}
-
-GtkWidget *
-e_alarm_selector_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_ALARM_SELECTOR,
- "extension-name", E_SOURCE_EXTENSION_CALENDAR,
- "registry", registry, NULL);
-}
diff --git a/widgets/misc/e-alarm-selector.h b/widgets/misc/e-alarm-selector.h
deleted file mode 100644
index 63500866c9..0000000000
--- a/widgets/misc/e-alarm-selector.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * e-alarm-selector.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_ALARM_SELECTOR_H
-#define E_ALARM_SELECTOR_H
-
-#include <libedataserverui/libedataserverui.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ALARM_SELECTOR \
- (e_alarm_selector_get_type ())
-#define E_ALARM_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ALARM_SELECTOR, EAlarmSelector))
-#define E_ALARM_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ALARM_SELECTOR, EAlarmSelectorClass))
-#define E_IS_ALARM_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ALARM_SELECTOR))
-#define E_IS_ALARM_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ALARM_SELECTOR))
-#define E_ALARM_SELECTOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ALARM_SELECTOR, EAlarmSelectorClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAlarmSelector EAlarmSelector;
-typedef struct _EAlarmSelectorClass EAlarmSelectorClass;
-typedef struct _EAlarmSelectorPrivate EAlarmSelectorPrivate;
-
-struct _EAlarmSelector {
- ESourceSelector parent;
- EAlarmSelectorPrivate *priv;
-};
-
-struct _EAlarmSelectorClass {
- ESourceSelectorClass parent_class;
-};
-
-GType e_alarm_selector_get_type (void) G_GNUC_CONST;
-GtkWidget * e_alarm_selector_new (ESourceRegistry *registry);
-
-G_END_DECLS
-
-#endif /* E_ALARM_SELECTOR_H */
diff --git a/widgets/misc/e-alert-bar.c b/widgets/misc/e-alert-bar.c
deleted file mode 100644
index 2022af99f1..0000000000
--- a/widgets/misc/e-alert-bar.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * e-alert-bar.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-alert-bar.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#define E_ALERT_BAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ALERT_BAR, EAlertBarPrivate))
-
-#define E_ALERT_BAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ALERT_BAR, EAlertBarPrivate))
-
-/* GTK_ICON_SIZE_DIALOG is a tad too big. */
-#define ICON_SIZE GTK_ICON_SIZE_DND
-
-/* Dismiss warnings automatically after 5 minutes. */
-#define WARNING_TIMEOUT_SECONDS (5 * 60)
-
-struct _EAlertBarPrivate {
- GQueue alerts;
- GtkWidget *image; /* not referenced */
- GtkWidget *primary_label; /* not referenced */
- GtkWidget *secondary_label; /* not referenced */
-};
-
-G_DEFINE_TYPE (
- EAlertBar,
- e_alert_bar,
- GTK_TYPE_INFO_BAR)
-
-static void
-alert_bar_response_close (EAlert *alert)
-{
- e_alert_response (alert, GTK_RESPONSE_CLOSE);
-}
-
-static void
-alert_bar_show_alert (EAlertBar *alert_bar)
-{
- GtkImage *image;
- GtkInfoBar *info_bar;
- GtkWidget *action_area;
- GtkWidget *widget;
- EAlert *alert;
- GList *actions;
- GList *children;
- GtkMessageType message_type;
- const gchar *primary_text;
- const gchar *secondary_text;
- const gchar *stock_id;
- gboolean have_primary_text;
- gboolean have_secondary_text;
- gboolean visible;
- gint response_id;
- gchar *markup;
-
- info_bar = GTK_INFO_BAR (alert_bar);
- action_area = gtk_info_bar_get_action_area (info_bar);
-
- alert = g_queue_peek_head (&alert_bar->priv->alerts);
- g_return_if_fail (E_IS_ALERT (alert));
-
- /* Remove all buttons from the previous alert. */
- children = gtk_container_get_children (GTK_CONTAINER (action_area));
- while (children != NULL) {
- GtkWidget *child = GTK_WIDGET (children->data);
- gtk_container_remove (GTK_CONTAINER (action_area), child);
- children = g_list_delete_link (children, children);
- }
-
- /* Add alert-specific buttons. */
- actions = e_alert_peek_actions (alert);
- while (actions != NULL) {
- /* These actions are already wired to trigger an
- * EAlert::response signal when activated, which
- * will in turn call gtk_info_bar_response(), so
- * we can add buttons directly to the action
- * area without knowning their response IDs. */
-
- widget = gtk_button_new ();
-
- gtk_activatable_set_related_action (
- GTK_ACTIVATABLE (widget),
- GTK_ACTION (actions->data));
-
- gtk_box_pack_end (
- GTK_BOX (action_area), widget, FALSE, FALSE, 0);
-
- actions = g_list_next (actions);
- }
-
- /* Add a dismiss button. */
- widget = gtk_button_new ();
- gtk_button_set_image (
- GTK_BUTTON (widget),
- gtk_image_new_from_stock (
- GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
- gtk_button_set_relief (
- GTK_BUTTON (widget), GTK_RELIEF_NONE);
- gtk_widget_set_tooltip_text (
- widget, _("Close this message"));
- gtk_box_pack_end (
- GTK_BOX (action_area), widget, FALSE, FALSE, 0);
- gtk_button_box_set_child_non_homogeneous (
- GTK_BUTTON_BOX (action_area), widget, TRUE);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (alert_bar_response_close), alert);
-
- primary_text = e_alert_get_primary_text (alert);
- secondary_text = e_alert_get_secondary_text (alert);
-
- if (primary_text == NULL)
- primary_text = "";
-
- if (secondary_text == NULL)
- secondary_text = "";
-
- have_primary_text = (*primary_text != '\0');
- have_secondary_text = (*secondary_text != '\0');
-
- response_id = e_alert_get_default_response (alert);
- gtk_info_bar_set_default_response (info_bar, response_id);
-
- message_type = e_alert_get_message_type (alert);
- gtk_info_bar_set_message_type (info_bar, message_type);
-
- widget = alert_bar->priv->primary_label;
- if (have_primary_text && have_secondary_text)
- markup = g_markup_printf_escaped (
- "<b>%s</b>", primary_text);
- else
- markup = g_markup_escape_text (primary_text, -1);
- gtk_label_set_markup (GTK_LABEL (widget), markup);
- gtk_widget_set_visible (widget, have_primary_text);
- g_free (markup);
-
- widget = alert_bar->priv->secondary_label;
- if (have_primary_text && have_secondary_text)
- markup = g_markup_printf_escaped (
- "<small>%s</small>", secondary_text);
- else
- markup = g_markup_escape_text (secondary_text, -1);
- gtk_label_set_markup (GTK_LABEL (widget), markup);
- gtk_widget_set_visible (widget, have_secondary_text);
- g_free (markup);
-
- stock_id = e_alert_get_stock_id (alert);
- image = GTK_IMAGE (alert_bar->priv->image);
- gtk_image_set_from_stock (image, stock_id, ICON_SIZE);
-
- /* Avoid showing an image for one-line alerts,
- * which are usually questions or informational. */
- visible = have_primary_text && have_secondary_text;
- gtk_widget_set_visible (alert_bar->priv->image, visible);
-
- gtk_widget_show (GTK_WIDGET (alert_bar));
-
- /* Warnings are generally meant for transient errors.
- * No need to leave them up indefinitely. Close them
- * automatically if the user hasn't responded after a
- * reasonable period of time has elapsed. */
- if (message_type == GTK_MESSAGE_WARNING)
- e_alert_start_timer (alert, WARNING_TIMEOUT_SECONDS);
-}
-
-static void
-alert_bar_response_cb (EAlert *alert,
- gint response_id,
- EAlertBar *alert_bar)
-{
- GQueue *queue;
- EAlert *head;
- gboolean was_head;
-
- queue = &alert_bar->priv->alerts;
- head = g_queue_peek_head (queue);
- was_head = (alert == head);
-
- g_signal_handlers_disconnect_by_func (
- alert, alert_bar_response_cb, alert_bar);
-
- if (g_queue_remove (queue, alert))
- g_object_unref (alert);
-
- if (g_queue_is_empty (queue))
- gtk_widget_hide (GTK_WIDGET (alert_bar));
- else if (was_head) {
- GtkInfoBar *info_bar = GTK_INFO_BAR (alert_bar);
- gtk_info_bar_response (info_bar, response_id);
- alert_bar_show_alert (alert_bar);
- }
-}
-
-static void
-alert_bar_dispose (GObject *object)
-{
- EAlertBarPrivate *priv;
-
- priv = E_ALERT_BAR_GET_PRIVATE (object);
-
- while (!g_queue_is_empty (&priv->alerts)) {
- EAlert *alert = g_queue_pop_head (&priv->alerts);
- g_signal_handlers_disconnect_by_func (
- alert, alert_bar_response_cb, object);
- g_object_unref (alert);
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_alert_bar_parent_class)->dispose (object);
-}
-
-static void
-alert_bar_constructed (GObject *object)
-{
- EAlertBarPrivate *priv;
- GtkInfoBar *info_bar;
- GtkWidget *action_area;
- GtkWidget *content_area;
- GtkWidget *container;
- GtkWidget *widget;
-
- priv = E_ALERT_BAR_GET_PRIVATE (object);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_alert_bar_parent_class)->constructed (object);
-
- g_queue_init (&priv->alerts);
-
- info_bar = GTK_INFO_BAR (object);
- action_area = gtk_info_bar_get_action_area (info_bar);
- content_area = gtk_info_bar_get_content_area (info_bar);
-
- gtk_orientable_set_orientation (
- GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_set_valign (action_area, GTK_ALIGN_START);
-
- container = content_area;
-
- widget = gtk_image_new ();
- gtk_misc_set_alignment (GTK_MISC (widget), 0.5, 0.0);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- priv->image = widget;
- gtk_widget_show (widget);
-
- widget = gtk_vbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- priv->primary_label = widget;
- gtk_widget_show (widget);
-
- widget = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- priv->secondary_label = widget;
- gtk_widget_show (widget);
-
- container = action_area;
-}
-
-static GtkSizeRequestMode
-alert_bar_get_request_mode (GtkWidget *widget)
-{
- /* GtkBox does width-for-height by default. But we
- * want the alert bar to be as short as possible. */
- return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
-}
-
-static void
-e_alert_bar_class_init (EAlertBarClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EAlertBarPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = alert_bar_dispose;
- object_class->constructed = alert_bar_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->get_request_mode = alert_bar_get_request_mode;
-}
-
-static void
-e_alert_bar_init (EAlertBar *alert_bar)
-{
- alert_bar->priv = E_ALERT_BAR_GET_PRIVATE (alert_bar);
-}
-
-GtkWidget *
-e_alert_bar_new (void)
-{
- return g_object_new (E_TYPE_ALERT_BAR, NULL);
-}
-
-void
-e_alert_bar_clear (EAlertBar *alert_bar)
-{
- GQueue *queue;
- EAlert *alert;
-
- g_return_if_fail (E_IS_ALERT_BAR (alert_bar));
-
- queue = &alert_bar->priv->alerts;
-
- while ((alert = g_queue_pop_head (queue)) != NULL)
- alert_bar_response_close (alert);
-}
-
-typedef struct {
- gboolean found;
- EAlert *looking_for;
-} DuplicateData;
-
-static void
-alert_bar_find_duplicate_cb (EAlert *alert,
- DuplicateData *dd)
-{
- g_return_if_fail (dd->looking_for != NULL);
-
- dd->found |= (
- e_alert_get_message_type (alert) ==
- e_alert_get_message_type (dd->looking_for) &&
- g_strcmp0 (
- e_alert_get_primary_text (alert),
- e_alert_get_primary_text (dd->looking_for)) == 0 &&
- g_strcmp0 (
- e_alert_get_secondary_text (alert),
- e_alert_get_secondary_text (dd->looking_for)) == 0);
-}
-
-void
-e_alert_bar_add_alert (EAlertBar *alert_bar,
- EAlert *alert)
-{
- DuplicateData dd;
-
- g_return_if_fail (E_IS_ALERT_BAR (alert_bar));
- g_return_if_fail (E_IS_ALERT (alert));
-
- dd.found = FALSE;
- dd.looking_for = alert;
-
- g_queue_foreach (
- &alert_bar->priv->alerts,
- (GFunc) alert_bar_find_duplicate_cb, &dd);
-
- if (dd.found)
- return;
-
- g_signal_connect (
- alert, "response",
- G_CALLBACK (alert_bar_response_cb), alert_bar);
-
- g_queue_push_head (&alert_bar->priv->alerts, g_object_ref (alert));
-
- alert_bar_show_alert (alert_bar);
-}
diff --git a/widgets/misc/e-alert-bar.h b/widgets/misc/e-alert-bar.h
deleted file mode 100644
index f0cf39abb1..0000000000
--- a/widgets/misc/e-alert-bar.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * e-alert-bar.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_ALERT_BAR_H
-#define E_ALERT_BAR_H
-
-#include <gtk/gtk.h>
-#include <libevolution-utils/e-alert.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ALERT_BAR \
- (e_alert_bar_get_type ())
-#define E_ALERT_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ALERT_BAR, EAlertBar))
-#define E_ALERT_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ALERT_BAR, EAlertBarClass))
-#define E_IS_ALERT_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ALERT_BAR))
-#define E_IS_ALERT_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ALERT_BAR))
-#define E_ALERT_BAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ALERT_BAR, EAlertBarClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAlertBar EAlertBar;
-typedef struct _EAlertBarClass EAlertBarClass;
-typedef struct _EAlertBarPrivate EAlertBarPrivate;
-
-struct _EAlertBar {
- GtkInfoBar parent;
- EAlertBarPrivate *priv;
-};
-
-struct _EAlertBarClass {
- GtkInfoBarClass parent_class;
-};
-
-GType e_alert_bar_get_type (void);
-GtkWidget * e_alert_bar_new (void);
-void e_alert_bar_clear (EAlertBar *alert_bar);
-void e_alert_bar_add_alert (EAlertBar *alert_bar,
- EAlert *alert);
-
-G_END_DECLS
-
-#endif /* E_ALERT_BAR_H */
diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c
deleted file mode 100644
index 3fc4753055..0000000000
--- a/widgets/misc/e-attachment-bar.c
+++ /dev/null
@@ -1,778 +0,0 @@
-/*
- * e-attachment-bar.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-bar.h"
-
-#include <glib/gi18n.h>
-
-#include "e-attachment-store.h"
-#include "e-attachment-icon-view.h"
-#include "e-attachment-tree-view.h"
-
-#define E_ATTACHMENT_BAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_BAR, EAttachmentBarPrivate))
-
-#define NUM_VIEWS 2
-
-struct _EAttachmentBarPrivate {
- GtkTreeModel *model;
- GtkWidget *vbox;
- GtkWidget *expander;
- GtkWidget *combo_box;
- GtkWidget *icon_view;
- GtkWidget *tree_view;
- GtkWidget *icon_frame;
- GtkWidget *tree_frame;
- GtkWidget *status_icon;
- GtkWidget *status_label;
- GtkWidget *save_all_button;
- GtkWidget *save_one_button;
-
- gint active_view;
- guint expanded : 1;
-};
-
-enum {
- PROP_0,
- PROP_ACTIVE_VIEW,
- PROP_DRAGGING,
- PROP_EDITABLE,
- PROP_EXPANDED,
- PROP_STORE
-};
-
-/* Forward Declarations */
-static void e_attachment_bar_interface_init
- (EAttachmentViewInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EAttachmentBar,
- e_attachment_bar,
- GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ATTACHMENT_VIEW,
- e_attachment_bar_interface_init))
-
-static void
-attachment_bar_update_status (EAttachmentBar *bar)
-{
- EAttachmentStore *store;
- GtkActivatable *activatable;
- GtkAction *action;
- GtkLabel *label;
- gint num_attachments;
- guint64 total_size;
- gchar *display_size;
- gchar *markup;
-
- store = E_ATTACHMENT_STORE (bar->priv->model);
- label = GTK_LABEL (bar->priv->status_label);
-
- num_attachments = e_attachment_store_get_num_attachments (store);
- total_size = e_attachment_store_get_total_size (store);
- display_size = g_format_size (total_size);
-
- if (total_size > 0)
- markup = g_strdup_printf (
- "<b>%d</b> %s (%s)", num_attachments, ngettext (
- "Attachment", "Attachments", num_attachments),
- display_size);
- else
- markup = g_strdup_printf (
- "<b>%d</b> %s", num_attachments, ngettext (
- "Attachment", "Attachments", num_attachments));
- gtk_label_set_markup (label, markup);
- g_free (markup);
-
- activatable = GTK_ACTIVATABLE (bar->priv->save_all_button);
- action = gtk_activatable_get_related_action (activatable);
- gtk_action_set_visible (action, (num_attachments > 1));
-
- activatable = GTK_ACTIVATABLE (bar->priv->save_one_button);
- action = gtk_activatable_get_related_action (activatable);
- gtk_action_set_visible (action, (num_attachments == 1));
-
- g_free (display_size);
-}
-
-static void
-attachment_bar_set_store (EAttachmentBar *bar,
- EAttachmentStore *store)
-{
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
-
- bar->priv->model = g_object_ref (store);
-
- gtk_icon_view_set_model (
- GTK_ICON_VIEW (bar->priv->icon_view),
- bar->priv->model);
- gtk_tree_view_set_model (
- GTK_TREE_VIEW (bar->priv->tree_view),
- bar->priv->model);
-
- g_signal_connect_object (
- bar->priv->model, "notify::num-attachments",
- G_CALLBACK (attachment_bar_update_status), bar,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (
- bar->priv->model, "notify::total-size",
- G_CALLBACK (attachment_bar_update_status), bar,
- G_CONNECT_SWAPPED);
-
- /* Initialize */
- attachment_bar_update_status (bar);
-}
-
-static void
-attachment_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVE_VIEW:
- e_attachment_bar_set_active_view (
- E_ATTACHMENT_BAR (object),
- g_value_get_int (value));
- return;
-
- case PROP_DRAGGING:
- e_attachment_view_set_dragging (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EDITABLE:
- e_attachment_view_set_editable (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EXPANDED:
- e_attachment_bar_set_expanded (
- E_ATTACHMENT_BAR (object),
- g_value_get_boolean (value));
- return;
- case PROP_STORE:
- attachment_bar_set_store (
- E_ATTACHMENT_BAR (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVE_VIEW:
- g_value_set_int (
- value,
- e_attachment_bar_get_active_view (
- E_ATTACHMENT_BAR (object)));
- return;
-
- case PROP_DRAGGING:
- g_value_set_boolean (
- value,
- e_attachment_view_get_dragging (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EDITABLE:
- g_value_set_boolean (
- value,
- e_attachment_view_get_editable (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EXPANDED:
- g_value_set_boolean (
- value,
- e_attachment_bar_get_expanded (
- E_ATTACHMENT_BAR (object)));
- return;
- case PROP_STORE:
- g_value_set_object (
- value,
- e_attachment_bar_get_store (
- E_ATTACHMENT_BAR (object)));
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_bar_dispose (GObject *object)
-{
- EAttachmentBarPrivate *priv;
-
- priv = E_ATTACHMENT_BAR_GET_PRIVATE (object);
-
- if (priv->model != NULL) {
- g_object_unref (priv->model);
- priv->model = NULL;
- }
-
- if (priv->vbox != NULL) {
- g_object_unref (priv->vbox);
- priv->vbox = NULL;
- }
-
- if (priv->expander != NULL) {
- g_object_unref (priv->expander);
- priv->expander = NULL;
- }
-
- if (priv->combo_box != NULL) {
- g_object_unref (priv->combo_box);
- priv->combo_box = NULL;
- }
-
- if (priv->icon_view != NULL) {
- g_object_unref (priv->icon_view);
- priv->icon_view = NULL;
- }
-
- if (priv->tree_view != NULL) {
- g_object_unref (priv->tree_view);
- priv->tree_view = NULL;
- }
-
- if (priv->icon_frame != NULL) {
- g_object_unref (priv->icon_frame);
- priv->icon_frame = NULL;
- }
-
- if (priv->tree_frame != NULL) {
- g_object_unref (priv->tree_frame);
- priv->tree_frame = NULL;
- }
-
- if (priv->status_icon != NULL) {
- g_object_unref (priv->status_icon);
- priv->status_icon = NULL;
- }
-
- if (priv->status_label != NULL) {
- g_object_unref (priv->status_label);
- priv->status_label = NULL;
- }
-
- if (priv->save_all_button != NULL) {
- g_object_unref (priv->save_all_button);
- priv->save_all_button = NULL;
- }
-
- if (priv->save_one_button != NULL) {
- g_object_unref (priv->save_one_button);
- priv->save_one_button = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_bar_parent_class)->dispose (object);
-}
-
-static void
-attachment_bar_constructed (GObject *object)
-{
- EAttachmentBarPrivate *priv;
- GSettings *settings;
-
- priv = E_ATTACHMENT_BAR_GET_PRIVATE (object);
-
- /* Set up property-to-property bindings. */
-
- g_object_bind_property (
- object, "active-view",
- priv->combo_box, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "dragging",
- priv->icon_view, "dragging",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "dragging",
- priv->tree_view, "dragging",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "editable",
- priv->icon_view, "editable",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "editable",
- priv->tree_view, "editable",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->expander, "expanded",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->combo_box, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->vbox, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Set up property-to-GSettings bindings. */
- settings = g_settings_new ("org.gnome.evolution.shell");
- g_settings_bind (
- settings, "attachment-view",
- object, "active-view",
- G_SETTINGS_BIND_DEFAULT);
- g_object_unref (settings);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_attachment_bar_parent_class)->constructed (object);
-}
-
-static EAttachmentViewPrivate *
-attachment_bar_get_private (EAttachmentView *view)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- return e_attachment_view_get_private (view);
-}
-
-static GtkTreePath *
-attachment_bar_get_path_at_pos (EAttachmentView *view,
- gint x,
- gint y)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- return e_attachment_view_get_path_at_pos (view, x, y);
-}
-
-static EAttachmentStore *
-attachment_bar_get_store (EAttachmentView *view)
-{
- return e_attachment_bar_get_store (E_ATTACHMENT_BAR (view));
-}
-
-static GList *
-attachment_bar_get_selected_paths (EAttachmentView *view)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- return e_attachment_view_get_selected_paths (view);
-}
-
-static gboolean
-attachment_bar_path_is_selected (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- return e_attachment_view_path_is_selected (view, path);
-}
-
-static void
-attachment_bar_select_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- e_attachment_view_select_path (view, path);
-}
-
-static void
-attachment_bar_unselect_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- e_attachment_view_unselect_path (view, path);
-}
-
-static void
-attachment_bar_select_all (EAttachmentView *view)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- e_attachment_view_select_all (view);
-}
-
-static void
-attachment_bar_unselect_all (EAttachmentView *view)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- e_attachment_view_unselect_all (view);
-}
-
-static void
-attachment_bar_update_actions (EAttachmentView *view)
-{
- EAttachmentBar *bar;
-
- bar = E_ATTACHMENT_BAR (view);
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- e_attachment_view_update_actions (view);
-}
-
-static void
-e_attachment_bar_class_init (EAttachmentBarClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentBarPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_bar_set_property;
- object_class->get_property = attachment_bar_get_property;
- object_class->dispose = attachment_bar_dispose;
- object_class->constructed = attachment_bar_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTIVE_VIEW,
- g_param_spec_int (
- "active-view",
- "Active View",
- NULL,
- 0,
- NUM_VIEWS,
- 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_EXPANDED,
- g_param_spec_boolean (
- "expanded",
- "Expanded",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_STORE,
- g_param_spec_object (
- "store",
- "Attachment Store",
- NULL,
- E_TYPE_ATTACHMENT_STORE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_override_property (
- object_class, PROP_DRAGGING, "dragging");
-
- g_object_class_override_property (
- object_class, PROP_EDITABLE, "editable");
-}
-
-static void
-e_attachment_bar_interface_init (EAttachmentViewInterface *interface)
-{
- interface->get_private = attachment_bar_get_private;
- interface->get_store = attachment_bar_get_store;
- interface->get_path_at_pos = attachment_bar_get_path_at_pos;
- interface->get_selected_paths = attachment_bar_get_selected_paths;
- interface->path_is_selected = attachment_bar_path_is_selected;
- interface->select_path = attachment_bar_select_path;
- interface->unselect_path = attachment_bar_unselect_path;
- interface->select_all = attachment_bar_select_all;
- interface->unselect_all = attachment_bar_unselect_all;
- interface->update_actions = attachment_bar_update_actions;
-}
-
-static void
-e_attachment_bar_init (EAttachmentBar *bar)
-{
- EAttachmentView *view;
- GtkSizeGroup *size_group;
- GtkWidget *container;
- GtkWidget *widget;
- GtkAction *action;
-
- bar->priv = E_ATTACHMENT_BAR_GET_PRIVATE (bar);
-
- gtk_box_set_spacing (GTK_BOX (bar), 6);
-
- /* Keep the expander label and save button the same height. */
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- /* Construct the Attachment Views */
-
- container = GTK_WIDGET (bar);
-
- widget = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->vbox = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = bar->priv->vbox;
-
- widget = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- bar->priv->icon_frame = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_attachment_icon_view_new ();
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_icon_view_set_model (GTK_ICON_VIEW (widget), bar->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- bar->priv->icon_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = bar->priv->vbox;
-
- widget = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- bar->priv->tree_frame = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- container = widget;
-
- widget = e_attachment_tree_view_new ();
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget), bar->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- bar->priv->tree_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* Construct the Controls */
-
- container = GTK_WIDGET (bar);
-
- widget = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_expander_new (NULL);
- gtk_expander_set_spacing (GTK_EXPANDER (widget), 0);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->expander = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* The "Save All" button proxies the "save-all" action from
- * one of the two attachment views. Doesn't matter which. */
- widget = gtk_button_new ();
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
- action = e_attachment_view_get_action (view, "save-all");
- gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new ());
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->save_all_button = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* Same deal with the "Save" button. */
- widget = gtk_button_new ();
- view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
- action = e_attachment_view_get_action (view, "save-one");
- gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new ());
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->save_one_button = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_combo_box_text_new ();
- gtk_size_group_add_widget (size_group, widget);
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("Icon View"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("List View"));
- gtk_container_add (GTK_CONTAINER (container), widget);
- bar->priv->combo_box = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = bar->priv->expander;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_size_group_add_widget (size_group, widget);
- gtk_expander_set_label_widget (GTK_EXPANDER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_icon_name (
- "mail-attachment", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->status_icon = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (NULL);
- gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->status_label = g_object_ref (widget);
- gtk_widget_show (widget);
-
- g_object_unref (size_group);
-}
-
-GtkWidget *
-e_attachment_bar_new (EAttachmentStore *store)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
-
- return g_object_new (
- E_TYPE_ATTACHMENT_BAR,
- "editable", FALSE,
- "store", store, NULL);
-}
-
-gint
-e_attachment_bar_get_active_view (EAttachmentBar *bar)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), 0);
-
- return bar->priv->active_view;
-}
-
-void
-e_attachment_bar_set_active_view (EAttachmentBar *bar,
- gint active_view)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
- g_return_if_fail (active_view >= 0 && active_view < NUM_VIEWS);
-
- if (active_view == bar->priv->active_view)
- return;
-
- bar->priv->active_view = active_view;
-
- if (active_view == 0) {
- gtk_widget_show (bar->priv->icon_frame);
- gtk_widget_hide (bar->priv->tree_frame);
- } else {
- gtk_widget_hide (bar->priv->icon_frame);
- gtk_widget_show (bar->priv->tree_frame);
- }
-
- /* Synchronize the item selection of the view we're
- * switching TO with the view we're switching FROM. */
- if (active_view == 0) {
- /* from tree view to icon view */
- source = E_ATTACHMENT_VIEW (bar->priv->tree_view);
- target = E_ATTACHMENT_VIEW (bar->priv->icon_view);
- } else {
- /* from icon view to tree view */
- source = E_ATTACHMENT_VIEW (bar->priv->icon_view);
- target = E_ATTACHMENT_VIEW (bar->priv->tree_view);
- }
-
- e_attachment_view_sync_selection (source, target);
-
- g_object_notify (G_OBJECT (bar), "active-view");
-}
-
-gboolean
-e_attachment_bar_get_expanded (EAttachmentBar *bar)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), FALSE);
-
- return bar->priv->expanded;
-}
-
-void
-e_attachment_bar_set_expanded (EAttachmentBar *bar,
- gboolean expanded)
-{
- g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
- if (bar->priv->expanded == expanded)
- return;
-
- bar->priv->expanded = expanded;
-
- g_object_notify (G_OBJECT (bar), "expanded");
-}
-
-EAttachmentStore *
-e_attachment_bar_get_store (EAttachmentBar *bar)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
- return E_ATTACHMENT_STORE (bar->priv->model);
-}
diff --git a/widgets/misc/e-attachment-bar.h b/widgets/misc/e-attachment-bar.h
deleted file mode 100644
index 3542f217df..0000000000
--- a/widgets/misc/e-attachment-bar.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * e-attachment-bar.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_BAR_H
-#define E_ATTACHMENT_BAR_H
-
-#include <gtk/gtk.h>
-#include <misc/e-attachment-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_BAR \
- (e_attachment_bar_get_type ())
-#define E_ATTACHMENT_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_BAR, EAttachmentBar))
-#define E_ATTACHMENT_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_BAR, EAttachmentBarClass))
-#define E_IS_ATTACHMENT_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_BAR))
-#define E_IS_ATTACHMENT_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_BAR))
-#define E_ATTACHMENT_BAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_BAR, EAttachmentBarClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentBar EAttachmentBar;
-typedef struct _EAttachmentBarClass EAttachmentBarClass;
-typedef struct _EAttachmentBarPrivate EAttachmentBarPrivate;
-
-struct _EAttachmentBar {
- GtkBox parent;
- EAttachmentBarPrivate *priv;
-};
-
-struct _EAttachmentBarClass {
- GtkBoxClass parent_class;
-};
-
-GType e_attachment_bar_get_type (void);
-GtkWidget * e_attachment_bar_new (EAttachmentStore *store);
-gint e_attachment_bar_get_active_view
- (EAttachmentBar *bar);
-void e_attachment_bar_set_active_view
- (EAttachmentBar *bar,
- gint active_view);
-gboolean e_attachment_bar_get_expanded
- (EAttachmentBar *bar);
-void e_attachment_bar_set_expanded
- (EAttachmentBar *bar,
- gboolean expanded);
-EAttachmentStore *
- e_attachment_bar_get_store (EAttachmentBar *bar);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_BAR_H */
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
deleted file mode 100644
index a2057e3354..0000000000
--- a/widgets/misc/e-attachment-button.c
+++ /dev/null
@@ -1,868 +0,0 @@
-/*
- * e-attachment-button.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* Much of the popup menu logic here was ripped from GtkMenuToolButton. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-button.h"
-
-#define E_ATTACHMENT_BUTTON_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButtonPrivate))
-
-struct _EAttachmentButtonPrivate {
-
- EAttachmentView *view;
- EAttachment *attachment;
- gulong reference_handler_id;
-
- GBinding *can_show_binding;
- GBinding *shown_binding;
-
- GtkWidget *expand_button;
- GtkWidget *toggle_button;
- GtkWidget *cell_view;
- GtkWidget *popup_menu;
-
- guint expandable : 1;
- guint expanded : 1;
-};
-
-enum {
- PROP_0,
- PROP_ATTACHMENT,
- PROP_EXPANDABLE,
- PROP_EXPANDED,
- PROP_VIEW
-};
-
-G_DEFINE_TYPE (
- EAttachmentButton,
- e_attachment_button,
- GTK_TYPE_HBOX)
-
-static void
-attachment_button_menu_deactivate_cb (EAttachmentButton *button)
-{
- EAttachmentView *view;
- GtkActionGroup *action_group;
- GtkToggleButton *toggle_button;
-
- view = e_attachment_button_get_view (button);
- action_group = e_attachment_view_get_action_group (view, "inline");
- toggle_button = GTK_TOGGLE_BUTTON (button->priv->toggle_button);
-
- gtk_toggle_button_set_active (toggle_button, FALSE);
-
- gtk_action_group_set_visible (action_group, FALSE);
-}
-
-static void
-attachment_button_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- EAttachmentButton *button)
-{
- GtkRequisition menu_requisition;
- GtkTextDirection direction;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkScreen *screen;
- GdkWindow *window;
- GtkWidget *widget;
- GtkWidget *toggle_button;
- gint monitor_num;
-
- widget = GTK_WIDGET (button);
- toggle_button = button->priv->toggle_button;
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
-
- window = gtk_widget_get_parent_window (widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gdk_window_get_origin (window, x, y);
- *x += allocation.x;
- *y += allocation.y;
-
- direction = gtk_widget_get_direction (widget);
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_requisition.width, 0);
- else if (menu_requisition.width > allocation.width)
- *x -= menu_requisition.width - allocation.width;
-
- gtk_widget_get_allocation (toggle_button, &allocation);
-
- if ((*y + allocation.height +
- menu_requisition.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_requisition.height) >= monitor.y)
- *y -= menu_requisition.height;
- else if (monitor.y + monitor.height -
- (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_requisition.height;
-
- *push_in = FALSE;
-}
-
-static void
-attachment_button_select_path (EAttachmentButton *button)
-{
- EAttachmentView *view;
- EAttachment *attachment;
- GtkTreeRowReference *reference;
- GtkTreePath *path;
-
- attachment = e_attachment_button_get_attachment (button);
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- reference = e_attachment_get_reference (attachment);
- g_return_if_fail (gtk_tree_row_reference_valid (reference));
-
- view = e_attachment_button_get_view (button);
- path = gtk_tree_row_reference_get_path (reference);
-
- e_attachment_view_unselect_all (view);
- e_attachment_view_select_path (view, path);
-
- gtk_tree_path_free (path);
-}
-
-static void
-attachment_button_show_popup_menu (EAttachmentButton *button,
- GdkEventButton *event)
-{
- EAttachmentView *view;
- GtkActionGroup *action_group;
- GtkToggleButton *toggle_button;
-
- view = e_attachment_button_get_view (button);
- action_group = e_attachment_view_get_action_group (view, "inline");
- toggle_button = GTK_TOGGLE_BUTTON (button->priv->toggle_button);
-
- attachment_button_select_path (button);
- gtk_toggle_button_set_active (toggle_button, TRUE);
-
- e_attachment_view_show_popup_menu (
- view, event, (GtkMenuPositionFunc)
- attachment_button_menu_position, button);
-
- gtk_action_group_set_visible (action_group, TRUE);
-}
-
-static void
-attachment_button_update_cell_view (EAttachmentButton *button)
-{
- GtkCellView *cell_view;
- EAttachment *attachment;
- GtkTreeRowReference *reference;
- GtkTreeModel *model = NULL;
- GtkTreePath *path = NULL;
-
- cell_view = GTK_CELL_VIEW (button->priv->cell_view);
-
- attachment = e_attachment_button_get_attachment (button);
- if (attachment == NULL)
- goto exit;
-
- reference = e_attachment_get_reference (attachment);
- if (reference == NULL)
- goto exit;
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
-
-exit:
- gtk_cell_view_set_model (cell_view, model);
- gtk_cell_view_set_displayed_row (cell_view, path);
-
- if (path != NULL)
- gtk_tree_path_free (path);
-}
-
-static void
-attachment_button_update_pixbufs (EAttachmentButton *button)
-{
- GtkCellLayout *cell_layout;
- GtkCellRenderer *renderer;
- GdkPixbuf *pixbuf_expander_open;
- GdkPixbuf *pixbuf_expander_closed;
- GList *list;
-
- /* Grab the first cell renderer. */
- cell_layout = GTK_CELL_LAYOUT (button->priv->cell_view);
- list = gtk_cell_layout_get_cells (cell_layout);
- renderer = GTK_CELL_RENDERER (list->data);
- g_list_free (list);
-
- pixbuf_expander_open = gtk_widget_render_icon (
- GTK_WIDGET (button), GTK_STOCK_GO_DOWN,
- GTK_ICON_SIZE_BUTTON, NULL);
-
- pixbuf_expander_closed = gtk_widget_render_icon (
- GTK_WIDGET (button), GTK_STOCK_GO_FORWARD,
- GTK_ICON_SIZE_BUTTON, NULL);
-
- g_object_set (
- renderer,
- "pixbuf-expander-open", pixbuf_expander_open,
- "pixbuf-expander-closed", pixbuf_expander_closed,
- NULL);
-
- g_object_unref (pixbuf_expander_open);
- g_object_unref (pixbuf_expander_closed);
-}
-
-static void
-attachment_button_expand_clicked_cb (EAttachmentButton *button)
-{
- gboolean expanded;
-
- expanded = e_attachment_button_get_expanded (button);
- e_attachment_button_set_expanded (button, !expanded);
-}
-
-static void
-attachment_button_expand_drag_begin_cb (EAttachmentButton *button,
- GdkDragContext *context)
-{
- EAttachmentView *view;
-
- view = e_attachment_button_get_view (button);
-
- attachment_button_select_path (button);
- e_attachment_view_drag_begin (view, context);
-}
-
-static void
-attachment_button_expand_drag_data_get_cb (EAttachmentButton *button,
- GdkDragContext *context,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentView *view;
-
- if (button->priv->attachment) {
- gchar *mime_type;
-
- mime_type = e_attachment_get_mime_type (
- button->priv->attachment);
-
- if (mime_type) {
- gboolean processed = FALSE;
- GdkAtom atom;
- gchar *atom_name;
-
- atom = gtk_selection_data_get_target (selection);
- atom_name = gdk_atom_name (atom);
-
- if (g_strcmp0 (atom_name, mime_type) == 0) {
- CamelMimePart *mime_part;
-
- mime_part = e_attachment_get_mime_part (
- button->priv->attachment);
-
- if (CAMEL_IS_MIME_PART (mime_part)) {
- CamelDataWrapper *wrapper;
- CamelStream *stream;
- GByteArray *buffer;
-
- buffer = g_byte_array_new ();
- stream = camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (
- CAMEL_STREAM_MEM (stream),
- buffer);
- wrapper = camel_medium_get_content (
- CAMEL_MEDIUM (mime_part));
- camel_data_wrapper_decode_to_stream_sync (
- wrapper, stream, NULL, NULL);
- g_object_unref (stream);
-
- gtk_selection_data_set (
- selection, atom, 8,
- buffer->data, buffer->len);
- processed = TRUE;
-
- g_byte_array_free (buffer, TRUE);
- }
- }
-
- g_free (atom_name);
- g_free (mime_type);
-
- if (processed)
- return;
- }
- }
-
- view = e_attachment_button_get_view (button);
-
- e_attachment_view_drag_data_get (
- view, context, selection, info, time);
-}
-
-static void
-attachment_button_expand_drag_end_cb (EAttachmentButton *button,
- GdkDragContext *context)
-{
- EAttachmentView *view;
-
- view = e_attachment_button_get_view (button);
-
- e_attachment_view_drag_end (view, context);
-}
-
-static gboolean
-attachment_button_toggle_button_press_event_cb (EAttachmentButton *button,
- GdkEventButton *event)
-{
- if (event->button == 1) {
- attachment_button_show_popup_menu (button, event);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-attachment_button_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ATTACHMENT:
- e_attachment_button_set_attachment (
- E_ATTACHMENT_BUTTON (object),
- g_value_get_object (value));
- return;
-
- case PROP_EXPANDABLE:
- e_attachment_button_set_expandable (
- E_ATTACHMENT_BUTTON (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EXPANDED:
- e_attachment_button_set_expanded (
- E_ATTACHMENT_BUTTON (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_VIEW:
- e_attachment_button_set_view (
- E_ATTACHMENT_BUTTON (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_button_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ATTACHMENT:
- g_value_set_object (
- value,
- e_attachment_button_get_attachment (
- E_ATTACHMENT_BUTTON (object)));
- return;
-
- case PROP_EXPANDABLE:
- g_value_set_boolean (
- value,
- e_attachment_button_get_expandable (
- E_ATTACHMENT_BUTTON (object)));
- return;
-
- case PROP_EXPANDED:
- g_value_set_boolean (
- value,
- e_attachment_button_get_expanded (
- E_ATTACHMENT_BUTTON (object)));
- return;
-
- case PROP_VIEW:
- g_value_set_object (
- value,
- e_attachment_button_get_view (
- E_ATTACHMENT_BUTTON (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_button_dispose (GObject *object)
-{
- EAttachmentButtonPrivate *priv;
-
- priv = E_ATTACHMENT_BUTTON_GET_PRIVATE (object);
-
- if (priv->view != NULL) {
- g_object_unref (priv->view);
- priv->view = NULL;
- }
-
- if (priv->attachment != NULL) {
- g_signal_handler_disconnect (
- priv->attachment,
- priv->reference_handler_id);
- g_object_unref (priv->attachment);
- priv->attachment = NULL;
- }
-
- if (priv->expand_button != NULL) {
- g_object_unref (priv->expand_button);
- priv->expand_button = NULL;
- }
-
- if (priv->toggle_button != NULL) {
- g_object_unref (priv->toggle_button);
- priv->toggle_button = NULL;
- }
-
- if (priv->cell_view != NULL) {
- g_object_unref (priv->cell_view);
- priv->cell_view = NULL;
- }
-
- if (priv->popup_menu != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->popup_menu, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->popup_menu);
- priv->popup_menu = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_button_parent_class)->dispose (object);
-}
-
-static void
-attachment_button_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- EAttachmentButton *button;
-
- /* Chain up to parent's style_set() method. */
- GTK_WIDGET_CLASS (e_attachment_button_parent_class)->
- style_set (widget, previous_style);
-
- button = E_ATTACHMENT_BUTTON (widget);
- attachment_button_update_pixbufs (button);
-}
-
-static void
-e_attachment_button_class_init (EAttachmentButtonClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentButtonPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_button_set_property;
- object_class->get_property = attachment_button_get_property;
- object_class->dispose = attachment_button_dispose;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->style_set = attachment_button_style_set;
-
- g_object_class_install_property (
- object_class,
- PROP_ATTACHMENT,
- g_param_spec_object (
- "attachment",
- "Attachment",
- NULL,
- E_TYPE_ATTACHMENT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_EXPANDABLE,
- g_param_spec_boolean (
- "expandable",
- "Expandable",
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_EXPANDED,
- g_param_spec_boolean (
- "expanded",
- "Expanded",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_VIEW,
- g_param_spec_object (
- "view",
- "View",
- NULL,
- E_TYPE_ATTACHMENT_VIEW,
- G_PARAM_READWRITE));
-}
-
-static void
-e_attachment_button_init (EAttachmentButton *button)
-{
- GtkCellRenderer *renderer;
- GtkCellLayout *cell_layout;
- GtkTargetEntry *targets;
- GtkTargetList *list;
- GtkWidget *container;
- GtkWidget *widget;
- GtkStyleContext *context;
- gint n_targets;
-
- button->priv = E_ATTACHMENT_BUTTON_GET_PRIVATE (button);
-
- /* Configure Widgets */
-
- container = GTK_WIDGET (button);
- context = gtk_widget_get_style_context (container);
- gtk_style_context_add_class (context, "linked");
-
- widget = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- button->priv->expand_button = g_object_ref (widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- button, "expandable",
- widget, "sensitive",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- widget = gtk_toggle_button_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- button->priv->toggle_button = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = button->priv->expand_button;
-
- widget = gtk_cell_view_new ();
- gtk_container_add (GTK_CONTAINER (container), widget);
- button->priv->cell_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = button->priv->toggle_button;
-
- widget = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- /* Configure Renderers */
-
- cell_layout = GTK_CELL_LAYOUT (button->priv->cell_view);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer, "is-expander", TRUE, NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
-
- g_object_bind_property (
- button, "expanded",
- renderer, "is-expanded",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "gicon",
- E_ATTACHMENT_STORE_COLUMN_ICON);
-
- /* Configure Drag and Drop */
-
- list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (list, 0);
- targets = gtk_target_table_new_from_list (list, &n_targets);
-
- gtk_drag_source_set (
- button->priv->expand_button, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_drag_source_set (
- button->priv->toggle_button, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (list);
-
- /* Configure Signal Handlers */
-
- g_signal_connect_swapped (
- button->priv->expand_button, "clicked",
- G_CALLBACK (attachment_button_expand_clicked_cb), button);
-
- g_signal_connect_swapped (
- button->priv->expand_button, "drag-begin",
- G_CALLBACK (attachment_button_expand_drag_begin_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->expand_button, "drag-data-get",
- G_CALLBACK (attachment_button_expand_drag_data_get_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->expand_button, "drag-end",
- G_CALLBACK (attachment_button_expand_drag_end_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->toggle_button, "button-press-event",
- G_CALLBACK (attachment_button_toggle_button_press_event_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->toggle_button, "drag-begin",
- G_CALLBACK (attachment_button_expand_drag_begin_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->toggle_button, "drag-data-get",
- G_CALLBACK (attachment_button_expand_drag_data_get_cb),
- button);
-
- g_signal_connect_swapped (
- button->priv->toggle_button, "drag-end",
- G_CALLBACK (attachment_button_expand_drag_end_cb),
- button);
-}
-
-GtkWidget *
-e_attachment_button_new ()
-{
- return g_object_new (
- E_TYPE_ATTACHMENT_BUTTON, NULL);
-}
-
-EAttachmentView *
-e_attachment_button_get_view (EAttachmentButton *button)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BUTTON (button), NULL);
-
- return button->priv->view;
-}
-
-void
-e_attachment_button_set_view (EAttachmentButton *button,
- EAttachmentView *view)
-{
- GtkWidget *popup_menu;
-
- g_return_if_fail (button->priv->view == NULL);
-
- g_object_ref (view);
- if (button->priv->view)
- g_object_unref (button->priv->view);
- button->priv->view = view;
-
- popup_menu = e_attachment_view_get_popup_menu (view);
-
- g_signal_connect_swapped (
- popup_menu, "deactivate",
- G_CALLBACK (attachment_button_menu_deactivate_cb), button);
-
- /* Keep a reference to the popup menu so we can
- * disconnect the signal handler in dispose(). */
- if (button->priv->popup_menu)
- g_object_unref (button->priv->popup_menu);
- button->priv->popup_menu = g_object_ref (popup_menu);
-}
-
-EAttachment *
-e_attachment_button_get_attachment (EAttachmentButton *button)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BUTTON (button), NULL);
-
- return button->priv->attachment;
-}
-
-void
-e_attachment_button_set_attachment (EAttachmentButton *button,
- EAttachment *attachment)
-{
- GtkTargetEntry *targets;
- GtkTargetList *list;
- gint n_targets;
-
- g_return_if_fail (E_IS_ATTACHMENT_BUTTON (button));
-
- if (attachment != NULL) {
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_object_ref (attachment);
- }
-
- if (button->priv->attachment != NULL) {
- g_object_unref (button->priv->can_show_binding);
- button->priv->can_show_binding = NULL;
- g_object_unref (button->priv->shown_binding);
- button->priv->shown_binding = NULL;
- g_signal_handler_disconnect (
- button->priv->attachment,
- button->priv->reference_handler_id);
- g_object_unref (button->priv->attachment);
- }
-
- button->priv->attachment = attachment;
-
- if (attachment != NULL) {
- GBinding *binding;
- gulong handler_id;
-
- binding = g_object_bind_property (
- attachment, "can-show",
- button, "expandable",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
- button->priv->can_show_binding = binding;
-
- binding = g_object_bind_property (
- attachment, "shown",
- button, "expanded",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
- button->priv->shown_binding = binding;
-
- handler_id = g_signal_connect_swapped (
- attachment, "notify::reference",
- G_CALLBACK (attachment_button_update_cell_view),
- button);
- button->priv->reference_handler_id = handler_id;
-
- attachment_button_update_cell_view (button);
- attachment_button_update_pixbufs (button);
- }
-
- /* update drag sources */
- list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (list, 0);
-
- if (attachment) {
- gchar *simple_type;
-
- simple_type = e_attachment_get_mime_type (attachment);
- if (simple_type) {
- GtkTargetEntry attach_entry[] = { { NULL, 0, 2 } };
-
- attach_entry[0].target = simple_type;
-
- gtk_target_list_add_table (
- list, attach_entry,
- G_N_ELEMENTS (attach_entry));
-
- g_free (simple_type);
- }
- }
-
- targets = gtk_target_table_new_from_list (list, &n_targets);
-
- gtk_drag_source_set (
- button->priv->expand_button, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_drag_source_set (
- button->priv->toggle_button, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (list);
-
- g_object_notify (G_OBJECT (button), "attachment");
-}
-
-gboolean
-e_attachment_button_get_expandable (EAttachmentButton *button)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BUTTON (button), FALSE);
-
- return button->priv->expandable;
-}
-
-void
-e_attachment_button_set_expandable (EAttachmentButton *button,
- gboolean expandable)
-{
- g_return_if_fail (E_IS_ATTACHMENT_BUTTON (button));
-
- if (button->priv->expandable == expandable)
- return;
-
- button->priv->expandable = expandable;
-
- if (!expandable)
- e_attachment_button_set_expanded (button, FALSE);
-
- g_object_notify (G_OBJECT (button), "expandable");
-}
-
-gboolean
-e_attachment_button_get_expanded (EAttachmentButton *button)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_BUTTON (button), FALSE);
-
- return button->priv->expanded;
-}
-
-void
-e_attachment_button_set_expanded (EAttachmentButton *button,
- gboolean expanded)
-{
- g_return_if_fail (E_IS_ATTACHMENT_BUTTON (button));
-
- if (button->priv->expanded == expanded)
- return;
-
- button->priv->expanded = expanded;
-
- g_object_notify (G_OBJECT (button), "expanded");
-}
diff --git a/widgets/misc/e-attachment-button.h b/widgets/misc/e-attachment-button.h
deleted file mode 100644
index 56adf704f0..0000000000
--- a/widgets/misc/e-attachment-button.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * e-attachment-button.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_BUTTON_H
-#define E_ATTACHMENT_BUTTON_H
-
-#include <gtk/gtk.h>
-#include <misc/e-attachment.h>
-#include <misc/e-attachment-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_BUTTON \
- (e_attachment_button_get_type ())
-#define E_ATTACHMENT_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButton))
-#define E_ATTACHMENT_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButtonClass))
-#define E_IS_ATTACHMENT_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_BUTTON))
-#define E_IS_ATTACHMENT_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_BUTTON))
-#define E_ATTACHMENT_BUTTON_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButtonClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentButton EAttachmentButton;
-typedef struct _EAttachmentButtonClass EAttachmentButtonClass;
-typedef struct _EAttachmentButtonPrivate EAttachmentButtonPrivate;
-
-struct _EAttachmentButton {
- GtkBox parent;
- EAttachmentButtonPrivate *priv;
-};
-
-struct _EAttachmentButtonClass {
- GtkBoxClass parent_class;
-};
-
-GType e_attachment_button_get_type (void);
-GtkWidget * e_attachment_button_new (void);
-EAttachmentView *
- e_attachment_button_get_view (EAttachmentButton *button);
-void e_attachment_button_set_view (EAttachmentButton *button,
- EAttachmentView *view);
-EAttachment * e_attachment_button_get_attachment
- (EAttachmentButton *button);
-void e_attachment_button_set_attachment
- (EAttachmentButton *button,
- EAttachment *attachment);
-gboolean e_attachment_button_get_expandable
- (EAttachmentButton *button);
-void e_attachment_button_set_expandable
- (EAttachmentButton *button,
- gboolean expandable);
-gboolean e_attachment_button_get_expanded
- (EAttachmentButton *button);
-void e_attachment_button_set_expanded
- (EAttachmentButton *button,
- gboolean expanded);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_BUTTON_H */
diff --git a/widgets/misc/e-attachment-dialog.c b/widgets/misc/e-attachment-dialog.c
deleted file mode 100644
index 9a9a1e7942..0000000000
--- a/widgets/misc/e-attachment-dialog.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * e-attachment-dialog.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-dialog.h"
-
-#include <glib/gi18n.h>
-
-#define E_ATTACHMENT_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_DIALOG, EAttachmentDialogPrivate))
-
-struct _EAttachmentDialogPrivate {
- EAttachment *attachment;
- GtkWidget *display_name_entry;
- GtkWidget *description_entry;
- GtkWidget *content_type_label;
- GtkWidget *disposition_checkbox;
-};
-
-enum {
- PROP_0,
- PROP_ATTACHMENT
-};
-
-G_DEFINE_TYPE (
- EAttachmentDialog,
- e_attachment_dialog,
- GTK_TYPE_DIALOG)
-
-static void
-attachment_dialog_update (EAttachmentDialog *dialog)
-{
- EAttachment *attachment;
- GFileInfo *file_info;
- GtkWidget *widget;
- const gchar *content_type;
- const gchar *display_name;
- const gchar *description;
- const gchar *disposition;
- gchar *type_description = NULL;
- gboolean sensitive;
- gboolean active;
-
- attachment = e_attachment_dialog_get_attachment (dialog);
-
- if (attachment != NULL) {
- file_info = e_attachment_get_file_info (attachment);
- description = e_attachment_get_description (attachment);
- disposition = e_attachment_get_disposition (attachment);
- } else {
- file_info = NULL;
- description = NULL;
- disposition = NULL;
- }
-
- if (file_info != NULL) {
- content_type = g_file_info_get_content_type (file_info);
- display_name = g_file_info_get_display_name (file_info);
- } else {
- content_type = NULL;
- display_name = NULL;
- }
-
- if (content_type != NULL) {
- gchar *comment;
- gchar *mime_type;
-
- comment = g_content_type_get_description (content_type);
- mime_type = g_content_type_get_mime_type (content_type);
-
- type_description =
- g_strdup_printf ("%s (%s)", comment, mime_type);
-
- g_free (comment);
- g_free (mime_type);
- }
-
- sensitive = G_IS_FILE_INFO (file_info);
-
- gtk_dialog_set_response_sensitive (
- GTK_DIALOG (dialog), GTK_RESPONSE_OK, sensitive);
-
- widget = dialog->priv->display_name_entry;
- gtk_widget_set_sensitive (widget, sensitive);
- if (display_name != NULL)
- gtk_entry_set_text (GTK_ENTRY (widget), display_name);
-
- widget = dialog->priv->description_entry;
- gtk_widget_set_sensitive (widget, sensitive);
- if (description != NULL)
- gtk_entry_set_text (GTK_ENTRY (widget), description);
-
- widget = dialog->priv->content_type_label;
- gtk_label_set_text (GTK_LABEL (widget), type_description);
-
- active = (g_strcmp0 (disposition, "inline") == 0);
- widget = dialog->priv->disposition_checkbox;
- gtk_widget_set_sensitive (widget, sensitive);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), active);
-
- g_free (type_description);
-}
-
-static void
-attachment_dialog_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ATTACHMENT:
- e_attachment_dialog_set_attachment (
- E_ATTACHMENT_DIALOG (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_dialog_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ATTACHMENT:
- g_value_set_object (
- value, e_attachment_dialog_get_attachment (
- E_ATTACHMENT_DIALOG (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_dialog_dispose (GObject *object)
-{
- EAttachmentDialogPrivate *priv;
-
- priv = E_ATTACHMENT_DIALOG_GET_PRIVATE (object);
-
- if (priv->attachment != NULL) {
- g_object_unref (priv->attachment);
- priv->attachment = NULL;
- }
-
- if (priv->display_name_entry != NULL) {
- g_object_unref (priv->display_name_entry);
- priv->display_name_entry = NULL;
- }
-
- if (priv->description_entry != NULL) {
- g_object_unref (priv->description_entry);
- priv->description_entry = NULL;
- }
-
- if (priv->content_type_label != NULL) {
- g_object_unref (priv->content_type_label);
- priv->content_type_label = NULL;
- }
-
- if (priv->disposition_checkbox != NULL) {
- g_object_unref (priv->disposition_checkbox);
- priv->disposition_checkbox = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_dialog_parent_class)->dispose (object);
-}
-
-static void
-attachment_dialog_map (GtkWidget *widget)
-{
- GtkWidget *action_area;
- GtkWidget *content_area;
-
- /* Chain up to parent's map() method. */
- GTK_WIDGET_CLASS (e_attachment_dialog_parent_class)->map (widget);
-
- /* XXX Override GtkDialog's broken style property defaults. */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (widget));
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (widget));
-
- gtk_box_set_spacing (GTK_BOX (content_area), 12);
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 0);
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
-}
-
-static void
-attachment_dialog_response (GtkDialog *dialog,
- gint response_id)
-{
- EAttachmentDialogPrivate *priv;
- EAttachment *attachment;
- GtkToggleButton *button;
- GFileInfo *file_info;
- CamelMimePart *mime_part;
- const gchar *attribute;
- const gchar *text;
- gboolean active;
-
- if (response_id != GTK_RESPONSE_OK)
- return;
-
- priv = E_ATTACHMENT_DIALOG_GET_PRIVATE (dialog);
- g_return_if_fail (E_IS_ATTACHMENT (priv->attachment));
- attachment = priv->attachment;
-
- file_info = e_attachment_get_file_info (attachment);
- g_return_if_fail (G_IS_FILE_INFO (file_info));
-
- mime_part = e_attachment_get_mime_part (attachment);
-
- attribute = G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME;
- text = gtk_entry_get_text (GTK_ENTRY (priv->display_name_entry));
- g_file_info_set_attribute_string (file_info, attribute, text);
-
- if (mime_part != NULL)
- camel_mime_part_set_filename (mime_part, text);
-
- attribute = G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION;
- text = gtk_entry_get_text (GTK_ENTRY (priv->description_entry));
- g_file_info_set_attribute_string (file_info, attribute, text);
-
- if (mime_part != NULL)
- camel_mime_part_set_description (mime_part, text);
-
- button = GTK_TOGGLE_BUTTON (priv->disposition_checkbox);
- active = gtk_toggle_button_get_active (button);
- text = active ? "inline" : "attachment";
- e_attachment_set_disposition (attachment, text);
-
- if (mime_part != NULL)
- camel_mime_part_set_disposition (mime_part, text);
-
- g_object_notify (G_OBJECT (attachment), "file-info");
-}
-
-static void
-e_attachment_dialog_class_init (EAttachmentDialogClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkDialogClass *dialog_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentDialogPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_dialog_set_property;
- object_class->get_property = attachment_dialog_get_property;
- object_class->dispose = attachment_dialog_dispose;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->map = attachment_dialog_map;
-
- dialog_class = GTK_DIALOG_CLASS (class);
- dialog_class->response = attachment_dialog_response;
-
- g_object_class_install_property (
- object_class,
- PROP_ATTACHMENT,
- g_param_spec_object (
- "attachment",
- "Attachment",
- NULL,
- E_TYPE_ATTACHMENT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_attachment_dialog_init (EAttachmentDialog *dialog)
-{
- GtkWidget *container;
- GtkWidget *widget;
-
- dialog->priv = E_ATTACHMENT_DIALOG_GET_PRIVATE (dialog);
-
- gtk_dialog_add_button (
- GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (
- GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK);
- gtk_window_set_icon_name (
- GTK_WINDOW (dialog), "mail-attachment");
- gtk_window_set_title (
- GTK_WINDOW (dialog), _("Attachment Properties"));
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- widget = gtk_table_new (4, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (widget), 6);
- gtk_table_set_row_spacings (GTK_TABLE (widget), 6);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->display_name_entry = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_label_new_with_mnemonic (_("F_ilename:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
- gtk_label_set_mnemonic_widget (
- GTK_LABEL (widget), dialog->priv->display_name_entry);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->description_entry = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_label_new_with_mnemonic (_("_Description:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
- gtk_label_set_mnemonic_widget (
- GTK_LABEL (widget), dialog->priv->description_entry);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->content_type_label = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (_("MIME Type:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_check_button_new_with_mnemonic (
- _("_Suggest automatic display of attachment"));
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->disposition_checkbox = g_object_ref (widget);
- gtk_widget_show (widget);
-}
-
-GtkWidget *
-e_attachment_dialog_new (GtkWindow *parent,
- EAttachment *attachment)
-{
- if (parent != NULL)
- g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
- if (attachment != NULL)
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return g_object_new (
- E_TYPE_ATTACHMENT_DIALOG,
- "transient-for", parent, "attachment", attachment, NULL);
-}
-
-EAttachment *
-e_attachment_dialog_get_attachment (EAttachmentDialog *dialog)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_DIALOG (dialog), NULL);
-
- return dialog->priv->attachment;
-}
-
-void
-e_attachment_dialog_set_attachment (EAttachmentDialog *dialog,
- EAttachment *attachment)
-{
- g_return_if_fail (E_IS_ATTACHMENT_DIALOG (dialog));
-
- if (attachment != NULL) {
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_object_ref (attachment);
- }
-
- if (dialog->priv->attachment != NULL)
- g_object_unref (dialog->priv->attachment);
-
- dialog->priv->attachment = attachment;
-
- attachment_dialog_update (dialog);
-
- g_object_notify (G_OBJECT (dialog), "attachment");
-}
diff --git a/widgets/misc/e-attachment-dialog.h b/widgets/misc/e-attachment-dialog.h
deleted file mode 100644
index 503dcbbc67..0000000000
--- a/widgets/misc/e-attachment-dialog.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * e-attachment-dialog.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_DIALOG_H
-#define E_ATTACHMENT_DIALOG_H
-
-#include <gtk/gtk.h>
-#include <misc/e-attachment.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_DIALOG \
- (e_attachment_dialog_get_type ())
-#define E_ATTACHMENT_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_DIALOG, EAttachmentDialog))
-#define E_ATTACHMENT_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_DIALOG, EAttachmentDialogClass))
-#define E_IS_ATTACHMENT_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_DIALOG))
-#define E_IS_ATTACHMENT_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_DIALOG))
-#define E_ATTACHMENT_DIALOG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_DIALOG, EAttachmentDialogClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentDialog EAttachmentDialog;
-typedef struct _EAttachmentDialogClass EAttachmentDialogClass;
-typedef struct _EAttachmentDialogPrivate EAttachmentDialogPrivate;
-
-struct _EAttachmentDialog {
- GtkDialog parent;
- EAttachmentDialogPrivate *priv;
-};
-
-struct _EAttachmentDialogClass {
- GtkDialogClass parent_class;
-};
-
-GType e_attachment_dialog_get_type (void);
-GtkWidget * e_attachment_dialog_new (GtkWindow *parent,
- EAttachment *attachment);
-EAttachment * e_attachment_dialog_get_attachment
- (EAttachmentDialog *dialog);
-void e_attachment_dialog_set_attachment
- (EAttachmentDialog *dialog,
- EAttachment *attachment);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_DIALOG_H */
diff --git a/widgets/misc/e-attachment-handler-image.c b/widgets/misc/e-attachment-handler-image.c
deleted file mode 100644
index a8c29f24c0..0000000000
--- a/widgets/misc/e-attachment-handler-image.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * e-attachment-handler-image.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-handler-image.h"
-
-#include <glib/gi18n.h>
-#include <gdesktop-enums.h>
-
-#include <e-util/e-util.h>
-
-#define E_ATTACHMENT_HANDLER_IMAGE_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_IMAGE, EAttachmentHandlerImagePrivate))
-
-struct _EAttachmentHandlerImagePrivate {
- gint placeholder;
-};
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <placeholder name='custom-actions'>"
-" <menuitem action='image-set-as-background'/>"
-" </placeholder>"
-" </popup>"
-"</ui>";
-
-G_DEFINE_TYPE (
- EAttachmentHandlerImage,
- e_attachment_handler_image,
- E_TYPE_ATTACHMENT_HANDLER)
-
-static void
-action_image_set_as_background_saved_cb (EAttachment *attachment,
- GAsyncResult *result,
- EAttachmentHandler *handler)
-{
- GDesktopBackgroundStyle style;
- EAttachmentView *view;
- GSettings *settings;
- GtkWidget *dialog;
- GFile *file;
- gpointer parent;
- gchar *uri;
- GError *error = NULL;
-
- view = e_attachment_handler_get_view (handler);
- settings = g_settings_new ("org.gnome.desktop.background");
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- if (error != NULL)
- goto error;
-
- uri = g_file_get_uri (file);
- g_settings_set_string (settings, "picture-uri", uri);
- g_free (uri);
-
- style = g_settings_get_enum (settings, "picture-options");
- if (style == G_DESKTOP_BACKGROUND_STYLE_NONE)
- g_settings_set_enum (
- settings, "picture-options",
- G_DESKTOP_BACKGROUND_STYLE_WALLPAPER);
-
- g_object_unref (file);
-
- goto exit;
-
-error:
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- dialog = gtk_message_dialog_new_with_markup (
- parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<big><b>%s</b></big>",
- _("Could not set as background"));
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_error_free (error);
-
-exit:
- g_object_unref (settings);
- g_object_unref (handler);
-}
-
-static void
-action_image_set_as_background_cb (GtkAction *action,
- EAttachmentHandler *handler)
-{
- EAttachmentView *view;
- EAttachment *attachment;
- GFile *destination;
- GList *selected;
- const gchar *path;
-
- view = e_attachment_handler_get_view (handler);
- selected = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (selected) == 1);
- attachment = E_ATTACHMENT (selected->data);
-
- /* Save the image under the user's Pictures directory. */
- path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
- destination = g_file_new_for_path (path);
- g_mkdir_with_parents (path, 0755);
-
- e_attachment_save_async (
- attachment, destination, (GAsyncReadyCallback)
- action_image_set_as_background_saved_cb,
- g_object_ref (handler));
-
- g_object_unref (destination);
-
- g_list_foreach (selected, (GFunc) g_object_unref, NULL);
- g_list_free (selected);
-}
-
-static GtkActionEntry standard_entries[] = {
-
- { "image-set-as-background",
- NULL,
- N_("Set as _Background"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_image_set_as_background_cb) }
-};
-
-static void
-attachment_handler_image_update_actions_cb (EAttachmentView *view,
- EAttachmentHandler *handler)
-{
- EAttachment *attachment;
- GFileInfo *file_info;
- GtkActionGroup *action_group;
- const gchar *content_type;
- gchar *mime_type;
- GList *selected;
- gboolean visible = FALSE;
-
- selected = e_attachment_view_get_selected_attachments (view);
-
- if (g_list_length (selected) != 1)
- goto exit;
-
- attachment = E_ATTACHMENT (selected->data);
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info == NULL)
- goto exit;
-
- if (e_attachment_get_loading (attachment))
- goto exit;
-
- if (e_attachment_get_saving (attachment))
- goto exit;
-
- content_type = g_file_info_get_content_type (file_info);
-
- mime_type = g_content_type_get_mime_type (content_type);
- visible = (g_ascii_strncasecmp (mime_type, "image/", 6) == 0);
- g_free (mime_type);
-
-exit:
- action_group = e_attachment_view_get_action_group (view, "image");
- gtk_action_group_set_visible (action_group, visible);
-
- g_list_foreach (selected, (GFunc) g_object_unref, NULL);
- g_list_free (selected);
-}
-
-static void
-attachment_handler_image_constructed (GObject *object)
-{
- EAttachmentHandler *handler;
- EAttachmentView *view;
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
- GError *error = NULL;
-
- handler = E_ATTACHMENT_HANDLER (object);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_attachment_handler_image_parent_class)->constructed (object);
-
- view = e_attachment_handler_get_view (handler);
-
- action_group = e_attachment_view_add_action_group (view, "image");
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), object);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_signal_connect (
- view, "update-actions",
- G_CALLBACK (attachment_handler_image_update_actions_cb),
- object);
-}
-
-static void
-e_attachment_handler_image_class_init (EAttachmentHandlerImageClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentHandlerImagePrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->constructed = attachment_handler_image_constructed;
-}
-
-static void
-e_attachment_handler_image_init (EAttachmentHandlerImage *handler)
-{
- handler->priv = E_ATTACHMENT_HANDLER_IMAGE_GET_PRIVATE (handler);
-}
diff --git a/widgets/misc/e-attachment-handler-image.h b/widgets/misc/e-attachment-handler-image.h
deleted file mode 100644
index bade5cec5e..0000000000
--- a/widgets/misc/e-attachment-handler-image.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * e-attachment-handler-image.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_HANDLER_IMAGE_H
-#define E_ATTACHMENT_HANDLER_IMAGE_H
-
-#include <misc/e-attachment-handler.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_HANDLER_IMAGE \
- (e_attachment_handler_image_get_type ())
-#define E_ATTACHMENT_HANDLER_IMAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_IMAGE, EAttachmentHandlerImage))
-#define E_ATTACHMENT_HANDLER_IMAGE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_IMAGE, EAttachmentHandlerImageClass))
-#define E_IS_ATTACHMENT_HANDLER_IMAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_IMAGE))
-#define E_IS_ATTACHMENT_HANDLER_IMAGE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_IMAGE))
-#define E_ATTACHMENT_HANDLER_IMAGE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_IMAGE, EAttachmentHandlerImageClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentHandlerImage EAttachmentHandlerImage;
-typedef struct _EAttachmentHandlerImageClass EAttachmentHandlerImageClass;
-typedef struct _EAttachmentHandlerImagePrivate EAttachmentHandlerImagePrivate;
-
-struct _EAttachmentHandlerImage {
- EAttachmentHandler parent;
- EAttachmentHandlerImagePrivate *priv;
-};
-
-struct _EAttachmentHandlerImageClass {
- EAttachmentHandlerClass parent_class;
-};
-
-GType e_attachment_handler_image_get_type (void);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_HANDLER_IMAGE_H */
diff --git a/widgets/misc/e-attachment-handler-sendto.c b/widgets/misc/e-attachment-handler-sendto.c
deleted file mode 100644
index f0fe698713..0000000000
--- a/widgets/misc/e-attachment-handler-sendto.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * e-attachment-handler-sendto.c
- *
- * Copyright (C) 2009 Matthew Barnes
- *
- * 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) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-handler-sendto.h"
-
-#include <errno.h>
-
-#include <glib/gi18n-lib.h>
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <placeholder name='custom-actions'>"
-" <menuitem action='sendto'/>"
-" </placeholder>"
-" </popup>"
-"</ui>";
-
-G_DEFINE_TYPE (
- EAttachmentHandlerSendto,
- e_attachment_handler_sendto,
- E_TYPE_ATTACHMENT_HANDLER)
-
-static void
-sendto_save_finished_cb (EAttachment *attachment,
- GAsyncResult *result,
- EAttachmentHandler *handler)
-{
- EAttachmentView *view;
- EAttachmentStore *store;
- GtkWidget *dialog;
- gchar **uris;
- gpointer parent;
- gchar *arguments;
- gchar *command_line;
- guint n_uris = 1;
- GError *error = NULL;
-
- view = e_attachment_handler_get_view (handler);
- store = e_attachment_view_get_store (view);
-
- uris = e_attachment_store_get_uris_finish (store, result, &error);
-
- if (uris != NULL)
- n_uris = g_strv_length (uris);
-
- if (error != NULL)
- goto error;
-
- arguments = g_strjoinv (" ", uris);
- command_line = g_strdup_printf ("nautilus-sendto %s", arguments);
-
- g_message ("Command: %s", command_line);
- g_spawn_command_line_async (command_line, &error);
-
- g_free (command_line);
- g_free (arguments);
-
- if (error != NULL)
- goto error;
-
- goto exit;
-
-error:
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- dialog = gtk_message_dialog_new_with_markup (
- parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<big><b>%s</b></big>",
- ngettext ("Could not send attachment",
- "Could not send attachments", n_uris));
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_error_free (error);
-
-exit:
- g_object_unref (handler);
- g_strfreev (uris);
-}
-
-static void
-action_sendto_cb (GtkAction *action,
- EAttachmentHandler *handler)
-{
- EAttachmentView *view;
- EAttachmentStore *store;
- GList *selected;
-
- view = e_attachment_handler_get_view (handler);
- store = e_attachment_view_get_store (view);
-
- selected = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (selected != NULL);
-
- e_attachment_store_get_uris_async (
- store, selected, (GAsyncReadyCallback)
- sendto_save_finished_cb, g_object_ref (handler));
-
- g_list_foreach (selected, (GFunc) g_object_unref, NULL);
- g_list_free (selected);
-}
-
-static GtkActionEntry standard_entries[] = {
-
- { "sendto",
- "document-send",
- N_("_Send To..."),
- NULL,
- N_("Send the selected attachments somewhere"),
- G_CALLBACK (action_sendto_cb) }
-};
-
-static void
-attachment_handler_sendto_update_actions_cb (EAttachmentView *view,
- EAttachmentHandler *handler)
-{
- GtkActionGroup *action_group;
- GList *selected, *iter;
- gboolean visible = FALSE;
- gchar *program;
-
- program = g_find_program_in_path ("nautilus-sendto");
- selected = e_attachment_view_get_selected_attachments (view);
-
- if (program == NULL || selected == NULL)
- goto exit;
-
- /* Make sure no file transfers are in progress. */
- for (iter = selected; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- if (e_attachment_get_loading (attachment))
- goto exit;
-
- if (e_attachment_get_saving (attachment))
- goto exit;
- }
-
- visible = TRUE;
-
-exit:
- action_group = e_attachment_view_get_action_group (view, "sendto");
- gtk_action_group_set_visible (action_group, visible);
-
- g_list_foreach (selected, (GFunc) g_object_unref, NULL);
- g_list_free (selected);
-
- g_free (program);
-}
-
-static void
-attachment_handler_sendto_constructed (GObject *object)
-{
- EAttachmentHandler *handler;
- EAttachmentView *view;
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
- GError *error = NULL;
-
- handler = E_ATTACHMENT_HANDLER (object);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_attachment_handler_sendto_parent_class)->constructed (object);
-
- view = e_attachment_handler_get_view (handler);
- ui_manager = e_attachment_view_get_ui_manager (view);
-
- action_group = gtk_action_group_new ("sendto");
- gtk_action_group_set_translation_domain (
- action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), object);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_signal_connect (
- view, "update-actions",
- G_CALLBACK (attachment_handler_sendto_update_actions_cb),
- object);
-}
-
-static void
-e_attachment_handler_sendto_class_init (EAttachmentHandlerSendtoClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->constructed = attachment_handler_sendto_constructed;
-}
-
-static void
-e_attachment_handler_sendto_init (EAttachmentHandlerSendto *handler)
-{
-}
diff --git a/widgets/misc/e-attachment-handler-sendto.h b/widgets/misc/e-attachment-handler-sendto.h
deleted file mode 100644
index 9ae272ad7a..0000000000
--- a/widgets/misc/e-attachment-handler-sendto.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * e-attachment-handler-sendto.h
- *
- * Copyright (C) 2009 Matthew Barnes
- *
- * 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) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_ATTACHMENT_HANDLER_SENDTO_H
-#define E_ATTACHMENT_HANDLER_SENDTO_H
-
-#include <misc/e-attachment-handler.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_HANDLER_SENDTO \
- (e_attachment_handler_sendto_get_type ())
-#define E_ATTACHMENT_HANDLER_SENDTO(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_SENDTO, EAttachmentHandlerSendto))
-#define E_ATTACHMENT_HANDLER_SENDTO_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_SENDTO, EAttachmentHandlerSendtoClass))
-#define E_IS_ATTACHMENT_HANDLER_SENDTO(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_SENDTO))
-#define E_IS_ATTACHMENT_HANDLER_SENDTO_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_SENDTO))
-#define E_ATTACHMENT_HANDLER_SENDTO_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_SENDTO, EAttachmentHandlerSendtoClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentHandlerSendto EAttachmentHandlerSendto;
-typedef struct _EAttachmentHandlerSendtoClass EAttachmentHandlerSendtoClass;
-
-struct _EAttachmentHandlerSendto {
- EAttachmentHandler parent;
-};
-
-struct _EAttachmentHandlerSendtoClass {
- EAttachmentHandlerClass parent_class;
-};
-
-GType e_attachment_handler_sendto_get_type (void);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_HANDLER_SENDTO_H */
diff --git a/widgets/misc/e-attachment-handler.c b/widgets/misc/e-attachment-handler.c
deleted file mode 100644
index 87b9abddb5..0000000000
--- a/widgets/misc/e-attachment-handler.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * e-attachment-handler.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-handler.h"
-
-#define E_ATTACHMENT_HANDLER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER, EAttachmentHandlerPrivate))
-
-struct _EAttachmentHandlerPrivate {
- gpointer placeholder;
-};
-
-G_DEFINE_TYPE (
- EAttachmentHandler,
- e_attachment_handler,
- E_TYPE_EXTENSION)
-
-static void
-attachment_handler_constructed (GObject *object)
-{
- EAttachmentView *view;
- EAttachmentHandler *handler;
- GdkDragAction drag_actions;
- GtkTargetList *target_list;
- const GtkTargetEntry *targets;
- guint n_targets;
-
- handler = E_ATTACHMENT_HANDLER (object);
- drag_actions = e_attachment_handler_get_drag_actions (handler);
- targets = e_attachment_handler_get_target_table (handler, &n_targets);
-
- view = e_attachment_handler_get_view (handler);
-
- target_list = e_attachment_view_get_target_list (view);
- gtk_target_list_add_table (target_list, targets, n_targets);
-
- e_attachment_view_add_drag_actions (view, drag_actions);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_attachment_handler_parent_class)->constructed (object);
-}
-
-static void
-e_attachment_handler_class_init (EAttachmentHandlerClass *class)
-{
- GObjectClass *object_class;
- EExtensionClass *extension_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentHandlerPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->constructed = attachment_handler_constructed;
-
- extension_class = E_EXTENSION_CLASS (class);
- extension_class->extensible_type = E_TYPE_ATTACHMENT_VIEW;
-}
-
-static void
-e_attachment_handler_init (EAttachmentHandler *handler)
-{
- handler->priv = E_ATTACHMENT_HANDLER_GET_PRIVATE (handler);
-}
-
-EAttachmentView *
-e_attachment_handler_get_view (EAttachmentHandler *handler)
-{
- EExtensible *extensible;
-
- /* This is purely a convenience function. */
-
- g_return_val_if_fail (E_IS_ATTACHMENT_HANDLER (handler), NULL);
-
- extensible = e_extension_get_extensible (E_EXTENSION (handler));
-
- return E_ATTACHMENT_VIEW (extensible);
-}
-
-GdkDragAction
-e_attachment_handler_get_drag_actions (EAttachmentHandler *handler)
-{
- EAttachmentHandlerClass *class;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_HANDLER (handler), 0);
-
- class = E_ATTACHMENT_HANDLER_GET_CLASS (handler);
-
- if (class->get_drag_actions != NULL)
- return class->get_drag_actions (handler);
-
- return 0;
-}
-
-const GtkTargetEntry *
-e_attachment_handler_get_target_table (EAttachmentHandler *handler,
- guint *n_targets)
-{
- EAttachmentHandlerClass *class;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_HANDLER (handler), NULL);
-
- class = E_ATTACHMENT_HANDLER_GET_CLASS (handler);
-
- if (class->get_target_table != NULL)
- return class->get_target_table (handler, n_targets);
-
- if (n_targets != NULL)
- *n_targets = 0;
-
- return NULL;
-}
diff --git a/widgets/misc/e-attachment-handler.h b/widgets/misc/e-attachment-handler.h
deleted file mode 100644
index 301f789b07..0000000000
--- a/widgets/misc/e-attachment-handler.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * e-attachment-handler.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_HANDLER_H
-#define E_ATTACHMENT_HANDLER_H
-
-#include <libebackend/libebackend.h>
-
-#include <misc/e-attachment-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_HANDLER \
- (e_attachment_handler_get_type ())
-#define E_ATTACHMENT_HANDLER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_HANDLER, EAttachmentHandler))
-#define E_ATTACHMENT_HANDLER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_HANDLER, EAttachmentHandlerClass))
-#define E_IS_ATTACHMENT_HANDLER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER))
-#define E_IS_ATTACHMENT_HANDLER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_HANDLER))
-#define E_ATTACHMENT_HANDLER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_HANDLER, EAttachmentHandlerClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentHandler EAttachmentHandler;
-typedef struct _EAttachmentHandlerClass EAttachmentHandlerClass;
-typedef struct _EAttachmentHandlerPrivate EAttachmentHandlerPrivate;
-
-struct _EAttachmentHandler {
- EExtension parent;
- EAttachmentHandlerPrivate *priv;
-};
-
-struct _EAttachmentHandlerClass {
- EExtensionClass parent_class;
-
- GdkDragAction (*get_drag_actions) (EAttachmentHandler *handler);
- const GtkTargetEntry *
- (*get_target_table) (EAttachmentHandler *handler,
- guint *n_targets);
-};
-
-GType e_attachment_handler_get_type (void);
-EAttachmentView *
- e_attachment_handler_get_view (EAttachmentHandler *handler);
-GdkDragAction e_attachment_handler_get_drag_actions
- (EAttachmentHandler *handler);
-const GtkTargetEntry *
- e_attachment_handler_get_target_table
- (EAttachmentHandler *handler,
- guint *n_targets);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_HANDLER_H */
diff --git a/widgets/misc/e-attachment-icon-view.c b/widgets/misc/e-attachment-icon-view.c
deleted file mode 100644
index 2be8009e8a..0000000000
--- a/widgets/misc/e-attachment-icon-view.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * e-attachment-icon-view.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-icon-view.h"
-
-#include <glib/gi18n.h>
-#include <libebackend/libebackend.h>
-
-#include "e-attachment.h"
-#include "e-attachment-store.h"
-#include "e-attachment-view.h"
-
-#define E_ATTACHMENT_ICON_VIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_ICON_VIEW, EAttachmentIconViewPrivate))
-
-struct _EAttachmentIconViewPrivate {
- EAttachmentViewPrivate view_priv;
-};
-
-enum {
- PROP_0,
- PROP_DRAGGING,
- PROP_EDITABLE
-};
-
-static gint icon_size = GTK_ICON_SIZE_DIALOG;
-
-/* Forward Declarations */
-static void e_attachment_icon_view_interface_init
- (EAttachmentViewInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EAttachmentIconView,
- e_attachment_icon_view,
- GTK_TYPE_ICON_VIEW,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ATTACHMENT_VIEW,
- e_attachment_icon_view_interface_init)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-void
-e_attachment_icon_view_set_default_icon_size (gint size)
-{
- icon_size = size;
-}
-
-static void
-attachment_icon_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DRAGGING:
- e_attachment_view_set_dragging (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EDITABLE:
- e_attachment_view_set_editable (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_icon_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DRAGGING:
- g_value_set_boolean (
- value, e_attachment_view_get_dragging (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EDITABLE:
- g_value_set_boolean (
- value, e_attachment_view_get_editable (
- E_ATTACHMENT_VIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_icon_view_dispose (GObject *object)
-{
- e_attachment_view_dispose (E_ATTACHMENT_VIEW (object));
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_icon_view_parent_class)->dispose (object);
-}
-
-static void
-attachment_icon_view_finalize (GObject *object)
-{
- e_attachment_view_finalize (E_ATTACHMENT_VIEW (object));
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_attachment_icon_view_parent_class)->finalize (object);
-}
-
-static void
-attachment_icon_view_constructed (GObject *object)
-{
- GtkCellLayout *cell_layout;
- GtkCellRenderer *renderer;
-
- cell_layout = GTK_CELL_LAYOUT (object);
-
- /* This needs to happen after constructor properties are set
- * so that GtkCellLayout.get_area() returns something valid. */
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer, "stock-size", icon_size, NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "gicon",
- E_ATTACHMENT_STORE_COLUMN_ICON);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (
- renderer, "alignment", PANGO_ALIGN_CENTER,
- "wrap-mode", PANGO_WRAP_WORD, "wrap-width", 150,
- "yalign", 0.0, NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "text",
- E_ATTACHMENT_STORE_COLUMN_CAPTION);
-
- renderer = gtk_cell_renderer_progress_new ();
- g_object_set (renderer, "text", _("Loading"), NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "value",
- E_ATTACHMENT_STORE_COLUMN_PERCENT);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "visible",
- E_ATTACHMENT_STORE_COLUMN_LOADING);
-
- renderer = gtk_cell_renderer_progress_new ();
- g_object_set (renderer, "text", _("Saving"), NULL);
- gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "value",
- E_ATTACHMENT_STORE_COLUMN_PERCENT);
-
- gtk_cell_layout_add_attribute (
- cell_layout, renderer, "visible",
- E_ATTACHMENT_STORE_COLUMN_SAVING);
-
- e_extensible_load_extensions (E_EXTENSIBLE (object));
-}
-
-static gboolean
-attachment_icon_view_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_button_press_event (view, event))
- return TRUE;
-
- /* Chain up to parent's button_press_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- button_press_event (widget, event);
-}
-
-static gboolean
-attachment_icon_view_button_release_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_button_release_event (view, event))
- return TRUE;
-
- /* Chain up to parent's button_release_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- button_release_event (widget, event);
-}
-
-static gboolean
-attachment_icon_view_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_motion_notify_event (view, event))
- return TRUE;
-
- /* Chain up to parent's motion_notify_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- motion_notify_event (widget, event);
-}
-
-static gboolean
-attachment_icon_view_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_key_press_event (view, event))
- return TRUE;
-
- /* Chain up to parent's key_press_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- key_press_event (widget, event);
-}
-
-static void
-attachment_icon_view_drag_begin (GtkWidget *widget,
- GdkDragContext *context)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- /* Chain up to parent's drag_begin() method. */
- GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- drag_begin (widget, context);
-
- e_attachment_view_drag_begin (view, context);
-}
-
-static void
-attachment_icon_view_drag_end (GtkWidget *widget,
- GdkDragContext *context)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- /* Chain up to parent's drag_end() method. */
- GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- drag_end (widget, context);
-
- e_attachment_view_drag_end (view, context);
-}
-
-static void
-attachment_icon_view_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_drag_data_get (
- view, context, selection, info, time);
-}
-
-static gboolean
-attachment_icon_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- return e_attachment_view_drag_motion (view, context, x, y, time);
-}
-
-static gboolean
-attachment_icon_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (!e_attachment_view_drag_drop (view, context, x, y, time))
- return FALSE;
-
- /* Chain up to parent's drag_drop() method. */
- return GTK_WIDGET_CLASS (e_attachment_icon_view_parent_class)->
- drag_drop (widget, context, x, y, time);
-}
-
-static void
-attachment_icon_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_drag_data_received (
- view, context, x, y, selection, info, time);
-}
-
-static gboolean
-attachment_icon_view_popup_menu (GtkWidget *widget)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_show_popup_menu (view, NULL, NULL, NULL);
-
- return TRUE;
-}
-
-static void
-attachment_icon_view_item_activated (GtkIconView *icon_view,
- GtkTreePath *path)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (icon_view);
-
- e_attachment_view_open_path (view, path, NULL);
-}
-
-static EAttachmentViewPrivate *
-attachment_icon_view_get_private (EAttachmentView *view)
-{
- EAttachmentIconViewPrivate *priv;
-
- priv = E_ATTACHMENT_ICON_VIEW_GET_PRIVATE (view);
-
- return &priv->view_priv;
-}
-
-static EAttachmentStore *
-attachment_icon_view_get_store (EAttachmentView *view)
-{
- GtkIconView *icon_view;
- GtkTreeModel *model;
-
- icon_view = GTK_ICON_VIEW (view);
- model = gtk_icon_view_get_model (icon_view);
-
- return E_ATTACHMENT_STORE (model);
-}
-
-static GtkTreePath *
-attachment_icon_view_get_path_at_pos (EAttachmentView *view,
- gint x,
- gint y)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- return gtk_icon_view_get_path_at_pos (icon_view, x, y);
-}
-
-static GList *
-attachment_icon_view_get_selected_paths (EAttachmentView *view)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- return gtk_icon_view_get_selected_items (icon_view);
-}
-
-static gboolean
-attachment_icon_view_path_is_selected (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- return gtk_icon_view_path_is_selected (icon_view, path);
-}
-
-static void
-attachment_icon_view_select_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_select_path (icon_view, path);
-}
-
-static void
-attachment_icon_view_unselect_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_unselect_path (icon_view, path);
-}
-
-static void
-attachment_icon_view_select_all (EAttachmentView *view)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_select_all (icon_view);
-}
-
-static void
-attachment_icon_view_unselect_all (EAttachmentView *view)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_unselect_all (icon_view);
-}
-
-static void
-attachment_icon_view_drag_source_set (EAttachmentView *view,
- GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_enable_model_drag_source (
- icon_view, start_button_mask, targets, n_targets, actions);
-}
-
-static void
-attachment_icon_view_drag_dest_set (EAttachmentView *view,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_enable_model_drag_dest (
- icon_view, targets, n_targets, actions);
-}
-
-static void
-attachment_icon_view_drag_source_unset (EAttachmentView *view)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_unset_model_drag_source (icon_view);
-}
-
-static void
-attachment_icon_view_drag_dest_unset (EAttachmentView *view)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (view);
-
- gtk_icon_view_unset_model_drag_dest (icon_view);
-}
-
-static void
-e_attachment_icon_view_class_init (EAttachmentIconViewClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkIconViewClass *icon_view_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentViewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_icon_view_set_property;
- object_class->get_property = attachment_icon_view_get_property;
- object_class->dispose = attachment_icon_view_dispose;
- object_class->finalize = attachment_icon_view_finalize;
- object_class->constructed = attachment_icon_view_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->button_press_event = attachment_icon_view_button_press_event;
- widget_class->button_release_event = attachment_icon_view_button_release_event;
- widget_class->motion_notify_event = attachment_icon_view_motion_notify_event;
- widget_class->key_press_event = attachment_icon_view_key_press_event;
- widget_class->drag_begin = attachment_icon_view_drag_begin;
- widget_class->drag_end = attachment_icon_view_drag_end;
- widget_class->drag_data_get = attachment_icon_view_drag_data_get;
- widget_class->drag_motion = attachment_icon_view_drag_motion;
- widget_class->drag_drop = attachment_icon_view_drag_drop;
- widget_class->drag_data_received = attachment_icon_view_drag_data_received;
- widget_class->popup_menu = attachment_icon_view_popup_menu;
-
- icon_view_class = GTK_ICON_VIEW_CLASS (class);
- icon_view_class->item_activated = attachment_icon_view_item_activated;
-
- g_object_class_override_property (
- object_class, PROP_DRAGGING, "dragging");
-
- g_object_class_override_property (
- object_class, PROP_EDITABLE, "editable");
-}
-
-static void
-e_attachment_icon_view_init (EAttachmentIconView *icon_view)
-{
- icon_view->priv = E_ATTACHMENT_ICON_VIEW_GET_PRIVATE (icon_view);
-
- e_attachment_view_init (E_ATTACHMENT_VIEW (icon_view));
-
- gtk_icon_view_set_selection_mode (
- GTK_ICON_VIEW (icon_view), GTK_SELECTION_MULTIPLE);
-}
-
-static void
-e_attachment_icon_view_interface_init (EAttachmentViewInterface *interface)
-{
- interface->get_private = attachment_icon_view_get_private;
- interface->get_store = attachment_icon_view_get_store;
-
- interface->get_path_at_pos = attachment_icon_view_get_path_at_pos;
- interface->get_selected_paths = attachment_icon_view_get_selected_paths;
- interface->path_is_selected = attachment_icon_view_path_is_selected;
- interface->select_path = attachment_icon_view_select_path;
- interface->unselect_path = attachment_icon_view_unselect_path;
- interface->select_all = attachment_icon_view_select_all;
- interface->unselect_all = attachment_icon_view_unselect_all;
-
- interface->drag_source_set = attachment_icon_view_drag_source_set;
- interface->drag_dest_set = attachment_icon_view_drag_dest_set;
- interface->drag_source_unset = attachment_icon_view_drag_source_unset;
- interface->drag_dest_unset = attachment_icon_view_drag_dest_unset;
-}
-
-GtkWidget *
-e_attachment_icon_view_new (void)
-{
- return g_object_new (E_TYPE_ATTACHMENT_ICON_VIEW, NULL);
-}
diff --git a/widgets/misc/e-attachment-icon-view.h b/widgets/misc/e-attachment-icon-view.h
deleted file mode 100644
index e89992fb76..0000000000
--- a/widgets/misc/e-attachment-icon-view.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * e-attachment-icon-view.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_ICON_VIEW_H
-#define E_ATTACHMENT_ICON_VIEW_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_ICON_VIEW \
- (e_attachment_icon_view_get_type ())
-#define E_ATTACHMENT_ICON_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_ICON_VIEW, EAttachmentIconView))
-#define E_ATTACHMENT_ICON_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_ICON_VIEW, EAttachmentIconView))
-#define E_IS_ATTACHMENT_ICON_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_ICON_VIEW))
-#define E_IS_ATTACHMENT_ICON_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_ICON_VIEW))
-#define E_ATTACHMENT_ICON_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_ICON_VIEW))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentIconView EAttachmentIconView;
-typedef struct _EAttachmentIconViewClass EAttachmentIconViewClass;
-typedef struct _EAttachmentIconViewPrivate EAttachmentIconViewPrivate;
-
-struct _EAttachmentIconView {
- GtkIconView parent;
- EAttachmentIconViewPrivate *priv;
-};
-
-struct _EAttachmentIconViewClass {
- GtkIconViewClass parent_class;
-};
-
-GType e_attachment_icon_view_get_type (void);
-GtkWidget * e_attachment_icon_view_new (void);
-void e_attachment_icon_view_set_default_icon_size
- (gint size);
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_ICON_VIEW_H */
diff --git a/widgets/misc/e-attachment-paned.c b/widgets/misc/e-attachment-paned.c
deleted file mode 100644
index a3c4efb187..0000000000
--- a/widgets/misc/e-attachment-paned.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/*
- * e-attachment-paned.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-paned.h"
-
-#include <glib/gi18n.h>
-
-#include "e-attachment-view.h"
-#include "e-attachment-store.h"
-#include "e-attachment-icon-view.h"
-#include "e-attachment-tree-view.h"
-
-#define E_ATTACHMENT_PANED_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_PANED, EAttachmentPanedPrivate))
-
-#define NUM_VIEWS 2
-
-/* Initial height of the lower pane. */
-static gint initial_height = 150;
-
-struct _EAttachmentPanedPrivate {
- GtkTreeModel *model;
- GtkWidget *expander;
- GtkWidget *notebook;
- GtkWidget *combo_box;
- GtkWidget *controls_container;
- GtkWidget *icon_view;
- GtkWidget *tree_view;
- GtkWidget *show_hide_label;
- GtkWidget *status_icon;
- GtkWidget *status_label;
- GtkWidget *content_area;
-
- gint active_view;
- gboolean expanded;
- gboolean resize_toplevel;
-};
-
-enum {
- PROP_0,
- PROP_ACTIVE_VIEW,
- PROP_DRAGGING,
- PROP_EDITABLE,
- PROP_EXPANDED,
- PROP_RESIZE_TOPLEVEL
-};
-
-/* Forward Declarations */
-static void e_attachment_paned_interface_init
- (EAttachmentViewInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EAttachmentPaned,
- e_attachment_paned,
- GTK_TYPE_VPANED,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ATTACHMENT_VIEW,
- e_attachment_paned_interface_init))
-
-void
-e_attachment_paned_set_default_height (gint height)
-{
- initial_height = height;
-}
-
-static void
-attachment_paned_notify_cb (EAttachmentPaned *paned,
- GParamSpec *pspec,
- GtkExpander *expander)
-{
- GtkAllocation toplevel_allocation;
- GtkWidget *toplevel;
- GtkWidget *child;
- GtkLabel *label;
- const gchar *text;
-
- label = GTK_LABEL (paned->priv->show_hide_label);
-
- /* Update the expander label. */
- if (gtk_expander_get_expanded (expander))
- text = _("Hide Attachment _Bar");
- else
- text = _("Show Attachment _Bar");
-
- gtk_label_set_text_with_mnemonic (label, text);
-
- /* Resize the top-level window if required conditions are met.
- * This is based on gtk_expander_resize_toplevel(), but adapted
- * to the fact our GtkExpander has no direct child widget. */
-
- if (!e_attachment_paned_get_resize_toplevel (paned))
- return;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (paned)))
- return;
-
- child = gtk_paned_get_child2 (GTK_PANED (paned));
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (paned));
-
- if (toplevel == NULL)
- return;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (toplevel)))
- return;
-
- gtk_widget_get_allocation (toplevel, &toplevel_allocation);
-
- if (gtk_expander_get_expanded (expander)) {
- GtkRequisition child_requisition;
-
- gtk_widget_get_preferred_size (
- child, &child_requisition, NULL);
-
- toplevel_allocation.height += child_requisition.height;
- } else {
- GtkAllocation child_allocation;
-
- gtk_widget_get_allocation (child, &child_allocation);
-
- toplevel_allocation.height -= child_allocation.height;
- }
-
- gtk_window_resize (
- GTK_WINDOW (toplevel),
- toplevel_allocation.width,
- toplevel_allocation.height);
-}
-
-static void
-attachment_paned_update_status (EAttachmentPaned *paned)
-{
- EAttachmentView *view;
- EAttachmentStore *store;
- GtkExpander *expander;
- GtkLabel *label;
- guint num_attachments;
- guint64 total_size;
- gchar *display_size;
- gchar *markup;
-
- view = E_ATTACHMENT_VIEW (paned);
- store = e_attachment_view_get_store (view);
- expander = GTK_EXPANDER (paned->priv->expander);
- label = GTK_LABEL (paned->priv->status_label);
-
- num_attachments = e_attachment_store_get_num_attachments (store);
- total_size = e_attachment_store_get_total_size (store);
- display_size = g_format_size (total_size);
-
- if (total_size > 0)
- markup = g_strdup_printf (
- "<b>%d</b> %s (%s)", num_attachments, ngettext (
- "Attachment", "Attachments", num_attachments),
- display_size);
- else
- markup = g_strdup_printf (
- "<b>%d</b> %s", num_attachments, ngettext (
- "Attachment", "Attachments", num_attachments));
- gtk_label_set_markup (label, markup);
- g_free (markup);
-
- g_free (display_size);
-
- if (num_attachments > 0) {
- gtk_widget_show (paned->priv->status_icon);
- gtk_widget_show (paned->priv->status_label);
- gtk_expander_set_expanded (expander, TRUE);
- } else {
- gtk_widget_hide (paned->priv->status_icon);
- gtk_widget_hide (paned->priv->status_label);
- gtk_expander_set_expanded (expander, FALSE);
- }
-}
-
-static void
-attachment_paned_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVE_VIEW:
- e_attachment_paned_set_active_view (
- E_ATTACHMENT_PANED (object),
- g_value_get_int (value));
- return;
-
- case PROP_DRAGGING:
- e_attachment_view_set_dragging (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EDITABLE:
- e_attachment_view_set_editable (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EXPANDED:
- e_attachment_paned_set_expanded (
- E_ATTACHMENT_PANED (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_RESIZE_TOPLEVEL:
- e_attachment_paned_set_resize_toplevel (
- E_ATTACHMENT_PANED (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_paned_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVE_VIEW:
- g_value_set_int (
- value,
- e_attachment_paned_get_active_view (
- E_ATTACHMENT_PANED (object)));
- return;
-
- case PROP_DRAGGING:
- g_value_set_boolean (
- value,
- e_attachment_view_get_dragging (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EDITABLE:
- g_value_set_boolean (
- value,
- e_attachment_view_get_editable (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EXPANDED:
- g_value_set_boolean (
- value,
- e_attachment_paned_get_expanded (
- E_ATTACHMENT_PANED (object)));
- return;
-
- case PROP_RESIZE_TOPLEVEL:
- g_value_set_boolean (
- value,
- e_attachment_paned_get_resize_toplevel (
- E_ATTACHMENT_PANED (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_paned_dispose (GObject *object)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (object);
-
- if (priv->model != NULL) {
- e_attachment_store_remove_all (E_ATTACHMENT_STORE (priv->model));
- g_object_unref (priv->model);
- priv->model = NULL;
- }
-
- if (priv->expander != NULL) {
- g_object_unref (priv->expander);
- priv->expander = NULL;
- }
-
- if (priv->notebook != NULL) {
- g_object_unref (priv->notebook);
- priv->notebook = NULL;
- }
-
- if (priv->combo_box != NULL) {
- g_object_unref (priv->combo_box);
- priv->combo_box = NULL;
- }
-
- if (priv->icon_view != NULL) {
- g_object_unref (priv->icon_view);
- priv->icon_view = NULL;
- }
-
- if (priv->tree_view != NULL) {
- g_object_unref (priv->tree_view);
- priv->tree_view = NULL;
- }
-
- if (priv->show_hide_label != NULL) {
- g_object_unref (priv->show_hide_label);
- priv->show_hide_label = NULL;
- }
-
- if (priv->status_icon != NULL) {
- g_object_unref (priv->status_icon);
- priv->status_icon = NULL;
- }
-
- if (priv->status_label != NULL) {
- g_object_unref (priv->status_label);
- priv->status_label = NULL;
- }
-
- if (priv->content_area != NULL) {
- g_object_unref (priv->content_area);
- priv->content_area = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_paned_parent_class)->dispose (object);
-}
-
-static void
-attachment_paned_constructed (GObject *object)
-{
- EAttachmentPanedPrivate *priv;
- GSettings *settings;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (object);
-
- settings = g_settings_new ("org.gnome.evolution.shell");
-
- /* Set up property-to-property bindings. */
-
- g_object_bind_property (
- object, "active-view",
- priv->combo_box, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "active-view",
- priv->notebook, "page",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "dragging",
- priv->icon_view, "dragging",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "dragging",
- priv->tree_view, "dragging",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "editable",
- priv->icon_view, "editable",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "editable",
- priv->tree_view, "editable",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->expander, "expanded",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->combo_box, "sensitive",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- object, "expanded",
- priv->notebook, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Set up property-to-GSettings bindings. */
- g_settings_bind (
- settings, "attachment-view",
- object, "active-view",
- G_SETTINGS_BIND_DEFAULT);
-
- g_object_unref (settings);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_attachment_paned_parent_class)->constructed (object);
-}
-
-static EAttachmentViewPrivate *
-attachment_paned_get_private (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- return e_attachment_view_get_private (view);
-}
-
-static EAttachmentStore *
-attachment_paned_get_store (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- return e_attachment_view_get_store (view);
-}
-
-static GtkTreePath *
-attachment_paned_get_path_at_pos (EAttachmentView *view,
- gint x,
- gint y)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- return e_attachment_view_get_path_at_pos (view, x, y);
-}
-
-static GList *
-attachment_paned_get_selected_paths (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- return e_attachment_view_get_selected_paths (view);
-}
-
-static gboolean
-attachment_paned_path_is_selected (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- return e_attachment_view_path_is_selected (view, path);
-}
-
-static void
-attachment_paned_select_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- e_attachment_view_select_path (view, path);
-}
-
-static void
-attachment_paned_unselect_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- e_attachment_view_unselect_path (view, path);
-}
-
-static void
-attachment_paned_select_all (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- e_attachment_view_select_all (view);
-}
-
-static void
-attachment_paned_unselect_all (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- e_attachment_view_unselect_all (view);
-}
-
-static void
-attachment_paned_update_actions (EAttachmentView *view)
-{
- EAttachmentPanedPrivate *priv;
-
- priv = E_ATTACHMENT_PANED_GET_PRIVATE (view);
- view = E_ATTACHMENT_VIEW (priv->icon_view);
-
- e_attachment_view_update_actions (view);
-}
-
-static void
-e_attachment_paned_class_init (EAttachmentPanedClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentPanedPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_paned_set_property;
- object_class->get_property = attachment_paned_get_property;
- object_class->dispose = attachment_paned_dispose;
- object_class->constructed = attachment_paned_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTIVE_VIEW,
- g_param_spec_int (
- "active-view",
- "Active View",
- NULL,
- 0,
- NUM_VIEWS,
- 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_override_property (
- object_class, PROP_DRAGGING, "dragging");
-
- g_object_class_override_property (
- object_class, PROP_EDITABLE, "editable");
-
- g_object_class_install_property (
- object_class,
- PROP_EXPANDED,
- g_param_spec_boolean (
- "expanded",
- "Expanded",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_RESIZE_TOPLEVEL,
- g_param_spec_boolean (
- "resize-toplevel",
- "Resize-Toplevel",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_attachment_paned_init (EAttachmentPaned *paned)
-{
- EAttachmentView *view;
- GtkSizeGroup *size_group;
- GtkWidget *container;
- GtkWidget *widget;
- GtkAction *action;
-
- paned->priv = E_ATTACHMENT_PANED_GET_PRIVATE (paned);
- paned->priv->model = e_attachment_store_new ();
-
- /* Keep the expander label and combo box the same height. */
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- /* Construct the Attachment Views */
-
- container = GTK_WIDGET (paned);
-
- widget = gtk_notebook_new ();
- gtk_widget_set_size_request (widget, -1, initial_height);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
- paned->priv->notebook = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- container = paned->priv->notebook;
-
- 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_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_attachment_icon_view_new ();
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_icon_view_set_model (GTK_ICON_VIEW (widget), paned->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- paned->priv->icon_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = paned->priv->notebook;
-
- 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_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_attachment_tree_view_new ();
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget), paned->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- paned->priv->tree_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* Construct the Controls */
-
- container = GTK_WIDGET (paned);
-
- widget = gtk_vbox_new (FALSE, 6);
- gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
- paned->priv->content_area = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
- paned->priv->controls_container = widget;
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_expander_new (NULL);
- gtk_expander_set_spacing (GTK_EXPANDER (widget), 0);
- gtk_expander_set_label_fill (GTK_EXPANDER (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- paned->priv->expander = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* The "Add Attachment" button proxies the "add" action from
- * one of the two attachment views. Doesn't matter which. */
- widget = gtk_button_new ();
- view = E_ATTACHMENT_VIEW (paned->priv->icon_view);
- action = e_attachment_view_get_action (view, "add");
- gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new ());
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_combo_box_text_new ();
- gtk_size_group_add_widget (size_group, widget);
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("Icon View"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("List View"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- paned->priv->combo_box = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = paned->priv->expander;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_size_group_add_widget (size_group, widget);
- gtk_expander_set_label_widget (GTK_EXPANDER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_label_new_with_mnemonic (_("Show Attachment _Bar"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- paned->priv->show_hide_label = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_alignment_new (0.5, 0.5, 0.0, 1.0);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_icon_name (
- "mail-attachment", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- paned->priv->status_icon = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- widget = gtk_label_new (NULL);
- gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- paned->priv->status_label = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- g_signal_connect_swapped (
- paned->priv->expander, "notify::expanded",
- G_CALLBACK (attachment_paned_notify_cb), paned);
-
- g_signal_connect_swapped (
- paned->priv->model, "notify::num-attachments",
- G_CALLBACK (attachment_paned_update_status), paned);
-
- g_signal_connect_swapped (
- paned->priv->model, "notify::total-size",
- G_CALLBACK (attachment_paned_update_status), paned);
-
- g_object_unref (size_group);
-}
-
-static void
-e_attachment_paned_interface_init (EAttachmentViewInterface *interface)
-{
- interface->get_private = attachment_paned_get_private;
- interface->get_store = attachment_paned_get_store;
- interface->get_path_at_pos = attachment_paned_get_path_at_pos;
- interface->get_selected_paths = attachment_paned_get_selected_paths;
- interface->path_is_selected = attachment_paned_path_is_selected;
- interface->select_path = attachment_paned_select_path;
- interface->unselect_path = attachment_paned_unselect_path;
- interface->select_all = attachment_paned_select_all;
- interface->unselect_all = attachment_paned_unselect_all;
- interface->update_actions = attachment_paned_update_actions;
-}
-
-GtkWidget *
-e_attachment_paned_new (void)
-{
- return g_object_new (E_TYPE_ATTACHMENT_PANED, NULL);
-}
-
-GtkWidget *
-e_attachment_paned_get_content_area (EAttachmentPaned *paned)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_PANED (paned), NULL);
-
- return paned->priv->content_area;
-}
-
-gint
-e_attachment_paned_get_active_view (EAttachmentPaned *paned)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_PANED (paned), 0);
-
- return paned->priv->active_view;
-}
-
-void
-e_attachment_paned_set_active_view (EAttachmentPaned *paned,
- gint active_view)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- g_return_if_fail (E_IS_ATTACHMENT_PANED (paned));
- g_return_if_fail (active_view >= 0 && active_view < NUM_VIEWS);
-
- if (active_view == paned->priv->active_view)
- return;
-
- paned->priv->active_view = active_view;
-
- /* Synchronize the item selection of the view we're
- * switching TO with the view we're switching FROM. */
- if (active_view == 0) {
- /* from tree view to icon view */
- source = E_ATTACHMENT_VIEW (paned->priv->tree_view);
- target = E_ATTACHMENT_VIEW (paned->priv->icon_view);
- } else {
- /* from icon view to tree view */
- source = E_ATTACHMENT_VIEW (paned->priv->icon_view);
- target = E_ATTACHMENT_VIEW (paned->priv->tree_view);
- }
-
- e_attachment_view_sync_selection (source, target);
-
- g_object_notify (G_OBJECT (paned), "active-view");
-}
-
-gboolean
-e_attachment_paned_get_expanded (EAttachmentPaned *paned)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_PANED (paned), FALSE);
-
- return paned->priv->expanded;
-}
-
-void
-e_attachment_paned_set_expanded (EAttachmentPaned *paned,
- gboolean expanded)
-{
- g_return_if_fail (E_IS_ATTACHMENT_PANED (paned));
-
- if (paned->priv->expanded == expanded)
- return;
-
- paned->priv->expanded = expanded;
-
- g_object_notify (G_OBJECT (paned), "expanded");
-}
-
-gboolean
-e_attachment_paned_get_resize_toplevel (EAttachmentPaned *paned)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_PANED (paned), FALSE);
-
- return paned->priv->resize_toplevel;
-}
-
-void
-e_attachment_paned_set_resize_toplevel (EAttachmentPaned *paned,
- gboolean resize_toplevel)
-{
- g_return_if_fail (E_IS_ATTACHMENT_PANED (paned));
-
- if (paned->priv->resize_toplevel == resize_toplevel)
- return;
-
- paned->priv->resize_toplevel = resize_toplevel;
-
- g_object_notify (G_OBJECT (paned), "resize-toplevel");
-}
-
-void
-e_attachment_paned_drag_data_received (EAttachmentPaned *paned,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- g_return_if_fail (E_IS_ATTACHMENT_PANED (paned));
-
- /* XXX Dirty hack for forwarding drop events. */
- g_signal_emit_by_name (
- paned->priv->icon_view, "drag-data-received",
- context, x, y, selection, info, time);
-}
-
-GtkWidget *
-e_attachment_paned_get_controls_container (EAttachmentPaned *paned)
-{
- return paned->priv->controls_container;
-}
-
-GtkWidget *
-e_attachment_paned_get_view_combo (EAttachmentPaned *paned)
-{
- return paned->priv->combo_box;
-}
-
diff --git a/widgets/misc/e-attachment-paned.h b/widgets/misc/e-attachment-paned.h
deleted file mode 100644
index 7daffd5508..0000000000
--- a/widgets/misc/e-attachment-paned.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * e-attachment-paned.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_PANED_H
-#define E_ATTACHMENT_PANED_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_PANED \
- (e_attachment_paned_get_type ())
-#define E_ATTACHMENT_PANED(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_PANED, EAttachmentPaned))
-#define E_ATTACHMENT_PANED_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_PANED, EAttachmentPanedClass))
-#define E_IS_ATTACHMENT_PANED(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_PANED))
-#define E_IS_ATTACHMENT_PANED_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_PANED))
-#define E_ATTACHMENT_PANED_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_PANED, EAttachmentPanedClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentPaned EAttachmentPaned;
-typedef struct _EAttachmentPanedClass EAttachmentPanedClass;
-typedef struct _EAttachmentPanedPrivate EAttachmentPanedPrivate;
-
-struct _EAttachmentPaned {
- GtkVPaned parent;
- EAttachmentPanedPrivate *priv;
-};
-
-struct _EAttachmentPanedClass {
- GtkVPanedClass parent_class;
-};
-
-GType e_attachment_paned_get_type (void);
-GtkWidget * e_attachment_paned_new (void);
-GtkWidget * e_attachment_paned_get_content_area
- (EAttachmentPaned *paned);
-gint e_attachment_paned_get_active_view
- (EAttachmentPaned *paned);
-void e_attachment_paned_set_active_view
- (EAttachmentPaned *paned,
- gint active_view);
-gboolean e_attachment_paned_get_expanded (EAttachmentPaned *paned);
-void e_attachment_paned_set_expanded (EAttachmentPaned *paned,
- gboolean expanded);
-gboolean e_attachment_paned_get_resize_toplevel
- (EAttachmentPaned *paned);
-void e_attachment_paned_set_resize_toplevel
- (EAttachmentPaned *paned,
- gboolean resize_toplevel);
-void e_attachment_paned_drag_data_received
- (EAttachmentPaned *paned,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time);
-GtkWidget * e_attachment_paned_get_controls_container
- (EAttachmentPaned *paned);
-GtkWidget * e_attachment_paned_get_view_combo
- (EAttachmentPaned *paned);
-void e_attachment_paned_set_default_height
- (gint height);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_PANED_H */
diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c
deleted file mode 100644
index 95465eba81..0000000000
--- a/widgets/misc/e-attachment-store.c
+++ /dev/null
@@ -1,1281 +0,0 @@
-/*
- * e-attachment-store.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-store.h"
-
-#include <errno.h>
-#include <glib/gi18n.h>
-
-#include "e-util/e-util.h"
-#include "e-util/e-mktemp.h"
-
-#define E_ATTACHMENT_STORE_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_STORE, EAttachmentStorePrivate))
-
-struct _EAttachmentStorePrivate {
- GHashTable *attachment_index;
-
- guint ignore_row_changed : 1;
-};
-
-enum {
- PROP_0,
- PROP_NUM_ATTACHMENTS,
- PROP_NUM_LOADING,
- PROP_TOTAL_SIZE
-};
-
-G_DEFINE_TYPE (
- EAttachmentStore,
- e_attachment_store,
- GTK_TYPE_LIST_STORE)
-
-static void
-attachment_store_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_NUM_ATTACHMENTS:
- g_value_set_uint (
- value,
- e_attachment_store_get_num_attachments (
- E_ATTACHMENT_STORE (object)));
- return;
-
- case PROP_NUM_LOADING:
- g_value_set_uint (
- value,
- e_attachment_store_get_num_loading (
- E_ATTACHMENT_STORE (object)));
- return;
-
- case PROP_TOTAL_SIZE:
- g_value_set_uint64 (
- value,
- e_attachment_store_get_total_size (
- E_ATTACHMENT_STORE (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_store_dispose (GObject *object)
-{
- e_attachment_store_remove_all (E_ATTACHMENT_STORE (object));
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_store_parent_class)->dispose (object);
-}
-
-static void
-attachment_store_finalize (GObject *object)
-{
- EAttachmentStorePrivate *priv;
-
- priv = E_ATTACHMENT_STORE_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->attachment_index);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_attachment_store_parent_class)->finalize (object);
-}
-
-static void
-e_attachment_store_class_init (EAttachmentStoreClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentStorePrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->get_property = attachment_store_get_property;
- object_class->dispose = attachment_store_dispose;
- object_class->finalize = attachment_store_finalize;
-
- g_object_class_install_property (
- object_class,
- PROP_NUM_ATTACHMENTS,
- g_param_spec_uint (
- "num-attachments",
- "Num Attachments",
- NULL,
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_NUM_LOADING,
- g_param_spec_uint (
- "num-loading",
- "Num Loading",
- NULL,
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_TOTAL_SIZE,
- g_param_spec_uint64 (
- "total-size",
- "Total Size",
- NULL,
- 0,
- G_MAXUINT64,
- 0,
- G_PARAM_READABLE));
-}
-
-static void
-e_attachment_store_init (EAttachmentStore *store)
-{
- GType types[E_ATTACHMENT_STORE_NUM_COLUMNS];
- GHashTable *attachment_index;
- gint column = 0;
-
- attachment_index = g_hash_table_new_full (
- g_direct_hash, g_direct_equal,
- (GDestroyNotify) g_object_unref,
- (GDestroyNotify) gtk_tree_row_reference_free);
-
- store->priv = E_ATTACHMENT_STORE_GET_PRIVATE (store);
- store->priv->attachment_index = attachment_index;
-
- types[column++] = E_TYPE_ATTACHMENT; /* COLUMN_ATTACHMENT */
- types[column++] = G_TYPE_STRING; /* COLUMN_CAPTION */
- types[column++] = G_TYPE_STRING; /* COLUMN_CONTENT_TYPE */
- types[column++] = G_TYPE_STRING; /* COLUMN_DESCRIPTION */
- types[column++] = G_TYPE_ICON; /* COLUMN_ICON */
- types[column++] = G_TYPE_BOOLEAN; /* COLUMN_LOADING */
- types[column++] = G_TYPE_INT; /* COLUMN_PERCENT */
- types[column++] = G_TYPE_BOOLEAN; /* COLUMN_SAVING */
- types[column++] = G_TYPE_UINT64; /* COLUMN_SIZE */
-
- g_assert (column == E_ATTACHMENT_STORE_NUM_COLUMNS);
-
- gtk_list_store_set_column_types (
- GTK_LIST_STORE (store), G_N_ELEMENTS (types), types);
-}
-
-GtkTreeModel *
-e_attachment_store_new (void)
-{
- return g_object_new (E_TYPE_ATTACHMENT_STORE, NULL);
-}
-
-void
-e_attachment_store_add_attachment (EAttachmentStore *store,
- EAttachment *attachment)
-{
- GtkTreeRowReference *reference;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- gtk_list_store_append (GTK_LIST_STORE (store), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (store), &iter,
- E_ATTACHMENT_STORE_COLUMN_ATTACHMENT, attachment, -1);
-
- model = GTK_TREE_MODEL (store);
- path = gtk_tree_model_get_path (model, &iter);
- reference = gtk_tree_row_reference_new (model, path);
- gtk_tree_path_free (path);
-
- g_hash_table_insert (
- store->priv->attachment_index,
- g_object_ref (attachment), reference);
-
- /* This lets the attachment tell us when to update. */
- e_attachment_set_reference (attachment, reference);
-
- g_object_freeze_notify (G_OBJECT (store));
- g_object_notify (G_OBJECT (store), "num-attachments");
- g_object_notify (G_OBJECT (store), "total-size");
- g_object_thaw_notify (G_OBJECT (store));
-}
-
-gboolean
-e_attachment_store_remove_attachment (EAttachmentStore *store,
- EAttachment *attachment)
-{
- GtkTreeRowReference *reference;
- GHashTable *hash_table;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), FALSE);
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- hash_table = store->priv->attachment_index;
- reference = g_hash_table_lookup (hash_table, attachment);
-
- if (reference == NULL)
- return FALSE;
-
- if (!gtk_tree_row_reference_valid (reference)) {
- g_hash_table_remove (hash_table, attachment);
- return FALSE;
- }
-
- e_attachment_cancel (attachment);
- e_attachment_set_reference (attachment, NULL);
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
-
- gtk_list_store_remove (GTK_LIST_STORE (store), &iter);
- g_hash_table_remove (hash_table, attachment);
-
- g_object_freeze_notify (G_OBJECT (store));
- g_object_notify (G_OBJECT (store), "num-attachments");
- g_object_notify (G_OBJECT (store), "total-size");
- g_object_thaw_notify (G_OBJECT (store));
-
- return TRUE;
-}
-
-void
-e_attachment_store_remove_all (EAttachmentStore *store)
-{
- GList *list, *iter;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
-
- if (!g_hash_table_size (store->priv->attachment_index))
- return;
-
- g_object_freeze_notify (G_OBJECT (store));
-
- list = e_attachment_store_get_attachments (store);
- for (iter = list; iter; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- e_attachment_cancel (attachment);
- g_hash_table_remove (store->priv->attachment_index, iter->data);
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-
- gtk_list_store_clear (GTK_LIST_STORE (store));
-
- g_object_notify (G_OBJECT (store), "num-attachments");
- g_object_notify (G_OBJECT (store), "total-size");
- g_object_thaw_notify (G_OBJECT (store));
-}
-
-void
-e_attachment_store_add_to_multipart (EAttachmentStore *store,
- CamelMultipart *multipart,
- const gchar *default_charset)
-{
- GList *list, *iter;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
- g_return_if_fail (CAMEL_MULTIPART (multipart));
-
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- /* Skip the attachment if it's still loading. */
- if (!e_attachment_get_loading (attachment))
- e_attachment_add_to_multipart (
- attachment, multipart, default_charset);
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-GList *
-e_attachment_store_get_attachments (EAttachmentStore *store)
-{
- GList *list = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
-
- model = GTK_TREE_MODEL (store);
- valid = gtk_tree_model_get_iter_first (model, &iter);
-
- while (valid) {
- EAttachment *attachment;
- gint column_id;
-
- column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT;
- gtk_tree_model_get (model, &iter, column_id, &attachment, -1);
-
- list = g_list_prepend (list, attachment);
-
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- return g_list_reverse (list);
-}
-
-guint
-e_attachment_store_get_num_attachments (EAttachmentStore *store)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), 0);
-
- return g_hash_table_size (store->priv->attachment_index);
-}
-
-guint
-e_attachment_store_get_num_loading (EAttachmentStore *store)
-{
- GList *list, *iter;
- guint num_loading = 0;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), 0);
-
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- if (e_attachment_get_loading (attachment))
- num_loading++;
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-
- return num_loading;
-}
-
-goffset
-e_attachment_store_get_total_size (EAttachmentStore *store)
-{
- GList *list, *iter;
- goffset total_size = 0;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), 0);
-
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
- GFileInfo *file_info;
-
- file_info = e_attachment_get_file_info (attachment);
- if (file_info != NULL)
- total_size += g_file_info_get_size (file_info);
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-
- return total_size;
-}
-
-void
-e_attachment_store_run_load_dialog (EAttachmentStore *store,
- GtkWindow *parent)
-{
- GtkFileChooser *file_chooser;
- GtkWidget *dialog;
- GtkWidget *option;
- GSList *files, *iter;
- const gchar *disposition;
- gboolean active;
- gint response;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
- g_return_if_fail (GTK_IS_WINDOW (parent));
-
- dialog = gtk_file_chooser_dialog_new (
- _("Add Attachment"), parent,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("A_ttach"), GTK_RESPONSE_OK, NULL);
-
- file_chooser = GTK_FILE_CHOOSER (dialog);
- gtk_file_chooser_set_local_only (file_chooser, FALSE);
- gtk_file_chooser_set_select_multiple (file_chooser, TRUE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
-
- option = gtk_check_button_new_with_mnemonic (
- _("_Suggest automatic display of attachment"));
- gtk_file_chooser_set_extra_widget (file_chooser, option);
- gtk_widget_show (option);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (response != GTK_RESPONSE_OK)
- goto exit;
-
- files = gtk_file_chooser_get_files (file_chooser);
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (option));
- disposition = active ? "inline" : "attachment";
-
- for (iter = files; iter != NULL; iter = g_slist_next (iter)) {
- EAttachment *attachment;
- GFile *file = iter->data;
-
- attachment = e_attachment_new ();
- e_attachment_set_file (attachment, file);
- e_attachment_set_disposition (attachment, disposition);
- e_attachment_store_add_attachment (store, attachment);
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- g_object_unref (attachment);
- }
-
- g_slist_foreach (files, (GFunc) g_object_unref, NULL);
- g_slist_free (files);
-
-exit:
- gtk_widget_destroy (dialog);
-}
-
-GFile *
-e_attachment_store_run_save_dialog (EAttachmentStore *store,
- GList *attachment_list,
- GtkWindow *parent)
-{
- GtkFileChooser *file_chooser;
- GtkFileChooserAction action;
- GtkWidget *dialog;
- GFile *destination;
- const gchar *title;
- gint response;
- guint length;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
-
- length = g_list_length (attachment_list);
-
- if (length == 0)
- return NULL;
-
- title = ngettext ("Save Attachment", "Save Attachments", length);
-
- if (length == 1)
- action = GTK_FILE_CHOOSER_ACTION_SAVE;
- else
- action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
-
- dialog = gtk_file_chooser_dialog_new (
- title, parent, action,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
-
- file_chooser = GTK_FILE_CHOOSER (dialog);
- gtk_file_chooser_set_local_only (file_chooser, FALSE);
- gtk_file_chooser_set_do_overwrite_confirmation (file_chooser, TRUE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
-
- if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
- EAttachment *attachment;
- GFileInfo *file_info;
- const gchar *name = NULL;
-
- attachment = attachment_list->data;
- file_info = e_attachment_get_file_info (attachment);
- if (file_info != NULL)
- name = g_file_info_get_display_name (file_info);
- if (name == NULL)
- /* Translators: Default attachment filename. */
- name = _("attachment.dat");
- gtk_file_chooser_set_current_name (file_chooser, name);
- }
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (response == GTK_RESPONSE_OK)
- destination = gtk_file_chooser_get_file (file_chooser);
- else
- destination = NULL;
-
- gtk_widget_destroy (dialog);
-
- return destination;
-}
-
-/******************** e_attachment_store_get_uris_async() ********************/
-
-typedef struct _UriContext UriContext;
-
-struct _UriContext {
- GSimpleAsyncResult *simple;
- GList *attachment_list;
- GError *error;
- gchar **uris;
- gint index;
-};
-
-static UriContext *
-attachment_store_uri_context_new (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- UriContext *uri_context;
- GSimpleAsyncResult *simple;
- guint length;
- gchar **uris;
-
- simple = g_simple_async_result_new (
- G_OBJECT (store), callback, user_data,
- e_attachment_store_get_uris_async);
-
- /* Add one for NULL terminator. */
- length = g_list_length (attachment_list) + 1;
- uris = g_malloc0 (sizeof (gchar *) * length);
-
- uri_context = g_slice_new0 (UriContext);
- uri_context->simple = simple;
- uri_context->attachment_list = g_list_copy (attachment_list);
- uri_context->uris = uris;
-
- g_list_foreach (
- uri_context->attachment_list,
- (GFunc) g_object_ref, NULL);
-
- return uri_context;
-}
-
-static void
-attachment_store_uri_context_free (UriContext *uri_context)
-{
- g_object_unref (uri_context->simple);
-
- /* The attachment list should be empty now. */
- g_warn_if_fail (uri_context->attachment_list == NULL);
-
- /* So should the error. */
- g_warn_if_fail (uri_context->error == NULL);
-
- g_strfreev (uri_context->uris);
-
- g_slice_free (UriContext, uri_context);
-}
-
-static void
-attachment_store_get_uris_save_cb (EAttachment *attachment,
- GAsyncResult *result,
- UriContext *uri_context)
-{
- GSimpleAsyncResult *simple;
- GFile *file;
- gchar **uris;
- gchar *uri;
- GError *error = NULL;
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- /* Remove the attachment from the list. */
- uri_context->attachment_list = g_list_remove (
- uri_context->attachment_list, attachment);
- g_object_unref (attachment);
-
- if (file != NULL) {
- uri = g_file_get_uri (file);
- uri_context->uris[uri_context->index++] = uri;
- g_object_unref (file);
-
- } else if (error != NULL) {
- /* If this is the first error, cancel the other jobs. */
- if (uri_context->error == NULL) {
- g_propagate_error (&uri_context->error, error);
- g_list_foreach (
- uri_context->attachment_list,
- (GFunc) e_attachment_cancel, NULL);
- error = NULL;
-
- /* Otherwise, we can only report back one error. So if
- * this is something other than cancellation, dump it to
- * the terminal. */
- } else if (!g_error_matches (
- error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("%s", error->message);
- }
-
- if (error != NULL)
- g_error_free (error);
-
- /* If there's still jobs running, let them finish. */
- if (uri_context->attachment_list != NULL)
- return;
-
- /* Steal the URI list. */
- uris = uri_context->uris;
- uri_context->uris = NULL;
-
- /* And the error. */
- error = uri_context->error;
- uri_context->error = NULL;
-
- simple = uri_context->simple;
-
- if (error == NULL)
- g_simple_async_result_set_op_res_gpointer (simple, uris, NULL);
- else
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
-
- attachment_store_uri_context_free (uri_context);
-}
-
-void
-e_attachment_store_get_uris_async (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFile *temp_directory;
- UriContext *uri_context;
- GList *iter, *trash = NULL;
- gchar *template;
- gchar *path;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
-
- uri_context = attachment_store_uri_context_new (
- store, attachment_list, callback, user_data);
-
- /* Grab the copied attachment list. */
- attachment_list = uri_context->attachment_list;
-
- /* First scan the list for attachments with a GFile. */
- for (iter = attachment_list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
- GFile *file;
- gchar *uri;
-
- file = e_attachment_get_file (attachment);
- if (file == NULL)
- continue;
-
- uri = g_file_get_uri (file);
- uri_context->uris[uri_context->index++] = uri;
-
- /* Mark the list node for deletion. */
- trash = g_list_prepend (trash, iter);
- g_object_unref (attachment);
- }
-
- /* Expunge the list. */
- for (iter = trash; iter != NULL; iter = iter->next) {
- GList *link = iter->data;
- attachment_list = g_list_delete_link (attachment_list, link);
- }
- g_list_free (trash);
-
- uri_context->attachment_list = attachment_list;
-
- /* If we got them all then we're done. */
- if (attachment_list == NULL) {
- GSimpleAsyncResult *simple;
- gchar **uris;
-
- /* Steal the URI list. */
- uris = uri_context->uris;
- uri_context->uris = NULL;
-
- simple = uri_context->simple;
- g_simple_async_result_set_op_res_gpointer (simple, uris, NULL);
- g_simple_async_result_complete (simple);
-
- attachment_store_uri_context_free (uri_context);
- return;
- }
-
- /* Any remaining attachments in the list should have MIME parts
- * only, so we need to save them all to a temporary directory.
- * We use a directory so the files can retain their basenames.
- * XXX This could trigger a blocking temp directory cleanup. */
- template = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ());
- path = e_mkdtemp (template);
- g_free (template);
-
- /* XXX Let's hope errno got set properly. */
- if (path == NULL) {
- GSimpleAsyncResult *simple;
-
- simple = uri_context->simple;
- g_simple_async_result_set_error (
- simple, G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
- g_simple_async_result_complete (simple);
-
- attachment_store_uri_context_free (uri_context);
- return;
- }
-
- temp_directory = g_file_new_for_path (path);
-
- for (iter = attachment_list; iter != NULL; iter = iter->next)
- e_attachment_save_async (
- E_ATTACHMENT (iter->data),
- temp_directory, (GAsyncReadyCallback)
- attachment_store_get_uris_save_cb,
- uri_context);
-
- g_object_unref (temp_directory);
- g_free (path);
-}
-
-gchar **
-e_attachment_store_get_uris_finish (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gchar **uris;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- uris = g_simple_async_result_get_op_res_gpointer (simple);
- g_simple_async_result_propagate_error (simple, error);
-
- return uris;
-}
-
-/********************** e_attachment_store_load_async() **********************/
-
-typedef struct _LoadContext LoadContext;
-
-struct _LoadContext {
- GSimpleAsyncResult *simple;
- GList *attachment_list;
- GError *error;
-};
-
-static LoadContext *
-attachment_store_load_context_new (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- LoadContext *load_context;
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (
- G_OBJECT (store), callback, user_data,
- e_attachment_store_load_async);
-
- load_context = g_slice_new0 (LoadContext);
- load_context->simple = simple;
- load_context->attachment_list = g_list_copy (attachment_list);
-
- g_list_foreach (
- load_context->attachment_list,
- (GFunc) g_object_ref, NULL);
-
- return load_context;
-}
-
-static void
-attachment_store_load_context_free (LoadContext *load_context)
-{
- g_object_unref (load_context->simple);
-
- /* The attachment list should be empty now. */
- g_warn_if_fail (load_context->attachment_list == NULL);
-
- /* So should the error. */
- g_warn_if_fail (load_context->error == NULL);
-
- g_slice_free (LoadContext, load_context);
-}
-
-static void
-attachment_store_load_ready_cb (EAttachment *attachment,
- GAsyncResult *result,
- LoadContext *load_context)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- e_attachment_load_finish (attachment, result, &error);
-
- /* Remove the attachment from the list. */
- load_context->attachment_list = g_list_remove (
- load_context->attachment_list, attachment);
- g_object_unref (attachment);
-
- if (error != NULL) {
- /* If this is the first error, cancel the other jobs. */
- if (load_context->error == NULL) {
- g_propagate_error (&load_context->error, error);
- g_list_foreach (
- load_context->attachment_list,
- (GFunc) e_attachment_cancel, NULL);
- error = NULL;
-
- /* Otherwise, we can only report back one error. So if
- * this is something other than cancellation, dump it to
- * the terminal. */
- } else if (!g_error_matches (
- error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("%s", error->message);
- }
-
- if (error != NULL)
- g_error_free (error);
-
- /* If there's still jobs running, let them finish. */
- if (load_context->attachment_list != NULL)
- return;
-
- /* Steal the error. */
- error = load_context->error;
- load_context->error = NULL;
-
- simple = load_context->simple;
-
- if (error == NULL)
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- else
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
-
- attachment_store_load_context_free (load_context);
-}
-
-void
-e_attachment_store_load_async (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- LoadContext *load_context;
- GList *iter;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
-
- load_context = attachment_store_load_context_new (
- store, attachment_list, callback, user_data);
-
- if (attachment_list == NULL) {
- GSimpleAsyncResult *simple;
-
- simple = load_context->simple;
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- g_simple_async_result_complete (simple);
-
- attachment_store_load_context_free (load_context);
- return;
- }
-
- for (iter = attachment_list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = E_ATTACHMENT (iter->data);
-
- e_attachment_store_add_attachment (store, attachment);
-
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- attachment_store_load_ready_cb,
- load_context);
- }
-}
-
-gboolean
-e_attachment_store_load_finish (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gboolean success;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), FALSE);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- success = g_simple_async_result_get_op_res_gboolean (simple);
- g_simple_async_result_propagate_error (simple, error);
-
- return success;
-}
-
-/********************** e_attachment_store_save_async() **********************/
-
-typedef struct _SaveContext SaveContext;
-
-struct _SaveContext {
- GSimpleAsyncResult *simple;
- GFile *destination;
- gchar *filename_prefix;
- GFile *fresh_directory;
- GFile *trash_directory;
- GList *attachment_list;
- GError *error;
- gchar **uris;
- gint index;
-};
-
-static SaveContext *
-attachment_store_save_context_new (EAttachmentStore *store,
- GFile *destination,
- const gchar *filename_prefix,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- SaveContext *save_context;
- GSimpleAsyncResult *simple;
- GList *attachment_list;
- guint length;
- gchar **uris;
-
- simple = g_simple_async_result_new (
- G_OBJECT (store), callback, user_data,
- e_attachment_store_save_async);
-
- attachment_list = e_attachment_store_get_attachments (store);
-
- /* Add one for NULL terminator. */
- length = g_list_length (attachment_list) + 1;
- uris = g_malloc0 (sizeof (gchar *) * length);
-
- save_context = g_slice_new0 (SaveContext);
- save_context->simple = simple;
- save_context->destination = g_object_ref (destination);
- save_context->filename_prefix = g_strdup (filename_prefix);
- save_context->attachment_list = attachment_list;
- save_context->uris = uris;
-
- return save_context;
-}
-
-static void
-attachment_store_save_context_free (SaveContext *save_context)
-{
- g_object_unref (save_context->simple);
-
- /* The attachment list should be empty now. */
- g_warn_if_fail (save_context->attachment_list == NULL);
-
- /* So should the error. */
- g_warn_if_fail (save_context->error == NULL);
-
- if (save_context->destination) {
- g_object_unref (save_context->destination);
- save_context->destination = NULL;
- }
-
- g_free (save_context->filename_prefix);
- save_context->filename_prefix = NULL;
-
- if (save_context->fresh_directory) {
- g_object_unref (save_context->fresh_directory);
- save_context->fresh_directory = NULL;
- }
-
- if (save_context->trash_directory) {
- g_object_unref (save_context->trash_directory);
- save_context->trash_directory = NULL;
- }
-
- g_strfreev (save_context->uris);
-
- g_slice_free (SaveContext, save_context);
-}
-
-static void
-attachment_store_move_file (SaveContext *save_context,
- GFile *source,
- GFile *destination,
- GError **error)
-{
- gchar *tmpl;
- gchar *path;
-
- g_return_if_fail (save_context != NULL);
- g_return_if_fail (source != NULL);
- g_return_if_fail (destination != NULL);
- g_return_if_fail (error != NULL);
-
- /* Attachments are all saved to a temporary directory.
- * Now we need to move the existing destination directory
- * out of the way (if it exists). Instead of testing for
- * existence we'll just attempt the move and ignore any
- * G_IO_ERROR_NOT_FOUND errors. */
-
- /* First, however, we need another temporary directory to
- * move the existing destination directory to. Note we're
- * not actually creating the directory yet, just picking a
- * name for it. The usual raciness with this approach
- * applies here (read up on mktemp(3)), but worst case is
- * we get a spurious G_IO_ERROR_WOULD_MERGE error and the
- * user has to try saving attachments again. */
- tmpl = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ());
- path = e_mktemp (tmpl);
- g_free (tmpl);
-
- save_context->trash_directory = g_file_new_for_path (path);
- g_free (path);
-
- /* XXX No asynchronous move operation in GIO? */
- g_file_move (
- destination,
- save_context->trash_directory,
- G_FILE_COPY_NONE, NULL, NULL, NULL, error);
-
- if (*error != NULL && !g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- return;
-
- g_clear_error (error);
-
- /* Now we can move the file from the temporary directory
- * to the user-specified destination. */
- g_file_move (
- source,
- destination,
- G_FILE_COPY_NONE, NULL, NULL, NULL, error);
-}
-
-static void
-attachment_store_save_cb (EAttachment *attachment,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- GSimpleAsyncResult *simple;
- GFile *file;
- gchar **uris;
- GError *error = NULL;
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- /* Remove the attachment from the list. */
- save_context->attachment_list = g_list_remove (
- save_context->attachment_list, attachment);
- g_object_unref (attachment);
-
- if (file != NULL) {
- /* Assemble the file's final URI from its basename. */
- gchar *basename;
- gchar *uri;
- GFile *source = NULL, *destination = NULL;
-
- basename = g_file_get_basename (file);
- g_object_unref (file);
-
- source = g_file_get_child (save_context->fresh_directory, basename);
-
- if (save_context->filename_prefix && *save_context->filename_prefix) {
- gchar *tmp = basename;
-
- basename = g_strconcat (save_context->filename_prefix, basename, NULL);
- g_free (tmp);
- }
-
- file = save_context->destination;
- destination = g_file_get_child (file, basename);
- uri = g_file_get_uri (destination);
-
- /* move them file-by-file */
- attachment_store_move_file (save_context, source, destination, &error);
-
- if (!error)
- save_context->uris[save_context->index++] = uri;
-
- g_object_unref (source);
- g_object_unref (destination);
- }
-
- if (error != NULL) {
- /* If this is the first error, cancel the other jobs. */
- if (save_context->error == NULL) {
- g_propagate_error (&save_context->error, error);
- g_list_foreach (
- save_context->attachment_list,
- (GFunc) e_attachment_cancel, NULL);
- error = NULL;
-
- /* Otherwise, we can only report back one error. So if
- * this is something other than cancellation, dump it to
- * the terminal. */
- } else if (!g_error_matches (
- error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("%s", error->message);
- }
-
- g_clear_error (&error);
-
- /* If there's still jobs running, let them finish. */
- if (save_context->attachment_list != NULL)
- return;
-
- /* If an error occurred while saving, we're done. */
- if (save_context->error != NULL) {
-
- /* Steal the error. */
- error = save_context->error;
- save_context->error = NULL;
-
- simple = save_context->simple;
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
-
- attachment_store_save_context_free (save_context);
- return;
- }
-
- if (error != NULL) {
- simple = save_context->simple;
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
-
- attachment_store_save_context_free (save_context);
- return;
- }
-
- /* clean-up left directory */
- g_file_delete (save_context->fresh_directory, NULL, NULL);
-
- /* And the URI list. */
- uris = save_context->uris;
- save_context->uris = NULL;
-
- simple = save_context->simple;
- g_simple_async_result_set_op_res_gpointer (simple, uris, NULL);
- g_simple_async_result_complete (simple);
-
- attachment_store_save_context_free (save_context);
-}
-/*
- * @filename_prefix: prefix to use for a file name; can be %NULL for none
- **/
-void
-e_attachment_store_save_async (EAttachmentStore *store,
- GFile *destination,
- const gchar *filename_prefix,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- SaveContext *save_context;
- GList *attachment_list, *iter;
- GFile *temp_directory;
- gchar *template;
- gchar *path;
-
- g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
- g_return_if_fail (G_IS_FILE (destination));
-
- save_context = attachment_store_save_context_new (
- store, destination, filename_prefix, callback, user_data);
-
- attachment_list = save_context->attachment_list;
-
- /* Deal with an empty attachment store. The caller will get
- * an empty NULL-terminated list as opposed to NULL, to help
- * distinguish it from an error. */
- if (attachment_list == NULL) {
- GSimpleAsyncResult *simple;
- gchar **uris;
-
- /* Steal the URI list. */
- uris = save_context->uris;
- save_context->uris = NULL;
-
- simple = save_context->simple;
- g_simple_async_result_set_op_res_gpointer (simple, uris, NULL);
- g_simple_async_result_complete (simple);
-
- attachment_store_save_context_free (save_context);
- return;
- }
-
- /* Save all attachments to a temporary directory, which we'll
- * then move to its proper location. We use a directory so
- * files can retain their basenames.
- * XXX This could trigger a blocking temp directory cleanup. */
- template = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ());
- path = e_mkdtemp (template);
- g_free (template);
-
- /* XXX Let's hope errno got set properly. */
- if (path == NULL) {
- GSimpleAsyncResult *simple;
-
- simple = save_context->simple;
- g_simple_async_result_set_error (
- simple, G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
- g_simple_async_result_complete (simple);
-
- attachment_store_save_context_free (save_context);
- return;
- }
-
- temp_directory = g_file_new_for_path (path);
- save_context->fresh_directory = temp_directory;
- g_free (path);
-
- for (iter = attachment_list; iter != NULL; iter = iter->next)
- e_attachment_save_async (
- E_ATTACHMENT (iter->data),
- temp_directory, (GAsyncReadyCallback)
- attachment_store_save_cb, save_context);
-}
-
-gchar **
-e_attachment_store_save_finish (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gchar **uris;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- uris = g_simple_async_result_get_op_res_gpointer (simple);
- g_simple_async_result_propagate_error (simple, error);
-
- return uris;
-}
diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h
deleted file mode 100644
index a963f0558f..0000000000
--- a/widgets/misc/e-attachment-store.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * e-attachment-store.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_STORE_H
-#define E_ATTACHMENT_STORE_H
-
-#include <gtk/gtk.h>
-#include <misc/e-attachment.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_STORE \
- (e_attachment_store_get_type ())
-#define E_ATTACHMENT_STORE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_STORE, EAttachmentStore))
-#define E_ATTACHMENT_STORE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_STORE, EAttachmentStoreClass))
-#define E_IS_ATTACHMENT_STORE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_STORE))
-#define E_IS_ATTACHMENT_STORE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_STORE))
-#define E_ATTACHMENT_STORE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_STORE, EAttachmentStoreClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentStore EAttachmentStore;
-typedef struct _EAttachmentStoreClass EAttachmentStoreClass;
-typedef struct _EAttachmentStorePrivate EAttachmentStorePrivate;
-
-struct _EAttachmentStore {
- GtkListStore parent;
- EAttachmentStorePrivate *priv;
-};
-
-struct _EAttachmentStoreClass {
- GtkListStoreClass parent_class;
-};
-
-enum {
- E_ATTACHMENT_STORE_COLUMN_ATTACHMENT, /* E_TYPE_ATTACHMENT */
- E_ATTACHMENT_STORE_COLUMN_CAPTION, /* G_TYPE_STRING */
- E_ATTACHMENT_STORE_COLUMN_CONTENT_TYPE, /* G_TYPE_STRING */
- E_ATTACHMENT_STORE_COLUMN_DESCRIPTION, /* G_TYPE_STRING */
- E_ATTACHMENT_STORE_COLUMN_ICON, /* G_TYPE_ICON */
- E_ATTACHMENT_STORE_COLUMN_LOADING, /* G_TYPE_BOOLEAN */
- E_ATTACHMENT_STORE_COLUMN_PERCENT, /* G_TYPE_INT */
- E_ATTACHMENT_STORE_COLUMN_SAVING, /* G_TYPE_BOOLEAN */
- E_ATTACHMENT_STORE_COLUMN_SIZE, /* G_TYPE_UINT64 */
- E_ATTACHMENT_STORE_NUM_COLUMNS
-};
-
-GType e_attachment_store_get_type (void);
-GtkTreeModel * e_attachment_store_new (void);
-void e_attachment_store_add_attachment
- (EAttachmentStore *store,
- EAttachment *attachment);
-gboolean e_attachment_store_remove_attachment
- (EAttachmentStore *store,
- EAttachment *attachment);
-void e_attachment_store_remove_all (EAttachmentStore *store);
-void e_attachment_store_add_to_multipart
- (EAttachmentStore *store,
- CamelMultipart *multipart,
- const gchar *default_charset);
-GList * e_attachment_store_get_attachments
- (EAttachmentStore *store);
-guint e_attachment_store_get_num_attachments
- (EAttachmentStore *store);
-guint e_attachment_store_get_num_loading
- (EAttachmentStore *store);
-goffset e_attachment_store_get_total_size
- (EAttachmentStore *store);
-void e_attachment_store_run_load_dialog
- (EAttachmentStore *store,
- GtkWindow *parent);
-GFile * e_attachment_store_run_save_dialog
- (EAttachmentStore *store,
- GList *attachment_list,
- GtkWindow *parent);
-
-/* Asynchronous Operations */
-void e_attachment_store_get_uris_async
- (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gchar ** e_attachment_store_get_uris_finish
- (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error);
-void e_attachment_store_load_async (EAttachmentStore *store,
- GList *attachment_list,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_attachment_store_load_finish (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error);
-void e_attachment_store_save_async (EAttachmentStore *store,
- GFile *destination,
- const gchar *filename_prefix,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gchar ** e_attachment_store_save_finish (EAttachmentStore *store,
- GAsyncResult *result,
- GError **error);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_STORE_H */
-
diff --git a/widgets/misc/e-attachment-tree-view.c b/widgets/misc/e-attachment-tree-view.c
deleted file mode 100644
index b73751fbbd..0000000000
--- a/widgets/misc/e-attachment-tree-view.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * e-attachment-tree-view.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-tree-view.h"
-
-#include <glib/gi18n.h>
-#include <libebackend/libebackend.h>
-
-#include "e-attachment.h"
-#include "e-attachment-store.h"
-#include "e-attachment-view.h"
-
-#define E_ATTACHMENT_TREE_VIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_TREE_VIEW, EAttachmentTreeViewPrivate))
-
-struct _EAttachmentTreeViewPrivate {
- EAttachmentViewPrivate view_priv;
-};
-
-enum {
- PROP_0,
- PROP_DRAGGING,
- PROP_EDITABLE
-};
-
-/* Forward Declarations */
-static void e_attachment_tree_view_interface_init
- (EAttachmentViewInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EAttachmentTreeView,
- e_attachment_tree_view,
- GTK_TYPE_TREE_VIEW,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ATTACHMENT_VIEW,
- e_attachment_tree_view_interface_init)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-static void
-attachment_tree_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DRAGGING:
- e_attachment_view_set_dragging (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EDITABLE:
- e_attachment_view_set_editable (
- E_ATTACHMENT_VIEW (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_tree_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DRAGGING:
- g_value_set_boolean (
- value, e_attachment_view_get_dragging (
- E_ATTACHMENT_VIEW (object)));
- return;
-
- case PROP_EDITABLE:
- g_value_set_boolean (
- value, e_attachment_view_get_editable (
- E_ATTACHMENT_VIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_tree_view_dispose (GObject *object)
-{
- e_attachment_view_dispose (E_ATTACHMENT_VIEW (object));
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_tree_view_parent_class)->dispose (object);
-}
-
-static void
-attachment_tree_view_finalize (GObject *object)
-{
- e_attachment_view_finalize (E_ATTACHMENT_VIEW (object));
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_attachment_tree_view_parent_class)->finalize (object);
-}
-
-static void
-attachment_tree_view_render_size (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- gchar *display_size = NULL;
- gint column_id;
- guint64 size;
-
- column_id = E_ATTACHMENT_STORE_COLUMN_SIZE;
- gtk_tree_model_get (model, iter, column_id, &size, -1);
-
- if (size > 0)
- display_size = g_format_size ((goffset) size);
-
- g_object_set (renderer, "text", display_size, NULL);
-
- g_free (display_size);
-}
-
-static gboolean
-attachment_tree_view_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_button_press_event (view, event))
- return TRUE;
-
- /* Chain up to parent's button_press_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- button_press_event (widget, event);
-}
-
-static gboolean
-attachment_tree_view_button_release_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_button_release_event (view, event))
- return TRUE;
-
- /* Chain up to parent's button_release_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- button_release_event (widget, event);
-}
-
-static gboolean
-attachment_tree_view_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_motion_notify_event (view, event))
- return TRUE;
-
- /* Chain up to parent's motion_notify_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- motion_notify_event (widget, event);
-}
-
-static gboolean
-attachment_tree_view_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (e_attachment_view_key_press_event (view, event))
- return TRUE;
-
- /* Chain up to parent's key_press_event() method. */
- return GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- key_press_event (widget, event);
-}
-
-static void
-attachment_tree_view_drag_begin (GtkWidget *widget,
- GdkDragContext *context)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- /* Chain up to parent's drag_begin() method. */
- GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- drag_begin (widget, context);
-
- e_attachment_view_drag_begin (view, context);
-}
-
-static void
-attachment_tree_view_drag_end (GtkWidget *widget,
- GdkDragContext *context)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- /* Chain up to parent's drag_end() method. */
- GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- drag_end (widget, context);
-
- e_attachment_view_drag_end (view, context);
-}
-
-static void
-attachment_tree_view_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_drag_data_get (
- view, context, selection, info, time);
-}
-
-static gboolean
-attachment_tree_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- return e_attachment_view_drag_motion (view, context, x, y, time);
-}
-
-static gboolean
-attachment_tree_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- if (!e_attachment_view_drag_drop (view, context, x, y, time))
- return FALSE;
-
- /* Chain up to parent's drag_drop() method. */
- return GTK_WIDGET_CLASS (e_attachment_tree_view_parent_class)->
- drag_drop (widget, context, x, y, time);
-}
-
-static void
-attachment_tree_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_drag_data_received (
- view, context, x, y, selection, info, time);
-}
-
-static gboolean
-attachment_tree_view_popup_menu (GtkWidget *widget)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
-
- e_attachment_view_show_popup_menu (view, NULL, NULL, NULL);
-
- return TRUE;
-}
-
-static void
-attachment_tree_view_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column)
-{
- EAttachmentView *view = E_ATTACHMENT_VIEW (tree_view);
-
- e_attachment_view_open_path (view, path, NULL);
-}
-
-static EAttachmentViewPrivate *
-attachment_tree_view_get_private (EAttachmentView *view)
-{
- EAttachmentTreeViewPrivate *priv;
-
- priv = E_ATTACHMENT_TREE_VIEW_GET_PRIVATE (view);
-
- return &priv->view_priv;
-}
-
-static EAttachmentStore *
-attachment_tree_view_get_store (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
- GtkTreeModel *model;
-
- tree_view = GTK_TREE_VIEW (view);
- model = gtk_tree_view_get_model (tree_view);
-
- return E_ATTACHMENT_STORE (model);
-}
-
-static GtkTreePath *
-attachment_tree_view_get_path_at_pos (EAttachmentView *view,
- gint x,
- gint y)
-{
- GtkTreeView *tree_view;
- GtkTreePath *path;
- gboolean row_exists;
-
- tree_view = GTK_TREE_VIEW (view);
-
- row_exists = gtk_tree_view_get_path_at_pos (
- tree_view, x, y, &path, NULL, NULL, NULL);
-
- return row_exists ? path : NULL;
-}
-
-static GList *
-attachment_tree_view_get_selected_paths (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- return gtk_tree_selection_get_selected_rows (selection, NULL);
-}
-
-static gboolean
-attachment_tree_view_path_is_selected (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- return gtk_tree_selection_path_is_selected (selection, path);
-}
-
-static void
-attachment_tree_view_select_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- gtk_tree_selection_select_path (selection, path);
-}
-
-static void
-attachment_tree_view_unselect_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- gtk_tree_selection_unselect_path (selection, path);
-}
-
-static void
-attachment_tree_view_select_all (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- gtk_tree_selection_select_all (selection);
-}
-
-static void
-attachment_tree_view_unselect_all (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- gtk_tree_selection_unselect_all (selection);
-}
-
-static void
-attachment_tree_view_drag_source_set (EAttachmentView *view,
- GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
-{
- GtkTreeView *tree_view;
-
- tree_view = GTK_TREE_VIEW (view);
-
- gtk_tree_view_enable_model_drag_source (
- tree_view, start_button_mask, targets, n_targets, actions);
-}
-
-static void
-attachment_tree_view_drag_dest_set (EAttachmentView *view,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
-{
- GtkTreeView *tree_view;
-
- tree_view = GTK_TREE_VIEW (view);
-
- gtk_tree_view_enable_model_drag_dest (
- tree_view, targets, n_targets, actions);
-}
-
-static void
-attachment_tree_view_drag_source_unset (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
-
- tree_view = GTK_TREE_VIEW (view);
-
- gtk_tree_view_unset_rows_drag_source (tree_view);
-}
-
-static void
-attachment_tree_view_drag_dest_unset (EAttachmentView *view)
-{
- GtkTreeView *tree_view;
-
- tree_view = GTK_TREE_VIEW (view);
-
- gtk_tree_view_unset_rows_drag_dest (tree_view);
-}
-
-static void
-e_attachment_tree_view_class_init (EAttachmentTreeViewClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkTreeViewClass *tree_view_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentViewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_tree_view_set_property;
- object_class->get_property = attachment_tree_view_get_property;
- object_class->dispose = attachment_tree_view_dispose;
- object_class->finalize = attachment_tree_view_finalize;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->button_press_event = attachment_tree_view_button_press_event;
- widget_class->button_release_event = attachment_tree_view_button_release_event;
- widget_class->motion_notify_event = attachment_tree_view_motion_notify_event;
- widget_class->key_press_event = attachment_tree_view_key_press_event;
- widget_class->drag_begin = attachment_tree_view_drag_begin;
- widget_class->drag_end = attachment_tree_view_drag_end;
- widget_class->drag_data_get = attachment_tree_view_drag_data_get;
- widget_class->drag_motion = attachment_tree_view_drag_motion;
- widget_class->drag_drop = attachment_tree_view_drag_drop;
- widget_class->drag_data_received = attachment_tree_view_drag_data_received;
- widget_class->popup_menu = attachment_tree_view_popup_menu;
-
- tree_view_class = GTK_TREE_VIEW_CLASS (class);
- tree_view_class->row_activated = attachment_tree_view_row_activated;
-
- g_object_class_override_property (
- object_class, PROP_DRAGGING, "dragging");
-
- g_object_class_override_property (
- object_class, PROP_EDITABLE, "editable");
-}
-
-static void
-e_attachment_tree_view_init (EAttachmentTreeView *tree_view)
-{
- GtkTreeSelection *selection;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- tree_view->priv = E_ATTACHMENT_TREE_VIEW_GET_PRIVATE (tree_view);
-
- e_attachment_view_init (E_ATTACHMENT_VIEW (tree_view));
-
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
-
- /* Name Column */
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_column_set_spacing (column, 3);
- gtk_tree_view_column_set_title (column, _("Description"));
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
-
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "gicon",
- E_ATTACHMENT_STORE_COLUMN_ICON);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "text",
- E_ATTACHMENT_STORE_COLUMN_DESCRIPTION);
-
- renderer = gtk_cell_renderer_progress_new ();
- g_object_set (renderer, "text", _("Loading"), NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "value",
- E_ATTACHMENT_STORE_COLUMN_PERCENT);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "visible",
- E_ATTACHMENT_STORE_COLUMN_LOADING);
-
- renderer = gtk_cell_renderer_progress_new ();
- g_object_set (renderer, "text", _("Saving"), NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "value",
- E_ATTACHMENT_STORE_COLUMN_PERCENT);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "visible",
- E_ATTACHMENT_STORE_COLUMN_SAVING);
-
- /* Size Column */
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Size"));
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
-
- gtk_tree_view_column_set_cell_data_func (
- column, renderer, (GtkTreeCellDataFunc)
- attachment_tree_view_render_size, NULL, NULL);
-
- /* Type Column */
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Type"));
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
-
- gtk_tree_view_column_add_attribute (
- column, renderer, "text",
- E_ATTACHMENT_STORE_COLUMN_CONTENT_TYPE);
-
- e_extensible_load_extensions (E_EXTENSIBLE (tree_view));
-}
-
-static void
-e_attachment_tree_view_interface_init (EAttachmentViewInterface *interface)
-{
- interface->get_private = attachment_tree_view_get_private;
- interface->get_store = attachment_tree_view_get_store;
-
- interface->get_path_at_pos = attachment_tree_view_get_path_at_pos;
- interface->get_selected_paths = attachment_tree_view_get_selected_paths;
- interface->path_is_selected = attachment_tree_view_path_is_selected;
- interface->select_path = attachment_tree_view_select_path;
- interface->unselect_path = attachment_tree_view_unselect_path;
- interface->select_all = attachment_tree_view_select_all;
- interface->unselect_all = attachment_tree_view_unselect_all;
-
- interface->drag_source_set = attachment_tree_view_drag_source_set;
- interface->drag_dest_set = attachment_tree_view_drag_dest_set;
- interface->drag_source_unset = attachment_tree_view_drag_source_unset;
- interface->drag_dest_unset = attachment_tree_view_drag_dest_unset;
-}
-
-GtkWidget *
-e_attachment_tree_view_new (void)
-{
- return g_object_new (E_TYPE_ATTACHMENT_TREE_VIEW, NULL);
-}
diff --git a/widgets/misc/e-attachment-tree-view.h b/widgets/misc/e-attachment-tree-view.h
deleted file mode 100644
index 4300ffa71f..0000000000
--- a/widgets/misc/e-attachment-tree-view.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * e-attachment-tree-view.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_TREE_VIEW_H
-#define E_ATTACHMENT_TREE_VIEW_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_TREE_VIEW \
- (e_attachment_tree_view_get_type ())
-#define E_ATTACHMENT_TREE_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_TREE_VIEW, EAttachmentTreeView))
-#define E_ATTACHMENT_TREE_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_TREE_VIEW, EAttachmentTreeViewClass))
-#define E_IS_ATTACHMENT_TREE_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_TREE_VIEW))
-#define E_IS_ATTACHMENT_TREE_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_TREE_VIEW))
-#define E_ATTACHMENT_TREE_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_TREE_VIEW, EAttachmentTreeViewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentTreeView EAttachmentTreeView;
-typedef struct _EAttachmentTreeViewClass EAttachmentTreeViewClass;
-typedef struct _EAttachmentTreeViewPrivate EAttachmentTreeViewPrivate;
-
-struct _EAttachmentTreeView {
- GtkTreeView parent;
- EAttachmentTreeViewPrivate *priv;
-};
-
-struct _EAttachmentTreeViewClass {
- GtkTreeViewClass parent_class;
-};
-
-GType e_attachment_tree_view_get_type (void);
-GtkWidget * e_attachment_tree_view_new (void);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_TREE_VIEW_H */
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c
deleted file mode 100644
index e8f9af8fdb..0000000000
--- a/widgets/misc/e-attachment-view.c
+++ /dev/null
@@ -1,1907 +0,0 @@
-/*
- * e-attachment-view.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment-view.h"
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-
-#include "e-util/e-selection.h"
-#include "e-util/e-ui-manager.h"
-#include "e-util/e-util.h"
-
-#include "e-attachment-dialog.h"
-#include "e-attachment-handler-image.h"
-#include "e-attachment-handler-sendto.h"
-
-enum {
- UPDATE_ACTIONS,
- LAST_SIGNAL
-};
-
-/* Note: Do not use the info field. */
-static GtkTargetEntry target_table[] = {
- { (gchar *) "_NETSCAPE_URL", 0, 0 }
-};
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <menuitem action='cancel'/>"
-" <menuitem action='save-as'/>"
-" <menuitem action='remove'/>"
-" <menuitem action='properties'/>"
-" <separator/>"
-" <placeholder name='inline-actions'>"
-" <menuitem action='show'/>"
-" <menuitem action='show-all'/>"
-" <separator/>"
-" <menuitem action='hide'/>"
-" <menuitem action='hide-all'/>"
-" </placeholder>"
-" <separator/>"
-" <placeholder name='custom-actions'/>"
-" <separator/>"
-" <menuitem action='add'/>"
-" <separator/>"
-" <placeholder name='open-actions'/>"
-" <menuitem action='open-with'/>"
-" </popup>"
-"</ui>";
-
-static gulong signals[LAST_SIGNAL];
-
-G_DEFINE_INTERFACE (
- EAttachmentView,
- e_attachment_view,
- GTK_TYPE_WIDGET)
-
-static void
-action_add_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachmentStore *store;
- gpointer parent;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- store = e_attachment_view_get_store (view);
- e_attachment_store_run_load_dialog (store, parent);
-}
-
-static void
-action_cancel_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachment *attachment;
- GList *list;
-
- list = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (list) == 1);
- attachment = list->data;
-
- e_attachment_cancel (attachment);
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_hide_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachment *attachment;
- GList *list;
-
- list = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (list) == 1);
- attachment = list->data;
-
- e_attachment_set_shown (attachment, FALSE);
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_hide_all_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachmentStore *store;
- GList *list, *iter;
-
- store = e_attachment_view_get_store (view);
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment;
-
- attachment = E_ATTACHMENT (iter->data);
- e_attachment_set_shown (attachment, FALSE);
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_open_with_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachment *attachment;
- EAttachmentStore *store;
- GtkWidget *dialog;
- GtkTreePath *path;
- GtkTreeIter iter;
- GAppInfo *app_info = NULL;
- GFileInfo *file_info;
- GList *list;
- gpointer parent;
- const gchar *content_type;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- list = e_attachment_view_get_selected_paths (view);
- g_return_if_fail (g_list_length (list) == 1);
- path = list->data;
-
- store = e_attachment_view_get_store (view);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
- gtk_tree_model_get (
- GTK_TREE_MODEL (store), &iter,
- E_ATTACHMENT_STORE_COLUMN_ATTACHMENT, &attachment, -1);
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- file_info = e_attachment_get_file_info (attachment);
- g_return_if_fail (file_info != NULL);
-
- content_type = g_file_info_get_content_type (file_info);
-
- dialog = gtk_app_chooser_dialog_new_for_content_type (
- parent, 0, content_type);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- GtkAppChooser *app_chooser = GTK_APP_CHOOSER (dialog);
- app_info = gtk_app_chooser_get_app_info (app_chooser);
- }
- gtk_widget_destroy (dialog);
-
- if (app_info != NULL) {
- e_attachment_view_open_path (view, path, app_info);
- g_object_unref (app_info);
- }
-
- g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (list);
-}
-
-static void
-action_open_with_app_info_cb (GtkAction *action,
- EAttachmentView *view)
-{
- GAppInfo *app_info;
- GtkTreePath *path;
- GList *list;
-
- list = e_attachment_view_get_selected_paths (view);
- g_return_if_fail (g_list_length (list) == 1);
- path = list->data;
-
- app_info = g_object_get_data (G_OBJECT (action), "app-info");
- g_return_if_fail (G_IS_APP_INFO (app_info));
-
- e_attachment_view_open_path (view, path, app_info);
-
- g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (list);
-}
-
-static void
-action_properties_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachment *attachment;
- GtkWidget *dialog;
- GList *list;
- gpointer parent;
-
- list = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (list) == 1);
- attachment = list->data;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- dialog = e_attachment_dialog_new (parent, attachment);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_remove_cb (GtkAction *action,
- EAttachmentView *view)
-{
- e_attachment_view_remove_selected (view, FALSE);
-}
-
-static void
-action_save_all_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachmentStore *store;
- GList *list, *iter;
- GFile *destination;
- gpointer parent;
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- /* XXX We lose the previous selection. */
- e_attachment_view_select_all (view);
- list = e_attachment_view_get_selected_attachments (view);
- e_attachment_view_unselect_all (view);
-
- destination = e_attachment_store_run_save_dialog (
- store, list, parent);
-
- if (destination == NULL)
- goto exit;
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- e_attachment_save_async (
- attachment, destination, (GAsyncReadyCallback)
- e_attachment_save_handle_error, parent);
- }
-
- g_object_unref (destination);
-
-exit:
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_save_as_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachmentStore *store;
- GList *list, *iter;
- GFile *destination;
- gpointer parent;
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- list = e_attachment_view_get_selected_attachments (view);
-
- destination = e_attachment_store_run_save_dialog (
- store, list, parent);
-
- if (destination == NULL)
- goto exit;
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
-
- e_attachment_save_async (
- attachment, destination, (GAsyncReadyCallback)
- e_attachment_save_handle_error, parent);
- }
-
- g_object_unref (destination);
-
-exit:
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_show_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachment *attachment;
- GList *list;
-
- list = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (list) == 1);
- attachment = list->data;
-
- e_attachment_set_shown (attachment, TRUE);
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-action_show_all_cb (GtkAction *action,
- EAttachmentView *view)
-{
- EAttachmentStore *store;
- GList *list, *iter;
-
- store = e_attachment_view_get_store (view);
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment;
-
- attachment = E_ATTACHMENT (iter->data);
- e_attachment_set_shown (attachment, TRUE);
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static GtkActionEntry standard_entries[] = {
-
- { "cancel",
- GTK_STOCK_CANCEL,
- NULL,
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_cancel_cb) },
-
- { "open-with",
- NULL,
- N_("Open With Other Application..."),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_open_with_cb) },
-
- { "save-all",
- GTK_STOCK_SAVE_AS,
- N_("S_ave All"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_save_all_cb) },
-
- { "save-as",
- GTK_STOCK_SAVE_AS,
- NULL,
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_save_as_cb) },
-
- /* Alternate "save-all" label, for when
- * the attachment store has one row. */
- { "save-one",
- GTK_STOCK_SAVE_AS,
- NULL,
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_save_all_cb) },
-};
-
-static GtkActionEntry editable_entries[] = {
-
- { "add",
- GTK_STOCK_ADD,
- N_("A_dd Attachment..."),
- NULL,
- N_("Attach a file"),
- G_CALLBACK (action_add_cb) },
-
- { "properties",
- GTK_STOCK_PROPERTIES,
- NULL,
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_properties_cb) },
-
- { "remove",
- GTK_STOCK_REMOVE,
- NULL,
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_remove_cb) }
-};
-
-static GtkActionEntry inline_entries[] = {
-
- { "hide",
- NULL,
- N_("_Hide"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_hide_cb) },
-
- { "hide-all",
- NULL,
- N_("Hid_e All"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_hide_all_cb) },
-
- { "show",
- NULL,
- N_("_View Inline"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_show_cb) },
-
- { "show-all",
- NULL,
- N_("Vie_w All Inline"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (action_show_all_cb) }
-};
-
-static void
-attachment_view_netscape_url (EAttachmentView *view,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- static GdkAtom atom = GDK_NONE;
- EAttachmentStore *store;
- EAttachment *attachment;
- const gchar *data;
- gpointer parent;
- gchar *copied_data;
- gchar **strv;
- gint length;
-
- if (G_UNLIKELY (atom == GDK_NONE))
- atom = gdk_atom_intern_static_string ("_NETSCAPE_URL");
-
- if (gtk_selection_data_get_target (selection_data) != atom)
- return;
-
- g_signal_stop_emission_by_name (view, "drag-data-received");
-
- /* _NETSCAPE_URL is represented as "URI\nTITLE" */
-
- data = (const gchar *) gtk_selection_data_get_data (selection_data);
- length = gtk_selection_data_get_length (selection_data);
-
- copied_data = g_strndup (data, length);
- strv = g_strsplit (copied_data, "\n", 2);
- g_free (copied_data);
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- attachment = e_attachment_new_for_uri (strv[0]);
- e_attachment_store_add_attachment (store, attachment);
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- g_object_unref (attachment);
-
- g_strfreev (strv);
-
- gtk_drag_finish (drag_context, TRUE, FALSE, time);
-}
-
-static void
-attachment_view_text_calendar (EAttachmentView *view,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- EAttachmentStore *store;
- EAttachment *attachment;
- CamelMimePart *mime_part;
- GdkAtom data_type;
- GdkAtom target;
- const gchar *data;
- gpointer parent;
- gchar *content_type;
- gint length;
-
- target = gtk_selection_data_get_target (selection_data);
- if (!e_targets_include_calendar (&target, 1))
- return;
-
- g_signal_stop_emission_by_name (view, "drag-data-received");
-
- data = (const gchar *) gtk_selection_data_get_data (selection_data);
- length = gtk_selection_data_get_length (selection_data);
- data_type = gtk_selection_data_get_data_type (selection_data);
-
- mime_part = camel_mime_part_new ();
-
- content_type = gdk_atom_name (data_type);
- camel_mime_part_set_content (mime_part, data, length, content_type);
- camel_mime_part_set_disposition (mime_part, "inline");
- g_free (content_type);
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- attachment = e_attachment_new ();
- e_attachment_set_mime_part (attachment, mime_part);
- e_attachment_store_add_attachment (store, attachment);
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- g_object_unref (attachment);
-
- g_object_unref (mime_part);
-
- gtk_drag_finish (drag_context, TRUE, FALSE, time);
-}
-
-static void
-attachment_view_text_x_vcard (EAttachmentView *view,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- EAttachmentStore *store;
- EAttachment *attachment;
- CamelMimePart *mime_part;
- GdkAtom data_type;
- GdkAtom target;
- const gchar *data;
- gpointer parent;
- gchar *content_type;
- gint length;
-
- target = gtk_selection_data_get_target (selection_data);
- if (!e_targets_include_directory (&target, 1))
- return;
-
- g_signal_stop_emission_by_name (view, "drag-data-received");
-
- data = (const gchar *) gtk_selection_data_get_data (selection_data);
- length = gtk_selection_data_get_length (selection_data);
- data_type = gtk_selection_data_get_data_type (selection_data);
-
- mime_part = camel_mime_part_new ();
-
- content_type = gdk_atom_name (data_type);
- camel_mime_part_set_content (mime_part, data, length, content_type);
- camel_mime_part_set_disposition (mime_part, "inline");
- g_free (content_type);
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- attachment = e_attachment_new ();
- e_attachment_set_mime_part (attachment, mime_part);
- e_attachment_store_add_attachment (store, attachment);
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- g_object_unref (attachment);
-
- g_object_unref (mime_part);
-
- gtk_drag_finish (drag_context, TRUE, FALSE, time);
-}
-
-static void
-attachment_view_uris (EAttachmentView *view,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- EAttachmentStore *store;
- gpointer parent;
- gchar **uris;
- gint ii;
-
- uris = gtk_selection_data_get_uris (selection_data);
-
- if (uris == NULL)
- return;
-
- g_signal_stop_emission_by_name (view, "drag-data-received");
-
- store = e_attachment_view_get_store (view);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- for (ii = 0; uris[ii] != NULL; ii++) {
- EAttachment *attachment;
-
- attachment = e_attachment_new_for_uri (uris[ii]);
- e_attachment_store_add_attachment (store, attachment);
- e_attachment_load_async (
- attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- g_object_unref (attachment);
- }
-
- g_strfreev (uris);
-
- gtk_drag_finish (drag_context, TRUE, FALSE, time);
-}
-
-static void
-attachment_view_update_actions (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
- EAttachment *attachment;
- EAttachmentStore *store;
- GtkActionGroup *action_group;
- GtkAction *action;
- GList *list, *iter;
- guint n_shown = 0;
- guint n_hidden = 0;
- guint n_selected;
- gboolean busy = FALSE;
- gboolean can_show = FALSE;
- gboolean shown = FALSE;
- gboolean visible;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- priv = e_attachment_view_get_private (view);
-
- store = e_attachment_view_get_store (view);
- list = e_attachment_store_get_attachments (store);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- attachment = iter->data;
-
- if (!e_attachment_get_can_show (attachment))
- continue;
-
- if (e_attachment_get_shown (attachment))
- n_shown++;
- else
- n_hidden++;
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-
- list = e_attachment_view_get_selected_attachments (view);
- n_selected = g_list_length (list);
-
- if (n_selected == 1) {
- attachment = g_object_ref (list->data);
- busy |= e_attachment_get_loading (attachment);
- busy |= e_attachment_get_saving (attachment);
- can_show = e_attachment_get_can_show (attachment);
- shown = e_attachment_get_shown (attachment);
- } else
- attachment = NULL;
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-
- action = e_attachment_view_get_action (view, "cancel");
- gtk_action_set_visible (action, busy);
-
- action = e_attachment_view_get_action (view, "hide");
- gtk_action_set_visible (action, can_show && shown);
-
- /* Show this action if there are multiple viewable
- * attachments, and at least one of them is shown. */
- visible = (n_shown + n_hidden > 1) && (n_shown > 0);
- action = e_attachment_view_get_action (view, "hide-all");
- gtk_action_set_visible (action, visible);
-
- action = e_attachment_view_get_action (view, "open-with");
- gtk_action_set_visible (action, !busy && n_selected == 1);
-
- action = e_attachment_view_get_action (view, "properties");
- gtk_action_set_visible (action, !busy && n_selected == 1);
-
- action = e_attachment_view_get_action (view, "remove");
- gtk_action_set_visible (action, !busy && n_selected > 0);
-
- action = e_attachment_view_get_action (view, "save-as");
- gtk_action_set_visible (action, !busy && n_selected > 0);
-
- action = e_attachment_view_get_action (view, "show");
- gtk_action_set_visible (action, can_show && !shown);
-
- /* Show this action if there are multiple viewable
- * attachments, and at least one of them is hidden. */
- visible = (n_shown + n_hidden > 1) && (n_hidden > 0);
- action = e_attachment_view_get_action (view, "show-all");
- gtk_action_set_visible (action, visible);
-
- /* Clear out the "openwith" action group. */
- gtk_ui_manager_remove_ui (priv->ui_manager, priv->merge_id);
- action_group = e_attachment_view_get_action_group (view, "openwith");
- e_action_group_remove_all_actions (action_group);
- gtk_ui_manager_ensure_update (priv->ui_manager);
-
- if (attachment == NULL || busy)
- return;
-
- list = e_attachment_list_apps (attachment);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- GAppInfo *app_info = iter->data;
- GtkAction *action;
- GIcon *app_icon;
- const gchar *app_executable;
- const gchar *app_name;
- gchar *action_tooltip;
- gchar *action_label;
- gchar *action_name;
-
- app_executable = g_app_info_get_executable (app_info);
- app_icon = g_app_info_get_icon (app_info);
- app_name = g_app_info_get_name (app_info);
-
- action_name = g_strdup_printf ("open-with-%s", app_executable);
- action_label = g_strdup_printf (_("Open With \"%s\""), app_name);
-
- action_tooltip = g_strdup_printf (
- _("Open this attachment in %s"), app_name);
-
- action = gtk_action_new (
- action_name, action_label, action_tooltip, NULL);
-
- gtk_action_set_gicon (action, app_icon);
-
- g_object_set_data_full (
- G_OBJECT (action),
- "app-info", g_object_ref (app_info),
- (GDestroyNotify) g_object_unref);
-
- g_object_set_data_full (
- G_OBJECT (action),
- "attachment", g_object_ref (attachment),
- (GDestroyNotify) g_object_unref);
-
- g_signal_connect (
- action, "activate",
- G_CALLBACK (action_open_with_app_info_cb), view);
-
- gtk_action_group_add_action (action_group, action);
-
- gtk_ui_manager_add_ui (
- priv->ui_manager, priv->merge_id,
- "/context/open-actions", action_name,
- action_name, GTK_UI_MANAGER_AUTO, FALSE);
-
- g_free (action_name);
- g_free (action_label);
- g_free (action_tooltip);
- }
-
- g_object_unref (attachment);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static void
-attachment_view_init_drag_dest (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
- GtkTargetList *target_list;
-
- priv = e_attachment_view_get_private (view);
-
- target_list = gtk_target_list_new (
- target_table, G_N_ELEMENTS (target_table));
-
- gtk_target_list_add_uri_targets (target_list, 0);
- e_target_list_add_calendar_targets (target_list, 0);
- e_target_list_add_directory_targets (target_list, 0);
-
- priv->target_list = target_list;
- priv->drag_actions = GDK_ACTION_COPY;
-}
-
-static void
-e_attachment_view_default_init (EAttachmentViewInterface *interface)
-{
- interface->update_actions = attachment_view_update_actions;
-
- g_object_interface_install_property (
- interface,
- g_param_spec_boolean (
- "dragging",
- "Dragging",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_interface_install_property (
- interface,
- g_param_spec_boolean (
- "editable",
- "Editable",
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- signals[UPDATE_ACTIONS] = g_signal_new (
- "update-actions",
- G_TYPE_FROM_INTERFACE (interface),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EAttachmentViewInterface, update_actions),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /* Register known handler types. */
- e_attachment_handler_image_get_type ();
- e_attachment_handler_sendto_get_type ();
-}
-
-void
-e_attachment_view_init (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
- GtkUIManager *ui_manager;
- GtkActionGroup *action_group;
- GError *error = NULL;
-
- priv = e_attachment_view_get_private (view);
-
- ui_manager = e_ui_manager_new ();
- priv->merge_id = gtk_ui_manager_new_merge_id (ui_manager);
- priv->ui_manager = ui_manager;
-
- action_group = e_attachment_view_add_action_group (view, "standard");
-
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), view);
-
- action_group = e_attachment_view_add_action_group (view, "editable");
-
- g_object_bind_property (
- view, "editable",
- action_group, "visible",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
- gtk_action_group_add_actions (
- action_group, editable_entries,
- G_N_ELEMENTS (editable_entries), view);
-
- action_group = e_attachment_view_add_action_group (view, "inline");
-
- gtk_action_group_add_actions (
- action_group, inline_entries,
- G_N_ELEMENTS (inline_entries), view);
- gtk_action_group_set_visible (action_group, FALSE);
-
- e_attachment_view_add_action_group (view, "openwith");
-
- /* Because we are loading from a hard-coded string, there is
- * no chance of I/O errors. Failure here implies a malformed
- * UI definition. Full stop. */
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- if (error != NULL)
- g_error ("%s", error->message);
-
- attachment_view_init_drag_dest (view);
-
- e_attachment_view_drag_source_set (view);
-
- /* Connect built-in drag and drop handlers. */
-
- g_signal_connect (
- view, "drag-data-received",
- G_CALLBACK (attachment_view_netscape_url), NULL);
-
- g_signal_connect (
- view, "drag-data-received",
- G_CALLBACK (attachment_view_text_calendar), NULL);
-
- g_signal_connect (
- view, "drag-data-received",
- G_CALLBACK (attachment_view_text_x_vcard), NULL);
-
- g_signal_connect (
- view, "drag-data-received",
- G_CALLBACK (attachment_view_uris), NULL);
-}
-
-void
-e_attachment_view_dispose (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- priv = e_attachment_view_get_private (view);
-
- if (priv->target_list != NULL) {
- gtk_target_list_unref (priv->target_list);
- priv->target_list = NULL;
- }
-
- if (priv->ui_manager != NULL) {
- g_object_unref (priv->ui_manager);
- priv->ui_manager = NULL;
- }
-}
-
-void
-e_attachment_view_finalize (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- priv = e_attachment_view_get_private (view);
-
- g_list_foreach (priv->event_list, (GFunc) gdk_event_free, NULL);
- g_list_free (priv->event_list);
-
- g_list_foreach (priv->selected, (GFunc) g_object_unref, NULL);
- g_list_free (priv->selected);
-}
-
-EAttachmentViewPrivate *
-e_attachment_view_get_private (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_val_if_fail (interface->get_private != NULL, NULL);
-
- return interface->get_private (view);
-}
-
-EAttachmentStore *
-e_attachment_view_get_store (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_val_if_fail (interface->get_store != NULL, NULL);
-
- return interface->get_store (view);
-}
-
-gboolean
-e_attachment_view_get_editable (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- return priv->editable;
-}
-
-void
-e_attachment_view_set_editable (EAttachmentView *view,
- gboolean editable)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- priv = e_attachment_view_get_private (view);
-
- priv->editable = editable;
-
- if (editable)
- e_attachment_view_drag_dest_set (view);
- else
- e_attachment_view_drag_dest_unset (view);
-
- g_object_notify (G_OBJECT (view), "editable");
-}
-
-gboolean
-e_attachment_view_get_dragging (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- return priv->dragging;
-}
-
-void
-e_attachment_view_set_dragging (EAttachmentView *view,
- gboolean dragging)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- priv = e_attachment_view_get_private (view);
-
- priv->dragging = dragging;
-
- g_object_notify (G_OBJECT (view), "dragging");
-}
-
-GtkTargetList *
-e_attachment_view_get_target_list (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- priv = e_attachment_view_get_private (view);
-
- return priv->target_list;
-}
-
-GdkDragAction
-e_attachment_view_get_drag_actions (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), 0);
-
- priv = e_attachment_view_get_private (view);
-
- return priv->drag_actions;
-}
-
-void
-e_attachment_view_add_drag_actions (EAttachmentView *view,
- GdkDragAction drag_actions)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- priv = e_attachment_view_get_private (view);
-
- priv->drag_actions |= drag_actions;
-}
-
-GList *
-e_attachment_view_get_selected_attachments (EAttachmentView *view)
-{
- EAttachmentStore *store;
- GtkTreeModel *model;
- GList *list, *item;
- gint column_id;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT;
- list = e_attachment_view_get_selected_paths (view);
- store = e_attachment_view_get_store (view);
- model = GTK_TREE_MODEL (store);
-
- /* Convert the GtkTreePaths to EAttachments. */
- for (item = list; item != NULL; item = item->next) {
- EAttachment *attachment;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = item->data;
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, column_id, &attachment, -1);
- gtk_tree_path_free (path);
-
- item->data = attachment;
- }
-
- return list;
-}
-
-void
-e_attachment_view_open_path (EAttachmentView *view,
- GtkTreePath *path,
- GAppInfo *app_info)
-{
- EAttachmentStore *store;
- EAttachment *attachment;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer parent;
- gint column_id;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (path != NULL);
-
- column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT;
- store = e_attachment_view_get_store (view);
- model = GTK_TREE_MODEL (store);
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, column_id, &attachment, -1);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- e_attachment_open_async (
- attachment, app_info, (GAsyncReadyCallback)
- e_attachment_open_handle_error, parent);
-
- g_object_unref (attachment);
-}
-
-void
-e_attachment_view_remove_selected (EAttachmentView *view,
- gboolean select_next)
-{
- EAttachmentStore *store;
- GtkTreeModel *model;
- GList *list, *item;
- gint column_id;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT;
- list = e_attachment_view_get_selected_paths (view);
- store = e_attachment_view_get_store (view);
- model = GTK_TREE_MODEL (store);
-
- /* Remove attachments in reverse order to avoid invalidating
- * tree paths as we iterate over the list. Note, the list is
- * probably already sorted but we sort again just to be safe. */
- list = g_list_reverse (g_list_sort (
- list, (GCompareFunc) gtk_tree_path_compare));
-
- for (item = list; item != NULL; item = item->next) {
- EAttachment *attachment;
- GtkTreePath *path = item->data;
- GtkTreeIter iter;
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, column_id, &attachment, -1);
- e_attachment_store_remove_attachment (store, attachment);
- g_object_unref (attachment);
- }
-
- /* If we only removed one attachment, try to select another. */
- if (select_next && g_list_length (list) == 1) {
- GtkTreePath *path = list->data;
-
- e_attachment_view_select_path (view, path);
- if (!e_attachment_view_path_is_selected (view, path))
- if (gtk_tree_path_prev (path))
- e_attachment_view_select_path (view, path);
- }
-
- g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (list);
-}
-
-gboolean
-e_attachment_view_button_press_event (EAttachmentView *view,
- GdkEventButton *event)
-{
- EAttachmentViewPrivate *priv;
- GtkTreePath *path;
- gboolean editable;
- gboolean handled = FALSE;
- gboolean path_is_selected = FALSE;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- if (g_list_find (priv->event_list, event) != NULL)
- return FALSE;
-
- if (priv->event_list != NULL) {
- /* Save the event to be propagated in order. */
- priv->event_list = g_list_append (
- priv->event_list,
- gdk_event_copy ((GdkEvent *) event));
- return TRUE;
- }
-
- editable = e_attachment_view_get_editable (view);
- path = e_attachment_view_get_path_at_pos (view, event->x, event->y);
- path_is_selected = e_attachment_view_path_is_selected (view, path);
-
- if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
- GList *list, *iter;
- gboolean busy = FALSE;
-
- list = e_attachment_view_get_selected_attachments (view);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- EAttachment *attachment = iter->data;
- busy |= e_attachment_get_loading (attachment);
- busy |= e_attachment_get_saving (attachment);
- }
-
- /* Prepare for dragging if the clicked item is selected
- * and none of the selected items are loading or saving. */
- if (path_is_selected && !busy) {
- priv->start_x = event->x;
- priv->start_y = event->y;
- priv->event_list = g_list_append (
- priv->event_list,
- gdk_event_copy ((GdkEvent *) event));
- handled = TRUE;
- }
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
- }
-
- if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
- /* If the user clicked on a selected item, retain the
- * current selection. If the user clicked on an unselected
- * item, select the clicked item only. If the user did not
- * click on an item, clear the current selection. */
- if (path == NULL)
- e_attachment_view_unselect_all (view);
- else if (!path_is_selected) {
- e_attachment_view_unselect_all (view);
- e_attachment_view_select_path (view, path);
- }
-
- /* Non-editable attachment views should only show a
- * popup menu when right-clicking on an attachment,
- * but editable views can show the menu any time. */
- if (path != NULL || editable) {
- e_attachment_view_show_popup_menu (
- view, event, NULL, NULL);
- handled = TRUE;
- }
- }
-
- if (path != NULL)
- gtk_tree_path_free (path);
-
- return handled;
-}
-
-gboolean
-e_attachment_view_button_release_event (EAttachmentView *view,
- GdkEventButton *event)
-{
- EAttachmentViewPrivate *priv;
- GtkWidget *widget = GTK_WIDGET (view);
- GList *iter;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- for (iter = priv->event_list; iter != NULL; iter = iter->next) {
- GdkEvent *event = iter->data;
-
- gtk_propagate_event (widget, event);
- gdk_event_free (event);
- }
-
- g_list_free (priv->event_list);
- priv->event_list = NULL;
-
- return FALSE;
-}
-
-gboolean
-e_attachment_view_motion_notify_event (EAttachmentView *view,
- GdkEventMotion *event)
-{
- EAttachmentViewPrivate *priv;
- GtkWidget *widget = GTK_WIDGET (view);
- GtkTargetList *targets;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- if (priv->event_list == NULL)
- return FALSE;
-
- if (!gtk_drag_check_threshold (
- widget, priv->start_x, priv->start_y, event->x, event->y))
- return TRUE;
-
- g_list_foreach (priv->event_list, (GFunc) gdk_event_free, NULL);
- g_list_free (priv->event_list);
- priv->event_list = NULL;
-
- targets = gtk_drag_source_get_target_list (widget);
-
- gtk_drag_begin (
- widget, targets, GDK_ACTION_COPY, 1, (GdkEvent *) event);
-
- return TRUE;
-}
-
-gboolean
-e_attachment_view_key_press_event (EAttachmentView *view,
- GdkEventKey *event)
-{
- gboolean editable;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- editable = e_attachment_view_get_editable (view);
-
- if (event->keyval == GDK_KEY_Delete && editable) {
- e_attachment_view_remove_selected (view, TRUE);
- return TRUE;
- }
-
- return FALSE;
-}
-
-GtkTreePath *
-e_attachment_view_get_path_at_pos (EAttachmentView *view,
- gint x,
- gint y)
-{
- EAttachmentViewInterface *interface;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_val_if_fail (interface->get_path_at_pos != NULL, NULL);
-
- return interface->get_path_at_pos (view, x, y);
-}
-
-GList *
-e_attachment_view_get_selected_paths (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_val_if_fail (interface->get_selected_paths != NULL, NULL);
-
- return interface->get_selected_paths (view);
-}
-
-gboolean
-e_attachment_view_path_is_selected (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentViewInterface *interface;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
-
- /* Handle NULL paths gracefully. */
- if (path == NULL)
- return FALSE;
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_val_if_fail (interface->path_is_selected != NULL, FALSE);
-
- return interface->path_is_selected (view, path);
-}
-
-void
-e_attachment_view_select_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (path != NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_if_fail (interface->select_path != NULL);
-
- interface->select_path (view, path);
-}
-
-void
-e_attachment_view_unselect_path (EAttachmentView *view,
- GtkTreePath *path)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (path != NULL);
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_if_fail (interface->unselect_path != NULL);
-
- interface->unselect_path (view, path);
-}
-
-void
-e_attachment_view_select_all (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_if_fail (interface->select_all != NULL);
-
- interface->select_all (view);
-}
-
-void
-e_attachment_view_unselect_all (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- g_return_if_fail (interface->unselect_all != NULL);
-
- interface->unselect_all (view);
-}
-
-void
-e_attachment_view_sync_selection (EAttachmentView *view,
- EAttachmentView *target)
-{
- GList *list, *iter;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (target));
-
- list = e_attachment_view_get_selected_paths (view);
- e_attachment_view_unselect_all (target);
-
- for (iter = list; iter != NULL; iter = iter->next)
- e_attachment_view_select_path (target, iter->data);
-
- g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (list);
-}
-
-void
-e_attachment_view_drag_source_set (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
- GtkTargetEntry *targets;
- GtkTargetList *list;
- gint n_targets;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- if (interface->drag_source_set == NULL)
- return;
-
- list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (list, 0);
- targets = gtk_target_table_new_from_list (list, &n_targets);
-
- interface->drag_source_set (
- view, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (list);
-}
-
-void
-e_attachment_view_drag_source_unset (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- if (interface->drag_source_unset == NULL)
- return;
-
- interface->drag_source_unset (view);
-}
-
-void
-e_attachment_view_drag_begin (EAttachmentView *view,
- GdkDragContext *context)
-{
- EAttachmentViewPrivate *priv;
- guint n_selected;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-
- priv = e_attachment_view_get_private (view);
-
- e_attachment_view_set_dragging (view, TRUE);
-
- g_warn_if_fail (priv->selected == NULL);
- priv->selected = e_attachment_view_get_selected_attachments (view);
- n_selected = g_list_length (priv->selected);
-
- if (n_selected > 1)
- gtk_drag_set_icon_stock (
- context, GTK_STOCK_DND_MULTIPLE, 0, 0);
-
- else if (n_selected == 1) {
- EAttachment *attachment;
- GtkIconTheme *icon_theme;
- GtkIconInfo *icon_info;
- GIcon *icon;
- gint width, height;
-
- attachment = E_ATTACHMENT (priv->selected->data);
- icon = e_attachment_get_icon (attachment);
- g_return_if_fail (icon != NULL);
-
- icon_theme = gtk_icon_theme_get_default ();
- gtk_icon_size_lookup (GTK_ICON_SIZE_DND, &width, &height);
-
- icon_info = gtk_icon_theme_lookup_by_gicon (
- icon_theme, icon, MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
-
- if (icon_info != NULL) {
- GdkPixbuf *pixbuf;
- GError *error = NULL;
-
- pixbuf = gtk_icon_info_load_icon (icon_info, &error);
-
- if (pixbuf != NULL) {
- gtk_drag_set_icon_pixbuf (
- context, pixbuf, 0, 0);
- g_object_unref (pixbuf);
- } else if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- gtk_icon_info_free (icon_info);
- }
- }
-}
-
-void
-e_attachment_view_drag_end (EAttachmentView *view,
- GdkDragContext *context)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-
- priv = e_attachment_view_get_private (view);
-
- e_attachment_view_set_dragging (view, FALSE);
-
- g_list_foreach (priv->selected, (GFunc) g_object_unref, NULL);
- g_list_free (priv->selected);
- priv->selected = NULL;
-}
-
-static void
-attachment_view_got_uris_cb (EAttachmentStore *store,
- GAsyncResult *result,
- gpointer user_data)
-{
- struct {
- gchar **uris;
- gboolean done;
- } *status = user_data;
-
- /* XXX Since this is a best-effort function,
- * should we care about errors? */
- status->uris = e_attachment_store_get_uris_finish (
- store, result, NULL);
-
- status->done = TRUE;
-}
-
-void
-e_attachment_view_drag_data_get (EAttachmentView *view,
- GdkDragContext *context,
- GtkSelectionData *selection,
- guint info,
- guint time)
-{
- EAttachmentViewPrivate *priv;
- EAttachmentStore *store;
-
- struct {
- gchar **uris;
- gboolean done;
- } status;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
- g_return_if_fail (selection != NULL);
-
- status.uris = NULL;
- status.done = FALSE;
-
- priv = e_attachment_view_get_private (view);
- store = e_attachment_view_get_store (view);
-
- if (priv->selected == NULL)
- return;
-
- e_attachment_store_get_uris_async (
- store, priv->selected, (GAsyncReadyCallback)
- attachment_view_got_uris_cb, &status);
-
- /* We can't return until we have results, so crank
- * the main loop until the callback gets triggered. */
- while (!status.done)
- if (gtk_main_iteration ())
- break;
-
- if (status.uris != NULL)
- gtk_selection_data_set_uris (selection, status.uris);
-
- g_strfreev (status.uris);
-}
-
-void
-e_attachment_view_drag_dest_set (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
- EAttachmentViewInterface *interface;
- GtkTargetEntry *targets;
- gint n_targets;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- if (interface->drag_dest_set == NULL)
- return;
-
- priv = e_attachment_view_get_private (view);
-
- targets = gtk_target_table_new_from_list (
- priv->target_list, &n_targets);
-
- interface->drag_dest_set (
- view, targets, n_targets, priv->drag_actions);
-
- gtk_target_table_free (targets, n_targets);
-}
-
-void
-e_attachment_view_drag_dest_unset (EAttachmentView *view)
-{
- EAttachmentViewInterface *interface;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- interface = E_ATTACHMENT_VIEW_GET_INTERFACE (view);
- if (interface->drag_dest_unset == NULL)
- return;
-
- interface->drag_dest_unset (view);
-}
-
-gboolean
-e_attachment_view_drag_motion (EAttachmentView *view,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EAttachmentViewPrivate *priv;
- GdkDragAction actions;
- GdkDragAction chosen_action;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
-
- priv = e_attachment_view_get_private (view);
-
- /* Disallow drops if we're not editable. */
- if (!e_attachment_view_get_editable (view))
- return FALSE;
-
- /* Disallow drops if we initiated the drag.
- * This helps prevent duplicate attachments. */
- if (e_attachment_view_get_dragging (view))
- return FALSE;
-
- actions = gdk_drag_context_get_actions (context);
- actions &= priv->drag_actions;
- chosen_action = gdk_drag_context_get_suggested_action (context);
-
- if (chosen_action == GDK_ACTION_ASK) {
- GdkDragAction mask;
-
- mask = GDK_ACTION_COPY | GDK_ACTION_MOVE;
- if ((actions & mask) != mask)
- chosen_action = GDK_ACTION_COPY;
- }
-
- gdk_drag_status (context, chosen_action, time);
-
- return (chosen_action != 0);
-}
-
-gboolean
-e_attachment_view_drag_drop (EAttachmentView *view,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
- g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
-
- /* Disallow drops if we initiated the drag.
- * This helps prevent duplicate attachments. */
- return !e_attachment_view_get_dragging (view);
-}
-
-void
-e_attachment_view_drag_data_received (EAttachmentView *view,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- GdkAtom atom;
- gchar *name;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (drag_context));
-
- /* Drop handlers are supposed to stop further emission of the
- * "drag-data-received" signal if they can handle the data. If
- * we get this far it means none of the handlers were successful,
- * so report the drop as failed. */
-
- atom = gtk_selection_data_get_target (selection_data);
-
- name = gdk_atom_name (atom);
- g_warning ("Unknown selection target: %s", name);
- g_free (name);
-
- gtk_drag_finish (drag_context, FALSE, FALSE, time);
-}
-
-GtkAction *
-e_attachment_view_get_action (EAttachmentView *view,
- const gchar *action_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
- g_return_val_if_fail (action_name != NULL, NULL);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
-
- return e_lookup_action (ui_manager, action_name);
-}
-
-GtkActionGroup *
-e_attachment_view_add_action_group (EAttachmentView *view,
- const gchar *group_name)
-{
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
- const gchar *domain;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
- g_return_val_if_fail (group_name != NULL, NULL);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
- domain = GETTEXT_PACKAGE;
-
- action_group = gtk_action_group_new (group_name);
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- return action_group;
-}
-
-GtkActionGroup *
-e_attachment_view_get_action_group (EAttachmentView *view,
- const gchar *group_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
- g_return_val_if_fail (group_name != NULL, NULL);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
-
- return e_lookup_action_group (ui_manager, group_name);
-}
-
-GtkWidget *
-e_attachment_view_get_popup_menu (EAttachmentView *view)
-{
- GtkUIManager *ui_manager;
- GtkWidget *menu;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
- menu = gtk_ui_manager_get_widget (ui_manager, "/context");
- g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
-
- return menu;
-}
-
-GtkUIManager *
-e_attachment_view_get_ui_manager (EAttachmentView *view)
-{
- EAttachmentViewPrivate *priv;
-
- g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
- priv = e_attachment_view_get_private (view);
-
- return priv->ui_manager;
-}
-
-void
-e_attachment_view_show_popup_menu (EAttachmentView *view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data)
-{
- GtkWidget *menu;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- e_attachment_view_update_actions (view);
-
- menu = e_attachment_view_get_popup_menu (view);
-
- if (event != NULL)
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, event->button, event->time);
- else
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, 0, gtk_get_current_event_time ());
-}
-
-void
-e_attachment_view_update_actions (EAttachmentView *view)
-{
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- g_signal_emit (view, signals[UPDATE_ACTIONS], 0);
-}
diff --git a/widgets/misc/e-attachment-view.h b/widgets/misc/e-attachment-view.h
deleted file mode 100644
index 87274d0c63..0000000000
--- a/widgets/misc/e-attachment-view.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * e-attachment-view.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_VIEW_H
-#define E_ATTACHMENT_VIEW_H
-
-#include <gtk/gtk.h>
-#include <misc/e-attachment-store.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_VIEW \
- (e_attachment_view_get_type ())
-#define E_ATTACHMENT_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_VIEW, EAttachmentView))
-#define E_ATTACHMENT_VIEW_INTERFACE(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_VIEW, EAttachmentViewInterface))
-#define E_IS_ATTACHMENT_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_VIEW))
-#define E_IS_ATTACHMENT_VIEW_INTERFACE(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_VIEW))
-#define E_ATTACHMENT_VIEW_GET_INTERFACE(obj) \
- (G_TYPE_INSTANCE_GET_INTERFACE \
- ((obj), E_TYPE_ATTACHMENT_VIEW, EAttachmentViewInterface))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentView EAttachmentView;
-typedef struct _EAttachmentViewInterface EAttachmentViewInterface;
-typedef struct _EAttachmentViewPrivate EAttachmentViewPrivate;
-
-struct _EAttachmentViewInterface {
- GTypeInterface parent_interface;
-
- /* General Methods */
- EAttachmentViewPrivate *
- (*get_private) (EAttachmentView *view);
- EAttachmentStore *
- (*get_store) (EAttachmentView *view);
-
- /* Selection Methods */
- GtkTreePath * (*get_path_at_pos) (EAttachmentView *view,
- gint x,
- gint y);
- GList * (*get_selected_paths) (EAttachmentView *view);
- gboolean (*path_is_selected) (EAttachmentView *view,
- GtkTreePath *path);
- void (*select_path) (EAttachmentView *view,
- GtkTreePath *path);
- void (*unselect_path) (EAttachmentView *view,
- GtkTreePath *path);
- void (*select_all) (EAttachmentView *view);
- void (*unselect_all) (EAttachmentView *view);
-
- /* Drag and Drop Methods */
- void (*drag_source_set) (EAttachmentView *view,
- GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions);
- void (*drag_dest_set) (EAttachmentView *view,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions);
- void (*drag_source_unset) (EAttachmentView *view);
- void (*drag_dest_unset) (EAttachmentView *view);
-
- /* Signals */
- void (*update_actions) (EAttachmentView *view);
-};
-
-struct _EAttachmentViewPrivate {
-
- /* Drag Destination */
- GtkTargetList *target_list;
- GdkDragAction drag_actions;
-
- /* Popup Menu Management */
- GtkUIManager *ui_manager;
- guint merge_id;
-
- /* Multi-DnD State */
- GList *event_list;
- GList *selected;
- gint start_x;
- gint start_y;
-
- guint dragging : 1;
- guint editable : 1;
-};
-
-GType e_attachment_view_get_type (void);
-
-void e_attachment_view_init (EAttachmentView *view);
-void e_attachment_view_dispose (EAttachmentView *view);
-void e_attachment_view_finalize (EAttachmentView *view);
-
-EAttachmentViewPrivate *
- e_attachment_view_get_private (EAttachmentView *view);
-EAttachmentStore *
- e_attachment_view_get_store (EAttachmentView *view);
-gboolean e_attachment_view_get_dragging (EAttachmentView *view);
-void e_attachment_view_set_dragging (EAttachmentView *view,
- gboolean dragging);
-gboolean e_attachment_view_get_editable (EAttachmentView *view);
-void e_attachment_view_set_editable (EAttachmentView *view,
- gboolean editable);
-GtkTargetList * e_attachment_view_get_target_list
- (EAttachmentView *view);
-GdkDragAction e_attachment_view_get_drag_actions
- (EAttachmentView *view);
-void e_attachment_view_add_drag_actions
- (EAttachmentView *view,
- GdkDragAction drag_actions);
-GList * e_attachment_view_get_selected_attachments
- (EAttachmentView *view);
-void e_attachment_view_open_path (EAttachmentView *view,
- GtkTreePath *path,
- GAppInfo *app_info);
-void e_attachment_view_remove_selected
- (EAttachmentView *view,
- gboolean select_next);
-
-/* Event Support */
-gboolean e_attachment_view_button_press_event
- (EAttachmentView *view,
- GdkEventButton *event);
-gboolean e_attachment_view_button_release_event
- (EAttachmentView *view,
- GdkEventButton *event);
-gboolean e_attachment_view_motion_notify_event
- (EAttachmentView *view,
- GdkEventMotion *event);
-gboolean e_attachment_view_key_press_event
- (EAttachmentView *view,
- GdkEventKey *event);
-
-/* Selection Management */
-GtkTreePath * e_attachment_view_get_path_at_pos
- (EAttachmentView *view,
- gint x,
- gint y);
-GList * e_attachment_view_get_selected_paths
- (EAttachmentView *view);
-gboolean e_attachment_view_path_is_selected
- (EAttachmentView *view,
- GtkTreePath *path);
-void e_attachment_view_select_path (EAttachmentView *view,
- GtkTreePath *path);
-void e_attachment_view_unselect_path (EAttachmentView *view,
- GtkTreePath *path);
-void e_attachment_view_select_all (EAttachmentView *view);
-void e_attachment_view_unselect_all (EAttachmentView *view);
-void e_attachment_view_sync_selection
- (EAttachmentView *view,
- EAttachmentView *target);
-
-/* Drag Source Support */
-void e_attachment_view_drag_source_set
- (EAttachmentView *view);
-void e_attachment_view_drag_source_unset
- (EAttachmentView *view);
-void e_attachment_view_drag_begin (EAttachmentView *view,
- GdkDragContext *context);
-void e_attachment_view_drag_end (EAttachmentView *view,
- GdkDragContext *context);
-void e_attachment_view_drag_data_get (EAttachmentView *view,
- GdkDragContext *context,
- GtkSelectionData *selection,
- guint info,
- guint time);
-
-/* Drag Destination Support */
-void e_attachment_view_drag_dest_set (EAttachmentView *view);
-void e_attachment_view_drag_dest_unset
- (EAttachmentView *view);
-gboolean e_attachment_view_drag_motion (EAttachmentView *view,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-gboolean e_attachment_view_drag_drop (EAttachmentView *view,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-void e_attachment_view_drag_data_received
- (EAttachmentView *view,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time);
-
-/* Popup Menu Management */
-GtkAction * e_attachment_view_get_action (EAttachmentView *view,
- const gchar *action_name);
-GtkActionGroup *e_attachment_view_add_action_group
- (EAttachmentView *view,
- const gchar *group_name);
-GtkActionGroup *e_attachment_view_get_action_group
- (EAttachmentView *view,
- const gchar *group_name);
-GtkWidget * e_attachment_view_get_popup_menu
- (EAttachmentView *view);
-GtkUIManager * e_attachment_view_get_ui_manager
- (EAttachmentView *view);
-void e_attachment_view_show_popup_menu
- (EAttachmentView *view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data);
-void e_attachment_view_update_actions
- (EAttachmentView *view);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_VIEW_H */
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
deleted file mode 100644
index 4ebaef3747..0000000000
--- a/widgets/misc/e-attachment.c
+++ /dev/null
@@ -1,2883 +0,0 @@
-/*
- * e-attachment.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-attachment.h"
-
-#include <errno.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-#include <libedataserver/libedataserver.h>
-
-#include "e-util/e-icon-factory.h"
-#include "e-util/e-util.h"
-#include "e-util/e-mktemp.h"
-#include "e-attachment-store.h"
-
-#define E_ATTACHMENT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT, EAttachmentPrivate))
-
-/* Fallback Icon */
-#define DEFAULT_ICON_NAME "mail-attachment"
-
-/* Emblems */
-#define EMBLEM_CANCELLED "gtk-cancel"
-#define EMBLEM_LOADING "emblem-downloads"
-#define EMBLEM_SAVING "document-save"
-#define EMBLEM_ENCRYPT_WEAK "security-low"
-#define EMBLEM_ENCRYPT_STRONG "security-high"
-#define EMBLEM_ENCRYPT_UNKNOWN "security-medium"
-#define EMBLEM_SIGN_BAD "stock_signature-bad"
-#define EMBLEM_SIGN_GOOD "stock_signature-ok"
-#define EMBLEM_SIGN_UNKNOWN "stock_signature"
-
-/* Attributes needed for EAttachmentStore columns. */
-#define ATTACHMENT_QUERY "standard::*,preview::*,thumbnail::*"
-
-struct _EAttachmentPrivate {
- GFile *file;
- GIcon *icon;
- GFileInfo *file_info;
- GCancellable *cancellable;
- CamelMimePart *mime_part;
- guint emblem_timeout_id;
- gchar *disposition;
- gint percent;
- gint64 last_percent_notify; /* to avoid excessive notifications */
-
- guint can_show : 1;
- guint loading : 1;
- guint saving : 1;
- guint shown : 1;
-
- camel_cipher_validity_encrypt_t encrypted;
- camel_cipher_validity_sign_t signed_;
-
- /* This is a reference to our row in an EAttachmentStore,
- * serving as a means of broadcasting "row-changed" signals.
- * If we are removed from the store, we lazily free the
- * reference when it is found to be to be invalid. */
- GtkTreeRowReference *reference;
-};
-
-enum {
- PROP_0,
- PROP_CAN_SHOW,
- PROP_DISPOSITION,
- PROP_ENCRYPTED,
- PROP_FILE,
- PROP_FILE_INFO,
- PROP_ICON,
- PROP_LOADING,
- PROP_MIME_PART,
- PROP_PERCENT,
- PROP_REFERENCE,
- PROP_SAVING,
- PROP_SHOWN,
- PROP_SIGNED
-};
-
-G_DEFINE_TYPE (
- EAttachment,
- e_attachment,
- G_TYPE_OBJECT)
-
-static gboolean
-create_system_thumbnail (EAttachment *attachment,
- GIcon **icon)
-{
- GFile *file;
- GFile *icon_file;
- gchar *thumbnail = NULL;
-
- g_return_val_if_fail (attachment != NULL, FALSE);
- g_return_val_if_fail (icon != NULL, FALSE);
-
- file = e_attachment_get_file (attachment);
-
- if (file && g_file_has_uri_scheme (file, "file")) {
- gchar *path = g_file_get_path (file);
- if (path) {
- thumbnail = e_icon_factory_create_thumbnail (path);
- g_free (path);
- }
- }
-
- if (thumbnail == NULL)
- return FALSE;
-
- icon_file = g_file_new_for_path (thumbnail);
-
- if (*icon)
- g_object_unref (*icon);
-
- *icon = g_file_icon_new (icon_file);
-
- g_object_unref (icon_file);
-
- if (file) {
- GFileInfo *file_info;
- const gchar *attribute;
-
- file_info = e_attachment_get_file_info (attachment);
- attribute = G_FILE_ATTRIBUTE_THUMBNAIL_PATH;
-
- if (file_info != NULL)
- g_file_info_set_attribute_byte_string (
- file_info, attribute, thumbnail);
- }
-
- g_free (thumbnail);
-
- return TRUE;
-}
-
-static gchar *
-attachment_get_default_charset (void)
-{
- GSettings *settings;
- gchar *charset;
-
- /* XXX This doesn't really belong here. */
-
- settings = g_settings_new ("org.gnome.evolution.mail");
- charset = g_settings_get_string (settings, "composer-charset");
- if (charset == NULL || *charset == '\0') {
- g_free (charset);
- /* FIXME This was "/apps/evolution/mail/format/charset",
- * not sure it relates to "charset" */
- charset = g_settings_get_string (settings, "charset");
- if (charset == NULL || *charset == '\0') {
- g_free (charset);
- charset = NULL;
- }
- }
- g_object_unref (settings);
-
- if (charset == NULL)
- charset = g_strdup (camel_iconv_locale_charset ());
-
- if (charset == NULL)
- charset = g_strdup ("us-ascii");
-
- return charset;
-}
-
-static void
-attachment_update_file_info_columns (EAttachment *attachment)
-{
- GtkTreeRowReference *reference;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- GFileInfo *file_info;
- const gchar *content_type;
- const gchar *description;
- const gchar *display_name;
- gchar *content_desc;
- gchar *display_size;
- gchar *caption;
- goffset size;
-
- reference = e_attachment_get_reference (attachment);
- if (!gtk_tree_row_reference_valid (reference))
- return;
-
- file_info = e_attachment_get_file_info (attachment);
- if (file_info == NULL)
- return;
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
-
- content_type = g_file_info_get_content_type (file_info);
- display_name = g_file_info_get_display_name (file_info);
- size = g_file_info_get_size (file_info);
-
- content_desc = g_content_type_get_description (content_type);
- display_size = g_format_size (size);
-
- description = e_attachment_get_description (attachment);
- if (description == NULL || *description == '\0')
- description = display_name;
-
- if (size > 0)
- caption = g_strdup_printf (
- "%s\n(%s)", description, display_size);
- else
- caption = g_strdup (description);
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- E_ATTACHMENT_STORE_COLUMN_CAPTION, caption,
- E_ATTACHMENT_STORE_COLUMN_CONTENT_TYPE, content_desc,
- E_ATTACHMENT_STORE_COLUMN_DESCRIPTION, description,
- E_ATTACHMENT_STORE_COLUMN_SIZE, size,
- -1);
-
- g_free (content_desc);
- g_free (display_size);
- g_free (caption);
-}
-
-static void
-attachment_update_icon_column (EAttachment *attachment)
-{
- GtkTreeRowReference *reference;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- GFileInfo *file_info;
- GCancellable *cancellable;
- GIcon *icon = NULL;
- const gchar *emblem_name = NULL;
- const gchar *thumbnail_path = NULL;
-
- reference = e_attachment_get_reference (attachment);
- if (!gtk_tree_row_reference_valid (reference))
- return;
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
-
- cancellable = attachment->priv->cancellable;
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info != NULL) {
- icon = g_file_info_get_icon (file_info);
- thumbnail_path = g_file_info_get_attribute_byte_string (
- file_info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
- }
-
- /* Prefer the thumbnail if we have one. */
- if (thumbnail_path != NULL && *thumbnail_path != '\0') {
- GFile *file;
-
- file = g_file_new_for_path (thumbnail_path);
- icon = g_file_icon_new (file);
- g_object_unref (file);
-
- /* Try the system thumbnailer. */
- } else if (create_system_thumbnail (attachment, &icon)) {
- /* Nothing to do, just use the icon. */
-
- /* Else use the standard icon for the content type. */
- } else if (icon != NULL)
- g_object_ref (icon);
-
- /* Last ditch fallback. (GFileInfo not yet loaded?) */
- else
- icon = g_themed_icon_new (DEFAULT_ICON_NAME);
-
- /* Pick an emblem, limit one. Choices listed by priority. */
-
- if (g_cancellable_is_cancelled (cancellable))
- emblem_name = EMBLEM_CANCELLED;
-
- else if (e_attachment_get_loading (attachment))
- emblem_name = EMBLEM_LOADING;
-
- else if (e_attachment_get_saving (attachment))
- emblem_name = EMBLEM_SAVING;
-
- else if (e_attachment_get_encrypted (attachment))
- switch (e_attachment_get_encrypted (attachment)) {
- case CAMEL_CIPHER_VALIDITY_ENCRYPT_WEAK:
- emblem_name = EMBLEM_ENCRYPT_WEAK;
- break;
-
- case CAMEL_CIPHER_VALIDITY_ENCRYPT_ENCRYPTED:
- emblem_name = EMBLEM_ENCRYPT_UNKNOWN;
- break;
-
- case CAMEL_CIPHER_VALIDITY_ENCRYPT_STRONG:
- emblem_name = EMBLEM_ENCRYPT_STRONG;
- break;
-
- default:
- g_warn_if_reached ();
- break;
- }
-
- else if (e_attachment_get_signed (attachment))
- switch (e_attachment_get_signed (attachment)) {
- case CAMEL_CIPHER_VALIDITY_SIGN_GOOD:
- emblem_name = EMBLEM_SIGN_GOOD;
- break;
-
- case CAMEL_CIPHER_VALIDITY_SIGN_BAD:
- emblem_name = EMBLEM_SIGN_BAD;
- break;
-
- case CAMEL_CIPHER_VALIDITY_SIGN_UNKNOWN:
- case CAMEL_CIPHER_VALIDITY_SIGN_NEED_PUBLIC_KEY:
- emblem_name = EMBLEM_SIGN_UNKNOWN;
- break;
-
- default:
- g_warn_if_reached ();
- break;
- }
-
- if (emblem_name != NULL) {
- GIcon *emblemed_icon;
- GEmblem *emblem;
-
- emblemed_icon = g_themed_icon_new (emblem_name);
- emblem = g_emblem_new (emblemed_icon);
- g_object_unref (emblemed_icon);
-
- emblemed_icon = g_emblemed_icon_new (icon, emblem);
- g_object_unref (emblem);
- g_object_unref (icon);
-
- icon = emblemed_icon;
- }
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- E_ATTACHMENT_STORE_COLUMN_ICON, icon,
- -1);
-
- /* Cache the icon to reuse for things like drag-n-drop. */
- if (attachment->priv->icon != NULL)
- g_object_unref (attachment->priv->icon);
- attachment->priv->icon = icon;
- g_object_notify (G_OBJECT (attachment), "icon");
-}
-
-static void
-attachment_update_progress_columns (EAttachment *attachment)
-{
- GtkTreeRowReference *reference;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gboolean loading;
- gboolean saving;
- gint percent;
-
- reference = e_attachment_get_reference (attachment);
- if (!gtk_tree_row_reference_valid (reference))
- return;
-
- model = gtk_tree_row_reference_get_model (reference);
- path = gtk_tree_row_reference_get_path (reference);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
-
- /* Don't show progress bars until we have progress to report. */
- percent = e_attachment_get_percent (attachment);
- loading = e_attachment_get_loading (attachment) && (percent > 0);
- saving = e_attachment_get_saving (attachment) && (percent > 0);
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- E_ATTACHMENT_STORE_COLUMN_LOADING, loading,
- E_ATTACHMENT_STORE_COLUMN_PERCENT, percent,
- E_ATTACHMENT_STORE_COLUMN_SAVING, saving,
- -1);
-}
-
-static void
-attachment_set_loading (EAttachment *attachment,
- gboolean loading)
-{
- GtkTreeRowReference *reference;
-
- reference = e_attachment_get_reference (attachment);
-
- attachment->priv->percent = 0;
- attachment->priv->loading = loading;
- attachment->priv->last_percent_notify = 0;
-
- g_object_freeze_notify (G_OBJECT (attachment));
- g_object_notify (G_OBJECT (attachment), "percent");
- g_object_notify (G_OBJECT (attachment), "loading");
- g_object_thaw_notify (G_OBJECT (attachment));
-
- if (gtk_tree_row_reference_valid (reference)) {
- GtkTreeModel *model;
- model = gtk_tree_row_reference_get_model (reference);
- g_object_notify (G_OBJECT (model), "num-loading");
- }
-}
-
-static void
-attachment_set_saving (EAttachment *attachment,
- gboolean saving)
-{
- attachment->priv->percent = 0;
- attachment->priv->saving = saving;
- attachment->priv->last_percent_notify = 0;
-
- g_object_freeze_notify (G_OBJECT (attachment));
- g_object_notify (G_OBJECT (attachment), "percent");
- g_object_notify (G_OBJECT (attachment), "saving");
- g_object_thaw_notify (G_OBJECT (attachment));
-}
-
-static void
-attachment_progress_cb (goffset current_num_bytes,
- goffset total_num_bytes,
- EAttachment *attachment)
-{
- gint new_percent;
-
- /* Avoid dividing by zero. */
- if (total_num_bytes == 0)
- return;
-
- /* do not notify too often, 5 times per second is sufficient */
- if (g_get_monotonic_time () - attachment->priv->last_percent_notify < 200000)
- return;
-
- attachment->priv->last_percent_notify = g_get_monotonic_time ();
-
- new_percent = (current_num_bytes * 100) / total_num_bytes;
-
- if (new_percent != attachment->priv->percent) {
- attachment->priv->percent = new_percent;
- g_object_notify (G_OBJECT (attachment), "percent");
- }
-}
-
-static gboolean
-attachment_cancelled_timeout_cb (EAttachment *attachment)
-{
- attachment->priv->emblem_timeout_id = 0;
- g_cancellable_reset (attachment->priv->cancellable);
-
- attachment_update_icon_column (attachment);
-
- return FALSE;
-}
-
-static void
-attachment_cancelled_cb (EAttachment *attachment)
-{
- /* Reset the GCancellable after one second. This causes a
- * cancel emblem to be briefly shown on the attachment icon
- * as visual feedback that an operation was cancelled. */
-
- if (attachment->priv->emblem_timeout_id > 0)
- g_source_remove (attachment->priv->emblem_timeout_id);
-
- attachment->priv->emblem_timeout_id = g_timeout_add_seconds (
- 1, (GSourceFunc) attachment_cancelled_timeout_cb, attachment);
-
- attachment_update_icon_column (attachment);
-}
-
-static void
-attachment_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CAN_SHOW:
- e_attachment_set_can_show (
- E_ATTACHMENT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_DISPOSITION:
- e_attachment_set_disposition (
- E_ATTACHMENT (object),
- g_value_get_string (value));
- return;
-
- case PROP_ENCRYPTED:
- e_attachment_set_encrypted (
- E_ATTACHMENT (object),
- g_value_get_int (value));
- return;
-
- case PROP_FILE:
- e_attachment_set_file (
- E_ATTACHMENT (object),
- g_value_get_object (value));
- return;
-
- case PROP_SHOWN:
- e_attachment_set_shown (
- E_ATTACHMENT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_MIME_PART:
- e_attachment_set_mime_part (
- E_ATTACHMENT (object),
- g_value_get_boxed (value));
- return;
-
- case PROP_REFERENCE:
- e_attachment_set_reference (
- E_ATTACHMENT (object),
- g_value_get_boxed (value));
- return;
-
- case PROP_SIGNED:
- e_attachment_set_signed (
- E_ATTACHMENT (object),
- g_value_get_int (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CAN_SHOW:
- g_value_set_boolean (
- value, e_attachment_get_can_show (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_DISPOSITION:
- g_value_set_string (
- value, e_attachment_get_disposition (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_ENCRYPTED:
- g_value_set_int (
- value, e_attachment_get_encrypted (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_FILE:
- g_value_set_object (
- value, e_attachment_get_file (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_FILE_INFO:
- g_value_set_object (
- value, e_attachment_get_file_info (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_ICON:
- g_value_set_object (
- value, e_attachment_get_icon (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_SHOWN:
- g_value_set_boolean (
- value, e_attachment_get_shown (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_LOADING:
- g_value_set_boolean (
- value, e_attachment_get_loading (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_MIME_PART:
- g_value_set_boxed (
- value, e_attachment_get_mime_part (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_PERCENT:
- g_value_set_int (
- value, e_attachment_get_percent (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_REFERENCE:
- g_value_set_boxed (
- value, e_attachment_get_reference (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_SAVING:
- g_value_set_boolean (
- value, e_attachment_get_saving (
- E_ATTACHMENT (object)));
- return;
-
- case PROP_SIGNED:
- g_value_set_int (
- value, e_attachment_get_signed (
- E_ATTACHMENT (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-attachment_dispose (GObject *object)
-{
- EAttachmentPrivate *priv;
-
- priv = E_ATTACHMENT_GET_PRIVATE (object);
-
- if (priv->file != NULL) {
- g_object_unref (priv->file);
- priv->file = NULL;
- }
-
- if (priv->icon != NULL) {
- g_object_unref (priv->icon);
- priv->icon = NULL;
- }
-
- if (priv->file_info != NULL) {
- g_object_unref (priv->file_info);
- priv->file_info = NULL;
- }
-
- if (priv->cancellable != NULL) {
- g_object_unref (priv->cancellable);
- priv->cancellable = NULL;
- }
-
- if (priv->mime_part != NULL) {
- g_object_unref (priv->mime_part);
- priv->mime_part = NULL;
- }
-
- if (priv->emblem_timeout_id > 0) {
- g_source_remove (priv->emblem_timeout_id);
- priv->emblem_timeout_id = 0;
- }
-
- /* This accepts NULL arguments. */
- gtk_tree_row_reference_free (priv->reference);
- priv->reference = NULL;
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_attachment_parent_class)->dispose (object);
-}
-
-static void
-attachment_finalize (GObject *object)
-{
- EAttachmentPrivate *priv;
-
- priv = E_ATTACHMENT_GET_PRIVATE (object);
-
- g_free (priv->disposition);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_attachment_parent_class)->finalize (object);
-}
-
-static void
-e_attachment_class_init (EAttachmentClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAttachmentPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = attachment_set_property;
- object_class->get_property = attachment_get_property;
- object_class->dispose = attachment_dispose;
- object_class->finalize = attachment_finalize;
-
- g_object_class_install_property (
- object_class,
- PROP_CAN_SHOW,
- g_param_spec_boolean (
- "can-show",
- "Can Show",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_DISPOSITION,
- g_param_spec_string (
- "disposition",
- "Disposition",
- NULL,
- "attachment",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /* FIXME Define a GEnumClass for this. */
- g_object_class_install_property (
- object_class,
- PROP_ENCRYPTED,
- g_param_spec_int (
- "encrypted",
- "Encrypted",
- NULL,
- CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE,
- CAMEL_CIPHER_VALIDITY_ENCRYPT_STRONG,
- CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_FILE,
- g_param_spec_object (
- "file",
- "File",
- NULL,
- G_TYPE_FILE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_FILE_INFO,
- g_param_spec_object (
- "file-info",
- "File Info",
- NULL,
- G_TYPE_FILE_INFO,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_ICON,
- g_param_spec_object (
- "icon",
- "Icon",
- NULL,
- G_TYPE_ICON,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_LOADING,
- g_param_spec_boolean (
- "loading",
- "Loading",
- NULL,
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_MIME_PART,
- g_param_spec_object (
- "mime-part",
- "MIME Part",
- NULL,
- CAMEL_TYPE_MIME_PART,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_PERCENT,
- g_param_spec_int (
- "percent",
- "Percent",
- NULL,
- 0,
- 100,
- 0,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_REFERENCE,
- g_param_spec_boxed (
- "reference",
- "Reference",
- NULL,
- GTK_TYPE_TREE_ROW_REFERENCE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SAVING,
- g_param_spec_boolean (
- "saving",
- "Saving",
- NULL,
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_SHOWN,
- g_param_spec_boolean (
- "shown",
- "Shown",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /* FIXME Define a GEnumClass for this. */
- g_object_class_install_property (
- object_class,
- PROP_SIGNED,
- g_param_spec_int (
- "signed",
- "Signed",
- NULL,
- CAMEL_CIPHER_VALIDITY_SIGN_NONE,
- CAMEL_CIPHER_VALIDITY_SIGN_NEED_PUBLIC_KEY,
- CAMEL_CIPHER_VALIDITY_SIGN_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_attachment_init (EAttachment *attachment)
-{
- attachment->priv = E_ATTACHMENT_GET_PRIVATE (attachment);
- attachment->priv->cancellable = g_cancellable_new ();
- attachment->priv->encrypted = CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE;
- attachment->priv->signed_ = CAMEL_CIPHER_VALIDITY_SIGN_NONE;
-
- g_signal_connect (
- attachment, "notify::encrypted",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect (
- attachment, "notify::file-info",
- G_CALLBACK (attachment_update_file_info_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::file-info",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect (
- attachment, "notify::loading",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect (
- attachment, "notify::loading",
- G_CALLBACK (attachment_update_progress_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::percent",
- G_CALLBACK (attachment_update_progress_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::reference",
- G_CALLBACK (attachment_update_file_info_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::reference",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect (
- attachment, "notify::reference",
- G_CALLBACK (attachment_update_progress_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::saving",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect (
- attachment, "notify::saving",
- G_CALLBACK (attachment_update_progress_columns), NULL);
-
- g_signal_connect (
- attachment, "notify::signed",
- G_CALLBACK (attachment_update_icon_column), NULL);
-
- g_signal_connect_swapped (
- attachment->priv->cancellable, "cancelled",
- G_CALLBACK (attachment_cancelled_cb), attachment);
-}
-
-EAttachment *
-e_attachment_new (void)
-{
- return g_object_new (E_TYPE_ATTACHMENT, NULL);
-}
-
-EAttachment *
-e_attachment_new_for_path (const gchar *path)
-{
- EAttachment *attachment;
- GFile *file;
-
- g_return_val_if_fail (path != NULL, NULL);
-
- file = g_file_new_for_path (path);
- attachment = g_object_new (E_TYPE_ATTACHMENT, "file", file, NULL);
- g_object_unref (file);
-
- return attachment;
-}
-
-EAttachment *
-e_attachment_new_for_uri (const gchar *uri)
-{
- EAttachment *attachment;
- GFile *file;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- file = g_file_new_for_uri (uri);
- attachment = g_object_new (E_TYPE_ATTACHMENT, "file", file, NULL);
- g_object_unref (file);
-
- return attachment;
-}
-
-EAttachment *
-e_attachment_new_for_message (CamelMimeMessage *message)
-{
- CamelDataWrapper *wrapper;
- CamelMimePart *mime_part;
- EAttachment *attachment;
- GString *description;
- const gchar *subject;
-
- g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
-
- mime_part = camel_mime_part_new ();
- camel_mime_part_set_disposition (mime_part, "inline");
- subject = camel_mime_message_get_subject (message);
-
- /* To Translators: This text is set as a description of an attached
- * message when, for example, attaching it to a composer. When the
- * message to be attached has also filled Subject, then this text is
- * of form "Attached message - Subject", otherwise it's left as is. */
- description = g_string_new (_("Attached message"));
- if (subject != NULL)
- g_string_append_printf (description, " - %s", subject);
- camel_mime_part_set_description (mime_part, description->str);
- g_string_free (description, TRUE);
-
- wrapper = CAMEL_DATA_WRAPPER (message);
- camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
- camel_mime_part_set_content_type (mime_part, "message/rfc822");
-
- attachment = e_attachment_new ();
- e_attachment_set_mime_part (attachment, mime_part);
- g_object_unref (mime_part);
-
- return attachment;
-}
-
-void
-e_attachment_add_to_multipart (EAttachment *attachment,
- CamelMultipart *multipart,
- const gchar *default_charset)
-{
- CamelContentType *content_type;
- CamelDataWrapper *wrapper;
- CamelMimePart *mime_part;
-
- /* XXX EMsgComposer might be a better place for this function. */
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
-
- /* Still loading? Too bad. */
- mime_part = e_attachment_get_mime_part (attachment);
- if (mime_part == NULL)
- return;
-
- content_type = camel_mime_part_get_content_type (mime_part);
- wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
-
- if (CAMEL_IS_MULTIPART (wrapper))
- goto exit;
-
- /* For text content, determine the best encoding and character set. */
- if (camel_content_type_is (content_type, "text", "*")) {
- CamelTransferEncoding encoding;
- CamelStream *filtered_stream;
- CamelMimeFilter *filter;
- CamelStream *stream;
- const gchar *charset;
-
- charset = camel_content_type_param (content_type, "charset");
-
- /* Determine the best encoding by writing the MIME
- * part to a NULL stream with a "bestenc" filter. */
- stream = camel_stream_null_new ();
- filtered_stream = camel_stream_filter_new (stream);
- filter = camel_mime_filter_bestenc_new (
- CAMEL_BESTENC_GET_ENCODING);
- camel_stream_filter_add (
- CAMEL_STREAM_FILTER (filtered_stream),
- CAMEL_MIME_FILTER (filter));
- camel_data_wrapper_decode_to_stream_sync (
- wrapper, filtered_stream, NULL, NULL);
- g_object_unref (filtered_stream);
- g_object_unref (stream);
-
- /* Retrieve the best encoding from the filter. */
- encoding = camel_mime_filter_bestenc_get_best_encoding (
- CAMEL_MIME_FILTER_BESTENC (filter),
- CAMEL_BESTENC_8BIT);
- camel_mime_part_set_encoding (mime_part, encoding);
- g_object_unref (filter);
-
- if (encoding == CAMEL_TRANSFER_ENCODING_7BIT) {
- /* The text fits within us-ascii, so this is safe.
- * FIXME Check that this isn't iso-2022-jp? */
- default_charset = "us-ascii";
-
- } else if (charset == NULL && default_charset == NULL) {
- default_charset = attachment_get_default_charset ();
- /* FIXME Check that this fits within the
- * default_charset and if not, find one
- * that does and/or allow the user to
- * specify. */
- }
-
- if (charset == NULL) {
- gchar *type;
-
- camel_content_type_set_param (
- content_type, "charset", default_charset);
- type = camel_content_type_format (content_type);
- camel_mime_part_set_content_type (mime_part, type);
- g_free (type);
- }
-
- /* Otherwise, unless it's a message/rfc822, Base64 encode it. */
- } else if (!CAMEL_IS_MIME_MESSAGE (wrapper))
- camel_mime_part_set_encoding (
- mime_part, CAMEL_TRANSFER_ENCODING_BASE64);
-
-exit:
- camel_multipart_add_part (multipart, mime_part);
-}
-
-void
-e_attachment_cancel (EAttachment *attachment)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- g_cancellable_cancel (attachment->priv->cancellable);
-}
-
-gboolean
-e_attachment_get_can_show (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- return attachment->priv->can_show;
-}
-
-void
-e_attachment_set_can_show (EAttachment *attachment,
- gboolean can_show)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- attachment->priv->can_show = can_show;
-
- g_object_notify (G_OBJECT (attachment), "can-show");
-}
-
-const gchar *
-e_attachment_get_disposition (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->disposition;
-}
-
-void
-e_attachment_set_disposition (EAttachment *attachment,
- const gchar *disposition)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- g_free (attachment->priv->disposition);
- attachment->priv->disposition = g_strdup (disposition);
-
- g_object_notify (G_OBJECT (attachment), "disposition");
-}
-
-GFile *
-e_attachment_get_file (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->file;
-}
-
-void
-e_attachment_set_file (EAttachment *attachment,
- GFile *file)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- if (file != NULL) {
- g_return_if_fail (G_IS_FILE (file));
- g_object_ref (file);
- }
-
- if (attachment->priv->file != NULL)
- g_object_unref (attachment->priv->file);
-
- attachment->priv->file = file;
-
- g_object_notify (G_OBJECT (attachment), "file");
-}
-
-GFileInfo *
-e_attachment_get_file_info (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->file_info;
-}
-
-void
-e_attachment_set_file_info (EAttachment *attachment,
- GFileInfo *file_info)
-{
- GtkTreeRowReference *reference;
- GIcon *icon;
-
- reference = e_attachment_get_reference (attachment);
-
- if (file_info != NULL)
- g_object_ref (file_info);
-
- if (attachment->priv->file_info != NULL)
- g_object_unref (attachment->priv->file_info);
-
- attachment->priv->file_info = file_info;
-
- /* If the GFileInfo contains a GThemedIcon, append a
- * fallback icon name to ensure we display something. */
- icon = g_file_info_get_icon (file_info);
- if (G_IS_THEMED_ICON (icon))
- g_themed_icon_append_name (
- G_THEMED_ICON (icon), DEFAULT_ICON_NAME);
-
- g_object_notify (G_OBJECT (attachment), "file-info");
-
- /* Tell the EAttachmentStore its total size changed. */
- if (gtk_tree_row_reference_valid (reference)) {
- GtkTreeModel *model;
- model = gtk_tree_row_reference_get_model (reference);
- g_object_notify (G_OBJECT (model), "total-size");
- }
-}
-
-/**
- * e_attachment_get_mime_type:
- *
- * Returns mime_type part of the file_info as a newly allocated string,
- * which should be freed with g_free().
- * Returns NULL, if mime_type not found or set on the attachment.
- **/
-gchar *
-e_attachment_get_mime_type (EAttachment *attachment)
-{
- GFileInfo *file_info;
- const gchar *content_type;
- gchar *mime_type;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- file_info = e_attachment_get_file_info (attachment);
- if (file_info == NULL)
- return NULL;
-
- content_type = g_file_info_get_content_type (file_info);
- if (content_type == NULL)
- return NULL;
-
- mime_type = g_content_type_get_mime_type (content_type);
- if (!mime_type)
- return NULL;
-
- camel_strdown (mime_type);
-
- return mime_type;
-}
-
-GIcon *
-e_attachment_get_icon (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->icon;
-}
-
-gboolean
-e_attachment_get_loading (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- return attachment->priv->loading;
-}
-
-CamelMimePart *
-e_attachment_get_mime_part (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->mime_part;
-}
-
-void
-e_attachment_set_mime_part (EAttachment *attachment,
- CamelMimePart *mime_part)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- if (mime_part != NULL) {
- g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
- g_object_ref (mime_part);
- }
-
- if (attachment->priv->mime_part != NULL)
- g_object_unref (attachment->priv->mime_part);
-
- attachment->priv->mime_part = mime_part;
-
- g_object_notify (G_OBJECT (attachment), "mime-part");
-}
-
-gint
-e_attachment_get_percent (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), 0);
-
- return attachment->priv->percent;
-}
-
-GtkTreeRowReference *
-e_attachment_get_reference (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- return attachment->priv->reference;
-}
-
-void
-e_attachment_set_reference (EAttachment *attachment,
- GtkTreeRowReference *reference)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- if (reference != NULL)
- reference = gtk_tree_row_reference_copy (reference);
-
- gtk_tree_row_reference_free (attachment->priv->reference);
- attachment->priv->reference = reference;
-
- g_object_notify (G_OBJECT (attachment), "reference");
-}
-
-gboolean
-e_attachment_get_saving (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- return attachment->priv->saving;
-}
-
-gboolean
-e_attachment_get_shown (EAttachment *attachment)
-{
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- return attachment->priv->shown;
-}
-
-void
-e_attachment_set_shown (EAttachment *attachment,
- gboolean shown)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- attachment->priv->shown = shown;
-
- g_object_notify (G_OBJECT (attachment), "shown");
-}
-
-camel_cipher_validity_encrypt_t
-e_attachment_get_encrypted (EAttachment *attachment)
-{
- g_return_val_if_fail (
- E_IS_ATTACHMENT (attachment),
- CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE);
-
- return attachment->priv->encrypted;
-}
-
-void
-e_attachment_set_encrypted (EAttachment *attachment,
- camel_cipher_validity_encrypt_t encrypted)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- attachment->priv->encrypted = encrypted;
-
- g_object_notify (G_OBJECT (attachment), "encrypted");
-}
-
-camel_cipher_validity_sign_t
-e_attachment_get_signed (EAttachment *attachment)
-{
- g_return_val_if_fail (
- E_IS_ATTACHMENT (attachment),
- CAMEL_CIPHER_VALIDITY_SIGN_NONE);
-
- return attachment->priv->signed_;
-}
-
-void
-e_attachment_set_signed (EAttachment *attachment,
- camel_cipher_validity_sign_t signed_)
-{
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- attachment->priv->signed_ = signed_;
-
- g_object_notify (G_OBJECT (attachment), "signed");
-}
-
-const gchar *
-e_attachment_get_description (EAttachment *attachment)
-{
- GFileInfo *file_info;
- const gchar *attribute;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- attribute = G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION;
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info == NULL)
- return NULL;
-
- return g_file_info_get_attribute_string (file_info, attribute);
-}
-
-const gchar *
-e_attachment_get_thumbnail_path (EAttachment *attachment)
-{
- GFileInfo *file_info;
- const gchar *attribute;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- attribute = G_FILE_ATTRIBUTE_THUMBNAIL_PATH;
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info == NULL)
- return NULL;
-
- return g_file_info_get_attribute_byte_string (file_info, attribute);
-}
-
-gboolean
-e_attachment_is_rfc822 (EAttachment *attachment)
-{
- gchar *mime_type;
- gboolean is_rfc822;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- mime_type = e_attachment_get_mime_type (attachment);
- is_rfc822 = mime_type && g_ascii_strcasecmp (mime_type, "message/rfc822") == 0;
- g_free (mime_type);
-
- return is_rfc822;
-}
-
-GList *
-e_attachment_list_apps (EAttachment *attachment)
-{
- GList *app_info_list;
- GList *guessed_infos;
- GFileInfo *file_info;
- const gchar *content_type;
- const gchar *display_name;
- gboolean type_is_unknown;
- gchar *allocated;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
-
- file_info = e_attachment_get_file_info (attachment);
- if (file_info == NULL)
- return NULL;
-
- content_type = g_file_info_get_content_type (file_info);
- display_name = g_file_info_get_display_name (file_info);
- g_return_val_if_fail (content_type != NULL, NULL);
-
- app_info_list = g_app_info_get_all_for_type (content_type);
- type_is_unknown = g_content_type_is_unknown (content_type);
-
- if (app_info_list != NULL && !type_is_unknown)
- goto exit;
-
- if (display_name == NULL)
- goto exit;
-
- allocated = g_content_type_guess (display_name, NULL, 0, NULL);
- guessed_infos = g_app_info_get_all_for_type (allocated);
- app_info_list = g_list_concat (guessed_infos, app_info_list);
- g_free (allocated);
-
-exit:
- return app_info_list;
-}
-
-/************************* e_attachment_load_async() *************************/
-
-typedef struct _LoadContext LoadContext;
-
-struct _LoadContext {
- EAttachment *attachment;
- CamelMimePart *mime_part;
- GSimpleAsyncResult *simple;
-
- GInputStream *input_stream;
- GOutputStream *output_stream;
- GFileInfo *file_info;
- goffset total_num_bytes;
- gssize bytes_read;
- gchar buffer[4096];
-};
-
-/* Forward Declaration */
-static void
-attachment_load_stream_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- LoadContext *load_context);
-
-static LoadContext *
-attachment_load_context_new (EAttachment *attachment,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- LoadContext *load_context;
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (
- G_OBJECT (attachment), callback,
- user_data, e_attachment_load_async);
-
- load_context = g_slice_new0 (LoadContext);
- load_context->attachment = g_object_ref (attachment);
- load_context->simple = simple;
-
- attachment_set_loading (load_context->attachment, TRUE);
-
- return load_context;
-}
-
-static void
-attachment_load_context_free (LoadContext *load_context)
-{
- g_object_unref (load_context->attachment);
-
- if (load_context->mime_part != NULL)
- g_object_unref (load_context->mime_part);
-
- if (load_context->simple)
- g_object_unref (load_context->simple);
-
- if (load_context->input_stream != NULL)
- g_object_unref (load_context->input_stream);
-
- if (load_context->output_stream != NULL)
- g_object_unref (load_context->output_stream);
-
- if (load_context->file_info != NULL)
- g_object_unref (load_context->file_info);
-
- g_slice_free (LoadContext, load_context);
-}
-
-static gboolean
-attachment_load_check_for_error (LoadContext *load_context,
- GError *error)
-{
- GSimpleAsyncResult *simple;
-
- if (error == NULL)
- return FALSE;
-
- simple = load_context->simple;
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
-
- attachment_load_context_free (load_context);
-
- return TRUE;
-}
-
-static void
-attachment_load_finish (LoadContext *load_context)
-{
- GFileInfo *file_info;
- EAttachment *attachment;
- GMemoryOutputStream *output_stream;
- GSimpleAsyncResult *simple;
- CamelDataWrapper *wrapper;
- CamelMimePart *mime_part;
- CamelStream *stream;
- const gchar *attribute;
- const gchar *content_type;
- const gchar *display_name;
- const gchar *description;
- const gchar *disposition;
- gchar *mime_type;
- gpointer data;
- gsize size;
-
- simple = load_context->simple;
-
- file_info = load_context->file_info;
- attachment = load_context->attachment;
- output_stream = G_MEMORY_OUTPUT_STREAM (load_context->output_stream);
-
- if (e_attachment_is_rfc822 (attachment))
- wrapper = (CamelDataWrapper *) camel_mime_message_new ();
- else
- wrapper = camel_data_wrapper_new ();
-
- content_type = g_file_info_get_content_type (file_info);
- mime_type = g_content_type_get_mime_type (content_type);
-
- data = g_memory_output_stream_get_data (output_stream);
- size = g_memory_output_stream_get_data_size (output_stream);
-
- stream = camel_stream_mem_new_with_buffer (data, size);
- camel_data_wrapper_construct_from_stream_sync (
- wrapper, stream, NULL, NULL);
- camel_data_wrapper_set_mime_type (wrapper, mime_type);
- camel_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
-
- mime_part = camel_mime_part_new ();
- camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
-
- g_object_unref (wrapper);
- g_free (mime_type);
-
- display_name = g_file_info_get_display_name (file_info);
- if (display_name != NULL)
- camel_mime_part_set_filename (mime_part, display_name);
-
- attribute = G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION;
- description = g_file_info_get_attribute_string (file_info, attribute);
- if (description != NULL)
- camel_mime_part_set_description (mime_part, description);
-
- disposition = e_attachment_get_disposition (attachment);
- if (disposition != NULL)
- camel_mime_part_set_disposition (mime_part, disposition);
-
- /* Correctly report the size of zero length special files. */
- if (g_file_info_get_size (file_info) == 0)
- g_file_info_set_size (file_info, size);
-
- load_context->mime_part = mime_part;
-
- g_simple_async_result_set_op_res_gpointer (
- simple, load_context, (GDestroyNotify) attachment_load_context_free);
-
- g_simple_async_result_complete (simple);
-
- /* make sure it's freed on operation end */
- load_context->simple = NULL;
- g_object_unref (simple);
-}
-
-static void
-attachment_load_write_cb (GOutputStream *output_stream,
- GAsyncResult *result,
- LoadContext *load_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GInputStream *input_stream;
- gssize bytes_written;
- GError *error = NULL;
-
- bytes_written = g_output_stream_write_finish (
- output_stream, result, &error);
-
- if (attachment_load_check_for_error (load_context, error))
- return;
-
- attachment = load_context->attachment;
- cancellable = attachment->priv->cancellable;
- input_stream = load_context->input_stream;
-
- attachment_progress_cb (
- g_seekable_tell (G_SEEKABLE (output_stream)),
- load_context->total_num_bytes, attachment);
-
- if (bytes_written < load_context->bytes_read) {
- g_memmove (
- load_context->buffer,
- load_context->buffer + bytes_written,
- load_context->bytes_read - bytes_written);
- load_context->bytes_read -= bytes_written;
-
- g_output_stream_write_async (
- output_stream,
- load_context->buffer,
- load_context->bytes_read,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_load_write_cb,
- load_context);
- } else
- g_input_stream_read_async (
- input_stream,
- load_context->buffer,
- sizeof (load_context->buffer),
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_load_stream_read_cb,
- load_context);
-}
-
-static void
-attachment_load_stream_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- LoadContext *load_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GOutputStream *output_stream;
- gssize bytes_read;
- GError *error = NULL;
-
- bytes_read = g_input_stream_read_finish (
- input_stream, result, &error);
-
- if (attachment_load_check_for_error (load_context, error))
- return;
-
- if (bytes_read == 0) {
- attachment_load_finish (load_context);
- return;
- }
-
- attachment = load_context->attachment;
- cancellable = attachment->priv->cancellable;
- output_stream = load_context->output_stream;
- load_context->bytes_read = bytes_read;
-
- g_output_stream_write_async (
- output_stream,
- load_context->buffer,
- load_context->bytes_read,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_load_write_cb,
- load_context);
-}
-
-static void
-attachment_load_file_read_cb (GFile *file,
- GAsyncResult *result,
- LoadContext *load_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GFileInputStream *input_stream;
- GOutputStream *output_stream;
- GError *error = NULL;
-
- /* Input stream might be NULL, so don't use cast macro. */
- input_stream = g_file_read_finish (file, result, &error);
- load_context->input_stream = (GInputStream *) input_stream;
-
- if (attachment_load_check_for_error (load_context, error))
- return;
-
- /* Load the contents into a GMemoryOutputStream. */
- output_stream = g_memory_output_stream_new (
- NULL, 0, g_realloc, g_free);
-
- attachment = load_context->attachment;
- cancellable = attachment->priv->cancellable;
- load_context->output_stream = output_stream;
-
- g_input_stream_read_async (
- load_context->input_stream,
- load_context->buffer,
- sizeof (load_context->buffer),
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_load_stream_read_cb,
- load_context);
-}
-
-static void
-attachment_load_query_info_cb (GFile *file,
- GAsyncResult *result,
- LoadContext *load_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GFileInfo *file_info;
- GError *error = NULL;
-
- attachment = load_context->attachment;
- cancellable = attachment->priv->cancellable;
-
- file_info = g_file_query_info_finish (file, result, &error);
- if (attachment_load_check_for_error (load_context, error))
- return;
-
- e_attachment_set_file_info (attachment, file_info);
- load_context->file_info = file_info;
-
- load_context->total_num_bytes = g_file_info_get_size (file_info);
-
- g_file_read_async (
- file, G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- attachment_load_file_read_cb, load_context);
-}
-
-#define ATTACHMENT_LOAD_CONTEXT "attachment-load-context-data"
-
-static void
-attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
- GObject *object,
- GCancellable *cancellable)
-{
- LoadContext *load_context;
- GFileInfo *file_info;
- EAttachment *attachment;
- CamelContentType *content_type;
- CamelMimePart *mime_part;
- const gchar *attribute;
- const gchar *string;
- gchar *allocated;
- CamelStream *null;
- CamelDataWrapper *dw;
-
- load_context = g_object_get_data (G_OBJECT (simple), ATTACHMENT_LOAD_CONTEXT);
- g_return_if_fail (load_context != NULL);
- g_object_set_data (G_OBJECT (simple), ATTACHMENT_LOAD_CONTEXT, NULL);
-
- attachment = load_context->attachment;
- mime_part = e_attachment_get_mime_part (attachment);
-
- file_info = g_file_info_new ();
- load_context->file_info = file_info;
-
- content_type = camel_mime_part_get_content_type (mime_part);
- allocated = camel_content_type_simple (content_type);
- if (allocated != NULL) {
- GIcon *icon;
- gchar *cp;
-
- /* GIO expects lowercase MIME types. */
- for (cp = allocated; *cp != '\0'; cp++)
- *cp = g_ascii_tolower (*cp);
-
- /* Swap the MIME type for a content type. */
- cp = g_content_type_from_mime_type (allocated);
- g_free (allocated);
- allocated = cp;
-
- /* Use the MIME part's filename if we have to. */
- if (g_content_type_is_unknown (allocated)) {
- string = camel_mime_part_get_filename (mime_part);
- if (string != NULL) {
- g_free (allocated);
- allocated = g_content_type_guess (
- string, NULL, 0, NULL);
- }
- }
-
- g_file_info_set_content_type (file_info, allocated);
-
- icon = g_content_type_get_icon (allocated);
- if (icon != NULL) {
- g_file_info_set_icon (file_info, icon);
- g_object_unref (icon);
- }
- }
- g_free (allocated);
-
- /* Strip any path components from the filename. */
- string = camel_mime_part_get_filename (mime_part);
- if (string == NULL)
- /* Translators: Default attachment filename. */
- string = _("attachment.dat");
- allocated = g_path_get_basename (string);
- g_file_info_set_display_name (file_info, allocated);
- g_free (allocated);
-
- attribute = G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION;
- string = camel_mime_part_get_description (mime_part);
- if (string != NULL)
- g_file_info_set_attribute_string (
- file_info, attribute, string);
-
- dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- null = camel_stream_null_new ();
- /* this actually downloads the part and makes it available later */
- camel_data_wrapper_decode_to_stream_sync (dw, null, attachment->priv->cancellable, NULL);
- g_file_info_set_size (file_info, CAMEL_STREAM_NULL (null)->written);
- g_object_unref (null);
-
- load_context->mime_part = g_object_ref (mime_part);
-
- /* make sure it's freed on operation end */
- g_object_unref (load_context->simple);
- load_context->simple = NULL;
-
- g_simple_async_result_set_op_res_gpointer (
- simple, load_context,
- (GDestroyNotify) attachment_load_context_free);
-}
-
-void
-e_attachment_load_async (EAttachment *attachment,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- LoadContext *load_context;
- GCancellable *cancellable;
- CamelMimePart *mime_part;
- GFile *file;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- if (e_attachment_get_loading (attachment)) {
- g_simple_async_report_error_in_idle (
- G_OBJECT (attachment), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_BUSY,
- _("A load operation is already in progress"));
- return;
- }
-
- if (e_attachment_get_saving (attachment)) {
- g_simple_async_report_error_in_idle (
- G_OBJECT (attachment), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_BUSY,
- _("A save operation is already in progress"));
- return;
- }
-
- file = e_attachment_get_file (attachment);
- mime_part = e_attachment_get_mime_part (attachment);
- g_return_if_fail (file != NULL || mime_part != NULL);
-
- load_context = attachment_load_context_new (
- attachment, callback, user_data);
-
- cancellable = attachment->priv->cancellable;
- g_cancellable_reset (cancellable);
-
- if (file != NULL) {
- g_file_query_info_async (
- file, ATTACHMENT_QUERY,
- G_FILE_QUERY_INFO_NONE,G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- attachment_load_query_info_cb, load_context);
-
- } else if (mime_part != NULL) {
- g_object_set_data (G_OBJECT (load_context->simple), ATTACHMENT_LOAD_CONTEXT, load_context);
-
- g_simple_async_result_run_in_thread (
- load_context->simple,
- attachment_load_from_mime_part_thread,
- G_PRIORITY_DEFAULT,
- cancellable);
- }
-}
-
-gboolean
-e_attachment_load_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- const LoadContext *load_context;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- load_context = g_simple_async_result_get_op_res_gpointer (simple);
- if (load_context && load_context->mime_part) {
- const gchar *string;
-
- string = camel_mime_part_get_disposition (load_context->mime_part);
- e_attachment_set_disposition (attachment, string);
-
- e_attachment_set_file_info (attachment, load_context->file_info);
- e_attachment_set_mime_part (attachment, load_context->mime_part);
- }
-
- g_simple_async_result_propagate_error (simple, error);
-
- attachment_set_loading (attachment, FALSE);
-
- return (load_context != NULL);
-}
-
-void
-e_attachment_load_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent)
-{
- GtkWidget *dialog;
- GFileInfo *file_info;
- GtkTreeRowReference *reference;
- const gchar *display_name;
- const gchar *primary_text;
- GError *error = NULL;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_return_if_fail (G_IS_ASYNC_RESULT (result));
- g_return_if_fail (!parent || GTK_IS_WINDOW (parent));
-
- if (e_attachment_load_finish (attachment, result, &error))
- return;
-
- /* XXX Calling EAttachmentStore functions from here violates
- * the abstraction, but for now it's not hurting anything. */
- reference = e_attachment_get_reference (attachment);
- if (gtk_tree_row_reference_valid (reference)) {
- GtkTreeModel *model;
-
- model = gtk_tree_row_reference_get_model (reference);
-
- e_attachment_store_remove_attachment (
- E_ATTACHMENT_STORE (model), attachment);
- }
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free (error);
- return;
- }
-
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info != NULL)
- display_name = g_file_info_get_display_name (file_info);
- else
- display_name = NULL;
-
- if (display_name != NULL)
- primary_text = g_strdup_printf (
- _("Could not load '%s'"), display_name);
- else
- primary_text = g_strdup_printf (
- _("Could not load the attachment"));
-
- dialog = gtk_message_dialog_new_with_markup (
- parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<big><b>%s</b></big>", primary_text);
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_error_free (error);
-}
-
-gboolean
-e_attachment_load (EAttachment *attachment,
- GError **error)
-{
- EAsyncClosure *closure;
- GAsyncResult *result;
- gboolean success;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- closure = e_async_closure_new ();
-
- e_attachment_load_async (attachment, e_async_closure_callback, closure);
-
- result = e_async_closure_wait (closure);
-
- success = e_attachment_load_finish (attachment, result, error);
-
- e_async_closure_free (closure);
-
- return success;
-}
-
-/************************* e_attachment_open_async() *************************/
-
-typedef struct _OpenContext OpenContext;
-
-struct _OpenContext {
- EAttachment *attachment;
- GSimpleAsyncResult *simple;
-
- GAppInfo *app_info;
-};
-
-static OpenContext *
-attachment_open_context_new (EAttachment *attachment,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- OpenContext *open_context;
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (
- G_OBJECT (attachment), callback,
- user_data, e_attachment_open_async);
-
- open_context = g_slice_new0 (OpenContext);
- open_context->attachment = g_object_ref (attachment);
- open_context->simple = simple;
-
- return open_context;
-}
-
-static void
-attachment_open_context_free (OpenContext *open_context)
-{
- g_object_unref (open_context->attachment);
- g_object_unref (open_context->simple);
-
- if (open_context->app_info != NULL)
- g_object_unref (open_context->app_info);
-
- g_slice_free (OpenContext, open_context);
-}
-
-static gboolean
-attachment_open_check_for_error (OpenContext *open_context,
- GError *error)
-{
- GSimpleAsyncResult *simple;
-
- if (error == NULL)
- return FALSE;
-
- simple = open_context->simple;
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
-
- attachment_open_context_free (open_context);
-
- return TRUE;
-}
-
-static void
-attachment_open_file (GFile *file,
- OpenContext *open_context)
-{
- GdkAppLaunchContext *context;
- GSimpleAsyncResult *simple;
- GdkDisplay *display;
- gboolean success;
- GError *error = NULL;
-
- simple = open_context->simple;
-
- display = gdk_display_get_default ();
- context = gdk_display_get_app_launch_context (display);
-
- if (open_context->app_info != NULL) {
- GList *file_list;
-
- file_list = g_list_prepend (NULL, file);
- success = g_app_info_launch (
- open_context->app_info, file_list,
- G_APP_LAUNCH_CONTEXT (context), &error);
- g_list_free (file_list);
- } else {
- gchar *uri;
-
- uri = g_file_get_uri (file);
- success = g_app_info_launch_default_for_uri (
- uri, G_APP_LAUNCH_CONTEXT (context), &error);
- g_free (uri);
- }
-
- g_object_unref (context);
-
- g_simple_async_result_set_op_res_gboolean (simple, success);
-
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
- attachment_open_context_free (open_context);
-}
-
-static void
-attachment_open_save_finished_cb (EAttachment *attachment,
- GAsyncResult *result,
- OpenContext *open_context)
-{
- GFile *file;
- gchar *path;
- GError *error = NULL;
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- if (attachment_open_check_for_error (open_context, error))
- return;
-
- /* Make the temporary file read-only.
- *
- * This step is non-critical, so if an error occurs just
- * emit a warning and move on.
- *
- * XXX I haven't figured out how to do this through GIO.
- * Attempting to set the "access::can-write" attribute via
- * g_file_set_attribute() returned G_IO_ERROR_NOT_SUPPORTED
- * and the only other possibility I see is "unix::mode",
- * which is obviously not portable.
- */
- path = g_file_get_path (file);
-#ifndef G_OS_WIN32
- if (g_chmod (path, S_IRUSR | S_IRGRP | S_IROTH) < 0)
- g_warning ("%s", g_strerror (errno));
-#endif
- g_free (path);
-
- attachment_open_file (file, open_context);
- g_object_unref (file);
-}
-
-static void
-attachment_open_save_temporary (OpenContext *open_context)
-{
- GFile *temp_directory;
- gchar *template;
- gchar *path;
- GError *error = NULL;
-
- errno = 0;
-
- /* Save the file to a temporary directory.
- * We use a directory so the files can retain their basenames.
- * XXX This could trigger a blocking temp directory cleanup. */
- template = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ());
- path = e_mkdtemp (template);
- g_free (template);
-
- /* XXX Let's hope errno got set properly. */
- if (path == NULL)
- g_set_error (
- &error, G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "%s", g_strerror (errno));
-
- /* We already know if there's an error, but this does the cleanup. */
- if (attachment_open_check_for_error (open_context, error))
- return;
-
- temp_directory = g_file_new_for_path (path);
-
- e_attachment_save_async (
- open_context->attachment,
- temp_directory, (GAsyncReadyCallback)
- attachment_open_save_finished_cb, open_context);
-
- g_object_unref (temp_directory);
- g_free (path);
-}
-
-void
-e_attachment_open_async (EAttachment *attachment,
- GAppInfo *app_info,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- OpenContext *open_context;
- CamelMimePart *mime_part;
- GFile *file;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
-
- file = e_attachment_get_file (attachment);
- mime_part = e_attachment_get_mime_part (attachment);
- g_return_if_fail (file != NULL || mime_part != NULL);
-
- open_context = attachment_open_context_new (
- attachment, callback, user_data);
-
- if (G_IS_APP_INFO (app_info))
- open_context->app_info = g_object_ref (app_info);
-
- /* If the attachment already references a GFile, we can launch
- * the application directly. Otherwise we have to save the MIME
- * part to a temporary file and launch the application from that. */
- if (file != NULL) {
- attachment_open_file (file, open_context);
-
- } else if (mime_part != NULL)
- attachment_open_save_temporary (open_context);
-}
-
-gboolean
-e_attachment_open_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gboolean success;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- success = g_simple_async_result_get_op_res_gboolean (simple);
- g_simple_async_result_propagate_error (simple, error);
-
- return success;
-}
-
-void
-e_attachment_open_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent)
-{
- GtkWidget *dialog;
- GFileInfo *file_info;
- const gchar *display_name;
- const gchar *primary_text;
- GError *error = NULL;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_return_if_fail (G_IS_ASYNC_RESULT (result));
- g_return_if_fail (GTK_IS_WINDOW (parent));
-
- if (e_attachment_open_finish (attachment, result, &error))
- return;
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- return;
-
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info != NULL)
- display_name = g_file_info_get_display_name (file_info);
- else
- display_name = NULL;
-
- if (display_name != NULL)
- primary_text = g_strdup_printf (
- _("Could not open '%s'"), display_name);
- else
- primary_text = g_strdup_printf (
- _("Could not open the attachment"));
-
- dialog = gtk_message_dialog_new_with_markup (
- parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<big><b>%s</b></big>", primary_text);
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_error_free (error);
-}
-
-gboolean
-e_attachment_open (EAttachment *attachment,
- GAppInfo *app_info,
- GError **error)
-{
- EAsyncClosure *closure;
- GAsyncResult *result;
- gboolean success;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
-
- closure = e_async_closure_new ();
-
- e_attachment_open_async (attachment, app_info, e_async_closure_callback, closure);
-
- result = e_async_closure_wait (closure);
-
- success = e_attachment_open_finish (attachment, result, error);
-
- e_async_closure_free (closure);
-
- return success;
-}
-
-/************************* e_attachment_save_async() *************************/
-
-typedef struct _SaveContext SaveContext;
-
-struct _SaveContext {
- EAttachment *attachment;
- GSimpleAsyncResult *simple;
-
- GFile *directory;
- GFile *destination;
- GInputStream *input_stream;
- GOutputStream *output_stream;
- goffset total_num_bytes;
- gssize bytes_read;
- gchar buffer[4096];
- gint count;
-};
-
-/* Forward Declaration */
-static void
-attachment_save_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- SaveContext *save_context);
-
-static SaveContext *
-attachment_save_context_new (EAttachment *attachment,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- SaveContext *save_context;
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (
- G_OBJECT (attachment), callback,
- user_data, e_attachment_save_async);
-
- save_context = g_slice_new0 (SaveContext);
- save_context->attachment = g_object_ref (attachment);
- save_context->simple = simple;
-
- attachment_set_saving (save_context->attachment, TRUE);
-
- return save_context;
-}
-
-static void
-attachment_save_context_free (SaveContext *save_context)
-{
- g_object_unref (save_context->attachment);
- g_object_unref (save_context->simple);
-
- if (save_context->directory != NULL)
- g_object_unref (save_context->directory);
-
- if (save_context->destination != NULL)
- g_object_unref (save_context->destination);
-
- if (save_context->input_stream != NULL)
- g_object_unref (save_context->input_stream);
-
- if (save_context->output_stream != NULL)
- g_object_unref (save_context->output_stream);
-
- g_slice_free (SaveContext, save_context);
-}
-
-static gboolean
-attachment_save_check_for_error (SaveContext *save_context,
- GError *error)
-{
- GSimpleAsyncResult *simple;
-
- if (error == NULL)
- return FALSE;
-
- simple = save_context->simple;
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
-
- attachment_save_context_free (save_context);
-
- return TRUE;
-}
-
-static GFile *
-attachment_save_new_candidate (SaveContext *save_context)
-{
- GFile *candidate;
- GFileInfo *file_info;
- EAttachment *attachment;
- const gchar *display_name = NULL;
- gchar *basename;
-
- attachment = save_context->attachment;
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info != NULL)
- display_name = g_file_info_get_display_name (file_info);
- if (display_name == NULL)
- /* Translators: Default attachment filename. */
- display_name = _("attachment.dat");
-
- if (save_context->count == 0)
- basename = g_strdup (display_name);
- else {
- GString *string;
- const gchar *ext;
- gsize length;
-
- string = g_string_sized_new (strlen (display_name));
- ext = g_utf8_strchr (display_name, -1, '.');
-
- if (ext != NULL)
- length = ext - display_name;
- else
- length = strlen (display_name);
-
- g_string_append_len (string, display_name, length);
- g_string_append_printf (string, " (%d)", save_context->count);
- g_string_append (string, (ext != NULL) ? ext : "");
-
- basename = g_string_free (string, FALSE);
- }
-
- save_context->count++;
-
- candidate = g_file_get_child (save_context->directory, basename);
-
- g_free (basename);
-
- return candidate;
-}
-
-static void
-attachment_save_write_cb (GOutputStream *output_stream,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GInputStream *input_stream;
- gssize bytes_written;
- GError *error = NULL;
-
- bytes_written = g_output_stream_write_finish (
- output_stream, result, &error);
-
- if (attachment_save_check_for_error (save_context, error))
- return;
-
- attachment = save_context->attachment;
- cancellable = attachment->priv->cancellable;
- input_stream = save_context->input_stream;
-
- if (bytes_written < save_context->bytes_read) {
- g_memmove (
- save_context->buffer,
- save_context->buffer + bytes_written,
- save_context->bytes_read - bytes_written);
- save_context->bytes_read -= bytes_written;
-
- g_output_stream_write_async (
- output_stream,
- save_context->buffer,
- save_context->bytes_read,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_write_cb,
- save_context);
- } else
- g_input_stream_read_async (
- input_stream,
- save_context->buffer,
- sizeof (save_context->buffer),
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_read_cb,
- save_context);
-}
-
-static void
-attachment_save_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GOutputStream *output_stream;
- gssize bytes_read;
- GError *error = NULL;
-
- bytes_read = g_input_stream_read_finish (
- input_stream, result, &error);
-
- if (attachment_save_check_for_error (save_context, error))
- return;
-
- if (bytes_read == 0) {
- GSimpleAsyncResult *simple;
- GFile *destination;
-
- /* Steal the destination. */
- destination = save_context->destination;
- save_context->destination = NULL;
-
- simple = save_context->simple;
- g_simple_async_result_set_op_res_gpointer (
- simple, destination, (GDestroyNotify) g_object_unref);
- g_simple_async_result_complete (simple);
-
- attachment_save_context_free (save_context);
-
- return;
- }
-
- attachment = save_context->attachment;
- cancellable = attachment->priv->cancellable;
- output_stream = save_context->output_stream;
- save_context->bytes_read = bytes_read;
-
- attachment_progress_cb (
- g_seekable_tell (G_SEEKABLE (input_stream)),
- save_context->total_num_bytes, attachment);
-
- g_output_stream_write_async (
- output_stream,
- save_context->buffer,
- save_context->bytes_read,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_write_cb,
- save_context);
-}
-
-static void
-attachment_save_got_output_stream (SaveContext *save_context)
-{
- GCancellable *cancellable;
- GInputStream *input_stream;
- CamelDataWrapper *wrapper;
- CamelMimePart *mime_part;
- CamelStream *stream;
- EAttachment *attachment;
- GByteArray *buffer;
-
- attachment = save_context->attachment;
- cancellable = attachment->priv->cancellable;
- mime_part = e_attachment_get_mime_part (attachment);
-
- /* Decode the MIME part to an in-memory buffer. We have to do
- * this because CamelStream is synchronous-only, and using threads
- * is dangerous because CamelDataWrapper is not reentrant. */
- buffer = g_byte_array_new ();
- stream = camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
- wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- camel_data_wrapper_decode_to_stream_sync (wrapper, stream, NULL, NULL);
- g_object_unref (stream);
-
- /* Load the buffer into a GMemoryInputStream.
- * But watch out for zero length MIME parts. */
- input_stream = g_memory_input_stream_new ();
- if (buffer->len > 0)
- g_memory_input_stream_add_data (
- G_MEMORY_INPUT_STREAM (input_stream),
- buffer->data, (gssize) buffer->len,
- (GDestroyNotify) g_free);
- save_context->input_stream = input_stream;
- save_context->total_num_bytes = (goffset) buffer->len;
- g_byte_array_free (buffer, FALSE);
-
- g_input_stream_read_async (
- input_stream,
- save_context->buffer,
- sizeof (save_context->buffer),
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_read_cb,
- save_context);
-}
-
-static void
-attachment_save_create_cb (GFile *destination,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GFileOutputStream *output_stream;
- GError *error = NULL;
-
- /* Output stream might be NULL, so don't use cast macro. */
- output_stream = g_file_create_finish (destination, result, &error);
- save_context->output_stream = (GOutputStream *) output_stream;
-
- attachment = save_context->attachment;
- cancellable = attachment->priv->cancellable;
-
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
- destination = attachment_save_new_candidate (save_context);
-
- g_file_create_async (
- destination, G_FILE_CREATE_NONE,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_create_cb,
- save_context);
-
- g_object_unref (destination);
- g_error_free (error);
- return;
- }
-
- if (attachment_save_check_for_error (save_context, error))
- return;
-
- save_context->destination = g_object_ref (destination);
- attachment_save_got_output_stream (save_context);
-}
-
-static void
-attachment_save_replace_cb (GFile *destination,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- GFileOutputStream *output_stream;
- GError *error = NULL;
-
- /* Output stream might be NULL, so don't use cast macro. */
- output_stream = g_file_replace_finish (destination, result, &error);
- save_context->output_stream = (GOutputStream *) output_stream;
-
- if (attachment_save_check_for_error (save_context, error))
- return;
-
- save_context->destination = g_object_ref (destination);
- attachment_save_got_output_stream (save_context);
-}
-
-static void
-attachment_save_query_info_cb (GFile *destination,
- GAsyncResult *result,
- SaveContext *save_context)
-{
- EAttachment *attachment;
- GCancellable *cancellable;
- GFileInfo *file_info;
- GFileType file_type;
- GError *error = NULL;
-
- attachment = save_context->attachment;
- cancellable = attachment->priv->cancellable;
-
- file_info = g_file_query_info_finish (destination, result, &error);
-
- /* G_IO_ERROR_NOT_FOUND just means we're creating a new file. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
- g_error_free (error);
- goto replace;
- }
-
- if (attachment_save_check_for_error (save_context, error))
- return;
-
- file_type = g_file_info_get_file_type (file_info);
- g_object_unref (file_info);
-
- if (file_type == G_FILE_TYPE_DIRECTORY) {
- save_context->directory = g_object_ref (destination);
- destination = attachment_save_new_candidate (save_context);
-
- g_file_create_async (
- destination, G_FILE_CREATE_NONE,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_create_cb,
- save_context);
-
- g_object_unref (destination);
-
- return;
- }
-
-replace:
- g_file_replace_async (
- destination, NULL, FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION,
- G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) attachment_save_replace_cb,
- save_context);
-}
-
-void
-e_attachment_save_async (EAttachment *attachment,
- GFile *destination,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- SaveContext *save_context;
- GCancellable *cancellable;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_return_if_fail (G_IS_FILE (destination));
-
- if (e_attachment_get_loading (attachment)) {
- g_simple_async_report_error_in_idle (
- G_OBJECT (attachment), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_BUSY,
- _("A load operation is already in progress"));
- return;
- }
-
- if (e_attachment_get_saving (attachment)) {
- g_simple_async_report_error_in_idle (
- G_OBJECT (attachment), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_BUSY,
- _("A save operation is already in progress"));
- return;
- }
-
- if (e_attachment_get_mime_part (attachment) == NULL) {
- g_simple_async_report_error_in_idle (
- G_OBJECT (attachment), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Attachment contents not loaded"));
- return;
- }
-
- save_context = attachment_save_context_new (
- attachment, callback, user_data);
-
- cancellable = attachment->priv->cancellable;
- g_cancellable_reset (cancellable);
-
- /* First we need to know if destination is a directory. */
- g_file_query_info_async (
- destination, G_FILE_ATTRIBUTE_STANDARD_TYPE,
- G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- attachment_save_query_info_cb, save_context);
-}
-
-GFile *
-e_attachment_save_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GFile *destination;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- destination = g_simple_async_result_get_op_res_gpointer (simple);
- if (destination != NULL)
- g_object_ref (destination);
- g_simple_async_result_propagate_error (simple, error);
-
- attachment_set_saving (attachment, FALSE);
-
- return destination;
-}
-
-void
-e_attachment_save_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent)
-{
- GFile *file;
- GFileInfo *file_info;
- GtkWidget *dialog;
- const gchar *display_name;
- const gchar *primary_text;
- GError *error = NULL;
-
- g_return_if_fail (E_IS_ATTACHMENT (attachment));
- g_return_if_fail (G_IS_ASYNC_RESULT (result));
- g_return_if_fail (GTK_IS_WINDOW (parent));
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- if (file != NULL) {
- g_object_unref (file);
- return;
- }
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- return;
-
- file_info = e_attachment_get_file_info (attachment);
-
- if (file_info != NULL)
- display_name = g_file_info_get_display_name (file_info);
- else
- display_name = NULL;
-
- if (display_name != NULL)
- primary_text = g_strdup_printf (
- _("Could not save '%s'"), display_name);
- else
- primary_text = g_strdup_printf (
- _("Could not save the attachment"));
-
- dialog = gtk_message_dialog_new_with_markup (
- parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<big><b>%s</b></big>", primary_text);
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_error_free (error);
-}
-
-gboolean
-e_attachment_save (EAttachment *attachment,
- GFile *in_destination,
- GFile **out_destination,
- GError **error)
-{
- EAsyncClosure *closure;
- GAsyncResult *result;
-
- g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
- g_return_val_if_fail (out_destination != NULL, FALSE);
-
- closure = e_async_closure_new ();
-
- e_attachment_save_async (attachment, in_destination, e_async_closure_callback, closure);
-
- result = e_async_closure_wait (closure);
-
- *out_destination = e_attachment_save_finish (attachment, result, error);
-
- e_async_closure_free (closure);
-
- return *out_destination != NULL;
-}
diff --git a/widgets/misc/e-attachment.h b/widgets/misc/e-attachment.h
deleted file mode 100644
index 890c13294e..0000000000
--- a/widgets/misc/e-attachment.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * e-attachment.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_ATTACHMENT_H
-#define E_ATTACHMENT_H
-
-#include <gtk/gtk.h>
-#include <camel/camel.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT \
- (e_attachment_get_type ())
-#define E_ATTACHMENT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT, EAttachment))
-#define E_ATTACHMENT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT, EAttachmentClass))
-#define E_IS_ATTACHMENT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT))
-#define E_IS_ATTACHMENT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT))
-#define E_ATTACHMENT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT, EAttachmentClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachment EAttachment;
-typedef struct _EAttachmentClass EAttachmentClass;
-typedef struct _EAttachmentPrivate EAttachmentPrivate;
-
-struct _EAttachment {
- GObject parent;
- EAttachmentPrivate *priv;
-};
-
-struct _EAttachmentClass {
- GObjectClass parent_class;
-};
-
-GType e_attachment_get_type (void);
-EAttachment * e_attachment_new (void);
-EAttachment * e_attachment_new_for_path (const gchar *path);
-EAttachment * e_attachment_new_for_uri (const gchar *uri);
-EAttachment * e_attachment_new_for_message (CamelMimeMessage *message);
-void e_attachment_add_to_multipart (EAttachment *attachment,
- CamelMultipart *multipart,
- const gchar *default_charset);
-void e_attachment_cancel (EAttachment *attachment);
-gboolean e_attachment_get_can_show (EAttachment *attachment);
-void e_attachment_set_can_show (EAttachment *attachment,
- gboolean can_show);
-const gchar * e_attachment_get_disposition (EAttachment *attachment);
-void e_attachment_set_disposition (EAttachment *attachment,
- const gchar *disposition);
-GFile * e_attachment_get_file (EAttachment *attachment);
-void e_attachment_set_file (EAttachment *attachment,
- GFile *file);
-GFileInfo * e_attachment_get_file_info (EAttachment *attachment);
-void e_attachment_set_file_info (EAttachment *attachment,
- GFileInfo *file_info);
-gchar * e_attachment_get_mime_type (EAttachment *attachment);
-GIcon * e_attachment_get_icon (EAttachment *attachment);
-gboolean e_attachment_get_loading (EAttachment *attachment);
-CamelMimePart * e_attachment_get_mime_part (EAttachment *attachment);
-void e_attachment_set_mime_part (EAttachment *attachment,
- CamelMimePart *mime_part);
-gint e_attachment_get_percent (EAttachment *attachment);
-GtkTreeRowReference *
- e_attachment_get_reference (EAttachment *attachment);
-void e_attachment_set_reference (EAttachment *attachment,
- GtkTreeRowReference *reference);
-gboolean e_attachment_get_saving (EAttachment *attachment);
-gboolean e_attachment_get_shown (EAttachment *attachment);
-void e_attachment_set_shown (EAttachment *attachment,
- gboolean shown);
-camel_cipher_validity_encrypt_t
- e_attachment_get_encrypted (EAttachment *attachment);
-void e_attachment_set_encrypted (EAttachment *attachment,
- camel_cipher_validity_encrypt_t encrypted);
-camel_cipher_validity_sign_t
- e_attachment_get_signed (EAttachment *attachment);
-void e_attachment_set_signed (EAttachment *attachment,
- camel_cipher_validity_sign_t signed_);
-const gchar * e_attachment_get_description (EAttachment *attachment);
-const gchar * e_attachment_get_thumbnail_path (EAttachment *attachment);
-gboolean e_attachment_is_rfc822 (EAttachment *attachment);
-GList * e_attachment_list_apps (EAttachment *attachment);
-
-/* Asynchronous Operations */
-void e_attachment_load_async (EAttachment *attachment,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_attachment_load_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error);
-gboolean e_attachment_load (EAttachment *attachment,
- GError **error);
-void e_attachment_open_async (EAttachment *attachment,
- GAppInfo *app_info,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_attachment_open_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error);
-gboolean e_attachment_open (EAttachment *attachment,
- GAppInfo *app_info,
- GError **error);
-void e_attachment_save_async (EAttachment *attachment,
- GFile *destination,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFile * e_attachment_save_finish (EAttachment *attachment,
- GAsyncResult *result,
- GError **error);
-gboolean e_attachment_save (EAttachment *attachment,
- GFile *in_destination,
- GFile **out_destination,
- GError **error);
-
-/* Handy GAsyncReadyCallback Functions */
-void e_attachment_load_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent);
-void e_attachment_open_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent);
-void e_attachment_save_handle_error (EAttachment *attachment,
- GAsyncResult *result,
- GtkWindow *parent);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_H */
diff --git a/widgets/misc/e-auth-combo-box.c b/widgets/misc/e-auth-combo-box.c
deleted file mode 100644
index bd3d8c78ea..0000000000
--- a/widgets/misc/e-auth-combo-box.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * e-auth-combo-box.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-auth-combo-box.h"
-
-#define E_AUTH_COMBO_BOX_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_AUTH_COMBO_BOX, EAuthComboBoxPrivate))
-
-struct _EAuthComboBoxPrivate {
- CamelProvider *provider;
-};
-
-enum {
- PROP_0,
- PROP_PROVIDER
-};
-
-enum {
- COLUMN_MECHANISM,
- COLUMN_DISPLAY_NAME,
- COLUMN_STRIKETHROUGH,
- COLUMN_AUTHTYPE,
- NUM_COLUMNS
-};
-
-G_DEFINE_TYPE (
- EAuthComboBox,
- e_auth_combo_box,
- GTK_TYPE_COMBO_BOX)
-
-static void
-auth_combo_box_rebuild_model (EAuthComboBox *combo_box)
-{
- GtkComboBox *gtk_combo_box;
- CamelProvider *provider;
- GtkTreeModel *model;
- GList *link;
- const gchar *active_id;
-
- provider = e_auth_combo_box_get_provider (combo_box);
-
- gtk_combo_box = GTK_COMBO_BOX (combo_box);
- model = gtk_combo_box_get_model (gtk_combo_box);
- active_id = gtk_combo_box_get_active_id (gtk_combo_box);
-
- gtk_list_store_clear (GTK_LIST_STORE (model));
-
- if (provider == NULL)
- return;
-
- for (link = provider->authtypes; link != NULL; link = link->next) {
- CamelServiceAuthType *authtype = link->data;
- GtkTreeIter iter;
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- COLUMN_MECHANISM, authtype->authproto,
- COLUMN_DISPLAY_NAME, authtype->name,
- COLUMN_AUTHTYPE, authtype,
- -1);
- }
-
- /* Try selecting the previous mechanism. */
- if (active_id != NULL)
- gtk_combo_box_set_active_id (gtk_combo_box, active_id);
-
- /* Or else fall back to the first mechanism. */
- if (gtk_combo_box_get_active (gtk_combo_box) == -1)
- gtk_combo_box_set_active (gtk_combo_box, 0);
-}
-
-static void
-auth_combo_box_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PROVIDER:
- e_auth_combo_box_set_provider (
- E_AUTH_COMBO_BOX (object),
- g_value_get_pointer (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-auth_combo_box_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PROVIDER:
- g_value_set_pointer (
- value,
- e_auth_combo_box_get_provider (
- E_AUTH_COMBO_BOX (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-auth_combo_box_constructed (GObject *object)
-{
- GtkComboBox *combo_box;
- GtkListStore *list_store;
- GtkCellLayout *cell_layout;
- GtkCellRenderer *cell_renderer;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_auth_combo_box_parent_class)->constructed (object);
-
- list_store = gtk_list_store_new (
- NUM_COLUMNS,
- G_TYPE_STRING, /* COLUMN_MECHANISM */
- G_TYPE_STRING, /* COLUMN_DISPLAY_NAME */
- G_TYPE_BOOLEAN, /* COLUMN_STRIKETHROUGH */
- G_TYPE_POINTER); /* COLUMN_AUTHTYPE */
-
- combo_box = GTK_COMBO_BOX (object);
- gtk_combo_box_set_model (combo_box, GTK_TREE_MODEL (list_store));
- gtk_combo_box_set_id_column (combo_box, COLUMN_MECHANISM);
- g_object_unref (list_store);
-
- cell_layout = GTK_CELL_LAYOUT (object);
- cell_renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (cell_layout, cell_renderer, TRUE);
-
- gtk_cell_layout_set_attributes (
- cell_layout, cell_renderer,
- "text", COLUMN_DISPLAY_NAME,
- "strikethrough", COLUMN_STRIKETHROUGH,
- NULL);
-}
-
-static void
-e_auth_combo_box_class_init (EAuthComboBoxClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EAuthComboBoxPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = auth_combo_box_set_property;
- object_class->get_property = auth_combo_box_get_property;
- object_class->constructed = auth_combo_box_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_PROVIDER,
- g_param_spec_pointer (
- "provider",
- "Provider",
- "The provider to query for auth mechanisms",
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_auth_combo_box_init (EAuthComboBox *combo_box)
-{
- combo_box->priv = E_AUTH_COMBO_BOX_GET_PRIVATE (combo_box);
-}
-
-GtkWidget *
-e_auth_combo_box_new (void)
-{
- return g_object_new (E_TYPE_AUTH_COMBO_BOX, NULL);
-}
-
-CamelProvider *
-e_auth_combo_box_get_provider (EAuthComboBox *combo_box)
-{
- g_return_val_if_fail (E_IS_AUTH_COMBO_BOX (combo_box), NULL);
-
- return combo_box->priv->provider;
-}
-
-void
-e_auth_combo_box_set_provider (EAuthComboBox *combo_box,
- CamelProvider *provider)
-{
- g_return_if_fail (E_IS_AUTH_COMBO_BOX (combo_box));
-
- if (provider == combo_box->priv->provider)
- return;
-
- combo_box->priv->provider = provider;
-
- g_object_notify (G_OBJECT (combo_box), "provider");
-
- auth_combo_box_rebuild_model (combo_box);
-}
-
-void
-e_auth_combo_box_update_available (EAuthComboBox *combo_box,
- GList *available_authtypes)
-{
- GtkComboBox *gtk_combo_box;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gint active_index;
- gint available_index = -1;
- gint index = 0;
- gboolean iter_set;
-
- g_return_if_fail (E_IS_AUTH_COMBO_BOX (combo_box));
-
- gtk_combo_box = GTK_COMBO_BOX (combo_box);
- model = gtk_combo_box_get_model (gtk_combo_box);
- active_index = gtk_combo_box_get_active (gtk_combo_box);
-
- iter_set = gtk_tree_model_get_iter_first (model, &iter);
-
- while (iter_set) {
- CamelServiceAuthType *authtype;
- gboolean available;
-
- gtk_tree_model_get (
- model, &iter, COLUMN_AUTHTYPE, &authtype, -1);
-
- available = (g_list_find (
- available_authtypes, authtype) != NULL);
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- COLUMN_STRIKETHROUGH, !available, -1);
-
- if (index == active_index && !available)
- active_index = -1;
-
- if (available && available_index == -1)
- available_index = index;
-
- iter_set = gtk_tree_model_iter_next (model, &iter);
- index++;
- }
-
- /* If the active combo_box item turned out to be unavailable
- * (or there was no active item), select the first available. */
- if (active_index == -1 && available_index != -1)
- gtk_combo_box_set_active (gtk_combo_box, available_index);
-}
diff --git a/widgets/misc/e-auth-combo-box.h b/widgets/misc/e-auth-combo-box.h
deleted file mode 100644
index e449f1c06b..0000000000
--- a/widgets/misc/e-auth-combo-box.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * e-auth-combo-box.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_AUTH_COMBO_BOX_H
-#define E_AUTH_COMBO_BOX_H
-
-#include <gtk/gtk.h>
-#include <camel/camel.h>
-
-/* Standard GObject macros */
-#define E_TYPE_AUTH_COMBO_BOX \
- (e_auth_combo_box_get_type ())
-#define E_AUTH_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_AUTH_COMBO_BOX, EAuthComboBox))
-#define E_AUTH_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_AUTH_COMBO_BOX, EAuthComboBoxClass))
-#define E_IS_AUTH_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_AUTH_COMBO_BOX))
-#define E_IS_AUTH_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_AUTH_COMBO_BOX))
-#define E_AUTH_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_AUTH_COMBO_BOX, EAuthComboBoxClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAuthComboBox EAuthComboBox;
-typedef struct _EAuthComboBoxClass EAuthComboBoxClass;
-typedef struct _EAuthComboBoxPrivate EAuthComboBoxPrivate;
-
-struct _EAuthComboBox {
- GtkComboBox parent;
- EAuthComboBoxPrivate *priv;
-};
-
-struct _EAuthComboBoxClass {
- GtkComboBoxClass parent_class;
-};
-
-GType e_auth_combo_box_get_type (void) G_GNUC_CONST;
-GtkWidget * e_auth_combo_box_new (void);
-CamelProvider * e_auth_combo_box_get_provider (EAuthComboBox *combo_box);
-void e_auth_combo_box_set_provider (EAuthComboBox *combo_box,
- CamelProvider *provider);
-void e_auth_combo_box_update_available
- (EAuthComboBox *combo_box,
- GList *available_authtypes);
-
-G_END_DECLS
-
-#endif /* E_AUTH_COMBO_BOX_H */
-
diff --git a/widgets/misc/e-autocomplete-selector.c b/widgets/misc/e-autocomplete-selector.c
deleted file mode 100644
index c0bf207bbd..0000000000
--- a/widgets/misc/e-autocomplete-selector.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * e-autocomplete-selector.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-autocomplete-selector.h"
-
-G_DEFINE_TYPE (
- EAutocompleteSelector,
- e_autocomplete_selector,
- E_TYPE_SOURCE_SELECTOR)
-
-static gboolean
-autocomplete_selector_get_source_selected (ESourceSelector *selector,
- ESource *source)
-{
- ESourceAutocomplete *extension;
- const gchar *extension_name;
-
- /* Make sure this source is an address book. */
- extension_name = e_source_selector_get_extension_name (selector);
- if (!e_source_has_extension (source, extension_name))
- return FALSE;
-
- extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
- extension = e_source_get_extension (source, extension_name);
- g_return_val_if_fail (E_IS_SOURCE_AUTOCOMPLETE (extension), FALSE);
-
- return e_source_autocomplete_get_include_me (extension);
-}
-
-static void
-autocomplete_selector_set_source_selected (ESourceSelector *selector,
- ESource *source,
- gboolean selected)
-{
- ESourceAutocomplete *extension;
- const gchar *extension_name;
-
- /* Make sure this source is an address book. */
- extension_name = e_source_selector_get_extension_name (selector);
- if (!e_source_has_extension (source, extension_name))
- return;
-
- extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
- extension = e_source_get_extension (source, extension_name);
- g_return_if_fail (E_IS_SOURCE_AUTOCOMPLETE (extension));
-
- if (selected != e_source_autocomplete_get_include_me (extension)) {
- e_source_autocomplete_set_include_me (extension, selected);
- e_source_selector_queue_write (selector, source);
- }
-}
-
-static void
-e_autocomplete_selector_class_init (EAutocompleteSelectorClass *class)
-{
- ESourceSelectorClass *source_selector_class;
-
- source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
- source_selector_class->get_source_selected =
- autocomplete_selector_get_source_selected;
- source_selector_class->set_source_selected =
- autocomplete_selector_set_source_selected;
-}
-
-static void
-e_autocomplete_selector_init (EAutocompleteSelector *selector)
-{
- e_source_selector_set_show_colors (
- E_SOURCE_SELECTOR (selector), FALSE);
-}
-
-GtkWidget *
-e_autocomplete_selector_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_AUTOCOMPLETE_SELECTOR,
- "extension-name", E_SOURCE_EXTENSION_ADDRESS_BOOK,
- "registry", registry, NULL);
-}
diff --git a/widgets/misc/e-autocomplete-selector.h b/widgets/misc/e-autocomplete-selector.h
deleted file mode 100644
index 4e44efc7f3..0000000000
--- a/widgets/misc/e-autocomplete-selector.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * e-autocomplete-selector.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_AUTOCOMPLETE_SELECTOR_H
-#define E_AUTOCOMPLETE_SELECTOR_H
-
-#include <libedataserverui/libedataserverui.h>
-
-/* Standard GObject macros */
-#define E_TYPE_AUTOCOMPLETE_SELECTOR \
- (e_autocomplete_selector_get_type ())
-#define E_AUTOCOMPLETE_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelector))
-#define E_AUTOCOMPLETE_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelectorClass))
-#define E_IS_AUTOCOMPLETE_SELECTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR))
-#define E_IS_AUTOCOMPLETE_SELECTOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_AUTOCOMPLETE_SELECTOR))
-#define E_AUTOCOMPLETE_SELECTOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelectorClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAutocompleteSelector EAutocompleteSelector;
-typedef struct _EAutocompleteSelectorClass EAutocompleteSelectorClass;
-typedef struct _EAutocompleteSelectorPrivate EAutocompleteSelectorPrivate;
-
-struct _EAutocompleteSelector {
- ESourceSelector parent;
- EAutocompleteSelectorPrivate *priv;
-};
-
-struct _EAutocompleteSelectorClass {
- ESourceSelectorClass parent_class;
-};
-
-GType e_autocomplete_selector_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_autocomplete_selector_new (ESourceRegistry *registry);
-
-G_END_DECLS
-
-#endif /* E_AUTOCOMPLETE_SELECTOR_H */
diff --git a/widgets/misc/e-book-source-config.c b/widgets/misc/e-book-source-config.c
deleted file mode 100644
index 56d9771d9f..0000000000
--- a/widgets/misc/e-book-source-config.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * e-book-source-config.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-book-source-config.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#define E_BOOK_SOURCE_CONFIG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_BOOK_SOURCE_CONFIG, EBookSourceConfigPrivate))
-
-struct _EBookSourceConfigPrivate {
- GtkWidget *default_button;
- GtkWidget *autocomplete_button;
-};
-
-G_DEFINE_TYPE (
- EBookSourceConfig,
- e_book_source_config,
- E_TYPE_SOURCE_CONFIG)
-
-static ESource *
-book_source_config_ref_default (ESourceConfig *config)
-{
- ESourceRegistry *registry;
-
- registry = e_source_config_get_registry (config);
-
- return e_source_registry_ref_default_address_book (registry);
-}
-
-static void
-book_source_config_set_default (ESourceConfig *config,
- ESource *source)
-{
- ESourceRegistry *registry;
-
- registry = e_source_config_get_registry (config);
-
- e_source_registry_set_default_address_book (registry, source);
-}
-
-static void
-book_source_config_dispose (GObject *object)
-{
- EBookSourceConfigPrivate *priv;
-
- priv = E_BOOK_SOURCE_CONFIG_GET_PRIVATE (object);
-
- if (priv->default_button != NULL) {
- g_object_unref (priv->default_button);
- priv->default_button = NULL;
- }
-
- if (priv->autocomplete_button != NULL) {
- g_object_unref (priv->autocomplete_button);
- priv->autocomplete_button = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_book_source_config_parent_class)->dispose (object);
-}
-
-static void
-book_source_config_constructed (GObject *object)
-{
- EBookSourceConfigPrivate *priv;
- ESource *default_source;
- ESource *original_source;
- ESourceConfig *config;
- GObjectClass *class;
- GtkWidget *widget;
- const gchar *label;
-
- /* Chain up to parent's constructed() method. */
- class = G_OBJECT_CLASS (e_book_source_config_parent_class);
- class->constructed (object);
-
- config = E_SOURCE_CONFIG (object);
- priv = E_BOOK_SOURCE_CONFIG_GET_PRIVATE (object);
-
- label = _("Mark as default address book");
- widget = gtk_check_button_new_with_label (label);
- priv->default_button = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- label = _("Autocomplete with this address book");
- widget = gtk_check_button_new_with_label (label);
- priv->autocomplete_button = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- default_source = book_source_config_ref_default (config);
- original_source = e_source_config_get_original_source (config);
-
- if (original_source != NULL) {
- gboolean active;
-
- active = e_source_equal (original_source, default_source);
- g_object_set (priv->default_button, "active", active, NULL);
- }
-
- g_object_unref (default_source);
-
- e_source_config_insert_widget (
- config, NULL, NULL, priv->default_button);
-
- e_source_config_insert_widget (
- config, NULL, NULL, priv->autocomplete_button);
-}
-
-static const gchar *
-book_source_config_get_backend_extension_name (ESourceConfig *config)
-{
- return E_SOURCE_EXTENSION_ADDRESS_BOOK;
-}
-
-static GList *
-book_source_config_list_eligible_collections (ESourceConfig *config)
-{
- GQueue trash = G_QUEUE_INIT;
- GList *list, *link;
-
- /* Chain up to parent's list_eligible_collections() method. */
- list = E_SOURCE_CONFIG_CLASS (e_book_source_config_parent_class)->
- list_eligible_collections (config);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESource *source = E_SOURCE (link->data);
- ESourceCollection *extension;
- const gchar *extension_name;
-
- extension_name = E_SOURCE_EXTENSION_COLLECTION;
- extension = e_source_get_extension (source, extension_name);
-
- if (!e_source_collection_get_contacts_enabled (extension))
- g_queue_push_tail (&trash, link);
- }
-
- /* Remove ineligible collections from the list. */
- while ((link = g_queue_pop_head (&trash)) != NULL) {
- g_object_unref (link->data);
- list = g_list_delete_link (list, link);
- }
-
- return list;
-}
-
-static void
-book_source_config_init_candidate (ESourceConfig *config,
- ESource *scratch_source)
-{
- EBookSourceConfigPrivate *priv;
- ESourceConfigClass *class;
- ESourceExtension *extension;
- const gchar *extension_name;
-
- /* Chain up to parent's init_candidate() method. */
- class = E_SOURCE_CONFIG_CLASS (e_book_source_config_parent_class);
- class->init_candidate (config, scratch_source);
-
- priv = E_BOOK_SOURCE_CONFIG_GET_PRIVATE (config);
-
- extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- g_object_bind_property (
- extension, "include-me",
- priv->autocomplete_button, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
-
-static void
-book_source_config_commit_changes (ESourceConfig *config,
- ESource *scratch_source)
-{
- EBookSourceConfigPrivate *priv;
- ESourceConfigClass *class;
- ESource *default_source;
- GtkToggleButton *toggle_button;
-
- priv = E_BOOK_SOURCE_CONFIG_GET_PRIVATE (config);
- toggle_button = GTK_TOGGLE_BUTTON (priv->default_button);
-
- /* Chain up to parent's commit_changes() method. */
- class = E_SOURCE_CONFIG_CLASS (e_book_source_config_parent_class);
- class->commit_changes (config, scratch_source);
-
- default_source = book_source_config_ref_default (config);
-
- /* The default setting is a little tricky to get right. If
- * the toggle button is active, this ESource is now the default.
- * That much is simple. But if the toggle button is NOT active,
- * then we have to inspect the old default. If this ESource WAS
- * the default, reset the default to 'system'. If this ESource
- * WAS NOT the old default, leave it alone. */
- if (gtk_toggle_button_get_active (toggle_button))
- book_source_config_set_default (config, scratch_source);
- else if (e_source_equal (scratch_source, default_source))
- book_source_config_set_default (config, NULL);
-
- g_object_unref (default_source);
-}
-
-static void
-e_book_source_config_class_init (EBookSourceConfigClass *class)
-{
- GObjectClass *object_class;
- ESourceConfigClass *source_config_class;
-
- g_type_class_add_private (class, sizeof (EBookSourceConfigPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = book_source_config_dispose;
- object_class->constructed = book_source_config_constructed;
-
- source_config_class = E_SOURCE_CONFIG_CLASS (class);
- source_config_class->get_backend_extension_name =
- book_source_config_get_backend_extension_name;
- source_config_class->list_eligible_collections =
- book_source_config_list_eligible_collections;
- source_config_class->init_candidate = book_source_config_init_candidate;
- source_config_class->commit_changes = book_source_config_commit_changes;
-}
-
-static void
-e_book_source_config_init (EBookSourceConfig *config)
-{
- config->priv = E_BOOK_SOURCE_CONFIG_GET_PRIVATE (config);
-}
-
-GtkWidget *
-e_book_source_config_new (ESourceRegistry *registry,
- ESource *original_source)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- if (original_source != NULL)
- g_return_val_if_fail (E_IS_SOURCE (original_source), NULL);
-
- return g_object_new (
- E_TYPE_BOOK_SOURCE_CONFIG, "registry", registry,
- "original-source", original_source, NULL);
-}
-
-void
-e_book_source_config_add_offline_toggle (EBookSourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget;
- ESourceExtension *extension;
- const gchar *extension_name;
-
- g_return_if_fail (E_IS_BOOK_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_OFFLINE;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- widget = gtk_check_button_new_with_label (
- _("Copy book content locally for offline operation"));
- e_source_config_insert_widget (
- E_SOURCE_CONFIG (config), scratch_source, NULL, widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- extension, "stay-synchronized",
- widget, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
diff --git a/widgets/misc/e-book-source-config.h b/widgets/misc/e-book-source-config.h
deleted file mode 100644
index 18e075511e..0000000000
--- a/widgets/misc/e-book-source-config.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * e-book-source-config.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_BOOK_SOURCE_CONFIG_H
-#define E_BOOK_SOURCE_CONFIG_H
-
-#include <misc/e-source-config.h>
-
-/* Standard GObject macros */
-#define E_TYPE_BOOK_SOURCE_CONFIG \
- (e_book_source_config_get_type ())
-#define E_BOOK_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_BOOK_SOURCE_CONFIG, EBookSourceConfig))
-#define E_BOOK_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_BOOK_SOURCE_CONFIG, EBookSourceConfigClass))
-#define E_IS_BOOK_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_BOOK_SOURCE_CONFIG))
-#define E_IS_BOOK_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_BOOK_SOURCE_CONFIG))
-#define E_BOOK_SOURCE_CONFIG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_BOOK_SOURCE_CONFIG, EBookSourceConfigClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EBookSourceConfig EBookSourceConfig;
-typedef struct _EBookSourceConfigClass EBookSourceConfigClass;
-typedef struct _EBookSourceConfigPrivate EBookSourceConfigPrivate;
-
-struct _EBookSourceConfig {
- ESourceConfig parent;
- EBookSourceConfigPrivate *priv;
-};
-
-struct _EBookSourceConfigClass {
- ESourceConfigClass parent_class;
-};
-
-GType e_book_source_config_get_type (void) G_GNUC_CONST;
-GtkWidget * e_book_source_config_new (ESourceRegistry *registry,
- ESource *original_source);
-void e_book_source_config_add_offline_toggle
- (EBookSourceConfig *config,
- ESource *scratch_source);
-
-G_END_DECLS
-
-#endif /* E_BOOK_SOURCE_CONFIG_H */
diff --git a/widgets/misc/e-buffer-tagger.c b/widgets/misc/e-buffer-tagger.c
deleted file mode 100644
index b68d414868..0000000000
--- a/widgets/misc/e-buffer-tagger.c
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * e-buffer-tagger.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <glib/gi18n.h>
-#include <regex.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "e-util/e-util.h"
-#include "e-buffer-tagger.h"
-
-enum EBufferTaggerState
-{
- E_BUFFER_TAGGER_STATE_NONE = 0,
- E_BUFFER_TAGGER_STATE_INSDEL = 1 << 0, /* set when was called insert or delete of a text */
- E_BUFFER_TAGGER_STATE_CHANGED = 1 << 1, /* remark of the buffer is scheduled */
- E_BUFFER_TAGGER_STATE_IS_HOVERING = 1 << 2, /* mouse is over the link */
- E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP = 1 << 3, /* mouse is over the link and the tooltip can be shown */
- E_BUFFER_TAGGER_STATE_CTRL_DOWN = 1 << 4 /* Ctrl key is down */
-};
-
-#define E_BUFFER_TAGGER_DATA_STATE "EBufferTagger::state"
-#define E_BUFFER_TAGGER_LINK_TAG "EBufferTagger::link"
-
-struct _MagicInsertMatch
-{
- const gchar *regex;
- regex_t *preg;
- const gchar *prefix;
-};
-
-typedef struct _MagicInsertMatch MagicInsertMatch;
-
-static MagicInsertMatch mim[] = {
- /* prefixed expressions */
- { "(news|telnet|nntp|file|http|ftp|sftp|https|webcal)://([-a-z0-9]+(:[-a-z0-9]+)?@)?[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(([.])?/[-a-z0-9_$.+!*(),;:@%&=?/~#']*[^]'.}>\\) \n\r\t,?!;:\"]?)?", NULL, NULL },
- { "(sip|h323|callto):([-_a-z0-9.'\\+]+(:[0-9]{1,5})?(/[-_a-z0-9.']+)?)(@([-_a-z0-9.%=?]+|([0-9]{1,3}.){3}[0-9]{1,3})?)?(:[0-9]{1,5})?", NULL, NULL },
- { "mailto:[-_a-z0-9.'\\+]+@[-_a-z0-9.%=?]+", NULL, NULL },
- /* not prefixed expression */
- { "www\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(([.])?/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]'.}>\\) \n\r\t,?!;:\"]?)?", NULL, "http://" },
- { "ftp\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(([.])?/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]'.}>\\) \n\r\t,?!;:\"]?)?", NULL, "ftp://" },
- { "[-_a-z0-9.'\\+]+@[-_a-z0-9.%=?]+", NULL, "mailto:" }
-};
-
-static void
-init_magic_links (void)
-{
- static gboolean done = FALSE;
- gint i;
-
- if (done)
- return;
-
- done = TRUE;
-
- for (i = 0; i < G_N_ELEMENTS (mim); i++) {
- mim[i].preg = g_new0 (regex_t, 1);
- if (regcomp (mim[i].preg, mim[i].regex, REG_EXTENDED | REG_ICASE)) {
- /* error */
- g_free (mim[i].preg);
- mim[i].preg = 0;
- }
- }
-}
-
-static void
-markup_text (GtkTextBuffer *buffer)
-{
- GtkTextIter start, end;
- gchar *text;
- gint i;
- regmatch_t pmatch[2];
- gboolean any;
- const gchar *str;
- gint offset = 0;
-
- g_return_if_fail (buffer != NULL);
-
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
- gtk_text_buffer_remove_tag_by_name (buffer, E_BUFFER_TAGGER_LINK_TAG, &start, &end);
- text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
-
- str = text;
- any = TRUE;
- while (any) {
- any = FALSE;
- for (i = 0; i < G_N_ELEMENTS (mim); i++) {
- if (mim[i].preg && !regexec (mim[i].preg, str, 2, pmatch, 0)) {
- gtk_text_buffer_get_iter_at_offset (buffer, &start, offset + pmatch[0].rm_so);
- gtk_text_buffer_get_iter_at_offset (buffer, &end, offset + pmatch[0].rm_eo);
- gtk_text_buffer_apply_tag_by_name (buffer, E_BUFFER_TAGGER_LINK_TAG, &start, &end);
-
- any = TRUE;
- str += pmatch[0].rm_eo;
- offset += pmatch[0].rm_eo;
- break;
- }
- }
- }
-
- g_free (text);
-}
-
-static void
-get_pointer_position (GtkTextView *text_view,
- gint *x,
- gint *y)
-{
- GdkWindow *window;
- GdkDisplay *display;
- GdkDeviceManager *device_manager;
- GdkDevice *device;
-
- window = gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_WIDGET);
- display = gdk_window_get_display (window);
- device_manager = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (device_manager);
-
- gdk_window_get_device_position (window, device, x, y, NULL);
-}
-
-static guint32
-get_state (GtkTextBuffer *buffer)
-{
- g_return_val_if_fail (buffer != NULL, E_BUFFER_TAGGER_STATE_NONE);
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), E_BUFFER_TAGGER_STATE_NONE);
-
- return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (buffer), E_BUFFER_TAGGER_DATA_STATE));
-}
-
-static void
-set_state (GtkTextBuffer *buffer,
- guint32 state)
-{
- g_object_set_data (G_OBJECT (buffer), E_BUFFER_TAGGER_DATA_STATE, GINT_TO_POINTER (state));
-}
-
-static void
-update_state (GtkTextBuffer *buffer,
- guint32 value,
- gboolean do_set)
-{
- guint32 state;
-
- g_return_if_fail (buffer != NULL);
- g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
-
- state = get_state (buffer);
-
- if (do_set)
- state = state | value;
- else
- state = state & (~value);
-
- set_state (buffer, state);
-}
-
-static gboolean
-get_tag_bounds (GtkTextIter *iter,
- GtkTextTag *tag,
- GtkTextIter *start,
- GtkTextIter *end)
-{
- gboolean res = FALSE;
-
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (tag != NULL, FALSE);
- g_return_val_if_fail (start != NULL, FALSE);
- g_return_val_if_fail (end != NULL, FALSE);
-
- if (gtk_text_iter_has_tag (iter, tag)) {
- *start = *iter;
- *end = *iter;
-
- if (!gtk_text_iter_begins_tag (start, tag))
- gtk_text_iter_backward_to_tag_toggle (start, tag);
-
- if (!gtk_text_iter_ends_tag (end, tag))
- gtk_text_iter_forward_to_tag_toggle (end, tag);
-
- res = TRUE;
- }
-
- return res;
-}
-
-static gchar *
-get_url_at_iter (GtkTextBuffer *buffer,
- GtkTextIter *iter)
-{
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
- GtkTextIter start, end;
- gchar *url = NULL;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
- g_return_val_if_fail (tag != NULL, FALSE);
-
- if (get_tag_bounds (iter, tag, &start, &end))
- url = gtk_text_iter_get_text (&start, &end);
-
- return url;
-}
-
-static gboolean
-invoke_link_if_present (GtkTextBuffer *buffer,
- GtkTextIter *iter)
-{
- gboolean res;
- gchar *url;
-
- g_return_val_if_fail (buffer != NULL, FALSE);
-
- url = get_url_at_iter (buffer, iter);
-
- res = url && *url;
- if (res)
- e_show_uri (NULL, url);
-
- g_free (url);
-
- return res;
-}
-
-static void
-remove_tag_if_present (GtkTextBuffer *buffer,
- GtkTextIter *where)
-{
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
- GtkTextIter start, end;
-
- g_return_if_fail (buffer != NULL);
- g_return_if_fail (where != NULL);
-
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
- g_return_if_fail (tag != NULL);
-
- if (get_tag_bounds (where, tag, &start, &end))
- gtk_text_buffer_remove_tag (buffer, tag, &start, &end);
-}
-
-static void
-buffer_insert_text (GtkTextBuffer *buffer,
- GtkTextIter *location,
- gchar *text,
- gint len,
- gpointer user_data)
-{
- update_state (buffer, E_BUFFER_TAGGER_STATE_INSDEL, TRUE);
- remove_tag_if_present (buffer, location);
-}
-
-static void
-buffer_delete_range (GtkTextBuffer *buffer,
- GtkTextIter *start,
- GtkTextIter *end,
- gpointer user_data)
-{
- update_state (buffer, E_BUFFER_TAGGER_STATE_INSDEL, TRUE);
- remove_tag_if_present (buffer, start);
- remove_tag_if_present (buffer, end);
-}
-
-static void
-buffer_cursor_position (GtkTextBuffer *buffer,
- gpointer user_data)
-{
- guint32 state;
-
- state = get_state (buffer);
- if (state & E_BUFFER_TAGGER_STATE_INSDEL) {
- state = (state & (~E_BUFFER_TAGGER_STATE_INSDEL)) | E_BUFFER_TAGGER_STATE_CHANGED;
- } else {
- if (state & E_BUFFER_TAGGER_STATE_CHANGED) {
- markup_text (buffer);
- }
-
- state = state & (~ (E_BUFFER_TAGGER_STATE_CHANGED | E_BUFFER_TAGGER_STATE_INSDEL));
- }
-
- set_state (buffer, state);
-}
-
-static void
-update_mouse_cursor (GtkTextView *text_view,
- gint x,
- gint y)
-{
- static GdkCursor *hand_cursor = NULL;
- static GdkCursor *regular_cursor = NULL;
- gboolean hovering = FALSE, hovering_over_link = FALSE, hovering_real;
- guint32 state;
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
- GtkTextIter iter;
-
- if (!hand_cursor) {
- hand_cursor = gdk_cursor_new (GDK_HAND2);
- regular_cursor = gdk_cursor_new (GDK_XTERM);
- }
-
- g_return_if_fail (buffer != NULL);
-
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
- g_return_if_fail (tag != NULL);
-
- state = get_state (buffer);
-
- gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
- hovering_real = gtk_text_iter_has_tag (&iter, tag);
-
- hovering_over_link = (state & E_BUFFER_TAGGER_STATE_IS_HOVERING) != 0;
- if ((state & E_BUFFER_TAGGER_STATE_CTRL_DOWN) == 0) {
- hovering = FALSE;
- } else {
- hovering = hovering_real;
- }
-
- if (hovering != hovering_over_link) {
- update_state (buffer, E_BUFFER_TAGGER_STATE_IS_HOVERING, hovering);
-
- if (hovering && gtk_widget_has_focus (GTK_WIDGET (text_view)))
- gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), hand_cursor);
- else
- gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), regular_cursor);
-
- /* XXX Is this necessary? Appears to be a no-op. */
- get_pointer_position (text_view, NULL, NULL);
- }
-
- hovering_over_link = (state & E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP) != 0;
-
- if (hovering_real != hovering_over_link) {
- update_state (buffer, E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP, hovering_real);
-
- gtk_widget_trigger_tooltip_query (GTK_WIDGET (text_view));
- }
-}
-
-static gboolean
-textview_query_tooltip (GtkTextView *text_view,
- gint x,
- gint y,
- gboolean keyboard_mode,
- GtkTooltip *tooltip,
- gpointer user_data)
-{
- GtkTextBuffer *buffer;
- guint32 state;
- gboolean res = FALSE;
-
- if (keyboard_mode)
- return FALSE;
-
- buffer = gtk_text_view_get_buffer (text_view);
- g_return_val_if_fail (buffer != NULL, FALSE);
-
- state = get_state (buffer);
-
- if ((state & E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP) != 0) {
- gchar *url;
- GtkTextIter iter;
-
- gtk_text_view_window_to_buffer_coords (
- text_view,
- GTK_TEXT_WINDOW_WIDGET,
- x, y, &x, &y);
- gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
-
- url = get_url_at_iter (buffer, &iter);
- res = url && *url;
-
- if (res) {
- gchar *str;
-
- /* To Translators: The text is concatenated to a form: "Ctrl-click to open a link http://www.example.com" */
- str = g_strconcat (_("Ctrl-click to open a link"), " ", url, NULL);
- gtk_tooltip_set_text (tooltip, str);
- g_free (str);
- }
-
- g_free (url);
- }
-
- return res;
-}
-
-/* Links can be activated by pressing Enter. */
-static gboolean
-textview_key_press_event (GtkWidget *text_view,
- GdkEventKey *event)
-{
- GtkTextIter iter;
- GtkTextBuffer *buffer;
-
- if ((event->state & GDK_CONTROL_MASK) == 0)
- return FALSE;
-
- switch (event->keyval) {
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
- if (invoke_link_if_present (buffer, &iter))
- return TRUE;
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-update_ctrl_state (GtkTextView *textview,
- gboolean ctrl_is_down)
-{
- GtkTextBuffer *buffer;
- gint x, y;
-
- buffer = gtk_text_view_get_buffer (textview);
- if (buffer) {
- if (((get_state (buffer) & E_BUFFER_TAGGER_STATE_CTRL_DOWN) != 0) != (ctrl_is_down != FALSE)) {
- update_state (buffer, E_BUFFER_TAGGER_STATE_CTRL_DOWN, ctrl_is_down != FALSE);
- }
-
- get_pointer_position (textview, &x, &y);
- gtk_text_view_window_to_buffer_coords (textview, GTK_TEXT_WINDOW_WIDGET, x, y, &x, &y);
- update_mouse_cursor (textview, x, y);
- }
-}
-
-/* Links can also be activated by clicking. */
-static gboolean
-textview_event_after (GtkTextView *textview,
- GdkEvent *event)
-{
- GtkTextIter start, end, iter;
- GtkTextBuffer *buffer;
- gint x, y;
- GdkModifierType mt = 0;
- guint event_button = 0;
- gdouble event_x_win = 0;
- gdouble event_y_win = 0;
-
- g_return_val_if_fail (GTK_IS_TEXT_VIEW (textview), FALSE);
-
- if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) {
- guint event_keyval = 0;
-
- gdk_event_get_keyval (event, &event_keyval);
-
- switch (event_keyval) {
- case GDK_KEY_Control_L:
- case GDK_KEY_Control_R:
- update_ctrl_state (
- textview,
- event->type == GDK_KEY_PRESS);
- break;
- }
-
- return FALSE;
- }
-
- if (!gdk_event_get_state (event, &mt)) {
- GdkWindow *window;
- GdkDisplay *display;
- GdkDeviceManager *device_manager;
- GdkDevice *device;
-
- window = gtk_widget_get_parent_window (GTK_WIDGET (textview));
- display = gdk_window_get_display (window);
- device_manager = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (device_manager);
-
- gdk_window_get_device_position (window, device, NULL, NULL, &mt);
- }
-
- update_ctrl_state (textview, (mt & GDK_CONTROL_MASK) != 0);
-
- if (event->type != GDK_BUTTON_RELEASE)
- return FALSE;
-
- gdk_event_get_button (event, &event_button);
- gdk_event_get_coords (event, &event_x_win, &event_y_win);
-
- if (event_button != 1 || (mt & GDK_CONTROL_MASK) == 0)
- return FALSE;
-
- buffer = gtk_text_view_get_buffer (textview);
-
- /* we shouldn't follow a link if the user has selected something */
- gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
- if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
- return FALSE;
-
- gtk_text_view_window_to_buffer_coords (
- textview,
- GTK_TEXT_WINDOW_WIDGET,
- event_x_win, event_y_win, &x, &y);
-
- gtk_text_view_get_iter_at_location (textview, &iter, x, y);
-
- invoke_link_if_present (buffer, &iter);
- update_mouse_cursor (textview, x, y);
-
- return FALSE;
-}
-
-static gboolean
-textview_motion_notify_event (GtkTextView *textview,
- GdkEventMotion *event)
-{
- gint x, y;
-
- g_return_val_if_fail (GTK_IS_TEXT_VIEW (textview), FALSE);
-
- gtk_text_view_window_to_buffer_coords (
- textview,
- GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
-
- update_mouse_cursor (textview, x, y);
-
- return FALSE;
-}
-
-static gboolean
-textview_visibility_notify_event (GtkTextView *textview,
- GdkEventVisibility *event)
-{
- gint wx, wy, bx, by;
-
- g_return_val_if_fail (GTK_IS_TEXT_VIEW (textview), FALSE);
-
- get_pointer_position (textview, &wx, &wy);
-
- gtk_text_view_window_to_buffer_coords (
- textview,
- GTK_TEXT_WINDOW_WIDGET,
- wx, wy, &bx, &by);
-
- update_mouse_cursor (textview, bx, by);
-
- return FALSE;
-}
-
-void
-e_buffer_tagger_connect (GtkTextView *textview)
-{
- GtkTextBuffer *buffer;
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
-
- init_magic_links ();
-
- g_return_if_fail (textview != NULL);
- g_return_if_fail (GTK_IS_TEXT_VIEW (textview));
-
- buffer = gtk_text_view_get_buffer (textview);
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
-
- /* if tag is there already, then it is connected, thus claim */
- g_return_if_fail (tag == NULL);
-
- gtk_text_buffer_create_tag (
- buffer, E_BUFFER_TAGGER_LINK_TAG,
- "foreground", "blue",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
-
- set_state (buffer, E_BUFFER_TAGGER_STATE_NONE);
-
- g_signal_connect (
- buffer, "insert-text",
- G_CALLBACK (buffer_insert_text), NULL);
- g_signal_connect (
- buffer, "delete-range",
- G_CALLBACK (buffer_delete_range), NULL);
- g_signal_connect (
- buffer, "notify::cursor-position",
- G_CALLBACK (buffer_cursor_position), NULL);
-
- gtk_widget_set_has_tooltip (GTK_WIDGET (textview), TRUE);
-
- g_signal_connect (
- textview, "query-tooltip",
- G_CALLBACK (textview_query_tooltip), NULL);
- g_signal_connect (
- textview, "key-press-event",
- G_CALLBACK (textview_key_press_event), NULL);
- g_signal_connect (
- textview, "event-after",
- G_CALLBACK (textview_event_after), NULL);
- g_signal_connect (
- textview, "motion-notify-event",
- G_CALLBACK (textview_motion_notify_event), NULL);
- g_signal_connect (
- textview, "visibility-notify-event",
- G_CALLBACK (textview_visibility_notify_event), NULL);
-}
-
-void
-e_buffer_tagger_disconnect (GtkTextView *textview)
-{
- GtkTextBuffer *buffer;
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
-
- g_return_if_fail (textview != NULL);
- g_return_if_fail (GTK_IS_TEXT_VIEW (textview));
-
- buffer = gtk_text_view_get_buffer (textview);
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
-
- /* if tag is not there, then it is not connected, thus claim */
- g_return_if_fail (tag != NULL);
-
- gtk_text_tag_table_remove (tag_table, tag);
-
- set_state (buffer, E_BUFFER_TAGGER_STATE_NONE);
-
- g_signal_handlers_disconnect_by_func (buffer, G_CALLBACK (buffer_insert_text), NULL);
- g_signal_handlers_disconnect_by_func (buffer, G_CALLBACK (buffer_delete_range), NULL);
- g_signal_handlers_disconnect_by_func (buffer, G_CALLBACK (buffer_cursor_position), NULL);
-
- gtk_widget_set_has_tooltip (GTK_WIDGET (textview), FALSE);
-
- g_signal_handlers_disconnect_by_func (textview, G_CALLBACK (textview_query_tooltip), NULL);
- g_signal_handlers_disconnect_by_func (textview, G_CALLBACK (textview_key_press_event), NULL);
- g_signal_handlers_disconnect_by_func (textview, G_CALLBACK (textview_event_after), NULL);
- g_signal_handlers_disconnect_by_func (textview, G_CALLBACK (textview_motion_notify_event), NULL);
- g_signal_handlers_disconnect_by_func (textview, G_CALLBACK (textview_visibility_notify_event), NULL);
-}
-
-void
-e_buffer_tagger_update_tags (GtkTextView *textview)
-{
- GtkTextBuffer *buffer;
- GtkTextTagTable *tag_table;
- GtkTextTag *tag;
-
- g_return_if_fail (textview != NULL);
- g_return_if_fail (GTK_IS_TEXT_VIEW (textview));
-
- buffer = gtk_text_view_get_buffer (textview);
- tag_table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);
-
- /* if tag is not there, then it is not connected, thus claim */
- g_return_if_fail (tag != NULL);
-
- update_state (buffer, E_BUFFER_TAGGER_STATE_INSDEL | E_BUFFER_TAGGER_STATE_CHANGED, FALSE);
-
- markup_text (buffer);
-}
diff --git a/widgets/misc/e-buffer-tagger.h b/widgets/misc/e-buffer-tagger.h
deleted file mode 100644
index 86e6710d01..0000000000
--- a/widgets/misc/e-buffer-tagger.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * e-buffer-tagger.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_BUFFER_TAGGER_H
-#define E_BUFFER_TAGGER_H
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-void e_buffer_tagger_connect (GtkTextView *textview);
-void e_buffer_tagger_disconnect (GtkTextView *textview);
-void e_buffer_tagger_update_tags (GtkTextView *textview);
-
-G_END_DECLS
-
-#endif /* E_BUFFER_TAGGER_H */
diff --git a/widgets/misc/e-cal-source-config.c b/widgets/misc/e-cal-source-config.c
deleted file mode 100644
index e57d0c6745..0000000000
--- a/widgets/misc/e-cal-source-config.c
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * e-cal-source-config.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-cal-source-config.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#include <e-util/e-util.h>
-
-#define E_CAL_SOURCE_CONFIG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CAL_SOURCE_CONFIG, ECalSourceConfigPrivate))
-
-struct _ECalSourceConfigPrivate {
- ECalClientSourceType source_type;
- GtkWidget *color_button;
- GtkWidget *default_button;
-};
-
-enum {
- PROP_0,
- PROP_SOURCE_TYPE
-};
-
-G_DEFINE_TYPE (
- ECalSourceConfig,
- e_cal_source_config,
- E_TYPE_SOURCE_CONFIG)
-
-static ESource *
-cal_source_config_ref_default (ESourceConfig *config)
-{
- ECalSourceConfigPrivate *priv;
- ESourceRegistry *registry;
-
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (config);
- registry = e_source_config_get_registry (config);
-
- if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
- return e_source_registry_ref_default_calendar (registry);
- else if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
- return e_source_registry_ref_default_memo_list (registry);
- else if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
- return e_source_registry_ref_default_task_list (registry);
-
- g_return_val_if_reached (NULL);
-}
-
-static void
-cal_source_config_set_default (ESourceConfig *config,
- ESource *source)
-{
- ECalSourceConfigPrivate *priv;
- ESourceRegistry *registry;
-
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (config);
- registry = e_source_config_get_registry (config);
-
- if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
- e_source_registry_set_default_calendar (registry, source);
- else if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
- e_source_registry_set_default_memo_list (registry, source);
- else if (priv->source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
- e_source_registry_set_default_task_list (registry, source);
-}
-
-static void
-cal_source_config_set_source_type (ECalSourceConfig *config,
- ECalClientSourceType source_type)
-{
- config->priv->source_type = source_type;
-}
-
-static void
-cal_source_config_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SOURCE_TYPE:
- cal_source_config_set_source_type (
- E_CAL_SOURCE_CONFIG (object),
- g_value_get_enum (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-cal_source_config_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SOURCE_TYPE:
- g_value_set_enum (
- value,
- e_cal_source_config_get_source_type (
- E_CAL_SOURCE_CONFIG (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-cal_source_config_dispose (GObject *object)
-{
- ECalSourceConfigPrivate *priv;
-
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (object);
-
- if (priv->color_button != NULL) {
- g_object_unref (priv->color_button);
- priv->color_button = NULL;
- }
-
- if (priv->default_button != NULL) {
- g_object_unref (priv->default_button);
- priv->default_button = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_cal_source_config_parent_class)->dispose (object);
-}
-
-static void
-cal_source_config_constructed (GObject *object)
-{
- ECalSourceConfigPrivate *priv;
- ESource *default_source;
- ESource *original_source;
- ESourceConfig *config;
- GObjectClass *class;
- GtkWidget *widget;
- const gchar *label;
-
- /* Chain up to parent's constructed() method. */
- class = G_OBJECT_CLASS (e_cal_source_config_parent_class);
- class->constructed (object);
-
- config = E_SOURCE_CONFIG (object);
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (object);
-
- widget = gtk_color_button_new ();
- priv->color_button = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- switch (priv->source_type) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- label = _("Mark as default calendar");
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- label = _("Mark as default task list");
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- label = _("Mark as default memo list");
- break;
- default:
- /* No need to translate this string. */
- label = "Invalid ECalSourceType value";
- g_warn_if_reached ();
- }
-
- widget = gtk_check_button_new_with_label (label);
- priv->default_button = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- default_source = cal_source_config_ref_default (config);
- original_source = e_source_config_get_original_source (config);
-
- if (original_source != NULL) {
- gboolean active;
-
- active = e_source_equal (original_source, default_source);
- g_object_set (priv->default_button, "active", active, NULL);
- }
-
- g_object_unref (default_source);
-
- e_source_config_insert_widget (
- config, NULL, _("Color:"), priv->color_button);
-
- e_source_config_insert_widget (
- config, NULL, NULL, priv->default_button);
-}
-
-static const gchar *
-cal_source_config_get_backend_extension_name (ESourceConfig *config)
-{
- ECalSourceConfig *cal_config;
- const gchar *extension_name;
-
- cal_config = E_CAL_SOURCE_CONFIG (config);
-
- switch (e_cal_source_config_get_source_type (cal_config)) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- extension_name = E_SOURCE_EXTENSION_CALENDAR;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- extension_name = E_SOURCE_EXTENSION_TASK_LIST;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
- break;
- default:
- g_return_val_if_reached (NULL);
- }
-
- return extension_name;
-}
-
-static GList *
-cal_source_config_list_eligible_collections (ESourceConfig *config)
-{
- GQueue trash = G_QUEUE_INIT;
- GList *list, *link;
-
- /* Chain up to parent's list_eligible_collections() method. */
- list = E_SOURCE_CONFIG_CLASS (e_cal_source_config_parent_class)->
- list_eligible_collections (config);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESource *source = E_SOURCE (link->data);
- ESourceCollection *extension;
- const gchar *extension_name;
-
- extension_name = E_SOURCE_EXTENSION_COLLECTION;
- extension = e_source_get_extension (source, extension_name);
-
- if (!e_source_collection_get_calendar_enabled (extension))
- g_queue_push_tail (&trash, link);
- }
-
- /* Remove ineligible collections from the list. */
- while ((link = g_queue_pop_head (&trash)) != NULL) {
- g_object_unref (link->data);
- list = g_list_delete_link (list, link);
- }
-
- return list;
-}
-
-static void
-cal_source_config_init_candidate (ESourceConfig *config,
- ESource *scratch_source)
-{
- ECalSourceConfigPrivate *priv;
- ESourceConfigClass *class;
- ESourceExtension *extension;
- const gchar *extension_name;
-
- /* Chain up to parent's init_candidate() method. */
- class = E_SOURCE_CONFIG_CLASS (e_cal_source_config_parent_class);
- class->init_candidate (config, scratch_source);
-
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (config);
-
- extension_name = e_source_config_get_backend_extension_name (config);
- extension = e_source_get_extension (scratch_source, extension_name);
-
- g_object_bind_property_full (
- extension, "color",
- priv->color_button, "color",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE,
- e_binding_transform_string_to_color,
- e_binding_transform_color_to_string,
- NULL, (GDestroyNotify) NULL);
-}
-
-static void
-cal_source_config_commit_changes (ESourceConfig *config,
- ESource *scratch_source)
-{
- ECalSourceConfigPrivate *priv;
- GtkToggleButton *toggle_button;
- ESourceConfigClass *class;
- ESource *default_source;
-
- priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (config);
- toggle_button = GTK_TOGGLE_BUTTON (priv->default_button);
-
- /* Chain up to parent's commit_changes() method. */
- class = E_SOURCE_CONFIG_CLASS (e_cal_source_config_parent_class);
- class->commit_changes (config, scratch_source);
-
- default_source = cal_source_config_ref_default (config);
-
- /* The default setting is a little tricky to get right. If
- * the toggle button is active, this ESource is now the default.
- * That much is simple. But if the toggle button is NOT active,
- * then we have to inspect the old default. If this ESource WAS
- * the default, reset the default to 'system'. If this ESource
- * WAS NOT the old default, leave it alone. */
- if (gtk_toggle_button_get_active (toggle_button))
- cal_source_config_set_default (config, scratch_source);
- else if (e_source_equal (scratch_source, default_source))
- cal_source_config_set_default (config, NULL);
-
- g_object_unref (default_source);
-}
-
-static void
-e_cal_source_config_class_init (ECalSourceConfigClass *class)
-{
- GObjectClass *object_class;
- ESourceConfigClass *source_config_class;
-
- g_type_class_add_private (class, sizeof (ECalSourceConfigPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = cal_source_config_set_property;
- object_class->get_property = cal_source_config_get_property;
- object_class->dispose = cal_source_config_dispose;
- object_class->constructed = cal_source_config_constructed;
-
- source_config_class = E_SOURCE_CONFIG_CLASS (class);
- source_config_class->get_backend_extension_name =
- cal_source_config_get_backend_extension_name;
- source_config_class->list_eligible_collections =
- cal_source_config_list_eligible_collections;
- source_config_class->init_candidate = cal_source_config_init_candidate;
- source_config_class->commit_changes = cal_source_config_commit_changes;
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_TYPE,
- g_param_spec_enum (
- "source-type",
- "Source Type",
- "The iCalendar object type",
- E_TYPE_CAL_CLIENT_SOURCE_TYPE,
- E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_cal_source_config_init (ECalSourceConfig *config)
-{
- config->priv = E_CAL_SOURCE_CONFIG_GET_PRIVATE (config);
-}
-
-GtkWidget *
-e_cal_source_config_new (ESourceRegistry *registry,
- ESource *original_source,
- ECalClientSourceType source_type)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- if (original_source != NULL)
- g_return_val_if_fail (E_IS_SOURCE (original_source), NULL);
-
- return g_object_new (
- E_TYPE_CAL_SOURCE_CONFIG, "registry", registry,
- "original-source", original_source, "source-type",
- source_type, NULL);
-}
-
-ECalClientSourceType
-e_cal_source_config_get_source_type (ECalSourceConfig *config)
-{
- g_return_val_if_fail (E_IS_CAL_SOURCE_CONFIG (config), 0);
-
- return config->priv->source_type;
-}
-
-void
-e_cal_source_config_add_offline_toggle (ECalSourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget;
- ESourceExtension *extension;
- const gchar *extension_name;
- const gchar *label;
-
- g_return_if_fail (E_IS_CAL_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_OFFLINE;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- switch (e_cal_source_config_get_source_type (config)) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- label = _("Copy calendar contents locally "
- "for offline operation");
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- label = _("Copy task list contents locally "
- "for offline operation");
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- label = _("Copy memo list contents locally "
- "for offline operation");
- break;
- default:
- g_return_if_reached ();
- }
-
- widget = gtk_check_button_new_with_label (label);
- e_source_config_insert_widget (
- E_SOURCE_CONFIG (config), scratch_source, NULL, widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- extension, "stay-synchronized",
- widget, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
diff --git a/widgets/misc/e-cal-source-config.h b/widgets/misc/e-cal-source-config.h
deleted file mode 100644
index 4db861069e..0000000000
--- a/widgets/misc/e-cal-source-config.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * e-cal-source-config.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_CAL_SOURCE_CONFIG_H
-#define E_CAL_SOURCE_CONFIG_H
-
-#include <libecal/libecal.h>
-#include <misc/e-source-config.h>
-
-/* Standard GObject macros */
-#define E_TYPE_CAL_SOURCE_CONFIG \
- (e_cal_source_config_get_type ())
-#define E_CAL_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CAL_SOURCE_CONFIG, ECalSourceConfig))
-#define E_CAL_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CAL_SOURCE_CONFIG, ECalSourceConfigClass))
-#define E_IS_CAL_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CAL_SOURCE_CONFIG))
-#define E_IS_CAL_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CAL_SOURCE_CONFIG))
-#define E_CAL_SOURCE_CONFIG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CAL_SOURCE_CONFIG, ECalSourceConfigClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ECalSourceConfig ECalSourceConfig;
-typedef struct _ECalSourceConfigClass ECalSourceConfigClass;
-typedef struct _ECalSourceConfigPrivate ECalSourceConfigPrivate;
-
-struct _ECalSourceConfig {
- ESourceConfig parent;
- ECalSourceConfigPrivate *priv;
-};
-
-struct _ECalSourceConfigClass {
- ESourceConfigClass parent_class;
-};
-
-GType e_cal_source_config_get_type (void) G_GNUC_CONST;
-GtkWidget * e_cal_source_config_new (ESourceRegistry *registry,
- ESource *original_source,
- ECalClientSourceType source_type);
-ECalClientSourceType
- e_cal_source_config_get_source_type
- (ECalSourceConfig *config);
-void e_cal_source_config_add_offline_toggle
- (ECalSourceConfig *config,
- ESource *scratch_source);
-
-G_END_DECLS
-
-#endif /* E_CAL_SOURCE_CONFIG_H */
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
deleted file mode 100644
index 96b39529b1..0000000000
--- a/widgets/misc/e-calendar-item.c
+++ /dev/null
@@ -1,3772 +0,0 @@
-/*
- * ECalendarItem - canvas item displaying a calendar.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <libebackend/libebackend.h>
-
-#include "e-calendar-item.h"
-#include "ea-widgets.h"
-
-#include <time.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <glib/gi18n.h>
-#include <e-util/e-util.h>
-
-static const gint e_calendar_item_days_in_month[12] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-#define DAYS_IN_MONTH(year, month) \
- e_calendar_item_days_in_month[month] + (((month) == 1 \
- && ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))) ? 1 : 0)
-
-static void e_calendar_item_dispose (GObject *object);
-static void e_calendar_item_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void e_calendar_item_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void e_calendar_item_realize (GnomeCanvasItem *item);
-static void e_calendar_item_unmap (GnomeCanvasItem *item);
-static void e_calendar_item_update (GnomeCanvasItem *item,
- const cairo_matrix_t *i2c,
- gint flags);
-static void e_calendar_item_draw (GnomeCanvasItem *item,
- cairo_t *cr,
- gint x,
- gint y,
- gint width,
- gint height);
-static void e_calendar_item_draw_month (ECalendarItem *calitem,
- cairo_t *cr,
- gint x,
- gint y,
- gint width,
- gint height,
- gint row,
- gint col);
-static void e_calendar_item_draw_day_numbers
- (ECalendarItem *calitem,
- cairo_t *cr,
- gint width,
- gint height,
- gint row,
- gint col,
- gint year,
- gint month,
- gint start_weekday,
- gint cells_x,
- gint cells_y);
-static GnomeCanvasItem *e_calendar_item_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy);
-static void e_calendar_item_stop_selecting (ECalendarItem *calitem,
- guint32 time);
-static void e_calendar_item_selection_add_days
- (ECalendarItem *calitem,
- gint n_days,
- gboolean multi_selection);
-static gint e_calendar_item_key_press_event (ECalendarItem *item,
- GdkEvent *event);
-static gint e_calendar_item_event (GnomeCanvasItem *item,
- GdkEvent *event);
-static void e_calendar_item_bounds (GnomeCanvasItem *item,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2);
-
-static gboolean e_calendar_item_button_press (ECalendarItem *calitem,
- GdkEvent *event);
-static gboolean e_calendar_item_button_release (ECalendarItem *calitem,
- GdkEvent *event);
-static gboolean e_calendar_item_motion (ECalendarItem *calitem,
- GdkEvent *event);
-
-static gboolean e_calendar_item_convert_position_to_day
- (ECalendarItem *calitem,
- gint x,
- gint y,
- gboolean round_empty_positions,
- gint *month_offset,
- gint *day,
- gboolean *entire_week);
-static void e_calendar_item_get_month_info (ECalendarItem *calitem,
- gint row,
- gint col,
- gint *first_day_offset,
- gint *days_in_month,
- gint *days_in_prev_month);
-static void e_calendar_item_recalc_sizes (ECalendarItem *calitem);
-
-static void e_calendar_item_get_day_style (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- gint day_style,
- gboolean today,
- gboolean prev_or_next_month,
- gboolean selected,
- gboolean has_focus,
- gboolean drop_target,
- GdkColor **bg_color,
- GdkColor **fg_color,
- GdkColor **box_color,
- gboolean *bold,
- gboolean *italic);
-static void e_calendar_item_check_selection_end
- (ECalendarItem *calitem,
- gint start_month,
- gint start_day,
- gint *end_month,
- gint *end_day);
-static void e_calendar_item_check_selection_start
- (ECalendarItem *calitem,
- gint *start_month,
- gint *start_day,
- gint end_month,
- gint end_day);
-static void e_calendar_item_add_days_to_selection
- (ECalendarItem *calitem,
- gint days);
-static void e_calendar_item_round_up_selection
- (ECalendarItem *calitem,
- gint *month_offset,
- gint *day);
-static void e_calendar_item_round_down_selection
- (ECalendarItem *calitem,
- gint *month_offset,
- gint *day);
-static gint e_calendar_item_get_inclusive_days
- (ECalendarItem *calitem,
- gint start_month_offset,
- gint start_day,
- gint end_month_offset,
- gint end_day);
-static void e_calendar_item_ensure_valid_day
- (ECalendarItem *calitem,
- gint *month_offset,
- gint *day);
-static gboolean e_calendar_item_ensure_days_visible
- (ECalendarItem *calitem,
- gint start_year,
- gint start_month,
- gint start_day,
- gint end_year,
- gint end_month,
- gint end_day,
- gboolean emission);
-static void e_calendar_item_show_popup_menu (ECalendarItem *calitem,
- GdkEvent *button_event,
- gint month_offset);
-static void e_calendar_item_on_menu_item_activate
- (GtkWidget *menuitem,
- ECalendarItem *calitem);
-static void e_calendar_item_position_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
-static void e_calendar_item_date_range_changed
- (ECalendarItem *calitem);
-static void e_calendar_item_queue_signal_emission
- (ECalendarItem *calitem);
-static gboolean e_calendar_item_signal_emission_idle_cb
- (gpointer data);
-static void e_calendar_item_set_selection_if_emission
- (ECalendarItem *calitem,
- const GDate *start_date,
- const GDate *end_date,
- gboolean emission);
-
-/* Our arguments. */
-enum {
- PROP_0,
- PROP_YEAR,
- PROP_MONTH,
- PROP_X1,
- PROP_Y1,
- PROP_X2,
- PROP_Y2,
- PROP_FONT_DESC,
- PROP_WEEK_NUMBER_FONT,
- PROP_WEEK_NUMBER_FONT_DESC,
- PROP_ROW_HEIGHT,
- PROP_COLUMN_WIDTH,
- PROP_MINIMUM_ROWS,
- PROP_MINIMUM_COLUMNS,
- PROP_MAXIMUM_ROWS,
- PROP_MAXIMUM_COLUMNS,
- PROP_WEEK_START_DAY,
- PROP_SHOW_WEEK_NUMBERS,
- PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK,
- PROP_MAXIMUM_DAYS_SELECTED,
- PROP_DAYS_TO_START_WEEK_SELECTION,
- PROP_MOVE_SELECTION_WHEN_MOVING,
- PROP_PRESERVE_DAY_WHEN_MOVING,
- PROP_DISPLAY_POPUP
-};
-
-enum {
- DATE_RANGE_CHANGED,
- SELECTION_CHANGED,
- SELECTION_PREVIEW_CHANGED,
- LAST_SIGNAL
-};
-
-static guint e_calendar_item_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE_WITH_CODE (
- ECalendarItem,
- e_calendar_item,
- GNOME_TYPE_CANVAS_ITEM,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-static void
-e_calendar_item_class_init (ECalendarItemClass *class)
-{
- GObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = e_calendar_item_dispose;
- object_class->get_property = e_calendar_item_get_property;
- object_class->set_property = e_calendar_item_set_property;
-
- item_class = GNOME_CANVAS_ITEM_CLASS (class);
- item_class->realize = e_calendar_item_realize;
- item_class->unmap = e_calendar_item_unmap;
- item_class->update = e_calendar_item_update;
- item_class->draw = e_calendar_item_draw;
- item_class->point = e_calendar_item_point;
- item_class->event = e_calendar_item_event;
- item_class->bounds = e_calendar_item_bounds;
-
- class->date_range_changed = NULL;
- class->selection_changed = NULL;
- class->selection_preview_changed = NULL;
-
- g_object_class_install_property (
- object_class,
- PROP_YEAR,
- g_param_spec_int (
- "year",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MONTH,
- g_param_spec_int (
- "month",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_X1,
- g_param_spec_double (
- "x1",
- NULL,
- NULL,
- -G_MAXDOUBLE,
- G_MAXDOUBLE,
- 0.,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_Y1,
- g_param_spec_double (
- "y1",
- NULL,
- NULL,
- -G_MAXDOUBLE,
- G_MAXDOUBLE,
- 0.,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_X2,
- g_param_spec_double (
- "x2",
- NULL,
- NULL,
- -G_MAXDOUBLE,
- G_MAXDOUBLE,
- 0.,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_Y2,
- g_param_spec_double (
- "y2",
- NULL,
- NULL,
- -G_MAXDOUBLE,
- G_MAXDOUBLE,
- 0.,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_FONT_DESC,
- g_param_spec_boxed (
- "font_desc",
- NULL,
- NULL,
- PANGO_TYPE_FONT_DESCRIPTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_WEEK_NUMBER_FONT_DESC,
- g_param_spec_boxed (
- "week_number_font_desc",
- NULL,
- NULL,
- PANGO_TYPE_FONT_DESCRIPTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_ROW_HEIGHT,
- g_param_spec_int (
- "row_height",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_COLUMN_WIDTH,
- g_param_spec_int (
- "column_width",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_MINIMUM_ROWS,
- g_param_spec_int (
- "minimum_rows",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MINIMUM_COLUMNS,
- g_param_spec_int (
- "minimum_columns",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAXIMUM_ROWS,
- g_param_spec_int (
- "maximum_rows",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAXIMUM_COLUMNS,
- g_param_spec_int (
- "maximum_columns",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_WEEK_START_DAY,
- g_param_spec_int (
- "week_start_day",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SHOW_WEEK_NUMBERS,
- g_param_spec_boolean (
- "show_week_numbers",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK,
- g_param_spec_boolean (
- "keep_wdays_on_weeknum_click",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAXIMUM_DAYS_SELECTED,
- g_param_spec_int (
- "maximum_days_selected",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_DAYS_TO_START_WEEK_SELECTION,
- g_param_spec_int (
- "days_to_start_week_selection",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MOVE_SELECTION_WHEN_MOVING,
- g_param_spec_boolean (
- "move_selection_when_moving",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_PRESERVE_DAY_WHEN_MOVING,
- g_param_spec_boolean (
- "preserve_day_when_moving",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_DISPLAY_POPUP,
- g_param_spec_boolean (
- "display_popup",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- e_calendar_item_signals[DATE_RANGE_CHANGED] = g_signal_new (
- "date_range_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ECalendarItemClass, date_range_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_calendar_item_signals[SELECTION_CHANGED] = g_signal_new (
- "selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ECalendarItemClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_calendar_item_signals[SELECTION_PREVIEW_CHANGED] = g_signal_new (
- "selection_preview_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarItemClass, selection_preview_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_calendar_item_a11y_init ();
-}
-
-static void
-e_calendar_item_init (ECalendarItem *calitem)
-{
- struct tm *tmp_tm;
- time_t t;
-
- /* Set the default time to the current month. */
- t = time (NULL);
- tmp_tm = localtime (&t);
- calitem->year = tmp_tm->tm_year + 1900;
- calitem->month = tmp_tm->tm_mon;
-
- calitem->styles = NULL;
-
- calitem->min_cols = 1;
- calitem->min_rows = 1;
- calitem->max_cols = -1;
- calitem->max_rows = -1;
-
- calitem->rows = 0;
- calitem->cols = 0;
-
- calitem->show_week_numbers = FALSE;
- calitem->keep_wdays_on_weeknum_click = FALSE;
- calitem->week_start_day = 0;
- calitem->expand = TRUE;
- calitem->max_days_selected = 1;
- calitem->days_to_start_week_selection = -1;
- calitem->move_selection_when_moving = TRUE;
- calitem->preserve_day_when_moving = FALSE;
- calitem->display_popup = TRUE;
-
- calitem->x1 = 0.0;
- calitem->y1 = 0.0;
- calitem->x2 = 0.0;
- calitem->y2 = 0.0;
-
- calitem->selecting = FALSE;
- calitem->selecting_axis = NULL;
-
- calitem->selection_set = FALSE;
-
- calitem->selection_changed = FALSE;
- calitem->date_range_changed = FALSE;
-
- calitem->style_callback = NULL;
- calitem->style_callback_data = NULL;
- calitem->style_callback_destroy = NULL;
-
- calitem->time_callback = NULL;
- calitem->time_callback_data = NULL;
- calitem->time_callback_destroy = NULL;
-
- calitem->signal_emission_idle_id = 0;
-}
-
-static void
-e_calendar_item_dispose (GObject *object)
-{
- ECalendarItem *calitem;
-
- calitem = E_CALENDAR_ITEM (object);
-
- e_calendar_item_set_style_callback (calitem, NULL, NULL, NULL);
- e_calendar_item_set_get_time_callback (calitem, NULL, NULL, NULL);
-
- if (calitem->styles) {
- g_free (calitem->styles);
- calitem->styles = NULL;
- }
-
- if (calitem->signal_emission_idle_id > 0) {
- g_source_remove (calitem->signal_emission_idle_id);
- calitem->signal_emission_idle_id = -1;
- }
-
- if (calitem->font_desc) {
- pango_font_description_free (calitem->font_desc);
- calitem->font_desc = NULL;
- }
-
- if (calitem->week_number_font_desc) {
- pango_font_description_free (calitem->week_number_font_desc);
- calitem->week_number_font_desc = NULL;
- }
-
- if (calitem->selecting_axis)
- g_free (calitem->selecting_axis);
-
- G_OBJECT_CLASS (e_calendar_item_parent_class)->dispose (object);
-}
-
-static void
-e_calendar_item_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ECalendarItem *calitem;
-
- calitem = E_CALENDAR_ITEM (object);
-
- switch (property_id) {
- case PROP_YEAR:
- g_value_set_int (value, calitem->year);
- return;
- case PROP_MONTH:
- g_value_set_int (value, calitem->month);
- return;
- case PROP_X1:
- g_value_set_double (value, calitem->x1);
- return;
- case PROP_Y1:
- g_value_set_double (value, calitem->y1);
- return;
- case PROP_X2:
- g_value_set_double (value, calitem->x2);
- return;
- case PROP_Y2:
- g_value_set_double (value, calitem->y2);
- return;
- case PROP_FONT_DESC:
- g_value_set_boxed (value, calitem->font_desc);
- return;
- case PROP_WEEK_NUMBER_FONT_DESC:
- g_value_set_boxed (value, calitem->week_number_font_desc);
- return;
- case PROP_ROW_HEIGHT:
- e_calendar_item_recalc_sizes (calitem);
- g_value_set_int (value, calitem->min_month_height);
- return;
- case PROP_COLUMN_WIDTH:
- e_calendar_item_recalc_sizes (calitem);
- g_value_set_int (value, calitem->min_month_width);
- return;
- case PROP_MINIMUM_ROWS:
- g_value_set_int (value, calitem->min_rows);
- return;
- case PROP_MINIMUM_COLUMNS:
- g_value_set_int (value, calitem->min_cols);
- return;
- case PROP_MAXIMUM_ROWS:
- g_value_set_int (value, calitem->max_rows);
- return;
- case PROP_MAXIMUM_COLUMNS:
- g_value_set_int (value, calitem->max_cols);
- return;
- case PROP_WEEK_START_DAY:
- g_value_set_int (value, calitem->week_start_day);
- return;
- case PROP_SHOW_WEEK_NUMBERS:
- g_value_set_boolean (value, calitem->show_week_numbers);
- return;
- case PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK:
- g_value_set_boolean (value, calitem->keep_wdays_on_weeknum_click);
- return;
- case PROP_MAXIMUM_DAYS_SELECTED:
- g_value_set_int (value, e_calendar_item_get_max_days_sel (calitem));
- return;
- case PROP_DAYS_TO_START_WEEK_SELECTION:
- g_value_set_int (value, e_calendar_item_get_days_start_week_sel (calitem));
- return;
- case PROP_MOVE_SELECTION_WHEN_MOVING:
- g_value_set_boolean (value, calitem->move_selection_when_moving);
- return;
- case PROP_PRESERVE_DAY_WHEN_MOVING:
- g_value_set_boolean (value, calitem->preserve_day_when_moving);
- return;
- case PROP_DISPLAY_POPUP:
- g_value_set_boolean (value, e_calendar_item_get_display_popup (calitem));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-e_calendar_item_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GnomeCanvasItem *item;
- ECalendarItem *calitem;
- PangoFontDescription *font_desc;
- gdouble dvalue;
- gint ivalue;
- gboolean bvalue;
-
- item = GNOME_CANVAS_ITEM (object);
- calitem = E_CALENDAR_ITEM (object);
-
- switch (property_id) {
- case PROP_YEAR:
- ivalue = g_value_get_int (value);
- e_calendar_item_set_first_month (
- calitem, ivalue, calitem->month);
- return;
- case PROP_MONTH:
- ivalue = g_value_get_int (value);
- e_calendar_item_set_first_month (
- calitem, calitem->year, ivalue);
- return;
- case PROP_X1:
- dvalue = g_value_get_double (value);
- if (calitem->x1 != dvalue) {
- calitem->x1 = dvalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_Y1:
- dvalue = g_value_get_double (value);
- if (calitem->y1 != dvalue) {
- calitem->y1 = dvalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_X2:
- dvalue = g_value_get_double (value);
- if (calitem->x2 != dvalue) {
- calitem->x2 = dvalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_Y2:
- dvalue = g_value_get_double (value);
- if (calitem->y2 != dvalue) {
- calitem->y2 = dvalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_FONT_DESC:
- font_desc = g_value_get_boxed (value);
- if (calitem->font_desc)
- pango_font_description_free (calitem->font_desc);
- calitem->font_desc = pango_font_description_copy (font_desc);
- gnome_canvas_item_request_update (item);
- return;
- case PROP_WEEK_NUMBER_FONT_DESC:
- font_desc = g_value_get_boxed (value);
- if (calitem->week_number_font_desc)
- pango_font_description_free (calitem->week_number_font_desc);
- calitem->week_number_font_desc = pango_font_description_copy (font_desc);
- gnome_canvas_item_request_update (item);
- return;
- case PROP_MINIMUM_ROWS:
- ivalue = g_value_get_int (value);
- ivalue = MAX (1, ivalue);
- if (calitem->min_rows != ivalue) {
- calitem->min_rows = ivalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_MINIMUM_COLUMNS:
- ivalue = g_value_get_int (value);
- ivalue = MAX (1, ivalue);
- if (calitem->min_cols != ivalue) {
- calitem->min_cols = ivalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_MAXIMUM_ROWS:
- ivalue = g_value_get_int (value);
- if (calitem->max_rows != ivalue) {
- calitem->max_rows = ivalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_MAXIMUM_COLUMNS:
- ivalue = g_value_get_int (value);
- if (calitem->max_cols != ivalue) {
- calitem->max_cols = ivalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_WEEK_START_DAY:
- ivalue = g_value_get_int (value);
- if (calitem->week_start_day != ivalue) {
- calitem->week_start_day = ivalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_SHOW_WEEK_NUMBERS:
- bvalue = g_value_get_boolean (value);
- if (calitem->show_week_numbers != bvalue) {
- calitem->show_week_numbers = bvalue;
- gnome_canvas_item_request_update (item);
- }
- return;
- case PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK:
- calitem->keep_wdays_on_weeknum_click = g_value_get_boolean (value);
- return;
- case PROP_MAXIMUM_DAYS_SELECTED:
- ivalue = g_value_get_int (value);
- e_calendar_item_set_max_days_sel (calitem, ivalue);
- return;
- case PROP_DAYS_TO_START_WEEK_SELECTION:
- ivalue = g_value_get_int (value);
- e_calendar_item_set_days_start_week_sel (calitem, ivalue);
- return;
- case PROP_MOVE_SELECTION_WHEN_MOVING:
- bvalue = g_value_get_boolean (value);
- calitem->move_selection_when_moving = bvalue;
- return;
- case PROP_PRESERVE_DAY_WHEN_MOVING:
- bvalue = g_value_get_boolean (value);
- calitem->preserve_day_when_moving = bvalue;
- return;
- case PROP_DISPLAY_POPUP:
- bvalue = g_value_get_boolean (value);
- e_calendar_item_set_display_popup (calitem, bvalue);
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-e_calendar_item_realize (GnomeCanvasItem *item)
-{
- ECalendarItem *calitem;
-
- if (GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->realize) (item);
-
- calitem = E_CALENDAR_ITEM (item);
-
- e_calendar_item_style_set (GTK_WIDGET (item->canvas), calitem);
-
- e_extensible_load_extensions (E_EXTENSIBLE (calitem));
-}
-
-static void
-e_calendar_item_unmap (GnomeCanvasItem *item)
-{
- ECalendarItem *calitem;
-
- calitem = E_CALENDAR_ITEM (item);
-
- if (calitem->selecting) {
- gnome_canvas_item_ungrab (item, GDK_CURRENT_TIME);
- calitem->selecting = FALSE;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->unmap)
- (* GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->unmap) (item);
-}
-
-static void
-e_calendar_item_update (GnomeCanvasItem *item,
- const cairo_matrix_t *i2c,
- gint flags)
-{
- GnomeCanvasItemClass *item_class;
- ECalendarItem *calitem;
- GtkStyle *style;
- gint char_height, width, height, space, space_per_cal, space_per_cell;
- gint rows, cols, xthickness, ythickness;
- PangoFontDescription *font_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
-
- item_class = GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class);
- if (item_class->update != NULL)
- item_class->update (item, i2c, flags);
-
- calitem = E_CALENDAR_ITEM (item);
- style = gtk_widget_get_style (GTK_WIDGET (item->canvas));
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-
- item->x1 = calitem->x1;
- item->y1 = calitem->y1;
- item->x2 = calitem->x2 >= calitem->x1 ? calitem->x2 : calitem->x1;
- item->y2 = calitem->y2 >= calitem->y1 ? calitem->y2 : calitem->y1;
-
- /* Set up Pango prerequisites */
- font_desc = style->font_desc;
- pango_context = gtk_widget_get_pango_context (GTK_WIDGET (item->canvas));
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- /*
- * Calculate the new layout of the calendar.
- */
-
- /* Make sure the minimum row width & cell height and the widths of
- * all the digits and characters are up to date. */
- e_calendar_item_recalc_sizes (calitem);
-
- /* Calculate how many rows & cols we can fit in. */
- width = item->x2 - item->x1;
- height = item->y2 - item->y1;
-
- width -= xthickness * 2;
- height -= ythickness * 2;
-
- if (calitem->min_month_height == 0)
- rows = 1;
- else
- rows = height / calitem->min_month_height;
- rows = MAX (rows, calitem->min_rows);
- if (calitem->max_rows > 0)
- rows = MIN (rows, calitem->max_rows);
-
- if (calitem->min_month_width == 0)
- cols = 1;
- else
- cols = width / calitem->min_month_width;
- cols = MAX (cols, calitem->min_cols);
- if (calitem->max_cols > 0)
- cols = MIN (cols, calitem->max_cols);
-
- if (rows != calitem->rows || cols != calitem->cols)
- e_calendar_item_date_range_changed (calitem);
-
- calitem->rows = rows;
- calitem->cols = cols;
-
- /* Split up the empty space according to the configuration.
- * If the calendar is set to expand, we divide the space between the
- * cells and the spaces around the calendar, otherwise we place the
- * calendars in the center of the available area. */
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-
- calitem->month_width = calitem->min_month_width;
- calitem->month_height = calitem->min_month_height;
- calitem->cell_width = MAX (calitem->max_day_width, (calitem->max_digit_width * 2))
- + E_CALENDAR_ITEM_MIN_CELL_XPAD;
- calitem->cell_height = char_height
- + E_CALENDAR_ITEM_MIN_CELL_YPAD;
- calitem->month_tpad = 0;
- calitem->month_bpad = 0;
- calitem->month_lpad = 0;
- calitem->month_rpad = 0;
-
- space = height - calitem->rows * calitem->month_height;
- if (space > 0) {
- space_per_cal = space / calitem->rows;
- calitem->month_height += space_per_cal;
-
- if (calitem->expand) {
- space_per_cell = space_per_cal / E_CALENDAR_ROWS_PER_MONTH;
- calitem->cell_height += space_per_cell;
- space_per_cal -= space_per_cell * E_CALENDAR_ROWS_PER_MONTH;
- }
-
- calitem->month_tpad = space_per_cal / 2;
- calitem->month_bpad = space_per_cal - calitem->month_tpad;
- }
-
- space = width - calitem->cols * calitem->month_width;
- if (space > 0) {
- space_per_cal = space / calitem->cols;
- calitem->month_width += space_per_cal;
- space -= space_per_cal * calitem->cols;
-
- if (calitem->expand) {
- space_per_cell = space_per_cal / E_CALENDAR_COLS_PER_MONTH;
- calitem->cell_width += space_per_cell;
- space_per_cal -= space_per_cell * E_CALENDAR_COLS_PER_MONTH;
- }
-
- calitem->month_lpad = space_per_cal / 2;
- calitem->month_rpad = space_per_cal - calitem->month_lpad;
- }
-
- space = MAX (0, space);
- calitem->x_offset = space / 2;
-
- gnome_canvas_request_redraw (
- item->canvas, item->x1, item->y1,
- item->x2, item->y2);
-
- pango_font_metrics_unref (font_metrics);
-}
-
-/*
- * DRAWING ROUTINES - functions to paint the canvas item.
- */
-static void
-e_calendar_item_draw (GnomeCanvasItem *canvas_item,
- cairo_t *cr,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- ECalendarItem *calitem;
- GtkWidget *widget;
- GtkStyleContext *style_context;
- gint char_height, row, col, row_y, bar_height, col_x;
- const PangoFontDescription *font_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- GdkRGBA bg_color;
- GtkBorder border;
-
-#if 0
- g_print (
- "In e_calendar_item_draw %i,%i %ix%i\n",
- x, y, width, height);
-#endif
- calitem = E_CALENDAR_ITEM (canvas_item);
-
- widget = GTK_WIDGET (canvas_item->canvas);
- style_context = gtk_widget_get_style_context (widget);
-
- /* Set up Pango prerequisites */
- font_desc = calitem->font_desc;
- if (!font_desc)
- font_desc = gtk_style_context_get_font (
- style_context, GTK_STATE_FLAG_NORMAL);
- pango_context = gtk_widget_get_pango_context (
- GTK_WIDGET (canvas_item->canvas));
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-
- gtk_style_context_get_background_color (
- style_context, GTK_STATE_NORMAL, &bg_color);
-
- gtk_style_context_get_border (
- style_context, GTK_STATE_NORMAL, &border);
-
- /* Clear the entire background. */
- cairo_save (cr);
- gdk_cairo_set_source_rgba (cr, &bg_color);
- cairo_rectangle (
- cr, calitem->x1 - x, calitem->y1 - y,
- calitem->x2 - calitem->x1 + 1,
- calitem->y2 - calitem->y1 + 1);
- cairo_fill (cr);
- cairo_restore (cr);
-
- /* Draw the shadow around the entire item. */
- gtk_style_context_save (style_context);
- gtk_style_context_add_class (
- style_context, GTK_STYLE_CLASS_ENTRY);
- cairo_save (cr);
- gtk_render_frame (
- style_context, cr,
- (gdouble) calitem->x1 - x,
- (gdouble) calitem->y1 - y,
- (gdouble) calitem->x2 - calitem->x1 + 1,
- (gdouble) calitem->y2 - calitem->y1 + 1);
- cairo_restore (cr);
- gtk_style_context_restore (style_context);
-
- row_y = canvas_item->y1 + border.top;
- bar_height =
- border.top + border.bottom +
- E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height +
- E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME;
-
- for (row = 0; row < calitem->rows; row++) {
- /* Draw the background for the title bars and the shadow around
- * it, and the vertical lines between columns. */
-
- cairo_save (cr);
- gdk_cairo_set_source_rgba (cr, &bg_color);
- cairo_rectangle (
- cr, calitem->x1 + border.left - x,
- row_y - y,
- calitem->x2 - calitem->x1 + 1 -
- (border.left + border.right),
- bar_height);
- cairo_fill (cr);
- cairo_restore (cr);
-
- gtk_style_context_save (style_context);
- gtk_style_context_add_class (
- style_context, GTK_STYLE_CLASS_HEADER);
- cairo_save (cr);
- gtk_render_frame (
- style_context, cr,
- (gdouble) calitem->x1 + border.left - x,
- (gdouble) row_y - y,
- (gdouble) calitem->x2 - calitem->x1 + 1 -
- (border.left + border.right),
- (gdouble) bar_height);
- cairo_restore (cr);
- gtk_style_context_restore (style_context);
-
- for (col = 0; col < calitem->cols; col++) {
- if (col != 0) {
- col_x = calitem->x1 + calitem->x_offset
- + calitem->month_width * col;
-
- gtk_style_context_save (style_context);
- gtk_style_context_add_class (
- style_context,
- GTK_STYLE_CLASS_SEPARATOR);
- cairo_save (cr);
- gtk_render_line (
- style_context, cr,
- (gdouble) col_x - 1 - x,
- (gdouble) row_y + border.top + 1 - y,
- (gdouble) row_y + bar_height -
- border.bottom - 2 - y,
- (gdouble) col_x - x);
- cairo_restore (cr);
- gtk_style_context_restore (style_context);
- }
-
- e_calendar_item_draw_month (
- calitem, cr, x, y,
- width, height, row, col);
- }
-
- row_y += calitem->month_height;
- }
-
- pango_font_metrics_unref (font_metrics);
-}
-
-static void
-layout_set_day_text (ECalendarItem *calitem,
- PangoLayout *layout,
- gint day_index)
-{
- const gchar *abbr_name;
-
- /* day_index: 0 = Monday ... 6 = Sunday */
- abbr_name = e_get_weekday_name (day_index + 1, TRUE);
- pango_layout_set_text (layout, abbr_name, -1);
-}
-
-static void
-e_calendar_item_draw_month (ECalendarItem *calitem,
- cairo_t *cr,
- gint x,
- gint y,
- gint width,
- gint height,
- gint row,
- gint col)
-{
- GnomeCanvasItem *item;
- GtkWidget *widget;
- GtkStyle *style;
- PangoFontDescription *font_desc;
- struct tm tmp_tm;
- GdkRectangle clip_rect;
- gint char_height, xthickness, ythickness, start_weekday;
- gint year, month;
- gint month_x, month_y, month_w, month_h;
- gint min_x, max_x, text_x, text_y;
- gint day, day_index, cells_x, cells_y, min_cell_width, text_width, arrow_button_size;
- gint clip_width, clip_height;
- gchar buffer[64];
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- PangoLayout *layout;
-
-#if 0
- g_print (
- "In e_calendar_item_draw_month: %i,%i %ix%i row:%i col:%i\n",
- x, y, width, height, row, col);
-#endif
- item = GNOME_CANVAS_ITEM (calitem);
- widget = GTK_WIDGET (item->canvas);
- style = gtk_widget_get_style (widget);
-
- /* Set up Pango prerequisites */
- font_desc = calitem->font_desc;
- if (!font_desc)
- font_desc = style->font_desc;
- pango_context = gtk_widget_get_pango_context (widget);
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
- xthickness = style->xthickness;
- ythickness = style->ythickness;
- arrow_button_size =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
- + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME
- + 2 * xthickness;
-
- pango_font_metrics_unref (font_metrics);
-
- /* Calculate the top-left position of the entire month display. */
- month_x = item->x1 + xthickness + calitem->x_offset
- + ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- ? (calitem->cols - 1 - col) : col) * calitem->month_width - x;
- month_w = item->x2 - item->x1 - xthickness * 2;
- month_w = MIN (month_w, calitem->month_width);
- month_y = item->y1 + ythickness + row * calitem->month_height - y;
- month_h = item->y2 - item->y1 - ythickness * 2;
- month_h = MIN (month_h, calitem->month_height);
-
- /* Just return if the month is outside the given area. */
- if (month_x >= width || month_x + calitem->month_width <= 0
- || month_y >= height || month_y + calitem->month_height <= 0)
- return;
-
- month = calitem->month + row * calitem->cols + col;
- year = calitem->year + month / 12;
- month %= 12;
-
- /* Draw the month name & year, with clipping. Note that the top row
- * needs extra space around it for the buttons. */
-
- layout = gtk_widget_create_pango_layout (widget, NULL);
-
- if (row == 0 && col == 0)
- min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON;
- else
- min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME;
-
- max_x = month_w;
- if (row == 0 && col == 0)
- max_x -= E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME_WITH_BUTTON;
- else
- max_x -= E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME;
-
- text_y = month_y + style->ythickness
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME;
- clip_rect.x = month_x + min_x;
- clip_rect.x = MAX (0, clip_rect.x);
- clip_rect.y = MAX (0, text_y);
-
- memset (&tmp_tm, 0, sizeof (tmp_tm));
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = 1;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
- start_weekday = (tmp_tm.tm_wday + 6) % 7;
-
- if (month_x + max_x - clip_rect.x > 0) {
- cairo_save (cr);
-
- clip_rect.width = month_x + max_x - clip_rect.x;
- clip_rect.height = text_y + char_height - clip_rect.y;
- gdk_cairo_rectangle (cr, &clip_rect);
- cairo_clip (cr);
-
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
-
- if (row == 0 && col == 0) {
- PangoLayout *layout_yr;
- gchar buffer_yr[64];
- gdouble max_width;
-
- layout_yr = gtk_widget_create_pango_layout (widget, NULL);
-
- /* This is a strftime() format. %B = Month name. */
- e_utf8_strftime (buffer, sizeof (buffer), C_("CalItem", "%B"), &tmp_tm);
- /* This is a strftime() format. %Y = Year. */
- e_utf8_strftime (buffer_yr, sizeof (buffer_yr), C_("CalItem", "%Y"), &tmp_tm);
-
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, buffer, -1);
-
- pango_layout_set_font_description (layout_yr, font_desc);
- pango_layout_set_text (layout_yr, buffer_yr, -1);
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- max_width = calitem->max_month_name_width;
- pango_layout_get_pixel_size (layout, &text_width, NULL);
-
- cairo_move_to (cr, month_x + min_x + arrow_button_size + (max_width - text_width) / 2, text_y);
- pango_cairo_show_layout (cr, layout);
-
- max_width = calitem->max_digit_width * 5;
- pango_layout_get_pixel_size (layout_yr, &text_width, NULL);
-
- cairo_move_to (cr, month_x + month_w - arrow_button_size - (max_width - text_width) / 2 - text_width - min_x, text_y);
- pango_cairo_show_layout (cr, layout_yr);
- } else {
- max_width = calitem->max_digit_width * 5;
- pango_layout_get_pixel_size (layout_yr, &text_width, NULL);
-
- cairo_move_to (cr, month_x + min_x + arrow_button_size + (max_width - text_width) / 2, text_y);
- pango_cairo_show_layout (cr, layout_yr);
-
- max_width = calitem->max_month_name_width;
- pango_layout_get_pixel_size (layout, &text_width, NULL);
-
- cairo_move_to (cr, month_x + month_w - arrow_button_size - (max_width - text_width) / 2 - text_width - min_x, text_y);
- pango_cairo_show_layout (cr, layout);
- }
-
- g_object_unref (layout_yr);
- } else {
- /* This is a strftime() format. %B = Month name, %Y = Year. */
- e_utf8_strftime (buffer, sizeof (buffer), C_("CalItem", "%B %Y"), &tmp_tm);
-
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, buffer, -1);
-
- /* Ideally we place the text centered in the month, but we
- * won't go to the left of the minimum x position. */
- pango_layout_get_pixel_size (layout, &text_width, NULL);
- text_x = (calitem->month_width - text_width) / 2;
- text_x = MAX (min_x, text_x);
-
- cairo_move_to (cr, month_x + text_x, text_y);
- pango_cairo_show_layout (cr, layout);
- }
-
- cairo_restore (cr);
- }
-
- /* Set the clip rectangle for the main month display. */
- clip_rect.x = MAX (0, month_x);
- clip_rect.y = MAX (0, month_y);
- clip_width = month_x + month_w - clip_rect.x;
- clip_height = month_y + month_h - clip_rect.y;
-
- if (clip_width <= 0 || clip_height <= 0) {
- g_object_unref (layout);
- return;
- }
-
- clip_rect.width = clip_width;
- clip_rect.height = clip_height;
-
- cairo_save (cr);
-
- gdk_cairo_rectangle (cr, &clip_rect);
- cairo_clip (cr);
-
- /* Draw the day initials across the top of the month. */
- min_cell_width = MAX (calitem->max_day_width, (calitem->max_digit_width * 2))
- + E_CALENDAR_ITEM_MIN_CELL_XPAD;
-
- cells_x = month_x + E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS + calitem->month_lpad
- + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS;
- if (calitem->show_week_numbers)
- cells_x += calitem->max_week_number_digit_width * 2
- + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1;
- text_x = cells_x + calitem->cell_width
- - (calitem->cell_width - min_cell_width) / 2;
- text_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2;
- text_y = month_y + ythickness * 2
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME
- + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad;
-
- cells_y = text_y + char_height
- + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1
- + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS;
-
- cairo_save (cr);
- gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
- cairo_rectangle (
- cr, cells_x ,
- text_y - E_CALENDAR_ITEM_YPAD_ABOVE_CELLS - 1,
- calitem->cell_width * 7 , cells_y - text_y);
- cairo_fill (cr);
- cairo_restore (cr);
-
- day_index = calitem->week_start_day;
- pango_layout_set_font_description (layout, font_desc);
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- text_x += (7 - 1) * calitem->cell_width;
- gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]);
- for (day = 0; day < 7; day++) {
- cairo_save (cr);
- layout_set_day_text (calitem, layout, day_index);
- cairo_move_to (
- cr,
- text_x - calitem->day_widths[day_index],
- text_y);
- pango_cairo_show_layout (cr, layout);
- text_x += (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- ? -calitem->cell_width : calitem->cell_width;
- day_index++;
- if (day_index == 7)
- day_index = 0;
- cairo_restore (cr);
- }
-
- /* Draw the rectangle around the week number. */
- if (calitem->show_week_numbers) {
- cairo_save (cr);
- gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
- cairo_rectangle (
- cr, cells_x, cells_y - (cells_y - text_y + 2) ,
- -20, E_CALENDAR_ROWS_PER_MONTH * calitem->cell_height + 18);
- cairo_fill (cr);
- cairo_restore (cr);
- }
-
- e_calendar_item_draw_day_numbers (
- calitem, cr, width, height, row, col,
- year, month, start_weekday, cells_x, cells_y);
-
- g_object_unref (layout);
- cairo_restore (cr);
-}
-
-static const gchar *
-get_digit_fomat (void)
-{
-
-#ifdef HAVE_GNU_GET_LIBC_VERSION
-#include <gnu/libc-version.h>
-
- const gchar *libc_version = gnu_get_libc_version ();
- gchar **split = g_strsplit (libc_version, ".", -1);
- gint major = 0;
- gint minor = 0;
- gint revision = 0;
-
- major = atoi (split[0]);
- minor = atoi (split[1]);
-
- if (g_strv_length (split) > 2)
- revision = atoi (split[2]);
- g_strfreev (split);
-
- if (major > 2 || minor > 2 || (minor == 2 && revision > 2)) {
- return "%Id";
- }
-#endif
-
- return "%d";
-}
-
-static void
-e_calendar_item_draw_day_numbers (ECalendarItem *calitem,
- cairo_t *cr,
- gint width,
- gint height,
- gint row,
- gint col,
- gint year,
- gint month,
- gint start_weekday,
- gint cells_x,
- gint cells_y)
-{
- GnomeCanvasItem *item;
- GtkWidget *widget;
- GtkStyle *style;
- PangoFontDescription *font_desc;
- GdkColor *bg_color, *fg_color, *box_color;
- struct tm today_tm;
- time_t t;
- gint char_height, min_cell_width, min_cell_height;
- gint day_num, drow, dcol, day_x, day_y;
- gint text_x, text_y;
- gint num_chars, digit;
- gint week_num, mon, days_from_week_start;
- gint years[3], months[3], days_in_month[3];
- gboolean today, selected, has_focus, drop_target = FALSE;
- gboolean bold, italic, draw_day, finished = FALSE;
- gint today_year, today_month, today_mday, month_offset;
- gchar buffer[9];
- gint day_style = 0;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- PangoLayout *layout;
-
- item = GNOME_CANVAS_ITEM (calitem);
- widget = GTK_WIDGET (item->canvas);
- style = gtk_widget_get_style (widget);
-
- /* Set up Pango prerequisites */
- font_desc = calitem->font_desc;
- if (!font_desc)
- font_desc = style->font_desc;
-
- pango_context = gtk_widget_get_pango_context (widget);
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-
- min_cell_width = MAX (calitem->max_day_width, (calitem->max_digit_width * 2))
- + E_CALENDAR_ITEM_MIN_CELL_XPAD;
- min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD;
-
- layout = pango_cairo_create_layout (cr);
-
- /* Calculate the number of days in the previous, current, and next
- * months. */
- years[0] = years[1] = years[2] = year;
- months[0] = month - 1;
- months[1] = month;
- months[2] = month + 1;
- if (months[0] == -1) {
- months[0] = 11;
- years[0]--;
- }
- if (months[2] == 12) {
- months[2] = 0;
- years[2]++;
- }
-
- days_in_month[0] = DAYS_IN_MONTH (years[0], months[0]);
- days_in_month[1] = DAYS_IN_MONTH (years[1], months[1]);
- days_in_month[2] = DAYS_IN_MONTH (years[2], months[2]);
-
- /* Mon 0 is the previous month, which we may show the end of. Mon 1 is
- * the current month, and mon 2 is the next month. */
- mon = 0;
-
- month_offset = row * calitem->cols + col - 1;
- day_num = days_in_month[0];
- days_from_week_start = (start_weekday + 7 - calitem->week_start_day)
- % 7;
- /* For the top-left month we show the end of the previous month, and
- * if the new month starts on the first day of the week we show a
- * complete week from the previous month. */
- if (days_from_week_start == 0) {
- if (row == 0 && col == 0) {
- day_num -= 6;
- } else {
- mon++;
- month_offset++;
- day_num = 1;
- }
- } else {
- day_num -= days_from_week_start - 1;
- }
-
- /* Get today's date, so we can highlight it. */
- if (calitem->time_callback) {
- today_tm = calitem->time_callback (
- calitem, calitem->time_callback_data);
- } else {
- t = time (NULL);
- today_tm = *localtime (&t);
- }
- today_year = today_tm.tm_year + 1900;
- today_month = today_tm.tm_mon;
- today_mday = today_tm.tm_mday;
-
- /* We usually skip the last days of the previous month (mon = 0),
- * except for the top-left month displayed. */
- draw_day = (mon == 1 || (row == 0 && col == 0));
-
- for (drow = 0; drow < 6; drow++) {
- /* Draw the week number. */
- if (calitem->show_week_numbers) {
- week_num = e_calendar_item_get_week_number (
- calitem, day_num, months[mon], years[mon]);
-
- text_x = cells_x - E_CALENDAR_ITEM_XPAD_BEFORE_CELLS - 1
- - E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS;
- text_y = cells_y + drow * calitem->cell_height +
- + (calitem->cell_height - min_cell_height + 1) / 2;
-
- num_chars = 0;
- if (week_num >= 10) {
- digit = week_num / 10;
- text_x -= calitem->week_number_digit_widths[digit];
- num_chars += sprintf (
- &buffer[num_chars],
- get_digit_fomat (), digit);
- }
-
- digit = week_num % 10;
- text_x -= calitem->week_number_digit_widths[digit] + 6;
- num_chars += sprintf (
- &buffer[num_chars],
- get_digit_fomat (), digit);
-
- cairo_save (cr);
- gdk_cairo_set_source_color (
- cr, &style->text[GTK_STATE_ACTIVE]);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, buffer, num_chars);
- cairo_move_to (cr, text_x, text_y);
- pango_cairo_update_layout (cr, layout);
- pango_cairo_show_layout (cr, layout);
- cairo_restore (cr);
- }
-
- for (dcol = 0; dcol < 7; dcol++) {
- if (draw_day) {
- day_x = cells_x +
- ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- ? 7 - 1 - dcol : dcol) * calitem->cell_width;
-
- day_y = cells_y + drow * calitem->cell_height;
-
- today = years[mon] == today_year
- && months[mon] == today_month
- && day_num == today_mday;
-
- selected = calitem->selection_set
- && (calitem->selection_start_month_offset < month_offset
- || (calitem->selection_start_month_offset == month_offset
- && calitem->selection_start_day <= day_num))
- && (calitem->selection_end_month_offset > month_offset
- || (calitem->selection_end_month_offset == month_offset
- && calitem->selection_end_day >= day_num));
-
- if (calitem->styles)
- day_style = calitem->styles[(month_offset + 1) * 32 + day_num];
-
- /* Get the colors & style to use for the day.*/
- if ((gtk_widget_has_focus (GTK_WIDGET (item->canvas))) &&
- item->canvas->focused_item == item)
- has_focus = TRUE;
- else
- has_focus = FALSE;
-
- bold = FALSE;
- italic = FALSE;
-
- if (calitem->style_callback)
- calitem->style_callback (
- calitem,
- years[mon],
- months[mon],
- day_num,
- day_style,
- today,
- mon != 1,
- selected,
- has_focus,
- drop_target,
- &bg_color,
- &fg_color,
- &box_color,
- &bold,
- &italic,
- calitem->style_callback_data);
- else
- e_calendar_item_get_day_style (
- calitem,
- years[mon],
- months[mon],
- day_num,
- day_style,
- today,
- mon != 1,
- selected,
- has_focus,
- drop_target,
- &bg_color,
- &fg_color,
- &box_color,
- &bold,
- &italic);
-
- /* Draw the background, if set. */
- if (bg_color) {
- cairo_save (cr);
- gdk_cairo_set_source_color (cr, bg_color);
- cairo_rectangle (
- cr, day_x , day_y,
- calitem->cell_width,
- calitem->cell_height);
- cairo_fill (cr);
- cairo_restore (cr);
- }
-
- /* Draw the box, if set. */
- if (box_color) {
- cairo_save (cr);
- gdk_cairo_set_source_color (cr, box_color);
- cairo_rectangle (
- cr, day_x , day_y,
- calitem->cell_width - 1,
- calitem->cell_height - 1);
- cairo_stroke (cr);
- cairo_restore (cr);
- }
-
- /* Draw the 1- or 2-digit day number. */
- day_x += calitem->cell_width -
- (calitem->cell_width -
- min_cell_width) / 2;
- day_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2;
- day_y += (calitem->cell_height - min_cell_height + 1) / 2;
- day_y += E_CALENDAR_ITEM_MIN_CELL_YPAD / 2;
-
- num_chars = 0;
- if (day_num >= 10) {
- digit = day_num / 10;
- day_x -= calitem->digit_widths[digit];
- num_chars += sprintf (
- &buffer[num_chars],
- get_digit_fomat (), digit);
- }
-
- digit = day_num % 10;
- day_x -= calitem->digit_widths[digit];
- num_chars += sprintf (
- &buffer[num_chars],
- get_digit_fomat (), digit);
-
- cairo_save (cr);
- if (fg_color) {
- gdk_cairo_set_source_color (
- cr, fg_color);
- } else {
- gdk_cairo_set_source_color (
- cr, &style->fg[GTK_STATE_NORMAL]);
- }
-
- if (bold) {
- pango_font_description_set_weight (
- font_desc, PANGO_WEIGHT_BOLD);
- } else {
- pango_font_description_set_weight (
- font_desc, PANGO_WEIGHT_NORMAL);
- }
-
- if (italic) {
- pango_font_description_set_style (
- font_desc, PANGO_STYLE_ITALIC);
- } else {
- pango_font_description_set_style (
- font_desc, PANGO_STYLE_NORMAL);
- }
-
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, buffer, num_chars);
- cairo_move_to (cr, day_x, day_y);
- pango_cairo_update_layout (cr, layout);
- pango_cairo_show_layout (cr, layout);
- cairo_restore (cr);
- }
-
- /* See if we've reached the end of a month. */
- if (day_num == days_in_month[mon]) {
- month_offset++;
- mon++;
- /* We only draw the start of the next month
- * for the bottom-right month displayed. */
- if (mon == 2 && (row != calitem->rows - 1
- || col != calitem->cols - 1)) {
- /* Set a flag so we exit the loop. */
- finished = TRUE;
- break;
- }
- day_num = 1;
- draw_day = TRUE;
- } else {
- day_num++;
- }
- }
-
- /* Exit the loop if the flag is set. */
- if (finished)
- break;
- }
-
- /* Reset pango weight and style */
- pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
- pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
-
- g_object_unref (layout);
-
- pango_font_metrics_unref (font_metrics);
-}
-
-gint
-e_calendar_item_get_week_number (ECalendarItem *calitem,
- gint day,
- gint month,
- gint year)
-{
- GDate date;
- guint weekday, yearday;
- gint week_num;
-
- g_date_clear (&date, 1);
- g_date_set_dmy (&date, day, month + 1, year);
-
- /* This results in a value of 0 (Monday) - 6 (Sunday).
- * (or -1 on error - oops!!) */
- weekday = g_date_get_weekday (&date) - 1;
-
- if (weekday > 0) {
- /* we want always point to nearest Monday, as the first day of the week,
- * regardless of the calendar's week_start_day */
- if (weekday >= 3)
- g_date_add_days (&date, 7 - weekday);
- else
- g_date_subtract_days (&date, weekday);
- }
-
- /* Calculate the day of the year, from 0 to 365. */
- yearday = g_date_get_day_of_year (&date) - 1;
-
- /* If the week starts on or after 29th December, it is week 1 of the
- * next year, since there are 4 days in the next year. */
- if (g_date_get_month (&date) == 12 && g_date_get_day (&date) >= 29)
- return 1;
-
- /* Calculate the week number, from 0. */
- week_num = yearday / 7;
-
- /* If the first week starts on or after Jan 5th, then we need to add
- * 1 since the previous week will really be the first week. */
- if (yearday % 7 >= 4)
- week_num++;
-
- /* Add 1 so week numbers are from 1 to 53. */
- return week_num + 1;
-}
-
-/* This is supposed to return the nearest item the the point and the distance.
- * Since we are the only item we just return ourself and 0 for the distance.
- * This is needed so that we get button/motion events. */
-static GnomeCanvasItem *
-e_calendar_item_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy)
-{
- return item;
-}
-
-static void
-e_calendar_item_stop_selecting (ECalendarItem *calitem,
- guint32 time)
-{
- if (!calitem->selecting)
- return;
-
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (calitem), time);
-
- calitem->selecting = FALSE;
-
- /* If the user selects the grayed dates before the first month or
- * after the last month, we move backwards or forwards one month.
- * The set_month () call should take care of updating the selection. */
- if (calitem->selection_end_month_offset == -1)
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month - 1);
- else if (calitem->selection_start_month_offset == calitem->rows * calitem->cols)
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month + 1);
-
- calitem->selection_changed = TRUE;
- if (calitem->selecting_axis) {
- g_free (calitem->selecting_axis);
- calitem->selecting_axis = NULL;
- }
-
- e_calendar_item_queue_signal_emission (calitem);
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-}
-
-static void
-e_calendar_item_selection_add_days (ECalendarItem *calitem,
- gint n_days,
- gboolean multi_selection)
-{
- GDate gdate_start, gdate_end;
-
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
-
- if (!e_calendar_item_get_selection (calitem, &gdate_start, &gdate_end)) {
- /* We set the date to the first day of the month */
- g_date_set_dmy (&gdate_start, 1, calitem->month + 1, calitem->year);
- gdate_end = gdate_start;
- }
-
- if (multi_selection && calitem->max_days_selected > 1) {
- gint days_between;
-
- days_between = g_date_days_between (&gdate_start, &gdate_end);
- if (!calitem->selecting_axis) {
- calitem->selecting_axis = g_new (GDate, 1);
- *(calitem->selecting_axis) = gdate_start;
- }
- if ((days_between != 0 &&
- g_date_compare (calitem->selecting_axis, &gdate_end) == 0) ||
- (days_between == 0 && n_days < 0)) {
- if (days_between - n_days > calitem->max_days_selected - 1)
- n_days = days_between + 1 - calitem->max_days_selected;
- g_date_add_days (&gdate_start, n_days);
- }
- else {
- if (days_between + n_days > calitem->max_days_selected - 1)
- n_days = calitem->max_days_selected - 1 - days_between;
- g_date_add_days (&gdate_end, n_days);
- }
-
- if (g_date_compare (&gdate_end, &gdate_start) < 0) {
- GDate tmp_date;
- tmp_date = gdate_start;
- gdate_start = gdate_end;
- gdate_end = tmp_date;
- }
- }
- else {
- /* clear "selecting_axis", it is only for mulit-selecting */
- if (calitem->selecting_axis) {
- g_free (calitem->selecting_axis);
- calitem->selecting_axis = NULL;
- }
- g_date_add_days (&gdate_start, n_days);
- gdate_end = gdate_start;
- }
-
- calitem->selecting = TRUE;
-
- e_calendar_item_set_selection_if_emission (
- calitem, &gdate_start, &gdate_end, FALSE);
-
- g_signal_emit_by_name (calitem, "selection_preview_changed");
-}
-
-static gint
-e_calendar_item_key_press_event (ECalendarItem *calitem,
- GdkEvent *event)
-{
- guint keyval = event->key.keyval;
- gboolean multi_selection = FALSE;
-
- if (event->key.state & GDK_CONTROL_MASK ||
- event->key.state & GDK_MOD1_MASK)
- return FALSE;
-
- multi_selection = event->key.state & GDK_SHIFT_MASK;
- switch (keyval) {
- case GDK_KEY_Up:
- e_calendar_item_selection_add_days (
- calitem, -7,
- multi_selection);
- break;
- case GDK_KEY_Down:
- e_calendar_item_selection_add_days (
- calitem, 7,
- multi_selection);
- break;
- case GDK_KEY_Left:
- e_calendar_item_selection_add_days (
- calitem, -1,
- multi_selection);
- break;
- case GDK_KEY_Right:
- e_calendar_item_selection_add_days (
- calitem, 1,
- multi_selection);
- break;
- case GDK_KEY_space:
- case GDK_KEY_Return:
- e_calendar_item_stop_selecting (calitem, event->key.time);
- break;
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-static gint
-e_calendar_item_event (GnomeCanvasItem *item,
- GdkEvent *event)
-{
- ECalendarItem *calitem;
-
- calitem = E_CALENDAR_ITEM (item);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- return e_calendar_item_button_press (calitem, event);
- case GDK_BUTTON_RELEASE:
- return e_calendar_item_button_release (calitem, event);
- case GDK_MOTION_NOTIFY:
- return e_calendar_item_motion (calitem, event);
- case GDK_FOCUS_CHANGE:
- gnome_canvas_item_request_update (item);
- return FALSE;
- case GDK_KEY_PRESS:
- return e_calendar_item_key_press_event (calitem, event);
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-e_calendar_item_bounds (GnomeCanvasItem *item,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2)
-{
- ECalendarItem *calitem;
-
- g_return_if_fail (E_IS_CALENDAR_ITEM (item));
-
- calitem = E_CALENDAR_ITEM (item);
- *x1 = calitem->x1;
- *y1 = calitem->y1;
- *x2 = calitem->x2;
- *y2 = calitem->y2;
-}
-
-/* This checks if any fonts have changed, and if so it recalculates the
- * text sizes and the minimum month size. */
-static void
-e_calendar_item_recalc_sizes (ECalendarItem *calitem)
-{
- GnomeCanvasItem *canvas_item;
- GtkStyle *style;
- gint day, max_day_width, digit, max_digit_width, max_week_number_digit_width;
- gint char_height, width, min_cell_width, min_cell_height;
- gchar buffer[64];
- struct tm tmp_tm;
- PangoFontDescription *font_desc, *wkfont_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- PangoLayout *layout;
-
- canvas_item = GNOME_CANVAS_ITEM (calitem);
- style = gtk_widget_get_style (GTK_WIDGET (canvas_item->canvas));
-
- if (!style)
- return;
-
- /* Set up Pango prerequisites */
- font_desc = calitem->font_desc;
- wkfont_desc = calitem->week_number_font_desc;
- if (!font_desc)
- font_desc = style->font_desc;
-
- pango_context = gtk_widget_create_pango_context (
- GTK_WIDGET (canvas_item->canvas));
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
- layout = pango_layout_new (pango_context);
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-
- max_day_width = 0;
- for (day = 0; day < 7; day++) {
- layout_set_day_text (calitem, layout, day);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- calitem->day_widths[day] = width;
- max_day_width = MAX (max_day_width, width);
- }
- calitem->max_day_width = max_day_width;
-
- max_digit_width = 0;
- max_week_number_digit_width = 0;
- for (digit = 0; digit < 10; digit++) {
- gchar locale_digit[5];
- gint locale_digit_len;
-
- locale_digit_len = sprintf (locale_digit, get_digit_fomat (), digit);
-
- pango_layout_set_text (layout, locale_digit, locale_digit_len);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- calitem->digit_widths[digit] = width;
- max_digit_width = MAX (max_digit_width, width);
-
- if (wkfont_desc) {
- pango_context_set_font_description (pango_context, wkfont_desc);
- pango_layout_context_changed (layout);
-
- pango_layout_set_text (layout, locale_digit, locale_digit_len);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- calitem->week_number_digit_widths[digit] = width;
- max_week_number_digit_width = MAX (max_week_number_digit_width, width);
-
- pango_context_set_font_description (pango_context, font_desc);
- pango_layout_context_changed (layout);
- } else {
- calitem->week_number_digit_widths[digit] = width;
- max_week_number_digit_width = max_digit_width;
- }
- }
- calitem->max_digit_width = max_digit_width;
- calitem->max_week_number_digit_width = max_week_number_digit_width;
-
- min_cell_width = MAX (calitem->max_day_width, (calitem->max_digit_width * 2))
- + E_CALENDAR_ITEM_MIN_CELL_XPAD;
- min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD;
-
- calitem->min_month_width = E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS
- + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS + min_cell_width * 7
- + E_CALENDAR_ITEM_XPAD_AFTER_CELLS;
- if (calitem->show_week_numbers) {
- calitem->min_month_width += calitem->max_week_number_digit_width * 2
- + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1;
- }
-
- calitem->min_month_height = style->ythickness * 2
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height
- + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME + 1
- + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1
- + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS + min_cell_height * 6
- + E_CALENDAR_ITEM_YPAD_BELOW_CELLS;
-
- calitem->max_month_name_width = 50;
- memset (&tmp_tm, 0, sizeof (tmp_tm));
- tmp_tm.tm_year = 2000 - 100;
- tmp_tm.tm_mday = 1;
- tmp_tm.tm_isdst = -1;
- for (tmp_tm.tm_mon = 0; tmp_tm.tm_mon < 12; tmp_tm.tm_mon++) {
- mktime (&tmp_tm);
-
- e_utf8_strftime (buffer, sizeof (buffer), C_("CalItem", "%B"), &tmp_tm);
-
- pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- if (width > calitem->max_month_name_width)
- calitem->max_month_name_width = width;
- }
-
- g_object_unref (layout);
- g_object_unref (pango_context);
- pango_font_metrics_unref (font_metrics);
-}
-
-static void
-e_calendar_item_get_day_style (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- gint day_style,
- gboolean today,
- gboolean prev_or_next_month,
- gboolean selected,
- gboolean has_focus,
- gboolean drop_target,
- GdkColor **bg_color,
- GdkColor **fg_color,
- GdkColor **box_color,
- gboolean *bold,
- gboolean *italic)
-{
- GtkWidget *widget;
- GtkStyle *style;
-
- widget = GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas);
- style = gtk_widget_get_style (widget);
-
- *bg_color = NULL;
- *fg_color = NULL;
- *box_color = NULL;
-
- *bold = (day_style & E_CALENDAR_ITEM_MARK_BOLD) ==
- E_CALENDAR_ITEM_MARK_BOLD;
- *italic = (day_style & E_CALENDAR_ITEM_MARK_ITALIC) ==
- E_CALENDAR_ITEM_MARK_ITALIC;
-
- if (today)
- *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX];
-
- if (prev_or_next_month)
- *fg_color = &style->mid[gtk_widget_get_state (widget)];
-
- if (selected) {
- if (has_focus) {
- *fg_color = &style->text[GTK_STATE_SELECTED];
- *bg_color = &style->base[GTK_STATE_SELECTED];
- } else {
- *fg_color = &style->text[GTK_STATE_ACTIVE];
- *bg_color = &style->base[GTK_STATE_ACTIVE];
-
- if ((*bg_color)->red == style->base[GTK_STATE_NORMAL].red &&
- (*bg_color)->green == style->base[GTK_STATE_NORMAL].green &&
- (*bg_color)->blue == style->base[GTK_STATE_NORMAL].blue) {
- *fg_color = &style->text[GTK_STATE_SELECTED];
- *bg_color = &style->base[GTK_STATE_SELECTED];
- }
- }
- }
-}
-
-static gboolean
-e_calendar_item_button_press (ECalendarItem *calitem,
- GdkEvent *button_event)
-{
- GdkGrabStatus grab_status;
- GdkDevice *event_device;
- guint event_button = 0;
- guint32 event_time;
- gdouble event_x_win = 0;
- gdouble event_y_win = 0;
- gint month_offset, day, add_days = 0;
- gboolean all_week, round_up_end = FALSE, round_down_start = FALSE;
-
- gdk_event_get_button (button_event, &event_button);
- gdk_event_get_coords (button_event, &event_x_win, &event_y_win);
- event_device = gdk_event_get_device (button_event);
- event_time = gdk_event_get_time (button_event);
-
- if (event_button == 4)
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month - 1);
- else if (event_button == 5)
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month + 1);
-
- if (!e_calendar_item_convert_position_to_day (calitem,
- event_x_win,
- event_y_win,
- TRUE,
- &month_offset, &day,
- &all_week))
- return FALSE;
-
- if (event_button == 3 && day == -1
- && e_calendar_item_get_display_popup (calitem)) {
- e_calendar_item_show_popup_menu (
- calitem, button_event, month_offset);
- return TRUE;
- }
-
- if (event_button != 1 || day == -1)
- return FALSE;
-
- if (calitem->max_days_selected < 1)
- return TRUE;
-
- grab_status = gnome_canvas_item_grab (
- GNOME_CANVAS_ITEM (calitem),
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK,
- NULL,
- event_device,
- event_time);
-
- if (grab_status != GDK_GRAB_SUCCESS)
- return FALSE;
-
- if (all_week && calitem->keep_wdays_on_weeknum_click) {
- gint tmp_start_moff, tmp_start_day;
-
- tmp_start_moff = calitem->selection_start_month_offset;
- tmp_start_day = calitem->selection_start_day;
- e_calendar_item_round_down_selection (
- calitem, &tmp_start_moff, &tmp_start_day);
-
- e_calendar_item_round_down_selection (calitem, &month_offset, &day);
- month_offset += calitem->selection_start_month_offset - tmp_start_moff;
- day += calitem->selection_start_day - tmp_start_day;
-
- /* keep same count of days selected */
- add_days = e_calendar_item_get_inclusive_days (
- calitem,
- calitem->selection_start_month_offset,
- calitem->selection_start_day,
- calitem->selection_end_month_offset,
- calitem->selection_end_day) - 1;
- }
-
- calitem->selection_set = TRUE;
- calitem->selection_start_month_offset = month_offset;
- calitem->selection_start_day = day;
- calitem->selection_end_month_offset = month_offset;
- calitem->selection_end_day = day;
-
- if (add_days > 0)
- e_calendar_item_add_days_to_selection (calitem, add_days);
-
- calitem->selection_real_start_month_offset = month_offset;
- calitem->selection_real_start_day = day;
-
- calitem->selection_from_full_week = FALSE;
- calitem->selecting = TRUE;
- calitem->selection_dragging_end = TRUE;
-
- if (all_week && !calitem->keep_wdays_on_weeknum_click) {
- calitem->selection_from_full_week = TRUE;
- round_up_end = TRUE;
- }
-
- if (calitem->days_to_start_week_selection == 1) {
- round_down_start = TRUE;
- round_up_end = TRUE;
- }
-
- /* Don't round up or down if we can't select a week or more,
- * or when keeping week days. */
- if (calitem->max_days_selected < 7 ||
- (all_week && calitem->keep_wdays_on_weeknum_click)) {
- round_down_start = FALSE;
- round_up_end = FALSE;
- }
-
- if (round_up_end)
- e_calendar_item_round_up_selection (
- calitem, &calitem->selection_end_month_offset,
- &calitem->selection_end_day);
-
- if (round_down_start)
- e_calendar_item_round_down_selection (
- calitem, &calitem->selection_start_month_offset,
- &calitem->selection_start_day);
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-
- return TRUE;
-}
-
-static gboolean
-e_calendar_item_button_release (ECalendarItem *calitem,
- GdkEvent *button_event)
-{
- guint32 event_time;
-
- event_time = gdk_event_get_time (button_event);
- e_calendar_item_stop_selecting (calitem, event_time);
-
- return FALSE;
-}
-
-static gboolean
-e_calendar_item_motion (ECalendarItem *calitem,
- GdkEvent *event)
-{
- gint start_month, start_day, end_month, end_day, month_offset, day;
- gint tmp_month, tmp_day, days_in_selection;
- gboolean all_week, round_up_end = FALSE, round_down_start = FALSE;
-
- if (!calitem->selecting)
- return FALSE;
-
- if (!e_calendar_item_convert_position_to_day (calitem,
- event->button.x,
- event->button.y,
- TRUE,
- &month_offset, &day,
- &all_week))
- return FALSE;
-
- if (day == -1)
- return FALSE;
-
- if (calitem->selection_dragging_end) {
- start_month = calitem->selection_real_start_month_offset;
- start_day = calitem->selection_real_start_day;
- end_month = month_offset;
- end_day = day;
- } else {
- start_month = month_offset;
- start_day = day;
- end_month = calitem->selection_real_start_month_offset;
- end_day = calitem->selection_real_start_day;
- }
-
- if (start_month > end_month || (start_month == end_month
- && start_day > end_day)) {
- tmp_month = start_month;
- tmp_day = start_day;
- start_month = end_month;
- start_day = end_day;
- end_month = tmp_month;
- end_day = tmp_day;
-
- calitem->selection_dragging_end =
- !calitem->selection_dragging_end;
- }
-
- if (calitem->days_to_start_week_selection > 0) {
- days_in_selection = e_calendar_item_get_inclusive_days (
- calitem, start_month, start_day, end_month, end_day);
- if (days_in_selection >= calitem->days_to_start_week_selection) {
- round_down_start = TRUE;
- round_up_end = TRUE;
- }
- }
-
- /* If we are over a week number and we are dragging the end of the
- * selection, we round up to the end of this week. */
- if (all_week && calitem->selection_dragging_end)
- round_up_end = TRUE;
-
- /* If the selection was started from a week number and we are dragging
- * the start of the selection, we need to round up the end to include
- * all of the original week selected. */
- if (calitem->selection_from_full_week
- && !calitem->selection_dragging_end)
- round_up_end = TRUE;
-
- /* Don't round up or down if we can't select a week or more. */
- if (calitem->max_days_selected < 7) {
- round_down_start = FALSE;
- round_up_end = FALSE;
- }
-
- if (round_up_end)
- e_calendar_item_round_up_selection (
- calitem, &end_month,
- &end_day);
- if (round_down_start)
- e_calendar_item_round_down_selection (
- calitem, &start_month,
- &start_day);
-
- /* Check we don't go over the maximum number of days to select. */
- if (calitem->selection_dragging_end) {
- e_calendar_item_check_selection_end (
- calitem,
- start_month,
- start_day,
- &end_month,
- &end_day);
- } else {
- e_calendar_item_check_selection_start (
- calitem,
- &start_month,
- &start_day,
- end_month,
- end_day);
- }
-
- if (start_month == calitem->selection_start_month_offset
- && start_day == calitem->selection_start_day
- && end_month == calitem->selection_end_month_offset
- && end_day == calitem->selection_end_day)
- return FALSE;
-
- calitem->selection_start_month_offset = start_month;
- calitem->selection_start_day = start_day;
- calitem->selection_end_month_offset = end_month;
- calitem->selection_end_day = end_day;
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-
- return TRUE;
-}
-
-static void
-e_calendar_item_check_selection_end (ECalendarItem *calitem,
- gint start_month,
- gint start_day,
- gint *end_month,
- gint *end_day)
-{
- gint year, month, max_month, max_day, days_in_month;
-
- if (calitem->max_days_selected <= 0)
- return;
-
- year = calitem->year;
- month = calitem->month + start_month;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- max_month = start_month;
- max_day = start_day + calitem->max_days_selected - 1;
-
- for (;;) {
- days_in_month = DAYS_IN_MONTH (year, month);
- if (max_day <= days_in_month)
- break;
- max_month++;
- month++;
- if (month == 12) {
- year++;
- month = 0;
- }
- max_day -= days_in_month;
- }
-
- if (*end_month > max_month) {
- *end_month = max_month;
- *end_day = max_day;
- } else if (*end_month == max_month && *end_day > max_day) {
- *end_day = max_day;
- }
-}
-
-static void
-e_calendar_item_check_selection_start (ECalendarItem *calitem,
- gint *start_month,
- gint *start_day,
- gint end_month,
- gint end_day)
-{
- gint year, month, min_month, min_day, days_in_month;
-
- if (calitem->max_days_selected <= 0)
- return;
-
- year = calitem->year;
- month = calitem->month + end_month;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- min_month = end_month;
- min_day = end_day - calitem->max_days_selected + 1;
-
- while (min_day <= 0) {
- min_month--;
- month--;
- if (month == -1) {
- year--;
- month = 11;
- }
- days_in_month = DAYS_IN_MONTH (year, month);
- min_day += days_in_month;
- }
-
- if (*start_month < min_month) {
- *start_month = min_month;
- *start_day = min_day;
- } else if (*start_month == min_month && *start_day < min_day) {
- *start_day = min_day;
- }
-}
-
-/* Converts a position within the item to a month & day.
- * The month returned is 0 for the top-left month displayed.
- * If the position is over the month heading -1 is returned for the day.
- * If the position is over a week number the first day of the week is returned
- * and entire_week is set to TRUE.
- * It returns FALSE if the position is completely outside all months. */
-static gboolean
-e_calendar_item_convert_position_to_day (ECalendarItem *calitem,
- gint event_x,
- gint event_y,
- gboolean round_empty_positions,
- gint *month_offset,
- gint *day,
- gboolean *entire_week)
-{
- GnomeCanvasItem *item;
- GtkWidget *widget;
- GtkStyle *style;
- gint xthickness, ythickness, char_height;
- gint x, y, row, col, cells_x, cells_y, day_row, day_col;
- gint first_day_offset, days_in_month, days_in_prev_month;
- gint week_num_x1, week_num_x2;
- PangoFontDescription *font_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
-
- item = GNOME_CANVAS_ITEM (calitem);
- widget = GTK_WIDGET (item->canvas);
- style = gtk_widget_get_style (widget);
-
- font_desc = calitem->font_desc;
- if (!font_desc)
- font_desc = style->font_desc;
- pango_context = gtk_widget_create_pango_context (widget);
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-
- pango_font_metrics_unref (font_metrics);
-
- *entire_week = FALSE;
-
- x = event_x - xthickness - calitem->x_offset;
- y = event_y - ythickness;
-
- if (x < 0 || y < 0)
- return FALSE;
-
- row = y / calitem->month_height;
- col = x / calitem->month_width;
-
- if (row >= calitem->rows || col >= calitem->cols)
- return FALSE;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- col = calitem->cols - 1 - col;
-
- *month_offset = row * calitem->cols + col;
-
- x = x % calitem->month_width;
- y = y % calitem->month_height;
-
- if (y < ythickness * 2 + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME) {
- *day = -1;
- return TRUE;
- }
-
- cells_y = ythickness * 2 + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME
- + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1
- + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS;
- y -= cells_y;
- if (y < 0)
- return FALSE;
- day_row = y / calitem->cell_height;
- if (day_row >= E_CALENDAR_ROWS_PER_MONTH)
- return FALSE;
-
- week_num_x1 = E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS + calitem->month_lpad;
-
- if (calitem->show_week_numbers) {
- week_num_x2 = week_num_x1
- + calitem->max_week_number_digit_width * 2;
- if (x >= week_num_x1 && x < week_num_x2)
- *entire_week = TRUE;
- cells_x = week_num_x2 + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1;
- } else {
- cells_x = week_num_x1;
- }
-
- if (*entire_week) {
- day_col = 0;
- } else {
- cells_x += E_CALENDAR_ITEM_XPAD_BEFORE_CELLS;
- x -= cells_x;
- if (x < 0)
- return FALSE;
- day_col = x / calitem->cell_width;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- day_col = E_CALENDAR_COLS_PER_MONTH - 1 - day_col;
- if (day_col >= E_CALENDAR_COLS_PER_MONTH)
- return FALSE;
- }
-
- *day = day_row * E_CALENDAR_COLS_PER_MONTH + day_col;
-
- e_calendar_item_get_month_info (
- calitem, row, col, &first_day_offset,
- &days_in_month, &days_in_prev_month);
- if (*day < first_day_offset) {
- if (*entire_week || (row == 0 && col == 0)) {
- (*month_offset)--;
- *day = days_in_prev_month + 1 - first_day_offset
- + *day;
- return TRUE;
- } else if (round_empty_positions) {
- *day = first_day_offset;
- } else {
- return FALSE;
- }
- }
-
- *day -= first_day_offset - 1;
-
- if (*day > days_in_month) {
- if (row == calitem->rows - 1 && col == calitem->cols - 1) {
- (*month_offset)++;
- *day -= days_in_month;
- return TRUE;
- } else if (round_empty_positions) {
- *day = days_in_month;
- } else {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-e_calendar_item_get_month_info (ECalendarItem *calitem,
- gint row,
- gint col,
- gint *first_day_offset,
- gint *days_in_month,
- gint *days_in_prev_month)
-{
- gint year, month, start_weekday, first_day_of_month;
- struct tm tmp_tm = { 0 };
-
- month = calitem->month + row * calitem->cols + col;
- year = calitem->year + month / 12;
- month = month % 12;
-
- *days_in_month = DAYS_IN_MONTH (year, month);
- if (month == 0)
- *days_in_prev_month = DAYS_IN_MONTH (year - 1, 11);
- else
- *days_in_prev_month = DAYS_IN_MONTH (year, month - 1);
-
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = 1;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
-
- /* Convert to 0 (Monday) to 6 (Sunday). */
- start_weekday = (tmp_tm.tm_wday + 6) % 7;
-
- first_day_of_month = (start_weekday + 7 - calitem->week_start_day) % 7;
-
- if (row == 0 && col == 0 && first_day_of_month == 0)
- *first_day_offset = 7;
- else
- *first_day_offset = first_day_of_month;
-}
-
-void
-e_calendar_item_get_first_month (ECalendarItem *calitem,
- gint *year,
- gint *month)
-{
- *year = calitem->year;
- *month = calitem->month;
-}
-
-static void
-e_calendar_item_preserve_day_selection (ECalendarItem *calitem,
- gint selected_day,
- gint *month_offset,
- gint *day)
-{
- gint year, month, weekday, days, days_in_month;
- struct tm tmp_tm = { 0 };
-
- year = calitem->year;
- month = calitem->month + *month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = *day;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
-
- /* Convert to 0 (Monday) to 6 (Sunday). */
- weekday = (tmp_tm.tm_wday + 6) % 7;
-
- /* Calculate how many days to the start of the row. */
- days = (weekday + 7 - selected_day) % 7;
-
- *day -= days;
- if (*day <= 0) {
- month--;
- if (month == -1) {
- year--;
- month = 11;
- }
- days_in_month = DAYS_IN_MONTH (year, month);
- (*month_offset)--;
- *day += days_in_month;
- }
-}
-
-/* This also handles values of month < 0 or > 11 by updating the year. */
-void
-e_calendar_item_set_first_month (ECalendarItem *calitem,
- gint year,
- gint month)
-{
- gint new_year, new_month, months_diff, num_months;
- gint old_days_in_selection, new_days_in_selection;
-
- new_year = year;
- new_month = month;
- e_calendar_item_normalize_date (calitem, &new_year, &new_month);
-
- if (calitem->year == new_year && calitem->month == new_month)
- return;
-
- /* Update the selection. */
- num_months = calitem->rows * calitem->cols;
- months_diff = (new_year - calitem->year) * 12
- + new_month - calitem->month;
-
- if (calitem->selection_set) {
- if (!calitem->move_selection_when_moving
- || (calitem->selection_start_month_offset - months_diff >= 0
- && calitem->selection_end_month_offset - months_diff < num_months)) {
- calitem->selection_start_month_offset -= months_diff;
- calitem->selection_end_month_offset -= months_diff;
- calitem->selection_real_start_month_offset -= months_diff;
-
- calitem->year = new_year;
- calitem->month = new_month;
- } else {
- gint selected_day;
- struct tm tmp_tm = { 0 };
-
- old_days_in_selection = e_calendar_item_get_inclusive_days (
- calitem,
- calitem->selection_start_month_offset,
- calitem->selection_start_day,
- calitem->selection_end_month_offset,
- calitem->selection_end_day);
-
- /* Calculate the currently selected day */
- tmp_tm.tm_year = calitem->year - 1900;
- tmp_tm.tm_mon = calitem->month + calitem->selection_start_month_offset;
- tmp_tm.tm_mday = calitem->selection_start_day;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
-
- selected_day = (tmp_tm.tm_wday + 6) % 7;
-
- /* Make sure the selection will be displayed. */
- if (calitem->selection_start_month_offset < 0
- || calitem->selection_start_month_offset >= num_months) {
- calitem->selection_end_month_offset -=
- calitem->selection_start_month_offset;
- calitem->selection_start_month_offset = 0;
- }
-
- /* We want to ensure that the same number of days are
- * selected after we have moved the selection. */
- calitem->year = new_year;
- calitem->month = new_month;
-
- e_calendar_item_ensure_valid_day (
- calitem, &calitem->selection_start_month_offset,
- &calitem->selection_start_day);
- e_calendar_item_ensure_valid_day (
- calitem, &calitem->selection_end_month_offset,
- &calitem->selection_end_day);
-
- if (calitem->preserve_day_when_moving) {
- e_calendar_item_preserve_day_selection (
- calitem, selected_day,
- &calitem->selection_start_month_offset,
- &calitem->selection_start_day);
- }
-
- new_days_in_selection = e_calendar_item_get_inclusive_days (
- calitem,
- calitem->selection_start_month_offset,
- calitem->selection_start_day,
- calitem->selection_end_month_offset,
- calitem->selection_end_day);
-
- if (old_days_in_selection != new_days_in_selection)
- e_calendar_item_add_days_to_selection (
- calitem, old_days_in_selection -
- new_days_in_selection);
-
- /* Flag that we need to emit the "selection_changed"
- * signal. We don't want to emit it here since setting
- * the "year" and "month" args would result in 2
- * signals emitted. */
- calitem->selection_changed = TRUE;
- }
- } else {
- calitem->year = new_year;
- calitem->month = new_month;
- }
-
- e_calendar_item_date_range_changed (calitem);
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-}
-
-/* Get the maximum number of days selectable */
-gint
-e_calendar_item_get_max_days_sel (ECalendarItem *calitem)
-{
- return calitem->max_days_selected;
-}
-
-/* Set the maximum number of days selectable */
-void
-e_calendar_item_set_max_days_sel (ECalendarItem *calitem,
- gint days)
-{
- calitem->max_days_selected = MAX (0, days);
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-}
-
-/* Get the maximum number of days before whole weeks are selected */
-gint
-e_calendar_item_get_days_start_week_sel (ECalendarItem *calitem)
-{
- return calitem->days_to_start_week_selection;
-}
-
-/* Set the maximum number of days before whole weeks are selected */
-void
-e_calendar_item_set_days_start_week_sel (ECalendarItem *calitem,
- gint days)
-{
- calitem->days_to_start_week_selection = days;
-}
-
-gboolean
-e_calendar_item_get_display_popup (ECalendarItem *calitem)
-{
- return calitem->display_popup;
-}
-
-void
-e_calendar_item_set_display_popup (ECalendarItem *calitem,
- gboolean display)
-{
- calitem->display_popup = display;
-}
-
-/* This will make sure that the given year & month are valid, i.e. if month
- * is < 0 or > 11 the year and month will be updated accordingly. */
-void
-e_calendar_item_normalize_date (ECalendarItem *calitem,
- gint *year,
- gint *month)
-{
- if (*month >= 0) {
- *year += *month / 12;
- *month = *month % 12;
- } else {
- *year += *month / 12 - 1;
- *month = *month % 12;
- if (*month != 0)
- *month += 12;
- }
-}
-
-/* Adds or subtracts days from the selection. It is used when we switch months
- * and the selection extends past the end of a month but we want to keep the
- * number of days selected the same. days should not be more than 30. */
-static void
-e_calendar_item_add_days_to_selection (ECalendarItem *calitem,
- gint days)
-{
- gint year, month, days_in_month;
-
- year = calitem->year;
- month = calitem->month + calitem->selection_end_month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- calitem->selection_end_day += days;
- if (calitem->selection_end_day <= 0) {
- month--;
- e_calendar_item_normalize_date (calitem, &year, &month);
- calitem->selection_end_month_offset--;
- calitem->selection_end_day += DAYS_IN_MONTH (year, month);
- } else {
- days_in_month = DAYS_IN_MONTH (year, month);
- if (calitem->selection_end_day > days_in_month) {
- calitem->selection_end_month_offset++;
- calitem->selection_end_day -= days_in_month;
- }
- }
-}
-
-/* Gets the range of dates actually shown. Months are 0 to 11.
- * This also includes the last days of the previous month and the first days
- * of the following month, which are normally shown in gray.
- * It returns FALSE if no dates are currently shown. */
-gboolean
-e_calendar_item_get_date_range (ECalendarItem *calitem,
- gint *start_year,
- gint *start_month,
- gint *start_day,
- gint *end_year,
- gint *end_month,
- gint *end_day)
-{
- gint first_day_offset, days_in_month, days_in_prev_month;
-
- if (calitem->rows == 0 || calitem->cols == 0)
- return FALSE;
-
- /* Calculate the first day shown. This will be one of the greyed-out
- * days before the first full month begins. */
- e_calendar_item_get_month_info (
- calitem, 0, 0, &first_day_offset,
- &days_in_month, &days_in_prev_month);
- *start_year = calitem->year;
- *start_month = calitem->month - 1;
- if (*start_month == -1) {
- (*start_year)--;
- *start_month = 11;
- }
- *start_day = days_in_prev_month + 1 - first_day_offset;
-
- /* Calculate the last day shown. This will be one of the greyed-out
- * days after the last full month ends. */
- e_calendar_item_get_month_info (
- calitem, calitem->rows - 1,
- calitem->cols - 1, &first_day_offset,
- &days_in_month, &days_in_prev_month);
- *end_month = calitem->month + calitem->rows * calitem->cols;
- *end_year = calitem->year + *end_month / 12;
- *end_month %= 12;
- *end_day = E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH
- - first_day_offset - days_in_month;
-
- return TRUE;
-}
-
-/* Simple way to mark days so they appear bold.
- * A more flexible interface may be added later. */
-void
-e_calendar_item_clear_marks (ECalendarItem *calitem)
-{
- GnomeCanvasItem *item;
-
- item = GNOME_CANVAS_ITEM (calitem);
-
- g_free (calitem->styles);
- calitem->styles = NULL;
-
- gnome_canvas_request_redraw (
- item->canvas, item->x1, item->y1,
- item->x2, item->y2);
-}
-
-/* add_day_style - whether bit-or with the actual style or change the style fully */
-void
-e_calendar_item_mark_day (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- guint8 day_style,
- gboolean add_day_style)
-{
- gint month_offset;
- gint index;
-
- month_offset = (year - calitem->year) * 12 + month - calitem->month;
- if (month_offset < -1 || month_offset > calitem->rows * calitem->cols)
- return;
-
- if (!calitem->styles)
- calitem->styles = g_new0 (guint8, (calitem->rows * calitem->cols + 2) * 32);
-
- index = (month_offset + 1) * 32 + day;
- calitem->styles[index] = day_style |
- (add_day_style ? calitem->styles[index] : 0);
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-}
-
-void
-e_calendar_item_mark_days (ECalendarItem *calitem,
- gint start_year,
- gint start_month,
- gint start_day,
- gint end_year,
- gint end_month,
- gint end_day,
- guint8 day_style,
- gboolean add_day_style)
-{
- gint month_offset, end_month_offset, day;
-
- month_offset = (start_year - calitem->year) * 12 + start_month
- - calitem->month;
- day = start_day;
- if (month_offset > calitem->rows * calitem->cols)
- return;
- if (month_offset < -1) {
- month_offset = -1;
- day = 1;
- }
-
- end_month_offset = (end_year - calitem->year) * 12 + end_month
- - calitem->month;
- if (end_month_offset < -1)
- return;
- if (end_month_offset > calitem->rows * calitem->cols) {
- end_month_offset = calitem->rows * calitem->cols;
- end_day = 31;
- }
-
- if (month_offset > end_month_offset)
- return;
-
- if (!calitem->styles)
- calitem->styles = g_new0 (guint8, (calitem->rows * calitem->cols + 2) * 32);
-
- for (;;) {
- gint index;
-
- if (month_offset == end_month_offset && day > end_day)
- break;
-
- if (month_offset < -1 || month_offset > calitem->rows * calitem->cols)
- g_warning ("Bad month offset: %i\n", month_offset);
- if (day < 1 || day > 31)
- g_warning ("Bad day: %i\n", day);
-
-#if 0
- g_print ("Marking Month:%i Day:%i\n", month_offset, day);
-#endif
- index = (month_offset + 1) * 32 + day;
- calitem->styles[index] = day_style |
- (add_day_style ? calitem->styles[index] : 0);
-
- day++;
- if (day == 32) {
- month_offset++;
- day = 1;
- if (month_offset > end_month_offset)
- break;
- }
- }
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
-}
-
-/* Rounds up the given day to the end of the week. */
-static void
-e_calendar_item_round_up_selection (ECalendarItem *calitem,
- gint *month_offset,
- gint *day)
-{
- gint year, month, weekday, days, days_in_month;
- struct tm tmp_tm = { 0 };
-
- year = calitem->year;
- month = calitem->month + *month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = *day;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
-
- /* Convert to 0 (Monday) to 6 (Sunday). */
- weekday = (tmp_tm.tm_wday + 6) % 7;
-
- /* Calculate how many days to the end of the row. */
- days = (calitem->week_start_day + 6 - weekday) % 7;
-
- *day += days;
- days_in_month = DAYS_IN_MONTH (year, month);
- if (*day > days_in_month) {
- (*month_offset)++;
- *day -= days_in_month;
- }
-}
-
-/* Rounds down the given day to the start of the week. */
-static void
-e_calendar_item_round_down_selection (ECalendarItem *calitem,
- gint *month_offset,
- gint *day)
-{
- gint year, month, weekday, days, days_in_month;
- struct tm tmp_tm = { 0 };
-
- year = calitem->year;
- month = calitem->month + *month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = *day;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
-
- /* Convert to 0 (Monday) to 6 (Sunday). */
- weekday = (tmp_tm.tm_wday + 6) % 7;
-
- /* Calculate how many days to the start of the row. */
- days = (weekday + 7 - calitem->week_start_day) % 7;
-
- *day -= days;
- if (*day <= 0) {
- month--;
- if (month == -1) {
- year--;
- month = 11;
- }
- days_in_month = DAYS_IN_MONTH (year, month);
- (*month_offset)--;
- *day += days_in_month;
- }
-}
-
-static gint
-e_calendar_item_get_inclusive_days (ECalendarItem *calitem,
- gint start_month_offset,
- gint start_day,
- gint end_month_offset,
- gint end_day)
-{
- gint start_year, start_month, end_year, end_month, days = 0;
-
- start_year = calitem->year;
- start_month = calitem->month + start_month_offset;
- e_calendar_item_normalize_date (calitem, &start_year, &start_month);
-
- end_year = calitem->year;
- end_month = calitem->month + end_month_offset;
- e_calendar_item_normalize_date (calitem, &end_year, &end_month);
-
- while (start_year < end_year || start_month < end_month) {
- days += DAYS_IN_MONTH (start_year, start_month);
- start_month++;
- if (start_month == 12) {
- start_year++;
- start_month = 0;
- }
- }
-
- days += end_day - start_day + 1;
-
- return days;
-}
-
-/* If the day is off the end of the month it is set to the last day of the
- * month. */
-static void
-e_calendar_item_ensure_valid_day (ECalendarItem *calitem,
- gint *month_offset,
- gint *day)
-{
- gint year, month, days_in_month;
-
- year = calitem->year;
- month = calitem->month + *month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
-
- days_in_month = DAYS_IN_MONTH (year, month);
- if (*day > days_in_month)
- *day = days_in_month;
-}
-
-gboolean
-e_calendar_item_get_selection (ECalendarItem *calitem,
- GDate *start_date,
- GDate *end_date)
-{
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
-
- g_date_clear (start_date, 1);
- g_date_clear (end_date, 1);
-
- if (!calitem->selection_set)
- return FALSE;
-
- start_year = calitem->year;
- start_month = calitem->month + calitem->selection_start_month_offset;
- e_calendar_item_normalize_date (calitem, &start_year, &start_month);
- start_day = calitem->selection_start_day;
-
- end_year = calitem->year;
- end_month = calitem->month + calitem->selection_end_month_offset;
- e_calendar_item_normalize_date (calitem, &end_year, &end_month);
- end_day = calitem->selection_end_day;
-
- g_date_set_dmy (start_date, start_day, start_month + 1, start_year);
- g_date_set_dmy (end_date, end_day, end_month + 1, end_year);
-
- return TRUE;
-}
-
-static void
-e_calendar_item_set_selection_if_emission (ECalendarItem *calitem,
- const GDate *start_date,
- const GDate *end_date,
- gboolean emission)
-{
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- gint new_start_month_offset, new_start_day;
- gint new_end_month_offset, new_end_day;
- gboolean need_update;
-
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
-
- /* If start_date is NULL, we clear the selection without changing the
- * month shown. */
- if (start_date == NULL) {
- calitem->selection_set = FALSE;
- calitem->selection_changed = TRUE;
- e_calendar_item_queue_signal_emission (calitem);
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
- return;
- }
-
- if (end_date == NULL)
- end_date = start_date;
-
- g_return_if_fail (g_date_compare (start_date, end_date) <= 0);
-
- start_year = g_date_get_year (start_date);
- start_month = g_date_get_month (start_date) - 1;
- start_day = g_date_get_day (start_date);
- end_year = g_date_get_year (end_date);
- end_month = g_date_get_month (end_date) - 1;
- end_day = g_date_get_day (end_date);
-
- need_update = e_calendar_item_ensure_days_visible (
- calitem,
- start_year,
- start_month,
- start_day,
- end_year,
- end_month,
- end_day,
- emission);
-
- new_start_month_offset = (start_year - calitem->year) * 12
- + start_month - calitem->month;
- new_start_day = start_day;
-
- /* This may go outside the visible months, but we don't care. */
- new_end_month_offset = (end_year - calitem->year) * 12
- + end_month - calitem->month;
- new_end_day = end_day;
-
- if (!calitem->selection_set
- || calitem->selection_start_month_offset != new_start_month_offset
- || calitem->selection_start_day != new_start_day
- || calitem->selection_end_month_offset != new_end_month_offset
- || calitem->selection_end_day != new_end_day) {
- need_update = TRUE;
- if (emission) {
- calitem->selection_changed = TRUE;
- e_calendar_item_queue_signal_emission (calitem);
- }
- calitem->selection_set = TRUE;
- calitem->selection_start_month_offset = new_start_month_offset;
- calitem->selection_start_day = new_start_day;
- calitem->selection_end_month_offset = new_end_month_offset;
- calitem->selection_end_day = new_end_day;
-
- calitem->selection_real_start_month_offset = new_start_month_offset;
- calitem->selection_real_start_day = new_start_day;
- calitem->selection_from_full_week = FALSE;
- }
-
- if (need_update) {
- g_signal_emit (
- calitem,
- e_calendar_item_signals[DATE_RANGE_CHANGED], 0);
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem));
- }
-}
-
-void
-e_calendar_item_style_set (GtkWidget *widget,
- ECalendarItem *calitem)
-{
- GtkStyle *style;
- GdkColor *color;
-
- style = gtk_widget_get_style (widget);
-
- color = &style->bg[GTK_STATE_SELECTED];
- calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX] = *color;
-
- color = &style->base[GTK_STATE_NORMAL];
- calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG] = *color;
-
- color = &style->bg[GTK_STATE_SELECTED];
- calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED] = *color;
-
- color = &style->fg[GTK_STATE_INSENSITIVE];
- calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG] = *color;
-
- color = &style->fg[GTK_STATE_INSENSITIVE];
- calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG] = *color;
-
- e_calendar_item_recalc_sizes (calitem);
-}
-
-void
-e_calendar_item_set_selection (ECalendarItem *calitem,
- const GDate *start_date,
- const GDate *end_date)
-{
- /* If the user is in the middle of a selection, we must abort it. */
- if (calitem->selecting) {
- gnome_canvas_item_ungrab (
- GNOME_CANVAS_ITEM (calitem),
- GDK_CURRENT_TIME);
- calitem->selecting = FALSE;
- }
-
- e_calendar_item_set_selection_if_emission (calitem,
- start_date, end_date,
- TRUE);
-}
-
-/* This tries to ensure that the given time range is visible. If the range
- * given is longer than we can show, only the start of it will be visible.
- * Note that this will not update the selection. That should be done somewhere
- * else. It returns TRUE if the visible range has been changed. */
-static gboolean
-e_calendar_item_ensure_days_visible (ECalendarItem *calitem,
- gint start_year,
- gint start_month,
- gint start_day,
- gint end_year,
- gint end_month,
- gint end_day,
- gboolean emission)
-{
- gint current_end_year, current_end_month;
- gint months_shown;
- gint first_day_offset, days_in_month, days_in_prev_month;
- gboolean need_update = FALSE;
-
- months_shown = calitem->rows * calitem->cols;
-
- /* Calculate the range of months currently displayed. */
- current_end_year = calitem->year;
- current_end_month = calitem->month + months_shown - 1;
- e_calendar_item_normalize_date (
- calitem, &current_end_year,
- &current_end_month);
-
- /* Try to ensure that the end month is shown. */
- if ((end_year == current_end_year + 1 &&
- current_end_month == 11 && end_month == 0) ||
- (end_year == current_end_year && end_month == current_end_month + 1)) {
- /* See if the end of the selection will fit in the
- * leftover days of the month after the last one shown. */
- calitem->month += (months_shown - 1);
- e_calendar_item_normalize_date (
- calitem, &calitem->year,
- &calitem->month);
-
- e_calendar_item_get_month_info (
- calitem, 0, 0,
- &first_day_offset,
- &days_in_month,
- &days_in_prev_month);
-
- if (end_day >= E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH -
- first_day_offset - days_in_month) {
- need_update = TRUE;
-
- calitem->year = end_year;
- calitem->month = end_month - months_shown + 1;
- } else {
- calitem->month -= (months_shown - 1);
- }
-
- e_calendar_item_normalize_date (
- calitem, &calitem->year,
- &calitem->month);
- }
- else if (end_year > current_end_year ||
- (end_year == current_end_year && end_month > current_end_month)) {
- /* The selection will definitely not fit in the leftover days
- * of the month after the last one shown. */
- need_update = TRUE;
-
- calitem->year = end_year;
- calitem->month = end_month - months_shown + 1;
-
- e_calendar_item_normalize_date (
- calitem, &calitem->year,
- &calitem->month);
- }
-
- /* Now try to ensure that the start month is shown. We do this after
- * the end month so that the start month will always be shown. */
- if (start_year < calitem->year
- || (start_year == calitem->year
- && start_month < calitem->month)) {
- need_update = TRUE;
-
- /* First we see if the start of the selection will fit in the
- * leftover days of the month before the first one shown. */
- calitem->year = start_year;
- calitem->month = start_month + 1;
- e_calendar_item_normalize_date (
- calitem, &calitem->year,
- &calitem->month);
-
- e_calendar_item_get_month_info (
- calitem, 0, 0,
- &first_day_offset,
- &days_in_month,
- &days_in_prev_month);
-
- if (start_day <= days_in_prev_month - first_day_offset) {
- calitem->year = start_year;
- calitem->month = start_month;
- }
- }
-
- if (need_update && emission)
- e_calendar_item_date_range_changed (calitem);
-
- return need_update;
-}
-
-static gboolean
-destroy_menu_idle_cb (gpointer menu)
-{
- gtk_widget_destroy (menu);
-
- return FALSE;
-}
-
-static void
-deactivate_menu_cb (GtkWidget *menu)
-{
- g_signal_handlers_disconnect_by_func (menu, deactivate_menu_cb, NULL);
-
- g_idle_add (destroy_menu_idle_cb, menu);
-}
-
-static void
-e_calendar_item_show_popup_menu (ECalendarItem *calitem,
- GdkEvent *button_event,
- gint month_offset)
-{
- GtkWidget *menu, *submenu, *menuitem, *label;
- gint year, month;
- const gchar *name;
- gchar buffer[64];
- guint event_button = 0;
- guint32 event_time;
-
- menu = gtk_menu_new ();
-
- for (year = calitem->year - 2; year <= calitem->year + 2; year++) {
- g_snprintf (buffer, 64, "%i", year);
- menuitem = gtk_menu_item_new_with_label (buffer);
- gtk_widget_show (menuitem);
- gtk_container_add (GTK_CONTAINER (menu), menuitem);
-
- submenu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-
- g_object_set_data (
- G_OBJECT (submenu), "year",
- GINT_TO_POINTER (year));
- g_object_set_data (
- G_OBJECT (submenu), "month_offset",
- GINT_TO_POINTER (month_offset));
-
- for (month = 0; month < 12; month++) {
- name = e_get_month_name (month + 1, FALSE);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_show (menuitem);
- gtk_container_add (GTK_CONTAINER (submenu), menuitem);
-
- label = gtk_label_new (name);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (menuitem), label);
-
- g_object_set_data (
- G_OBJECT (menuitem), "month",
- GINT_TO_POINTER (month));
-
- g_signal_connect (
- menuitem, "activate",
- G_CALLBACK (e_calendar_item_on_menu_item_activate),
- calitem);
- }
- }
-
- g_signal_connect (
- menu, "deactivate",
- G_CALLBACK (deactivate_menu_cb), NULL);
-
- gdk_event_get_button (button_event, &event_button);
- event_time = gdk_event_get_time (button_event);
-
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL,
- e_calendar_item_position_menu, calitem,
- event_button, event_time);
-}
-
-static void
-e_calendar_item_on_menu_item_activate (GtkWidget *menuitem,
- ECalendarItem *calitem)
-{
- GtkWidget *parent;
- gint year, month_offset, month;
- gpointer data;
-
- parent = gtk_widget_get_parent (menuitem);
- data = g_object_get_data (G_OBJECT (parent), "year");
- year = GPOINTER_TO_INT (data);
-
- parent = gtk_widget_get_parent (menuitem);
- data = g_object_get_data (G_OBJECT (parent), "month_offset");
- month_offset = GPOINTER_TO_INT (data);
-
- data = g_object_get_data (G_OBJECT (menuitem), "month");
- month = GPOINTER_TO_INT (data);
-
- month -= month_offset;
- e_calendar_item_normalize_date (calitem, &year, &month);
- e_calendar_item_set_first_month (calitem, year, month);
-}
-
-static void
-e_calendar_item_position_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkRequisition requisition;
- gint screen_width, screen_height;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
-
- *x -= (gtk_widget_get_direction(GTK_WIDGET(menu)) == GTK_TEXT_DIR_RTL)
- ? requisition.width - 2
- : 2;
- *y -= requisition.height / 2;
-
- screen_width = gdk_screen_width ();
- screen_height = gdk_screen_height ();
-
- *x = CLAMP (*x, 0, screen_width - requisition.width);
- *y = CLAMP (*y, 0, screen_height - requisition.height);
-}
-
-/* Sets the function to call to get the colors to use for a particular day. */
-void
-e_calendar_item_set_style_callback (ECalendarItem *calitem,
- ECalendarItemStyleCallback cb,
- gpointer data,
- GDestroyNotify destroy)
-{
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
-
- if (calitem->style_callback_data && calitem->style_callback_destroy)
- (*calitem->style_callback_destroy) (calitem->style_callback_data);
-
- calitem->style_callback = cb;
- calitem->style_callback_data = data;
- calitem->style_callback_destroy = destroy;
-}
-
-static void
-e_calendar_item_date_range_changed (ECalendarItem *calitem)
-{
- g_free (calitem->styles);
- calitem->styles = NULL;
- calitem->date_range_changed = TRUE;
- e_calendar_item_queue_signal_emission (calitem);
-}
-
-static void
-e_calendar_item_queue_signal_emission (ECalendarItem *calitem)
-{
- if (calitem->signal_emission_idle_id == 0) {
- calitem->signal_emission_idle_id = g_idle_add_full (
- G_PRIORITY_HIGH, (GSourceFunc)
- e_calendar_item_signal_emission_idle_cb,
- calitem, NULL);
- }
-}
-
-static gboolean
-e_calendar_item_signal_emission_idle_cb (gpointer data)
-{
- ECalendarItem *calitem;
-
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (data), FALSE);
-
- calitem = E_CALENDAR_ITEM (data);
-
- calitem->signal_emission_idle_id = 0;
-
- /* We ref the calitem & check in case it gets destroyed, since we
- * were getting a free memory write here. */
- g_object_ref ((calitem));
-
- if (calitem->date_range_changed) {
- calitem->date_range_changed = FALSE;
- g_signal_emit (calitem, e_calendar_item_signals[DATE_RANGE_CHANGED], 0);
- }
-
- if (calitem->selection_changed) {
- calitem->selection_changed = FALSE;
- g_signal_emit (calitem, e_calendar_item_signals[SELECTION_CHANGED], 0);
- }
-
- g_object_unref ((calitem));
-
- return FALSE;
-}
-
-/* Sets a callback to use to get the current time. This is useful if the
- * application needs to use its own timezone data rather than rely on the
- * Unix timezone. */
-void
-e_calendar_item_set_get_time_callback (ECalendarItem *calitem,
- ECalendarItemGetTimeCallback cb,
- gpointer data,
- GDestroyNotify destroy)
-{
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
-
- if (calitem->time_callback_data && calitem->time_callback_destroy)
- (*calitem->time_callback_destroy) (calitem->time_callback_data);
-
- calitem->time_callback = cb;
- calitem->time_callback_data = data;
- calitem->time_callback_destroy = destroy;
-}
diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h
deleted file mode 100644
index d8fc5f7277..0000000000
--- a/widgets/misc/e-calendar-item.h
+++ /dev/null
@@ -1,390 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#ifndef _E_CALENDAR_ITEM_H_
-#define _E_CALENDAR_ITEM_H_
-
-#include <libgnomecanvas/gnome-canvas.h>
-
-G_BEGIN_DECLS
-
-/*
- * ECalendarItem - canvas item displaying a calendar.
- */
-
-#define E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME 1
-#define E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME 1
-
-/* The number of rows & columns of days in each month. */
-#define E_CALENDAR_ROWS_PER_MONTH 6
-#define E_CALENDAR_COLS_PER_MONTH 7
-
-/* Used to mark days as bold in e_calendar_item_mark_day(). */
-#define E_CALENDAR_ITEM_MARK_BOLD (1 << 0)
-#define E_CALENDAR_ITEM_MARK_ITALIC (1 << 1)
-
-/*
- * These are the padding sizes between various pieces of the calendar.
- */
-
-/* The minimum padding around the numbers in each cell/day. */
-#define E_CALENDAR_ITEM_MIN_CELL_XPAD 4
-#define E_CALENDAR_ITEM_MIN_CELL_YPAD 0
-
-/* Vertical padding. */
-#define E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS 1
-#define E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS 0
-#define E_CALENDAR_ITEM_YPAD_ABOVE_CELLS 1
-#define E_CALENDAR_ITEM_YPAD_BELOW_CELLS 2
-
-/* Horizontal padding in the heading bars. */
-#define E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON 10
-#define E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME 3
-#define E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME 3
-#define E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME_WITH_BUTTON 10
-
-/* Horizontal padding in the month displays. */
-#define E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS 4
-#define E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS 2
-#define E_CALENDAR_ITEM_XPAD_BEFORE_CELLS 1
-#define E_CALENDAR_ITEM_XPAD_AFTER_CELLS 4
-
-/* These index our colors array. */
-typedef enum
-{
- E_CALENDAR_ITEM_COLOR_TODAY_BOX,
- E_CALENDAR_ITEM_COLOR_SELECTION_FG,
- E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED,
- E_CALENDAR_ITEM_COLOR_SELECTION_BG,
- E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG,
-
- E_CALENDAR_ITEM_COLOR_LAST
-} ECalendarItemColors;
-
-typedef struct _ECalendarItem ECalendarItem;
-typedef struct _ECalendarItemClass ECalendarItemClass;
-
-/* The type of the callback function optionally used to get the colors to
- * use for each day. */
-typedef void (*ECalendarItemStyleCallback) (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- gint day_style,
- gboolean today,
- gboolean prev_or_next_month,
- gboolean selected,
- gboolean has_focus,
- gboolean drop_target,
- GdkColor **bg_color,
- GdkColor **fg_color,
- GdkColor **box_color,
- gboolean *bold,
- gboolean *italic,
- gpointer data);
-
-/* The type of the callback function optionally used to get the current time.
- */
-typedef struct tm (*ECalendarItemGetTimeCallback) (ECalendarItem *calitem,
- gpointer data);
-
-/* Standard GObject macros */
-#define E_TYPE_CALENDAR_ITEM \
- (e_calendar_item_get_type ())
-#define E_CALENDAR_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CALENDAR_ITEM, ECalendarItem))
-#define E_CALENDAR_ITEM_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CALENDAR_ITEM, ECalendarItemClass))
-#define E_IS_CALENDAR_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CALENDAR_ITEM))
-#define E_IS_CALENDAR_ITEM_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CALENDAR_ITEM))
-#define E_CALENDAR_ITEM_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CALENDAR_ITEM, ECalendarItemClass))
-
-struct _ECalendarItem
-{
- GnomeCanvasItem canvas_item;
-
- /* The year & month of the first calendar being displayed. */
- gint year;
- gint month; /* 0 to 11 */
-
- /* Points to an array of styles, one gchar for each day. We use 32
- * chars for each month, with n + 2 months, where n is the number of
- * complete months shown (since we show some days before the first
- * month and after the last month grayes out).
- * A value of 0 is the default, and 1 is bold. */
- guint8 *styles;
-
- /*
- * Options.
- */
-
- /* The minimum & maximum number of rows & columns of months.
- * If the maximum values are -1 then there is no maximum.
- * The minimum valies default to 1. The maximum values to -1. */
- gint min_rows;
- gint min_cols;
- gint max_rows;
- gint max_cols;
-
- /* The actual number of rows & columns of months. */
- gint rows;
- gint cols;
-
- /* Whether we show week nubers. */
- gboolean show_week_numbers;
- /* whether to keep same week days selected on week number click */
- gboolean keep_wdays_on_weeknum_click;
-
- /* The first day of the week, 0 (Monday) to 6 (Sunday). */
- gint week_start_day;
-
- /* Whether the cells expand to fill extra space. */
- gboolean expand;
-
- /* The maximum number of days that can be selected. Defaults to 1. */
- gint max_days_selected;
-
- /* The number of days selected before we switch to selecting whole
- * weeks, or -1 if we never switch. Defaults to -1. */
- gint days_to_start_week_selection;
-
- /* Whether the selection is moved when we move back/forward one month.
- * Used for things like the EDateEdit which only want the selection to
- * be changed when the user explicitly selects a day. */
- gboolean move_selection_when_moving;
-
- /* Whether the selection day is preserved when we move back/forward
- * one month. Used for the work week and week view. */
- gboolean preserve_day_when_moving;
-
- /* Whether to display the pop-up, TRUE by default */
- gboolean display_popup;
-
- /*
- * Internal stuff.
- */
-
- /* Bounds of item. */
- gdouble x1, y1, x2, y2;
-
- /* The minimum size of each month, based on the fonts used. */
- gint min_month_width;
- gint min_month_height;
-
- /* The actual size of each month, after dividing extra space. */
- gint month_width;
- gint month_height;
-
- /* The offset to the left edge of the first calendar. */
- gint x_offset;
-
- /* The padding around each calendar month. */
- gint month_lpad, month_rpad;
- gint month_tpad, month_bpad;
-
- /* The size of each cell. */
- gint cell_width;
- gint cell_height;
-
- /* The current selection. The month offsets are from 0, which is the
- * top-left calendar month view. Note that -1 is used for the last days
- * from the previous month. The days are real month days. */
- gboolean selecting;
- GDate *selecting_axis;
- gboolean selection_dragging_end;
- gboolean selection_from_full_week;
- gboolean selection_set;
- gint selection_start_month_offset;
- gint selection_start_day;
- gint selection_end_month_offset;
- gint selection_end_day;
- gint selection_real_start_month_offset;
- gint selection_real_start_day;
-
- /* Widths of the day characters. */
- gint day_widths[7];
- gint max_day_width;
-
- /* Widths of the digits, '0' .. '9'. */
- gint digit_widths[10];
- gint max_digit_width;
-
- gint week_number_digit_widths[10];
- gint max_week_number_digit_width;
-
- gint max_month_name_width;
-
- /* Fonts for drawing text. If font isn't set it uses the font from the
- * canvas widget. If week_number_font isn't set it uses font. */
- PangoFontDescription *font_desc;
- PangoFontDescription *week_number_font_desc;
-
- ECalendarItemStyleCallback style_callback;
- gpointer style_callback_data;
- GDestroyNotify style_callback_destroy;
-
- ECalendarItemGetTimeCallback time_callback;
- gpointer time_callback_data;
- GDestroyNotify time_callback_destroy;
-
- /* Colors for drawing. */
- GdkColor colors[E_CALENDAR_ITEM_COLOR_LAST];
-
- /* Our idle handler for emitting signals. */
- gint signal_emission_idle_id;
-
- /* A flag to indicate that the selection or date range has changed.
- * When set the idle function will emit the signal and reset it to
- * FALSE. This is so we don't emit it several times when args are set
- * etc. */
- gboolean selection_changed;
- gboolean date_range_changed;
-};
-
-struct _ECalendarItemClass
-{
- GnomeCanvasItemClass parent_class;
-
- void (* date_range_changed) (ECalendarItem *calitem);
- void (* selection_changed) (ECalendarItem *calitem);
- void (* selection_preview_changed) (ECalendarItem *calitem);
-};
-
-GType e_calendar_item_get_type (void);
-
-/* FIXME: months are 0-11 throughout, but 1-12 may be better. */
-
-void e_calendar_item_get_first_month (ECalendarItem *calitem,
- gint *year,
- gint *month);
-void e_calendar_item_set_first_month (ECalendarItem *calitem,
- gint year,
- gint month);
-
-/* Get the maximum number of days selectable */
-gint e_calendar_item_get_max_days_sel (ECalendarItem *calitem);
-
-/* Set the maximum number of days selectable */
-void e_calendar_item_set_max_days_sel (ECalendarItem *calitem,
- gint days);
-
-/* Get the maximum number of days selectable */
-gint e_calendar_item_get_days_start_week_sel (ECalendarItem *calitem);
-
-/* Set the maximum number of days selectable */
-void e_calendar_item_set_days_start_week_sel (ECalendarItem *calitem,
- gint days);
-
-/* Set the maximum number of days before whole weeks are selected */
-gboolean
- e_calendar_item_get_display_popup (ECalendarItem *calitem);
-
-/* Get the maximum number of days before whole weeks are selected */
-void e_calendar_item_set_display_popup (ECalendarItem *calitem,
- gboolean display);
-
-/* Gets the range of dates actually shown. Months are 0 to 11.
- * This also includes the last days of the previous month and the first days
- * of the following month, which are normally shown in gray.
- * It returns FALSE if no dates are currently shown. */
-gboolean
- e_calendar_item_get_date_range (ECalendarItem *calitem,
- gint *start_year,
- gint *start_month,
- gint *start_day,
- gint *end_year,
- gint *end_month,
- gint *end_day);
-
-/* Returns the selected date range. It returns FALSE if no days are currently
- * selected. */
-gboolean
- e_calendar_item_get_selection (ECalendarItem *calitem,
- GDate *start_date,
- GDate *end_date);
-/* Sets the selected date range, and changes the date range shown so at least
- * the start of the selection is shown. If start_date is NULL it clears the
- * selection. */
-void e_calendar_item_set_selection (ECalendarItem *calitem,
- const GDate *start_date,
- const GDate *end_date);
-
-/* Marks a particular day. Passing E_CALENDAR_ITEM_MARK_BOLD as the day style
- * will result in the day being shown as bold by default. The style callback
- * could support more day_styles, or the style callback could determine the
- * colors itself, without needing to mark days. */
-void e_calendar_item_clear_marks (ECalendarItem *calitem);
-void e_calendar_item_mark_day (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- guint8 day_style,
- gboolean add_day_style);
-
-/* Mark a range of days. Any days outside the currently shown range are
- * ignored. */
-void e_calendar_item_mark_days (ECalendarItem *calitem,
- gint start_year,
- gint start_month,
- gint start_day,
- gint end_year,
- gint end_month,
- gint end_day,
- guint8 day_style,
- gboolean add_day_style);
-
-/* Sets the function to call to get the colors to use for a particular day. */
-void e_calendar_item_set_style_callback (ECalendarItem *calitem,
- ECalendarItemStyleCallback cb,
- gpointer data,
- GDestroyNotify destroy);
-
-/* Sets a callback to use to get the current time. This is useful if the
- * application needs to use its own timezone data rather than rely on the
- * Unix timezone. */
-void e_calendar_item_set_get_time_callback (ECalendarItem *calitem,
- ECalendarItemGetTimeCallback cb,
- gpointer data,
- GDestroyNotify destroy);
-void e_calendar_item_normalize_date (ECalendarItem *calitem,
- gint *year,
- gint *month);
-gint e_calendar_item_get_week_number (ECalendarItem *calitem,
- gint day,
- gint month,
- gint year);
-void e_calendar_item_style_set (GtkWidget *widget,
- ECalendarItem *calitem);
-
-G_END_DECLS
-
-#endif /* _E_CALENDAR_ITEM_H_ */
diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c
deleted file mode 100644
index 38336cb618..0000000000
--- a/widgets/misc/e-calendar.c
+++ /dev/null
@@ -1,848 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/*
- * ECalendar - displays a table of monthly calendars, allowing highlighting
- * and selection of one or more days. Like GtkCalendar with more features.
- * Most of the functionality is in the ECalendarItem canvas item, though
- * we also add GnomeCanvasWidget buttons to go to the previous/next month and
- * to got to the current day.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-calendar.h"
-
-#include <gtk/gtk.h>
-#include <libgnomecanvas/gnome-canvas-widget.h>
-#include <glib/gi18n.h>
-
-#define E_CALENDAR_SMALL_FONT_PTSIZE 6
-
-#define E_CALENDAR_SMALL_FONT \
- "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*"
-#define E_CALENDAR_SMALL_FONT_FALLBACK \
- "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*"
-
-/* The space between the arrow buttons and the edge of the widget. */
-#define E_CALENDAR_ARROW_BUTTON_X_PAD 2
-#define E_CALENDAR_ARROW_BUTTON_Y_PAD 0
-
-/* Vertical padding. The padding above the button includes the space for the
- * horizontal line. */
-#define E_CALENDAR_YPAD_ABOVE_LOWER_BUTTONS 4
-#define E_CALENDAR_YPAD_BELOW_LOWER_BUTTONS 3
-
-/* Horizontal padding inside & between buttons. */
-#define E_CALENDAR_IXPAD_BUTTONS 4
-#define E_CALENDAR_XPAD_BUTTONS 8
-
-/* The time between steps when the prev/next buttons is pressed, in 1/1000ths
- * of a second, and the number of timeouts we skip before we start
- * automatically moving back/forward. */
-#define E_CALENDAR_AUTO_MOVE_TIMEOUT 150
-#define E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY 2
-
-static void e_calendar_dispose (GObject *object);
-static void e_calendar_realize (GtkWidget *widget);
-static void e_calendar_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static void e_calendar_get_preferred_width (GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width);
-static void e_calendar_get_preferred_height (GtkWidget *widget,
- gint *minimal_height,
- gint *natural_height);
-static void e_calendar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_calendar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static void e_calendar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time);
-static gboolean e_calendar_button_has_focus (ECalendar *cal);
-static gboolean e_calendar_focus (GtkWidget *widget,
- GtkDirectionType direction);
-
-static void e_calendar_on_prev_pressed (ECalendar *cal);
-static void e_calendar_on_prev_released (ECalendar *cal);
-static void e_calendar_on_prev_clicked (ECalendar *cal);
-static void e_calendar_on_next_pressed (ECalendar *cal);
-static void e_calendar_on_next_released (ECalendar *cal);
-static void e_calendar_on_next_clicked (ECalendar *cal);
-static void e_calendar_on_prev_year_pressed (ECalendar *cal);
-static void e_calendar_on_prev_year_released (ECalendar *cal);
-static void e_calendar_on_prev_year_clicked (ECalendar *cal);
-static void e_calendar_on_next_year_pressed (ECalendar *cal);
-static void e_calendar_on_next_year_released (ECalendar *cal);
-static void e_calendar_on_next_year_clicked (ECalendar *cal);
-
-static void e_calendar_start_auto_move (ECalendar *cal,
- gboolean moving_forward);
-static gboolean e_calendar_auto_move_handler (gpointer data);
-static void e_calendar_start_auto_move_year (ECalendar *cal,
- gboolean moving_forward);
-static gboolean e_calendar_auto_move_year_handler (gpointer data);
-static void e_calendar_stop_auto_move (ECalendar *cal);
-
-G_DEFINE_TYPE (
- ECalendar,
- e_calendar,
- E_TYPE_CANVAS)
-
-static void
-e_calendar_class_init (ECalendarClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- object_class->dispose = e_calendar_dispose;
-
- widget_class->realize = e_calendar_realize;
- widget_class->style_set = e_calendar_style_set;
- widget_class->get_preferred_width = e_calendar_get_preferred_width;
- widget_class->get_preferred_height = e_calendar_get_preferred_height;
- widget_class->size_allocate = e_calendar_size_allocate;
- widget_class->drag_motion = e_calendar_drag_motion;
- widget_class->drag_leave = e_calendar_drag_leave;
- widget_class->focus = e_calendar_focus;
-}
-
-static void
-e_calendar_init (ECalendar *cal)
-{
- GnomeCanvasGroup *canvas_group;
- PangoFontDescription *small_font_desc;
- GtkWidget *button, *pixmap;
- AtkObject *a11y;
-
- /* Create the small font. */
-
- small_font_desc = pango_font_description_copy (
- gtk_widget_get_style (GTK_WIDGET (cal))->font_desc);
- pango_font_description_set_size (
- small_font_desc,
- E_CALENDAR_SMALL_FONT_PTSIZE * PANGO_SCALE);
-
- canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (cal)->root);
-
- cal->calitem = E_CALENDAR_ITEM (
- gnome_canvas_item_new (
- canvas_group,
- e_calendar_item_get_type (),
- "week_number_font_desc", small_font_desc,
- NULL));
-
- pango_font_description_free (small_font_desc);
-
- /* Create the arrow buttons to move to the previous/next month. */
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- g_signal_connect_swapped (
- button, "pressed",
- G_CALLBACK (e_calendar_on_prev_pressed), cal);
- g_signal_connect_swapped (
- button, "released",
- G_CALLBACK (e_calendar_on_prev_released), cal);
- g_signal_connect_swapped (
- button, "clicked",
- G_CALLBACK (e_calendar_on_prev_clicked), cal);
-
- pixmap = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- gtk_widget_show (pixmap);
- gtk_container_add (GTK_CONTAINER (button), pixmap);
-
- cal->prev_item = gnome_canvas_item_new (
- canvas_group,
- gnome_canvas_widget_get_type (),
- "widget", button,
- NULL);
- a11y = gtk_widget_get_accessible (button);
- atk_object_set_name (a11y, _("Previous month"));
-
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- g_signal_connect_swapped (
- button, "pressed",
- G_CALLBACK (e_calendar_on_next_pressed), cal);
- g_signal_connect_swapped (
- button, "released",
- G_CALLBACK (e_calendar_on_next_released), cal);
- g_signal_connect_swapped (
- button, "clicked",
- G_CALLBACK (e_calendar_on_next_clicked), cal);
-
- pixmap = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- gtk_widget_show (pixmap);
- gtk_container_add (GTK_CONTAINER (button), pixmap);
-
- cal->next_item = gnome_canvas_item_new (
- canvas_group,
- gnome_canvas_widget_get_type (),
- "widget", button,
- NULL);
- a11y = gtk_widget_get_accessible (button);
- atk_object_set_name (a11y, _("Next month"));
-
- /* Create the arrow buttons to move to the previous/next year. */
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- g_signal_connect_swapped (
- button, "pressed",
- G_CALLBACK (e_calendar_on_prev_year_pressed), cal);
- g_signal_connect_swapped (
- button, "released",
- G_CALLBACK (e_calendar_on_prev_year_released), cal);
- g_signal_connect_swapped (
- button, "clicked",
- G_CALLBACK (e_calendar_on_prev_year_clicked), cal);
-
- pixmap = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- gtk_widget_show (pixmap);
- gtk_container_add (GTK_CONTAINER (button), pixmap);
-
- cal->prev_item_year = gnome_canvas_item_new (
- canvas_group,
- gnome_canvas_widget_get_type (),
- "widget", button,
- NULL);
- a11y = gtk_widget_get_accessible (button);
- atk_object_set_name (a11y, _("Previous year"));
-
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- g_signal_connect_swapped (
- button, "pressed",
- G_CALLBACK (e_calendar_on_next_year_pressed), cal);
- g_signal_connect_swapped (
- button, "released",
- G_CALLBACK (e_calendar_on_next_year_released), cal);
- g_signal_connect_swapped (
- button, "clicked",
- G_CALLBACK (e_calendar_on_next_year_clicked), cal);
-
- pixmap = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- gtk_widget_show (pixmap);
- gtk_container_add (GTK_CONTAINER (button), pixmap);
-
- cal->next_item_year = gnome_canvas_item_new (
- canvas_group,
- gnome_canvas_widget_get_type (),
- "widget", button,
- NULL);
- a11y = gtk_widget_get_accessible (button);
- atk_object_set_name (a11y, _("Next year"));
-
- cal->min_rows = 1;
- cal->min_cols = 1;
- cal->max_rows = -1;
- cal->max_cols = -1;
-
- cal->timeout_id = 0;
-}
-
-/**
- * e_calendar_new:
- * @Returns: a new #ECalendar.
- *
- * Creates a new #ECalendar.
- **/
-GtkWidget *
-e_calendar_new (void)
-{
- GtkWidget *cal;
- AtkObject *a11y;
-
- cal = g_object_new (e_calendar_get_type (), NULL);
- a11y = gtk_widget_get_accessible (cal);
- atk_object_set_name (a11y, _("Month Calendar"));
-
- return cal;
-}
-
-static void
-e_calendar_dispose (GObject *object)
-{
- ECalendar *cal;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_CALENDAR (object));
-
- cal = E_CALENDAR (object);
-
- if (cal->timeout_id != 0) {
- g_source_remove (cal->timeout_id);
- cal->timeout_id = 0;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_calendar_parent_class)->dispose (object);
-}
-
-static void
-e_calendar_realize (GtkWidget *widget)
-{
- GtkStyle *style;
- GdkWindow *window;
-
- (*GTK_WIDGET_CLASS (e_calendar_parent_class)->realize) (widget);
-
- /* Set the background of the canvas window to the normal color,
- * or the arrow buttons are not displayed properly. */
- style = gtk_widget_get_style (widget);
- window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- gdk_window_set_background (window, &style->bg[GTK_STATE_NORMAL]);
-}
-
-static void
-e_calendar_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- ECalendar *e_calendar;
-
- e_calendar = E_CALENDAR (widget);
- if (GTK_WIDGET_CLASS (e_calendar_parent_class)->style_set)
- (*GTK_WIDGET_CLASS (e_calendar_parent_class)->style_set) (widget,
- previous_style);
-
- /* Set the background of the canvas window to the normal color,
- * or the arrow buttons are not displayed properly. */
- if (gtk_widget_get_realized (widget)) {
- GtkStyle *style;
- GdkWindow *window;
-
- style = gtk_widget_get_style (widget);
- window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- gdk_window_set_background (window, &style->bg[GTK_STATE_NORMAL]);
- }
- e_calendar_item_style_set (widget, e_calendar->calitem);
-}
-
-static void
-e_calendar_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- ECalendar *cal;
- GtkStyle *style;
- gint col_width;
-
- cal = E_CALENDAR (widget);
- style = gtk_widget_get_style (GTK_WIDGET (cal));
-
- g_object_get ((cal->calitem), "column_width", &col_width, NULL);
-
- *minimum = *natural = col_width * cal->min_cols + style->xthickness * 2;
-}
-
-static void
-e_calendar_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- ECalendar *cal;
- GtkStyle *style;
- gint row_height;
-
- cal = E_CALENDAR (widget);
- style = gtk_widget_get_style (GTK_WIDGET (cal));
-
- g_object_get ((cal->calitem), "row_height", &row_height, NULL);
-
- *minimum = *natural = row_height * cal->min_rows + style->ythickness * 2;
-}
-
-static void
-e_calendar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- ECalendar *cal;
- GtkStyle *style;
- GtkAllocation old_allocation;
- PangoFontDescription *font_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- gdouble old_x2, old_y2, new_x2, new_y2;
- gdouble xthickness, ythickness, arrow_button_size, current_x, month_width;
- gboolean is_rtl;
-
- cal = E_CALENDAR (widget);
- style = gtk_widget_get_style (widget);
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-
- (*GTK_WIDGET_CLASS (e_calendar_parent_class)->size_allocate) (widget, allocation);
-
- /* Set up Pango prerequisites */
- font_desc = gtk_widget_get_style (widget)->font_desc;
- pango_context = gtk_widget_get_pango_context (widget);
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- /* Set the scroll region to its allocated size, if changed. */
- gnome_canvas_get_scroll_region (
- GNOME_CANVAS (cal),
- NULL, NULL, &old_x2, &old_y2);
- gtk_widget_get_allocation (widget, &old_allocation);
- new_x2 = old_allocation.width - 1;
- new_y2 = old_allocation.height - 1;
- if (old_x2 != new_x2 || old_y2 != new_y2)
- gnome_canvas_set_scroll_region (
- GNOME_CANVAS (cal),
- 0, 0, new_x2, new_y2);
-
- /* Take off space for line & buttons if shown. */
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (cal->calitem),
- "x1", 0.0,
- "y1", 0.0,
- "x2", new_x2,
- "y2", new_y2,
- NULL);
-
- if (cal->calitem->month_width > 0)
- month_width = cal->calitem->month_width;
- else
- month_width = new_x2;
- month_width -= E_CALENDAR_ITEM_MIN_CELL_XPAD + E_CALENDAR_ARROW_BUTTON_X_PAD;
-
- /* Position the arrow buttons. */
- arrow_button_size =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
- + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME
- - E_CALENDAR_ARROW_BUTTON_Y_PAD * 2 - 2;
-
- is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
- current_x = is_rtl ?
- (month_width - 2 * xthickness - E_CALENDAR_ARROW_BUTTON_X_PAD - arrow_button_size) :
- (xthickness);
-
- gnome_canvas_item_set (
- cal->prev_item,
- "x", current_x,
- "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
- "width", arrow_button_size,
- "height", arrow_button_size,
- NULL);
-
- current_x += (is_rtl ? -1.0 : +1.0) * (cal->calitem->max_month_name_width - xthickness + 2 * arrow_button_size);
-
- gnome_canvas_item_set (
- cal->next_item,
- "x", current_x,
- "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
- "width", arrow_button_size,
- "height", arrow_button_size,
- NULL);
-
- current_x = is_rtl ?
- (xthickness) :
- (month_width - 2 * xthickness - E_CALENDAR_ARROW_BUTTON_X_PAD - arrow_button_size);
-
- gnome_canvas_item_set (
- cal->next_item_year,
- "x", current_x,
- "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
- "width", arrow_button_size,
- "height", arrow_button_size,
- NULL);
-
- current_x += (is_rtl ? +1.0 : -1.0) * (cal->calitem->max_digit_width * 5 - xthickness + 2 * arrow_button_size);
-
- gnome_canvas_item_set (
- cal->prev_item_year,
- "x", current_x,
- "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
- "width", arrow_button_size,
- "height", arrow_button_size,
- NULL);
-
- pango_font_metrics_unref (font_metrics);
-}
-
-void
-e_calendar_set_minimum_size (ECalendar *cal,
- gint rows,
- gint cols)
-{
- g_return_if_fail (E_IS_CALENDAR (cal));
-
- cal->min_rows = rows;
- cal->min_cols = cols;
-
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (cal->calitem),
- "minimum_rows", rows,
- "minimum_columns", cols,
- NULL);
-
- gtk_widget_queue_resize (GTK_WIDGET (cal));
-}
-
-void
-e_calendar_set_maximum_size (ECalendar *cal,
- gint rows,
- gint cols)
-{
- g_return_if_fail (E_IS_CALENDAR (cal));
-
- cal->max_rows = rows;
- cal->max_cols = cols;
-
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (cal->calitem),
- "maximum_rows", rows,
- "maximum_columns", cols,
- NULL);
-
- gtk_widget_queue_resize (GTK_WIDGET (cal));
-}
-
-/* Returns the border size on each side of the month displays. */
-void
-e_calendar_get_border_size (ECalendar *cal,
- gint *top,
- gint *bottom,
- gint *left,
- gint *right)
-{
- GtkStyle *style;
-
- g_return_if_fail (E_IS_CALENDAR (cal));
-
- style = gtk_widget_get_style (GTK_WIDGET (cal));
-
- if (style) {
- *top = style->ythickness;
- *bottom = style->ythickness;
- *left = style->xthickness;
- *right = style->xthickness;
- } else {
- *top = *bottom = *left = *right = 0;
- }
-}
-
-static void
-e_calendar_on_prev_pressed (ECalendar *cal)
-{
- e_calendar_start_auto_move (cal, FALSE);
-}
-
-static void
-e_calendar_on_next_pressed (ECalendar *cal)
-{
- e_calendar_start_auto_move (cal, TRUE);
-}
-
-static void
-e_calendar_on_prev_year_pressed (ECalendar *cal)
-{
- e_calendar_start_auto_move_year (cal, FALSE);
-}
-
-static void
-e_calendar_on_next_year_pressed (ECalendar *cal)
-{
- e_calendar_start_auto_move_year (cal, TRUE);
-}
-
-static void
-e_calendar_start_auto_move (ECalendar *cal,
- gboolean moving_forward)
-{
- if (cal->timeout_id == 0) {
- cal->timeout_id = g_timeout_add (
- E_CALENDAR_AUTO_MOVE_TIMEOUT,
- e_calendar_auto_move_handler,
- cal);
- }
- cal->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
- cal->moving_forward = moving_forward;
-
-}
-
-static void
-e_calendar_start_auto_move_year (ECalendar *cal,
- gboolean moving_forward)
-{
- if (cal->timeout_id == 0) {
- cal->timeout_id = g_timeout_add (
- E_CALENDAR_AUTO_MOVE_TIMEOUT,
- e_calendar_auto_move_year_handler,
- cal);
- }
- cal->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
- cal->moving_forward = moving_forward;
-}
-
-static gboolean
-e_calendar_auto_move_year_handler (gpointer data)
-{
- ECalendar *cal;
- ECalendarItem *calitem;
- gint offset;
-
- g_return_val_if_fail (E_IS_CALENDAR (data), FALSE);
-
- cal = E_CALENDAR (data);
- calitem = cal->calitem;
-
- if (cal->timeout_delay > 0) {
- cal->timeout_delay--;
- } else {
- offset = cal->moving_forward ? 12 : -12;
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month + offset);
- }
-
- return TRUE;
-}
-
-static gboolean
-e_calendar_auto_move_handler (gpointer data)
-{
- ECalendar *cal;
- ECalendarItem *calitem;
- gint offset;
-
- g_return_val_if_fail (E_IS_CALENDAR (data), FALSE);
-
- cal = E_CALENDAR (data);
- calitem = cal->calitem;
-
- if (cal->timeout_delay > 0) {
- cal->timeout_delay--;
- } else {
- offset = cal->moving_forward ? 1 : -1;
- e_calendar_item_set_first_month (
- calitem, calitem->year,
- calitem->month + offset);
- }
-
- return TRUE;
-}
-
-static void
-e_calendar_on_prev_released (ECalendar *cal)
-{
- e_calendar_stop_auto_move (cal);
-}
-
-static void
-e_calendar_on_next_released (ECalendar *cal)
-{
- e_calendar_stop_auto_move (cal);
-}
-
-static void
-e_calendar_on_prev_year_released (ECalendar *cal)
-{
- e_calendar_stop_auto_move (cal);
-}
-
-static void
-e_calendar_on_next_year_released (ECalendar *cal)
-{
- e_calendar_stop_auto_move (cal);
-}
-
-static void
-e_calendar_stop_auto_move (ECalendar *cal)
-{
- if (cal->timeout_id != 0) {
- g_source_remove (cal->timeout_id);
- cal->timeout_id = 0;
- }
-}
-
-static void
-e_calendar_on_prev_clicked (ECalendar *cal)
-{
- e_calendar_item_set_first_month (
- cal->calitem, cal->calitem->year,
- cal->calitem->month - 1);
-}
-
-static void
-e_calendar_on_next_clicked (ECalendar *cal)
-{
- e_calendar_item_set_first_month (
- cal->calitem, cal->calitem->year,
- cal->calitem->month + 1);
-}
-
-static void
-e_calendar_on_prev_year_clicked (ECalendar *cal)
-{
- e_calendar_item_set_first_month (
- cal->calitem, cal->calitem->year,
- cal->calitem->month - 12);
-}
-
-static void
-e_calendar_on_next_year_clicked (ECalendar *cal)
-{
- e_calendar_item_set_first_month (
- cal->calitem, cal->calitem->year,
- cal->calitem->month + 12);
-}
-
-static gint
-e_calendar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- return FALSE;
-}
-
-static void
-e_calendar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time)
-{
-}
-
-static gboolean
-e_calendar_button_has_focus (ECalendar *cal)
-{
- GtkWidget *prev_widget, *next_widget;
- gboolean ret_val;
-
- g_return_val_if_fail (E_IS_CALENDAR (cal), FALSE);
-
- prev_widget = GNOME_CANVAS_WIDGET (cal->prev_item)->widget;
- next_widget = GNOME_CANVAS_WIDGET (cal->next_item)->widget;
- ret_val = gtk_widget_has_focus (prev_widget) ||
- gtk_widget_has_focus (next_widget);
- return ret_val;
-}
-
-static gboolean
-e_calendar_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
-#define E_CALENDAR_FOCUS_CHILDREN_NUM 5
- ECalendar *cal;
- GnomeCanvas *canvas;
- GnomeCanvasItem *children[E_CALENDAR_FOCUS_CHILDREN_NUM];
- gint focused_index = -1;
- gint index;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_CALENDAR (widget), FALSE);
- cal = E_CALENDAR (widget);
- canvas = GNOME_CANVAS (widget);
-
- if (!gtk_widget_get_can_focus (widget))
- return FALSE;
-
- children[0] = GNOME_CANVAS_ITEM (cal->calitem);
- children[1] = cal->prev_item;
- children[2] = cal->next_item;
- children[3] = cal->prev_item_year;
- children[4] = cal->next_item_year;
-
- /* get current focused item, if e-calendar has had focus */
- if (gtk_widget_has_focus (widget) || e_calendar_button_has_focus (cal))
- for (index = 0; index < E_CALENDAR_FOCUS_CHILDREN_NUM; ++index) {
- if (canvas->focused_item == NULL)
- break;
-
- if (children[index] == canvas->focused_item) {
- focused_index = index;
- break;
- }
- }
-
- if (focused_index == -1)
- if (direction == GTK_DIR_TAB_FORWARD)
- focused_index = 0;
- else
- focused_index = E_CALENDAR_FOCUS_CHILDREN_NUM - 1;
- else
- if (direction == GTK_DIR_TAB_FORWARD)
- ++focused_index;
- else
- --focused_index;
-
- if (focused_index < 0 ||
- focused_index >= E_CALENDAR_FOCUS_CHILDREN_NUM)
- /* move out of e-calendar */
- return FALSE;
- gnome_canvas_item_grab_focus (children[focused_index]);
- if (GNOME_IS_CANVAS_WIDGET (children[focused_index])) {
- widget = GNOME_CANVAS_WIDGET (children[focused_index])->widget;
- gtk_widget_grab_focus (widget);
- }
- return TRUE;
-}
-
-void
-e_calendar_set_focusable (ECalendar *cal,
- gboolean focusable)
-{
- GtkWidget *widget;
- GtkWidget *prev_widget, *next_widget;
- GtkWidget *toplevel;
-
- g_return_if_fail (E_IS_CALENDAR (cal));
-
- widget = GTK_WIDGET (cal);
- prev_widget = GNOME_CANVAS_WIDGET (cal->prev_item)->widget;
- next_widget = GNOME_CANVAS_WIDGET (cal->next_item)->widget;
-
- if (focusable) {
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_widget_set_can_focus (prev_widget, TRUE);
- gtk_widget_set_can_focus (next_widget, TRUE);
- }
- else {
- if (gtk_widget_has_focus (GTK_WIDGET (cal)) ||
- e_calendar_button_has_focus (cal)) {
- toplevel = gtk_widget_get_toplevel (widget);
- if (toplevel)
- gtk_widget_grab_focus (toplevel);
- }
- gtk_widget_set_can_focus (widget, FALSE);
- gtk_widget_set_can_focus (prev_widget, FALSE);
- gtk_widget_set_can_focus (next_widget, FALSE);
- }
-}
diff --git a/widgets/misc/e-calendar.h b/widgets/misc/e-calendar.h
deleted file mode 100644
index bdf77786f2..0000000000
--- a/widgets/misc/e-calendar.h
+++ /dev/null
@@ -1,108 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CALENDAR_H_
-#define _E_CALENDAR_H_
-
-#include <gtk/gtk.h>
-#include <misc/e-canvas.h>
-#include "e-calendar-item.h"
-
-G_BEGIN_DECLS
-
-/*
- * ECalendar - displays a table of monthly calendars, allowing highlighting
- * and selection of one or more days. Like GtkCalendar with more features.
- * Most of the functionality is in the ECalendarItem canvas item, though
- * we also add GnomeCanvasWidget buttons to go to the previous/next month and
- * to got to the current day.
- */
-
-/* Standard GObject macros */
-#define E_TYPE_CALENDAR \
- (e_calendar_get_type ())
-#define E_CALENDAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CALENDAR, ECalendar))
-#define E_CALENDAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CALENDAR, ECalendarClass))
-#define E_IS_CALENDAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CALENDAR))
-#define E_IS_CALENDAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CALENDAR))
-#define E_CALENDAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CALENDAR, ECalendarClass))
-
-typedef struct _ECalendar ECalendar;
-typedef struct _ECalendarClass ECalendarClass;
-
-struct _ECalendar {
- ECanvas parent;
-
- ECalendarItem *calitem;
-
- GnomeCanvasItem *prev_item;
- GnomeCanvasItem *next_item;
- GnomeCanvasItem *prev_item_year;
- GnomeCanvasItem *next_item_year;
-
- gint min_rows;
- gint min_cols;
-
- gint max_rows;
- gint max_cols;
-
- /* These are all used when the prev/next buttons are held down.
- * moving_forward is TRUE if we are moving forward in time, i.e. the
- * next button is pressed. */
- gint timeout_id;
- gint timeout_delay;
- gboolean moving_forward;
-};
-
-struct _ECalendarClass {
- ECanvasClass parent_class;
-};
-
-GType e_calendar_get_type (void);
-GtkWidget * e_calendar_new (void);
-void e_calendar_set_minimum_size (ECalendar *cal,
- gint rows,
- gint cols);
-void e_calendar_set_maximum_size (ECalendar *cal,
- gint rows,
- gint cols);
-void e_calendar_get_border_size (ECalendar *cal,
- gint *top,
- gint *bottom,
- gint *left,
- gint *right);
-void e_calendar_set_focusable (ECalendar *cal,
- gboolean focusable);
-
-G_END_DECLS
-
-#endif /* _E_CALENDAR_H_ */
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
deleted file mode 100644
index 0b1f05a6b8..0000000000
--- a/widgets/misc/e-canvas-background.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * e-canvas-background.c - background color for canvas.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include <glib/gi18n.h>
-#include "e-util/e-util.h"
-#include "misc/e-canvas.h"
-#include "misc/e-canvas-utils.h"
-
-#include "e-canvas-background.h"
-
-#define E_CANVAS_BACKGROUND_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_CANVAS_BACKGROUND_TYPE, ECanvasBackgroundPrivate))
-
-/* workaround for avoiding API broken */
-#define ecb_get_type e_canvas_background_get_type
-G_DEFINE_TYPE (
- ECanvasBackground,
- ecb,
- GNOME_TYPE_CANVAS_ITEM)
-
-#define d(x)
-
-struct _ECanvasBackgroundPrivate {
- guint rgba; /* Fill color, RGBA */
-};
-
-enum {
- STYLE_SET,
- LAST_SIGNAL
-};
-
-static guint ecb_signals[LAST_SIGNAL] = { 0, };
-
-enum {
- PROP_0,
- PROP_FILL_COLOR,
- PROP_FILL_COLOR_GDK,
- PROP_FILL_COLOR_RGBA,
-};
-
-static void
-ecb_bounds (GnomeCanvasItem *item,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2)
-{
- *x1 = -G_MAXDOUBLE;
- *y1 = -G_MAXDOUBLE;
- *x2 = G_MAXDOUBLE;
- *y2 = G_MAXDOUBLE;
-}
-
-static void
-ecb_update (GnomeCanvasItem *item,
- const cairo_matrix_t *i2c,
- gint flags)
-{
- gdouble x1, y1, x2, y2;
-
- x1 = item->x1;
- y1 = item->y1;
- x2 = item->x2;
- y2 = item->y2;
-
- /* The bounds are all constants so we should only have to
- * redraw once. */
- ecb_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
-
- if (item->x1 != x1 || item->y1 != y1 ||
- item->x2 != x2 || item->y2 != y2)
- gnome_canvas_request_redraw (
- item->canvas, item->x1, item->y1, item->x2, item->y2);
-}
-
-static void
-ecb_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ECanvasBackground *ecb;
-
- GdkColor color = { 0, 0, 0, 0, };
- GdkColor *pcolor;
-
- ecb = E_CANVAS_BACKGROUND (object);
-
- switch (property_id) {
- case PROP_FILL_COLOR:
- if (g_value_get_string (value))
- gdk_color_parse (g_value_get_string (value), &color);
-
- ecb->priv->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- break;
-
- case PROP_FILL_COLOR_GDK:
- pcolor = g_value_get_boxed (value);
- if (pcolor) {
- color = *pcolor;
- }
-
- ecb->priv->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- break;
-
- case PROP_FILL_COLOR_RGBA:
- ecb->priv->rgba = g_value_get_uint (value);
- break;
-
- }
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (ecb));
-}
-
-static void
-ecb_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ECanvasBackground *ecb;
-
- ecb = E_CANVAS_BACKGROUND (object);
-
- switch (property_id) {
- case PROP_FILL_COLOR_RGBA:
- g_value_set_uint (value, ecb->priv->rgba);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-ecb_init (ECanvasBackground *ecb)
-{
- ecb->priv = E_CANVAS_BACKGROUND_GET_PRIVATE (ecb);
-}
-
-static void
-ecb_draw (GnomeCanvasItem *item,
- cairo_t *cr,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
-
- cairo_save (cr);
- cairo_set_source_rgba (
- cr,
- ((ecb->priv->rgba >> 24) & 0xff) / 255.0,
- ((ecb->priv->rgba >> 16) & 0xff) / 255.0,
- ((ecb->priv->rgba >> 8) & 0xff) / 255.0,
- ( ecb->priv->rgba & 0xff) / 255.0);
- cairo_paint (cr);
- cairo_restore (cr);
-}
-
-static GnomeCanvasItem *
-ecb_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy)
-{
- return item;
-}
-
-static void
-ecb_style_set (ECanvasBackground *ecb,
- GtkStyle *previous_style)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ecb);
-
- if (gtk_widget_get_realized (GTK_WIDGET (item->canvas)))
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (ecb));
-}
-
-static void
-ecb_class_init (ECanvasBackgroundClass *ecb_class)
-{
- GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (ecb_class);
- GObjectClass *object_class = G_OBJECT_CLASS (ecb_class);
-
- g_type_class_add_private (ecb_class, sizeof (ECanvasBackgroundPrivate));
-
- object_class->set_property = ecb_set_property;
- object_class->get_property = ecb_get_property;
-
- item_class->update = ecb_update;
- item_class->draw = ecb_draw;
- item_class->point = ecb_point;
- item_class->bounds = ecb_bounds;
-
- ecb_class->style_set = ecb_style_set;
-
- g_object_class_install_property (
- object_class,
- PROP_FILL_COLOR,
- g_param_spec_string (
- "fill_color",
- "Fill color",
- "Fill color",
- NULL,
- G_PARAM_WRITABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_FILL_COLOR_GDK,
- g_param_spec_boxed (
- "fill_color_gdk",
- "GDK fill color",
- "GDK fill color",
- GDK_TYPE_COLOR,
- G_PARAM_WRITABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_FILL_COLOR_RGBA,
- g_param_spec_uint (
- "fill_color_rgba",
- "GDK fill color",
- "GDK fill color",
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE));
-
- ecb_signals[STYLE_SET] = g_signal_new (
- "style_set",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECanvasBackgroundClass, style_set),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_STYLE);
-}
-
diff --git a/widgets/misc/e-canvas-background.h b/widgets/misc/e-canvas-background.h
deleted file mode 100644
index 3c07770701..0000000000
--- a/widgets/misc/e-canvas-background.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * e-canvas-background.h - background color for canvas.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_CANVAS_BACKGROUND_H
-#define E_CANVAS_BACKGROUND_H
-
-#include <libgnomecanvas/gnome-canvas.h>
-
-G_BEGIN_DECLS
-
-/*
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * fill_color string W X color specification for fill color,
- * or NULL pointer for no color (transparent)
- * fill_color_gdk GdkColor* RW Allocated GdkColor for fill
- * x1 gdouble RW Coordinates for edges of background rectangle
- * x2 gdouble RW Default is all of them = -1.
- * y1 gdouble RW Which means that the entire space is shown.
- * y2 gdouble RW If you need the rectangle to have negative coordinates, use an affine.
- */
-
-#define E_CANVAS_BACKGROUND_TYPE (e_canvas_background_get_type ())
-#define E_CANVAS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_CANVAS_BACKGROUND_TYPE, ECanvasBackground))
-#define E_CANVAS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_CANVAS_BACKGROUND_TYPE, ECanvasBackgroundClass))
-#define E_IS_CANVAS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_CANVAS_BACKGROUND_TYPE))
-#define E_IS_CANVAS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_CANVAS_BACKGROUND_TYPE))
-
-typedef struct _ECanvasBackground ECanvasBackground;
-typedef struct _ECanvasBackgroundClass ECanvasBackgroundClass;
-typedef struct _ECanvasBackgroundPrivate ECanvasBackgroundPrivate;
-
-struct _ECanvasBackground {
- GnomeCanvasItem item;
-
- ECanvasBackgroundPrivate *priv;
-};
-
-struct _ECanvasBackgroundClass {
- GnomeCanvasItemClass parent_class;
- void (*style_set) (ECanvasBackground *eti, GtkStyle *previous_style);
-};
-
-/* Standard Gtk function */
-GType e_canvas_background_get_type (void);
-
-G_END_DECLS
-
-#endif
diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c
deleted file mode 100644
index ec3aad3858..0000000000
--- a/widgets/misc/e-canvas-utils.c
+++ /dev/null
@@ -1,222 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-canvas-utils.h"
-
-void
-e_canvas_item_move_absolute (GnomeCanvasItem *item,
- gdouble dx,
- gdouble dy)
-{
- cairo_matrix_t translate;
-
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- cairo_matrix_init_translate (&translate, dx, dy);
-
- gnome_canvas_item_set_matrix (item, &translate);
-}
-
-static double
-compute_offset (gint top,
- gint bottom,
- gint page_top,
- gint page_bottom)
-{
- gint size = bottom - top;
- gint offset = 0;
-
- if (top <= page_top && bottom >= page_bottom)
- return 0;
-
- if (bottom > page_bottom)
- offset = (bottom - page_bottom);
- if (top < page_top + offset)
- offset = (top - page_top);
-
- if (top <= page_top + offset && bottom >= page_bottom + offset)
- return offset;
-
- if (top < page_top + size * 3 / 2 + offset)
- offset = top - (page_top + size * 3 / 2);
- if (bottom > page_bottom - size * 3 / 2 + offset)
- offset = bottom - (page_bottom - size * 3 / 2);
- if (top < page_top + size * 3 / 2 + offset)
- offset = top - ((page_top + page_bottom - (bottom - top)) / 2);
-
- return offset;
-}
-
-static void
-e_canvas_show_area (GnomeCanvas *canvas,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2)
-{
- GtkAdjustment *h, *v;
- gint dx = 0, dy = 0;
- gdouble page_size;
- gdouble lower;
- gdouble upper;
- gdouble value;
-
- g_return_if_fail (canvas != NULL);
- g_return_if_fail (GNOME_IS_CANVAS (canvas));
-
- h = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
- page_size = gtk_adjustment_get_page_size (h);
- lower = gtk_adjustment_get_lower (h);
- upper = gtk_adjustment_get_upper (h);
- value = gtk_adjustment_get_value (h);
- dx = compute_offset (x1, x2, value, value + page_size);
- if (dx)
- gtk_adjustment_set_value (h, CLAMP (value + dx, lower, upper - page_size));
-
- v = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
- page_size = gtk_adjustment_get_page_size (v);
- lower = gtk_adjustment_get_lower (v);
- upper = gtk_adjustment_get_upper (v);
- value = gtk_adjustment_get_value (v);
- dy = compute_offset (y1, y2, value, value + page_size);
- if (dy)
- gtk_adjustment_set_value (v, CLAMP (value + dy, lower, upper - page_size));
-}
-
-void
-e_canvas_item_show_area (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2)
-{
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- gnome_canvas_item_i2w (item, &x1, &y1);
- gnome_canvas_item_i2w (item, &x2, &y2);
-
- e_canvas_show_area (item->canvas, x1, y1, x2, y2);
-}
-
-static gboolean
-e_canvas_area_shown (GnomeCanvas *canvas,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2)
-{
- GtkAdjustment *h, *v;
- gint dx = 0, dy = 0;
- gdouble page_size;
- gdouble lower;
- gdouble upper;
- gdouble value;
-
- g_return_val_if_fail (canvas != NULL, FALSE);
- g_return_val_if_fail (GNOME_IS_CANVAS (canvas), FALSE);
-
- h = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
- page_size = gtk_adjustment_get_page_size (h);
- lower = gtk_adjustment_get_lower (h);
- upper = gtk_adjustment_get_upper (h);
- value = gtk_adjustment_get_value (h);
- dx = compute_offset (x1, x2, value, value + page_size);
- if (CLAMP (value + dx, lower, upper - page_size) - value != 0)
- return FALSE;
-
- v = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
- page_size = gtk_adjustment_get_page_size (v);
- lower = gtk_adjustment_get_lower (v);
- upper = gtk_adjustment_get_upper (v);
- value = gtk_adjustment_get_value (v);
- dy = compute_offset (y1, y2, value, value + page_size);
- if (CLAMP (value + dy, lower, upper - page_size) - value != 0)
- return FALSE;
- return TRUE;
-}
-
-gboolean
-e_canvas_item_area_shown (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2)
-{
- g_return_val_if_fail (item != NULL, FALSE);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), FALSE);
-
- gnome_canvas_item_i2w (item, &x1, &y1);
- gnome_canvas_item_i2w (item, &x2, &y2);
-
- return e_canvas_area_shown (item->canvas, x1, y1, x2, y2);
-}
-
-typedef struct {
- gdouble x1;
- gdouble y1;
- gdouble x2;
- gdouble y2;
- GnomeCanvas *canvas;
-} DoubsAndCanvas;
-
-static gboolean
-show_area_timeout (gpointer data)
-{
- DoubsAndCanvas *dac = data;
-
- e_canvas_show_area (dac->canvas, dac->x1, dac->y1, dac->x2, dac->y2);
- g_object_unref (dac->canvas);
- g_free (dac);
- return FALSE;
-}
-
-void
-e_canvas_item_show_area_delayed (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2,
- gint delay)
-{
- DoubsAndCanvas *dac;
-
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- gnome_canvas_item_i2w (item, &x1, &y1);
- gnome_canvas_item_i2w (item, &x2, &y2);
-
- dac = g_new (DoubsAndCanvas, 1);
- dac->x1 = x1;
- dac->y1 = y1;
- dac->x2 = x2;
- dac->y2 = y2;
- dac->canvas = item->canvas;
- g_object_ref (item->canvas);
- g_timeout_add (delay, show_area_timeout, dac);
-}
diff --git a/widgets/misc/e-canvas-utils.h b/widgets/misc/e-canvas-utils.h
deleted file mode 100644
index 0843ba8f17..0000000000
--- a/widgets/misc/e-canvas-utils.h
+++ /dev/null
@@ -1,55 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_CANVAS_UTILS__
-#define __E_CANVAS_UTILS__
-
-#include <libgnomecanvas/gnome-canvas.h>
-
-G_BEGIN_DECLS
-
-void e_canvas_item_move_absolute (GnomeCanvasItem *item,
- gdouble dx,
- gdouble dy);
-void e_canvas_item_show_area (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2);
-void e_canvas_item_show_area_delayed (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2,
- gint delay);
-/* Returns TRUE if the area is already shown on the screen (including
- * spacing.) This is equivelent to returning FALSE iff show_area
- * would do anything. */
-gboolean e_canvas_item_area_shown (GnomeCanvasItem *item,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2);
-
-G_END_DECLS
-
-#endif /* __E_CANVAS_UTILS__ */
diff --git a/widgets/misc/e-canvas-vbox.c b/widgets/misc/e-canvas-vbox.c
deleted file mode 100644
index 1767c1ac14..0000000000
--- a/widgets/misc/e-canvas-vbox.c
+++ /dev/null
@@ -1,411 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include <glib/gi18n.h>
-#include "e-util/e-util.h"
-
-#include "e-canvas.h"
-#include "e-canvas-utils.h"
-#include "e-canvas-vbox.h"
-
-static void e_canvas_vbox_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static void e_canvas_vbox_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static void e_canvas_vbox_dispose (GObject *object);
-
-static gint e_canvas_vbox_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_canvas_vbox_realize (GnomeCanvasItem *item);
-
-static void e_canvas_vbox_reflow (GnomeCanvasItem *item, gint flags);
-
-static void e_canvas_vbox_real_add_item (ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item);
-static void e_canvas_vbox_real_add_item_start (ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item);
-static void e_canvas_vbox_resize_children (GnomeCanvasItem *item);
-
-enum {
- PROP_0,
- PROP_WIDTH,
- PROP_MINIMUM_WIDTH,
- PROP_HEIGHT,
- PROP_SPACING
-};
-
-G_DEFINE_TYPE (
- ECanvasVbox,
- e_canvas_vbox,
- GNOME_TYPE_CANVAS_GROUP)
-
-static void
-e_canvas_vbox_class_init (ECanvasVboxClass *class)
-{
- GObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
-
- class->add_item = e_canvas_vbox_real_add_item;
- class->add_item_start = e_canvas_vbox_real_add_item_start;
-
- object_class->set_property = e_canvas_vbox_set_property;
- object_class->get_property = e_canvas_vbox_get_property;
- object_class->dispose = e_canvas_vbox_dispose;
-
- /* GnomeCanvasItem method overrides */
- item_class->event = e_canvas_vbox_event;
- item_class->realize = e_canvas_vbox_realize;
-
- g_object_class_install_property (
- object_class,
- PROP_WIDTH,
- g_param_spec_double (
- "width",
- "Width",
- "Width",
- 0.0, G_MAXDOUBLE, 0.0,
- G_PARAM_READWRITE));
- g_object_class_install_property (
- object_class,
- PROP_MINIMUM_WIDTH,
- g_param_spec_double (
- "minimum_width",
- "Minimum width",
- "Minimum Width",
- 0.0, G_MAXDOUBLE, 0.0,
- G_PARAM_READWRITE));
- g_object_class_install_property (
- object_class,
- PROP_HEIGHT,
- g_param_spec_double (
- "height",
- "Height",
- "Height",
- 0.0, G_MAXDOUBLE, 0.0,
- G_PARAM_READABLE));
- g_object_class_install_property (
- object_class,
- PROP_SPACING,
- g_param_spec_double (
- "spacing",
- "Spacing",
- "Spacing",
- 0.0, G_MAXDOUBLE, 0.0,
- G_PARAM_READWRITE));
-}
-
-static void
-e_canvas_vbox_init (ECanvasVbox *vbox)
-{
- vbox->items = NULL;
-
- vbox->width = 10;
- vbox->minimum_width = 10;
- vbox->height = 10;
- vbox->spacing = 0;
-
- e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM (vbox), e_canvas_vbox_reflow);
-}
-
-static void
-e_canvas_vbox_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GnomeCanvasItem *item;
- ECanvasVbox *e_canvas_vbox;
-
- item = GNOME_CANVAS_ITEM (object);
- e_canvas_vbox = E_CANVAS_VBOX (object);
-
- switch (property_id) {
- case PROP_WIDTH:
- case PROP_MINIMUM_WIDTH:
- e_canvas_vbox->minimum_width = g_value_get_double (value);
- e_canvas_vbox_resize_children (item);
- e_canvas_item_request_reflow (item);
- break;
- case PROP_SPACING:
- e_canvas_vbox->spacing = g_value_get_double (value);
- e_canvas_item_request_reflow (item);
- break;
- }
-}
-
-static void
-e_canvas_vbox_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ECanvasVbox *e_canvas_vbox;
-
- e_canvas_vbox = E_CANVAS_VBOX (object);
-
- switch (property_id) {
- case PROP_WIDTH:
- g_value_set_double (value, e_canvas_vbox->width);
- break;
- case PROP_MINIMUM_WIDTH:
- g_value_set_double (value, e_canvas_vbox->minimum_width);
- break;
- case PROP_HEIGHT:
- g_value_set_double (value, e_canvas_vbox->height);
- break;
- case PROP_SPACING:
- g_value_set_double (value, e_canvas_vbox->spacing);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* Used from g_list_foreach(); disconnects from an item's signals */
-static void
-disconnect_item_cb (gpointer data,
- gpointer user_data)
-{
- ECanvasVbox *vbox;
- GnomeCanvasItem *item;
-
- vbox = E_CANVAS_VBOX (user_data);
-
- item = GNOME_CANVAS_ITEM (data);
- g_signal_handlers_disconnect_matched (
- item,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL,
- vbox);
-}
-
-static void
-e_canvas_vbox_dispose (GObject *object)
-{
- ECanvasVbox *vbox = E_CANVAS_VBOX (object);
-
- if (vbox->items) {
- g_list_foreach (vbox->items, disconnect_item_cb, vbox);
- g_list_free (vbox->items);
- vbox->items = NULL;
- }
-
- G_OBJECT_CLASS (e_canvas_vbox_parent_class)->dispose (object);
-}
-
-static gint
-e_canvas_vbox_event (GnomeCanvasItem *item,
- GdkEvent *event)
-{
- gint return_val = TRUE;
-
- switch (event->type) {
- case GDK_KEY_PRESS:
- switch (event->key.keyval) {
- case GDK_KEY_Left:
- case GDK_KEY_KP_Left:
- case GDK_KEY_Right:
- case GDK_KEY_KP_Right:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Down:
- case GDK_KEY_Up:
- case GDK_KEY_KP_Up:
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- return_val = TRUE;
- break;
- default:
- return_val = FALSE;
- break;
- }
- break;
- default:
- return_val = FALSE;
- break;
- }
- if (!return_val) {
- if (GNOME_CANVAS_ITEM_CLASS (e_canvas_vbox_parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS (e_canvas_vbox_parent_class)->event (item, event);
- }
- return return_val;
-
-}
-
-static void
-e_canvas_vbox_realize (GnomeCanvasItem *item)
-{
- if (GNOME_CANVAS_ITEM_CLASS (e_canvas_vbox_parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS (e_canvas_vbox_parent_class)->realize) (item);
-
- e_canvas_vbox_resize_children (item);
- e_canvas_item_request_reflow (item);
-}
-
-static void
-e_canvas_vbox_remove_item (gpointer data,
- GObject *where_object_was)
-{
- ECanvasVbox *vbox = data;
- vbox->items = g_list_remove (vbox->items, where_object_was);
-}
-
-static void
-e_canvas_vbox_real_add_item (ECanvasVbox *e_canvas_vbox,
- GnomeCanvasItem *item)
-{
- e_canvas_vbox->items = g_list_append (e_canvas_vbox->items, item);
- g_object_weak_ref (
- G_OBJECT (item),
- e_canvas_vbox_remove_item, e_canvas_vbox);
- if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & GNOME_CANVAS_ITEM_REALIZED) {
- gnome_canvas_item_set (
- item,
- "width", (gdouble) e_canvas_vbox->minimum_width,
- NULL);
- e_canvas_item_request_reflow (item);
- }
-}
-
-static void
-e_canvas_vbox_real_add_item_start (ECanvasVbox *e_canvas_vbox,
- GnomeCanvasItem *item)
-{
- e_canvas_vbox->items = g_list_prepend (e_canvas_vbox->items, item);
- g_object_weak_ref (
- G_OBJECT (item),
- e_canvas_vbox_remove_item, e_canvas_vbox);
- if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & GNOME_CANVAS_ITEM_REALIZED) {
- gnome_canvas_item_set (
- item,
- "width", (gdouble) e_canvas_vbox->minimum_width,
- NULL);
- e_canvas_item_request_reflow (item);
- }
-}
-
-static void
-e_canvas_vbox_resize_children (GnomeCanvasItem *item)
-{
- GList *list;
- ECanvasVbox *e_canvas_vbox;
-
- e_canvas_vbox = E_CANVAS_VBOX (item);
- for (list = e_canvas_vbox->items; list; list = list->next) {
- GnomeCanvasItem *child = GNOME_CANVAS_ITEM (list->data);
- gnome_canvas_item_set (
- child,
- "width", (gdouble) e_canvas_vbox->minimum_width,
- NULL);
- }
-}
-
-static void
-e_canvas_vbox_reflow (GnomeCanvasItem *item,
- gint flags)
-{
- ECanvasVbox *e_canvas_vbox = E_CANVAS_VBOX (item);
- if (item->flags & GNOME_CANVAS_ITEM_REALIZED) {
-
- gdouble old_height;
- gdouble running_height;
- gdouble old_width;
- gdouble max_width;
-
- old_width = e_canvas_vbox->width;
- max_width = e_canvas_vbox->minimum_width;
-
- old_height = e_canvas_vbox->height;
- running_height = 0;
-
- if (e_canvas_vbox->items == NULL) {
- } else {
- GList *list;
- gdouble item_height;
- gdouble item_width;
-
- list = e_canvas_vbox->items;
- g_object_get (
- list->data,
- "height", &item_height,
- "width", &item_width,
- NULL);
- e_canvas_item_move_absolute (
- GNOME_CANVAS_ITEM (list->data),
- (gdouble) 0,
- (gdouble) running_height);
- running_height += item_height;
- if (max_width < item_width)
- max_width = item_width;
- list = g_list_next (list);
-
- for (; list; list = g_list_next (list)) {
- running_height += e_canvas_vbox->spacing;
-
- g_object_get (
- list->data,
- "height", &item_height,
- "width", &item_width,
- NULL);
-
- e_canvas_item_move_absolute (
- GNOME_CANVAS_ITEM (list->data),
- (gdouble) 0,
- (gdouble) running_height);
-
- running_height += item_height;
- if (max_width < item_width)
- max_width = item_width;
- }
-
- }
- e_canvas_vbox->height = running_height;
- e_canvas_vbox->width = max_width;
- if (old_height != e_canvas_vbox->height ||
- old_width != e_canvas_vbox->width)
- e_canvas_item_request_parent_reflow (item);
- }
-}
-
-void
-e_canvas_vbox_add_item (ECanvasVbox *e_canvas_vbox,
- GnomeCanvasItem *item)
-{
- if (E_CANVAS_VBOX_CLASS (G_OBJECT_GET_CLASS (e_canvas_vbox))->add_item)
- (E_CANVAS_VBOX_CLASS (G_OBJECT_GET_CLASS (e_canvas_vbox))->add_item) (e_canvas_vbox, item);
-}
-
-void
-e_canvas_vbox_add_item_start (ECanvasVbox *e_canvas_vbox,
- GnomeCanvasItem *item)
-{
- if (E_CANVAS_VBOX_CLASS (G_OBJECT_GET_CLASS (e_canvas_vbox))->add_item_start)
- (E_CANVAS_VBOX_CLASS (G_OBJECT_GET_CLASS (e_canvas_vbox))->add_item_start) (e_canvas_vbox, item);
-}
-
diff --git a/widgets/misc/e-canvas-vbox.h b/widgets/misc/e-canvas-vbox.h
deleted file mode 100644
index 7f0110ce9e..0000000000
--- a/widgets/misc/e-canvas-vbox.h
+++ /dev/null
@@ -1,85 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_CANVAS_VBOX_H__
-#define __E_CANVAS_VBOX_H__
-
-#include <gtk/gtk.h>
-#include <libgnomecanvas/gnome-canvas.h>
-
-G_BEGIN_DECLS
-
-/* ECanvasVbox - A canvas item container.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * width gdouble RW width of the CanvasVbox
- * height gdouble R height of the CanvasVbox
- * spacing gdouble RW Spacing between items.
- */
-
-#define E_CANVAS_VBOX_TYPE (e_canvas_vbox_get_type ())
-#define E_CANVAS_VBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_CANVAS_VBOX_TYPE, ECanvasVbox))
-#define E_CANVAS_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_CANVAS_VBOX_TYPE, ECanvasVboxClass))
-#define E_IS_CANVAS_VBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_CANVAS_VBOX_TYPE))
-#define E_IS_CANVAS_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_CANVAS_VBOX_TYPE))
-
-typedef struct _ECanvasVbox ECanvasVbox;
-typedef struct _ECanvasVboxClass ECanvasVboxClass;
-
-struct _ECanvasVbox
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- GList *items; /* Of type GnomeCanvasItem */
-
- gdouble width;
- gdouble minimum_width;
- gdouble height;
- gdouble spacing;
-};
-
-struct _ECanvasVboxClass
-{
- GnomeCanvasGroupClass parent_class;
-
- /* Virtual methods. */
- void (* add_item) (ECanvasVbox *CanvasVbox, GnomeCanvasItem *item);
- void (* add_item_start) (ECanvasVbox *CanvasVbox, GnomeCanvasItem *item);
-};
-
-/*
- * To be added to a CanvasVbox, an item must have the argument "width" as
- * a Read/Write argument and "height" as a Read Only argument. It
- * should also do an ECanvas parent CanvasVbox request if its size
- * changes.
- */
-void e_canvas_vbox_add_item (ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item);
-void e_canvas_vbox_add_item_start (ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item);
-GType e_canvas_vbox_get_type (void);
-
-G_END_DECLS
-
-#endif /* __E_CANVAS_VBOX_H__ */
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
deleted file mode 100644
index 3ffc105867..0000000000
--- a/widgets/misc/e-canvas.c
+++ /dev/null
@@ -1,882 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include "e-util/e-util.h"
-
-#include "e-canvas.h"
-
-#define d(x)
-
-enum {
- REFLOW,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (
- ECanvas,
- e_canvas,
- GNOME_TYPE_CANVAS)
-
-/* Emits an event for an item in the canvas, be it the current
- * item, grabbed item, or focused item, as appropriate. */
-static gint
-canvas_emit_event (GnomeCanvas *canvas,
- GdkEvent *event)
-{
- GdkEvent *ev;
- gint finished;
- GnomeCanvasItem *item;
- GnomeCanvasItem *parent;
- guint mask;
-
- /* Choose where we send the event */
-
- item = canvas->current_item;
-
- if (canvas->focused_item &&
- ((event->type == GDK_KEY_PRESS) ||
- (event->type == GDK_KEY_RELEASE) ||
- (event->type == GDK_FOCUS_CHANGE)))
- item = canvas->focused_item;
-
- if (canvas->grabbed_item)
- item = canvas->grabbed_item;
-
- /* Perform checks for grabbed items */
-
- if (canvas->grabbed_item) {
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- mask = GDK_ENTER_NOTIFY_MASK;
- break;
-
- case GDK_LEAVE_NOTIFY:
- mask = GDK_LEAVE_NOTIFY_MASK;
- break;
-
- case GDK_MOTION_NOTIFY:
- mask = GDK_POINTER_MOTION_MASK;
- break;
-
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- mask = GDK_BUTTON_PRESS_MASK;
- break;
-
- case GDK_BUTTON_RELEASE:
- mask = GDK_BUTTON_RELEASE_MASK;
- break;
-
- case GDK_KEY_PRESS:
- mask = GDK_KEY_PRESS_MASK;
- break;
-
- case GDK_KEY_RELEASE:
- mask = GDK_KEY_RELEASE_MASK;
- break;
-
- default:
- mask = 0;
- break;
- }
-
- if (!(mask & canvas->grabbed_event_mask))
- return FALSE;
- }
-
- /* Convert to world coordinates -- we have two cases because of
- * different offsets of the fields in the event structures. */
-
- ev = gdk_event_copy (event);
-
- switch (ev->type) {
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- gnome_canvas_window_to_world (
- canvas,
- ev->crossing.x, ev->crossing.y,
- &ev->crossing.x, &ev->crossing.y);
- break;
-
- case GDK_MOTION_NOTIFY:
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- gnome_canvas_window_to_world (
- canvas,
- ev->motion.x, ev->motion.y,
- &ev->motion.x, &ev->motion.y);
- break;
-
- default:
- break;
- }
-
- /* The event is propagated up the hierarchy (for if someone connected
- * to a group instead of a leaf event), and emission is stopped if a
- * handler returns TRUE, just like for GtkWidget events. */
-
- finished = FALSE;
-
- while (item && !finished) {
- g_object_ref (item);
-
- g_signal_emit_by_name (item, "event", ev, &finished);
-
- parent = item->parent;
- g_object_unref (item);
-
- item = parent;
- }
-
- gdk_event_free (ev);
-
- return finished;
-}
-
-/* This routine invokes the point method of the item. The argument x, y
- * should be in the parent's item-relative coordinate system. This routine
- * applies the inverse of the item's transform, maintaining the affine
- * invariant. */
-static GnomeCanvasItem *
-gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
- gdouble x,
- gdouble y,
- gint cx,
- gint cy)
-{
- cairo_matrix_t inverse;
-
- /* Calculate x & y in item local coordinates */
- inverse = item->matrix;
- if (cairo_matrix_invert (&inverse) != CAIRO_STATUS_SUCCESS)
- return NULL;
-
- cairo_matrix_transform_point (&inverse, &x, &y);
-
- if (GNOME_CANVAS_ITEM_GET_CLASS (item)->point)
- return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy);
-
- return NULL;
-}
-
-/* Re-picks the current item in the canvas, based on the event's coordinates.
- * Also emits enter/leave events for items as appropriate.
- */
-#define DISPLAY_X1(canvas) (GNOME_CANVAS (canvas)->layout.xoffset)
-#define DISPLAY_Y1(canvas) (GNOME_CANVAS (canvas)->layout.yoffset)
-static gint
-pick_current_item (GnomeCanvas *canvas,
- GdkEvent *event)
-{
- gint button_down;
- gdouble x, y;
- gint cx, cy;
- gint retval;
-
- retval = FALSE;
-
- /* If a button is down, we'll perform enter and leave events on the
- * current item, but not enter on any other item. This is more or less
- * like X pointer grabbing for canvas items.
- */
- button_down = canvas->state & (GDK_BUTTON1_MASK
- | GDK_BUTTON2_MASK
- | GDK_BUTTON3_MASK
- | GDK_BUTTON4_MASK
- | GDK_BUTTON5_MASK);
- if (!button_down)
- canvas->left_grabbed_item = FALSE;
-
- /* Save the event in the canvas. This is used to synthesize enter and
- * leave events in case the current item changes. It is also used to
- * re-pick the current item if the current one gets deleted. Also,
- * synthesize an enter event.
- */
- if (event != &canvas->pick_event) {
- if ((event->type == GDK_MOTION_NOTIFY) ||
- (event->type == GDK_BUTTON_RELEASE)) {
- /* these fields have the same offsets in both types of events */
-
- canvas->pick_event.crossing.type = GDK_ENTER_NOTIFY;
- canvas->pick_event.crossing.window = event->motion.window;
- canvas->pick_event.crossing.send_event = event->motion.send_event;
- canvas->pick_event.crossing.subwindow = NULL;
- canvas->pick_event.crossing.x = event->motion.x;
- canvas->pick_event.crossing.y = event->motion.y;
- canvas->pick_event.crossing.mode = GDK_CROSSING_NORMAL;
- canvas->pick_event.crossing.detail = GDK_NOTIFY_NONLINEAR;
- canvas->pick_event.crossing.focus = FALSE;
- canvas->pick_event.crossing.state = event->motion.state;
-
- /* these fields don't have the same offsets in both types of events */
-
- if (event->type == GDK_MOTION_NOTIFY) {
- canvas->pick_event.crossing.x_root = event->motion.x_root;
- canvas->pick_event.crossing.y_root = event->motion.y_root;
- } else {
- canvas->pick_event.crossing.x_root = event->button.x_root;
- canvas->pick_event.crossing.y_root = event->button.y_root;
- }
- } else
- canvas->pick_event = *event;
- }
-
- /* Don't do anything else if this is a recursive call */
-
- if (canvas->in_repick)
- return retval;
-
- /* LeaveNotify means that there is no current item, so we don't look for one */
-
- if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) {
- /* these fields don't have the same offsets in both types of events */
-
- if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
- x = canvas->pick_event.crossing.x +
- canvas->scroll_x1 - canvas->zoom_xofs;
- y = canvas->pick_event.crossing.y +
- canvas->scroll_y1 - canvas->zoom_yofs;
- } else {
- x = canvas->pick_event.motion.x +
- canvas->scroll_x1 - canvas->zoom_xofs;
- y = canvas->pick_event.motion.y +
- canvas->scroll_y1 - canvas->zoom_yofs;
- }
-
- /* canvas pixel coords */
-
- cx = (gint) (x + 0.5);
- cy = (gint) (y + 0.5);
-
- /* world coords */
-
- x = canvas->scroll_x1 + x;
- y = canvas->scroll_y1 + y;
-
- /* find the closest item */
-
- if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE)
- canvas->new_current_item =
- gnome_canvas_item_invoke_point (
- canvas->root, x, y, cx, cy);
- else
- canvas->new_current_item = NULL;
- } else
- canvas->new_current_item = NULL;
-
- if ((canvas->new_current_item == canvas->current_item) &&
- !canvas->left_grabbed_item)
- return retval; /* current item did not change */
-
- /* Synthesize events for old and new current items */
-
- if ((canvas->new_current_item != canvas->current_item)
- && (canvas->current_item != NULL)
- && !canvas->left_grabbed_item) {
- GdkEvent new_event = { 0 };
-
- new_event = canvas->pick_event;
- new_event.type = GDK_LEAVE_NOTIFY;
-
- new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
- new_event.crossing.subwindow = NULL;
- canvas->in_repick = TRUE;
- retval = canvas_emit_event (canvas, &new_event);
- canvas->in_repick = FALSE;
- }
-
- /* new_current_item may have been set to NULL during
- * the call to canvas_emit_event() above. */
-
- if ((canvas->new_current_item != canvas->current_item) && button_down) {
- canvas->left_grabbed_item = TRUE;
- return retval;
- }
-
- /* Handle the rest of cases */
-
- canvas->left_grabbed_item = FALSE;
- canvas->current_item = canvas->new_current_item;
-
- if (canvas->current_item != NULL) {
- GdkEvent new_event = { 0 };
-
- new_event = canvas->pick_event;
- new_event.type = GDK_ENTER_NOTIFY;
- new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
- new_event.crossing.subwindow = NULL;
- retval = canvas_emit_event (canvas, &new_event);
- }
-
- return retval;
-}
-
-static void
-canvas_style_set_recursive (GnomeCanvasItem *item,
- GtkStyle *previous_style)
-{
- guint signal_id = g_signal_lookup ("style_set", G_OBJECT_TYPE (item));
- if (signal_id >= 1) {
- GSignalQuery query;
- g_signal_query (signal_id, &query);
- if (query.return_type == G_TYPE_NONE &&
- query.n_params == 1 &&
- query.param_types[0] == GTK_TYPE_STYLE) {
- g_signal_emit (item, signal_id, 0, previous_style);
- }
- }
-
- if (GNOME_IS_CANVAS_GROUP (item)) {
- GList *items = GNOME_CANVAS_GROUP (item)->item_list;
- for (; items; items = items->next)
- canvas_style_set_recursive (
- items->data, previous_style);
- }
-}
-
-static void
-canvas_dispose (GObject *object)
-{
- ECanvas *canvas = E_CANVAS (object);
-
- if (canvas->idle_id)
- g_source_remove (canvas->idle_id);
- canvas->idle_id = 0;
-
- if (canvas->grab_cancelled_check_id)
- g_source_remove (canvas->grab_cancelled_check_id);
- canvas->grab_cancelled_check_id = 0;
-
- if (canvas->toplevel) {
- if (canvas->visibility_notify_id)
- g_signal_handler_disconnect (
- canvas->toplevel,
- canvas->visibility_notify_id);
- canvas->visibility_notify_id = 0;
-
- g_object_unref (canvas->toplevel);
- canvas->toplevel = NULL;
- }
-
- if (canvas->im_context) {
- g_object_unref (canvas->im_context);
- canvas->im_context = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_canvas_parent_class)->dispose (object);
-}
-
-static void
-canvas_realize (GtkWidget *widget)
-{
- ECanvas *ecanvas = E_CANVAS (widget);
- GdkWindow *window;
-
- /* Chain up to parent's realize() method. */
- GTK_WIDGET_CLASS (e_canvas_parent_class)->realize (widget);
-
- window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- gdk_window_set_background_pattern (window, NULL);
-
- window = gtk_widget_get_window (widget);
- gtk_im_context_set_client_window (ecanvas->im_context, window);
-}
-
-static void
-canvas_unrealize (GtkWidget *widget)
-{
- ECanvas * ecanvas = E_CANVAS (widget);
-
- if (ecanvas->idle_id) {
- g_source_remove (ecanvas->idle_id);
- ecanvas->idle_id = 0;
- }
-
- gtk_im_context_set_client_window (ecanvas->im_context, NULL);
-
- /* Chain up to parent's unrealize() method. */
- GTK_WIDGET_CLASS (e_canvas_parent_class)->unrealize (widget);
-}
-
-static void
-canvas_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- canvas_style_set_recursive (
- GNOME_CANVAS_ITEM (gnome_canvas_root (
- GNOME_CANVAS (widget))), previous_style);
-}
-
-static gint
-canvas_button_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GnomeCanvas *canvas;
- GdkWindow *bin_window;
- gint mask;
- gint retval;
-
- g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- retval = FALSE;
-
- canvas = GNOME_CANVAS (widget);
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (canvas));
-
- d (
- g_print ("button %d, event type %d, grabbed=%p, current=%p\n",
- event->button,
- event->type,
- canvas->grabbed_item,
- canvas->current_item));
-
- /* dispatch normally regardless of the event's window if an item has
- has a pointer grab in effect */
- if (!canvas->grabbed_item && event->window != bin_window)
- return retval;
-
- switch (event->button) {
- case 1:
- mask = GDK_BUTTON1_MASK;
- break;
- case 2:
- mask = GDK_BUTTON2_MASK;
- break;
- case 3:
- mask = GDK_BUTTON3_MASK;
- break;
- case 4:
- mask = GDK_BUTTON4_MASK;
- break;
- case 5:
- mask = GDK_BUTTON5_MASK;
- break;
- default:
- mask = 0;
- }
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- /* Pick the current item as if the button were not
- * pressed, and then process the event. */
- canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
- canvas->state ^= mask;
- retval = canvas_emit_event (canvas, (GdkEvent *) event);
- break;
-
- case GDK_BUTTON_RELEASE:
- /* Process the event as if the button were pressed,
- * then repick after the button has been released. */
- canvas->state = event->state;
- retval = canvas_emit_event (canvas, (GdkEvent *) event);
- event->state ^= mask;
- canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
- event->state ^= mask;
- break;
-
- default:
- g_return_val_if_reached (0);
- }
-
- return retval;
-}
-
-static gint
-canvas_key_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- GnomeCanvas *canvas;
- GdkEvent full_event = { 0 };
-
- g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- canvas = GNOME_CANVAS (widget);
-
- full_event.type = event->type;
- full_event.key = *event;
-
- return canvas_emit_event (canvas, &full_event);
-}
-
-static gint
-canvas_focus_in_event (GtkWidget *widget,
- GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
- ECanvas *ecanvas;
- GdkEvent full_event = { 0 };
-
- canvas = GNOME_CANVAS (widget);
- ecanvas = E_CANVAS (widget);
-
- /* XXX Can't access flags directly anymore, but is it really needed?
- * If so, could we call gtk_widget_send_focus_change() instead? */
-#if 0
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
-#endif
-
- gtk_im_context_focus_in (ecanvas->im_context);
-
- if (canvas->focused_item) {
- full_event.type = event->type;
- full_event.focus_change = *event;
- return canvas_emit_event (canvas, &full_event);
- } else {
- return FALSE;
- }
-}
-
-static gint
-canvas_focus_out_event (GtkWidget *widget,
- GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
- ECanvas *ecanvas;
- GdkEvent full_event = { 0 };
-
- canvas = GNOME_CANVAS (widget);
- ecanvas = E_CANVAS (widget);
-
- /* XXX Can't access flags directly anymore, but is it really needed?
- * If so, could we call gtk_widget_send_focus_change() instead? */
-#if 0
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
-#endif
-
- gtk_im_context_focus_out (ecanvas->im_context);
-
- if (canvas->focused_item) {
- full_event.type = event->type;
- full_event.focus_change = *event;
- return canvas_emit_event (canvas, &full_event);
- } else {
- return FALSE;
- }
-}
-
-static void
-canvas_reflow (ECanvas *canvas)
-{
- /* Placeholder so subclasses can safely chain up. */
-}
-
-static void
-e_canvas_class_init (ECanvasClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = canvas_dispose;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->realize = canvas_realize;
- widget_class->unrealize = canvas_unrealize;
- widget_class->style_set = canvas_style_set;
- widget_class->button_press_event = canvas_button_event;
- widget_class->button_release_event = canvas_button_event;
- widget_class->key_press_event = canvas_key_event;
- widget_class->key_release_event = canvas_key_event;
- widget_class->focus_in_event = canvas_focus_in_event;
- widget_class->focus_out_event = canvas_focus_out_event;
-
- class->reflow = canvas_reflow;
-
- signals[REFLOW] = g_signal_new (
- "reflow",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECanvasClass, reflow),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_canvas_init (ECanvas *canvas)
-{
- canvas->im_context = gtk_im_multicontext_new ();
-}
-
-GtkWidget *
-e_canvas_new (void)
-{
- return g_object_new (E_TYPE_CANVAS, NULL);
-}
-
-/**
- * e_canvas_item_grab_focus:
- * @item: A canvas item.
- * @widget_too: Whether or not to grab the widget-level focus too
- *
- * Makes the specified item take the keyboard focus, so all keyboard
- * events will be sent to it. If the canvas widget itself did not have
- * the focus and @widget_too is %TRUE, it grabs that focus as well.
- **/
-void
-e_canvas_item_grab_focus (GnomeCanvasItem *item,
- gboolean widget_too)
-{
- GnomeCanvasItem *focused_item;
- GdkWindow *bin_window;
- GdkEvent ev = { 0 };
-
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
- g_return_if_fail (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas)));
-
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas));
-
- focused_item = item->canvas->focused_item;
-
- if (focused_item) {
- ev.type = GDK_FOCUS_CHANGE;
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = bin_window;
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = FALSE;
-
- canvas_emit_event (item->canvas, &ev);
- }
-
- item->canvas->focused_item = item;
-
- if (widget_too && !gtk_widget_has_focus (GTK_WIDGET (item->canvas))) {
- gtk_widget_grab_focus (GTK_WIDGET (item->canvas));
- }
-
- if (item) {
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = bin_window;
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = TRUE;
-
- canvas_emit_event (item->canvas, &ev);
- }
-}
-
-static void
-e_canvas_item_invoke_reflow (GnomeCanvasItem *item,
- gint flags)
-{
- GnomeCanvasGroup *group;
- GList *list;
- GnomeCanvasItem *child;
-
- if (GNOME_IS_CANVAS_GROUP (item)) {
- group = GNOME_CANVAS_GROUP (item);
- for (list = group->item_list; list; list = list->next) {
- child = GNOME_CANVAS_ITEM (list->data);
- if (child->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW)
- e_canvas_item_invoke_reflow (child, flags);
- }
- }
-
- if (item->flags & E_CANVAS_ITEM_NEEDS_REFLOW) {
- ECanvasItemReflowFunc func;
- func = (ECanvasItemReflowFunc)
- g_object_get_data (
- G_OBJECT (item),
- "ECanvasItem::reflow_callback");
- if (func)
- func (item, flags);
- }
-
- item->flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW;
- item->flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW;
-}
-
-static void
-do_reflow (ECanvas *canvas)
-{
- if (GNOME_CANVAS (canvas)->root->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW)
- e_canvas_item_invoke_reflow (GNOME_CANVAS (canvas)->root, 0);
-}
-
-/* Idle handler for the e-canvas. It deals with pending reflows. */
-static gint
-idle_handler (gpointer data)
-{
- ECanvas *canvas;
-
- canvas = E_CANVAS (data);
- do_reflow (canvas);
-
- /* Reset idle id */
- canvas->idle_id = 0;
-
- g_signal_emit (canvas, signals[REFLOW], 0);
-
- return FALSE;
-}
-
-/* Convenience function to add an idle handler to a canvas */
-static void
-add_idle (ECanvas *canvas)
-{
- if (canvas->idle_id != 0)
- return;
-
- canvas->idle_id = g_idle_add_full (
- G_PRIORITY_HIGH_IDLE, idle_handler, (gpointer) canvas, NULL);
-}
-
-static void
-e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item)
-{
- if (item->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW)
- return;
-
- item->flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW;
- if (item->parent)
- e_canvas_item_descendent_needs_reflow (item->parent);
-}
-
-void
-e_canvas_item_request_reflow (GnomeCanvasItem *item)
-{
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- if (item->flags & GNOME_CANVAS_ITEM_REALIZED) {
- item->flags |= E_CANVAS_ITEM_NEEDS_REFLOW;
- e_canvas_item_descendent_needs_reflow (item);
- add_idle (E_CANVAS (item->canvas));
- }
-}
-
-void
-e_canvas_item_request_parent_reflow (GnomeCanvasItem *item)
-{
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- e_canvas_item_request_reflow (item->parent);
-}
-
-void
-e_canvas_item_set_reflow_callback (GnomeCanvasItem *item,
- ECanvasItemReflowFunc func)
-{
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
- g_return_if_fail (func != NULL);
-
- g_object_set_data (
- G_OBJECT (item), "ECanvasItem::reflow_callback",
- (gpointer) func);
-}
-
-static gboolean
-grab_cancelled_check (gpointer data)
-{
- ECanvas *canvas = data;
-
- if (GNOME_CANVAS (canvas)->grabbed_item == NULL) {
- canvas->grab_cancelled_cb = NULL;
- canvas->grab_cancelled_check_id = 0;
- canvas->grab_cancelled_time = 0;
- canvas->grab_cancelled_data = NULL;
- return FALSE;
- }
-
- if (gtk_grab_get_current ()) {
- gnome_canvas_item_ungrab (
- GNOME_CANVAS (canvas)->grabbed_item,
- canvas->grab_cancelled_time);
- if (canvas->grab_cancelled_cb)
- canvas->grab_cancelled_cb (
- canvas, GNOME_CANVAS (canvas)->grabbed_item,
- canvas->grab_cancelled_data);
- canvas->grab_cancelled_cb = NULL;
- canvas->grab_cancelled_check_id = 0;
- canvas->grab_cancelled_time = 0;
- canvas->grab_cancelled_data = NULL;
- return FALSE;
- }
- return TRUE;
-}
-
-gint
-e_canvas_item_grab (ECanvas *canvas,
- GnomeCanvasItem *item,
- guint event_mask,
- GdkCursor *cursor,
- GdkDevice *device,
- guint32 etime,
- ECanvasItemGrabCancelled cancelled_cb,
- gpointer cancelled_data)
-{
- GdkGrabStatus grab_status;
-
- g_return_val_if_fail (E_IS_CANVAS (canvas), -1);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), -1);
- g_return_val_if_fail (GDK_IS_DEVICE (device), -1);
-
- if (gtk_grab_get_current ())
- return GDK_GRAB_ALREADY_GRABBED;
-
- grab_status = gnome_canvas_item_grab (
- item, event_mask, cursor, device, etime);
- if (grab_status == GDK_GRAB_SUCCESS) {
- canvas->grab_cancelled_cb = cancelled_cb;
- canvas->grab_cancelled_check_id = g_timeout_add_full (
- G_PRIORITY_LOW, 100,
- grab_cancelled_check, canvas, NULL);
- canvas->grab_cancelled_time = etime;
- canvas->grab_cancelled_data = cancelled_data;
- }
-
- return grab_status;
-}
-
-void
-e_canvas_item_ungrab (ECanvas *canvas,
- GnomeCanvasItem *item,
- guint32 etime)
-{
- g_return_if_fail (E_IS_CANVAS (canvas));
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- if (canvas->grab_cancelled_check_id) {
- g_source_remove (canvas->grab_cancelled_check_id);
- canvas->grab_cancelled_cb = NULL;
- canvas->grab_cancelled_check_id = 0;
- canvas->grab_cancelled_time = 0;
- canvas->grab_cancelled_data = NULL;
- gnome_canvas_item_ungrab (item, etime);
- }
-}
diff --git a/widgets/misc/e-canvas.h b/widgets/misc/e-canvas.h
deleted file mode 100644
index c5f2087cd0..0000000000
--- a/widgets/misc/e-canvas.h
+++ /dev/null
@@ -1,137 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_CANVAS_H
-#define E_CANVAS_H
-
-#include <gtk/gtk.h>
-#include <libgnomecanvas/gnome-canvas.h>
-
-/* ECanvas - A class derived from canvas for the purpose of adding
- * evolution specific canvas hacks. */
-
-/* Standard GObject macros */
-#define E_TYPE_CANVAS \
- (e_canvas_get_type ())
-#define E_CANVAS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CANVAS, ECanvas))
-#define E_CANVAS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CANVAS, ECanvasClass))
-#define E_IS_CANVAS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CANVAS))
-#define E_IS_CANVAS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CANVAS))
-#define E_CANVAS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CANVAS, ECanvasClass))
-
-G_BEGIN_DECLS
-
-typedef void (*ECanvasItemReflowFunc) (GnomeCanvasItem *item,
- gint flags);
-
-typedef void (*ECanvasItemSelectionFunc) (GnomeCanvasItem *item,
- gint flags,
- gpointer user_data);
-/* Returns the same as strcmp does. */
-typedef gint (*ECanvasItemSelectionCompareFunc)
- (GnomeCanvasItem *item,
- gpointer data1,
- gpointer data2,
- gint flags);
-
-typedef struct _ECanvas ECanvas;
-typedef struct _ECanvasClass ECanvasClass;
-
-/* Object flags for items */
-enum {
- E_CANVAS_ITEM_NEEDS_REFLOW = 1 << 13,
- E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW = 1 << 14
-};
-
-typedef struct {
- GnomeCanvasItem *item;
- gpointer id;
-} ECanvasSelectionInfo;
-
-typedef void (*ECanvasItemGrabCancelled) (ECanvas *canvas,
- GnomeCanvasItem *item,
- gpointer data);
-
-struct _ECanvas {
- GnomeCanvas parent;
-
- gint idle_id;
- GList *selection;
- ECanvasSelectionInfo *cursor;
-
- GtkWidget *tooltip_window;
- gint visibility_notify_id;
- GtkWidget *toplevel;
-
- /* Input context for dead key support */
- GtkIMContext *im_context;
-
- ECanvasItemGrabCancelled grab_cancelled_cb;
- guint grab_cancelled_check_id;
- guint32 grab_cancelled_time;
- gpointer grab_cancelled_data;
-};
-
-struct _ECanvasClass {
- GnomeCanvasClass parent_class;
-
- void (*reflow) (ECanvas *canvas);
-};
-
-GType e_canvas_get_type (void);
-GtkWidget * e_canvas_new (void);
-
-/* Used to send all of the keystroke events to a specific item as well as
- * GDK_FOCUS_CHANGE events. */
-void e_canvas_item_grab_focus (GnomeCanvasItem *item,
- gboolean widget_too);
-void e_canvas_item_request_reflow (GnomeCanvasItem *item);
-void e_canvas_item_request_parent_reflow
- (GnomeCanvasItem *item);
-void e_canvas_item_set_reflow_callback
- (GnomeCanvasItem *item,
- ECanvasItemReflowFunc func);
-gint e_canvas_item_grab (ECanvas *canvas,
- GnomeCanvasItem *item,
- guint event_mask,
- GdkCursor *cursor,
- GdkDevice *device,
- guint32 etime,
- ECanvasItemGrabCancelled cancelled,
- gpointer cancelled_data);
-void e_canvas_item_ungrab (ECanvas *canvas,
- GnomeCanvasItem *item,
- guint32 etime);
-
-G_END_DECLS
-
-#endif /* E_CANVAS_H */
diff --git a/widgets/misc/e-charset-combo-box.c b/widgets/misc/e-charset-combo-box.c
deleted file mode 100644
index 01a814ad10..0000000000
--- a/widgets/misc/e-charset-combo-box.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * e-charset-combo-box.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-charset-combo-box.h"
-
-#include <glib/gi18n.h>
-
-#include "e-util/e-charset.h"
-#include "e-util/e-util.h"
-
-#define E_CHARSET_COMBO_BOX_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CHARSET_COMBO_BOX, ECharsetComboBoxPrivate))
-
-#define DEFAULT_CHARSET "UTF-8"
-#define OTHER_VALUE G_MAXINT
-
-struct _ECharsetComboBoxPrivate {
- GtkActionGroup *action_group;
- GtkRadioAction *other_action;
- GHashTable *charset_index;
-
- /* Used when the user clicks Cancel in the character set
- * dialog. Reverts to the previous combo box setting. */
- gint previous_index;
-
- /* When setting the character set programmatically, this
- * prevents the custom character set dialog from running. */
- guint block_dialog : 1;
-};
-
-enum {
- PROP_0,
- PROP_CHARSET
-};
-
-G_DEFINE_TYPE (
- ECharsetComboBox,
- e_charset_combo_box,
- E_TYPE_ACTION_COMBO_BOX)
-
-static void
-charset_combo_box_entry_changed_cb (GtkEntry *entry,
- GtkDialog *dialog)
-{
- const gchar *text;
- gboolean sensitive;
-
- text = gtk_entry_get_text (entry);
- sensitive = (text != NULL && *text != '\0');
- gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
-}
-
-static void
-charset_combo_box_run_dialog (ECharsetComboBox *combo_box)
-{
- GtkDialog *dialog;
- GtkEntry *entry;
- GtkWidget *container;
- GtkWidget *widget;
- GObject *object;
- gpointer parent;
- const gchar *charset;
-
- /* FIXME Using a dialog for this is lame. Selecting "Other..."
- * should unlock an entry directly in the Preferences tab.
- * Unfortunately space in Preferences is at a premium right
- * now, but we should revisit this when the space issue is
- * finally resolved. */
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- object = G_OBJECT (combo_box->priv->other_action);
- charset = g_object_get_data (object, "charset");
-
- widget = gtk_dialog_new_with_buttons (
- _("Character Encoding"), parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
-
- /* Load the broken border width defaults so we can override them. */
- gtk_widget_ensure_style (widget);
-
- dialog = GTK_DIALOG (widget);
-
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
-
- widget = gtk_dialog_get_action_area (dialog);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 0);
-
- widget = gtk_dialog_get_content_area (dialog);
- gtk_box_set_spacing (GTK_BOX (widget), 12);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 0);
-
- container = widget;
-
- widget = gtk_label_new (_("Enter the character set to use"));
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 0);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_entry_new ();
- entry = GTK_ENTRY (widget);
- gtk_entry_set_activates_default (entry, TRUE);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- g_signal_connect (
- entry, "changed",
- G_CALLBACK (charset_combo_box_entry_changed_cb), dialog);
-
- /* Set the default text -after- connecting the signal handler.
- * This will initialize the "OK" button to the proper state. */
- gtk_entry_set_text (entry, charset);
-
- if (gtk_dialog_run (dialog) != GTK_RESPONSE_OK) {
- gint active;
-
- /* Revert to the previously selected character set. */
- combo_box->priv->block_dialog = TRUE;
- active = combo_box->priv->previous_index;
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), active);
- combo_box->priv->block_dialog = FALSE;
-
- goto exit;
- }
-
- charset = gtk_entry_get_text (entry);
- g_return_if_fail (charset != NULL && charset != '\0');
-
- g_object_set_data_full (
- object, "charset", g_strdup (charset),
- (GDestroyNotify) g_free);
-
-exit:
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-charset_combo_box_notify_charset_cb (ECharsetComboBox *combo_box)
-{
- GtkToggleAction *action;
-
- action = GTK_TOGGLE_ACTION (combo_box->priv->other_action);
- if (!gtk_toggle_action_get_active (action))
- return;
-
- if (combo_box->priv->block_dialog)
- return;
-
- /* "Other" action was selected by user. */
- charset_combo_box_run_dialog (combo_box);
-}
-
-static void
-charset_combo_box_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CHARSET:
- e_charset_combo_box_set_charset (
- E_CHARSET_COMBO_BOX (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-charset_combo_box_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CHARSET:
- g_value_set_string (
- value, e_charset_combo_box_get_charset (
- E_CHARSET_COMBO_BOX (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-charset_combo_box_dispose (GObject *object)
-{
- ECharsetComboBoxPrivate *priv;
-
- priv = E_CHARSET_COMBO_BOX_GET_PRIVATE (object);
-
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
- if (priv->other_action != NULL) {
- g_object_unref (priv->other_action);
- priv->other_action = NULL;
- }
-
- g_hash_table_remove_all (priv->charset_index);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_charset_combo_box_parent_class)->dispose (object);
-}
-
-static void
-charset_combo_box_finalize (GObject *object)
-{
- ECharsetComboBoxPrivate *priv;
-
- priv = E_CHARSET_COMBO_BOX_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->charset_index);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_charset_combo_box_parent_class)->finalize (object);
-}
-
-static void
-charset_combo_box_changed (GtkComboBox *combo_box)
-{
- ECharsetComboBoxPrivate *priv;
-
- priv = E_CHARSET_COMBO_BOX_GET_PRIVATE (combo_box);
-
- /* Chain up to parent's changed() method. */
- GTK_COMBO_BOX_CLASS (e_charset_combo_box_parent_class)->
- changed (combo_box);
-
- /* Notify -before- updating previous index. */
- g_object_notify (G_OBJECT (combo_box), "charset");
- priv->previous_index = gtk_combo_box_get_active (combo_box);
-}
-
-static void
-e_charset_combo_box_class_init (ECharsetComboBoxClass *class)
-{
- GObjectClass *object_class;
- GtkComboBoxClass *combo_box_class;
-
- g_type_class_add_private (class, sizeof (ECharsetComboBoxPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = charset_combo_box_set_property;
- object_class->get_property = charset_combo_box_get_property;
- object_class->dispose = charset_combo_box_dispose;
- object_class->finalize = charset_combo_box_finalize;
-
- combo_box_class = GTK_COMBO_BOX_CLASS (class);
- combo_box_class->changed = charset_combo_box_changed;
-
- g_object_class_install_property (
- object_class,
- PROP_CHARSET,
- g_param_spec_string (
- "charset",
- "Charset",
- "The selected character set",
- "UTF-8",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_charset_combo_box_init (ECharsetComboBox *combo_box)
-{
- GtkActionGroup *action_group;
- GtkRadioAction *radio_action;
- GHashTable *charset_index;
- GSList *group, *iter;
-
- action_group = gtk_action_group_new ("charset-combo-box-internal");
-
- charset_index = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_object_unref);
-
- combo_box->priv = E_CHARSET_COMBO_BOX_GET_PRIVATE (combo_box);
- combo_box->priv->action_group = action_group;
- combo_box->priv->charset_index = charset_index;
-
- group = e_charset_add_radio_actions (
- action_group, "charset-", NULL, NULL, NULL);
-
- /* Populate the character set index. */
- for (iter = group; iter != NULL; iter = iter->next) {
- GObject *object = iter->data;
- const gchar *charset;
-
- charset = g_object_get_data (object, "charset");
- g_return_if_fail (charset != NULL);
-
- g_hash_table_insert (
- charset_index, g_strdup (charset),
- g_object_ref (object));
- }
-
- /* Note the "other" action is not included in the index. */
-
- radio_action = gtk_radio_action_new (
- "charset-other", _("Other..."), NULL, NULL, OTHER_VALUE);
-
- g_object_set_data (G_OBJECT (radio_action), "charset", (gpointer) "");
-
- gtk_radio_action_set_group (radio_action, group);
- group = gtk_radio_action_get_group (radio_action);
-
- e_action_combo_box_set_action (
- E_ACTION_COMBO_BOX (combo_box), radio_action);
-
- e_action_combo_box_add_separator_after (
- E_ACTION_COMBO_BOX (combo_box), g_slist_length (group));
-
- g_signal_connect (
- combo_box, "notify::charset",
- G_CALLBACK (charset_combo_box_notify_charset_cb), NULL);
-
- combo_box->priv->other_action = radio_action;
-}
-
-GtkWidget *
-e_charset_combo_box_new (void)
-{
- return g_object_new (E_TYPE_CHARSET_COMBO_BOX, NULL);
-}
-
-const gchar *
-e_charset_combo_box_get_charset (ECharsetComboBox *combo_box)
-{
- GtkRadioAction *radio_action;
-
- g_return_val_if_fail (E_IS_CHARSET_COMBO_BOX (combo_box), NULL);
-
- radio_action = combo_box->priv->other_action;
- radio_action = e_radio_action_get_current_action (radio_action);
-
- return g_object_get_data (G_OBJECT (radio_action), "charset");
-}
-
-void
-e_charset_combo_box_set_charset (ECharsetComboBox *combo_box,
- const gchar *charset)
-{
- GHashTable *charset_index;
- GtkRadioAction *radio_action;
-
- g_return_if_fail (E_IS_CHARSET_COMBO_BOX (combo_box));
-
- if (charset == NULL || *charset == '\0')
- charset = "UTF-8";
-
- charset_index = combo_box->priv->charset_index;
- radio_action = g_hash_table_lookup (charset_index, charset);
-
- if (radio_action == NULL) {
- radio_action = combo_box->priv->other_action;
- g_object_set_data_full (
- G_OBJECT (radio_action),
- "charset", g_strdup (charset),
- (GDestroyNotify) g_free);
- }
-
- combo_box->priv->block_dialog = TRUE;
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (radio_action), TRUE);
- combo_box->priv->block_dialog = FALSE;
-}
diff --git a/widgets/misc/e-charset-combo-box.h b/widgets/misc/e-charset-combo-box.h
deleted file mode 100644
index 471dfa6a54..0000000000
--- a/widgets/misc/e-charset-combo-box.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * e-charset-combo-box.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_CHARSET_COMBO_BOX_H
-#define E_CHARSET_COMBO_BOX_H
-
-#include <misc/e-action-combo-box.h>
-
-/* Standard GObject macros */
-#define E_TYPE_CHARSET_COMBO_BOX \
- (e_charset_combo_box_get_type ())
-#define E_CHARSET_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CHARSET_COMBO_BOX, ECharsetComboBox))
-#define E_CHARSET_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CHARSET_COMBO_BOX, ECharsetComboBoxClass))
-#define E_IS_CHARSET_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CHARSET_COMBO_BOX))
-#define E_IS_CHARSET_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CHARSET_COMBO_BOX))
-#define E_CHARSET_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CHARSET_COMBO_BOX, ECharsetComboBoxClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ECharsetComboBox ECharsetComboBox;
-typedef struct _ECharsetComboBoxClass ECharsetComboBoxClass;
-typedef struct _ECharsetComboBoxPrivate ECharsetComboBoxPrivate;
-
-struct _ECharsetComboBox {
- EActionComboBox parent;
- ECharsetComboBoxPrivate *priv;
-};
-
-struct _ECharsetComboBoxClass {
- EActionComboBoxClass parent_class;
-};
-
-GType e_charset_combo_box_get_type (void);
-GtkWidget * e_charset_combo_box_new (void);
-const gchar * e_charset_combo_box_get_charset (ECharsetComboBox *combo_box);
-void e_charset_combo_box_set_charset (ECharsetComboBox *combo_box,
- const gchar *charset);
-
-G_END_DECLS
-
-#endif /* E_CHARSET_COMBO_BOX_H */
diff --git a/widgets/misc/e-contact-map-window.c b/widgets/misc/e-contact-map-window.c
deleted file mode 100644
index 2e3aec5bcb..0000000000
--- a/widgets/misc/e-contact-map-window.c
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * e-contact-map-window.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WITH_CONTACT_MAPS
-
-#include "e-contact-map.h"
-#include "e-contact-map-window.h"
-#include "e-contact-marker.h"
-
-#include <champlain/champlain.h>
-
-#include <string.h>
-
-#include <glib/gi18n.h>
-#include <glib-object.h>
-
-#define E_CONTACT_MAP_WINDOW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CONTACT_MAP_WINDOW, EContactMapWindowPrivate))
-
-G_DEFINE_TYPE (EContactMapWindow, e_contact_map_window, GTK_TYPE_WINDOW)
-
-struct _EContactMapWindowPrivate {
- EContactMap *map;
-
- GtkWidget *zoom_in_btn;
- GtkWidget *zoom_out_btn;
-
- GtkWidget *search_entry;
- GtkListStore *completion_model;
-
- GHashTable *hash_table; /* Hash table contact-name -> marker */
-
- GtkWidget *spinner;
- gint tasks_cnt;
-};
-
-enum {
- SHOW_CONTACT_EDITOR,
- LAST_SIGNAL
-};
-
-static gint signals[LAST_SIGNAL] = {0};
-
-static void
-marker_doubleclick_cb (ClutterActor *actor,
- gpointer user_data)
-{
- EContactMapWindow *window = user_data;
- EContactMarker *marker;
- const gchar *contact_uid;
-
- marker = E_CONTACT_MARKER (actor);
- contact_uid = e_contact_marker_get_contact_uid (marker);
-
- g_signal_emit (window, signals[SHOW_CONTACT_EDITOR], 0, contact_uid);
-}
-
-static void
-book_contacts_received_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- EContactMapWindow *window = user_data;
- EBookClient *client = E_BOOK_CLIENT (source_object);
- GSList *contacts = NULL, *p;
- GError *error = NULL;
-
- if (!e_book_client_get_contacts_finish (client, result, &contacts, &error))
- contacts = NULL;
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to get contacts: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- }
-
- for (p = contacts; p; p = p->next)
- e_contact_map_add_contact (
- window->priv->map, (EContact *) p->data);
-
- e_client_util_free_object_slist (contacts);
- g_object_unref (client);
-}
-
-static void
-contact_map_window_zoom_in_cb (GtkButton *button,
- gpointer user_data)
-{
- EContactMapWindow *window = user_data;
- ChamplainView *view;
-
- view = e_contact_map_get_view (window->priv->map);
-
- champlain_view_zoom_in (view);
-}
-
-static void
-contact_map_window_zoom_out_cb (GtkButton *button,
- gpointer user_data)
-{
- EContactMapWindow *window = user_data;
- ChamplainView *view;
-
- view = e_contact_map_get_view (window->priv->map);
-
- champlain_view_zoom_out (view);
-}
-static void
-zoom_level_changed_cb (ChamplainView *view,
- GParamSpec *pspec,
- gpointer user_data)
-{
- EContactMapWindow *window = user_data;
- gint zoom_level = champlain_view_get_zoom_level (view);
-
- gtk_widget_set_sensitive (
- window->priv->zoom_in_btn,
- (zoom_level < champlain_view_get_max_zoom_level (view)));
-
- gtk_widget_set_sensitive (
- window->priv->zoom_out_btn,
- (zoom_level > champlain_view_get_min_zoom_level (view)));
-}
-
-/**
- * Add contact to hash_table only when EContactMap tells us
- * that the contact has really been added to map.
- */
-static void
-map_contact_added_cb (EContactMap *map,
- ClutterActor *marker,
- gpointer user_data)
-{
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
- const gchar *name;
- GtkTreeIter iter;
-
- name = champlain_label_get_text (CHAMPLAIN_LABEL (marker));
-
- g_hash_table_insert (
- priv->hash_table,
- g_strdup (name), marker);
-
- gtk_list_store_append (priv->completion_model, &iter);
- gtk_list_store_set (
- priv->completion_model, &iter,
- 0, name, -1);
-
- g_signal_connect (
- marker, "double-clicked",
- G_CALLBACK (marker_doubleclick_cb), user_data);
-
- priv->tasks_cnt--;
- if (priv->tasks_cnt == 0) {
- gtk_spinner_stop (GTK_SPINNER (priv->spinner));
- gtk_widget_hide (priv->spinner);
- }
-}
-
-static void
-map_contact_removed_cb (EContactMap *map,
- const gchar *name,
- gpointer user_data)
-{
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
- GtkTreeIter iter;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->completion_model);
-
- g_hash_table_remove (priv->hash_table, name);
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gchar *name_str;
- gtk_tree_model_get (model, &iter, 0, &name_str, -1);
- if (g_ascii_strcasecmp (name_str, name) == 0) {
- g_free (name_str);
- gtk_list_store_remove (priv->completion_model, &iter);
- break;
- }
- g_free (name_str);
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-}
-
-static void
-map_contact_geocoding_started_cb (EContactMap *map,
- ClutterActor *marker,
- gpointer user_data)
-{
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
-
- gtk_spinner_start (GTK_SPINNER (priv->spinner));
- gtk_widget_show (priv->spinner);
-
- priv->tasks_cnt++;
-}
-
-static void
-map_contact_geocoding_failed_cb (EContactMap *map,
- const gchar *name,
- gpointer user_data)
-{
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
-
- priv->tasks_cnt--;
-
- if (priv->tasks_cnt == 0) {
- gtk_spinner_stop (GTK_SPINNER (priv->spinner));
- gtk_widget_hide (priv->spinner);
- }
-}
-
-static void
-contact_map_window_find_contact_cb (GtkButton *button,
- gpointer user_data)
-{
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
- ClutterActor *marker;
-
- marker = g_hash_table_lookup (
- priv->hash_table,
- gtk_entry_get_text (GTK_ENTRY (priv->search_entry)));
-
- if (marker)
- e_contact_map_zoom_on_marker (priv->map, marker);
-}
-
-static gboolean
-contact_map_window_entry_key_pressed_cb (GtkWidget *entry,
- GdkEventKey *event,
- gpointer user_data)
-{
- if (event->keyval == GDK_KEY_Return)
- contact_map_window_find_contact_cb (NULL, user_data);
-
- return FALSE;
-}
-
-static gboolean
-entry_completion_match_selected_cb (GtkEntryCompletion *widget,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data)
-{
- GValue name_val = {0};
- EContactMapWindowPrivate *priv = E_CONTACT_MAP_WINDOW (user_data)->priv;
- const gchar *name;
-
- gtk_tree_model_get_value (model, iter, 0, &name_val);
- g_return_val_if_fail (G_VALUE_HOLDS_STRING (&name_val), FALSE);
-
- name = g_value_get_string (&name_val);
- gtk_entry_set_text (GTK_ENTRY (priv->search_entry), name);
-
- contact_map_window_find_contact_cb (NULL, user_data);
-
- return TRUE;
-}
-
-static void
-contact_map_window_finalize (GObject *object)
-{
- EContactMapWindowPrivate *priv;
-
- priv = E_CONTACT_MAP_WINDOW (object)->priv;
-
- if (priv->hash_table) {
- g_hash_table_destroy (priv->hash_table);
- priv->hash_table = NULL;
- }
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_contact_map_window_parent_class)->finalize (object);
-}
-
-static void
-contact_map_window_dispose (GObject *object)
-{
- EContactMapWindowPrivate *priv;
-
- priv = E_CONTACT_MAP_WINDOW (object)->priv;
-
- if (priv->map) {
- gtk_widget_destroy (GTK_WIDGET (priv->map));
- priv->map = NULL;
- }
-
- if (priv->completion_model) {
- g_object_unref (priv->completion_model);
- priv->completion_model = NULL;
- }
-
- G_OBJECT_CLASS (e_contact_map_window_parent_class)->dispose (object);
-}
-
-static void
-e_contact_map_window_class_init (EContactMapWindowClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EContactMapWindowPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = contact_map_window_finalize;
- object_class->dispose = contact_map_window_dispose;
-
- signals[SHOW_CONTACT_EDITOR] = g_signal_new (
- "show-contact-editor",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMapWindowClass, show_contact_editor),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-}
-
-static void
-e_contact_map_window_init (EContactMapWindow *window)
-{
- EContactMapWindowPrivate *priv;
- GtkWidget *map;
- GtkWidget *button, *entry;
- GtkWidget *hbox, *vbox, *viewport;
- GtkEntryCompletion *entry_completion;
- GtkListStore *completion_model;
- ChamplainView *view;
- GHashTable *hash_table;
-
- priv = E_CONTACT_MAP_WINDOW_GET_PRIVATE (window);
- window->priv = priv;
-
- priv->tasks_cnt = 0;
-
- hash_table = g_hash_table_new_full (
- (GHashFunc) g_str_hash,
- (GEqualFunc) g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) NULL);
- priv->hash_table = hash_table;
-
- gtk_window_set_title (GTK_WINDOW (window), _("Contacts Map"));
- gtk_container_set_border_width (GTK_CONTAINER (window), 12);
- gtk_widget_set_size_request (GTK_WIDGET (window), 800, 600);
-
- /* The map view itself */
- map = e_contact_map_new ();
- view = e_contact_map_get_view (E_CONTACT_MAP (map));
- champlain_view_set_zoom_level (view, 2);
- priv->map = E_CONTACT_MAP (map);
- g_signal_connect (
- view, "notify::zoom-level",
- G_CALLBACK (zoom_level_changed_cb), window);
- g_signal_connect (
- map, "contact-added",
- G_CALLBACK (map_contact_added_cb), window);
- g_signal_connect (
- map, "contact-removed",
- G_CALLBACK (map_contact_removed_cb), window);
- g_signal_connect (
- map, "geocoding-started",
- G_CALLBACK (map_contact_geocoding_started_cb), window);
- g_signal_connect (
- map, "geocoding-failed",
- G_CALLBACK (map_contact_geocoding_failed_cb), window);
-
- /* HBox container */
- hbox = gtk_hbox_new (FALSE, 7);
-
- /* Spinner */
- button = gtk_spinner_new ();
- gtk_container_add (GTK_CONTAINER (hbox), button);
- gtk_widget_hide (button);
- priv->spinner = button;
-
- /* Zoom-in button */
- button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_IN);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (contact_map_window_zoom_in_cb), window);
- priv->zoom_in_btn = button;
- gtk_container_add (GTK_CONTAINER (hbox), button);
-
- /* Zoom-out button */
- button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (contact_map_window_zoom_out_cb), window);
- priv->zoom_out_btn = button;
- gtk_container_add (GTK_CONTAINER (hbox), button);
-
- /* Completion model */
- completion_model = gtk_list_store_new (1, G_TYPE_STRING);
- priv->completion_model = completion_model;
-
- /* Entry completion */
- entry_completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (
- entry_completion, GTK_TREE_MODEL (completion_model));
- gtk_entry_completion_set_text_column (entry_completion, 0);
- g_signal_connect (
- entry_completion, "match-selected",
- G_CALLBACK (entry_completion_match_selected_cb), window);
-
- /* Search entry */
- entry = gtk_entry_new ();
- gtk_entry_set_completion (GTK_ENTRY (entry), entry_completion);
- g_signal_connect (
- entry, "key-press-event",
- G_CALLBACK (contact_map_window_entry_key_pressed_cb), window);
- window->priv->search_entry = entry;
- gtk_container_add (GTK_CONTAINER (hbox), entry);
-
- /* Search button */
- button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (contact_map_window_find_contact_cb), window);
- gtk_container_add (GTK_CONTAINER (hbox), button);
-
- viewport = gtk_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (viewport), map);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (vbox), viewport);
- gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- gtk_widget_show_all (vbox);
- gtk_widget_hide (priv->spinner);
-}
-
-EContactMapWindow *
-e_contact_map_window_new (void)
-{
- return g_object_new (
- E_TYPE_CONTACT_MAP_WINDOW, NULL);
-}
-
-/**
- * Gets all contacts from @book and puts them
- * on the map view
- */
-void
-e_contact_map_window_load_addressbook (EContactMapWindow *map,
- EBookClient *book_client)
-{
- EBookQuery *book_query;
- gchar *query_string;
-
- g_return_if_fail (E_IS_CONTACT_MAP_WINDOW (map));
- g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
-
- /* Reference book, so that it does not get deleted before the callback is
- * involved. The book is unrefed in the callback */
- g_object_ref (book_client);
-
- book_query = e_book_query_field_exists (E_CONTACT_ADDRESS);
- query_string = e_book_query_to_string (book_query);
- e_book_query_unref (book_query);
-
- e_book_client_get_contacts (
- book_client, query_string, NULL,
- book_contacts_received_cb, map);
-
- g_free (query_string);
-}
-
-EContactMap *
-e_contact_map_window_get_map (EContactMapWindow *window)
-{
- g_return_val_if_fail (E_IS_CONTACT_MAP_WINDOW (window), NULL);
-
- return window->priv->map;
-}
-
-#endif /* WITH_CONTACT_MAPS */
diff --git a/widgets/misc/e-contact-map-window.h b/widgets/misc/e-contact-map-window.h
deleted file mode 100644
index 821fe243d2..0000000000
--- a/widgets/misc/e-contact-map-window.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * e-contact-map-window.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- *
- */
-
-#ifndef E_CONTACT_MAP_WINDOW_H
-#define E_CONTACT_MAP_WINDOW_H
-
-#include <gtk/gtk.h>
-
-#include <libebook/libebook.h>
-
-#include <e-contact-map.h>
-
-/* Standard GObject macros */
-#define E_TYPE_CONTACT_MAP_WINDOW \
- (e_contact_map_window_get_type ())
-#define E_CONTACT_MAP_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CONTACT_MAP_WINDOW, EContactMapWindow))
-#define E_CONTACT_MAP_WINDOW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CONTACT_MAP_WINDOW, EContactMapWindowClass))
-#define E_IS_CONTACT_MAP_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CONTACT_MAP_WINDOW))
-#define E_IS_CONTACT_MAP_WINDOW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CONTACT_MAP_WINDOW))
-#define E_CONTACT_MAP_WINDOW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CONTACT_MAP_WINDOW, EContactMapWindowClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EContactMapWindow EContactMapWindow;
-typedef struct _EContactMapWindowClass EContactMapWindowClass;
-typedef struct _EContactMapWindowPrivate EContactMapWindowPrivate;
-
-struct _EContactMapWindow {
- GtkWindow parent;
- EContactMapWindowPrivate *priv;
-};
-
-struct _EContactMapWindowClass {
- GtkWindowClass parent_class;
-
- void (*show_contact_editor) (EContactMapWindow *window,
- const gchar *contact_uid);
-};
-
-GType e_contact_map_window_get_type (void) G_GNUC_CONST;
-EContactMapWindow * e_contact_map_window_new (void);
-
-void e_contact_map_window_load_addressbook (EContactMapWindow *window,
- EBookClient *book);
-
-EContactMap * e_contact_map_window_get_map (EContactMapWindow *window);
-
-G_END_DECLS
-
-#endif
diff --git a/widgets/misc/e-contact-map.c b/widgets/misc/e-contact-map.c
deleted file mode 100644
index 3ad17b441f..0000000000
--- a/widgets/misc/e-contact-map.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * e-contact-map.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WITH_CONTACT_MAPS
-
-#include "e-contact-map.h"
-#include "e-contact-marker.h"
-
-#include <e-util/e-marshal.h>
-
-#include <champlain/champlain.h>
-#include <champlain-gtk/champlain-gtk.h>
-#include <geoclue/geoclue-address.h>
-#include <geoclue/geoclue-position.h>
-#include <geocode-glib.h>
-
-#include <clutter/clutter.h>
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <math.h>
-
-#define E_CONTACT_MAP_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CONTACT_MAP, EContactMapPrivate))
-
-typedef struct _AsyncContext AsyncContext;
-
-struct _EContactMapPrivate {
- GHashTable *markers; /* Hash table contact-name -> marker */
-
- ChamplainMarkerLayer *marker_layer;
-};
-
-struct _AsyncContext {
- EContactMap *map;
- EContactMarker *marker;
-};
-
-enum {
- CONTACT_ADDED,
- CONTACT_REMOVED,
- GEOCODING_STARTED,
- GEOCODING_FAILED,
- LAST_SIGNAL
-};
-
-static gint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE (EContactMap, e_contact_map, GTK_CHAMPLAIN_TYPE_EMBED)
-
-static void
-async_context_free (AsyncContext *async_context)
-{
- if (async_context->map != NULL)
- g_object_unref (async_context->map);
-
- g_slice_free (AsyncContext, async_context);
-}
-
-static void
-contact_map_address_resolved_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- GHashTable *resolved = NULL;
- gpointer marker_ptr;
- const gchar *name;
- gdouble latitude, longitude;
- AsyncContext *async_context = user_data;
- ChamplainMarkerLayer *marker_layer;
- ChamplainMarker *marker;
- GError *error = NULL;
-
- g_return_if_fail (async_context != NULL);
- g_return_if_fail (E_IS_CONTACT_MAP (async_context->map));
- g_return_if_fail (E_IS_CONTACT_MARKER (async_context->marker));
-
- marker = CHAMPLAIN_MARKER (async_context->marker);
- marker_layer = async_context->map->priv->marker_layer;
-
- /* If the marker_layer does not exist anymore, the map has
- * probably been destroyed before this callback was launched.
- * It's not a failure, just silently clean up what was left
- * behind and pretend nothing happened. */
-
- if (!CHAMPLAIN_IS_MARKER_LAYER (marker_layer))
- goto exit;
-
- resolved = geocode_object_resolve_finish (
- GEOCODE_OBJECT (source), result, &error);
-
- if (resolved == NULL ||
- !geocode_object_get_coords (resolved, &longitude, &latitude)) {
- const gchar *name;
- if (error)
- g_error_free (error);
- name = champlain_label_get_text (CHAMPLAIN_LABEL (marker));
- g_signal_emit (
- async_context->map,
- signals[GEOCODING_FAILED], 0, name);
- goto exit;
- }
-
- /* Move the marker to resolved position */
- champlain_location_set_location (
- CHAMPLAIN_LOCATION (marker), latitude, longitude);
- champlain_marker_layer_add_marker (marker_layer, marker);
- champlain_marker_set_selected (marker, FALSE);
-
- /* Store the marker in the hash table. Use it's label as key */
- name = champlain_label_get_text (CHAMPLAIN_LABEL (marker));
- marker_ptr = g_hash_table_lookup (
- async_context->map->priv->markers, name);
- if (marker_ptr != NULL) {
- g_hash_table_remove (async_context->map->priv->markers, name);
- champlain_marker_layer_remove_marker (marker_layer, marker_ptr);
- }
- g_hash_table_insert (
- async_context->map->priv->markers,
- g_strdup (name), marker);
-
- g_signal_emit (
- async_context->map,
- signals[CONTACT_ADDED], 0, marker);
-
-exit:
- async_context_free (async_context);
-
- if (resolved != NULL)
- g_hash_table_unref (resolved);
-}
-
-static void
-resolve_marker_position (EContactMap *map,
- EContactMarker *marker,
- EContactAddress *address)
-{
- GeocodeObject *geocoder;
- AsyncContext *async_context;
- const gchar *key;
-
- g_return_if_fail (E_IS_CONTACT_MAP (map));
- g_return_if_fail (address != NULL);
-
- geocoder = geocode_object_new ();
-
- key = GEOCODE_OBJECT_FIELD_POSTAL;
- geocode_object_add (geocoder, key, address->code);
-
- key = GEOCODE_OBJECT_FIELD_COUNTRY;
- geocode_object_add (geocoder, key, address->country);
-
- key = GEOCODE_OBJECT_FIELD_STATE;
- geocode_object_add (geocoder, key, address->region);
-
- key = GEOCODE_OBJECT_FIELD_CITY;
- geocode_object_add (geocoder, key, address->locality);
-
- key = GEOCODE_OBJECT_FIELD_STREET;
- geocode_object_add (geocoder, key, address->street);
-
- async_context = g_slice_new0 (AsyncContext);
- async_context->map = g_object_ref (map);
- async_context->marker = marker;
-
- geocode_object_resolve_async (
- geocoder, NULL,
- contact_map_address_resolved_cb,
- async_context);
-
- g_object_unref (geocoder);
-
- g_signal_emit (map, signals[GEOCODING_STARTED], 0, marker);
-}
-
-static void
-contact_map_finalize (GObject *object)
-{
- EContactMapPrivate *priv;
-
- priv = E_CONTACT_MAP (object)->priv;
-
- if (priv->markers) {
- g_hash_table_destroy (priv->markers);
- priv->markers = NULL;
- }
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_contact_map_parent_class)->finalize (object);
-}
-
-static void
-e_contact_map_class_init (EContactMapClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EContactMapPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = contact_map_finalize;
-
- signals[CONTACT_ADDED] = g_signal_new (
- "contact-added",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMapClass, contact_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[CONTACT_REMOVED] = g_signal_new (
- "contact-removed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMapClass, contact_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- signals[GEOCODING_STARTED] = g_signal_new (
- "geocoding-started",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMapClass, geocoding_started),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[GEOCODING_FAILED] = g_signal_new (
- "geocoding-failed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMapClass, geocoding_failed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-}
-
-static void
-e_contact_map_init (EContactMap *map)
-{
- GHashTable *hash_table;
- ChamplainMarkerLayer *layer;
- ChamplainView *view;
-
- map->priv = E_CONTACT_MAP_GET_PRIVATE (map);
-
- hash_table = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free, NULL);
-
- map->priv->markers = hash_table;
-
- view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (map));
- /* This feature is somehow broken sometimes, so disable it for now */
- champlain_view_set_zoom_on_double_click (view, FALSE);
- layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE);
- champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer));
- map->priv->marker_layer = layer;
-}
-
-GtkWidget *
-e_contact_map_new (void)
-{
- return g_object_new (
- E_TYPE_CONTACT_MAP,NULL);
-}
-
-void
-e_contact_map_add_contact (EContactMap *map,
- EContact *contact)
-{
- EContactAddress *address;
- EContactPhoto *photo;
- const gchar *contact_uid;
- gchar *name;
-
- g_return_if_fail (map && E_IS_CONTACT_MAP (map));
- g_return_if_fail (contact && E_IS_CONTACT (contact));
-
- photo = e_contact_get (contact, E_CONTACT_PHOTO);
- contact_uid = e_contact_get_const (contact, E_CONTACT_UID);
-
- address = e_contact_get (contact, E_CONTACT_ADDRESS_HOME);
- if (address) {
- name = g_strconcat (e_contact_get_const (contact, E_CONTACT_FILE_AS), " (", _("Home"), ")", NULL);
- e_contact_map_add_marker (map, name, contact_uid, address, photo);
- g_free (name);
- e_contact_address_free (address);
- }
-
- address = e_contact_get (contact, E_CONTACT_ADDRESS_WORK);
- if (address) {
- name = g_strconcat (e_contact_get_const (contact, E_CONTACT_FILE_AS), " (", _("Work"), ")", NULL);
- e_contact_map_add_marker (map, name, contact_uid, address, photo);
- g_free (name);
- e_contact_address_free (address);
- }
-
- if (photo)
- e_contact_photo_free (photo);
-}
-
-void
-e_contact_map_add_marker (EContactMap *map,
- const gchar *name,
- const gchar *contact_uid,
- EContactAddress *address,
- EContactPhoto *photo)
-{
- EContactMarker *marker;
-
- g_return_if_fail (map && E_IS_CONTACT_MAP (map));
- g_return_if_fail (name && *name);
- g_return_if_fail (contact_uid && *contact_uid);
- g_return_if_fail (address);
-
- marker = E_CONTACT_MARKER (e_contact_marker_new (name, contact_uid, photo));
-
- resolve_marker_position (map, marker, address);
-}
-
-/**
- * The \name parameter must match the label of the
- * marker (for example "John Smith (work)")
- */
-void
-e_contact_map_remove_contact (EContactMap *map,
- const gchar *name)
-{
- ChamplainMarker *marker;
-
- g_return_if_fail (map && E_IS_CONTACT_MAP (map));
- g_return_if_fail (name && *name);
-
- marker = g_hash_table_lookup (map->priv->markers, name);
-
- champlain_marker_layer_remove_marker (map->priv->marker_layer, marker);
-
- g_hash_table_remove (map->priv->markers, name);
-
- g_signal_emit (map, signals[CONTACT_REMOVED], 0, name);
-}
-
-void
-e_contact_map_remove_marker (EContactMap *map,
- ClutterActor *marker)
-{
- const gchar *name;
-
- g_return_if_fail (map && E_IS_CONTACT_MAP (map));
- g_return_if_fail (marker && CLUTTER_IS_ACTOR (marker));
-
- name = champlain_label_get_text (CHAMPLAIN_LABEL (marker));
-
- e_contact_map_remove_contact (map, name);
-}
-
-void
-e_contact_map_zoom_on_marker (EContactMap *map,
- ClutterActor *marker)
-{
- ChamplainView *view;
- gdouble lat, lng;
-
- g_return_if_fail (map && E_IS_CONTACT_MAP (map));
- g_return_if_fail (marker && CLUTTER_IS_ACTOR (marker));
-
- lat = champlain_location_get_latitude (CHAMPLAIN_LOCATION (marker));
- lng = champlain_location_get_longitude (CHAMPLAIN_LOCATION (marker));
-
- view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (map));
-
- champlain_view_center_on (view, lat, lng);
- champlain_view_set_zoom_level (view, 15);
-}
-
-ChamplainView *
-e_contact_map_get_view (EContactMap *map)
-{
- g_return_val_if_fail (E_IS_CONTACT_MAP (map), NULL);
-
- return gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (map));
-}
-
-#endif /* WITH_CONTACT_MAPS */
diff --git a/widgets/misc/e-contact-map.h b/widgets/misc/e-contact-map.h
deleted file mode 100644
index d9503e2c9b..0000000000
--- a/widgets/misc/e-contact-map.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * e-contact-map.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- *
- */
-
-#ifndef E_CONTACT_MAP_H
-#define E_CONTACT_MAP_H
-
-#ifdef WITH_CONTACT_MAPS
-
-#include <gtk/gtk.h>
-
-#include <champlain/champlain.h>
-#include <champlain-gtk/champlain-gtk.h>
-
-#include <libebook/libebook.h>
-
-/* Standard GObject macros */
-#define E_TYPE_CONTACT_MAP \
- (e_contact_map_get_type ())
-#define E_CONTACT_MAP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_CONTACT_MAP, EContactMap))
-#define E_CONTACT_MAP_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_CONTACT_MAP, EContactMapClass))
-#define E_IS_CONTACT_MAP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_CONTACT_MAP))
-#define E_IS_CONTACT_MAP_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_CONTACT_MAP))
-#define E_CONTACT_MAP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_CONTACT_MAP, EContactMapClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EContactMap EContactMap;
-typedef struct _EContactMapClass EContactMapClass;
-typedef struct _EContactMapPrivate EContactMapPrivate;
-
-struct _EContactMap {
- GtkChamplainEmbed parent;
- EContactMapPrivate *priv;
-};
-
-struct _EContactMapClass {
- GtkWindowClass parent_class;
-
- void (*contact_added) (EContactMap *map,
- ClutterActor *marker);
-
- void (*contact_removed) (EContactMap *map,
- const gchar *name);
-
- void (*geocoding_started) (EContactMap *map,
- ClutterActor *marker);
-
- void (*geocoding_failed) (EContactMap *map,
- const gchar *name);
-};
-
-GType e_contact_map_get_type (void) G_GNUC_CONST;
-GtkWidget * e_contact_map_new (void);
-
-void e_contact_map_add_contact (EContactMap *map,
- EContact *contact);
-
-void e_contact_map_add_marker (EContactMap *map,
- const gchar *name,
- const gchar *contact_uid,
- EContactAddress *address,
- EContactPhoto *photo);
-
-void e_contact_map_remove_contact (EContactMap *map,
- const gchar *name);
-
-void e_contact_map_remove_marker (EContactMap *map,
- ClutterActor *marker);
-
-void e_contact_map_zoom_on_marker (EContactMap *map,
- ClutterActor *marker);
-
-ChamplainView * e_contact_map_get_view (EContactMap *map);
-
-G_END_DECLS
-
-#endif /* WITH_CONTACT_MAPS */
-
-#endif
diff --git a/widgets/misc/e-contact-marker.c b/widgets/misc/e-contact-marker.c
deleted file mode 100644
index 9ac9417c9f..0000000000
--- a/widgets/misc/e-contact-marker.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * e-contact-marker.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
- * Copyright (C) 2011 Jiri Techet <techet@gmail.com>
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WITH_CONTACT_MAPS
-
-#include "e-contact-marker.h"
-
-#include <champlain/champlain.h>
-#include <gtk/gtk.h>
-#include <clutter/clutter.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <glib-object.h>
-#include <cairo.h>
-#include <math.h>
-#include <string.h>
-
-#define E_CONTACT_MARKER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CONTACT_MARKER, EContactMarkerPrivate))
-
-G_DEFINE_TYPE (EContactMarker, e_contact_marker, CHAMPLAIN_TYPE_LABEL);
-
-struct _EContactMarkerPrivate
-{
- gchar *contact_uid;
-
- ClutterActor *image;
- ClutterActor *text_actor;
-
- ClutterActor *shadow;
- ClutterActor *background;
-
- guint total_width;
- guint total_height;
-
- ClutterGroup *content_group;
-
- guint redraw_id;
-};
-
-enum {
- DOUBLE_CLICKED,
- LAST_SIGNAL
-};
-
-static gint signals[LAST_SIGNAL] = {0};
-
-#define DEFAULT_FONT_NAME "Serif 9"
-
-static ClutterColor DEFAULT_COLOR = { 0x33, 0x33, 0x33, 0xff };
-
-#define RADIUS 10
-#define PADDING (RADIUS / 2)
-
-static gboolean
-contact_marker_clicked_cb (ClutterActor *actor,
- ClutterEvent *event,
- gpointer user_data)
-{
- gint click_count = clutter_event_get_click_count (event);
-
- if (click_count == 2)
- g_signal_emit (E_CONTACT_MARKER (actor), signals[DOUBLE_CLICKED], 0);
-
- return TRUE;
-}
-
-static ClutterActor *
-texture_new_from_pixbuf (GdkPixbuf *pixbuf,
- GError **error)
-{
- ClutterActor *texture = NULL;
- const guchar *data;
- gboolean has_alpha, success;
- gint width, height, rowstride;
- ClutterTextureFlags flags = 0;
-
- data = gdk_pixbuf_get_pixels (pixbuf);
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-
- texture = clutter_texture_new ();
- success = clutter_texture_set_from_rgb_data (
- CLUTTER_TEXTURE (texture),
- data, has_alpha, width, height, rowstride,
- (has_alpha ? 4: 3), flags, NULL);
-
- if (!success) {
- clutter_actor_destroy (CLUTTER_ACTOR (texture));
- texture = NULL;
- }
-
- return texture;
-}
-
-static ClutterActor *
-contact_photo_to_texture (EContactPhoto *photo)
-{
- GdkPixbuf *pixbuf;
-
- if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
- GError *error = NULL;
-
- GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
- gdk_pixbuf_loader_write (
- loader, photo->data.inlined.data,
- photo->data.inlined.length, NULL);
- gdk_pixbuf_loader_close (loader, NULL);
- pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
- if (pixbuf)
- g_object_ref (pixbuf);
- g_object_unref (loader);
-
- if (error) {
- g_error_free (error);
- return NULL;
- }
- } else if (photo->type == E_CONTACT_PHOTO_TYPE_URI) {
- GError *error = NULL;
-
- pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, &error);
-
- if (error) {
- g_error_free (error);
- return NULL;
- }
- } else
- return NULL;
-
- if (pixbuf) {
- ClutterActor *texture;
- GError *error = NULL;
-
- texture = texture_new_from_pixbuf (pixbuf, &error);
- if (error) {
- g_error_free (error);
- g_object_unref (pixbuf);
- return NULL;
- }
-
- g_object_unref (pixbuf);
- return texture;
- }
-
- return NULL;
-}
-
-static void
-draw_box (cairo_t *cr,
- gint width,
- gint height,
- gint point)
-{
- cairo_move_to (cr, RADIUS, 0);
- cairo_line_to (cr, width - RADIUS, 0);
- cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0);
- cairo_line_to (cr, width, height - RADIUS);
- cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0);
- cairo_line_to (cr, point, height);
- cairo_line_to (cr, 0, height + point);
- cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0);
- cairo_close_path (cr);
-}
-
-static void
-draw_shadow (EContactMarker *marker,
- gint width,
- gint height,
- gint point)
-{
- EContactMarkerPrivate *priv = marker->priv;
- ClutterActor *shadow = NULL;
- cairo_t *cr;
- gdouble slope;
- gdouble scaling;
- gint x;
- cairo_matrix_t matrix;
-
- slope = -0.3;
- scaling = 0.65;
- x = -40 * slope;
-
- shadow = clutter_cairo_texture_new (width + x, (height + point));
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (shadow));
-
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-
- cairo_matrix_init (&matrix, 1, 0, slope, scaling, x, 0);
- cairo_set_matrix (cr, &matrix);
-
- draw_box (cr, width, height, point);
-
- cairo_set_source_rgba (cr, 0, 0, 0, 0.15);
- cairo_fill (cr);
-
- cairo_destroy (cr);
-
- clutter_actor_set_position (shadow, 0, height / 2.0);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), shadow);
-
- if (priv->shadow != NULL) {
- clutter_container_remove_actor (
- CLUTTER_CONTAINER (priv->content_group),
- priv->shadow);
- }
-
- priv->shadow = shadow;
-}
-
-static void
-draw_background (EContactMarker *marker,
- gint width,
- gint height,
- gint point)
-{
- EContactMarkerPrivate *priv = marker->priv;
- ClutterActor *bg = NULL;
- const ClutterColor *color;
- ClutterColor darker_color;
- cairo_t *cr;
-
- bg = clutter_cairo_texture_new (width, height + point);
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
-
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-
- /* If selected, add the selection color to the marker's color */
- if (champlain_marker_get_selected (CHAMPLAIN_MARKER (marker)))
- color = champlain_marker_get_selection_color ();
- else
- color = &DEFAULT_COLOR;
-
- draw_box (cr, width, height, point);
-
- clutter_color_darken (color, &darker_color);
-
- cairo_set_source_rgba (
- cr,
- color->red / 255.0,
- color->green / 255.0,
- color->blue / 255.0,
- color->alpha / 255.0);
- cairo_fill_preserve (cr);
-
- cairo_set_line_width (cr, 1.0);
- cairo_set_source_rgba (
- cr,
- darker_color.red / 255.0,
- darker_color.green / 255.0,
- darker_color.blue / 255.0,
- darker_color.alpha / 255.0);
- cairo_stroke (cr);
- cairo_destroy (cr);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->content_group), bg);
-
- if (priv->background != NULL) {
- clutter_container_remove_actor (
- CLUTTER_CONTAINER (priv->content_group),
- priv->background);
- }
-
- priv->background = bg;
-}
-
-static void
-draw_marker (EContactMarker *marker)
-{
- EContactMarkerPrivate *priv = marker->priv;
- ChamplainLabel *label = CHAMPLAIN_LABEL (marker);
- guint height = 0, point = 0;
- guint total_width = 0, total_height = 0;
- ClutterText *text;
-
- if (priv->image) {
- clutter_actor_set_position (priv->image, 2 *PADDING, 2 *PADDING);
- if (clutter_actor_get_parent (priv->image) == NULL)
- clutter_container_add_actor (
- CLUTTER_CONTAINER (priv->content_group),
- priv->image);
- }
-
- if (priv->text_actor == NULL) {
- priv->text_actor = clutter_text_new_with_text (
- "Serif 8",
- champlain_label_get_text (label));
- champlain_label_set_font_name (label, "Serif 8");
- }
-
- text = CLUTTER_TEXT (priv->text_actor);
- clutter_text_set_text (
- text,
- champlain_label_get_text (label));
- clutter_text_set_font_name (
- text,
- champlain_label_get_font_name (label));
- clutter_text_set_line_alignment (text, PANGO_ALIGN_CENTER);
- clutter_text_set_line_wrap (text, TRUE);
- clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD);
- clutter_text_set_ellipsize (
- text,
- champlain_label_get_ellipsize (label));
- clutter_text_set_attributes (
- text,
- champlain_label_get_attributes (label));
- clutter_text_set_use_markup (
- text,
- champlain_label_get_use_markup (label));
-
- if (priv->image) {
- clutter_actor_set_width (
- priv->text_actor,
- clutter_actor_get_width (priv->image));
- total_height = clutter_actor_get_height (priv->image) + 2 *PADDING +
- clutter_actor_get_height (priv->text_actor) + 2 *PADDING;
- total_width = clutter_actor_get_width (priv->image) + 4 *PADDING;
- clutter_actor_set_position (
- priv->text_actor, PADDING,
- clutter_actor_get_height (priv->image) + 2 *PADDING + 3);
- } else {
- total_height = clutter_actor_get_height (priv->text_actor) + 2 *PADDING;
- total_width = clutter_actor_get_width (priv->text_actor) + 4 *PADDING;
- clutter_actor_set_position (priv->text_actor, 2 * PADDING, PADDING);
- }
-
- height += 2 * PADDING;
- if (height > total_height)
- total_height = height;
-
- clutter_text_set_color (
- CLUTTER_TEXT (priv->text_actor),
- (champlain_marker_get_selected (CHAMPLAIN_MARKER (marker)) ?
- champlain_marker_get_selection_text_color () :
- champlain_label_get_text_color (CHAMPLAIN_LABEL (marker))));
- if (clutter_actor_get_parent (priv->text_actor) == NULL)
- clutter_container_add_actor (
- CLUTTER_CONTAINER (priv->content_group),
- priv->text_actor);
-
- if (priv->text_actor == NULL && priv->image == NULL) {
- total_width = 6 * PADDING;
- total_height = 6 * PADDING;
- }
-
- point = (total_height + 2 * PADDING) / 4.0;
- priv->total_width = total_width;
- priv->total_height = total_height;
-
- draw_shadow (marker, total_width, total_height, point);
- draw_background (marker, total_width, total_height, point);
-
- if (priv->text_actor != NULL && priv->background != NULL)
- clutter_actor_raise (priv->text_actor, priv->background);
- if (priv->image != NULL && priv->background != NULL)
- clutter_actor_raise (priv->image, priv->background);
-
- clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), 0, total_height + point);
-}
-
-static gboolean
-redraw_on_idle (gpointer gobject)
-{
- EContactMarker *marker = E_CONTACT_MARKER (gobject);
-
- draw_marker (marker);
- marker->priv->redraw_id = 0;
- return FALSE;
-}
-
-static void
-queue_redraw (EContactMarker *marker)
-{
- EContactMarkerPrivate *priv = marker->priv;
-
- if (!priv->redraw_id) {
- priv->redraw_id = g_idle_add_full (
- G_PRIORITY_DEFAULT,
- (GSourceFunc) redraw_on_idle,
- g_object_ref (marker),
- (GDestroyNotify) g_object_unref);
- }
-}
-
-static void
-allocate (ClutterActor *self,
- const ClutterActorBox *box,
- ClutterAllocationFlags flags)
-{
- ClutterActorBox child_box;
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (self)->priv;
-
- CLUTTER_ACTOR_CLASS (e_contact_marker_parent_class)->allocate (self, box, flags);
-
- child_box.x1 = 0;
- child_box.x2 = box->x2 - box->x1;
- child_box.y1 = 0;
- child_box.y2 = box->y2 - box->y1;
- clutter_actor_allocate (CLUTTER_ACTOR (priv->content_group), &child_box, flags);
-}
-
-static void
-paint (ClutterActor *self)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (self)->priv;
-
- clutter_actor_paint (CLUTTER_ACTOR (priv->content_group));
-}
-
-static void
-map (ClutterActor *self)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (self)->priv;
-
- CLUTTER_ACTOR_CLASS (e_contact_marker_parent_class)->map (self);
-
- clutter_actor_map (CLUTTER_ACTOR (priv->content_group));
-}
-
-static void
-unmap (ClutterActor *self)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (self)->priv;
-
- CLUTTER_ACTOR_CLASS (e_contact_marker_parent_class)->unmap (self);
-
- clutter_actor_unmap (CLUTTER_ACTOR (priv->content_group));
-}
-
-static void
-pick (ClutterActor *self,
- const ClutterColor *color)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (self)->priv;
- gfloat width, height;
-
- if (!clutter_actor_should_pick_paint (self))
- return;
-
- width = priv->total_width;
- height = priv->total_height;
-
- cogl_path_new ();
-
- cogl_set_source_color4ub (
- color->red,
- color->green,
- color->blue,
- color->alpha);
-
- cogl_path_move_to (RADIUS, 0);
- cogl_path_line_to (width - RADIUS, 0);
- cogl_path_arc (width - RADIUS, RADIUS, RADIUS, RADIUS, -90, 0);
- cogl_path_line_to (width, height - RADIUS);
- cogl_path_arc (width - RADIUS, height - RADIUS, RADIUS, RADIUS, 0, 90);
- cogl_path_line_to (RADIUS, height);
- cogl_path_arc (RADIUS, height - RADIUS, RADIUS, RADIUS, 90, 180);
- cogl_path_line_to (0, RADIUS);
- cogl_path_arc (RADIUS, RADIUS, RADIUS, RADIUS, 180, 270);
- cogl_path_close ();
- cogl_path_fill ();
-}
-
-static void
-notify_selected (GObject *gobject,
- G_GNUC_UNUSED GParamSpec *pspec,
- G_GNUC_UNUSED gpointer user_data)
-{
- queue_redraw (E_CONTACT_MARKER (gobject));
-}
-
-static void
-e_contact_marker_finalize (GObject *object)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (object)->priv;
-
- if (priv->contact_uid) {
- g_free (priv->contact_uid);
- priv->contact_uid = NULL;
- }
-
- if (priv->redraw_id) {
- g_source_remove (priv->redraw_id);
- priv->redraw_id = 0;
- }
-
- G_OBJECT_CLASS (e_contact_marker_parent_class)->finalize (object);
-}
-
-static void
-e_contact_marker_dispose (GObject *object)
-{
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (object)->priv;
-
- priv->background = NULL;
- priv->shadow = NULL;
- priv->text_actor = NULL;
-
- if (priv->content_group) {
- clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
- priv->content_group = NULL;
- }
-
- G_OBJECT_CLASS (e_contact_marker_parent_class)->dispose (object);
-}
-
-static void
-e_contact_marker_class_init (EContactMarkerClass *class)
-{
- ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (class);
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- g_type_class_add_private (class, sizeof (EContactMarkerPrivate));
-
- object_class->dispose = e_contact_marker_dispose;
- object_class->finalize = e_contact_marker_finalize;
-
- actor_class->paint = paint;
- actor_class->allocate = allocate;
- actor_class->map = map;
- actor_class->unmap = unmap;
- actor_class->pick = pick;
-
- signals[DOUBLE_CLICKED] = g_signal_new (
- "double-clicked",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactMarkerClass, double_clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_contact_marker_init (EContactMarker *marker)
-{
- EContactMarkerPrivate *priv;
-
- priv = E_CONTACT_MARKER_GET_PRIVATE (marker);
-
- marker->priv = priv;
- priv->contact_uid = NULL;
- priv->image = NULL;
- priv->background = NULL;
- priv->shadow = NULL;
- priv->text_actor = NULL;
- priv->content_group = CLUTTER_GROUP (clutter_group_new ());
- priv->redraw_id = 0;
-
- clutter_actor_set_parent (
- CLUTTER_ACTOR (priv->content_group), CLUTTER_ACTOR (marker));
- clutter_actor_queue_relayout (CLUTTER_ACTOR (marker));
-
- priv->total_width = 0;
- priv->total_height = 0;
-
- g_signal_connect (
- marker, "notify::selected",
- G_CALLBACK (notify_selected), NULL);
- g_signal_connect (
- marker, "button-release-event",
- G_CALLBACK (contact_marker_clicked_cb), NULL);
-}
-
-ClutterActor *
-e_contact_marker_new (const gchar *name,
- const gchar *contact_uid,
- EContactPhoto *photo)
-{
- ClutterActor *marker = CLUTTER_ACTOR (g_object_new (E_TYPE_CONTACT_MARKER, NULL));
- EContactMarkerPrivate *priv = E_CONTACT_MARKER (marker)->priv;
-
- g_return_val_if_fail (name && *name, NULL);
- g_return_val_if_fail (contact_uid && *contact_uid, NULL);
-
- champlain_label_set_text (CHAMPLAIN_LABEL (marker), name);
- priv->contact_uid = g_strdup (contact_uid);
- if (photo)
- priv->image = contact_photo_to_texture (photo);
-
- queue_redraw (E_CONTACT_MARKER (marker));
-
- return marker;
-}
-
-const gchar *
-e_contact_marker_get_contact_uid (EContactMarker *marker)
-{
- g_return_val_if_fail (marker && E_IS_CONTACT_MARKER (marker), NULL);
-
- return marker->priv->contact_uid;
-}
-
-#endif /* WITH_CONTACT_MAPS */
diff --git a/widgets/misc/e-contact-marker.h b/widgets/misc/e-contact-marker.h
deleted file mode 100644
index 791a9c46b5..0000000000
--- a/widgets/misc/e-contact-marker.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * e-contact-marker.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
- * Copyright (C) 2011 Jiri Techet <techet@gmail.com>
- * Copyright (C) 2011 Dan Vratil <dvratil@redhat.com>
- *
- */
-
-#ifndef E_CONTACT_MARKER_H
-#define E_CONTACT_MARKER_H
-
-#ifdef WITH_CONTACT_MAPS
-
-#include <libebook/libebook.h>
-
-#include <champlain/champlain.h>
-
-#include <glib-object.h>
-#include <clutter/clutter.h>
-
-G_BEGIN_DECLS
-
-#define E_TYPE_CONTACT_MARKER e_contact_marker_get_type ()
-
-#define E_CONTACT_MARKER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_MARKER, EContactMarker))
-
-#define E_CONTACT_MARKER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_MARKER, EContactMarkerClass))
-
-#define E_IS_CONTACT_MARKER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_MARKER))
-
-#define E_IS_CONTACT_MARKER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CONTACT_MARKER))
-
-#define E_CONTACT_MARKER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_CONTACT_MARKER, EContactMarkerClass))
-
-typedef struct _EContactMarkerPrivate EContactMarkerPrivate;
-
-typedef struct _EContactMarker EContactMarker;
-typedef struct _EContactMarkerClass EContactMarkerClass;
-
-struct _EContactMarker
-{
- ChamplainLabel parent;
- EContactMarkerPrivate *priv;
-};
-
-struct _EContactMarkerClass
-{
- ChamplainLabelClass parent_class;
-
- void (*double_clicked) (ClutterActor *actor);
-};
-
-GType e_contact_marker_get_type (void);
-
-ClutterActor * e_contact_marker_new (const gchar *name,
- const gchar *contact_uid,
- EContactPhoto *photo);
-
-const gchar * e_contact_marker_get_contact_uid (EContactMarker *marker);
-
-G_END_DECLS
-
-#endif /* WITH_CONTACT_MAPS */
-
-#endif
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
deleted file mode 100644
index fd2676a6b4..0000000000
--- a/widgets/misc/e-dateedit.c
+++ /dev/null
@@ -1,2498 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library 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 Library General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-/*
- * EDateEdit - a widget based on GnomeDateEdit to provide a date & optional
- * time field with popups for entering a date.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-dateedit.h"
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <atk/atkrelation.h>
-#include <atk/atkrelationset.h>
-#include <glib/gi18n.h>
-
-#include <libebackend/libebackend.h>
-
-#include <e-util/e-util.h>
-#include "e-calendar.h"
-
-#define E_DATE_EDIT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_DATE_EDIT, EDateEditPrivate))
-
-struct _EDateEditPrivate {
- GtkWidget *date_entry;
- GtkWidget *date_button;
-
- GtkWidget *space;
-
- GtkWidget *time_combo;
-
- GtkWidget *cal_popup;
- GtkWidget *calendar;
- GtkWidget *now_button;
- GtkWidget *today_button;
- GtkWidget *none_button; /* This will only be visible if a
- * 'None' date/time is permitted. */
-
- GdkDevice *grabbed_keyboard;
- GdkDevice *grabbed_pointer;
-
- gboolean show_date;
- gboolean show_time;
- gboolean use_24_hour_format;
-
- /* This is TRUE if we want to make the time field insensitive rather
- * than hide it when set_show_time() is called. */
- gboolean make_time_insensitive;
-
- /* This is the range of hours we show in the time popup. */
- gint lower_hour;
- gint upper_hour;
-
- /* This indicates whether the last date committed was invalid.
- * (A date is committed by hitting Return, moving the keyboard focus,
- * or selecting a date in the popup). Note that this only indicates
- * that the date couldn't be parsed. A date set to 'None' is valid
- * here, though e_date_edit_date_is_valid() will return FALSE if an
- * empty date isn't actually permitted. */
- gboolean date_is_valid;
-
- /* This is the last valid date which was set. If the date was set to
- * 'None' or empty, date_set_to_none will be TRUE and the other fields
- * are undefined, so don't use them. */
- gboolean date_set_to_none;
- gint year;
- gint month;
- gint day;
-
- /* This indicates whether the last time committed was invalid.
- * (A time is committed by hitting Return, moving the keyboard focus,
- * or selecting a time in the popup). Note that this only indicates
- * that the time couldn't be parsed. An empty/None time is valid
- * here, though e_date_edit_time_is_valid() will return FALSE if an
- * empty time isn't actually permitted. */
- gboolean time_is_valid;
-
- /* This is the last valid time which was set. If the time was set to
- * 'None' or empty, time_set_to_none will be TRUE and the other fields
- * are undefined, so don't use them. */
- gboolean time_set_to_none;
- gint hour;
- gint minute;
-
- EDateEditGetTimeCallback time_callback;
- gpointer time_callback_data;
- GDestroyNotify time_callback_destroy;
-
- gboolean twodigit_year_can_future;
-
- /* set to TRUE when the date has been changed by typing to the entry */
- gboolean has_been_changed;
-
- gboolean allow_no_date_set;
-};
-
-enum {
- PROP_0,
- PROP_ALLOW_NO_DATE_SET,
- PROP_SHOW_DATE,
- PROP_SHOW_TIME,
- PROP_SHOW_WEEK_NUMBERS,
- PROP_USE_24_HOUR_FORMAT,
- PROP_WEEK_START_DAY,
- PROP_TWODIGIT_YEAR_CAN_FUTURE,
- PROP_SET_NONE
-};
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-static void create_children (EDateEdit *dedit);
-static gboolean e_date_edit_mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling);
-static void e_date_edit_grab_focus (GtkWidget *widget);
-
-static gint on_date_entry_key_press (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit);
-static gint on_date_entry_key_release (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit);
-static void on_date_button_clicked (GtkWidget *widget,
- EDateEdit *dedit);
-static void e_date_edit_show_date_popup (EDateEdit *dedit,
- GdkEvent *event);
-static void position_date_popup (EDateEdit *dedit);
-static void on_date_popup_none_button_clicked (GtkWidget *button,
- EDateEdit *dedit);
-static void on_date_popup_today_button_clicked (GtkWidget *button,
- EDateEdit *dedit);
-static void on_date_popup_now_button_clicked (GtkWidget *button,
- EDateEdit *dedit);
-static gint on_date_popup_delete_event (GtkWidget *widget,
- EDateEdit *dedit);
-static gint on_date_popup_key_press (GtkWidget *widget,
- GdkEventKey *event,
- EDateEdit *dedit);
-static gint on_date_popup_button_press (GtkWidget *widget,
- GdkEvent *button_event,
- gpointer data);
-static void on_date_popup_date_selected (ECalendarItem *calitem,
- EDateEdit *dedit);
-static void hide_date_popup (EDateEdit *dedit);
-static void rebuild_time_popup (EDateEdit *dedit);
-static gboolean field_set_to_none (const gchar *text);
-static gboolean e_date_edit_parse_date (EDateEdit *dedit,
- const gchar *date_text,
- struct tm *date_tm);
-static gboolean e_date_edit_parse_time (EDateEdit *dedit,
- const gchar *time_text,
- struct tm *time_tm);
-static void on_date_edit_time_selected (GtkComboBox *combo,
- EDateEdit *dedit);
-static gint on_time_entry_key_press (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit);
-static gint on_time_entry_key_release (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit);
-static gint on_date_entry_focus_out (GtkEntry *entry,
- GdkEventFocus *event,
- EDateEdit *dedit);
-static gint on_time_entry_focus_out (GtkEntry *entry,
- GdkEventFocus *event,
- EDateEdit *dedit);
-static void e_date_edit_update_date_entry (EDateEdit *dedit);
-static void e_date_edit_update_time_entry (EDateEdit *dedit);
-static void e_date_edit_update_time_combo_state (EDateEdit *dedit);
-static void e_date_edit_check_date_changed (EDateEdit *dedit);
-static void e_date_edit_check_time_changed (EDateEdit *dedit);
-static gboolean e_date_edit_set_date_internal (EDateEdit *dedit,
- gboolean valid,
- gboolean none,
- gint year,
- gint month,
- gint day);
-static gboolean e_date_edit_set_time_internal (EDateEdit *dedit,
- gboolean valid,
- gboolean none,
- gint hour,
- gint minute);
-
-static gint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (
- EDateEdit,
- e_date_edit,
- GTK_TYPE_HBOX,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-static void
-date_edit_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ALLOW_NO_DATE_SET:
- e_date_edit_set_allow_no_date_set (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SHOW_DATE:
- e_date_edit_set_show_date (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SHOW_TIME:
- e_date_edit_set_show_time (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SHOW_WEEK_NUMBERS:
- e_date_edit_set_show_week_numbers (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_USE_24_HOUR_FORMAT:
- e_date_edit_set_use_24_hour_format (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_WEEK_START_DAY:
- e_date_edit_set_week_start_day (
- E_DATE_EDIT (object),
- g_value_get_int (value));
- return;
-
- case PROP_TWODIGIT_YEAR_CAN_FUTURE:
- e_date_edit_set_twodigit_year_can_future (
- E_DATE_EDIT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SET_NONE:
- if (g_value_get_boolean (value))
- e_date_edit_set_time (E_DATE_EDIT (object), -1);
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-date_edit_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ALLOW_NO_DATE_SET:
- g_value_set_boolean (
- value, e_date_edit_get_allow_no_date_set (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_SHOW_DATE:
- g_value_set_boolean (
- value, e_date_edit_get_show_date (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_SHOW_TIME:
- g_value_set_boolean (
- value, e_date_edit_get_show_time (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_SHOW_WEEK_NUMBERS:
- g_value_set_boolean (
- value, e_date_edit_get_show_week_numbers (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_USE_24_HOUR_FORMAT:
- g_value_set_boolean (
- value, e_date_edit_get_use_24_hour_format (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_WEEK_START_DAY:
- g_value_set_int (
- value, e_date_edit_get_week_start_day (
- E_DATE_EDIT (object)));
- return;
-
- case PROP_TWODIGIT_YEAR_CAN_FUTURE:
- g_value_set_boolean (
- value, e_date_edit_get_twodigit_year_can_future (
- E_DATE_EDIT (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-date_edit_dispose (GObject *object)
-{
- EDateEdit *dedit;
-
- dedit = E_DATE_EDIT (object);
-
- e_date_edit_set_get_time_callback (dedit, NULL, NULL, NULL);
-
- if (dedit->priv->cal_popup != NULL) {
- gtk_widget_destroy (dedit->priv->cal_popup);
- dedit->priv->cal_popup = NULL;
- }
-
- if (dedit->priv->grabbed_keyboard != NULL) {
- gdk_device_ungrab (
- dedit->priv->grabbed_keyboard,
- GDK_CURRENT_TIME);
- g_object_unref (dedit->priv->grabbed_keyboard);
- dedit->priv->grabbed_keyboard = NULL;
- }
-
- if (dedit->priv->grabbed_pointer != NULL) {
- gdk_device_ungrab (
- dedit->priv->grabbed_pointer,
- GDK_CURRENT_TIME);
- g_object_unref (dedit->priv->grabbed_pointer);
- dedit->priv->grabbed_pointer = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_date_edit_parent_class)->dispose (object);
-}
-
-static void
-e_date_edit_class_init (EDateEditClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EDateEditPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = date_edit_set_property;
- object_class->get_property = date_edit_get_property;
- object_class->dispose = date_edit_dispose;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->mnemonic_activate = e_date_edit_mnemonic_activate;
- widget_class->grab_focus = e_date_edit_grab_focus;
-
- g_object_class_install_property (
- object_class,
- PROP_ALLOW_NO_DATE_SET,
- g_param_spec_boolean (
- "allow-no-date-set",
- "Allow No Date Set",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SHOW_DATE,
- g_param_spec_boolean (
- "show-date",
- "Show Date",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SHOW_TIME,
- g_param_spec_boolean (
- "show-time",
- "Show Time",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SHOW_WEEK_NUMBERS,
- g_param_spec_boolean (
- "show-week-numbers",
- "Show Week Numbers",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_USE_24_HOUR_FORMAT,
- g_param_spec_boolean (
- "use-24-hour-format",
- "Use 24-Hour Format",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_WEEK_START_DAY,
- g_param_spec_int (
- "week-start-day",
- "Week Start Day",
- NULL,
- 0, /* Monday */
- 6, /* Sunday */
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_TWODIGIT_YEAR_CAN_FUTURE,
- g_param_spec_boolean (
- "twodigit-year-can-future",
- "Two-digit year can be treated as future",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SET_NONE,
- g_param_spec_boolean (
- "set-none",
- "Sets None as selected date",
- NULL,
- FALSE,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-
- signals[CHANGED] = g_signal_new (
- "changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EDateEditClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_date_edit_init (EDateEdit *dedit)
-{
- dedit->priv = E_DATE_EDIT_GET_PRIVATE (dedit);
-
- dedit->priv->show_date = TRUE;
- dedit->priv->show_time = TRUE;
- dedit->priv->use_24_hour_format = TRUE;
-
- dedit->priv->make_time_insensitive = FALSE;
-
- dedit->priv->lower_hour = 0;
- dedit->priv->upper_hour = 24;
-
- dedit->priv->date_is_valid = TRUE;
- dedit->priv->date_set_to_none = TRUE;
- dedit->priv->time_is_valid = TRUE;
- dedit->priv->time_set_to_none = TRUE;
- dedit->priv->time_callback = NULL;
- dedit->priv->time_callback_data = NULL;
- dedit->priv->time_callback_destroy = NULL;
-
- dedit->priv->twodigit_year_can_future = TRUE;
- dedit->priv->has_been_changed = FALSE;
-
- create_children (dedit);
-
- /* Set it to the current time. */
- e_date_edit_set_time (dedit, 0);
-
- e_extensible_load_extensions (E_EXTENSIBLE (dedit));
-}
-
-/**
- * e_date_edit_new:
- *
- * Description: Creates a new #EDateEdit widget which can be used
- * to provide an easy to use way for entering dates and times.
- *
- * Returns: a new #EDateEdit widget.
- */
-GtkWidget *
-e_date_edit_new (void)
-{
- EDateEdit *dedit;
- AtkObject *a11y;
-
- dedit = g_object_new (E_TYPE_DATE_EDIT, NULL);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (dedit));
- atk_object_set_name (a11y, _("Date and Time"));
-
- return GTK_WIDGET (dedit);
-}
-
-static void
-create_children (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- ECalendar *calendar;
- GtkWidget *frame, *arrow;
- GtkWidget *vbox, *bbox;
- GtkWidget *child;
- AtkObject *a11y;
- GtkListStore *time_store;
- GList *cells;
- GtkCssProvider *css_provider;
- GtkStyleContext *style_context;
- const gchar *css;
- GError *error = NULL;
-
- priv = dedit->priv;
-
- priv->date_entry = gtk_entry_new ();
- a11y = gtk_widget_get_accessible (priv->date_entry);
- atk_object_set_description (a11y, _("Text entry to input date"));
- atk_object_set_name (a11y, _("Date"));
- gtk_box_pack_start (GTK_BOX (dedit), priv->date_entry, FALSE, TRUE, 0);
- gtk_widget_set_size_request (priv->date_entry, 100, -1);
-
- g_signal_connect (
- priv->date_entry, "key_press_event",
- G_CALLBACK (on_date_entry_key_press), dedit);
- g_signal_connect (
- priv->date_entry, "key_release_event",
- G_CALLBACK (on_date_entry_key_release), dedit);
- g_signal_connect_after (
- priv->date_entry, "focus_out_event",
- G_CALLBACK (on_date_entry_focus_out), dedit);
-
- priv->date_button = gtk_button_new ();
- g_signal_connect (
- priv->date_button, "clicked",
- G_CALLBACK (on_date_button_clicked), dedit);
- gtk_box_pack_start (
- GTK_BOX (dedit), priv->date_button,
- FALSE, FALSE, 0);
- a11y = gtk_widget_get_accessible (priv->date_button);
- atk_object_set_description (a11y, _("Click this button to show a calendar"));
- atk_object_set_name (a11y, _("Date"));
-
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (priv->date_button), arrow);
- gtk_widget_show (arrow);
-
- if (priv->show_date) {
- gtk_widget_show (priv->date_entry);
- gtk_widget_show (priv->date_button);
- }
-
- /* This is just to create a space between the date & time parts. */
- priv->space = gtk_drawing_area_new ();
- gtk_box_pack_start (GTK_BOX (dedit), priv->space, FALSE, FALSE, 2);
-
- time_store = gtk_list_store_new (1, G_TYPE_STRING);
- priv->time_combo = gtk_combo_box_new_with_model_and_entry (
- GTK_TREE_MODEL (time_store));
- gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->time_combo), 0);
- g_object_unref (time_store);
-
- css_provider = gtk_css_provider_new ();
- css = "GtkComboBox { -GtkComboBox-appears-as-list: 1; }";
- gtk_css_provider_load_from_data (css_provider, css, -1, &error);
- style_context = gtk_widget_get_style_context (priv->time_combo);
- if (error == NULL) {
- gtk_style_context_add_provider (
- style_context,
- GTK_STYLE_PROVIDER (css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- } else {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_clear_error (&error);
- }
- g_object_unref (css_provider);
-
- child = gtk_bin_get_child (GTK_BIN (priv->time_combo));
-
- /* We need to make sure labels are right-aligned, since we want
- * digits to line up, and with a nonproportional font, the width
- * of a space != width of a digit. Technically, only 12-hour
- * format needs this, but we do it always, for consistency. */
- g_object_set (child, "xalign", 1.0, NULL);
- cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->time_combo));
- if (cells) {
- g_object_set (GTK_CELL_RENDERER (cells->data), "xalign", 1.0, NULL);
- g_list_free (cells);
- }
-
- gtk_box_pack_start (GTK_BOX (dedit), priv->time_combo, FALSE, TRUE, 0);
- gtk_widget_set_size_request (priv->time_combo, 110, -1);
- rebuild_time_popup (dedit);
- a11y = gtk_widget_get_accessible (priv->time_combo);
- atk_object_set_description (a11y, _("Drop-down combination box to select time"));
- atk_object_set_name (a11y, _("Time"));
-
- g_signal_connect (
- child, "key_press_event",
- G_CALLBACK (on_time_entry_key_press), dedit);
- g_signal_connect (
- child, "key_release_event",
- G_CALLBACK (on_time_entry_key_release), dedit);
- g_signal_connect_after (
- child, "focus_out_event",
- G_CALLBACK (on_time_entry_focus_out), dedit);
- g_signal_connect_after (
- priv->time_combo, "changed",
- G_CALLBACK (on_date_edit_time_selected), dedit);
-
- if (priv->show_time || priv->make_time_insensitive)
- gtk_widget_show (priv->time_combo);
-
- if (!priv->show_time && priv->make_time_insensitive)
- gtk_widget_set_sensitive (priv->time_combo, FALSE);
-
- if (priv->show_date
- && (priv->show_time || priv->make_time_insensitive))
- gtk_widget_show (priv->space);
-
- priv->cal_popup = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_type_hint (
- GTK_WINDOW (priv->cal_popup),
- GDK_WINDOW_TYPE_HINT_COMBO);
- gtk_widget_set_events (
- priv->cal_popup,
- gtk_widget_get_events (priv->cal_popup)
- | GDK_KEY_PRESS_MASK);
- g_signal_connect (
- priv->cal_popup, "delete_event",
- G_CALLBACK (on_date_popup_delete_event), dedit);
- g_signal_connect (
- priv->cal_popup, "key_press_event",
- G_CALLBACK (on_date_popup_key_press), dedit);
- g_signal_connect (
- priv->cal_popup, "button_press_event",
- G_CALLBACK (on_date_popup_button_press), dedit);
- gtk_window_set_resizable (GTK_WINDOW (priv->cal_popup), TRUE);
-
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
- gtk_container_add (GTK_CONTAINER (priv->cal_popup), frame);
- gtk_widget_show (frame);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
- gtk_widget_show (vbox);
-
- priv->calendar = e_calendar_new ();
- calendar = E_CALENDAR (priv->calendar);
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (calendar->calitem),
- "maximum_days_selected", 1,
- "move_selection_when_moving", FALSE,
- NULL);
-
- g_signal_connect (
- calendar->calitem, "selection_changed",
- G_CALLBACK (on_date_popup_date_selected), dedit);
-
- gtk_box_pack_start (GTK_BOX (vbox), priv->calendar, FALSE, FALSE, 0);
- gtk_widget_show (priv->calendar);
-
- bbox = gtk_hbutton_box_new ();
- gtk_container_set_border_width (GTK_CONTAINER (bbox), 4);
- gtk_box_set_spacing (GTK_BOX (bbox), 2);
- gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
- gtk_widget_show (bbox);
-
- priv->now_button = gtk_button_new_with_mnemonic (_("No_w"));
- gtk_container_add (GTK_CONTAINER (bbox), priv->now_button);
- gtk_widget_show (priv->now_button);
- g_signal_connect (
- priv->now_button, "clicked",
- G_CALLBACK (on_date_popup_now_button_clicked), dedit);
-
- priv->today_button = gtk_button_new_with_mnemonic (_("_Today"));
- gtk_container_add (GTK_CONTAINER (bbox), priv->today_button);
- gtk_widget_show (priv->today_button);
- g_signal_connect (
- priv->today_button, "clicked",
- G_CALLBACK (on_date_popup_today_button_clicked), dedit);
-
- /* Note that we don't show this here, since by default a 'None' date
- * is not permitted. */
- priv->none_button = gtk_button_new_with_mnemonic (_("_None"));
- gtk_container_add (GTK_CONTAINER (bbox), priv->none_button);
- g_signal_connect (
- priv->none_button, "clicked",
- G_CALLBACK (on_date_popup_none_button_clicked), dedit);
- g_object_bind_property (
- dedit, "allow-no-date-set",
- priv->none_button, "visible",
- G_BINDING_SYNC_CREATE);
-}
-
-/* GtkWidget::mnemonic_activate() handler for the EDateEdit */
-static gboolean
-e_date_edit_mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling)
-{
- e_date_edit_grab_focus (widget);
- return TRUE;
-}
-
-/* Grab_focus handler for the EDateEdit. If the date field is being shown, we
- * grab the focus to that, otherwise we grab it to the time field. */
-static void
-e_date_edit_grab_focus (GtkWidget *widget)
-{
- EDateEdit *dedit;
- GtkWidget *child;
-
- g_return_if_fail (E_IS_DATE_EDIT (widget));
-
- dedit = E_DATE_EDIT (widget);
- child = gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo));
-
- if (dedit->priv->show_date)
- gtk_widget_grab_focus (dedit->priv->date_entry);
- else
- gtk_widget_grab_focus (child);
-}
-
-/**
- * e_date_edit_set_editable:
- * @dedit: an #EDateEdit widget.
- * @editable: whether or not the widget should accept edits.
- *
- * Allows the programmer to disallow editing (and the popping up of
- * the calendar widget), while still allowing the user to select the
- * date from the GtkEntry.
- */
-void
-e_date_edit_set_editable (EDateEdit *dedit,
- gboolean editable)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- gtk_editable_set_editable (GTK_EDITABLE (priv->date_entry), editable);
- gtk_widget_set_sensitive (priv->date_button, editable);
-}
-
-/**
- * e_date_edit_get_time:
- * @dedit: an #EDateEdit widget.
- * @the_time: returns the last valid time entered.
- * @Returns: the last valid time entered, or -1 if the time is not set.
- *
- * Returns the last valid time entered. If empty times are valid, by calling
- * e_date_edit_set_allow_no_date_set(), then it may return -1.
- *
- * Note that the last time entered may actually have been invalid. You can
- * check this with e_date_edit_time_is_valid().
- */
-time_t
-e_date_edit_get_time (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- struct tm tmp_tm = { 0 };
-
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), -1);
-
- priv = dedit->priv;
-
- /* Try to parse any new value now. */
- e_date_edit_check_date_changed (dedit);
- e_date_edit_check_time_changed (dedit);
-
- if (priv->date_set_to_none)
- return -1;
-
- tmp_tm.tm_year = priv->year;
- tmp_tm.tm_mon = priv->month;
- tmp_tm.tm_mday = priv->day;
-
- if (!priv->show_time || priv->time_set_to_none) {
- tmp_tm.tm_hour = 0;
- tmp_tm.tm_min = 0;
- } else {
- tmp_tm.tm_hour = priv->hour;
- tmp_tm.tm_min = priv->minute;
- }
- tmp_tm.tm_sec = 0;
- tmp_tm.tm_isdst = -1;
-
- return mktime (&tmp_tm);
-}
-
-/**
- * e_date_edit_set_time:
- * @dedit: the EDateEdit widget
- * @the_time: The time and date that should be set on the widget
- *
- * Description: Changes the displayed date and time in the EDateEdit
- * widget to be the one represented by @the_time. If @the_time is 0
- * then current time is used. If it is -1, then the date is set to None.
- *
- * Note that the time is converted to local time using the Unix timezone,
- * so if you are using your own timezones then you should use
- * e_date_edit_set_date() and e_date_edit_set_time_of_day() instead.
- */
-void
-e_date_edit_set_time (EDateEdit *dedit,
- time_t the_time)
-{
- EDateEditPrivate *priv;
- struct tm tmp_tm;
- gboolean date_changed = FALSE, time_changed = FALSE;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (the_time == -1) {
- date_changed = e_date_edit_set_date_internal (
- dedit, TRUE,
- TRUE, 0, 0, 0);
- time_changed = e_date_edit_set_time_internal (
- dedit, TRUE,
- TRUE, 0, 0);
- } else {
- if (the_time == 0) {
- if (priv->time_callback) {
- tmp_tm = (*priv->time_callback) (dedit, priv->time_callback_data);
- } else {
- the_time = time (NULL);
- tmp_tm = *localtime (&the_time);
- }
- } else {
- tmp_tm = *localtime (&the_time);
- }
-
- date_changed = e_date_edit_set_date_internal (
- dedit, TRUE,
- FALSE,
- tmp_tm.tm_year,
- tmp_tm.tm_mon,
- tmp_tm.tm_mday);
- time_changed = e_date_edit_set_time_internal (
- dedit, TRUE,
- FALSE,
- tmp_tm.tm_hour,
- tmp_tm.tm_min);
- }
-
- e_date_edit_update_date_entry (dedit);
- e_date_edit_update_time_entry (dedit);
- e_date_edit_update_time_combo_state (dedit);
-
- /* Emit the signals if the date and/or time has actually changed. */
- if (date_changed || time_changed)
- g_signal_emit (dedit, signals[CHANGED], 0);
-}
-
-/**
- * e_date_edit_get_date:
- * @dedit: an #EDateEdit widget.
- * @year: returns the year set.
- * @month: returns the month set (1 - 12).
- * @day: returns the day set (1 - 31).
- * @Returns: TRUE if a time was set, or FALSE if the field is empty or 'None'.
- *
- * Returns the last valid date entered into the date field.
- */
-gboolean
-e_date_edit_get_date (EDateEdit *dedit,
- gint *year,
- gint *month,
- gint *day)
-{
- EDateEditPrivate *priv;
-
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- priv = dedit->priv;
-
- /* Try to parse any new value now. */
- e_date_edit_check_date_changed (dedit);
-
- *year = priv->year + 1900;
- *month = priv->month + 1;
- *day = priv->day;
-
- if (priv->date_set_to_none
- && e_date_edit_get_allow_no_date_set (dedit))
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * e_date_edit_set_date:
- * @dedit: an #EDateEdit widget.
- * @year: the year to set.
- * @month: the month to set (1 - 12).
- * @day: the day to set (1 - 31).
- *
- * Sets the date in the date field.
- */
-void
-e_date_edit_set_date (EDateEdit *dedit,
- gint year,
- gint month,
- gint day)
-{
- gboolean date_changed = FALSE;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- date_changed = e_date_edit_set_date_internal (
- dedit, TRUE, FALSE,
- year - 1900, month - 1,
- day);
-
- e_date_edit_update_date_entry (dedit);
- e_date_edit_update_time_combo_state (dedit);
-
- /* Emit the signals if the date has actually changed. */
- if (date_changed)
- g_signal_emit (dedit, signals[CHANGED], 0);
-}
-
-/**
- * e_date_edit_get_time_of_day:
- * @dedit: an #EDateEdit widget.
- * @hour: returns the hour set, or 0 if the time isn't set.
- * @minute: returns the minute set, or 0 if the time isn't set.
- * @Returns: TRUE if a time was set, or FALSE if the field is empty or 'None'.
- *
- * Returns the last valid time entered into the time field.
- */
-gboolean
-e_date_edit_get_time_of_day (EDateEdit *dedit,
- gint *hour,
- gint *minute)
-{
- EDateEditPrivate *priv;
-
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- priv = dedit->priv;
-
- /* Try to parse any new value now. */
- e_date_edit_check_time_changed (dedit);
-
- if (priv->time_set_to_none) {
- *hour = 0;
- *minute = 0;
- return FALSE;
- } else {
- *hour = priv->hour;
- *minute = priv->minute;
- return TRUE;
- }
-}
-
-/**
- * e_date_edit_set_time_of_day:
- * @dedit: an #EDateEdit widget.
- * @hour: the hour to set, or -1 to set the time to None (i.e. empty).
- * @minute: the minute to set.
- *
- * Description: Sets the time in the time field.
- */
-void
-e_date_edit_set_time_of_day (EDateEdit *dedit,
- gint hour,
- gint minute)
-{
- EDateEditPrivate *priv;
- gboolean time_changed = FALSE;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (hour == -1) {
- gboolean allow_no_date_set = e_date_edit_get_allow_no_date_set (dedit);
- g_return_if_fail (allow_no_date_set);
- if (!priv->time_set_to_none) {
- priv->time_set_to_none = TRUE;
- time_changed = TRUE;
- }
- } else if (priv->time_set_to_none
- || priv->hour != hour
- || priv->minute != minute) {
- priv->time_set_to_none = FALSE;
- priv->hour = hour;
- priv->minute = minute;
- time_changed = TRUE;
- }
-
- e_date_edit_update_time_entry (dedit);
-
- if (time_changed)
- g_signal_emit (dedit, signals[CHANGED], 0);
-}
-
-void
-e_date_edit_set_date_and_time_of_day (EDateEdit *dedit,
- gint year,
- gint month,
- gint day,
- gint hour,
- gint minute)
-{
- gboolean date_changed, time_changed;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- date_changed = e_date_edit_set_date_internal (
- dedit, TRUE, FALSE,
- year - 1900, month - 1, day);
- time_changed = e_date_edit_set_time_internal (
- dedit, TRUE, FALSE,
- hour, minute);
-
- e_date_edit_update_date_entry (dedit);
- e_date_edit_update_time_entry (dedit);
- e_date_edit_update_time_combo_state (dedit);
-
- if (date_changed || time_changed)
- g_signal_emit (dedit, signals[CHANGED], 0);
-}
-
-/**
- * e_date_edit_get_show_date:
- * @dedit: an #EDateEdit widget.
- * @Returns: Whether the date field is shown.
- *
- * Description: Returns TRUE if the date field is currently shown.
- */
-gboolean
-e_date_edit_get_show_date (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE);
-
- return dedit->priv->show_date;
-}
-
-/**
- * e_date_edit_set_show_date:
- * @dedit: an #EDateEdit widget.
- * @show_date: TRUE if the date field should be shown.
- *
- * Description: Specifies whether the date field should be shown. The date
- * field would be hidden if only a time needed to be entered.
- */
-void
-e_date_edit_set_show_date (EDateEdit *dedit,
- gboolean show_date)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (priv->show_date == show_date)
- return;
-
- priv->show_date = show_date;
-
- if (show_date) {
- gtk_widget_show (priv->date_entry);
- gtk_widget_show (priv->date_button);
- } else {
- gtk_widget_hide (priv->date_entry);
- gtk_widget_hide (priv->date_button);
- }
-
- e_date_edit_update_time_combo_state (dedit);
-
- if (priv->show_date
- && (priv->show_time || priv->make_time_insensitive))
- gtk_widget_show (priv->space);
- else
- gtk_widget_hide (priv->space);
-
- g_object_notify (G_OBJECT (dedit), "show-date");
-}
-
-/**
- * e_date_edit_get_show_time:
- * @dedit: an #EDateEdit widget
- * @Returns: Whether the time field is shown.
- *
- * Description: Returns TRUE if the time field is currently shown.
- */
-gboolean
-e_date_edit_get_show_time (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE);
-
- return dedit->priv->show_time;
-}
-
-/**
- * e_date_edit_set_show_time:
- * @dedit: an #EDateEdit widget
- * @show_time: TRUE if the time field should be shown.
- *
- * Description: Specifies whether the time field should be shown. The time
- * field would be hidden if only a date needed to be entered.
- */
-void
-e_date_edit_set_show_time (EDateEdit *dedit,
- gboolean show_time)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (priv->show_time == show_time)
- return;
-
- priv->show_time = show_time;
-
- e_date_edit_update_time_combo_state (dedit);
-
- g_object_notify (G_OBJECT (dedit), "show-time");
-}
-
-/**
- * e_date_edit_get_make_time_insensitive:
- * @dedit: an #EDateEdit widget
- * @Returns: Whether the time field is be made insensitive instead of hiding
- * it.
- *
- * Description: Returns TRUE if the time field is made insensitive instead of
- * hiding it.
- */
-gboolean
-e_date_edit_get_make_time_insensitive (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE);
-
- return dedit->priv->make_time_insensitive;
-}
-
-/**
- * e_date_edit_set_make_time_insensitive:
- * @dedit: an #EDateEdit widget
- * @make_insensitive: TRUE if the time field should be made insensitive instead
- * of hiding it.
- *
- * Description: Specifies whether the time field should be made insensitive
- * rather than hiding it. Note that this doesn't make it insensitive - you
- * need to call e_date_edit_set_show_time() with FALSE as show_time to do that.
- *
- * This is useful if you want to disable the time field, but don't want it to
- * disappear as that may affect the layout of the widgets.
- */
-void
-e_date_edit_set_make_time_insensitive (EDateEdit *dedit,
- gboolean make_insensitive)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (priv->make_time_insensitive == make_insensitive)
- return;
-
- priv->make_time_insensitive = make_insensitive;
-
- e_date_edit_update_time_combo_state (dedit);
-}
-
-/**
- * e_date_edit_get_week_start_day:
- * @dedit: an #EDateEdit widget
- * @Returns: the week start day, from 0 (Monday) to 6 (Sunday).
- *
- * Description: Returns the week start day currently used in the calendar
- * popup.
- */
-gint
-e_date_edit_get_week_start_day (EDateEdit *dedit)
-{
- gint week_start_day;
-
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), 1);
-
- g_object_get (
- E_CALENDAR (dedit->priv->calendar)->calitem,
- "week_start_day", &week_start_day, NULL);
-
- return week_start_day;
-}
-
-/**
- * e_date_edit_set_week_start_day:
- * @dedit: an #EDateEdit widget
- * @week_start_day: the week start day, from 0 (Monday) to 6 (Sunday).
- *
- * Description: Sets the week start day to use in the calendar popup.
- */
-void
-e_date_edit_set_week_start_day (EDateEdit *dedit,
- gint week_start_day)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem),
- "week_start_day", week_start_day, NULL);
-
- g_object_notify (G_OBJECT (dedit), "week-start-day");
-}
-
-/* Whether we show week numbers in the date popup. */
-gboolean
-e_date_edit_get_show_week_numbers (EDateEdit *dedit)
-{
- gboolean show_week_numbers;
-
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- g_object_get (
- E_CALENDAR (dedit->priv->calendar)->calitem,
- "show_week_numbers", &show_week_numbers, NULL);
-
- return show_week_numbers;
-}
-
-void
-e_date_edit_set_show_week_numbers (EDateEdit *dedit,
- gboolean show_week_numbers)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- gnome_canvas_item_set (
- GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem),
- "show_week_numbers", show_week_numbers, NULL);
-
- g_object_notify (G_OBJECT (dedit), "show-week-numbers");
-}
-
-/* Whether we use 24 hour format in the time field & popup. */
-gboolean
-e_date_edit_get_use_24_hour_format (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE);
-
- return dedit->priv->use_24_hour_format;
-}
-
-void
-e_date_edit_set_use_24_hour_format (EDateEdit *dedit,
- gboolean use_24_hour_format)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- if (dedit->priv->use_24_hour_format == use_24_hour_format)
- return;
-
- dedit->priv->use_24_hour_format = use_24_hour_format;
-
- rebuild_time_popup (dedit);
-
- e_date_edit_update_time_entry (dedit);
-
- g_object_notify (G_OBJECT (dedit), "use-24-hour-format");
-}
-
-/* Whether we allow the date to be set to 'None'. e_date_edit_get_time() will
- * return (time_t) -1 in this case. */
-gboolean
-e_date_edit_get_allow_no_date_set (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- return dedit->priv->allow_no_date_set;
-}
-
-void
-e_date_edit_set_allow_no_date_set (EDateEdit *dedit,
- gboolean allow_no_date_set)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- if (dedit->priv->allow_no_date_set == allow_no_date_set)
- return;
-
- dedit->priv->allow_no_date_set = allow_no_date_set;
-
- if (!allow_no_date_set) {
- /* If the date is showing, we make sure it isn't 'None' (we
- * don't really mind if the time is empty), else if just the
- * time is showing we make sure it isn't 'None'. */
- if (dedit->priv->show_date) {
- if (dedit->priv->date_set_to_none)
- e_date_edit_set_time (dedit, 0);
- } else {
- if (dedit->priv->time_set_to_none)
- e_date_edit_set_time (dedit, 0);
- }
- }
-
- g_object_notify (G_OBJECT (dedit), "allow-no-date-set");
-}
-
-/* The range of time to show in the time combo popup. */
-void
-e_date_edit_get_time_popup_range (EDateEdit *dedit,
- gint *lower_hour,
- gint *upper_hour)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- *lower_hour = dedit->priv->lower_hour;
- *upper_hour = dedit->priv->upper_hour;
-}
-
-void
-e_date_edit_set_time_popup_range (EDateEdit *dedit,
- gint lower_hour,
- gint upper_hour)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (priv->lower_hour == lower_hour
- && priv->upper_hour == upper_hour)
- return;
-
- priv->lower_hour = lower_hour;
- priv->upper_hour = upper_hour;
-
- rebuild_time_popup (dedit);
-
- /* Setting the combo list items seems to mess up the time entry, so
- * we set it again. We have to reset it to its last valid time. */
- priv->time_is_valid = TRUE;
- e_date_edit_update_time_entry (dedit);
-}
-
-/* The arrow button beside the date field has been clicked, so we show the
- * popup with the ECalendar in. */
-static void
-on_date_button_clicked (GtkWidget *widget,
- EDateEdit *dedit)
-{
- GdkEvent *event;
-
- /* Obtain the GdkEvent that triggered
- * the date button's "clicked" signal. */
- event = gtk_get_current_event ();
- e_date_edit_show_date_popup (dedit, event);
-}
-
-static void
-e_date_edit_show_date_popup (EDateEdit *dedit,
- GdkEvent *event)
-{
- EDateEditPrivate *priv;
- ECalendar *calendar;
- GdkDevice *event_device;
- GdkDevice *assoc_device;
- GdkDevice *keyboard_device;
- GdkDevice *pointer_device;
- GdkWindow *window;
- GdkGrabStatus grab_status;
- struct tm mtm;
- const gchar *date_text;
- GDate selected_day;
- gboolean clear_selection = FALSE;
- guint event_time;
-
- priv = dedit->priv;
- calendar = E_CALENDAR (priv->calendar);
-
- date_text = gtk_entry_get_text (GTK_ENTRY (priv->date_entry));
- if (field_set_to_none (date_text)
- || !e_date_edit_parse_date (dedit, date_text, &mtm))
- clear_selection = TRUE;
-
- if (clear_selection) {
- e_calendar_item_set_selection (calendar->calitem, NULL, NULL);
- } else {
- g_date_clear (&selected_day, 1);
- g_date_set_dmy (
- &selected_day, mtm.tm_mday, mtm.tm_mon + 1,
- mtm.tm_year + 1900);
- e_calendar_item_set_selection (
- calendar->calitem,
- &selected_day, NULL);
- }
-
- /* FIXME: Hack. Change ECalendarItem so it doesn't queue signal
- * emissions. */
- calendar->calitem->selection_changed = FALSE;
-
- position_date_popup (dedit);
- gtk_widget_show (priv->cal_popup);
- gtk_widget_grab_focus (priv->cal_popup);
- gtk_grab_add (priv->cal_popup);
-
- window = gtk_widget_get_window (priv->cal_popup);
-
- g_return_if_fail (priv->grabbed_keyboard == NULL);
- g_return_if_fail (priv->grabbed_pointer == NULL);
-
- event_device = gdk_event_get_device (event);
- assoc_device = gdk_device_get_associated_device (event_device);
-
- event_time = gdk_event_get_time (event);
-
- if (gdk_device_get_source (event_device) == GDK_SOURCE_KEYBOARD) {
- keyboard_device = event_device;
- pointer_device = assoc_device;
- } else {
- keyboard_device = assoc_device;
- pointer_device = event_device;
- }
-
- if (keyboard_device != NULL) {
- grab_status = gdk_device_grab (
- keyboard_device,
- window,
- GDK_OWNERSHIP_WINDOW,
- TRUE,
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK,
- NULL,
- event_time);
- if (grab_status == GDK_GRAB_SUCCESS) {
- priv->grabbed_keyboard =
- g_object_ref (keyboard_device);
- }
- }
-
- if (pointer_device != NULL) {
- grab_status = gdk_device_grab (
- pointer_device,
- window,
- GDK_OWNERSHIP_WINDOW,
- TRUE,
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK,
- NULL,
- event_time);
- if (grab_status == GDK_GRAB_SUCCESS) {
- priv->grabbed_pointer =
- g_object_ref (pointer_device);
- } else if (priv->grabbed_keyboard != NULL) {
- gdk_device_ungrab (
- priv->grabbed_keyboard,
- event_time);
- g_object_unref (priv->grabbed_keyboard);
- priv->grabbed_keyboard = NULL;
- }
- }
-
- gdk_window_focus (window, event_time);
-}
-
-/* This positions the date popup below and to the left of the arrow button,
- * just before it is shown. */
-static void
-position_date_popup (EDateEdit *dedit)
-{
- gint x, y;
- gint win_x, win_y;
- gint bwidth, bheight;
- GtkWidget *toplevel;
- GdkWindow *window;
- GtkRequisition cal_req, button_req;
- gint screen_width, screen_height;
-
- gtk_widget_get_preferred_size (dedit->priv->cal_popup, &cal_req, NULL);
-
- gtk_widget_get_preferred_size (dedit->priv->date_button, &button_req, NULL);
- bwidth = button_req.width;
- gtk_widget_get_preferred_size (
- gtk_widget_get_parent (dedit->priv->date_button), &button_req, NULL);
- bheight = button_req.height;
-
- gtk_widget_translate_coordinates (
- dedit->priv->date_button,
- gtk_widget_get_toplevel (dedit->priv->date_button),
- bwidth - cal_req.width, bheight, &x, &y);
-
- toplevel = gtk_widget_get_toplevel (dedit->priv->date_button);
- window = gtk_widget_get_window (toplevel);
- gdk_window_get_origin (window, &win_x, &win_y);
-
- x += win_x;
- y += win_y;
-
- screen_width = gdk_screen_width ();
- screen_height = gdk_screen_height ();
-
- x = CLAMP (x, 0, MAX (0, screen_width - cal_req.width));
- y = CLAMP (y, 0, MAX (0, screen_height - cal_req.height));
-
- gtk_window_move (GTK_WINDOW (dedit->priv->cal_popup), x, y);
-}
-
-/* A date has been selected in the date popup, so we set the date field
- * and hide the popup. */
-static void
-on_date_popup_date_selected (ECalendarItem *calitem,
- EDateEdit *dedit)
-{
- GDate start_date, end_date;
-
- hide_date_popup (dedit);
-
- if (!e_calendar_item_get_selection (calitem, &start_date, &end_date))
- return;
-
- e_date_edit_set_date (
- dedit, g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date));
-}
-
-static void
-on_date_popup_now_button_clicked (GtkWidget *button,
- EDateEdit *dedit)
-{
- hide_date_popup (dedit);
- e_date_edit_set_time (dedit, 0);
-}
-
-static void
-on_date_popup_today_button_clicked (GtkWidget *button,
- EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- struct tm tmp_tm;
- time_t t;
-
- priv = dedit->priv;
-
- hide_date_popup (dedit);
-
- if (priv->time_callback) {
- tmp_tm = (*priv->time_callback) (dedit, priv->time_callback_data);
- } else {
- t = time (NULL);
- tmp_tm = *localtime (&t);
- }
-
- e_date_edit_set_date (
- dedit, tmp_tm.tm_year + 1900,
- tmp_tm.tm_mon + 1, tmp_tm.tm_mday);
-}
-
-static void
-on_date_popup_none_button_clicked (GtkWidget *button,
- EDateEdit *dedit)
-{
- hide_date_popup (dedit);
- e_date_edit_set_time (dedit, -1);
-}
-
-/* A key has been pressed while the date popup is showing. If it is the Escape
- * key we hide the popup. */
-static gint
-on_date_popup_key_press (GtkWidget *widget,
- GdkEventKey *event,
- EDateEdit *dedit)
-{
- if (event->keyval == GDK_KEY_Escape) {
- g_signal_stop_emission_by_name (widget, "key_press_event");
- hide_date_popup (dedit);
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* A mouse button has been pressed while the date popup is showing.
- * Any button press events used to select days etc. in the popup will have
- * have been handled elsewhere, so here we just hide the popup.
- * (This function is yanked from gtkcombo.c) */
-static gint
-on_date_popup_button_press (GtkWidget *widget,
- GdkEvent *button_event,
- gpointer data)
-{
- EDateEdit *dedit;
- GtkWidget *child;
-
- dedit = data;
-
- child = gtk_get_event_widget (button_event);
-
- /* We don't ask for button press events on the grab widget, so
- * if an event is reported directly to the grab widget, it must
- * be on a window outside the application (and thus we remove
- * the popup window). Otherwise, we check if the widget is a child
- * of the grab widget, and only remove the popup window if it
- * is not.
- */
- if (child != widget) {
- while (child) {
- if (child == widget)
- return FALSE;
- child = gtk_widget_get_parent (child);
- }
- }
-
- hide_date_popup (dedit);
-
- return TRUE;
-}
-
-/* A delete event has been received for the date popup, so we hide it and
- * return TRUE so it doesn't get destroyed. */
-static gint
-on_date_popup_delete_event (GtkWidget *widget,
- EDateEdit *dedit)
-{
- hide_date_popup (dedit);
- return TRUE;
-}
-
-/* Hides the date popup, removing any grabs. */
-static void
-hide_date_popup (EDateEdit *dedit)
-{
- gtk_widget_hide (dedit->priv->cal_popup);
- gtk_grab_remove (dedit->priv->cal_popup);
-
- if (dedit->priv->grabbed_keyboard != NULL) {
- gdk_device_ungrab (
- dedit->priv->grabbed_keyboard,
- GDK_CURRENT_TIME);
- g_object_unref (dedit->priv->grabbed_keyboard);
- dedit->priv->grabbed_keyboard = NULL;
- }
-
- if (dedit->priv->grabbed_pointer != NULL) {
- gdk_device_ungrab (
- dedit->priv->grabbed_pointer,
- GDK_CURRENT_TIME);
- g_object_unref (dedit->priv->grabbed_pointer);
- dedit->priv->grabbed_pointer = NULL;
- }
-}
-
-/* Clears the time popup and rebuilds it using the lower_hour, upper_hour
- * and use_24_hour_format settings. */
-static void
-rebuild_time_popup (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- GtkTreeModel *model;
- GtkListStore *list_store;
- GtkTreeIter iter;
- gchar buffer[40];
- struct tm tmp_tm;
- gint hour, min;
-
- priv = dedit->priv;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->time_combo));
- list_store = GTK_LIST_STORE (model);
- gtk_list_store_clear (list_store);
-
- /* Fill the struct tm with some sane values. */
- tmp_tm.tm_year = 2000;
- tmp_tm.tm_mon = 0;
- tmp_tm.tm_mday = 1;
- tmp_tm.tm_sec = 0;
- tmp_tm.tm_isdst = 0;
-
- for (hour = priv->lower_hour; hour <= priv->upper_hour; hour++) {
-
- /* We don't want to display midnight at the end,
- * since that is really in the next day. */
- if (hour == 24)
- break;
-
- /* We want to finish on upper_hour, with min == 0. */
- for (min = 0;
- min == 0 || (min < 60 && hour != priv->upper_hour);
- min += 30) {
- tmp_tm.tm_hour = hour;
- tmp_tm.tm_min = min;
-
- if (priv->use_24_hour_format)
- /* This is a strftime() format.
- * %H = hour (0-23), %M = minute. */
- e_time_format_time (
- &tmp_tm, 1, 0,
- buffer, sizeof (buffer));
- else
- /* This is a strftime() format.
- * %I = hour (1-12), %M = minute,
- * %p = am/pm string. */
- e_time_format_time (
- &tmp_tm, 0, 0,
- buffer, sizeof (buffer));
-
- /* For 12-hour am/pm format, we want space padding,
- * not zero padding. This can be done with strftime's
- * %l, but it's a potentially unportable extension. */
- if (!priv->use_24_hour_format && buffer[0] == '0')
- buffer[0] = ' ';
-
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter, 0, buffer, -1);
- }
- }
-}
-
-static gboolean
-e_date_edit_parse_date (EDateEdit *dedit,
- const gchar *date_text,
- struct tm *date_tm)
-{
- gboolean twodigit_year = FALSE;
-
- if (e_time_parse_date_ex (date_text, date_tm, &twodigit_year) != E_TIME_PARSE_OK)
- return FALSE;
-
- if (twodigit_year && !dedit->priv->twodigit_year_can_future) {
- time_t t = time (NULL);
- struct tm *today_tm = localtime (&t);
-
- /* It was only 2 digit year in dedit and it was interpreted as
- * in the future, but we don't want it as this, so decrease by
- * 100 years to last century. */
- if (date_tm->tm_year > today_tm->tm_year)
- date_tm->tm_year -= 100;
- }
-
- return TRUE;
-}
-
-static gboolean
-e_date_edit_parse_time (EDateEdit *dedit,
- const gchar *time_text,
- struct tm *time_tm)
-{
- if (field_set_to_none (time_text)) {
- time_tm->tm_hour = 0;
- time_tm->tm_min = 0;
- return TRUE;
- }
-
- if (e_time_parse_time (time_text, time_tm) != E_TIME_PARSE_OK)
- return FALSE;
-
- return TRUE;
-}
-
-/* Returns TRUE if the string is empty or is "None" in the current locale.
- * It ignores whitespace. */
-static gboolean
-field_set_to_none (const gchar *text)
-{
- const gchar *pos;
- const gchar *none_string;
- gint n;
-
- pos = text;
- while (n = (gint)((guchar) * pos), isspace (n))
- pos++;
-
- /* Translators: "None" for date field of a date edit, shown when
- * there is no date set. */
- none_string = C_("date", "None");
-
- if (*pos == '\0' || !strncmp (pos, none_string, strlen (none_string)))
- return TRUE;
- return FALSE;
-}
-
-static void
-on_date_edit_time_selected (GtkComboBox *combo,
- EDateEdit *dedit)
-{
- GtkWidget *child;
-
- child = gtk_bin_get_child (GTK_BIN (combo));
-
- /* We only want to emit signals when an item is selected explicitly,
- * not when it is selected by the silly combo update thing. */
- if (gtk_combo_box_get_active (combo) == -1)
- return;
-
- if (!gtk_widget_get_mapped (child))
- return;
-
- e_date_edit_check_time_changed (dedit);
-}
-
-static gint
-on_date_entry_key_press (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit)
-{
- GdkModifierType event_state = 0;
- guint event_keyval = 0;
-
- gdk_event_get_keyval (key_event, &event_keyval);
- gdk_event_get_state (key_event, &event_state);
-
- if (event_state & GDK_MOD1_MASK
- && (event_keyval == GDK_KEY_Up || event_keyval == GDK_KEY_Down
- || event_keyval == GDK_KEY_Return)) {
- g_signal_stop_emission_by_name (widget, "key_press_event");
- e_date_edit_show_date_popup (dedit, key_event);
- return TRUE;
- }
-
- /* If the user hits the return key emit a "date_changed" signal if
- * needed. But let the signal carry on. */
- if (event_keyval == GDK_KEY_Return) {
- e_date_edit_check_date_changed (dedit);
- return FALSE;
- }
-
- return FALSE;
-}
-
-static gint
-on_time_entry_key_press (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit)
-{
- GtkWidget *child;
- GdkModifierType event_state = 0;
- guint event_keyval = 0;
-
- gdk_event_get_keyval (key_event, &event_keyval);
- gdk_event_get_state (key_event, &event_state);
-
- child = gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo));
-
- /* I'd like to use Alt+Up/Down for popping up the list, like Win32,
- * but the combo steals any Up/Down keys, so we use Alt + Return. */
-#if 0
- if (event_state & GDK_MOD1_MASK
- && (event_keyval == GDK_KEY_Up || event_keyval == GDK_KEY_Down)) {
-#else
- if (event_state & GDK_MOD1_MASK && event_keyval == GDK_KEY_Return) {
-#endif
- g_signal_stop_emission_by_name (widget, "key_press_event");
- g_signal_emit_by_name (child, "activate", 0);
- return TRUE;
- }
-
- /* Stop the return key from emitting the activate signal, and check
- * if we need to emit a "time_changed" signal. */
- if (event_keyval == GDK_KEY_Return) {
- g_signal_stop_emission_by_name (widget, "key_press_event");
- e_date_edit_check_time_changed (dedit);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-on_date_entry_key_release (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit)
-{
- e_date_edit_check_date_changed (dedit);
- return TRUE;
-}
-
-static gint
-on_time_entry_key_release (GtkWidget *widget,
- GdkEvent *key_event,
- EDateEdit *dedit)
-{
- guint event_keyval = 0;
-
- gdk_event_get_keyval (key_event, &event_keyval);
-
- if (event_keyval == GDK_KEY_Up || event_keyval == GDK_KEY_Down) {
- g_signal_stop_emission_by_name (widget, "key_release_event");
- e_date_edit_check_time_changed (dedit);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-on_date_entry_focus_out (GtkEntry *entry,
- GdkEventFocus *event,
- EDateEdit *dedit)
-{
- struct tm tmp_tm;
- GtkWidget *msg_dialog;
-
- tmp_tm.tm_year = 0;
- tmp_tm.tm_mon = 0;
- tmp_tm.tm_mday = 0;
-
- e_date_edit_check_date_changed (dedit);
-
- if (!e_date_edit_date_is_valid (dedit)) {
- msg_dialog = gtk_message_dialog_new (
- NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", _("Invalid Date Value"));
- gtk_dialog_run (GTK_DIALOG (msg_dialog));
- gtk_widget_destroy (msg_dialog);
- e_date_edit_get_date (
- dedit, &tmp_tm.tm_year,
- &tmp_tm.tm_mon, &tmp_tm.tm_mday);
- e_date_edit_set_date (
- dedit, tmp_tm.tm_year,
- tmp_tm.tm_mon, tmp_tm.tm_mday);
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- return FALSE;
- } else if (e_date_edit_get_date (
- dedit, &tmp_tm.tm_year, &tmp_tm.tm_mon, &tmp_tm.tm_mday)) {
-
- e_date_edit_set_date (
- dedit,tmp_tm.tm_year,tmp_tm.tm_mon,tmp_tm.tm_mday);
-
- if (dedit->priv->has_been_changed) {
- /* The previous one didn't emit changed signal,
- * but we want it even here, thus doing itself. */
- g_signal_emit (dedit, signals[CHANGED], 0);
- dedit->priv->has_been_changed = FALSE;
- }
- } else {
- dedit->priv->date_set_to_none = TRUE;
- e_date_edit_update_date_entry (dedit);
- }
- return FALSE;
-}
-
-static gint
-on_time_entry_focus_out (GtkEntry *entry,
- GdkEventFocus *event,
- EDateEdit *dedit)
-{
- GtkWidget *msg_dialog;
-
- e_date_edit_check_time_changed (dedit);
-
- if (!e_date_edit_time_is_valid (dedit)) {
- msg_dialog = gtk_message_dialog_new (
- NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", _("Invalid Time Value"));
- gtk_dialog_run (GTK_DIALOG (msg_dialog));
- gtk_widget_destroy (msg_dialog);
- e_date_edit_set_time (dedit,e_date_edit_get_time (dedit));
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- return FALSE;
- }
- return FALSE;
-}
-
-static void
-add_relation (EDateEdit *dedit,
- GtkWidget *widget)
-{
- AtkObject *a11yEdit, *a11yWidget;
- AtkRelationSet *set;
- AtkRelation *relation;
- GPtrArray *target;
- gpointer target_object;
-
- /* add a labelled_by relation for widget for accessibility */
-
- a11yEdit = gtk_widget_get_accessible (GTK_WIDGET (dedit));
- a11yWidget = gtk_widget_get_accessible (widget);
-
- set = atk_object_ref_relation_set (a11yWidget);
- if (set != NULL) {
- relation = atk_relation_set_get_relation_by_type (
- set, ATK_RELATION_LABELLED_BY);
- /* check whether has a labelled_by relation already */
- if (relation != NULL)
- return;
- }
-
- set = atk_object_ref_relation_set (a11yEdit);
- if (!set)
- return;
-
- relation = atk_relation_set_get_relation_by_type (
- set, ATK_RELATION_LABELLED_BY);
- if (relation != NULL) {
- target = atk_relation_get_target (relation);
- target_object = g_ptr_array_index (target, 0);
- if (ATK_IS_OBJECT (target_object)) {
- atk_object_add_relationship (
- a11yWidget,
- ATK_RELATION_LABELLED_BY,
- ATK_OBJECT (target_object));
- }
- }
-}
-
-/* This sets the text in the date entry according to the current settings. */
-static void
-e_date_edit_update_date_entry (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- gchar buffer[100];
- struct tm tmp_tm = { 0 };
-
- priv = dedit->priv;
-
- if (priv->date_set_to_none || !priv->date_is_valid) {
- gtk_entry_set_text (GTK_ENTRY (priv->date_entry), C_("date", "None"));
- } else {
- /* This is a strftime() format for a short date.
- * %x the preferred date representation for the current locale
- * without the time, but is forced to use 4 digit year. */
- gchar *format = e_time_get_d_fmt_with_4digit_year ();
- time_t tt;
-
- tmp_tm.tm_year = priv->year;
- tmp_tm.tm_mon = priv->month;
- tmp_tm.tm_mday = priv->day;
- tmp_tm.tm_isdst = -1;
-
- /* initialize all 'struct tm' members properly */
- tt = mktime (&tmp_tm);
- if (tt && localtime (&tt))
- tmp_tm = *localtime (&tt);
-
- e_utf8_strftime (buffer, sizeof (buffer), format, &tmp_tm);
- g_free (format);
- gtk_entry_set_text (GTK_ENTRY (priv->date_entry), buffer);
- }
-
- add_relation (dedit, priv->date_entry);
- add_relation (dedit, priv->date_button);
-}
-
-/* This sets the text in the time entry according to the current settings. */
-static void
-e_date_edit_update_time_entry (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- GtkComboBox *combo_box;
- GtkWidget *child;
- gchar buffer[40];
- struct tm tmp_tm = { 0 };
-
- priv = dedit->priv;
-
- combo_box = GTK_COMBO_BOX (priv->time_combo);
- child = gtk_bin_get_child (GTK_BIN (priv->time_combo));
-
- if (priv->time_set_to_none || !priv->time_is_valid) {
- gtk_combo_box_set_active (combo_box, -1);
- gtk_entry_set_text (GTK_ENTRY (child), "");
- } else {
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid;
- gchar *b;
-
- /* Set these to reasonable values just in case. */
- tmp_tm.tm_year = 2000;
- tmp_tm.tm_mon = 0;
- tmp_tm.tm_mday = 1;
-
- tmp_tm.tm_hour = priv->hour;
- tmp_tm.tm_min = priv->minute;
-
- tmp_tm.tm_sec = 0;
- tmp_tm.tm_isdst = -1;
-
- if (priv->use_24_hour_format)
- /* This is a strftime() format.
- * %H = hour (0-23), %M = minute. */
- e_time_format_time (
- &tmp_tm, 1, 0, buffer, sizeof (buffer));
- else
- /* This is a strftime() format.
- * %I = hour (1-12), %M = minute, %p = am/pm. */
- e_time_format_time (
- &tmp_tm, 0, 0, buffer, sizeof (buffer));
-
- /* For 12-hour am/pm format, we want space padding, not
- * zero padding. This can be done with strftime's %l,
- * but it's a potentially unportable extension. */
- if (!priv->use_24_hour_format && buffer[0] == '0')
- buffer[0] = ' ';
-
- gtk_entry_set_text (GTK_ENTRY (child), buffer);
-
- /* truncate left spaces */
- b = buffer;
- while (*b == ' ')
- b++;
-
- model = gtk_combo_box_get_model (combo_box);
- valid = gtk_tree_model_get_iter_first (model, &iter);
-
- while (valid) {
- gchar *text = NULL;
-
- gtk_tree_model_get (model, &iter, 0, &text, -1);
- if (text) {
- gchar *t = text;
-
- /* truncate left spaces */
- while (*t == ' ')
- t++;
-
- if (strcmp (b, t) == 0) {
- gtk_combo_box_set_active_iter (
- combo_box, &iter);
- g_free (text);
- break;
- }
- }
-
- g_free (text);
-
- valid = gtk_tree_model_iter_next (model, &iter);
- }
- }
-
- add_relation (dedit, priv->time_combo);
-}
-
-static void
-e_date_edit_update_time_combo_state (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- gboolean show = TRUE, show_now_button = TRUE;
- gboolean clear_entry = FALSE, sensitive = TRUE;
- const gchar *text;
-
- priv = dedit->priv;
-
- /* If the date entry is currently shown, and it is set to None,
- * clear the time entry and disable the time combo. */
- if (priv->show_date && priv->date_set_to_none) {
- clear_entry = TRUE;
- sensitive = FALSE;
- }
-
- if (!priv->show_time) {
- if (priv->make_time_insensitive) {
- clear_entry = TRUE;
- sensitive = FALSE;
- } else {
- show = FALSE;
- }
-
- show_now_button = FALSE;
- }
-
- if (clear_entry) {
- GtkWidget *child;
-
- /* Only clear it if it isn't empty already. */
- child = gtk_bin_get_child (GTK_BIN (priv->time_combo));
- text = gtk_entry_get_text (GTK_ENTRY (child));
- if (text[0])
- gtk_entry_set_text (GTK_ENTRY (child), "");
- }
-
- gtk_widget_set_sensitive (priv->time_combo, sensitive);
-
- if (show)
- gtk_widget_show (priv->time_combo);
- else
- gtk_widget_hide (priv->time_combo);
-
- if (show_now_button)
- gtk_widget_show (priv->now_button);
- else
- gtk_widget_hide (priv->now_button);
-
- if (priv->show_date
- && (priv->show_time || priv->make_time_insensitive))
- gtk_widget_show (priv->space);
- else
- gtk_widget_hide (priv->space);
-}
-
-/* Parses the date, and if it is different from the current settings it
- * updates the settings and emits a "date_changed" signal. */
-static void
-e_date_edit_check_date_changed (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- const gchar *date_text;
- struct tm tmp_tm;
- gboolean none = FALSE, valid = TRUE, date_changed = FALSE;
-
- priv = dedit->priv;
-
- tmp_tm.tm_year = 0;
- tmp_tm.tm_mon = 0;
- tmp_tm.tm_mday = 0;
-
- date_text = gtk_entry_get_text (GTK_ENTRY (priv->date_entry));
- if (field_set_to_none (date_text)) {
- none = TRUE;
- } else if (!e_date_edit_parse_date (dedit, date_text, &tmp_tm)) {
- valid = FALSE;
- tmp_tm.tm_year = 0;
- tmp_tm.tm_mon = 0;
- tmp_tm.tm_mday = 0;
- }
-
- date_changed = e_date_edit_set_date_internal (
- dedit, valid, none,
- tmp_tm.tm_year,
- tmp_tm.tm_mon,
- tmp_tm.tm_mday);
-
- if (date_changed) {
- priv->has_been_changed = TRUE;
- g_signal_emit (dedit, signals[CHANGED], 0);
- }
-}
-
-/* Parses the time, and if it is different from the current settings it
- * updates the settings and emits a "time_changed" signal. */
-static void
-e_date_edit_check_time_changed (EDateEdit *dedit)
-{
- EDateEditPrivate *priv;
- GtkWidget *child;
- const gchar *time_text;
- struct tm tmp_tm;
- gboolean none = FALSE, valid = TRUE, time_changed;
-
- priv = dedit->priv;
-
- tmp_tm.tm_hour = 0;
- tmp_tm.tm_min = 0;
-
- child = gtk_bin_get_child (GTK_BIN (priv->time_combo));
- time_text = gtk_entry_get_text (GTK_ENTRY (child));
- if (field_set_to_none (time_text))
- none = TRUE;
- else if (!e_date_edit_parse_time (dedit, time_text, &tmp_tm))
- valid = FALSE;
-
- time_changed = e_date_edit_set_time_internal (
- dedit, valid, none,
- tmp_tm.tm_hour,
- tmp_tm.tm_min);
-
- if (time_changed) {
- e_date_edit_update_time_entry (dedit);
- g_signal_emit (dedit, signals[CHANGED], 0);
- }
-}
-
-/**
- * e_date_edit_date_is_valid:
- * @dedit: an #EDateEdit widget.
- * @Returns: TRUE if the last date entered was valid.
- *
- * Returns TRUE if the last date entered was valid.
- *
- * Note that if this returns FALSE, you can still use e_date_edit_get_time()
- * or e_date_edit_get_date() to get the last time or date entered which was
- * valid.
- */
-gboolean
-e_date_edit_date_is_valid (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- if (!dedit->priv->date_is_valid)
- return FALSE;
-
- /* If the date is empty/None and that isn't permitted, return FALSE. */
- if (dedit->priv->date_set_to_none
- && !e_date_edit_get_allow_no_date_set (dedit))
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * e_date_edit_time_is_valid:
- * @dedit: an #EDateEdit widget.
- * @Returns: TRUE if the last time entered was valid.
- *
- * Returns TRUE if the last time entered was valid.
- *
- * Note that if this returns FALSE, you can still use e_date_edit_get_time()
- * or e_date_edit_get_time_of_day() to get the last time or time of the day
- * entered which was valid.
- */
-gboolean
-e_date_edit_time_is_valid (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- if (!dedit->priv->time_is_valid)
- return FALSE;
-
- /* If the time is empty and that isn't permitted, return FALSE.
- * Note that we don't mind an empty time if the date field is shown
- * - in that case we just assume 0:00. */
- if (dedit->priv->time_set_to_none && !dedit->priv->show_date
- && !e_date_edit_get_allow_no_date_set (dedit))
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-e_date_edit_set_date_internal (EDateEdit *dedit,
- gboolean valid,
- gboolean none,
- gint year,
- gint month,
- gint day)
-{
- EDateEditPrivate *priv;
- gboolean date_changed = FALSE;
-
- priv = dedit->priv;
-
- if (!valid) {
- /* Date is invalid. */
- if (priv->date_is_valid) {
- priv->date_is_valid = FALSE;
- date_changed = TRUE;
- }
- } else if (none) {
- /* Date has been set to 'None'. */
- if (!priv->date_is_valid
- || !priv->date_set_to_none) {
- priv->date_is_valid = TRUE;
- priv->date_set_to_none = TRUE;
- date_changed = TRUE;
- }
- } else {
- /* Date has been set to a specific date. */
- if (!priv->date_is_valid
- || priv->date_set_to_none
- || priv->year != year
- || priv->month != month
- || priv->day != day) {
- priv->date_is_valid = TRUE;
- priv->date_set_to_none = FALSE;
- priv->year = year;
- priv->month = month;
- priv->day = day;
- date_changed = TRUE;
- }
- }
-
- return date_changed;
-}
-
-static gboolean
-e_date_edit_set_time_internal (EDateEdit *dedit,
- gboolean valid,
- gboolean none,
- gint hour,
- gint minute)
-{
- EDateEditPrivate *priv;
- gboolean time_changed = FALSE;
-
- priv = dedit->priv;
-
- if (!valid) {
- /* Time is invalid. */
- if (priv->time_is_valid) {
- priv->time_is_valid = FALSE;
- time_changed = TRUE;
- }
- } else if (none) {
- /* Time has been set to empty/'None'. */
- if (!priv->time_is_valid
- || !priv->time_set_to_none) {
- priv->time_is_valid = TRUE;
- priv->time_set_to_none = TRUE;
- time_changed = TRUE;
- }
- } else {
- /* Time has been set to a specific time. */
- if (!priv->time_is_valid
- || priv->time_set_to_none
- || priv->hour != hour
- || priv->minute != minute) {
- priv->time_is_valid = TRUE;
- priv->time_set_to_none = FALSE;
- priv->hour = hour;
- priv->minute = minute;
- time_changed = TRUE;
- }
- }
-
- return time_changed;
-}
-
-gboolean
-e_date_edit_get_twodigit_year_can_future (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
-
- return dedit->priv->twodigit_year_can_future;
-}
-
-void
-e_date_edit_set_twodigit_year_can_future (EDateEdit *dedit,
- gboolean value)
-{
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- dedit->priv->twodigit_year_can_future = value;
-}
-
-/* Sets a callback to use to get the current time. This is useful if the
- * application needs to use its own timezone data rather than rely on the
- * Unix timezone. */
-void
-e_date_edit_set_get_time_callback (EDateEdit *dedit,
- EDateEditGetTimeCallback cb,
- gpointer data,
- GDestroyNotify destroy)
-{
- EDateEditPrivate *priv;
-
- g_return_if_fail (E_IS_DATE_EDIT (dedit));
-
- priv = dedit->priv;
-
- if (priv->time_callback_data && priv->time_callback_destroy)
- (*priv->time_callback_destroy) (priv->time_callback_data);
-
- priv->time_callback = cb;
- priv->time_callback_data = data;
- priv->time_callback_destroy = destroy;
-
-}
-
-GtkWidget *
-e_date_edit_get_entry (EDateEdit *dedit)
-{
- g_return_val_if_fail (E_IS_DATE_EDIT (dedit), NULL);
-
- return GTK_WIDGET (dedit->priv->date_entry);
-}
diff --git a/widgets/misc/e-dateedit.h b/widgets/misc/e-dateedit.h
deleted file mode 100644
index 7da72ec975..0000000000
--- a/widgets/misc/e-dateedit.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * Based on the GnomeDateEdit, part of the Gnome Library.
- * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library 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
- */
-
-/*
- * EDateEdit - a widget based on GnomeDateEdit to provide a date & optional
- * time field with popups for entering a date.
- *
- * It emits a "changed" signal when the date and/or time has changed.
- * You can check if the last date or time entered was invalid by
- * calling e_date_edit_date_is_valid() and e_date_edit_time_is_valid().
- *
- * Note that when the user types in a date or time, it will only emit the
- * signals when the user presses the return key or switches the keyboard
- * focus to another widget, or you call one of the _get_time/date functions.
- */
-
-#ifndef E_DATE_EDIT_H
-#define E_DATE_EDIT_H
-
-#include <time.h>
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_DATE_EDIT \
- (e_date_edit_get_type ())
-#define E_DATE_EDIT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_DATE_EDIT, EDateEdit))
-#define E_DATE_EDIT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_DATE_EDIT, EDateEditClass))
-#define E_IS_DATE_EDIT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_DATE_EDIT))
-#define E_IS_DATE_EDIT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_DATE_EDIT))
-#define E_DATE_EDIT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_DATE_EDIT, EDateEditClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EDateEdit EDateEdit;
-typedef struct _EDateEditClass EDateEditClass;
-typedef struct _EDateEditPrivate EDateEditPrivate;
-
-/* The type of the callback function optionally used to get the current time.
- */
-typedef struct tm (*EDateEditGetTimeCallback)
- (EDateEdit *dedit,
- gpointer data);
-
-struct _EDateEdit {
- GtkBox hbox;
- EDateEditPrivate *priv;
-};
-
-struct _EDateEditClass {
- GtkBoxClass parent_class;
-
- /* Signals */
- void (*changed) (EDateEdit *dedit);
-};
-
-GType e_date_edit_get_type (void);
-GtkWidget * e_date_edit_new (void);
-
-/* Analogous to gtk_editable_set_editable. disable editing, while still
- * allowing selection. */
-void e_date_edit_set_editable (EDateEdit *dedit,
- gboolean editable);
-
-/* Returns TRUE if the last date and time set were valid. The date and time
- * are only set when the user hits Return or switches keyboard focus, or
- * selects a date or time from the popup. */
-gboolean e_date_edit_date_is_valid (EDateEdit *dedit);
-gboolean e_date_edit_time_is_valid (EDateEdit *dedit);
-
-/* Returns the last valid date & time set, or -1 if the date & time was set to
- * 'None' and this is permitted via e_date_edit_set_allow_no_date_set. */
-time_t e_date_edit_get_time (EDateEdit *dedit);
-void e_date_edit_set_time (EDateEdit *dedit,
- time_t the_time);
-
-/* This returns the last valid date set, without the time. It returns TRUE
- * if a date is set, or FALSE if the date is set to 'None' and this is
- * permitted via e_date_edit_set_allow_no_date_set. (Month is 1 - 12). */
-gboolean e_date_edit_get_date (EDateEdit *dedit,
- gint *year,
- gint *month,
- gint *day);
-void e_date_edit_set_date (EDateEdit *dedit,
- gint year,
- gint month,
- gint day);
-
-/* This returns the last valid time set, without the date. It returns TRUE
- * if a time is set, or FALSE if the time is set to 'None' and this is
- * permitted via e_date_edit_set_allow_no_date_set. */
-gboolean e_date_edit_get_time_of_day (EDateEdit *dedit,
- gint *hour,
- gint *minute);
-/* Set the time. Pass -1 as hour to set to empty. */
-void e_date_edit_set_time_of_day (EDateEdit *dedit,
- gint hour,
- gint minute);
-
-void e_date_edit_set_date_and_time_of_day
- (EDateEdit *dedit,
- gint year,
- gint month,
- gint day,
- gint hour,
- gint minute);
-
-/* Whether we show the date field. */
-gboolean e_date_edit_get_show_date (EDateEdit *dedit);
-void e_date_edit_set_show_date (EDateEdit *dedit,
- gboolean show_date);
-
-/* Whether we show the time field. */
-gboolean e_date_edit_get_show_time (EDateEdit *dedit);
-void e_date_edit_set_show_time (EDateEdit *dedit,
- gboolean show_time);
-
-/* The week start day, used in the date popup. 0 (Mon) to 6 (Sun). */
-gint e_date_edit_get_week_start_day (EDateEdit *dedit);
-void e_date_edit_set_week_start_day (EDateEdit *dedit,
- gint week_start_day);
-
-/* Whether we show week numbers in the date popup. */
-gboolean e_date_edit_get_show_week_numbers
- (EDateEdit *dedit);
-void e_date_edit_set_show_week_numbers
- (EDateEdit *dedit,
- gboolean show_week_numbers);
-
-/* Whether we use 24 hour format in the time field & popup. */
-gboolean e_date_edit_get_use_24_hour_format
- (EDateEdit *dedit);
-void e_date_edit_set_use_24_hour_format
- (EDateEdit *dedit,
- gboolean use_24_hour_format);
-
-/* Whether we allow the date to be set to 'None'. e_date_edit_get_time() will
- * return (time_t) -1 in this case. */
-gboolean e_date_edit_get_allow_no_date_set
- (EDateEdit *dedit);
-void e_date_edit_set_allow_no_date_set
- (EDateEdit *dedit,
- gboolean allow_no_date_set);
-
-/* The range of time to show in the time combo popup. */
-void e_date_edit_get_time_popup_range
- (EDateEdit *dedit,
- gint *lower_hour,
- gint *upper_hour);
-void e_date_edit_set_time_popup_range
- (EDateEdit *dedit,
- gint lower_hour,
- gint upper_hour);
-
-/* Whether the time field is made insensitive rather than hiding it. */
-gboolean e_date_edit_get_make_time_insensitive
- (EDateEdit *dedit);
-void e_date_edit_set_make_time_insensitive
- (EDateEdit *dedit,
- gboolean make_insensitive);
-
-/* Whether two-digit years in date could be modified as in future; default is TRUE */
-gboolean e_date_edit_get_twodigit_year_can_future
- (EDateEdit *dedit);
-void e_date_edit_set_twodigit_year_can_future
- (EDateEdit *dedit,
- gboolean value);
-
-/* Sets a callback to use to get the current time. This is useful if the
- * application needs to use its own timezone data rather than rely on the
- * Unix timezone. */
-void e_date_edit_set_get_time_callback
- (EDateEdit *dedit,
- EDateEditGetTimeCallback cb,
- gpointer data,
- GDestroyNotify destroy);
-
-GtkWidget * e_date_edit_get_entry (EDateEdit *dedit);
-
-G_END_DECLS
-
-#endif /* E_DATE_EDIT_H */
diff --git a/widgets/misc/e-focus-tracker.c b/widgets/misc/e-focus-tracker.c
deleted file mode 100644
index 505d991a2f..0000000000
--- a/widgets/misc/e-focus-tracker.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/*
- * e-focus-tracker.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-focus-tracker.h"
-
-#include <glib/gi18n-lib.h>
-
-#include <misc/e-selectable.h>
-
-#define E_FOCUS_TRACKER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_FOCUS_TRACKER, EFocusTrackerPrivate))
-
-struct _EFocusTrackerPrivate {
- GtkWidget *focus; /* not referenced */
- GtkWindow *window;
-
- GtkAction *cut_clipboard;
- GtkAction *copy_clipboard;
- GtkAction *paste_clipboard;
- GtkAction *delete_selection;
- GtkAction *select_all;
-};
-
-enum {
- PROP_0,
- PROP_FOCUS,
- PROP_WINDOW,
- PROP_CUT_CLIPBOARD_ACTION,
- PROP_COPY_CLIPBOARD_ACTION,
- PROP_PASTE_CLIPBOARD_ACTION,
- PROP_DELETE_SELECTION_ACTION,
- PROP_SELECT_ALL_ACTION
-};
-
-G_DEFINE_TYPE (
- EFocusTracker,
- e_focus_tracker,
- G_TYPE_OBJECT)
-
-static void
-focus_tracker_disable_actions (EFocusTracker *focus_tracker)
-{
- GtkAction *action;
-
- action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
- if (action != NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
- if (action != NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
- if (action != NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_delete_selection_action (focus_tracker);
- if (action != NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_select_all_action (focus_tracker);
- if (action != NULL)
- gtk_action_set_sensitive (action, FALSE);
-}
-
-static void
-focus_tracker_editable_update_actions (EFocusTracker *focus_tracker,
- GtkEditable *editable,
- GdkAtom *targets,
- gint n_targets)
-{
- GtkAction *action;
- gboolean can_edit_text;
- gboolean clipboard_has_text;
- gboolean text_is_selected;
- gboolean sensitive;
-
- can_edit_text =
- gtk_editable_get_editable (editable);
-
- clipboard_has_text = (targets != NULL) &&
- gtk_targets_include_text (targets, n_targets);
-
- text_is_selected =
- gtk_editable_get_selection_bounds (editable, NULL, NULL);
-
- action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
- if (action != NULL) {
- sensitive = can_edit_text && text_is_selected;
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, _("Cut the selection"));
- }
-
- action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
- if (action != NULL) {
- sensitive = text_is_selected;
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, _("Copy the selection"));
- }
-
- action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
- if (action != NULL) {
- sensitive = can_edit_text && clipboard_has_text;
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, _("Paste the clipboard"));
- }
-
- action = e_focus_tracker_get_delete_selection_action (focus_tracker);
- if (action != NULL) {
- sensitive = can_edit_text && text_is_selected;
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, _("Delete the selection"));
- }
-
- action = e_focus_tracker_get_select_all_action (focus_tracker);
- if (action != NULL) {
- sensitive = TRUE; /* always enabled */
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, _("Select all text"));
- }
-}
-
-static void
-focus_tracker_selectable_update_actions (EFocusTracker *focus_tracker,
- ESelectable *selectable,
- GdkAtom *targets,
- gint n_targets)
-{
- ESelectableInterface *interface;
- GtkAction *action;
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- e_selectable_update_actions (
- selectable, focus_tracker, targets, n_targets);
-
- /* Disable actions for which the corresponding method is not
- * implemented. This allows update_actions() implementations
- * to simply skip the actions they don't support, which in turn
- * allows us to add new actions without disturbing the existing
- * ESelectable implementations. */
-
- action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
- if (action != NULL && interface->cut_clipboard == NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
- if (action != NULL && interface->copy_clipboard == NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
- if (action != NULL && interface->paste_clipboard == NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_delete_selection_action (focus_tracker);
- if (action != NULL && interface->delete_selection == NULL)
- gtk_action_set_sensitive (action, FALSE);
-
- action = e_focus_tracker_get_select_all_action (focus_tracker);
- if (action != NULL && interface->select_all == NULL)
- gtk_action_set_sensitive (action, FALSE);
-}
-
-static void
-focus_tracker_targets_received_cb (GtkClipboard *clipboard,
- GdkAtom *targets,
- gint n_targets,
- EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (focus == NULL)
- focus_tracker_disable_actions (focus_tracker);
-
- else if (GTK_IS_EDITABLE (focus))
- focus_tracker_editable_update_actions (
- focus_tracker, GTK_EDITABLE (focus),
- targets, n_targets);
-
- else if (E_IS_SELECTABLE (focus))
- focus_tracker_selectable_update_actions (
- focus_tracker, E_SELECTABLE (focus),
- targets, n_targets);
-
- g_object_unref (focus_tracker);
-}
-
-static void
-focus_tracker_set_focus_cb (GtkWindow *window,
- GtkWidget *focus,
- EFocusTracker *focus_tracker)
-{
- while (focus != NULL) {
- if (GTK_IS_EDITABLE (focus))
- break;
-
- if (E_IS_SELECTABLE (focus))
- break;
-
- focus = gtk_widget_get_parent (focus);
- }
-
- if (focus == focus_tracker->priv->focus)
- return;
-
- focus_tracker->priv->focus = focus;
- g_object_notify (G_OBJECT (focus_tracker), "focus");
-
- e_focus_tracker_update_actions (focus_tracker);
-}
-
-static void
-focus_tracker_set_window (EFocusTracker *focus_tracker,
- GtkWindow *window)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (focus_tracker->priv->window == NULL);
-
- focus_tracker->priv->window = g_object_ref (window);
-
- g_signal_connect (
- window, "set-focus",
- G_CALLBACK (focus_tracker_set_focus_cb), focus_tracker);
-}
-
-static void
-focus_tracker_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_WINDOW:
- focus_tracker_set_window (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
-
- case PROP_CUT_CLIPBOARD_ACTION:
- e_focus_tracker_set_cut_clipboard_action (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
-
- case PROP_COPY_CLIPBOARD_ACTION:
- e_focus_tracker_set_copy_clipboard_action (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
-
- case PROP_PASTE_CLIPBOARD_ACTION:
- e_focus_tracker_set_paste_clipboard_action (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
-
- case PROP_DELETE_SELECTION_ACTION:
- e_focus_tracker_set_delete_selection_action (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
-
- case PROP_SELECT_ALL_ACTION:
- e_focus_tracker_set_select_all_action (
- E_FOCUS_TRACKER (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-focus_tracker_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_FOCUS:
- g_value_set_object (
- value,
- e_focus_tracker_get_focus (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_WINDOW:
- g_value_set_object (
- value,
- e_focus_tracker_get_window (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_CUT_CLIPBOARD_ACTION:
- g_value_set_object (
- value,
- e_focus_tracker_get_cut_clipboard_action (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_COPY_CLIPBOARD_ACTION:
- g_value_set_object (
- value,
- e_focus_tracker_get_copy_clipboard_action (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_PASTE_CLIPBOARD_ACTION:
- g_value_set_object (
- value,
- e_focus_tracker_get_paste_clipboard_action (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_DELETE_SELECTION_ACTION:
- g_value_set_object (
- value,
- e_focus_tracker_get_delete_selection_action (
- E_FOCUS_TRACKER (object)));
- return;
-
- case PROP_SELECT_ALL_ACTION:
- g_value_set_object (
- value,
- e_focus_tracker_get_select_all_action (
- E_FOCUS_TRACKER (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-focus_tracker_dispose (GObject *object)
-{
- EFocusTrackerPrivate *priv;
-
- priv = E_FOCUS_TRACKER_GET_PRIVATE (object);
-
- g_signal_handlers_disconnect_matched (
- gtk_clipboard_get (GDK_SELECTION_PRIMARY),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object);
-
- g_signal_handlers_disconnect_matched (
- gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object);
-
- if (priv->window != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->window, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->window);
- priv->window = NULL;
- }
-
- if (priv->cut_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->cut_clipboard, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->cut_clipboard);
- priv->cut_clipboard = NULL;
- }
-
- if (priv->copy_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->copy_clipboard, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->copy_clipboard);
- priv->copy_clipboard = NULL;
- }
-
- if (priv->paste_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->paste_clipboard, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->paste_clipboard);
- priv->paste_clipboard = NULL;
- }
-
- if (priv->delete_selection != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->delete_selection, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->delete_selection);
- priv->delete_selection = NULL;
- }
-
- if (priv->select_all != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->select_all, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->select_all);
- priv->select_all = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_focus_tracker_parent_class)->dispose (object);
-}
-
-static void
-focus_tracker_constructed (GObject *object)
-{
- GtkClipboard *clipboard;
-
- /* Listen for "owner-change" signals from the primary selection
- * clipboard to learn when text selections change in GtkEditable
- * widgets. It's a bit of an overkill, but I don't know of any
- * other notification mechanism. */
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
-
- g_signal_connect_swapped (
- clipboard, "owner-change",
- G_CALLBACK (e_focus_tracker_update_actions), object);
-
- /* Listen for "owner-change" signals from the default clipboard
- * so we can update the paste action when the user cuts or copies
- * something. This is how GEdit does it. */
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-
- g_signal_connect_swapped (
- clipboard, "owner-change",
- G_CALLBACK (e_focus_tracker_update_actions), object);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_focus_tracker_parent_class)->constructed (object);
-}
-
-static void
-e_focus_tracker_class_init (EFocusTrackerClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EFocusTrackerPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = focus_tracker_set_property;
- object_class->get_property = focus_tracker_get_property;
- object_class->dispose = focus_tracker_dispose;
- object_class->constructed = focus_tracker_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_FOCUS,
- g_param_spec_object (
- "focus",
- "Focus",
- NULL,
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_WINDOW,
- g_param_spec_object (
- "window",
- "Window",
- NULL,
- GTK_TYPE_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (
- object_class,
- PROP_CUT_CLIPBOARD_ACTION,
- g_param_spec_object (
- "cut-clipboard-action",
- "Cut Clipboard Action",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_COPY_CLIPBOARD_ACTION,
- g_param_spec_object (
- "copy-clipboard-action",
- "Copy Clipboard Action",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_PASTE_CLIPBOARD_ACTION,
- g_param_spec_object (
- "paste-clipboard-action",
- "Paste Clipboard Action",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_DELETE_SELECTION_ACTION,
- g_param_spec_object (
- "delete-selection-action",
- "Delete Selection Action",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SELECT_ALL_ACTION,
- g_param_spec_object (
- "select-all-action",
- "Select All Action",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-}
-
-static void
-e_focus_tracker_init (EFocusTracker *focus_tracker)
-{
- GtkAction *action;
-
- focus_tracker->priv = E_FOCUS_TRACKER_GET_PRIVATE (focus_tracker);
-
- /* Define dummy actions. These will most likely be overridden,
- * but for cases where they're not it ensures ESelectable objects
- * will always get a valid GtkAction when they ask us for one. */
-
- action = gtk_action_new (
- "cut-clipboard", NULL,
- _("Cut the selection"), GTK_STOCK_CUT);
- focus_tracker->priv->cut_clipboard = action;
-
- action = gtk_action_new (
- "copy-clipboard", NULL,
- _("Copy the selection"), GTK_STOCK_COPY);
- focus_tracker->priv->copy_clipboard = action;
-
- action = gtk_action_new (
- "paste-clipboard", NULL,
- _("Paste the clipboard"), GTK_STOCK_PASTE);
- focus_tracker->priv->paste_clipboard = action;
-
- action = gtk_action_new (
- "delete-selection", NULL,
- _("Delete the selection"), GTK_STOCK_DELETE);
- focus_tracker->priv->delete_selection = action;
-
- action = gtk_action_new (
- "select-all", NULL,
- _("Select all text"), GTK_STOCK_SELECT_ALL);
- focus_tracker->priv->select_all = action;
-}
-
-EFocusTracker *
-e_focus_tracker_new (GtkWindow *window)
-{
- g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
-
- return g_object_new (E_TYPE_FOCUS_TRACKER, "window", window, NULL);
-}
-
-GtkWidget *
-e_focus_tracker_get_focus (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->focus;
-}
-
-GtkWindow *
-e_focus_tracker_get_window (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->window;
-}
-
-GtkAction *
-e_focus_tracker_get_cut_clipboard_action (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->cut_clipboard;
-}
-
-void
-e_focus_tracker_set_cut_clipboard_action (EFocusTracker *focus_tracker,
- GtkAction *cut_clipboard)
-{
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- if (cut_clipboard != NULL) {
- g_return_if_fail (GTK_IS_ACTION (cut_clipboard));
- g_object_ref (cut_clipboard);
- }
-
- if (focus_tracker->priv->cut_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- focus_tracker->priv->cut_clipboard,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- focus_tracker);
- g_object_unref (focus_tracker->priv->cut_clipboard);
- }
-
- focus_tracker->priv->cut_clipboard = cut_clipboard;
-
- if (cut_clipboard != NULL)
- g_signal_connect_swapped (
- cut_clipboard, "activate",
- G_CALLBACK (e_focus_tracker_cut_clipboard),
- focus_tracker);
-
- g_object_notify (G_OBJECT (focus_tracker), "cut-clipboard-action");
-}
-
-GtkAction *
-e_focus_tracker_get_copy_clipboard_action (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->copy_clipboard;
-}
-
-void
-e_focus_tracker_set_copy_clipboard_action (EFocusTracker *focus_tracker,
- GtkAction *copy_clipboard)
-{
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- if (copy_clipboard != NULL) {
- g_return_if_fail (GTK_IS_ACTION (copy_clipboard));
- g_object_ref (copy_clipboard);
- }
-
- if (focus_tracker->priv->copy_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- focus_tracker->priv->copy_clipboard,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- focus_tracker);
- g_object_unref (focus_tracker->priv->copy_clipboard);
- }
-
- focus_tracker->priv->copy_clipboard = copy_clipboard;
-
- if (copy_clipboard != NULL)
- g_signal_connect_swapped (
- copy_clipboard, "activate",
- G_CALLBACK (e_focus_tracker_copy_clipboard),
- focus_tracker);
-
- g_object_notify (G_OBJECT (focus_tracker), "copy-clipboard-action");
-}
-
-GtkAction *
-e_focus_tracker_get_paste_clipboard_action (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->paste_clipboard;
-}
-
-void
-e_focus_tracker_set_paste_clipboard_action (EFocusTracker *focus_tracker,
- GtkAction *paste_clipboard)
-{
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- if (paste_clipboard != NULL) {
- g_return_if_fail (GTK_IS_ACTION (paste_clipboard));
- g_object_ref (paste_clipboard);
- }
-
- if (focus_tracker->priv->paste_clipboard != NULL) {
- g_signal_handlers_disconnect_matched (
- focus_tracker->priv->paste_clipboard,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- focus_tracker);
- g_object_unref (focus_tracker->priv->paste_clipboard);
- }
-
- focus_tracker->priv->paste_clipboard = paste_clipboard;
-
- if (paste_clipboard != NULL)
- g_signal_connect_swapped (
- paste_clipboard, "activate",
- G_CALLBACK (e_focus_tracker_paste_clipboard),
- focus_tracker);
-
- g_object_notify (G_OBJECT (focus_tracker), "paste-clipboard-action");
-}
-
-GtkAction *
-e_focus_tracker_get_delete_selection_action (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->delete_selection;
-}
-
-void
-e_focus_tracker_set_delete_selection_action (EFocusTracker *focus_tracker,
- GtkAction *delete_selection)
-{
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- if (delete_selection != NULL) {
- g_return_if_fail (GTK_IS_ACTION (delete_selection));
- g_object_ref (delete_selection);
- }
-
- if (focus_tracker->priv->delete_selection != NULL) {
- g_signal_handlers_disconnect_matched (
- focus_tracker->priv->delete_selection,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- focus_tracker);
- g_object_unref (focus_tracker->priv->delete_selection);
- }
-
- focus_tracker->priv->delete_selection = delete_selection;
-
- if (delete_selection != NULL)
- g_signal_connect_swapped (
- delete_selection, "activate",
- G_CALLBACK (e_focus_tracker_delete_selection),
- focus_tracker);
-
- g_object_notify (G_OBJECT (focus_tracker), "delete-selection-action");
-}
-
-GtkAction *
-e_focus_tracker_get_select_all_action (EFocusTracker *focus_tracker)
-{
- g_return_val_if_fail (E_IS_FOCUS_TRACKER (focus_tracker), NULL);
-
- return focus_tracker->priv->select_all;
-}
-
-void
-e_focus_tracker_set_select_all_action (EFocusTracker *focus_tracker,
- GtkAction *select_all)
-{
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- if (select_all != NULL) {
- g_return_if_fail (GTK_IS_ACTION (select_all));
- g_object_ref (select_all);
- }
-
- if (focus_tracker->priv->select_all != NULL) {
- g_signal_handlers_disconnect_matched (
- focus_tracker->priv->select_all,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- focus_tracker);
- g_object_unref (focus_tracker->priv->select_all);
- }
-
- focus_tracker->priv->select_all = select_all;
-
- if (select_all != NULL)
- g_signal_connect_swapped (
- select_all, "activate",
- G_CALLBACK (e_focus_tracker_select_all),
- focus_tracker);
-
- g_object_notify (G_OBJECT (focus_tracker), "select-all-action");
-}
-
-void
-e_focus_tracker_update_actions (EFocusTracker *focus_tracker)
-{
- GtkClipboard *clipboard;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- /* Request clipboard targets asynchronously. */
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-
- gtk_clipboard_request_targets (
- clipboard, (GtkClipboardTargetsReceivedFunc)
- focus_tracker_targets_received_cb,
- g_object_ref (focus_tracker));
-}
-
-void
-e_focus_tracker_cut_clipboard (EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (GTK_IS_EDITABLE (focus))
- gtk_editable_cut_clipboard (GTK_EDITABLE (focus));
-
- else if (E_IS_SELECTABLE (focus))
- e_selectable_cut_clipboard (E_SELECTABLE (focus));
-}
-
-void
-e_focus_tracker_copy_clipboard (EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (GTK_IS_EDITABLE (focus))
- gtk_editable_copy_clipboard (GTK_EDITABLE (focus));
-
- else if (E_IS_SELECTABLE (focus))
- e_selectable_copy_clipboard (E_SELECTABLE (focus));
-}
-
-void
-e_focus_tracker_paste_clipboard (EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (GTK_IS_EDITABLE (focus))
- gtk_editable_paste_clipboard (GTK_EDITABLE (focus));
-
- else if (E_IS_SELECTABLE (focus))
- e_selectable_paste_clipboard (E_SELECTABLE (focus));
-}
-
-void
-e_focus_tracker_delete_selection (EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (GTK_IS_EDITABLE (focus))
- gtk_editable_delete_selection (GTK_EDITABLE (focus));
-
- else if (E_IS_SELECTABLE (focus))
- e_selectable_delete_selection (E_SELECTABLE (focus));
-}
-
-void
-e_focus_tracker_select_all (EFocusTracker *focus_tracker)
-{
- GtkWidget *focus;
-
- g_return_if_fail (E_IS_FOCUS_TRACKER (focus_tracker));
-
- focus = e_focus_tracker_get_focus (focus_tracker);
-
- if (GTK_IS_EDITABLE (focus))
- gtk_editable_select_region (GTK_EDITABLE (focus), 0, -1);
-
- else if (E_IS_SELECTABLE (focus))
- e_selectable_select_all (E_SELECTABLE (focus));
-}
diff --git a/widgets/misc/e-focus-tracker.h b/widgets/misc/e-focus-tracker.h
deleted file mode 100644
index 86b206e240..0000000000
--- a/widgets/misc/e-focus-tracker.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * e-focus-tracker.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_FOCUS_TRACKER_H
-#define E_FOCUS_TRACKER_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_FOCUS_TRACKER \
- (e_focus_tracker_get_type ())
-#define E_FOCUS_TRACKER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_FOCUS_TRACKER, EFocusTracker))
-#define E_FOCUS_TRACKER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_FOCUS_TRACKER, EFocusTrackerClass))
-#define E_IS_FOCUS_TRACKER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_FOCUS_TRACKER))
-#define E_IS_FOCUS_TRACKER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_FOCUS_TRACKER))
-#define E_FOCUS_TRACKER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_FOCUS_TRACKER, EFocusTrackerClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EFocusTracker EFocusTracker;
-typedef struct _EFocusTrackerClass EFocusTrackerClass;
-typedef struct _EFocusTrackerPrivate EFocusTrackerPrivate;
-
-struct _EFocusTracker {
- GObject parent;
- EFocusTrackerPrivate *priv;
-};
-
-struct _EFocusTrackerClass {
- GObjectClass parent_class;
-};
-
-GType e_focus_tracker_get_type (void);
-EFocusTracker * e_focus_tracker_new (GtkWindow *window);
-GtkWidget * e_focus_tracker_get_focus (EFocusTracker *focus_tracker);
-GtkWindow * e_focus_tracker_get_window (EFocusTracker *focus_tracker);
-GtkAction * e_focus_tracker_get_cut_clipboard_action
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_set_cut_clipboard_action
- (EFocusTracker *focus_tracker,
- GtkAction *cut_clipboard);
-GtkAction * e_focus_tracker_get_copy_clipboard_action
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_set_copy_clipboard_action
- (EFocusTracker *focus_tracker,
- GtkAction *copy_clipboard);
-GtkAction * e_focus_tracker_get_paste_clipboard_action
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_set_paste_clipboard_action
- (EFocusTracker *focus_tracker,
- GtkAction *paste_clipboard);
-GtkAction * e_focus_tracker_get_delete_selection_action
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_set_delete_selection_action
- (EFocusTracker *focus_tracker,
- GtkAction *delete_selection);
-GtkAction * e_focus_tracker_get_select_all_action
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_set_select_all_action
- (EFocusTracker *focus_tracker,
- GtkAction *select_all);
-void e_focus_tracker_update_actions (EFocusTracker *focus_tracker);
-void e_focus_tracker_cut_clipboard (EFocusTracker *focus_tracker);
-void e_focus_tracker_copy_clipboard (EFocusTracker *focus_tracker);
-void e_focus_tracker_paste_clipboard (EFocusTracker *focus_tracker);
-void e_focus_tracker_delete_selection
- (EFocusTracker *focus_tracker);
-void e_focus_tracker_select_all (EFocusTracker *focus_tracker);
-
-G_END_DECLS
-
-#endif /* E_FOCUS_TRACKER_H */
diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c
deleted file mode 100644
index 5fe6941d58..0000000000
--- a/widgets/misc/e-image-chooser.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * e-image-chooser.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include <glib/gi18n.h>
-
-#include "e-image-chooser.h"
-#include "e-util/e-util.h"
-#include "e-util/e-icon-factory.h"
-
-#define E_IMAGE_CHOOSER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_IMAGE_CHOOSER, EImageChooserPrivate))
-
-struct _EImageChooserPrivate {
- GtkWidget *frame;
- GtkWidget *image;
-
- gchar *image_buf;
- gint image_buf_size;
- gint image_width;
- gint image_height;
-
- /* Default Image */
- gchar *icon_name;
-};
-
-enum {
- PROP_0,
- PROP_ICON_NAME
-};
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-#define URI_LIST_TYPE "text/uri-list"
-
-G_DEFINE_TYPE (
- EImageChooser,
- e_image_chooser,
- GTK_TYPE_VBOX)
-
-static gboolean
-set_image_from_data (EImageChooser *chooser,
- gchar *data,
- gint length)
-{
- GdkPixbufLoader *loader;
- GdkPixbuf *pixbuf;
- gfloat scale;
- gint new_height;
- gint new_width;
-
- loader = gdk_pixbuf_loader_new ();
- gdk_pixbuf_loader_write (loader, (guchar *) data, length, NULL);
- gdk_pixbuf_loader_close (loader, NULL);
-
- pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
- if (pixbuf)
- g_object_ref (pixbuf);
-
- g_object_unref (loader);
-
- if (pixbuf == NULL)
- return FALSE;
-
- new_height = gdk_pixbuf_get_height (pixbuf);
- new_width = gdk_pixbuf_get_width (pixbuf);
-
- if (chooser->priv->image_height == 0
- && chooser->priv->image_width == 0) {
- scale = 1.0;
- } else if (chooser->priv->image_height < new_height
- || chooser->priv->image_width < new_width) {
- /* we need to scale down */
- if (new_height > new_width)
- scale = (gfloat) chooser->priv->image_height / new_height;
- else
- scale = (gfloat) chooser->priv->image_width / new_width;
- } else {
- /* we need to scale up */
- if (new_height > new_width)
- scale = (gfloat) new_height / chooser->priv->image_height;
- else
- scale = (gfloat) new_width / chooser->priv->image_width;
- }
-
- if (scale == 1.0) {
- gtk_image_set_from_pixbuf (
- GTK_IMAGE (chooser->priv->image), pixbuf);
- chooser->priv->image_width = new_width;
- chooser->priv->image_height = new_height;
- } else {
- GdkPixbuf *scaled;
- GdkPixbuf *composite;
-
- new_width *= scale;
- new_height *= scale;
- new_width = MIN (new_width, chooser->priv->image_width);
- new_height = MIN (new_height, chooser->priv->image_height);
-
- scaled = gdk_pixbuf_scale_simple (
- pixbuf, new_width, new_height,
- GDK_INTERP_BILINEAR);
-
- composite = gdk_pixbuf_new (
- GDK_COLORSPACE_RGB, TRUE,
- gdk_pixbuf_get_bits_per_sample (pixbuf),
- chooser->priv->image_width,
- chooser->priv->image_height);
-
- gdk_pixbuf_fill (composite, 0x00000000);
-
- gdk_pixbuf_copy_area (
- scaled, 0, 0, new_width, new_height,
- composite,
- chooser->priv->image_width / 2 - new_width / 2,
- chooser->priv->image_height / 2 - new_height / 2);
-
- gtk_image_set_from_pixbuf (
- GTK_IMAGE (chooser->priv->image), composite);
-
- g_object_unref (scaled);
- g_object_unref (composite);
- }
-
- g_object_unref (pixbuf);
-
- g_free (chooser->priv->image_buf);
- chooser->priv->image_buf = data;
- chooser->priv->image_buf_size = length;
-
- g_signal_emit (chooser, signals[CHANGED], 0);
-
- return TRUE;
-}
-
-static gboolean
-image_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EImageChooser *chooser)
-{
- GtkFrame *frame;
- GList *targets, *p;
-
- frame = GTK_FRAME (chooser->priv->frame);
- targets = gdk_drag_context_list_targets (context);
-
- for (p = targets; p != NULL; p = p->next) {
- gchar *possible_type;
-
- possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
- if (!strcmp (possible_type, URI_LIST_TYPE)) {
- g_free (possible_type);
- gdk_drag_status (context, GDK_ACTION_COPY, time);
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_IN);
- return TRUE;
- }
-
- g_free (possible_type);
- }
-
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_NONE);
-
- return FALSE;
-}
-
-static void
-image_drag_leave_cb (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- EImageChooser *chooser)
-{
- GtkFrame *frame;
-
- frame = GTK_FRAME (chooser->priv->frame);
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_NONE);
-}
-
-static gboolean
-image_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EImageChooser *chooser)
-{
- GtkFrame *frame;
- GList *targets, *p;
-
- frame = GTK_FRAME (chooser->priv->frame);
- targets = gdk_drag_context_list_targets (context);
-
- if (targets == NULL) {
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_NONE);
- return FALSE;
- }
-
- for (p = targets; p != NULL; p = p->next) {
- gchar *possible_type;
-
- possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
- if (!strcmp (possible_type, URI_LIST_TYPE)) {
- g_free (possible_type);
- gtk_drag_get_data (
- widget, context,
- GDK_POINTER_TO_ATOM (p->data), time);
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_NONE);
- return TRUE;
- }
-
- g_free (possible_type);
- }
-
- gtk_frame_set_shadow_type (frame, GTK_SHADOW_NONE);
-
- return FALSE;
-}
-
-static void
-image_chooser_file_loaded_cb (GFile *file,
- GAsyncResult *result,
- EImageChooser *chooser)
-{
- gchar *contents;
- gsize length;
- GError *error = NULL;
-
- g_file_load_contents_finish (
- file, result, &contents, &length, NULL, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- goto exit;
- }
-
- set_image_from_data (chooser, contents, length);
-
- g_free (contents);
-
-exit:
- g_object_unref (chooser);
-}
-
-static void
-image_drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EImageChooser *chooser)
-{
- GFile *file;
- gboolean handled = FALSE;
- gchar **uris;
-
- uris = gtk_selection_data_get_uris (selection_data);
-
- if (uris == NULL)
- goto exit;
-
- file = g_file_new_for_uri (uris[0]);
-
- /* XXX Not cancellable. */
- g_file_load_contents_async (
- file, NULL, (GAsyncReadyCallback)
- image_chooser_file_loaded_cb,
- g_object_ref (chooser));
-
- g_object_unref (file);
- g_strfreev (uris);
-
- /* Assume success. We won't know til later. */
- handled = TRUE;
-
-exit:
- gtk_drag_finish (context, handled, FALSE, time);
-}
-
-static void
-image_chooser_set_icon_name (EImageChooser *chooser,
- const gchar *icon_name)
-{
- GtkIconTheme *icon_theme;
- GtkIconInfo *icon_info;
- const gchar *filename;
- gint width, height;
-
- g_return_if_fail (chooser->priv->icon_name == NULL);
-
- chooser->priv->icon_name = g_strdup (icon_name);
-
- icon_theme = gtk_icon_theme_get_default ();
- gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, &height);
-
- icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, icon_name, height, 0);
- g_return_if_fail (icon_info != NULL);
-
- filename = gtk_icon_info_get_filename (icon_info);
- e_image_chooser_set_from_file (chooser, filename);
- gtk_icon_info_free (icon_info);
-}
-
-static void
-image_chooser_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ICON_NAME:
- image_chooser_set_icon_name (
- E_IMAGE_CHOOSER (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-image_chooser_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ICON_NAME:
- g_value_set_string (
- value,
- e_image_chooser_get_icon_name (
- E_IMAGE_CHOOSER (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-image_chooser_dispose (GObject *object)
-{
- EImageChooserPrivate *priv;
-
- priv = E_IMAGE_CHOOSER_GET_PRIVATE (object);
-
- if (priv->frame != NULL) {
- g_object_unref (priv->frame);
- priv->frame = NULL;
- }
-
- if (priv->image != NULL) {
- g_object_unref (priv->image);
- priv->image = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_image_chooser_parent_class)->dispose (object);
-}
-
-static void
-image_chooser_finalize (GObject *object)
-{
- EImageChooserPrivate *priv;
-
- priv = E_IMAGE_CHOOSER_GET_PRIVATE (object);
-
- g_free (priv->image_buf);
- g_free (priv->icon_name);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_image_chooser_parent_class)->finalize (object);
-}
-
-static void
-e_image_chooser_class_init (EImageChooserClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EImageChooserPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = image_chooser_set_property;
- object_class->get_property = image_chooser_get_property;
- object_class->dispose = image_chooser_dispose;
- object_class->finalize = image_chooser_finalize;
-
- g_object_class_install_property (
- object_class,
- PROP_ICON_NAME,
- g_param_spec_string (
- "icon-name",
- "Icon Name",
- NULL,
- "avatar-default",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- signals[CHANGED] = g_signal_new (
- "changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EImageChooserClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_image_chooser_init (EImageChooser *chooser)
-{
- GtkWidget *container;
- GtkWidget *widget;
-
- chooser->priv = E_IMAGE_CHOOSER_GET_PRIVATE (chooser);
-
- container = GTK_WIDGET (chooser);
-
- widget = gtk_frame_new ("");
- gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- chooser->priv->frame = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_alignment_new (0, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (container), widget);
- chooser->priv->image = g_object_ref (widget);
- gtk_widget_show (widget);
-
- gtk_drag_dest_set (widget, 0, NULL, 0, GDK_ACTION_COPY);
- gtk_drag_dest_add_uri_targets (widget);
-
- g_signal_connect (
- widget, "drag-motion",
- G_CALLBACK (image_drag_motion_cb), chooser);
- g_signal_connect (
- widget, "drag-leave",
- G_CALLBACK (image_drag_leave_cb), chooser);
- g_signal_connect (
- widget, "drag-drop",
- G_CALLBACK (image_drag_drop_cb), chooser);
- g_signal_connect (
- widget, "drag-data-received",
- G_CALLBACK (image_drag_data_received_cb), chooser);
-}
-
-const gchar *
-e_image_chooser_get_icon_name (EImageChooser *chooser)
-{
- g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), NULL);
-
- return chooser->priv->icon_name;
-}
-
-GtkWidget *
-e_image_chooser_new (const gchar *icon_name)
-{
- g_return_val_if_fail (icon_name != NULL, NULL);
-
- return g_object_new (
- E_TYPE_IMAGE_CHOOSER,
- "icon-name", icon_name, NULL);
-}
-
-gboolean
-e_image_chooser_set_from_file (EImageChooser *chooser,
- const gchar *filename)
-{
- gchar *data;
- gsize data_length;
-
- g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
-
- if (!g_file_get_contents (filename, &data, &data_length, NULL))
- return FALSE;
-
- if (!set_image_from_data (chooser, data, data_length))
- g_free (data);
-
- return TRUE;
-}
-
-gboolean
-e_image_chooser_get_image_data (EImageChooser *chooser,
- gchar **data,
- gsize *data_length)
-{
- g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE);
- g_return_val_if_fail (data != NULL, FALSE);
- g_return_val_if_fail (data_length != NULL, FALSE);
-
- *data_length = chooser->priv->image_buf_size;
- *data = g_malloc (*data_length);
- memcpy (*data, chooser->priv->image_buf, *data_length);
-
- return TRUE;
-}
-
-gboolean
-e_image_chooser_set_image_data (EImageChooser *chooser,
- gchar *data,
- gsize data_length)
-{
- gchar *buf;
-
- g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE);
- g_return_val_if_fail (data != NULL, FALSE);
-
- /* yuck, a copy... */
- buf = g_malloc (data_length);
- memcpy (buf, data, data_length);
-
- if (!set_image_from_data (chooser, buf, data_length)) {
- g_free (buf);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/widgets/misc/e-image-chooser.h b/widgets/misc/e-image-chooser.h
deleted file mode 100644
index cf983c641d..0000000000
--- a/widgets/misc/e-image-chooser.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * e-image-chooser.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_IMAGE_CHOOSER_H
-#define E_IMAGE_CHOOSER_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_IMAGE_CHOOSER \
- (e_image_chooser_get_type ())
-#define E_IMAGE_CHOOSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_IMAGE_CHOOSER, EImageChooser))
-#define E_IMAGE_CHOOSER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_IMAGE_CHOOSER, EImageChooserClass))
-#define E_IS_IMAGE_CHOOSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_IMAGE_CHOOSER))
-#define E_IS_IMAGE_CHOOSER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_IMAGE_CHOOSER))
-#define E_IMAGE_CHOOSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_IMAGE_CHOOSER, EImageChooserClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EImageChooser EImageChooser;
-typedef struct _EImageChooserClass EImageChooserClass;
-typedef struct _EImageChooserPrivate EImageChooserPrivate;
-
-struct _EImageChooser {
- GtkBox parent;
- EImageChooserPrivate *priv;
-};
-
-struct _EImageChooserClass {
- GtkBoxClass parent_class;
-
- /* signals */
- void (*changed) (EImageChooser *chooser);
-};
-
-GType e_image_chooser_get_type (void);
-GtkWidget * e_image_chooser_new (const gchar *icon_name);
-const gchar * e_image_chooser_get_icon_name (EImageChooser *chooser);
-gboolean e_image_chooser_set_from_file (EImageChooser *chooser,
- const gchar *filename);
-gboolean e_image_chooser_set_image_data (EImageChooser *chooser,
- gchar *data,
- gsize data_length);
-gboolean e_image_chooser_get_image_data (EImageChooser *chooser,
- gchar **data,
- gsize *data_length);
-
-#endif /* E_IMAGE_CHOOSER_H */
diff --git a/widgets/misc/e-import-assistant.c b/widgets/misc/e-import-assistant.c
deleted file mode 100644
index 9e06324ab6..0000000000
--- a/widgets/misc/e-import-assistant.c
+++ /dev/null
@@ -1,1436 +0,0 @@
-/*
- * e-import-assistant.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-import-assistant.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <libebackend/libebackend.h>
-
-#include <e-util/e-import.h>
-#include <e-util/e-util-private.h>
-
-#define E_IMPORT_ASSISTANT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_IMPORT_ASSISTANT, EImportAssistantPrivate))
-
-typedef struct _ImportFilePage ImportFilePage;
-typedef struct _ImportDestinationPage ImportDestinationPage;
-typedef struct _ImportTypePage ImportTypePage;
-typedef struct _ImportSelectionPage ImportSelectionPage;
-typedef struct _ImportProgressPage ImportProgressPage;
-typedef struct _ImportSimplePage ImportSimplePage;
-
-struct _ImportFilePage {
- GtkWidget *filename;
- GtkWidget *filetype;
-
- EImportTargetURI *target;
- EImportImporter *importer;
-};
-
-struct _ImportDestinationPage {
- GtkWidget *control;
-};
-
-struct _ImportTypePage {
- GtkWidget *intelligent;
- GtkWidget *file;
-};
-
-struct _ImportSelectionPage {
- GSList *importers;
- GSList *current;
- EImportTargetHome *target;
-};
-
-struct _ImportProgressPage {
- GtkWidget *progress_bar;
-};
-
-struct _ImportSimplePage {
- GtkWidget *actionlabel;
- GtkWidget *filetypetable;
- GtkWidget *filetype;
- GtkWidget *control; /* importer's destination or preview widget in an alignment */
- gboolean has_preview; /* TRUE when 'control' holds a preview widget,
- otherwise holds destination widget */
-
- EImportTargetURI *target;
- EImportImporter *importer;
-};
-
-struct _EImportAssistantPrivate {
- ImportFilePage file_page;
- ImportDestinationPage destination_page;
- ImportTypePage type_page;
- ImportSelectionPage selection_page;
- ImportProgressPage progress_page;
- ImportSimplePage simple_page;
-
- EImport *import;
-
- gboolean is_simple;
- GPtrArray *fileuris; /* each element is a file URI, as a newly allocated string */
-
- /* Used for importing phase of operation */
- EImportTarget *import_target;
- EImportImporter *import_importer;
-};
-
-enum {
- PAGE_START,
- PAGE_INTELI_OR_DIRECT,
- PAGE_INTELI_SOURCE,
- PAGE_FILE_CHOOSE,
- PAGE_FILE_DEST,
- PAGE_FINISH,
- PAGE_PROGRESS
-};
-
-enum {
- PROP_0,
- PROP_IS_SIMPLE
-};
-
-enum {
- FINISHED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (
- EImportAssistant,
- e_import_assistant,
- GTK_TYPE_ASSISTANT,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-/* Importing functions */
-
-static void
-import_assistant_emit_finished (EImportAssistant *import_assistant)
-{
- g_signal_emit (import_assistant, signals[FINISHED], 0);
-}
-
-static void
-filename_changed (GtkWidget *widget,
- GtkAssistant *assistant)
-{
- EImportAssistantPrivate *priv;
- ImportFilePage *page;
- const gchar *filename;
- gint fileok;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->file_page;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
-
- fileok =
- filename != NULL && *filename != '\0' &&
- g_file_test (filename, G_FILE_TEST_IS_REGULAR);
-
- if (fileok) {
- GtkTreeIter iter;
- GtkTreeModel *model;
- gboolean valid;
- GSList *l;
- EImportImporter *first = NULL;
- gint i = 0, firstitem = 0;
-
- g_free (page->target->uri_src);
- page->target->uri_src = g_filename_to_uri (filename, NULL, NULL);
-
- l = e_import_get_importers (
- priv->import, (EImportTarget *) page->target);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype));
- valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid) {
- gpointer eii = NULL;
-
- gtk_tree_model_get (model, &iter, 2, &eii, -1);
-
- if (g_slist_find (l, eii) != NULL) {
- if (first == NULL) {
- firstitem = i;
- first = eii;
- }
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, TRUE, -1);
- } else {
- if (page->importer == eii)
- page->importer = NULL;
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, FALSE, -1);
- }
- i++;
- valid = gtk_tree_model_iter_next (model, &iter);
- }
- g_slist_free (l);
-
- if (page->importer == NULL && first) {
- page->importer = first;
- gtk_combo_box_set_active (GTK_COMBO_BOX (page->filetype), firstitem);
- }
- fileok = first != NULL;
- } else {
- GtkTreeIter iter;
- GtkTreeModel *model;
- gboolean valid;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype));
- for (valid = gtk_tree_model_get_iter_first (model, &iter);
- valid;
- valid = gtk_tree_model_iter_next (model, &iter)) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, FALSE, -1);
- }
- }
-
- widget = gtk_assistant_get_nth_page (assistant, PAGE_FILE_CHOOSE);
- gtk_assistant_set_page_complete (assistant, widget, fileok);
-}
-
-static void
-filetype_changed_cb (GtkComboBox *combo_box,
- GtkAssistant *assistant)
-{
- EImportAssistantPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
-
- g_return_if_fail (gtk_combo_box_get_active_iter (combo_box, &iter));
-
- model = gtk_combo_box_get_model (combo_box);
- gtk_tree_model_get (model, &iter, 2, &priv->file_page.importer, -1);
- filename_changed (priv->file_page.filename, assistant);
-}
-
-static GtkWidget *
-import_assistant_file_page_init (EImportAssistant *import_assistant)
-{
- GtkWidget *page;
- GtkWidget *label;
- GtkWidget *container;
- GtkWidget *widget;
- GtkCellRenderer *cell;
- GtkListStore *store;
- const gchar *text;
- gint row = 0;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- text = _("Choose the file that you want to import into Evolution, "
- "and select what type of file it is from the list.");
-
- widget = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (widget), 2);
- gtk_table_set_col_spacings (GTK_TABLE (widget), 10);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 8);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_label_new_with_mnemonic (_("F_ilename:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- label = widget;
-
- widget = gtk_file_chooser_button_new (
- _("Select a file"), GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
- gtk_table_attach (
- GTK_TABLE (container), widget, 1, 2,
- row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- import_assistant->priv->file_page.filename = widget;
- gtk_widget_show (widget);
-
- g_signal_connect (
- widget, "selection-changed",
- G_CALLBACK (filename_changed), import_assistant);
-
- row++;
-
- widget = gtk_label_new_with_mnemonic (_("File _type:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- label = widget;
-
- store = gtk_list_store_new (
- 3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER);
- widget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- import_assistant->priv->file_page.filetype = widget;
- gtk_widget_show (widget);
- g_object_unref (store);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), cell, TRUE);
- gtk_cell_layout_set_attributes (
- GTK_CELL_LAYOUT (widget), cell,
- "text", 0, "sensitive", 1, NULL);
-
- return page;
-}
-
-static GtkWidget *
-import_assistant_destination_page_init (EImportAssistant *import_assistant)
-{
- GtkWidget *page;
- GtkWidget *container;
- GtkWidget *widget;
- const gchar *text;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- text = _("Choose the destination for this import");
-
- widget = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- return page;
-}
-
-static GtkWidget *
-import_assistant_type_page_init (EImportAssistant *import_assistant)
-{
- GtkRadioButton *radio_button;
- GtkWidget *page;
- GtkWidget *container;
- GtkWidget *widget;
- const gchar *text;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- text = _("Choose the type of importer to run:");
-
- widget = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_radio_button_new_with_mnemonic (
- NULL, _("Import data and settings from _older programs"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- import_assistant->priv->type_page.intelligent = widget;
- gtk_widget_show (widget);
-
- radio_button = GTK_RADIO_BUTTON (widget);
-
- widget = gtk_radio_button_new_with_mnemonic_from_widget (
- radio_button, _("Import a _single file"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- import_assistant->priv->type_page.file = widget;
- gtk_widget_show (widget);
-
- return page;
-}
-
-static GtkWidget *
-import_assistant_selection_page_init (EImportAssistant *import_assistant)
-{
- GtkWidget *page;
- GtkWidget *container;
- GtkWidget *widget;
- const gchar *text;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- text = _("Please select the information "
- "that you would like to import:");
-
- widget = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- return page;
-}
-
-static GtkWidget *
-import_assistant_progress_page_init (EImportAssistant *import_assistant)
-{
- GtkWidget *page;
- GtkWidget *container;
- GtkWidget *widget;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- widget = gtk_progress_bar_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, FALSE, 0);
- import_assistant->priv->progress_page.progress_bar = widget;
- gtk_widget_show (widget);
-
- return page;
-}
-
-static GtkWidget *
-import_assistant_simple_page_init (EImportAssistant *import_assistant)
-{
- GtkWidget *page;
- GtkWidget *label;
- GtkWidget *container;
- GtkWidget *widget;
- GtkCellRenderer *cell;
- GtkListStore *store;
- gint row = 0;
-
- page = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- gtk_widget_show (page);
-
- container = page;
-
- widget = gtk_label_new ("");
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
- import_assistant->priv->simple_page.actionlabel = widget;
-
- widget = gtk_table_new (2, 1, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (widget), 2);
- gtk_table_set_col_spacings (GTK_TABLE (widget), 10);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 8);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
- import_assistant->priv->simple_page.filetypetable = widget;
-
- container = widget;
-
- widget = gtk_label_new_with_mnemonic (_("File _type:"));
- gtk_misc_set_alignment (GTK_MISC (widget), 1, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- label = widget;
-
- store = gtk_list_store_new (
- 3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER);
- widget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- import_assistant->priv->simple_page.filetype = widget;
- gtk_widget_show (widget);
- g_object_unref (store);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), cell, TRUE);
- gtk_cell_layout_set_attributes (
- GTK_CELL_LAYOUT (widget), cell,
- "text", 0, "sensitive", 1, NULL);
-
- import_assistant->priv->simple_page.control = NULL;
-
- return page;
-}
-
-static void
-prepare_intelligent_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- GSList *l;
- GtkWidget *table;
- gint row;
- ImportSelectionPage *page;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->selection_page;
-
- if (page->target != NULL) {
- gtk_assistant_set_page_complete (assistant, vbox, FALSE);
- return;
- }
-
- page->target = e_import_target_new_home (priv->import);
-
- if (page->importers)
- g_slist_free (page->importers);
- l = page->importers =
- e_import_get_importers (
- priv->import, (EImportTarget *) page->target);
-
- if (l == NULL) {
- GtkWidget *widget;
- const gchar *text;
-
- text = _("Evolution checked for settings to import from "
- "the following applications: Pine, Netscape, Elm, "
- "iCalendar. No importable settings found. If you "
- "would like to try again, please click the "
- "\"Back\" button.");
-
- widget = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- gtk_assistant_set_page_complete (assistant, vbox, FALSE);
-
- return;
- }
-
- table = gtk_table_new (g_slist_length (l), 2, FALSE);
- row = 0;
- for (; l; l = l->next) {
- EImportImporter *eii = l->data;
- gchar *str;
- GtkWidget *w, *label;
-
- w = e_import_get_widget (
- priv->import, (EImportTarget *) page->target, eii);
-
- str = g_strdup_printf (_("From %s:"), eii->name);
- label = gtk_label_new (str);
- gtk_widget_show (label);
- g_free (str);
-
- gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
-
- gtk_table_attach (
- GTK_TABLE (table), label,
- 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
- if (w)
- gtk_table_attach (
- GTK_TABLE (table), w,
- 1, 2, row, row + 1, GTK_FILL, 0, 3, 0);
- row++;
- }
-
- gtk_widget_show (table);
- gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
-
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
-}
-
-static void
-import_status (EImport *import,
- const gchar *what,
- gint percent,
- gpointer user_data)
-{
- EImportAssistant *import_assistant = user_data;
- GtkProgressBar *progress_bar;
-
- progress_bar = GTK_PROGRESS_BAR (
- import_assistant->priv->progress_page.progress_bar);
- gtk_progress_bar_set_fraction (progress_bar, percent / 100.0);
- gtk_progress_bar_set_text (progress_bar, what);
-}
-
-static void
-import_done (EImport *ei,
- gpointer user_data)
-{
- EImportAssistant *import_assistant = user_data;
-
- import_assistant_emit_finished (import_assistant);
-}
-
-static void
-import_simple_done (EImport *ei,
- gpointer user_data)
-{
- EImportAssistant *import_assistant = user_data;
- EImportAssistantPrivate *priv;
-
- g_return_if_fail (import_assistant != NULL);
-
- priv = import_assistant->priv;
- g_return_if_fail (priv != NULL);
- g_return_if_fail (priv->fileuris != NULL);
- g_return_if_fail (priv->simple_page.target != NULL);
-
- if (import_assistant->priv->fileuris->len > 0) {
- import_status (ei, "", 0, import_assistant);
-
- /* process next file URI */
- g_free (priv->simple_page.target->uri_src);
- priv->simple_page.target->uri_src =
- g_ptr_array_remove_index (priv->fileuris, 0);
-
- e_import_import (
- priv->import, priv->import_target,
- priv->import_importer, import_status,
- import_simple_done, import_assistant);
- } else
- import_done (ei, import_assistant);
-}
-
-static void
-import_intelligent_done (EImport *ei,
- gpointer user_data)
-{
- EImportAssistant *import_assistant = user_data;
- ImportSelectionPage *page;
-
- page = &import_assistant->priv->selection_page;
-
- if (page->current && (page->current = page->current->next)) {
- import_status (ei, "", 0, import_assistant);
- import_assistant->priv->import_importer = page->current->data;
- e_import_import (
- import_assistant->priv->import,
- (EImportTarget *) page->target,
- import_assistant->priv->import_importer,
- import_status, import_intelligent_done,
- import_assistant);
- } else
- import_done (ei, import_assistant);
-}
-
-static void
-import_cancelled (EImportAssistant *assistant)
-{
- e_import_cancel (
- assistant->priv->import,
- assistant->priv->import_target,
- assistant->priv->import_importer);
-}
-
-static void
-prepare_file_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- GSList *importers, *imp;
- GtkListStore *store;
- ImportFilePage *page;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->file_page;
-
- if (page->target != NULL) {
- filename_changed (priv->file_page.filename, assistant);
- return;
- }
-
- page->target = e_import_target_new_uri (priv->import, NULL, NULL);
- importers = e_import_get_importers (priv->import, (EImportTarget *) page->target);
-
- store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype)));
- gtk_list_store_clear (store);
-
- for (imp = importers; imp; imp = imp->next) {
- GtkTreeIter iter;
- EImportImporter *eii = imp->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (
- store, &iter,
- 0, eii->name,
- 1, TRUE,
- 2, eii,
- -1);
- }
-
- g_slist_free (importers);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (page->filetype), 0);
-
- filename_changed (priv->file_page.filename, assistant);
-
- g_signal_connect (
- page->filetype, "changed",
- G_CALLBACK (filetype_changed_cb), assistant);
-}
-
-static GtkWidget *
-create_importer_control (EImport *import,
- EImportTarget *target,
- EImportImporter *importer)
-{
- GtkWidget *control;
-
- control = e_import_get_widget (import, target, importer);
- if (control == NULL) {
- /* Coding error, not needed for translators */
- control = gtk_label_new (
- "** PLUGIN ERROR ** No settings for importer");
- gtk_widget_show (control);
- }
-
- return control;
-}
-
-static gboolean
-prepare_destination_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- ImportDestinationPage *page;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->destination_page;
-
- if (page->control)
- gtk_container_remove (GTK_CONTAINER (vbox), page->control);
-
- page->control = create_importer_control (
- priv->import, (EImportTarget *)
- priv->file_page.target, priv->file_page.importer);
-
- gtk_box_pack_start (GTK_BOX (vbox), page->control, TRUE, TRUE, 0);
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
-
- return FALSE;
-}
-
-static void
-prepare_progress_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- EImportCompleteFunc done = NULL;
- ImportSelectionPage *page;
- GtkWidget *cancel_button;
- gboolean intelligent_import;
- gboolean is_simple = FALSE;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->selection_page;
-
- /* Because we're a GTK_ASSISTANT_PAGE_PROGRESS, this will
- * prevent the assistant window from being closed via window
- * manager decorations while importing. */
- gtk_assistant_commit (assistant);
-
- /* Install a custom "Cancel Import" button. */
- cancel_button = gtk_button_new_with_mnemonic (_("_Cancel Import"));
- gtk_button_set_image (
- GTK_BUTTON (cancel_button),
- gtk_image_new_from_stock (
- GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
- g_signal_connect_swapped (
- cancel_button, "clicked",
- G_CALLBACK (import_cancelled), assistant);
- gtk_assistant_add_action_widget (assistant, cancel_button);
- gtk_widget_show (cancel_button);
-
- g_object_get (assistant, "is-simple", &is_simple, NULL);
-
- intelligent_import = is_simple ? FALSE : gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (priv->type_page.intelligent));
-
- if (is_simple) {
- priv->import_importer = priv->simple_page.importer;
- priv->import_target = (EImportTarget *) priv->simple_page.target;
- done = import_simple_done;
- } else if (intelligent_import) {
- page->current = page->importers;
- if (page->current) {
- priv->import_target = (EImportTarget *) page->target;
- priv->import_importer = page->current->data;
- done = import_intelligent_done;
- }
- } else {
- if (priv->file_page.importer) {
- priv->import_importer = priv->file_page.importer;
- priv->import_target = (EImportTarget *) priv->file_page.target;
- done = import_done;
- }
- }
-
- if (done)
- e_import_import (
- priv->import, priv->import_target,
- priv->import_importer, import_status,
- done, assistant);
- else
- import_assistant_emit_finished (E_IMPORT_ASSISTANT (assistant));
-}
-
-static void
-simple_filetype_changed_cb (GtkComboBox *combo_box,
- GtkAssistant *assistant)
-{
- EImportAssistantPrivate *priv;
- ImportSimplePage *page;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *vbox;
- GtkWidget *control;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->simple_page;
-
- g_return_if_fail (gtk_combo_box_get_active_iter (combo_box, &iter));
-
- model = gtk_combo_box_get_model (combo_box);
- gtk_tree_model_get (model, &iter, 2, &page->importer, -1);
-
- vbox = g_object_get_data (G_OBJECT (combo_box), "page-vbox");
- g_return_if_fail (vbox != NULL);
-
- if (page->control)
- gtk_widget_destroy (page->control);
- page->has_preview = FALSE;
-
- control = e_import_get_preview_widget (
- priv->import, (EImportTarget *)
- page->target, page->importer);
- if (control) {
- page->has_preview = TRUE;
- gtk_widget_set_size_request (control, 440, 360);
- } else
- control = create_importer_control (
- priv->import, (EImportTarget *)
- page->target, page->importer);
-
- page->control = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
- gtk_widget_show (page->control);
- gtk_container_add (GTK_CONTAINER (page->control), control);
-
- gtk_box_pack_start (GTK_BOX (vbox), page->control, TRUE, TRUE, 0);
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
-}
-
-static void
-prepare_simple_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- GSList *importers, *imp;
- GtkListStore *store;
- ImportSimplePage *page;
- gchar *uri;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->simple_page;
-
- g_return_if_fail (priv->fileuris != NULL);
-
- if (page->target != NULL) {
- return;
- }
-
- uri = g_ptr_array_remove_index (priv->fileuris, 0);
- page->target = e_import_target_new_uri (priv->import, uri, NULL);
- g_free (uri);
- importers = e_import_get_importers (priv->import, (EImportTarget *) page->target);
-
- store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype)));
- gtk_list_store_clear (store);
-
- for (imp = importers; imp; imp = imp->next) {
- GtkTreeIter iter;
- EImportImporter *eii = imp->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (
- store, &iter,
- 0, eii->name,
- 1, TRUE,
- 2, eii,
- -1);
- }
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (page->filetype), 0);
- g_object_set_data (G_OBJECT (page->filetype), "page-vbox", vbox);
-
- simple_filetype_changed_cb (GTK_COMBO_BOX (page->filetype), assistant);
-
- g_signal_connect (
- page->filetype, "changed",
- G_CALLBACK (simple_filetype_changed_cb), assistant);
-
- if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 1) {
- gchar *title;
-
- /* only one importer found, make it even simpler */
- gtk_label_set_text (
- GTK_LABEL (page->actionlabel),
- page->has_preview ?
- _("Preview data to be imported") :
- _("Choose the destination for this import"));
-
- gtk_widget_hide (page->filetypetable);
-
- title = g_strconcat (
- _("Import Data"), " - ",
- ((EImportImporter *) importers->data)->name, NULL);
- gtk_assistant_set_page_title (assistant, vbox, title);
- g_free (title);
- } else {
- /* multiple importers found, be able to choose from them */
- gtk_label_set_text (
- GTK_LABEL (page->actionlabel),
- _("Select what type of file you "
- "want to import from the list."));
-
- gtk_widget_show (page->filetypetable);
-
- gtk_assistant_set_page_title (assistant, vbox, _("Import Data"));
- }
-
- g_slist_free (importers);
-}
-
-static gboolean
-prepare_simple_destination_page (GtkAssistant *assistant,
- GtkWidget *vbox)
-{
- EImportAssistantPrivate *priv;
- ImportDestinationPage *page;
- ImportSimplePage *simple_page;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->destination_page;
- simple_page = &priv->simple_page;
-
- if (page->control)
- gtk_container_remove (GTK_CONTAINER (vbox), page->control);
-
- page->control = create_importer_control (
- priv->import, (EImportTarget *)
- simple_page->target, simple_page->importer);
-
- gtk_box_pack_start (GTK_BOX (vbox), page->control, TRUE, TRUE, 0);
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
-
- return FALSE;
-}
-
-static gint
-forward_cb (gint current_page,
- EImportAssistant *import_assistant)
-{
- GtkToggleButton *toggle_button;
- gboolean is_simple = FALSE;
-
- g_object_get (import_assistant, "is-simple", &is_simple, NULL);
-
- if (is_simple) {
- if (!import_assistant->priv->simple_page.has_preview)
- current_page++;
-
- return current_page + 1;
- }
-
- toggle_button = GTK_TOGGLE_BUTTON (
- import_assistant->priv->type_page.intelligent);
-
- switch (current_page) {
- case PAGE_INTELI_OR_DIRECT:
- if (gtk_toggle_button_get_active (toggle_button))
- return PAGE_INTELI_SOURCE;
- else
- return PAGE_FILE_CHOOSE;
- case PAGE_INTELI_SOURCE:
- return PAGE_FINISH;
- }
-
- return current_page + 1;
-}
-
-static gboolean
-set_import_uris (EImportAssistant *assistant,
- const gchar * const *uris)
-{
- EImportAssistantPrivate *priv;
- GPtrArray *fileuris = NULL;
- gint i;
-
- g_return_val_if_fail (assistant != NULL, FALSE);
- g_return_val_if_fail (assistant->priv != NULL, FALSE);
- g_return_val_if_fail (assistant->priv->import != NULL, FALSE);
- g_return_val_if_fail (uris != NULL, FALSE);
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
-
- for (i = 0; uris[i]; i++) {
- const gchar *uri = uris[i];
- gchar *filename;
-
- filename = g_filename_from_uri (uri, NULL, NULL);
- if (!filename)
- filename = g_strdup (uri);
-
- if (filename && *filename &&
- g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
- gchar *furi;
-
- if (!g_path_is_absolute (filename)) {
- gchar *tmp, *curr;
-
- curr = g_get_current_dir ();
- tmp = g_build_filename (curr, filename, NULL);
- g_free (curr);
-
- g_free (filename);
- filename = tmp;
- }
-
- if (fileuris == NULL) {
- EImportTargetURI *target;
- GSList *importers;
-
- furi = g_filename_to_uri (filename, NULL, NULL);
- target = e_import_target_new_uri (priv->import, furi, NULL);
- importers = e_import_get_importers (
- priv->import, (EImportTarget *) target);
-
- if (importers != NULL) {
- /* there is at least one importer which can be used,
- * thus there can be done an import */
- fileuris = g_ptr_array_new ();
- }
-
- g_slist_free (importers);
- e_import_target_free (priv->import, target);
- g_free (furi);
-
- if (fileuris == NULL) {
- g_free (filename);
- break;
- }
- }
-
- furi = g_filename_to_uri (filename, NULL, NULL);
- if (furi)
- g_ptr_array_add (fileuris, furi);
- }
-
- g_free (filename);
- }
-
- if (fileuris != NULL) {
- priv->fileuris = fileuris;
- }
-
- return fileuris != NULL;
-}
-
-static void
-import_assistant_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EImportAssistantPrivate *priv;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (object);
-
- switch (property_id) {
- case PROP_IS_SIMPLE:
- priv->is_simple = g_value_get_boolean (value);
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-import_assistant_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EImportAssistantPrivate *priv;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (object);
-
- switch (property_id) {
- case PROP_IS_SIMPLE:
- g_value_set_boolean (value, priv->is_simple);
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-import_assistant_dispose (GObject *object)
-{
- EImportAssistantPrivate *priv;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (object);
-
- if (priv->file_page.target != NULL) {
- e_import_target_free (
- priv->import, (EImportTarget *)
- priv->file_page.target);
- priv->file_page.target = NULL;
- }
-
- if (priv->selection_page.target != NULL) {
- e_import_target_free (
- priv->import, (EImportTarget *)
- priv->selection_page.target);
- priv->selection_page.target = NULL;
- }
-
- if (priv->simple_page.target != NULL) {
- e_import_target_free (
- priv->import, (EImportTarget *)
- priv->simple_page.target);
- priv->simple_page.target = NULL;
- }
-
- if (priv->import != NULL) {
- g_object_unref (priv->import);
- priv->import = NULL;
- }
-
- if (priv->fileuris != NULL) {
- g_ptr_array_foreach (priv->fileuris, (GFunc) g_free, NULL);
- g_ptr_array_free (priv->fileuris, TRUE);
- priv->fileuris = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_import_assistant_parent_class)->dispose (object);
-}
-
-static void
-import_assistant_finalize (GObject *object)
-{
- EImportAssistantPrivate *priv;
-
- priv = E_IMPORT_ASSISTANT_GET_PRIVATE (object);
-
- g_slist_free (priv->selection_page.importers);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_import_assistant_parent_class)->finalize (object);
-}
-
-static gboolean
-import_assistant_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- GtkWidgetClass *parent_class;
-
- if (event->keyval == GDK_KEY_Escape) {
- g_signal_emit_by_name (widget, "cancel");
- return TRUE;
- }
-
- /* Chain up to parent's key_press_event () method. */
- parent_class = GTK_WIDGET_CLASS (e_import_assistant_parent_class);
- return parent_class->key_press_event (widget, event);
-}
-
-static void
-import_assistant_prepare (GtkAssistant *assistant,
- GtkWidget *page)
-{
- gint page_no = gtk_assistant_get_current_page (assistant);
- gboolean is_simple = FALSE;
-
- g_object_get (assistant, "is-simple", &is_simple, NULL);
-
- if (is_simple) {
- if (page_no == 0) {
- prepare_simple_page (assistant, page);
- } else if (page_no == 1) {
- prepare_simple_destination_page (assistant, page);
- } else if (page_no == 2) {
- prepare_progress_page (assistant, page);
- }
-
- return;
- }
-
- switch (page_no) {
- case PAGE_INTELI_SOURCE:
- prepare_intelligent_page (assistant, page);
- break;
- case PAGE_FILE_CHOOSE:
- prepare_file_page (assistant, page);
- break;
- case PAGE_FILE_DEST:
- prepare_destination_page (assistant, page);
- break;
- case PAGE_PROGRESS:
- prepare_progress_page (assistant, page);
- break;
- default:
- break;
- }
-}
-
-static void
-e_import_assistant_class_init (EImportAssistantClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkAssistantClass *assistant_class;
-
- g_type_class_add_private (class, sizeof (EImportAssistantPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = import_assistant_dispose;
- object_class->finalize = import_assistant_finalize;
- object_class->set_property = import_assistant_set_property;
- object_class->get_property = import_assistant_get_property;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->key_press_event = import_assistant_key_press_event;
-
- assistant_class = GTK_ASSISTANT_CLASS (class);
- assistant_class->prepare = import_assistant_prepare;
-
- g_object_class_install_property (
- object_class,
- PROP_IS_SIMPLE,
- g_param_spec_boolean (
- "is-simple",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- signals[FINISHED] = g_signal_new (
- "finished",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-import_assistant_construct (EImportAssistant *import_assistant)
-{
- GtkAssistant *assistant;
- GtkWidget *page;
-
- assistant = GTK_ASSISTANT (import_assistant);
-
- import_assistant->priv->import =
- e_import_new ("org.gnome.evolution.shell.importer");
-
- gtk_window_set_position (GTK_WINDOW (assistant), GTK_WIN_POS_CENTER);
- gtk_window_set_title (GTK_WINDOW (assistant), _("Evolution Import Assistant"));
- gtk_window_set_default_size (GTK_WINDOW (assistant), 500, 330);
-
- e_extensible_load_extensions (E_EXTENSIBLE (import_assistant));
-
- if (import_assistant->priv->is_simple) {
- /* simple import assistant page, URIs of files will be known later */
- page = import_assistant_simple_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (assistant, page, _("Import Data"));
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
-
- /* File destination page - when with preview*/
- page = import_assistant_destination_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (assistant, page, _("Import Location"));
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
- } else {
- /* complex import assistant pages */
-
- /* Start page */
- page = gtk_label_new ("");
- gtk_label_set_line_wrap (GTK_LABEL (page), TRUE);
- gtk_misc_set_alignment (GTK_MISC (page), 0.0, 0.5);
- gtk_misc_set_padding (GTK_MISC (page), 12, 12);
- gtk_label_set_text (GTK_LABEL (page), _(
- "Welcome to the Evolution Import Assistant.\n"
- "With this assistant you will be guided through the "
- "process of importing external files into Evolution."));
- gtk_widget_show (page);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (
- assistant, page, _("Evolution Import Assistant"));
- gtk_assistant_set_page_type (
- assistant, page, GTK_ASSISTANT_PAGE_INTRO);
- gtk_assistant_set_page_complete (assistant, page, TRUE);
-
- /* Intelligent or direct import page */
- page = import_assistant_type_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (
- assistant, page, _("Importer Type"));
- gtk_assistant_set_page_type (
- assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
- gtk_assistant_set_page_complete (assistant, page, TRUE);
-
- /* Intelligent importer source page */
- page = import_assistant_selection_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (
- assistant, page, _("Select Information to Import"));
- gtk_assistant_set_page_type (
- assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
-
- /* File selection and file type page */
- page = import_assistant_file_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (
- assistant, page, _("Select a File"));
- gtk_assistant_set_page_type (
- assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
-
- /* File destination page */
- page = import_assistant_destination_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (
- assistant, page, _("Import Location"));
- gtk_assistant_set_page_type (
- assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
-
- /* Finish page */
- page = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (page), 0.5, 0.5);
- gtk_label_set_text (
- GTK_LABEL (page), _("Click \"Apply\" to "
- "begin importing the file into Evolution."));
- gtk_widget_show (page);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (assistant, page, _("Import Data"));
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
- gtk_assistant_set_page_complete (assistant, page, TRUE);
- }
-
- /* Progress Page */
- page = import_assistant_progress_page_init (import_assistant);
-
- gtk_assistant_append_page (assistant, page);
- gtk_assistant_set_page_title (assistant, page, _("Import Data"));
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_PROGRESS);
- gtk_assistant_set_page_complete (assistant, page, TRUE);
-
- gtk_assistant_set_forward_page_func (
- assistant, (GtkAssistantPageFunc)
- forward_cb, import_assistant, NULL);
-
- gtk_assistant_update_buttons_state (assistant);
-}
-
-static void
-e_import_assistant_init (EImportAssistant *import_assistant)
-{
- import_assistant->priv =
- E_IMPORT_ASSISTANT_GET_PRIVATE (import_assistant);
-}
-
-GtkWidget *
-e_import_assistant_new (GtkWindow *parent)
-{
- GtkWidget *assistant;
-
- assistant = g_object_new (
- E_TYPE_IMPORT_ASSISTANT,
- "transient-for", parent, NULL);
-
- import_assistant_construct (E_IMPORT_ASSISTANT (assistant));
-
- return assistant;
-}
-
-/* Creates a simple assistant with only page to choose an import type
- * and where to import, and then finishes. It shows import types based
- * on the first valid URI given.
- *
- * Returns: EImportAssistant widget.
- */
-GtkWidget *
-e_import_assistant_new_simple (GtkWindow *parent,
- const gchar * const *uris)
-{
- GtkWidget *assistant;
-
- assistant = g_object_new (
- E_TYPE_IMPORT_ASSISTANT,
- "transient-for", parent,
- "is-simple", TRUE,
- NULL);
-
- import_assistant_construct (E_IMPORT_ASSISTANT (assistant));
-
- if (!set_import_uris (E_IMPORT_ASSISTANT (assistant), uris)) {
- g_object_ref_sink (assistant);
- g_object_unref (assistant);
- return NULL;
- }
-
- return assistant;
-}
diff --git a/widgets/misc/e-import-assistant.h b/widgets/misc/e-import-assistant.h
deleted file mode 100644
index e120844dfd..0000000000
--- a/widgets/misc/e-import-assistant.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * e-import-assistant.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_IMPORT_ASSISTANT_H
-#define E_IMPORT_ASSISTANT_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_IMPORT_ASSISTANT \
- (e_import_assistant_get_type ())
-#define E_IMPORT_ASSISTANT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_IMPORT_ASSISTANT, EImportAssistant))
-#define E_IMPORT_ASSISTANT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_IMPORT_ASSISTANT, EImportAssistantClass))
-#define E_IS_IMPORT_ASSISTANT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_IMPORT_ASSISTANT))
-#define E_IS_IMPORT_ASSISTANT_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_IMPORT_ASSISTANT))
-#define E_IMPORT_ASSISTANT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_IMPORT_ASSISTANT, EImportAssistantClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EImportAssistant EImportAssistant;
-typedef struct _EImportAssistantClass EImportAssistantClass;
-typedef struct _EImportAssistantPrivate EImportAssistantPrivate;
-
-struct _EImportAssistant {
- GtkAssistant parent;
- EImportAssistantPrivate *priv;
-};
-
-struct _EImportAssistantClass {
- GtkAssistantClass parent_class;
-};
-
-GType e_import_assistant_get_type (void);
-GtkWidget * e_import_assistant_new (GtkWindow *parent);
-GtkWidget * e_import_assistant_new_simple (GtkWindow *parent,
- const gchar * const *uris);
-
-G_END_DECLS
-
-#endif /* E_IMPORT_ASSISTANT_H */
diff --git a/widgets/misc/e-interval-chooser.c b/widgets/misc/e-interval-chooser.c
deleted file mode 100644
index 5a2b4e04ad..0000000000
--- a/widgets/misc/e-interval-chooser.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * e-interval-chooser.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-interval-chooser.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#include <e-util/e-util.h>
-
-#define E_INTERVAL_CHOOSER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_INTERVAL_CHOOSER, EIntervalChooserPrivate))
-
-#define MINUTES_PER_HOUR (60)
-#define MINUTES_PER_DAY (MINUTES_PER_HOUR * 24)
-
-struct _EIntervalChooserPrivate {
- GtkComboBox *combo_box; /* not referenced */
- GtkSpinButton *spin_button; /* not referenced */
-};
-
-enum {
- PROP_0,
- PROP_INTERVAL_MINUTES
-};
-
-G_DEFINE_TYPE (
- EIntervalChooser,
- e_interval_chooser,
- GTK_TYPE_BOX)
-
-static void
-interval_chooser_notify_interval (GObject *object)
-{
- g_object_notify (object, "interval-minutes");
-}
-
-static void
-interval_chooser_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_INTERVAL_MINUTES:
- e_interval_chooser_set_interval_minutes (
- E_INTERVAL_CHOOSER (object),
- g_value_get_uint (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-interval_chooser_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_INTERVAL_MINUTES:
- g_value_set_uint (
- value,
- e_interval_chooser_get_interval_minutes (
- E_INTERVAL_CHOOSER (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-e_interval_chooser_class_init (EIntervalChooserClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EIntervalChooserPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = interval_chooser_set_property;
- object_class->get_property = interval_chooser_get_property;
-
- g_object_class_install_property (
- object_class,
- PROP_INTERVAL_MINUTES,
- g_param_spec_uint (
- "interval-minutes",
- "Interval in Minutes",
- "Refresh interval in minutes",
- 0, G_MAXUINT, 60,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_interval_chooser_init (EIntervalChooser *chooser)
-{
- GtkWidget *widget;
-
- chooser->priv = E_INTERVAL_CHOOSER_GET_PRIVATE (chooser);
-
- gtk_orientable_set_orientation (
- GTK_ORIENTABLE (chooser), GTK_ORIENTATION_HORIZONTAL);
-
- gtk_box_set_spacing (GTK_BOX (chooser), 6);
-
- widget = gtk_spin_button_new_with_range (0, G_MAXUINT, 1);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (widget), TRUE);
- gtk_spin_button_set_update_policy (
- GTK_SPIN_BUTTON (widget), GTK_UPDATE_IF_VALID);
- gtk_box_pack_start (GTK_BOX (chooser), widget, TRUE, TRUE, 0);
- chooser->priv->spin_button = GTK_SPIN_BUTTON (widget);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "notify::value",
- G_CALLBACK (interval_chooser_notify_interval), chooser);
-
- widget = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("minutes"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("hours"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (widget), _("days"));
- gtk_box_pack_start (GTK_BOX (chooser), widget, FALSE, FALSE, 0);
- chooser->priv->combo_box = GTK_COMBO_BOX (widget);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "notify::active",
- G_CALLBACK (interval_chooser_notify_interval), chooser);
-}
-
-GtkWidget *
-e_interval_chooser_new (void)
-{
- return g_object_new (E_TYPE_INTERVAL_CHOOSER, NULL);
-}
-
-guint
-e_interval_chooser_get_interval_minutes (EIntervalChooser *chooser)
-{
- EDurationType units;
- gdouble interval_minutes;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG_REFRESH (chooser), 0);
-
- units = gtk_combo_box_get_active (chooser->priv->combo_box);
-
- interval_minutes = gtk_spin_button_get_value (
- chooser->priv->spin_button);
-
- switch (units) {
- case E_DURATION_HOURS:
- interval_minutes *= MINUTES_PER_HOUR;
- break;
- case E_DURATION_DAYS:
- interval_minutes *= MINUTES_PER_DAY;
- break;
- default:
- break;
- }
-
- return (guint) interval_minutes;
-}
-
-void
-e_interval_chooser_set_interval_minutes (EIntervalChooser *chooser,
- guint interval_minutes)
-{
- EDurationType units;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG_REFRESH (chooser));
-
- if (interval_minutes == 0) {
- units = E_DURATION_MINUTES;
- } else if (interval_minutes % MINUTES_PER_DAY == 0) {
- interval_minutes /= MINUTES_PER_DAY;
- units = E_DURATION_DAYS;
- } else if (interval_minutes % MINUTES_PER_HOUR == 0) {
- interval_minutes /= MINUTES_PER_HOUR;
- units = E_DURATION_HOURS;
- } else {
- units = E_DURATION_MINUTES;
- }
-
- g_object_freeze_notify (G_OBJECT (chooser));
-
- gtk_combo_box_set_active (chooser->priv->combo_box, units);
-
- gtk_spin_button_set_value (
- chooser->priv->spin_button, interval_minutes);
-
- g_object_thaw_notify (G_OBJECT (chooser));
-}
diff --git a/widgets/misc/e-interval-chooser.h b/widgets/misc/e-interval-chooser.h
deleted file mode 100644
index 351cbbe336..0000000000
--- a/widgets/misc/e-interval-chooser.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * e-interval-chooser.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_INTERVAL_CHOOSER_H
-#define E_INTERVAL_CHOOSER_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_INTERVAL_CHOOSER \
- (e_interval_chooser_get_type ())
-#define E_INTERVAL_CHOOSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_INTERVAL_CHOOSER, EIntervalChooser))
-#define E_INTERVAL_CHOOSER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_INTERVAL_CHOOSER, EIntervalChooserClass))
-#define E_IS_SOURCE_CONFIG_REFRESH(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_INTERVAL_CHOOSER))
-#define E_IS_SOURCE_CONFIG_REFRESH_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_INTERVAL_CHOOSER))
-#define E_INTERVAL_CHOOSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_INTERVAL_CHOOSER, EIntervalChooserClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EIntervalChooser EIntervalChooser;
-typedef struct _EIntervalChooserClass EIntervalChooserClass;
-typedef struct _EIntervalChooserPrivate EIntervalChooserPrivate;
-
-struct _EIntervalChooser {
- GtkBox parent;
- EIntervalChooserPrivate *priv;
-};
-
-struct _EIntervalChooserClass {
- GtkBoxClass parent_class;
-};
-
-GType e_interval_chooser_get_type (void) G_GNUC_CONST;
-GtkWidget * e_interval_chooser_new (void);
-guint e_interval_chooser_get_interval_minutes
- (EIntervalChooser *refresh);
-void e_interval_chooser_set_interval_minutes
- (EIntervalChooser *refresh,
- guint interval_minutes);
-
-G_END_DECLS
-
-#endif /* E_INTERVAL_CHOOSER_H */
diff --git a/widgets/misc/e-mail-identity-combo-box.c b/widgets/misc/e-mail-identity-combo-box.c
deleted file mode 100644
index b76e0ee6bc..0000000000
--- a/widgets/misc/e-mail-identity-combo-box.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * e-mail-identity-combo-box.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-identity-combo-box.h"
-
-#define E_MAIL_IDENTITY_COMBO_BOX_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_IDENTITY_COMBO_BOX, EMailIdentityComboBoxPrivate))
-
-#define SOURCE_IS_MAIL_IDENTITY(source) \
- (e_source_has_extension ((source), E_SOURCE_EXTENSION_MAIL_IDENTITY))
-
-struct _EMailIdentityComboBoxPrivate {
- ESourceRegistry *registry;
- guint refresh_idle_id;
-};
-
-enum {
- PROP_0,
- PROP_REGISTRY
-};
-
-enum {
- COLUMN_DISPLAY_NAME,
- COLUMN_UID
-};
-
-G_DEFINE_TYPE (
- EMailIdentityComboBox,
- e_mail_identity_combo_box,
- GTK_TYPE_COMBO_BOX)
-
-static gboolean
-mail_identity_combo_box_refresh_idle_cb (EMailIdentityComboBox *combo_box)
-{
- /* The refresh function will clear the idle ID. */
- e_mail_identity_combo_box_refresh (combo_box);
-
- return FALSE;
-}
-
-static void
-mail_identity_combo_box_registry_changed (ESourceRegistry *registry,
- ESource *source,
- EMailIdentityComboBox *combo_box)
-{
- /* If the ESource in question has a "Mail Identity" extension,
- * schedule a refresh of the tree model. Otherwise ignore it.
- * We use an idle callback to limit how frequently we refresh
- * the tree model, in case the registry is emitting lots of
- * signals at once. */
-
- if (!SOURCE_IS_MAIL_IDENTITY (source))
- return;
-
- if (combo_box->priv->refresh_idle_id > 0)
- return;
-
- combo_box->priv->refresh_idle_id = g_idle_add (
- (GSourceFunc) mail_identity_combo_box_refresh_idle_cb,
- combo_box);
-}
-
-static void
-mail_identity_combo_box_activate_default (EMailIdentityComboBox *combo_box)
-{
- ESource *source;
- ESourceRegistry *registry;
-
- registry = e_mail_identity_combo_box_get_registry (combo_box);
- source = e_source_registry_ref_default_mail_identity (registry);
-
- if (source != NULL) {
- const gchar *uid = e_source_get_uid (source);
- gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
- g_object_unref (source);
- }
-}
-
-static void
-mail_identity_combo_box_set_registry (EMailIdentityComboBox *combo_box,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (combo_box->priv->registry == NULL);
-
- combo_box->priv->registry = g_object_ref (registry);
-
- g_signal_connect (
- registry, "source-added",
- G_CALLBACK (mail_identity_combo_box_registry_changed),
- combo_box);
-
- g_signal_connect (
- registry, "source-changed",
- G_CALLBACK (mail_identity_combo_box_registry_changed),
- combo_box);
-
- g_signal_connect (
- registry, "source-removed",
- G_CALLBACK (mail_identity_combo_box_registry_changed),
- combo_box);
-}
-
-static void
-mail_identity_combo_box_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- mail_identity_combo_box_set_registry (
- E_MAIL_IDENTITY_COMBO_BOX (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_identity_combo_box_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_identity_combo_box_get_registry (
- E_MAIL_IDENTITY_COMBO_BOX (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_identity_combo_box_dispose (GObject *object)
-{
- EMailIdentityComboBoxPrivate *priv;
-
- priv = E_MAIL_IDENTITY_COMBO_BOX_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->registry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->refresh_idle_id > 0) {
- g_source_remove (priv->refresh_idle_id);
- priv->refresh_idle_id = 0;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_identity_combo_box_parent_class)->
- dispose (object);
-}
-
-static void
-mail_identity_combo_box_constructed (GObject *object)
-{
- GtkListStore *list_store;
- GtkComboBox *combo_box;
- GtkCellLayout *cell_layout;
- GtkCellRenderer *cell_renderer;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_identity_combo_box_parent_class)->
- constructed (object);
-
- combo_box = GTK_COMBO_BOX (object);
- cell_layout = GTK_CELL_LAYOUT (object);
-
- list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- gtk_combo_box_set_model (combo_box, GTK_TREE_MODEL (list_store));
- gtk_combo_box_set_id_column (combo_box, COLUMN_UID);
- g_object_unref (list_store);
-
- cell_renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (cell_layout, cell_renderer, TRUE);
- gtk_cell_layout_add_attribute (
- cell_layout, cell_renderer, "text", COLUMN_DISPLAY_NAME);
-
- e_mail_identity_combo_box_refresh (E_MAIL_IDENTITY_COMBO_BOX (object));
-}
-
-static void
-e_mail_identity_combo_box_class_init (EMailIdentityComboBoxClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (
- class, sizeof (EMailIdentityComboBoxPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_identity_combo_box_set_property;
- object_class->get_property = mail_identity_combo_box_get_property;
- object_class->dispose = mail_identity_combo_box_dispose;
- object_class->constructed = mail_identity_combo_box_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- NULL,
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_mail_identity_combo_box_init (EMailIdentityComboBox *combo_box)
-{
- combo_box->priv = E_MAIL_IDENTITY_COMBO_BOX_GET_PRIVATE (combo_box);
-}
-
-GtkWidget *
-e_mail_identity_combo_box_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_IDENTITY_COMBO_BOX,
- "registry", registry, NULL);
-}
-
-void
-e_mail_identity_combo_box_refresh (EMailIdentityComboBox *combo_box)
-{
- ESourceRegistry *registry;
- GtkTreeModel *tree_model;
- GtkComboBox *gtk_combo_box;
- ESource *source;
- GList *list, *link;
- GHashTable *address_table;
- const gchar *extension_name;
- const gchar *saved_uid;
-
- g_return_if_fail (E_IS_MAIL_IDENTITY_COMBO_BOX (combo_box));
-
- if (combo_box->priv->refresh_idle_id > 0) {
- g_source_remove (combo_box->priv->refresh_idle_id);
- combo_box->priv->refresh_idle_id = 0;
- }
-
- gtk_combo_box = GTK_COMBO_BOX (combo_box);
- tree_model = gtk_combo_box_get_model (gtk_combo_box);
-
- /* This is an interned string, which means it's safe
- * to use even after clearing the combo box model. */
- saved_uid = gtk_combo_box_get_active_id (gtk_combo_box);
-
- gtk_list_store_clear (GTK_LIST_STORE (tree_model));
-
- extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
- registry = e_mail_identity_combo_box_get_registry (combo_box);
- list = e_source_registry_list_sources (registry, extension_name);
-
- /* Build a hash table of GQueues by email address so we can
- * spot duplicate email addresses. Then if the GQueue for a
- * given email address has multiple elements, we use a more
- * verbose description in the combo box. */
-
- address_table = g_hash_table_new_full (
- (GHashFunc) g_str_hash,
- (GEqualFunc) g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_queue_free);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESourceMailIdentity *extension;
- GQueue *queue;
- const gchar *address;
-
- source = E_SOURCE (link->data);
- extension = e_source_get_extension (source, extension_name);
- address = e_source_mail_identity_get_address (extension);
-
- if (address == NULL)
- continue;
-
- queue = g_hash_table_lookup (address_table, address);
- if (queue == NULL) {
- queue = g_queue_new ();
- g_hash_table_insert (
- address_table,
- g_strdup (address), queue);
- }
-
- g_queue_push_tail (queue, source);
- }
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESourceMailIdentity *extension;
- GtkTreeIter iter;
- GQueue *queue;
- GString *string;
- const gchar *address;
- const gchar *display_name;
- const gchar *name;
- const gchar *uid;
-
- source = E_SOURCE (link->data);
-
- if (!e_source_registry_check_enabled (registry, source))
- continue;
-
- extension = e_source_get_extension (source, extension_name);
- name = e_source_mail_identity_get_name (extension);
- address = e_source_mail_identity_get_address (extension);
-
- if (name == NULL || address == NULL)
- continue;
-
- queue = g_hash_table_lookup (address_table, address);
-
- display_name = e_source_get_display_name (source);
- uid = e_source_get_uid (source);
-
- string = g_string_sized_new (512);
- g_string_append_printf (string, "%s <%s>", name, address);
-
- /* Show the account name for duplicate email addresses. */
- if (queue != NULL && g_queue_get_length (queue) > 1)
- g_string_append_printf (string, " (%s)", display_name);
-
- gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, string->str,
- COLUMN_UID, uid, -1);
-
- g_string_free (string, TRUE);
- }
-
- g_hash_table_destroy (address_table);
-
- g_list_free_full (list, (GDestroyNotify) g_object_unref);
-
- /* Try and restore the previous selected source, or else pick
- * the default identity of the default mail account. If even
- * that fails, just pick the first item. */
-
- if (saved_uid != NULL)
- gtk_combo_box_set_active_id (gtk_combo_box, saved_uid);
-
- if (gtk_combo_box_get_active_id (gtk_combo_box) == NULL)
- mail_identity_combo_box_activate_default (combo_box);
-
- if (gtk_combo_box_get_active_id (gtk_combo_box) == NULL)
- gtk_combo_box_set_active (gtk_combo_box, 0);
-}
-
-ESourceRegistry *
-e_mail_identity_combo_box_get_registry (EMailIdentityComboBox *combo_box)
-{
- g_return_val_if_fail (E_IS_MAIL_IDENTITY_COMBO_BOX (combo_box), NULL);
-
- return combo_box->priv->registry;
-}
diff --git a/widgets/misc/e-mail-identity-combo-box.h b/widgets/misc/e-mail-identity-combo-box.h
deleted file mode 100644
index 691d69bde2..0000000000
--- a/widgets/misc/e-mail-identity-combo-box.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * e-mail-identity-combo-box.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_IDENTITY_COMBO_BOX_H
-#define E_MAIL_IDENTITY_COMBO_BOX_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_IDENTITY_COMBO_BOX \
- (e_mail_identity_combo_box_get_type ())
-#define E_MAIL_IDENTITY_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_IDENTITY_COMBO_BOX, EMailIdentityComboBox))
-#define E_MAIL_IDENTITY_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_IDENTITY_COMBO_BOX, EMailIdentityComboBoxClass))
-#define E_IS_MAIL_IDENTITY_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_IDENTITY_COMBO_BOX))
-#define E_IS_MAIL_IDENTITY_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_IDENTITY_COMBO_BOX))
-#define E_MAIL_IDENTITY_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_IDENTITY_COMBO_BOX, EMailIdentityComboBoxClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailIdentityComboBox EMailIdentityComboBox;
-typedef struct _EMailIdentityComboBoxClass EMailIdentityComboBoxClass;
-typedef struct _EMailIdentityComboBoxPrivate EMailIdentityComboBoxPrivate;
-
-struct _EMailIdentityComboBox {
- GtkComboBox parent;
- EMailIdentityComboBoxPrivate *priv;
-};
-
-struct _EMailIdentityComboBoxClass {
- GtkComboBoxClass parent_class;
-};
-
-GType e_mail_identity_combo_box_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_identity_combo_box_new
- (ESourceRegistry *registry);
-void e_mail_identity_combo_box_refresh
- (EMailIdentityComboBox *combo_box);
-ESourceRegistry *
- e_mail_identity_combo_box_get_registry
- (EMailIdentityComboBox *combo_box);
-
-G_END_DECLS
-
-#endif /* E_MAIL_IDENTITY_COMBO_BOX_H */
diff --git a/widgets/misc/e-mail-signature-combo-box.c b/widgets/misc/e-mail-signature-combo-box.c
deleted file mode 100644
index 275c2538b9..0000000000
--- a/widgets/misc/e-mail-signature-combo-box.c
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * e-mail-signature-combo-box.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-combo-box.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#define E_MAIL_SIGNATURE_COMBO_BOX_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_COMBO_BOX, EMailSignatureComboBoxPrivate))
-
-#define SOURCE_IS_MAIL_SIGNATURE(source) \
- (e_source_has_extension ((source), E_SOURCE_EXTENSION_MAIL_SIGNATURE))
-
-struct _EMailSignatureComboBoxPrivate {
- ESourceRegistry *registry;
- guint refresh_idle_id;
- gchar *identity_uid;
-};
-
-enum {
- PROP_0,
- PROP_IDENTITY_UID,
- PROP_REGISTRY
-};
-
-enum {
- COLUMN_DISPLAY_NAME,
- COLUMN_UID
-};
-
-G_DEFINE_TYPE (
- EMailSignatureComboBox,
- e_mail_signature_combo_box,
- GTK_TYPE_COMBO_BOX)
-
-static gboolean
-mail_signature_combo_box_refresh_idle_cb (EMailSignatureComboBox *combo_box)
-{
- /* The refresh function will clear the idle ID. */
- e_mail_signature_combo_box_refresh (combo_box);
-
- return FALSE;
-}
-
-static void
-mail_signature_combo_box_registry_changed (ESourceRegistry *registry,
- ESource *source,
- EMailSignatureComboBox *combo_box)
-{
- /* If the ESource in question has a "Mail Signature" extension,
- * schedule a refresh of the tree model. Otherwise ignore it.
- * We use an idle callback to limit how frequently we refresh
- * the tree model, in case the registry is emitting lots of
- * signals at once. */
-
- if (!SOURCE_IS_MAIL_SIGNATURE (source))
- return;
-
- if (combo_box->priv->refresh_idle_id > 0)
- return;
-
- combo_box->priv->refresh_idle_id = g_idle_add (
- (GSourceFunc) mail_signature_combo_box_refresh_idle_cb,
- combo_box);
-}
-
-static gboolean
-mail_signature_combo_box_identity_to_signature (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer user_data)
-{
- EMailSignatureComboBox *combo_box;
- ESourceRegistry *registry;
- GObject *source_object;
- ESource *source;
- ESourceMailIdentity *extension;
- const gchar *identity_uid;
- const gchar *signature_uid = "none";
- const gchar *extension_name;
-
- /* Source and target are the same object. */
- source_object = g_binding_get_source (binding);
- combo_box = E_MAIL_SIGNATURE_COMBO_BOX (source_object);
- registry = e_mail_signature_combo_box_get_registry (combo_box);
-
- identity_uid = g_value_get_string (source_value);
- if (identity_uid == NULL)
- return FALSE;
-
- source = e_source_registry_ref_source (registry, identity_uid);
- if (source == NULL)
- return FALSE;
-
- extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
- if (!e_source_has_extension (source, extension_name)) {
- g_object_unref (source);
- return FALSE;
- }
-
- extension = e_source_get_extension (source, extension_name);
- signature_uid = e_source_mail_identity_get_signature_uid (extension);
- g_value_set_string (target_value, signature_uid);
-
- g_object_unref (source);
-
- return TRUE;
-}
-
-static void
-mail_signature_combo_box_set_registry (EMailSignatureComboBox *combo_box,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (combo_box->priv->registry == NULL);
-
- combo_box->priv->registry = g_object_ref (registry);
-
- g_signal_connect (
- registry, "source-added",
- G_CALLBACK (mail_signature_combo_box_registry_changed),
- combo_box);
-
- g_signal_connect (
- registry, "source-changed",
- G_CALLBACK (mail_signature_combo_box_registry_changed),
- combo_box);
-
- g_signal_connect (
- registry, "source-removed",
- G_CALLBACK (mail_signature_combo_box_registry_changed),
- combo_box);
-}
-
-static void
-mail_signature_combo_box_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_IDENTITY_UID:
- e_mail_signature_combo_box_set_identity_uid (
- E_MAIL_SIGNATURE_COMBO_BOX (object),
- g_value_get_string (value));
- return;
-
- case PROP_REGISTRY:
- mail_signature_combo_box_set_registry (
- E_MAIL_SIGNATURE_COMBO_BOX (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_combo_box_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_IDENTITY_UID:
- g_value_set_string (
- value,
- e_mail_signature_combo_box_get_identity_uid (
- E_MAIL_SIGNATURE_COMBO_BOX (object)));
- return;
-
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_combo_box_get_registry (
- E_MAIL_SIGNATURE_COMBO_BOX (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_combo_box_dispose (GObject *object)
-{
- EMailSignatureComboBoxPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_COMBO_BOX_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->registry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->refresh_idle_id > 0) {
- g_source_remove (priv->refresh_idle_id);
- priv->refresh_idle_id = 0;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_combo_box_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_combo_box_finalize (GObject *object)
-{
- EMailSignatureComboBoxPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_COMBO_BOX_GET_PRIVATE (object);
-
- g_free (priv->identity_uid);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_mail_signature_combo_box_parent_class)->
- finalize (object);
-}
-
-static void
-mail_signature_combo_box_constructed (GObject *object)
-{
- GtkListStore *list_store;
- GtkComboBox *combo_box;
- GtkCellLayout *cell_layout;
- GtkCellRenderer *cell_renderer;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_signature_combo_box_parent_class)->
- constructed (object);
-
- combo_box = GTK_COMBO_BOX (object);
- cell_layout = GTK_CELL_LAYOUT (object);
-
- list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- gtk_combo_box_set_model (combo_box, GTK_TREE_MODEL (list_store));
- gtk_combo_box_set_id_column (combo_box, COLUMN_UID);
- g_object_unref (list_store);
-
- cell_renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (cell_layout, cell_renderer, TRUE);
- gtk_cell_layout_add_attribute (
- cell_layout, cell_renderer, "text", COLUMN_DISPLAY_NAME);
-
- g_object_bind_property_full (
- combo_box, "identity-uid",
- combo_box, "active-id",
- G_BINDING_DEFAULT,
- mail_signature_combo_box_identity_to_signature,
- NULL,
- NULL, (GDestroyNotify) NULL);
-
- e_mail_signature_combo_box_refresh (
- E_MAIL_SIGNATURE_COMBO_BOX (object));
-}
-
-static void
-e_mail_signature_combo_box_class_init (EMailSignatureComboBoxClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (
- class, sizeof (EMailSignatureComboBoxPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_combo_box_set_property;
- object_class->get_property = mail_signature_combo_box_get_property;
- object_class->dispose = mail_signature_combo_box_dispose;
- object_class->finalize = mail_signature_combo_box_finalize;
- object_class->constructed = mail_signature_combo_box_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_IDENTITY_UID,
- g_param_spec_string (
- "identity-uid",
- "Identity UID",
- NULL,
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- NULL,
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_mail_signature_combo_box_init (EMailSignatureComboBox *combo_box)
-{
- combo_box->priv = E_MAIL_SIGNATURE_COMBO_BOX_GET_PRIVATE (combo_box);
-}
-
-GtkWidget *
-e_mail_signature_combo_box_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_COMBO_BOX,
- "registry", registry, NULL);
-}
-
-void
-e_mail_signature_combo_box_refresh (EMailSignatureComboBox *combo_box)
-{
- ESourceRegistry *registry;
- GtkComboBox *gtk_combo_box;
- GtkTreeModel *tree_model;
- GtkTreeIter iter;
- ESource *source;
- GList *list, *link;
- const gchar *extension_name;
- const gchar *saved_uid;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_COMBO_BOX (combo_box));
-
- if (combo_box->priv->refresh_idle_id > 0) {
- g_source_remove (combo_box->priv->refresh_idle_id);
- combo_box->priv->refresh_idle_id = 0;
- }
-
- gtk_combo_box = GTK_COMBO_BOX (combo_box);
- tree_model = gtk_combo_box_get_model (gtk_combo_box);
-
- /* This is an interned string, which means it's safe
- * to use even after clearing the combo box model. */
- saved_uid = gtk_combo_box_get_active_id (gtk_combo_box);
-
- gtk_list_store_clear (GTK_LIST_STORE (tree_model));
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- registry = e_mail_signature_combo_box_get_registry (combo_box);
- list = e_source_registry_list_sources (registry, extension_name);
-
- /* The "None" option always comes first. */
-
- gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, _("None"),
- COLUMN_UID, "none", -1);
-
- /* The "autogenerated" UID has special meaning. */
-
- gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, _("Autogenerated"),
- COLUMN_UID, E_MAIL_SIGNATURE_AUTOGENERATED_UID, -1);
-
- /* Followed by the other mail signatures, alphabetized. */
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- GtkTreeIter iter;
- const gchar *display_name;
- const gchar *uid;
-
- source = E_SOURCE (link->data);
- display_name = e_source_get_display_name (source);
- uid = e_source_get_uid (source);
-
- gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, display_name,
- COLUMN_UID, uid, -1);
- }
-
- g_list_free_full (list, (GDestroyNotify) g_object_unref);
-
- /* Try and restore the previous selected source, or else "None". */
-
- if (saved_uid != NULL)
- gtk_combo_box_set_active_id (gtk_combo_box, saved_uid);
-
- if (gtk_combo_box_get_active_id (gtk_combo_box) == NULL)
- gtk_combo_box_set_active (gtk_combo_box, 0);
-}
-
-ESourceRegistry *
-e_mail_signature_combo_box_get_registry (EMailSignatureComboBox *combo_box)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_COMBO_BOX (combo_box), NULL);
-
- return combo_box->priv->registry;
-}
-
-const gchar *
-e_mail_signature_combo_box_get_identity_uid (EMailSignatureComboBox *combo_box)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_COMBO_BOX (combo_box), NULL);
-
- return combo_box->priv->identity_uid;
-}
-
-void
-e_mail_signature_combo_box_set_identity_uid (EMailSignatureComboBox *combo_box,
- const gchar *identity_uid)
-{
- const gchar *active_id;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_COMBO_BOX (combo_box));
-
- if (g_strcmp0 (combo_box->priv->identity_uid, identity_uid) == 0)
- return;
-
- g_free (combo_box->priv->identity_uid);
- combo_box->priv->identity_uid = g_strdup (identity_uid);
-
- g_object_notify (G_OBJECT (combo_box), "identity-uid");
-
- /* If "Autogenerated" is selected, emit a "changed" signal as
- * a hint to whomever is listening to reload the signature. */
- active_id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (combo_box));
- if (g_strcmp0 (active_id, E_MAIL_SIGNATURE_AUTOGENERATED_UID) == 0)
- g_signal_emit_by_name (combo_box, "changed");
-}
-
-/**************** e_mail_signature_combo_box_load_selected() *****************/
-
-typedef struct _LoadContext LoadContext;
-
-struct _LoadContext {
- gchar *contents;
- gsize length;
- gboolean is_html;
-};
-
-static void
-load_context_free (LoadContext *context)
-{
- g_free (context->contents);
- g_slice_free (LoadContext, context);
-}
-
-static void
-mail_signature_combo_box_autogenerate (EMailSignatureComboBox *combo_box,
- LoadContext *context)
-{
- ESourceMailIdentity *extension;
- ESourceRegistry *registry;
- ESource *source;
- GString *buffer;
- const gchar *extension_name;
- const gchar *identity_uid;
- const gchar *text;
- gchar *escaped;
-
- identity_uid = e_mail_signature_combo_box_get_identity_uid (combo_box);
-
- /* If we have no mail identity UID, handle it as though
- * "None" were selected. No need to report an error. */
- if (identity_uid == NULL)
- return;
-
- registry = e_mail_signature_combo_box_get_registry (combo_box);
- source = e_source_registry_ref_source (registry, identity_uid);
-
- /* If the mail identity lookup fails, handle it as though
- * "None" were selected. No need to report an error. */
- if (source == NULL)
- return;
-
- /* If the source is not actually a mail identity, handle it as
- * though "None" were selected. No need to report an error. */
- extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
- if (!e_source_has_extension (source, extension_name)) {
- g_object_unref (source);
- return;
- }
-
- extension = e_source_get_extension (source, extension_name);
-
- /* The autogenerated signature format is:
- *
- * <NAME> <ADDRESS>
- * <ORGANIZATION>
- *
- * The <ADDRESS> is a mailto link and
- * the <ORGANIZATION> line is optional.
- */
-
- buffer = g_string_sized_new (512);
-
- text = e_source_mail_identity_get_name (extension);
- escaped = (text != NULL) ? g_markup_escape_text (text, -1) : NULL;
- if (escaped != NULL && *escaped != '\0')
- g_string_append (buffer, escaped);
- g_free (escaped);
-
- text = e_source_mail_identity_get_address (extension);
- escaped = (text != NULL) ? g_markup_escape_text (text, -1) : NULL;
- if (escaped != NULL && *escaped != '\0')
- g_string_append_printf (
- buffer, " &lt;<a href=\"mailto:%s\">%s</a>&gt;",
- escaped, escaped);
- g_free (escaped);
-
- text = e_source_mail_identity_get_organization (extension);
- escaped = (text != NULL) ? g_markup_escape_text (text, -1) : NULL;
- if (escaped != NULL && *escaped != '\0')
- g_string_append_printf (buffer, "<br>%s", escaped);
- g_free (escaped);
-
- context->length = buffer->len;
- context->contents = g_string_free (buffer, FALSE);
- context->is_html = TRUE;
-
- g_object_unref (source);
-}
-
-static void
-mail_signature_combo_box_load_cb (ESource *source,
- GAsyncResult *result,
- GSimpleAsyncResult *simple)
-{
- ESourceMailSignature *extension;
- LoadContext *context;
- const gchar *extension_name;
- const gchar *mime_type;
- GError *error = NULL;
-
- context = g_simple_async_result_get_op_res_gpointer (simple);
-
- e_source_mail_signature_load_finish (
- source, result, &context->contents, &context->length, &error);
-
- if (error != NULL) {
- g_simple_async_result_set_from_error (simple, error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- g_error_free (error);
- return;
- }
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- mime_type = e_source_mail_signature_get_mime_type (extension);
- context->is_html = (g_strcmp0 (mime_type, "text/html") == 0);
-
- g_simple_async_result_complete (simple);
-
- g_object_unref (simple);
-}
-
-void
-e_mail_signature_combo_box_load_selected (EMailSignatureComboBox *combo_box,
- gint io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- ESourceRegistry *registry;
- LoadContext *context;
- ESource *source;
- const gchar *active_id;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_COMBO_BOX (combo_box));
-
- context = g_slice_new0 (LoadContext);
-
- simple = g_simple_async_result_new (
- G_OBJECT (combo_box), callback, user_data,
- e_mail_signature_combo_box_load_selected);
-
- g_simple_async_result_set_op_res_gpointer (
- simple, context, (GDestroyNotify) load_context_free);
-
- active_id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (combo_box));
-
- if (active_id == NULL) {
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (g_strcmp0 (active_id, E_MAIL_SIGNATURE_AUTOGENERATED_UID) == 0) {
- mail_signature_combo_box_autogenerate (combo_box, context);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- registry = e_mail_signature_combo_box_get_registry (combo_box);
- source = e_source_registry_ref_source (registry, active_id);
-
- /* If for some reason the ESource lookup fails, handle it as
- * though "None" were selected. No need to report an error. */
- if (source == NULL) {
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- e_source_mail_signature_load (
- source, io_priority, cancellable, (GAsyncReadyCallback)
- mail_signature_combo_box_load_cb, simple);
-
- g_object_unref (source);
-}
-
-gboolean
-e_mail_signature_combo_box_load_selected_finish (EMailSignatureComboBox *combo_box,
- GAsyncResult *result,
- gchar **contents,
- gsize *length,
- gboolean *is_html,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- LoadContext *context;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (combo_box),
- e_mail_signature_combo_box_load_selected), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- context = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- if (contents != NULL) {
- *contents = context->contents;
- context->contents = NULL;
- }
-
- if (length != NULL)
- *length = context->length;
-
- if (is_html != NULL)
- *is_html = context->is_html;
-
- return TRUE;
-}
diff --git a/widgets/misc/e-mail-signature-combo-box.h b/widgets/misc/e-mail-signature-combo-box.h
deleted file mode 100644
index d3ddaa9694..0000000000
--- a/widgets/misc/e-mail-signature-combo-box.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * e-mail-signature-combo-box.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_COMBO_BOX_H
-#define E_MAIL_SIGNATURE_COMBO_BOX_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_COMBO_BOX \
- (e_mail_signature_combo_box_get_type ())
-#define E_MAIL_SIGNATURE_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_COMBO_BOX, EMailSignatureComboBox))
-#define E_MAIL_SIGNATURE_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_COMBO_BOX, EMailSignatureComboBoxClass))
-#define E_IS_MAIL_SIGNATURE_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_COMBO_BOX))
-#define E_IS_MAIL_SIGNATURE_COMBO_BOX_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_COMBO_BOX))
-#define E_MAIL_SIGNATURE_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_COMBO_BOX, EMailSignatureComboBoxClass))
-
-#define E_MAIL_SIGNATURE_AUTOGENERATED_UID "autogenerated"
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignatureComboBox EMailSignatureComboBox;
-typedef struct _EMailSignatureComboBoxClass EMailSignatureComboBoxClass;
-typedef struct _EMailSignatureComboBoxPrivate EMailSignatureComboBoxPrivate;
-
-struct _EMailSignatureComboBox {
- GtkComboBox parent;
- EMailSignatureComboBoxPrivate *priv;
-};
-
-struct _EMailSignatureComboBoxClass {
- GtkComboBoxClass parent_class;
-};
-
-GType e_mail_signature_combo_box_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_combo_box_new
- (ESourceRegistry *registry);
-void e_mail_signature_combo_box_refresh
- (EMailSignatureComboBox *combo_box);
-ESourceRegistry *
- e_mail_signature_combo_box_get_registry
- (EMailSignatureComboBox *combo_box);
-const gchar * e_mail_signature_combo_box_get_identity_uid
- (EMailSignatureComboBox *combo_box);
-void e_mail_signature_combo_box_set_identity_uid
- (EMailSignatureComboBox *combo_box,
- const gchar *identity_uid);
-void e_mail_signature_combo_box_load_selected
- (EMailSignatureComboBox *combo_box,
- gint io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_mail_signature_combo_box_load_selected_finish
- (EMailSignatureComboBox *combo_box,
- GAsyncResult *result,
- gchar **contents,
- gsize *length,
- gboolean *is_html,
- GError **error);
-
-G_END_DECLS
-
-#endif /* E_MAIL_SIGNATURE_COMBO_BOX_H */
diff --git a/widgets/misc/e-mail-signature-editor.c b/widgets/misc/e-mail-signature-editor.c
deleted file mode 100644
index 5e5910b013..0000000000
--- a/widgets/misc/e-mail-signature-editor.c
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- * e-mail-signature-editor.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-editor.h"
-
-#include <string.h>
-#include <glib/gi18n.h>
-
-#include <libevolution-utils/e-alert-dialog.h>
-#include <libevolution-utils/e-alert-sink.h>
-#include <misc/e-alert-bar.h>
-#include <misc/e-web-view-gtkhtml.h>
-
-#define E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_EDITOR, EMailSignatureEditorPrivate))
-
-typedef struct _AsyncContext AsyncContext;
-
-struct _EMailSignatureEditorPrivate {
- GtkActionGroup *action_group;
- EFocusTracker *focus_tracker;
- GCancellable *cancellable;
- ESourceRegistry *registry;
- ESource *source;
- gchar *original_name;
-
- GtkWidget *entry; /* not referenced */
- GtkWidget *alert_bar; /* not referenced */
-};
-
-struct _AsyncContext {
- ESource *source;
- GCancellable *cancellable;
- gchar *contents;
- gsize length;
-};
-
-enum {
- PROP_0,
- PROP_FOCUS_TRACKER,
- PROP_REGISTRY,
- PROP_SOURCE
-};
-
-static const gchar *ui =
-"<ui>\n"
-" <menubar name='main-menu'>\n"
-" <placeholder name='pre-edit-menu'>\n"
-" <menu action='file-menu'>\n"
-" <menuitem action='save-and-close'/>\n"
-" <separator/>"
-" <menuitem action='close'/>\n"
-" </menu>\n"
-" </placeholder>\n"
-" </menubar>\n"
-" <toolbar name='main-toolbar'>\n"
-" <placeholder name='pre-main-toolbar'>\n"
-" <toolitem action='save-and-close'/>\n"
-" </placeholder>\n"
-" </toolbar>\n"
-"</ui>";
-
-/* Forward Declarations */
-static void e_mail_signature_editor_alert_sink_init
- (EAlertSinkInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EMailSignatureEditor,
- e_mail_signature_editor,
- GTKHTML_TYPE_EDITOR,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ALERT_SINK,
- e_mail_signature_editor_alert_sink_init))
-
-static void
-async_context_free (AsyncContext *async_context)
-{
- if (async_context->source != NULL)
- g_object_unref (async_context->source);
-
- if (async_context->cancellable != NULL)
- g_object_unref (async_context->cancellable);
-
- g_free (async_context->contents);
-
- g_slice_free (AsyncContext, async_context);
-}
-
-static void
-mail_signature_editor_loaded_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ESource *source;
- EMailSignatureEditor *editor;
- ESourceMailSignature *extension;
- const gchar *extension_name;
- const gchar *mime_type;
- gchar *contents = NULL;
- gboolean is_html;
- GError *error = NULL;
-
- source = E_SOURCE (object);
- editor = E_MAIL_SIGNATURE_EDITOR (user_data);
-
- e_source_mail_signature_load_finish (
- source, result, &contents, NULL, &error);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (contents == NULL);
- g_object_unref (editor);
- g_error_free (error);
- return;
-
- } else if (error != NULL) {
- g_warn_if_fail (contents == NULL);
- e_alert_submit (
- E_ALERT_SINK (editor),
- "widgets:no-load-signature",
- error->message, NULL);
- g_object_unref (editor);
- g_error_free (error);
- return;
- }
-
- g_return_if_fail (contents != NULL);
-
- /* The load operation should have set the MIME type. */
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- mime_type = e_source_mail_signature_get_mime_type (extension);
- is_html = (g_strcmp0 (mime_type, "text/html") == 0);
-
- gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (editor), is_html);
-
- if (is_html) {
- gtkhtml_editor_insert_html (
- GTKHTML_EDITOR (editor), contents);
- } else {
- gtkhtml_editor_insert_text (
- GTKHTML_EDITOR (editor), contents);
-
- gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "cursor-position-save");
- gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "select-all");
- gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "style-pre");
- gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "unselect-all");
- gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "cursor-position-restore");
- }
-
- g_free (contents);
-
- g_object_unref (editor);
-}
-
-static gboolean
-mail_signature_editor_delete_event_cb (EMailSignatureEditor *editor,
- GdkEvent *event)
-{
- GtkActionGroup *action_group;
- GtkAction *action;
-
- action_group = editor->priv->action_group;
- action = gtk_action_group_get_action (action_group, "close");
- gtk_action_activate (action);
-
- return TRUE;
-}
-
-static void
-action_close_cb (GtkAction *action,
- EMailSignatureEditor *editor)
-{
- gboolean something_changed = FALSE;
- const gchar *original_name;
- const gchar *signature_name;
-
- original_name = editor->priv->original_name;
- signature_name = gtk_entry_get_text (GTK_ENTRY (editor->priv->entry));
-
- something_changed |= gtkhtml_editor_has_undo (GTKHTML_EDITOR (editor));
- something_changed |= (strcmp (signature_name, original_name) != 0);
-
- if (something_changed) {
- gint response;
-
- response = e_alert_run_dialog_for_args (
- GTK_WINDOW (editor),
- "widgets:ask-signature-changed", NULL);
- if (response == GTK_RESPONSE_YES) {
- GtkActionGroup *action_group;
-
- action_group = editor->priv->action_group;
- action = gtk_action_group_get_action (
- action_group, "save-and-close");
- gtk_action_activate (action);
- return;
- } else if (response == GTK_RESPONSE_CANCEL)
- return;
- }
-
- gtk_widget_destroy (GTK_WIDGET (editor));
-}
-
-static void
-action_save_and_close_cb (GtkAction *action,
- EMailSignatureEditor *editor)
-{
- GtkEntry *entry;
- EAsyncClosure *closure;
- GAsyncResult *result;
- ESource *source;
- gchar *display_name;
- GError *error = NULL;
-
- entry = GTK_ENTRY (editor->priv->entry);
- source = e_mail_signature_editor_get_source (editor);
-
- display_name = g_strstrip (g_strdup (gtk_entry_get_text (entry)));
-
- /* Make sure the signature name is not blank. */
- if (*display_name == '\0') {
- e_alert_submit (
- E_ALERT_SINK (editor),
- "widgets:blank-signature", NULL);
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- g_free (display_name);
- return;
- }
-
- e_source_set_display_name (source, display_name);
-
- g_free (display_name);
-
- /* Cancel any ongoing load or save operations. */
- if (editor->priv->cancellable != NULL) {
- g_cancellable_cancel (editor->priv->cancellable);
- g_object_unref (editor->priv->cancellable);
- }
-
- editor->priv->cancellable = g_cancellable_new ();
-
- closure = e_async_closure_new ();
-
- e_mail_signature_editor_commit (
- editor, editor->priv->cancellable,
- e_async_closure_callback, closure);
-
- result = e_async_closure_wait (closure);
-
- e_mail_signature_editor_commit_finish (editor, result, &error);
-
- e_async_closure_free (closure);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free (error);
-
- } else if (error != NULL) {
- e_alert_submit (
- E_ALERT_SINK (editor),
- "widgets:no-save-signature",
- error->message, NULL);
- g_error_free (error);
-
- /* Only destroy the editor if the save was successful. */
- } else {
- gtk_widget_destroy (GTK_WIDGET (editor));
- }
-}
-
-static GtkActionEntry entries[] = {
-
- { "close",
- GTK_STOCK_CLOSE,
- N_("_Close"),
- "<Control>w",
- N_("Close"),
- G_CALLBACK (action_close_cb) },
-
- { "save-and-close",
- GTK_STOCK_SAVE,
- N_("_Save and Close"),
- "<Control>Return",
- N_("Save and Close"),
- G_CALLBACK (action_save_and_close_cb) },
-
- { "file-menu",
- NULL,
- N_("_File"),
- NULL,
- NULL,
- NULL }
-};
-
-static void
-mail_signature_editor_set_registry (EMailSignatureEditor *editor,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (editor->priv->registry == NULL);
-
- editor->priv->registry = g_object_ref (registry);
-}
-
-static void
-mail_signature_editor_set_source (EMailSignatureEditor *editor,
- ESource *source)
-{
- GDBusObject *dbus_object = NULL;
- const gchar *extension_name;
- GError *error = NULL;
-
- g_return_if_fail (source == NULL || E_IS_SOURCE (source));
- g_return_if_fail (editor->priv->source == NULL);
-
- if (source != NULL)
- dbus_object = e_source_ref_dbus_object (source);
-
- /* Clone the source so we can make changes to it freely. */
- editor->priv->source = e_source_new (dbus_object, NULL, &error);
-
- if (dbus_object != NULL)
- g_object_unref (dbus_object);
-
- /* This should rarely fail. If the file was loaded successfully
- * once then it should load successfully here as well, unless an
- * I/O error occurs. */
- if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-
- /* Make sure the source has a mail signature extension. */
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- e_source_get_extension (editor->priv->source, extension_name);
-}
-
-static void
-mail_signature_editor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- mail_signature_editor_set_registry (
- E_MAIL_SIGNATURE_EDITOR (object),
- g_value_get_object (value));
- return;
-
- case PROP_SOURCE:
- mail_signature_editor_set_source (
- E_MAIL_SIGNATURE_EDITOR (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_editor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_FOCUS_TRACKER:
- g_value_set_object (
- value,
- e_mail_signature_editor_get_focus_tracker (
- E_MAIL_SIGNATURE_EDITOR (object)));
- return;
-
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_editor_get_registry (
- E_MAIL_SIGNATURE_EDITOR (object)));
- return;
-
- case PROP_SOURCE:
- g_value_set_object (
- value,
- e_mail_signature_editor_get_source (
- E_MAIL_SIGNATURE_EDITOR (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_editor_dispose (GObject *object)
-{
- EMailSignatureEditorPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE (object);
-
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
- if (priv->focus_tracker != NULL) {
- g_object_unref (priv->focus_tracker);
- priv->focus_tracker = NULL;
- }
-
- if (priv->cancellable != NULL) {
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
- priv->cancellable = NULL;
- }
-
- if (priv->registry != NULL) {
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->source != NULL) {
- g_object_unref (priv->source);
- priv->source = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_editor_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_editor_finalize (GObject *object)
-{
- EMailSignatureEditorPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE (object);
-
- g_free (priv->original_name);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_mail_signature_editor_parent_class)->
- finalize (object);
-}
-
-static void
-mail_signature_editor_constructed (GObject *object)
-{
- EMailSignatureEditor *editor;
- GtkActionGroup *action_group;
- EFocusTracker *focus_tracker;
- GtkhtmlEditor *gtkhtml_editor;
- GtkUIManager *ui_manager;
- GDBusObject *dbus_object;
- ESource *source;
- GtkAction *action;
- GtkWidget *container;
- GtkWidget *widget;
- const gchar *display_name;
- GError *error = NULL;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_signature_editor_parent_class)->
- constructed (object);
-
- editor = E_MAIL_SIGNATURE_EDITOR (object);
-
- gtkhtml_editor = GTKHTML_EDITOR (editor);
- ui_manager = gtkhtml_editor_get_ui_manager (gtkhtml_editor);
-
- /* Because we are loading from a hard-coded string, there is
- * no chance of I/O errors. Failure here implies a malformed
- * UI definition. Full stop. */
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- if (error != NULL)
- g_error ("%s", error->message);
-
- action_group = gtk_action_group_new ("signature");
- gtk_action_group_set_translation_domain (
- action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (
- action_group, entries,
- G_N_ELEMENTS (entries), editor);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- editor->priv->action_group = g_object_ref (action_group);
-
- /* Hide page properties because it is not inherited in the mail. */
- action = gtkhtml_editor_get_action (gtkhtml_editor, "properties-page");
- gtk_action_set_visible (action, FALSE);
-
- action = gtkhtml_editor_get_action (
- gtkhtml_editor, "context-properties-page");
- gtk_action_set_visible (action, FALSE);
-
- gtk_ui_manager_ensure_update (ui_manager);
-
- gtk_window_set_title (GTK_WINDOW (editor), _("Edit Signature"));
-
- /* Construct the signature name entry. */
-
- container = gtkhtml_editor->vbox;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- /* Position 2 should be between the main and style toolbars. */
- gtk_box_reorder_child (GTK_BOX (container), widget, 2);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_entry_new ();
- gtk_box_pack_end (GTK_BOX (container), widget, TRUE, TRUE, 0);
- editor->priv->entry = widget; /* not referenced */
- gtk_widget_show (widget);
-
- widget = gtk_label_new_with_mnemonic (_("_Signature Name:"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), editor->priv->entry);
- gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- g_signal_connect (
- editor, "delete-event",
- G_CALLBACK (mail_signature_editor_delete_event_cb), NULL);
-
- /* Construct the alert bar for errors. */
-
- container = gtkhtml_editor->vbox;
-
- widget = e_alert_bar_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- /* Position 5 should be between the style toolbar and editing area. */
- gtk_box_reorder_child (GTK_BOX (container), widget, 5);
- editor->priv->alert_bar = widget; /* not referenced */
- /* EAlertBar controls its own visibility. */
-
- /* Configure an EFocusTracker to manage selection actions.
- *
- * XXX GtkhtmlEditor does not manage its own selection actions,
- * which is technically a bug but works in our favor here
- * because it won't cause any conflicts with EFocusTracker. */
-
- focus_tracker = e_focus_tracker_new (GTK_WINDOW (editor));
-
- action = gtkhtml_editor_get_action (gtkhtml_editor, "cut");
- e_focus_tracker_set_cut_clipboard_action (focus_tracker, action);
-
- action = gtkhtml_editor_get_action (gtkhtml_editor, "copy");
- e_focus_tracker_set_copy_clipboard_action (focus_tracker, action);
-
- action = gtkhtml_editor_get_action (gtkhtml_editor, "paste");
- e_focus_tracker_set_paste_clipboard_action (focus_tracker, action);
-
- action = gtkhtml_editor_get_action (gtkhtml_editor, "select-all");
- e_focus_tracker_set_select_all_action (focus_tracker, action);
-
- editor->priv->focus_tracker = focus_tracker;
-
- source = e_mail_signature_editor_get_source (editor);
-
- display_name = e_source_get_display_name (source);
- if (display_name == NULL || *display_name == '\0')
- display_name = _("Unnamed");
-
- /* Set the entry text before we grab focus. */
- g_free (editor->priv->original_name);
- editor->priv->original_name = g_strdup (display_name);
- gtk_entry_set_text (GTK_ENTRY (editor->priv->entry), display_name);
-
- /* Set the focus appropriately. If this is a new signature, draw
- * the user's attention to the signature name entry. Otherwise go
- * straight to the editing area. */
- if (source == NULL)
- gtk_widget_grab_focus (editor->priv->entry);
- else {
- GtkHTML *html;
-
- html = gtkhtml_editor_get_html (gtkhtml_editor);
- gtk_widget_grab_focus (GTK_WIDGET (html));
- }
-
- /* Load file content only for an existing signature.
- * (A new signature will not yet have a GDBusObject.) */
- dbus_object = e_source_ref_dbus_object (source);
- if (dbus_object != NULL) {
- GCancellable *cancellable;
-
- cancellable = g_cancellable_new ();
-
- e_source_mail_signature_load (
- source,
- G_PRIORITY_DEFAULT,
- cancellable,
- mail_signature_editor_loaded_cb,
- g_object_ref (editor));
-
- g_warn_if_fail (editor->priv->cancellable == NULL);
- editor->priv->cancellable = cancellable;
-
- g_object_unref (dbus_object);
- }
-}
-
-static void
-mail_signature_editor_cut_clipboard (GtkhtmlEditor *editor)
-{
- /* Do nothing. EFocusTracker handles this. */
-}
-
-static void
-mail_signature_editor_copy_clipboard (GtkhtmlEditor *editor)
-{
- /* Do nothing. EFocusTracker handles this. */
-}
-
-static void
-mail_signature_editor_paste_clipboard (GtkhtmlEditor *editor)
-{
- /* Do nothing. EFocusTracker handles this. */
-}
-
-static void
-mail_signature_editor_select_all (GtkhtmlEditor *editor)
-{
- /* Do nothing. EFocusTracker handles this. */
-}
-
-static void
-mail_signature_editor_submit_alert (EAlertSink *alert_sink,
- EAlert *alert)
-{
- EMailSignatureEditorPrivate *priv;
- EAlertBar *alert_bar;
- GtkWidget *dialog;
- GtkWindow *parent;
-
- priv = E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE (alert_sink);
-
- switch (e_alert_get_message_type (alert)) {
- case GTK_MESSAGE_INFO:
- case GTK_MESSAGE_WARNING:
- case GTK_MESSAGE_ERROR:
- alert_bar = E_ALERT_BAR (priv->alert_bar);
- e_alert_bar_add_alert (alert_bar, alert);
- break;
-
- default:
- parent = GTK_WINDOW (alert_sink);
- dialog = e_alert_dialog_new (parent, alert);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- break;
- }
-}
-
-static void
-e_mail_signature_editor_class_init (EMailSignatureEditorClass *class)
-{
- GObjectClass *object_class;
- GtkhtmlEditorClass *editor_class;
-
- g_type_class_add_private (class, sizeof (EMailSignatureEditorPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_editor_set_property;
- object_class->get_property = mail_signature_editor_get_property;
- object_class->dispose = mail_signature_editor_dispose;
- object_class->finalize = mail_signature_editor_finalize;
- object_class->constructed = mail_signature_editor_constructed;
-
- editor_class = GTKHTML_EDITOR_CLASS (class);
- editor_class->cut_clipboard = mail_signature_editor_cut_clipboard;
- editor_class->copy_clipboard = mail_signature_editor_copy_clipboard;
- editor_class->paste_clipboard = mail_signature_editor_paste_clipboard;
- editor_class->select_all = mail_signature_editor_select_all;
-
- g_object_class_install_property (
- object_class,
- PROP_FOCUS_TRACKER,
- g_param_spec_object (
- "focus-tracker",
- NULL,
- NULL,
- E_TYPE_FOCUS_TRACKER,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- "Data source registry",
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE,
- g_param_spec_object (
- "source",
- NULL,
- NULL,
- E_TYPE_SOURCE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_mail_signature_editor_alert_sink_init (EAlertSinkInterface *interface)
-{
- interface->submit_alert = mail_signature_editor_submit_alert;
-}
-
-static void
-e_mail_signature_editor_init (EMailSignatureEditor *editor)
-{
- editor->priv = E_MAIL_SIGNATURE_EDITOR_GET_PRIVATE (editor);
-}
-
-GtkWidget *
-e_mail_signature_editor_new (ESourceRegistry *registry,
- ESource *source)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- if (source != NULL)
- g_return_val_if_fail (E_IS_SOURCE (source), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_EDITOR,
- "html", e_web_view_gtkhtml_new (),
- "registry", registry,
- "source", source, NULL);
-}
-
-EFocusTracker *
-e_mail_signature_editor_get_focus_tracker (EMailSignatureEditor *editor)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor), NULL);
-
- return editor->priv->focus_tracker;
-}
-
-ESourceRegistry *
-e_mail_signature_editor_get_registry (EMailSignatureEditor *editor)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor), NULL);
-
- return editor->priv->registry;
-}
-
-ESource *
-e_mail_signature_editor_get_source (EMailSignatureEditor *editor)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor), NULL);
-
- return editor->priv->source;
-}
-
-/********************** e_mail_signature_editor_commit() *********************/
-
-static void
-mail_signature_editor_replace_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
-
- e_source_mail_signature_replace_finish (
- E_SOURCE (object), result, &error);
-
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
-
- g_object_unref (simple);
-}
-
-static void
-mail_signature_editor_commit_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- AsyncContext *async_context;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
-
- e_source_registry_commit_source_finish (
- E_SOURCE_REGISTRY (object), result, &error);
-
- if (error != NULL) {
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- return;
- }
-
- /* We can call this on our scratch source because only its UID is
- * really needed, which even a new scratch source already knows. */
- e_source_mail_signature_replace (
- async_context->source,
- async_context->contents,
- async_context->length,
- G_PRIORITY_DEFAULT,
- async_context->cancellable,
- mail_signature_editor_replace_cb,
- simple);
-}
-
-void
-e_mail_signature_editor_commit (EMailSignatureEditor *editor,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- AsyncContext *async_context;
- ESourceMailSignature *extension;
- ESourceRegistry *registry;
- ESource *source;
- const gchar *extension_name;
- const gchar *mime_type;
- gchar *contents;
- gboolean is_html;
- gsize length;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor));
-
- registry = e_mail_signature_editor_get_registry (editor);
- source = e_mail_signature_editor_get_source (editor);
- is_html = gtkhtml_editor_get_html_mode (GTKHTML_EDITOR (editor));
-
- if (is_html) {
- mime_type = "text/html";
- contents = gtkhtml_editor_get_text_html (
- GTKHTML_EDITOR (editor), &length);
- } else {
- mime_type = "text/plain";
- contents = gtkhtml_editor_get_text_plain (
- GTKHTML_EDITOR (editor), &length);
- }
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- e_source_mail_signature_set_mime_type (extension, mime_type);
-
- async_context = g_slice_new0 (AsyncContext);
- async_context->source = g_object_ref (source);
- async_context->contents = contents; /* takes ownership */
- async_context->length = length;
-
- if (G_IS_CANCELLABLE (cancellable))
- async_context->cancellable = g_object_ref (cancellable);
-
- simple = g_simple_async_result_new (
- G_OBJECT (editor), callback, user_data,
- e_mail_signature_editor_commit);
-
- g_simple_async_result_set_op_res_gpointer (
- simple, async_context, (GDestroyNotify) async_context_free);
-
- e_source_registry_commit_source (
- registry, source,
- async_context->cancellable,
- mail_signature_editor_commit_cb,
- simple);
-}
-
-gboolean
-e_mail_signature_editor_commit_finish (EMailSignatureEditor *editor,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (editor),
- e_mail_signature_editor_commit), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- /* Assume success unless a GError is set. */
- return !g_simple_async_result_propagate_error (simple, error);
-}
-
diff --git a/widgets/misc/e-mail-signature-editor.h b/widgets/misc/e-mail-signature-editor.h
deleted file mode 100644
index 8f1be2dd0f..0000000000
--- a/widgets/misc/e-mail-signature-editor.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * e-mail-signature-editor.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_EDITOR_H
-#define E_MAIL_SIGNATURE_EDITOR_H
-
-#include <gtkhtml-editor.h>
-#include <misc/e-focus-tracker.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_EDITOR \
- (e_mail_signature_editor_get_type ())
-#define E_MAIL_SIGNATURE_EDITOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_EDITOR, EMailSignatureEditor))
-#define E_MAIL_SIGNATURE_EDITOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_EDITOR, EMailSignatureEditorClass))
-#define E_IS_MAIL_SIGNATURE_EDITOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_EDITOR))
-#define E_IS_MAIL_SIGNATURE_EDITOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_EDITOR))
-#define E_MAIL_SIGNATURE_EDITOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_EDITOR, EMailSignatureEditorClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignatureEditor EMailSignatureEditor;
-typedef struct _EMailSignatureEditorClass EMailSignatureEditorClass;
-typedef struct _EMailSignatureEditorPrivate EMailSignatureEditorPrivate;
-
-struct _EMailSignatureEditor {
- GtkhtmlEditor parent;
- EMailSignatureEditorPrivate *priv;
-};
-
-struct _EMailSignatureEditorClass {
- GtkhtmlEditorClass parent_class;
-};
-
-GType e_mail_signature_editor_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_editor_new (ESourceRegistry *registry,
- ESource *source);
-EFocusTracker * e_mail_signature_editor_get_focus_tracker
- (EMailSignatureEditor *editor);
-ESourceRegistry *
- e_mail_signature_editor_get_registry
- (EMailSignatureEditor *editor);
-ESource * e_mail_signature_editor_get_source
- (EMailSignatureEditor *editor);
-void e_mail_signature_editor_commit (EMailSignatureEditor *editor,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_mail_signature_editor_commit_finish
- (EMailSignatureEditor *editor,
- GAsyncResult *result,
- GError **error);
-
-G_END_DECLS
-
-#endif /* E_MAIL_SIGNATURE_EDITOR_H */
diff --git a/widgets/misc/e-mail-signature-manager.c b/widgets/misc/e-mail-signature-manager.c
deleted file mode 100644
index 66463336ea..0000000000
--- a/widgets/misc/e-mail-signature-manager.c
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
- * e-mail-signature-manager.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-manager.h"
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <libedataserver/libedataserver.h>
-
-#include "e-mail-signature-preview.h"
-#include "e-mail-signature-tree-view.h"
-#include "e-mail-signature-script-dialog.h"
-
-#define E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_MANAGER, EMailSignatureManagerPrivate))
-
-#define PREVIEW_HEIGHT 200
-
-struct _EMailSignatureManagerPrivate {
- ESourceRegistry *registry;
-
- GtkWidget *tree_view; /* not referenced */
- GtkWidget *add_button; /* not referenced */
- GtkWidget *add_script_button; /* not referenced */
- GtkWidget *edit_button; /* not referenced */
- GtkWidget *remove_button; /* not referenced */
- GtkWidget *preview; /* not referenced */
-
- gboolean prefer_html;
-};
-
-enum {
- PROP_0,
- PROP_PREFER_HTML,
- PROP_REGISTRY
-};
-
-enum {
- ADD_SIGNATURE,
- ADD_SIGNATURE_SCRIPT,
- EDITOR_CREATED,
- EDIT_SIGNATURE,
- REMOVE_SIGNATURE,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (
- EMailSignatureManager,
- e_mail_signature_manager,
- GTK_TYPE_PANED)
-
-static void
-mail_signature_manager_emit_editor_created (EMailSignatureManager *manager,
- GtkWidget *editor)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor));
-
- g_signal_emit (manager, signals[EDITOR_CREATED], 0, editor);
-}
-
-static gboolean
-mail_signature_manager_key_press_event_cb (EMailSignatureManager *manager,
- GdkEventKey *event)
-{
- if (event->keyval == GDK_KEY_Delete) {
- e_mail_signature_manager_remove_signature (manager);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-mail_signature_manager_run_script_dialog (EMailSignatureManager *manager,
- ESource *source,
- const gchar *title)
-{
- ESourceRegistry *registry;
- GtkWidget *dialog;
- gpointer parent;
-
- registry = e_mail_signature_manager_get_registry (manager);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- dialog = e_mail_signature_script_dialog_new (registry, parent, source);
- gtk_window_set_title (GTK_WINDOW (dialog), title);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- EAsyncClosure *closure;
- GAsyncResult *result;
- GError *error = NULL;
-
- closure = e_async_closure_new ();
-
- /* FIXME Make this cancellable. */
- e_mail_signature_script_dialog_commit (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog), NULL,
- e_async_closure_callback, closure);
-
- result = e_async_closure_wait (closure);
-
- e_mail_signature_script_dialog_commit_finish (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog),
- result, &error);
-
- e_async_closure_free (closure);
-
- /* FIXME Make this into an EAlert. */
- if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
- }
-
- gtk_widget_destroy (dialog);
-}
-
-static void
-mail_signature_manager_selection_changed_cb (EMailSignatureManager *manager,
- GtkTreeSelection *selection)
-{
- EMailSignaturePreview *preview;
- EMailSignatureTreeView *tree_view;
- ESource *source;
- GtkWidget *edit_button;
- GtkWidget *remove_button;
- gboolean sensitive;
- const gchar *uid = NULL;
-
- edit_button = manager->priv->edit_button;
- remove_button = manager->priv->remove_button;
-
- tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
- source = e_mail_signature_tree_view_ref_selected_source (tree_view);
-
- if (source != NULL)
- uid = e_source_get_uid (source);
-
- preview = E_MAIL_SIGNATURE_PREVIEW (manager->priv->preview);
- e_mail_signature_preview_set_source_uid (preview, uid);
-
- sensitive = (source != NULL);
- gtk_widget_set_sensitive (edit_button, sensitive);
- gtk_widget_set_sensitive (remove_button, sensitive);
-
- if (source != NULL)
- g_object_unref (source);
-}
-
-static void
-mail_signature_manager_set_registry (EMailSignatureManager *manager,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (manager->priv->registry == NULL);
-
- manager->priv->registry = g_object_ref (registry);
-}
-
-static void
-mail_signature_manager_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PREFER_HTML:
- e_mail_signature_manager_set_prefer_html (
- E_MAIL_SIGNATURE_MANAGER (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_REGISTRY:
- mail_signature_manager_set_registry (
- E_MAIL_SIGNATURE_MANAGER (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_manager_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PREFER_HTML:
- g_value_set_boolean (
- value,
- e_mail_signature_manager_get_prefer_html (
- E_MAIL_SIGNATURE_MANAGER (object)));
- return;
-
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_manager_get_registry (
- E_MAIL_SIGNATURE_MANAGER (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_manager_dispose (GObject *object)
-{
- EMailSignatureManagerPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_manager_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_manager_constructed (GObject *object)
-{
- EMailSignatureManager *manager;
- GtkTreeSelection *selection;
- ESourceRegistry *registry;
- GSettings *settings;
- GtkWidget *container;
- GtkWidget *widget;
- GtkWidget *hbox;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_signature_manager_parent_class)->
- constructed (object);
-
- manager = E_MAIL_SIGNATURE_MANAGER (object);
- registry = e_mail_signature_manager_get_registry (manager);
-
- gtk_orientable_set_orientation (
- GTK_ORIENTABLE (manager), GTK_ORIENTATION_VERTICAL);
-
- container = GTK_WIDGET (manager);
-
- widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 12, 0, 0);
- gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = hbox = 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_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_mail_signature_tree_view_new (registry);
- gtk_container_add (GTK_CONTAINER (container), widget);
- manager->priv->tree_view = widget; /* not referenced */
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "key-press-event",
- G_CALLBACK (mail_signature_manager_key_press_event_cb),
- manager);
-
- g_signal_connect_swapped (
- widget, "row-activated",
- G_CALLBACK (e_mail_signature_manager_edit_signature),
- manager);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
-
- g_signal_connect_swapped (
- selection, "changed",
- G_CALLBACK (mail_signature_manager_selection_changed_cb),
- manager);
-
- container = hbox;
-
- widget = gtk_vbutton_box_new ();
- gtk_button_box_set_layout (
- GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_START);
- gtk_box_set_spacing (GTK_BOX (widget), 6);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_button_new_from_stock (GTK_STOCK_ADD);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- manager->priv->add_button = widget; /* not referenced */
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (e_mail_signature_manager_add_signature),
- manager);
-
- widget = gtk_button_new_with_mnemonic (_("Add _Script"));
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_stock (
- GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON));
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- manager->priv->add_script_button = widget; /* not referenced */
- gtk_widget_show (widget);
-
- settings = g_settings_new ("org.gnome.desktop.lockdown");
-
- g_settings_bind (
- settings, "disable-command-line",
- widget, "visible",
- G_SETTINGS_BIND_GET |
- G_SETTINGS_BIND_INVERT_BOOLEAN);
-
- g_object_unref (settings);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (e_mail_signature_manager_add_signature_script),
- manager);
-
- widget = gtk_button_new_from_stock (GTK_STOCK_EDIT);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- manager->priv->edit_button = widget; /* not referenced */
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (e_mail_signature_manager_edit_signature),
- manager);
-
- widget = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- manager->priv->remove_button = widget; /* not referenced */
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (e_mail_signature_manager_remove_signature),
- manager);
-
- container = GTK_WIDGET (manager);
-
- 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_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_mail_signature_preview_new (registry);
- gtk_container_add (GTK_CONTAINER (container), widget);
- manager->priv->preview = widget; /* not referenced */
- gtk_widget_show (widget);
-
- gtk_paned_set_position (GTK_PANED (manager), PREVIEW_HEIGHT);
-}
-
-static void
-mail_signature_manager_add_signature (EMailSignatureManager *manager)
-{
- ESourceRegistry *registry;
- GtkWidget *editor;
-
- registry = e_mail_signature_manager_get_registry (manager);
-
- editor = e_mail_signature_editor_new (registry, NULL);
- gtkhtml_editor_set_html_mode (
- GTKHTML_EDITOR (editor), manager->priv->prefer_html);
- mail_signature_manager_emit_editor_created (manager, editor);
-
- gtk_widget_grab_focus (manager->priv->tree_view);
-}
-
-static void
-mail_signature_manager_add_signature_script (EMailSignatureManager *manager)
-{
- const gchar *title;
-
- title = _("Add Signature Script");
- mail_signature_manager_run_script_dialog (manager, NULL, title);
-
- gtk_widget_grab_focus (manager->priv->tree_view);
-}
-
-static void
-mail_signature_manager_editor_created (EMailSignatureManager *manager,
- EMailSignatureEditor *editor)
-{
- GtkWindowPosition position;
- gpointer parent;
-
- position = GTK_WIN_POS_CENTER_ON_PARENT;
- parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- gtk_window_set_transient_for (GTK_WINDOW (editor), parent);
- gtk_window_set_position (GTK_WINDOW (editor), position);
- gtk_widget_show (GTK_WIDGET (editor));
-}
-
-static void
-mail_signature_manager_edit_signature (EMailSignatureManager *manager)
-{
- EMailSignatureTreeView *tree_view;
- ESourceMailSignature *extension;
- ESourceRegistry *registry;
- GtkWidget *editor;
- ESource *source;
- GFileInfo *file_info;
- GFile *file;
- const gchar *attribute;
- const gchar *extension_name;
- const gchar *title;
- GError *error = NULL;
-
- registry = e_mail_signature_manager_get_registry (manager);
- tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
- source = e_mail_signature_tree_view_ref_selected_source (tree_view);
- g_return_if_fail (source != NULL);
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- file = e_source_mail_signature_get_file (extension);
-
- attribute = G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE;
-
- /* XXX This blocks but it should just be a local file. */
- file_info = g_file_query_info (
- file, attribute, G_FILE_QUERY_INFO_NONE, NULL, &error);
-
- /* FIXME Make this into an EAlert. */
- if (error != NULL) {
- g_warn_if_fail (file_info == NULL);
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_object_unref (source);
- g_error_free (error);
- return;
- }
-
- if (g_file_info_get_attribute_boolean (file_info, attribute))
- goto script;
-
- editor = e_mail_signature_editor_new (registry, source);
- mail_signature_manager_emit_editor_created (manager, editor);
-
- goto exit;
-
-script:
- title = _("Edit Signature Script");
- mail_signature_manager_run_script_dialog (manager, source, title);
-
-exit:
- gtk_widget_grab_focus (GTK_WIDGET (tree_view));
-
- g_object_unref (file_info);
- g_object_unref (source);
-}
-
-static void
-mail_signature_manager_remove_signature (EMailSignatureManager *manager)
-{
- EMailSignatureTreeView *tree_view;
- ESourceMailSignature *extension;
- ESource *source;
- GFile *file;
- const gchar *extension_name;
- GError *error = NULL;
-
- tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
- source = e_mail_signature_tree_view_ref_selected_source (tree_view);
-
- if (source == NULL)
- return;
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
-
- file = e_source_mail_signature_get_file (extension);
-
- /* XXX This blocks but it should just be a local file. */
- if (!g_file_delete (file, NULL, &error)) {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- /* Remove the mail signature data source asynchronously.
- * XXX No callback function because there's not much we can do
- * if this fails. We should probably implement EAlertSink. */
- e_source_remove (source, NULL, NULL, NULL);
-
- gtk_widget_grab_focus (GTK_WIDGET (tree_view));
-
- g_object_unref (source);
-}
-
-static void
-e_mail_signature_manager_class_init (EMailSignatureManagerClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (
- class, sizeof (EMailSignatureManagerPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_manager_set_property;
- object_class->get_property = mail_signature_manager_get_property;
- object_class->dispose = mail_signature_manager_dispose;
- object_class->constructed = mail_signature_manager_constructed;
-
- class->add_signature = mail_signature_manager_add_signature;
- class->add_signature_script =
- mail_signature_manager_add_signature_script;
- class->editor_created = mail_signature_manager_editor_created;
- class->edit_signature = mail_signature_manager_edit_signature;
- class->remove_signature = mail_signature_manager_remove_signature;
-
- g_object_class_install_property (
- object_class,
- PROP_PREFER_HTML,
- g_param_spec_boolean (
- "prefer-html",
- "Prefer HTML",
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- NULL,
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- signals[ADD_SIGNATURE] = g_signal_new (
- "add-signature",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EMailSignatureManagerClass, add_signature),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[ADD_SIGNATURE_SCRIPT] = g_signal_new (
- "add-signature-script",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (
- EMailSignatureManagerClass, add_signature_script),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[EDITOR_CREATED] = g_signal_new (
- "editor-created",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EMailSignatureManagerClass, editor_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- E_TYPE_MAIL_SIGNATURE_EDITOR);
-
- signals[EDIT_SIGNATURE] = g_signal_new (
- "edit-signature",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EMailSignatureManagerClass, edit_signature),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[REMOVE_SIGNATURE] = g_signal_new (
- "remove-signature",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EMailSignatureManagerClass, remove_signature),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_mail_signature_manager_init (EMailSignatureManager *manager)
-{
- manager->priv = E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE (manager);
-}
-
-GtkWidget *
-e_mail_signature_manager_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_MANAGER,
- "registry", registry, NULL);
-}
-
-void
-e_mail_signature_manager_add_signature (EMailSignatureManager *manager)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
-
- g_signal_emit (manager, signals[ADD_SIGNATURE], 0);
-}
-
-void
-e_mail_signature_manager_add_signature_script (EMailSignatureManager *manager)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
-
- g_signal_emit (manager, signals[ADD_SIGNATURE_SCRIPT], 0);
-}
-
-void
-e_mail_signature_manager_edit_signature (EMailSignatureManager *manager)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
-
- g_signal_emit (manager, signals[EDIT_SIGNATURE], 0);
-}
-
-void
-e_mail_signature_manager_remove_signature (EMailSignatureManager *manager)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
-
- g_signal_emit (manager, signals[REMOVE_SIGNATURE], 0);
-}
-
-gboolean
-e_mail_signature_manager_get_prefer_html (EMailSignatureManager *manager)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager), FALSE);
-
- return manager->priv->prefer_html;
-}
-
-void
-e_mail_signature_manager_set_prefer_html (EMailSignatureManager *manager,
- gboolean prefer_html)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
-
- if (manager->priv->prefer_html == prefer_html)
- return;
-
- manager->priv->prefer_html = prefer_html;
-
- g_object_notify (G_OBJECT (manager), "prefer-html");
-}
-
-ESourceRegistry *
-e_mail_signature_manager_get_registry (EMailSignatureManager *manager)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager), NULL);
-
- return manager->priv->registry;
-}
diff --git a/widgets/misc/e-mail-signature-manager.h b/widgets/misc/e-mail-signature-manager.h
deleted file mode 100644
index a627bd57fa..0000000000
--- a/widgets/misc/e-mail-signature-manager.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * e-mail-signature-manager.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_MANAGER_H
-#define E_MAIL_SIGNATURE_MANAGER_H
-
-#include <gtk/gtk.h>
-#include <misc/e-mail-signature-editor.h>
-#include <misc/e-mail-signature-tree-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_MANAGER \
- (e_mail_signature_manager_get_type ())
-#define E_MAIL_SIGNATURE_MANAGER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_MANAGER, EMailSignatureManager))
-#define E_MAIL_SIGNATURE_MANAGER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_MANAGER, EMailSignatureManagerClass))
-#define E_IS_MAIL_SIGNATURE_MANAGER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_MANAGER))
-#define E_IS_MAIL_SIGNATURE_MANAGER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_MANAGER))
-#define E_MAIL_SIGNATURE_MANAGER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_MANAGER, EMailSignatureManagerClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignatureManager EMailSignatureManager;
-typedef struct _EMailSignatureManagerClass EMailSignatureManagerClass;
-typedef struct _EMailSignatureManagerPrivate EMailSignatureManagerPrivate;
-
-struct _EMailSignatureManager {
- GtkPaned parent;
- EMailSignatureManagerPrivate *priv;
-};
-
-struct _EMailSignatureManagerClass {
- GtkPanedClass parent_class;
-
- void (*add_signature) (EMailSignatureManager *manager);
- void (*add_signature_script) (EMailSignatureManager *manager);
- void (*editor_created) (EMailSignatureManager *manager,
- EMailSignatureEditor *editor);
- void (*edit_signature) (EMailSignatureManager *manager);
- void (*remove_signature) (EMailSignatureManager *manager);
-};
-
-GType e_mail_signature_manager_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_manager_new
- (ESourceRegistry *registry);
-void e_mail_signature_manager_add_signature
- (EMailSignatureManager *manager);
-void e_mail_signature_manager_add_signature_script
- (EMailSignatureManager *manager);
-void e_mail_signature_manager_edit_signature
- (EMailSignatureManager *manager);
-void e_mail_signature_manager_remove_signature
- (EMailSignatureManager *manager);
-gboolean e_mail_signature_manager_get_prefer_html
- (EMailSignatureManager *manager);
-void e_mail_signature_manager_set_prefer_html
- (EMailSignatureManager *manager,
- gboolean prefer_html);
-ESourceRegistry *
- e_mail_signature_manager_get_registry
- (EMailSignatureManager *manager);
-
-#endif /* E_MAIL_SIGNATURE_MANAGER_H */
diff --git a/widgets/misc/e-mail-signature-preview.c b/widgets/misc/e-mail-signature-preview.c
deleted file mode 100644
index 0e7500c5ae..0000000000
--- a/widgets/misc/e-mail-signature-preview.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * e-mail-signature-preview.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-preview.h"
-
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <glib/gstdio.h>
-
-#include <libevolution-utils/e-alert-sink.h>
-
-#define E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_PREVIEW, EMailSignaturePreviewPrivate))
-
-#define SOURCE_IS_MAIL_SIGNATURE(source) \
- (e_source_has_extension ((source), E_SOURCE_EXTENSION_MAIL_SIGNATURE))
-
-struct _EMailSignaturePreviewPrivate {
- ESourceRegistry *registry;
- GCancellable *cancellable;
- gchar *source_uid;
-};
-
-enum {
- PROP_0,
- PROP_REGISTRY,
- PROP_SOURCE_UID
-};
-
-enum {
- REFRESH,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (
- EMailSignaturePreview,
- e_mail_signature_preview,
- E_TYPE_WEB_VIEW)
-
-static void
-mail_signature_preview_load_cb (ESource *source,
- GAsyncResult *result,
- EMailSignaturePreview *preview)
-{
- ESourceMailSignature *extension;
- const gchar *extension_name;
- const gchar *mime_type;
- gchar *contents = NULL;
- GError *error = NULL;
-
- e_source_mail_signature_load_finish (
- source, result, &contents, NULL, &error);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (contents == NULL);
- g_object_unref (preview);
- g_error_free (error);
- return;
-
- } else if (error != NULL) {
- g_warn_if_fail (contents == NULL);
- e_alert_submit (
- E_ALERT_SINK (preview),
- "widgets:no-load-signature",
- error->message, NULL);
- g_object_unref (preview);
- g_error_free (error);
- return;
- }
-
- g_return_if_fail (contents != NULL);
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- mime_type = e_source_mail_signature_get_mime_type (extension);
-
- if (g_strcmp0 (mime_type, "text/html") == 0)
- e_web_view_load_string (E_WEB_VIEW (preview), contents);
- else {
- gchar *string;
-
- string = g_markup_printf_escaped ("<pre>%s</pre>", contents);
- e_web_view_load_string (E_WEB_VIEW (preview), string);
- g_free (string);
- }
-
- g_free (contents);
-
- g_object_unref (preview);
-}
-
-static void
-mail_signature_preview_set_registry (EMailSignaturePreview *preview,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (preview->priv->registry == NULL);
-
- preview->priv->registry = g_object_ref (registry);
-}
-
-static void
-mail_signature_preview_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- mail_signature_preview_set_registry (
- E_MAIL_SIGNATURE_PREVIEW (object),
- g_value_get_object (value));
- return;
-
- case PROP_SOURCE_UID:
- e_mail_signature_preview_set_source_uid (
- E_MAIL_SIGNATURE_PREVIEW (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_preview_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_preview_get_registry (
- E_MAIL_SIGNATURE_PREVIEW (object)));
- return;
-
- case PROP_SOURCE_UID:
- g_value_set_string (
- value,
- e_mail_signature_preview_get_source_uid (
- E_MAIL_SIGNATURE_PREVIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_preview_dispose (GObject *object)
-{
- EMailSignaturePreviewPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->cancellable != NULL) {
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
- priv->cancellable = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_preview_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_preview_finalize (GObject *object)
-{
- EMailSignaturePreviewPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE (object);
-
- g_free (priv->source_uid);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_mail_signature_preview_parent_class)->
- finalize (object);
-}
-
-static void
-mail_signature_preview_refresh (EMailSignaturePreview *preview)
-{
- ESourceRegistry *registry;
- ESource *source;
- const gchar *extension_name;
- const gchar *source_uid;
-
- /* Cancel any unfinished refreshes. */
- if (preview->priv->cancellable != NULL) {
- g_cancellable_cancel (preview->priv->cancellable);
- g_object_unref (preview->priv->cancellable);
- preview->priv->cancellable = NULL;
- }
-
- source_uid = e_mail_signature_preview_get_source_uid (preview);
-
- if (source_uid == NULL)
- goto fail;
-
- registry = e_mail_signature_preview_get_registry (preview);
- source = e_source_registry_ref_source (registry, source_uid);
-
- if (source == NULL)
- goto fail;
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- if (!e_source_has_extension (source, extension_name)) {
- g_object_unref (source);
- goto fail;
- }
-
- preview->priv->cancellable = g_cancellable_new ();
-
- e_source_mail_signature_load (
- source, G_PRIORITY_DEFAULT,
- preview->priv->cancellable, (GAsyncReadyCallback)
- mail_signature_preview_load_cb, g_object_ref (preview));
-
- g_object_unref (source);
-
- return;
-
-fail:
- e_web_view_clear (E_WEB_VIEW (preview));
-}
-
-static void
-e_mail_signature_preview_class_init (EMailSignaturePreviewClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EMailSignaturePreviewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_preview_set_property;
- object_class->get_property = mail_signature_preview_get_property;
- object_class->dispose = mail_signature_preview_dispose;
- object_class->finalize = mail_signature_preview_finalize;
-
- class->refresh = mail_signature_preview_refresh;
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- NULL,
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_UID,
- g_param_spec_string (
- "source-uid",
- "Source UID",
- NULL,
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- signals[REFRESH] = g_signal_new (
- "refresh",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EMailSignaturePreviewClass, refresh),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_mail_signature_preview_init (EMailSignaturePreview *preview)
-{
- preview->priv = E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE (preview);
-}
-
-GtkWidget *
-e_mail_signature_preview_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_PREVIEW,
- "registry", registry, NULL);
-}
-
-void
-e_mail_signature_preview_refresh (EMailSignaturePreview *preview)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_PREVIEW (preview));
-
- g_signal_emit (preview, signals[REFRESH], 0);
-}
-
-ESourceRegistry *
-e_mail_signature_preview_get_registry (EMailSignaturePreview *preview)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_PREVIEW (preview), NULL);
-
- return preview->priv->registry;
-}
-
-const gchar *
-e_mail_signature_preview_get_source_uid (EMailSignaturePreview *preview)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_PREVIEW (preview), NULL);
-
- return preview->priv->source_uid;
-}
-
-void
-e_mail_signature_preview_set_source_uid (EMailSignaturePreview *preview,
- const gchar *source_uid)
-{
- g_return_if_fail (E_IS_MAIL_SIGNATURE_PREVIEW (preview));
-
- /* Avoid repeatedly loading the same signature file. */
- if (g_strcmp0 (source_uid, preview->priv->source_uid) == 0)
- return;
-
- g_free (preview->priv->source_uid);
- preview->priv->source_uid = g_strdup (source_uid);
-
- g_object_notify (G_OBJECT (preview), "source-uid");
-
- e_mail_signature_preview_refresh (preview);
-}
diff --git a/widgets/misc/e-mail-signature-preview.h b/widgets/misc/e-mail-signature-preview.h
deleted file mode 100644
index fff4c64d3d..0000000000
--- a/widgets/misc/e-mail-signature-preview.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * e-mail-signature-preview.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_PREVIEW_H
-#define E_MAIL_SIGNATURE_PREVIEW_H
-
-#include <misc/e-web-view.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_PREVIEW \
- (e_mail_signature_preview_get_type ())
-#define E_MAIL_SIGNATURE_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_PREVIEW, EMailSignaturePreview))
-#define E_MAIL_SIGNATURE_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_PREVIEW, EMailSignaturePreviewClass))
-#define E_IS_MAIL_SIGNATURE_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_PREVIEW))
-#define E_IS_MAIL_SIGNATURE_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_PREVIEW))
-#define E_MAIL_SIGNATURE_PREVIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_PREVIEW, EMailSignaturePreview))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignaturePreview EMailSignaturePreview;
-typedef struct _EMailSignaturePreviewClass EMailSignaturePreviewClass;
-typedef struct _EMailSignaturePreviewPrivate EMailSignaturePreviewPrivate;
-
-struct _EMailSignaturePreview {
- EWebView parent;
- EMailSignaturePreviewPrivate *priv;
-};
-
-struct _EMailSignaturePreviewClass {
- EWebViewClass parent_class;
-
- /* Signals */
- void (*refresh) (EMailSignaturePreview *preview);
-};
-
-GType e_mail_signature_preview_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_preview_new
- (ESourceRegistry *registry);
-void e_mail_signature_preview_refresh
- (EMailSignaturePreview *preview);
-ESourceRegistry *
- e_mail_signature_preview_get_registry
- (EMailSignaturePreview *preview);
-const gchar * e_mail_signature_preview_get_source_uid
- (EMailSignaturePreview *preview);
-void e_mail_signature_preview_set_source_uid
- (EMailSignaturePreview *preview,
- const gchar *source_uid);
-
-G_END_DECLS
-
-#endif /* E_MAIL_SIGNATURE_PREVIEW_H */
diff --git a/widgets/misc/e-mail-signature-script-dialog.c b/widgets/misc/e-mail-signature-script-dialog.c
deleted file mode 100644
index 58e8c43157..0000000000
--- a/widgets/misc/e-mail-signature-script-dialog.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/*
- * e-mail-signature-script-dialog.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-script-dialog.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#define E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG, \
- EMailSignatureScriptDialogPrivate))
-
-typedef struct _AsyncContext AsyncContext;
-
-struct _EMailSignatureScriptDialogPrivate {
- ESourceRegistry *registry;
- ESource *source;
-
- GtkWidget *entry; /* not referenced */
- GtkWidget *file_chooser; /* not referenced */
- GtkWidget *alert; /* not referenced */
-
- gchar *symlink_target;
-};
-
-struct _AsyncContext {
- ESource *source;
- GCancellable *cancellable;
- gchar *symlink_target;
-};
-
-enum {
- PROP_0,
- PROP_REGISTRY,
- PROP_SOURCE,
- PROP_SYMLINK_TARGET
-};
-
-G_DEFINE_TYPE (
- EMailSignatureScriptDialog,
- e_mail_signature_script_dialog,
- GTK_TYPE_DIALOG)
-
-static void
-async_context_free (AsyncContext *async_context)
-{
- if (async_context->source != NULL)
- g_object_unref (async_context->source);
-
- if (async_context->cancellable != NULL)
- g_object_unref (async_context->cancellable);
-
- g_free (async_context->symlink_target);
-
- g_slice_free (AsyncContext, async_context);
-}
-
-static gboolean
-mail_signature_script_dialog_filter_cb (const GtkFileFilterInfo *filter_info)
-{
- return g_file_test (filter_info->filename, G_FILE_TEST_IS_EXECUTABLE);
-}
-
-static void
-mail_signature_script_dialog_update_status (EMailSignatureScriptDialog *dialog)
-{
- ESource *source;
- const gchar *display_name;
- const gchar *symlink_target;
- gboolean show_alert;
- gboolean sensitive;
-
- source = e_mail_signature_script_dialog_get_source (dialog);
-
- display_name = e_source_get_display_name (source);
- sensitive = (display_name != NULL && *display_name != '\0');
-
- symlink_target =
- e_mail_signature_script_dialog_get_symlink_target (dialog);
-
- if (symlink_target != NULL) {
- gboolean executable;
-
- executable = g_file_test (
- symlink_target, G_FILE_TEST_IS_EXECUTABLE);
-
- show_alert = !executable;
- sensitive &= executable;
- } else {
- sensitive = FALSE;
- show_alert = FALSE;
- }
-
- if (show_alert)
- gtk_widget_show (dialog->priv->alert);
- else
- gtk_widget_hide (dialog->priv->alert);
-
- gtk_dialog_set_response_sensitive (
- GTK_DIALOG (dialog), GTK_RESPONSE_OK, sensitive);
-}
-
-static void
-mail_signature_script_dialog_file_set_cb (GtkFileChooserButton *button,
- EMailSignatureScriptDialog *dialog)
-{
- ESource *source;
- ESourceMailSignature *extension;
- GtkFileChooser *file_chooser;
- const gchar *extension_name;
- gchar *filename;
-
- file_chooser = GTK_FILE_CHOOSER (button);
- filename = gtk_file_chooser_get_filename (file_chooser);
-
- g_free (dialog->priv->symlink_target);
- dialog->priv->symlink_target = filename; /* takes ownership */
-
- /* Invalidate the saved MIME type. */
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- source = e_mail_signature_script_dialog_get_source (dialog);
- extension = e_source_get_extension (source, extension_name);
- e_source_mail_signature_set_mime_type (extension, NULL);
-
- g_object_notify (G_OBJECT (dialog), "symlink-target");
-
- mail_signature_script_dialog_update_status (dialog);
-}
-
-static void
-mail_signature_script_dialog_query_cb (GFile *file,
- GAsyncResult *result,
- EMailSignatureScriptDialog *dialog)
-{
- GFileInfo *file_info;
- const gchar *symlink_target;
- GError *error = NULL;
-
- file_info = g_file_query_info_finish (file, result, &error);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (file_info == NULL);
- g_object_unref (dialog);
- g_error_free (error);
- return;
-
- } else if (error != NULL) {
- g_warn_if_fail (file_info == NULL);
- g_warning ("%s", error->message);
- g_object_unref (dialog);
- g_error_free (error);
- return;
- }
-
- g_return_if_fail (G_IS_FILE_INFO (file_info));
-
- symlink_target = g_file_info_get_symlink_target (file_info);
-
- e_mail_signature_script_dialog_set_symlink_target (
- dialog, symlink_target);
-
- g_object_unref (file_info);
- g_object_unref (dialog);
-}
-
-static void
-mail_signature_script_dialog_set_registry (EMailSignatureScriptDialog *dialog,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (dialog->priv->registry == NULL);
-
- dialog->priv->registry = g_object_ref (registry);
-}
-
-static void
-mail_signature_script_dialog_set_source (EMailSignatureScriptDialog *dialog,
- ESource *source)
-{
- GDBusObject *dbus_object = NULL;
- const gchar *extension_name;
- GError *error = NULL;
-
- g_return_if_fail (source == NULL || E_IS_SOURCE (source));
- g_return_if_fail (dialog->priv->source == NULL);
-
- if (source != NULL)
- dbus_object = e_source_ref_dbus_object (source);
-
- /* Clone the source so we can make changes to it freely. */
- dialog->priv->source = e_source_new (dbus_object, NULL, &error);
-
- /* This should rarely fail. If the file was loaded successfully
- * once then it should load successfully here as well, unless an
- * I/O error occurs. */
- if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-
- /* Make sure the source has a mail signature extension. */
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- e_source_get_extension (dialog->priv->source, extension_name);
-
- /* If we're editing an existing signature, query the symbolic
- * link target of the signature file so we can initialize the
- * file chooser button. Note: The asynchronous callback will
- * run after the dialog initialization is complete. */
- if (dbus_object != NULL) {
- ESourceMailSignature *extension;
- const gchar *extension_name;
- GFile *file;
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- extension = e_source_get_extension (source, extension_name);
- file = e_source_mail_signature_get_file (extension);
-
- g_file_query_info_async (
- file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
- G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT,
- NULL, (GAsyncReadyCallback)
- mail_signature_script_dialog_query_cb,
- g_object_ref (dialog));
-
- g_object_unref (dbus_object);
- }
-}
-
-static void
-mail_signature_script_dialog_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- mail_signature_script_dialog_set_registry (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object),
- g_value_get_object (value));
- return;
-
- case PROP_SOURCE:
- mail_signature_script_dialog_set_source (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object),
- g_value_get_object (value));
- return;
-
- case PROP_SYMLINK_TARGET:
- e_mail_signature_script_dialog_set_symlink_target (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_script_dialog_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_script_dialog_get_registry (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object)));
- return;
-
- case PROP_SOURCE:
- g_value_set_object (
- value,
- e_mail_signature_script_dialog_get_source (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object)));
- return;
-
- case PROP_SYMLINK_TARGET:
- g_value_set_string (
- value,
- e_mail_signature_script_dialog_get_symlink_target (
- E_MAIL_SIGNATURE_SCRIPT_DIALOG (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_script_dialog_dispose (GObject *object)
-{
- EMailSignatureScriptDialogPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->source != NULL) {
- g_object_unref (priv->source);
- priv->source = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_script_dialog_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_script_dialog_finalize (GObject *object)
-{
- EMailSignatureScriptDialogPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_PRIVATE (object);
-
- g_free (priv->symlink_target);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_mail_signature_script_dialog_parent_class)->
- finalize (object);
-}
-
-static void
-mail_signature_script_dialog_constructed (GObject *object)
-{
- EMailSignatureScriptDialog *dialog;
- GtkFileFilter *filter;
- GtkWidget *container;
- GtkWidget *widget;
- ESource *source;
- const gchar *display_name;
- gchar *markup;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_signature_script_dialog_parent_class)->
- constructed (object);
-
- dialog = E_MAIL_SIGNATURE_SCRIPT_DIALOG (object);
-
- source = e_mail_signature_script_dialog_get_source (dialog);
- display_name = e_source_get_display_name (source);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-
- gtk_dialog_add_button (
- GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (
- GTK_DIALOG (dialog),
- GTK_STOCK_SAVE, GTK_RESPONSE_OK);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- widget = gtk_table_new (4, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (widget), 6);
- gtk_table_set_row_spacings (GTK_TABLE (widget), 6);
- gtk_table_set_row_spacing (GTK_TABLE (widget), 0, 12);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_stock (
- GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 0, 1, 0, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (_(
- "The output of this script will be used as your\n"
- "signature. The name you specify will be used\n"
- "for display purposes only."));
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (widget), display_name);
- gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->entry = widget; /* not referenced */
- gtk_widget_show (widget);
-
- g_object_bind_property (
- widget, "text",
- source, "display-name",
- G_BINDING_DEFAULT);
-
- widget = gtk_label_new_with_mnemonic (_("_Name:"));
- gtk_label_set_mnemonic_widget (
- GTK_LABEL (widget), dialog->priv->entry);
- gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_file_chooser_button_new (
- NULL, GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- dialog->priv->file_chooser = widget; /* not referenced */
- gtk_widget_show (widget);
-
- /* Restrict file selection to executable files. */
- filter = gtk_file_filter_new ();
- gtk_file_filter_add_custom (
- filter, GTK_FILE_FILTER_FILENAME,
- (GtkFileFilterFunc) mail_signature_script_dialog_filter_cb,
- NULL, NULL);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (widget), filter);
-
- /* We create symbolic links to script files from the "signatures"
- * directory, so restrict the selection to local files only. */
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE);
-
- widget = gtk_label_new_with_mnemonic (_("S_cript:"));
- gtk_label_set_mnemonic_widget (
- GTK_LABEL (widget), dialog->priv->file_chooser);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- /* This is just a placeholder. */
- widget = gtk_label_new (NULL);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- 1, 2, 3, 4, 0, 0, 0, 0);
- dialog->priv->alert = widget; /* not referenced */
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_stock (
- GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- markup = g_markup_printf_escaped (
- "<small>%s</small>",
- _("Script file must be executable."));
- widget = gtk_label_new (markup);
- gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
- g_free (markup);
-
- g_signal_connect (
- dialog->priv->file_chooser, "file-set",
- G_CALLBACK (mail_signature_script_dialog_file_set_cb), dialog);
-
- g_signal_connect_swapped (
- dialog->priv->entry, "changed",
- G_CALLBACK (mail_signature_script_dialog_update_status), dialog);
-
- mail_signature_script_dialog_update_status (dialog);
-}
-
-static void
-e_mail_signature_script_dialog_class_init (EMailSignatureScriptDialogClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (
- class, sizeof (EMailSignatureScriptDialogPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_script_dialog_set_property;
- object_class->get_property = mail_signature_script_dialog_get_property;
- object_class->dispose = mail_signature_script_dialog_dispose;
- object_class->finalize = mail_signature_script_dialog_finalize;
- object_class->constructed = mail_signature_script_dialog_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- "Data source registry",
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE,
- g_param_spec_object (
- "source",
- "Source",
- NULL,
- E_TYPE_SOURCE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_SYMLINK_TARGET,
- g_param_spec_string (
- "symlink-target",
- "Symlink Target",
- NULL,
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_mail_signature_script_dialog_init (EMailSignatureScriptDialog *dialog)
-{
- dialog->priv = E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_PRIVATE (dialog);
-}
-
-GtkWidget *
-e_mail_signature_script_dialog_new (ESourceRegistry *registry,
- GtkWindow *parent,
- ESource *source)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- if (source != NULL)
- g_return_val_if_fail (E_IS_SOURCE (source), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG,
- "registry", registry,
- "transient-for", parent,
- "source", source, NULL);
-}
-
-ESourceRegistry *
-e_mail_signature_script_dialog_get_registry (EMailSignatureScriptDialog *dialog)
-{
- g_return_val_if_fail (
- E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog), NULL);
-
- return dialog->priv->registry;
-}
-
-ESource *
-e_mail_signature_script_dialog_get_source (EMailSignatureScriptDialog *dialog)
-{
- g_return_val_if_fail (
- E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog), NULL);
-
- return dialog->priv->source;
-}
-
-const gchar *
-e_mail_signature_script_dialog_get_symlink_target (EMailSignatureScriptDialog *dialog)
-{
- g_return_val_if_fail (
- E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog), NULL);
-
- return dialog->priv->symlink_target;
-}
-
-void
-e_mail_signature_script_dialog_set_symlink_target (EMailSignatureScriptDialog *dialog,
- const gchar *symlink_target)
-{
- GtkFileChooser *file_chooser;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog));
- g_return_if_fail (symlink_target != NULL);
-
- g_free (dialog->priv->symlink_target);
- dialog->priv->symlink_target = g_strdup (symlink_target);
-
- file_chooser = GTK_FILE_CHOOSER (dialog->priv->file_chooser);
- gtk_file_chooser_set_filename (file_chooser, symlink_target);
-
- g_object_notify (G_OBJECT (dialog), "symlink-target");
-
- mail_signature_script_dialog_update_status (dialog);
-}
-
-/****************** e_mail_signature_script_dialog_commit() ******************/
-
-static void
-mail_signature_script_dialog_symlink_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
-
- e_source_mail_signature_symlink_finish (
- E_SOURCE (object), result, &error);
-
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
-
- g_object_unref (simple);
-}
-
-static void
-mail_signature_script_dialog_commit_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- AsyncContext *async_context;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
-
- e_source_registry_commit_source_finish (
- E_SOURCE_REGISTRY (object), result, &error);
-
- if (error != NULL) {
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- return;
- }
-
- /* We can call this on our scratch source because only its UID is
- * really needed, which even a new scratch source already knows. */
- e_source_mail_signature_symlink (
- async_context->source,
- async_context->symlink_target,
- G_PRIORITY_DEFAULT,
- async_context->cancellable,
- mail_signature_script_dialog_symlink_cb,
- simple);
-}
-
-void
-e_mail_signature_script_dialog_commit (EMailSignatureScriptDialog *dialog,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- AsyncContext *async_context;
- ESourceRegistry *registry;
- ESource *source;
- const gchar *symlink_target;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog));
-
- registry = e_mail_signature_script_dialog_get_registry (dialog);
- source = e_mail_signature_script_dialog_get_source (dialog);
-
- symlink_target =
- e_mail_signature_script_dialog_get_symlink_target (dialog);
-
- async_context = g_slice_new0 (AsyncContext);
- async_context->source = g_object_ref (source);
- async_context->symlink_target = g_strdup (symlink_target);
-
- if (G_IS_CANCELLABLE (cancellable))
- async_context->cancellable = g_object_ref (cancellable);
-
- simple = g_simple_async_result_new (
- G_OBJECT (dialog), callback, user_data,
- e_mail_signature_script_dialog_commit);
-
- g_simple_async_result_set_op_res_gpointer (
- simple, async_context, (GDestroyNotify) async_context_free);
-
- e_source_registry_commit_source (
- registry, source,
- async_context->cancellable,
- mail_signature_script_dialog_commit_cb,
- simple);
-}
-
-gboolean
-e_mail_signature_script_dialog_commit_finish (EMailSignatureScriptDialog *dialog,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (dialog),
- e_mail_signature_script_dialog_commit), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- /* Assume success unless a GError is set. */
- return !g_simple_async_result_propagate_error (simple, error);
-}
-
diff --git a/widgets/misc/e-mail-signature-script-dialog.h b/widgets/misc/e-mail-signature-script-dialog.h
deleted file mode 100644
index b28521e488..0000000000
--- a/widgets/misc/e-mail-signature-script-dialog.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * e-mail-signature-script-dialog.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_SCRIPT_DIALOG_H
-#define E_MAIL_SIGNATURE_SCRIPT_DIALOG_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG \
- (e_mail_signature_script_dialog_get_type ())
-#define E_MAIL_SIGNATURE_SCRIPT_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG, \
- EMailSignatureScriptDialog))
-#define E_MAIL_SIGNATURE_SCRIPT_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG, \
- EMailSignatureScriptDialogClass))
-#define E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG))
-#define E_IS_MAIL_SIGNATURE_SCRIPT_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG))
-#define E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG, \
- EMailSignatureScriptDialogClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignatureScriptDialog EMailSignatureScriptDialog;
-typedef struct _EMailSignatureScriptDialogClass EMailSignatureScriptDialogClass;
-typedef struct _EMailSignatureScriptDialogPrivate EMailSignatureScriptDialogPrivate;
-
-struct _EMailSignatureScriptDialog {
- GtkDialog parent;
- EMailSignatureScriptDialogPrivate *priv;
-};
-
-struct _EMailSignatureScriptDialogClass {
- GtkDialogClass parent_class;
-};
-
-GType e_mail_signature_script_dialog_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_script_dialog_new
- (ESourceRegistry *registry,
- GtkWindow *parent,
- ESource *source);
-ESourceRegistry *
- e_mail_signature_script_dialog_get_registry
- (EMailSignatureScriptDialog *dialog);
-ESource * e_mail_signature_script_dialog_get_source
- (EMailSignatureScriptDialog *dialog);
-const gchar * e_mail_signature_script_dialog_get_symlink_target
- (EMailSignatureScriptDialog *dialog);
-void e_mail_signature_script_dialog_set_symlink_target
- (EMailSignatureScriptDialog *dialog,
- const gchar *symlink_target);
-void e_mail_signature_script_dialog_commit
- (EMailSignatureScriptDialog *dialog,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_mail_signature_script_dialog_commit_finish
- (EMailSignatureScriptDialog *dialog,
- GAsyncResult *result,
- GError **error);
-
-G_END_DECLS
-
-#endif /* E_MAIL_SIGNATURE_SCRIPT_DIALOG_H */
diff --git a/widgets/misc/e-mail-signature-tree-view.c b/widgets/misc/e-mail-signature-tree-view.c
deleted file mode 100644
index 05a2580d78..0000000000
--- a/widgets/misc/e-mail-signature-tree-view.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * e-mail-signature-tree-view.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-signature-tree-view.h"
-
-#define E_MAIL_SIGNATURE_TREE_VIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAIL_SIGNATURE_TREE_VIEW, EMailSignatureTreeViewPrivate))
-
-#define SOURCE_IS_MAIL_SIGNATURE(source) \
- (e_source_has_extension ((source), E_SOURCE_EXTENSION_MAIL_SIGNATURE))
-
-struct _EMailSignatureTreeViewPrivate {
- ESourceRegistry *registry;
- guint refresh_idle_id;
-};
-
-enum {
- PROP_0,
- PROP_REGISTRY
-};
-
-enum {
- COLUMN_DISPLAY_NAME,
- COLUMN_UID,
- NUM_COLUMNS
-};
-
-G_DEFINE_TYPE (
- EMailSignatureTreeView,
- e_mail_signature_tree_view,
- GTK_TYPE_TREE_VIEW)
-
-static gboolean
-mail_signature_tree_view_refresh_idle_cb (EMailSignatureTreeView *tree_view)
-{
- /* The refresh function will clear the idle ID. */
- e_mail_signature_tree_view_refresh (tree_view);
-
- return FALSE;
-}
-
-static void
-mail_signature_tree_view_registry_changed (ESourceRegistry *registry,
- ESource *source,
- EMailSignatureTreeView *tree_view)
-{
- /* If the ESource in question has a "Mail Signature" extension,
- * schedule a refresh of the tree model. Otherwise ignore it.
- * We use an idle callback to limit how frequently we refresh
- * the tree model, in case the registry is emitting lots of
- * signals at once. */
-
- if (!SOURCE_IS_MAIL_SIGNATURE (source))
- return;
-
- if (tree_view->priv->refresh_idle_id > 0)
- return;
-
- tree_view->priv->refresh_idle_id = g_idle_add (
- (GSourceFunc) mail_signature_tree_view_refresh_idle_cb,
- tree_view);
-}
-
-static void
-mail_signature_tree_view_set_registry (EMailSignatureTreeView *tree_view,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (tree_view->priv->registry == NULL);
-
- tree_view->priv->registry = g_object_ref (registry);
-
- g_signal_connect (
- registry, "source-added",
- G_CALLBACK (mail_signature_tree_view_registry_changed),
- tree_view);
-
- g_signal_connect (
- registry, "source-changed",
- G_CALLBACK (mail_signature_tree_view_registry_changed),
- tree_view);
-
- g_signal_connect (
- registry, "source-removed",
- G_CALLBACK (mail_signature_tree_view_registry_changed),
- tree_view);
-}
-
-static void
-mail_signature_tree_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- mail_signature_tree_view_set_registry (
- E_MAIL_SIGNATURE_TREE_VIEW (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_tree_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_mail_signature_tree_view_get_registry (
- E_MAIL_SIGNATURE_TREE_VIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-mail_signature_tree_view_dispose (GObject *object)
-{
- EMailSignatureTreeViewPrivate *priv;
-
- priv = E_MAIL_SIGNATURE_TREE_VIEW_GET_PRIVATE (object);
-
- if (priv->registry != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->registry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->refresh_idle_id > 0) {
- g_source_remove (priv->refresh_idle_id);
- priv->refresh_idle_id = 0;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_signature_tree_view_parent_class)->
- dispose (object);
-}
-
-static void
-mail_signature_tree_view_constructed (GObject *object)
-{
- GtkTreeView *tree_view;
- GtkTreeViewColumn *column;
- GtkCellRenderer *cell_renderer;
- GtkListStore *list_store;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_mail_signature_tree_view_parent_class)->
- constructed (object);
-
- list_store = gtk_list_store_new (
- NUM_COLUMNS,
- G_TYPE_STRING, /* COLUMN_DISPLAY_NAME */
- G_TYPE_STRING); /* COLUMN_UID */
-
- tree_view = GTK_TREE_VIEW (object);
- gtk_tree_view_set_headers_visible (tree_view, FALSE);
- gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (list_store));
-
- g_object_unref (list_store);
-
- /* Column: Signature Name */
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
-
- cell_renderer = gtk_cell_renderer_text_new ();
- g_object_set (cell_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
-
- gtk_tree_view_column_add_attribute (
- column, cell_renderer, "text", COLUMN_DISPLAY_NAME);
-
- gtk_tree_view_append_column (tree_view, column);
-
- e_mail_signature_tree_view_refresh (
- E_MAIL_SIGNATURE_TREE_VIEW (object));
-}
-
-static void
-e_mail_signature_tree_view_class_init (EMailSignatureTreeViewClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (
- class, sizeof (EMailSignatureTreeViewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_signature_tree_view_set_property;
- object_class->get_property = mail_signature_tree_view_get_property;
- object_class->dispose = mail_signature_tree_view_dispose;
- object_class->constructed = mail_signature_tree_view_constructed;
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- NULL,
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_mail_signature_tree_view_init (EMailSignatureTreeView *tree_view)
-{
- tree_view->priv = E_MAIL_SIGNATURE_TREE_VIEW_GET_PRIVATE (tree_view);
-}
-
-GtkWidget *
-e_mail_signature_tree_view_new (ESourceRegistry *registry)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- return g_object_new (
- E_TYPE_MAIL_SIGNATURE_TREE_VIEW,
- "registry", registry, NULL);
-}
-
-void
-e_mail_signature_tree_view_refresh (EMailSignatureTreeView *tree_view)
-{
- ESourceRegistry *registry;
- GtkTreeModel *tree_model;
- GtkTreeSelection *selection;
- ESource *source;
- GList *list, *link;
- const gchar *extension_name;
- gchar *saved_uid = NULL;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_TREE_VIEW (tree_view));
-
- if (tree_view->priv->refresh_idle_id > 0) {
- g_source_remove (tree_view->priv->refresh_idle_id);
- tree_view->priv->refresh_idle_id = 0;
- }
-
- registry = e_mail_signature_tree_view_get_registry (tree_view);
- tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-
- source = e_mail_signature_tree_view_ref_selected_source (tree_view);
- if (source != NULL) {
- saved_uid = e_source_dup_uid (source);
- g_object_unref (source);
- }
-
- gtk_list_store_clear (GTK_LIST_STORE (tree_model));
-
- extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
- list = e_source_registry_list_sources (registry, extension_name);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- GtkTreeIter iter;
- const gchar *display_name;
- const gchar *uid;
-
- source = E_SOURCE (link->data);
- display_name = e_source_get_display_name (source);
- uid = e_source_get_uid (source);
-
- gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, display_name,
- COLUMN_UID, uid, -1);
- }
-
- g_list_free_full (list, (GDestroyNotify) g_object_unref);
-
- /* Try and restore the previous selected source. */
-
- source = NULL;
-
- if (saved_uid != NULL) {
- source = e_source_registry_ref_source (registry, saved_uid);
- g_free (saved_uid);
- }
-
- if (source != NULL) {
- e_mail_signature_tree_view_set_selected_source (
- tree_view, source);
- g_object_unref (source);
- }
-
- /* Hint to refresh a signature preview. */
- g_signal_emit_by_name (selection, "changed");
-}
-
-ESourceRegistry *
-e_mail_signature_tree_view_get_registry (EMailSignatureTreeView *tree_view)
-{
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_TREE_VIEW (tree_view), NULL);
-
- return tree_view->priv->registry;
-}
-
-ESource *
-e_mail_signature_tree_view_ref_selected_source (EMailSignatureTreeView *tree_view)
-{
- ESourceRegistry *registry;
- GtkTreeSelection *selection;
- GtkTreeModel *tree_model;
- GtkTreeIter iter;
- ESource *source;
- gchar *uid;
-
- g_return_val_if_fail (E_IS_MAIL_SIGNATURE_TREE_VIEW (tree_view), NULL);
-
- registry = e_mail_signature_tree_view_get_registry (tree_view);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-
- if (!gtk_tree_selection_get_selected (selection, &tree_model, &iter))
- return NULL;
-
- gtk_tree_model_get (tree_model, &iter, COLUMN_UID, &uid, -1);
- source = e_source_registry_ref_source (registry, uid);
- g_free (uid);
-
- return source;
-}
-
-void
-e_mail_signature_tree_view_set_selected_source (EMailSignatureTreeView *tree_view,
- ESource *source)
-{
- ESourceRegistry *registry;
- GtkTreeSelection *selection;
- GtkTreeModel *tree_model;
- GtkTreeIter iter;
- gboolean valid;
-
- g_return_if_fail (E_IS_MAIL_SIGNATURE_TREE_VIEW (tree_view));
- g_return_if_fail (E_IS_SOURCE (source));
-
- /* It is a programming error to pass an ESource that has no
- * "Mail Signature" extension. */
- g_return_if_fail (SOURCE_IS_MAIL_SIGNATURE (source));
-
- registry = e_mail_signature_tree_view_get_registry (tree_view);
- tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-
- valid = gtk_tree_model_get_iter_first (tree_model, &iter);
-
- while (valid) {
- ESource *candidate;
- gchar *uid;
-
- gtk_tree_model_get (tree_model, &iter, COLUMN_UID, &uid, -1);
- candidate = e_source_registry_ref_source (registry, uid);
- g_free (uid);
-
- if (candidate != NULL && e_source_equal (source, candidate)) {
- gtk_tree_selection_select_iter (selection, &iter);
- g_object_unref (candidate);
- break;
- }
-
- if (candidate != NULL)
- g_object_unref (candidate);
-
- valid = gtk_tree_model_iter_next (tree_model, &iter);
- }
-}
diff --git a/widgets/misc/e-mail-signature-tree-view.h b/widgets/misc/e-mail-signature-tree-view.h
deleted file mode 100644
index ba2615f6d8..0000000000
--- a/widgets/misc/e-mail-signature-tree-view.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * e-mail-signature-tree-view.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_SIGNATURE_TREE_VIEW_H
-#define E_MAIL_SIGNATURE_TREE_VIEW_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAIL_SIGNATURE_TREE_VIEW \
- (e_mail_signature_tree_view_get_type ())
-#define E_MAIL_SIGNATURE_TREE_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAIL_SIGNATURE_TREE_VIEW, EMailSignatureTreeView))
-#define E_MAIL_SIGNATURE_TREE_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAIL_SIGNATURE_TREE_VIEW, EMailSignatureTreeViewClass))
-#define E_IS_MAIL_SIGNATURE_TREE_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAIL_SIGNATURE_TREE_VIEW))
-#define E_IS_MAIL_SIGNATURE_TREE_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAIL_SIGNATURE_TREE_VIEW))
-#define E_MAIL_SIGNATURE_TREE_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAIL_SIGNATURE_TREE_VIEW, EMailSignatureTreeViewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMailSignatureTreeView EMailSignatureTreeView;
-typedef struct _EMailSignatureTreeViewClass EMailSignatureTreeViewClass;
-typedef struct _EMailSignatureTreeViewPrivate EMailSignatureTreeViewPrivate;
-
-struct _EMailSignatureTreeView {
- GtkTreeView parent;
- EMailSignatureTreeViewPrivate *priv;
-};
-
-struct _EMailSignatureTreeViewClass {
- GtkTreeViewClass parent_class;
-};
-
-GType e_mail_signature_tree_view_get_type
- (void) G_GNUC_CONST;
-GtkWidget * e_mail_signature_tree_view_new
- (ESourceRegistry *registry);
-void e_mail_signature_tree_view_refresh
- (EMailSignatureTreeView *tree_view);
-ESourceRegistry *
- e_mail_signature_tree_view_get_registry
- (EMailSignatureTreeView *tree_view);
-ESource * e_mail_signature_tree_view_ref_selected_source
- (EMailSignatureTreeView *tree_view);
-void e_mail_signature_tree_view_set_selected_source
- (EMailSignatureTreeView *tree_view,
- ESource *selected_source);
-
-G_END_DECLS
-
-#endif /* E_MAIL_SIGNATURE_TREE_VIEW_H */
diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c
deleted file mode 100644
index b9f83d811d..0000000000
--- a/widgets/misc/e-map.c
+++ /dev/null
@@ -1,1430 +0,0 @@
-/*
- * Map widget.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Hans Petter Jansson <hpj@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-#include <stdlib.h>
-#include <gdk/gdkkeysyms.h>
-#include <glib/gi18n.h>
-
-#include "e-util/e-util-private.h"
-#include "e-util/e-util.h"
-
-#include "e-map.h"
-
-#define E_MAP_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MAP, EMapPrivate))
-
-#define E_MAP_TWEEN_TIMEOUT_MSECS 25
-#define E_MAP_TWEEN_DURATION_MSECS 150
-
-/* Scroll step increment */
-
-#define SCROLL_STEP_SIZE 32
-
-/* */
-
-#define E_MAP_GET_WIDTH(map) gtk_adjustment_get_upper((map)->priv->hadjustment)
-#define E_MAP_GET_HEIGHT(map) gtk_adjustment_get_upper((map)->priv->vadjustment)
-
-/* Zoom state - keeps track of animation hacks */
-
-typedef enum
-{
- E_MAP_ZOOMED_IN,
- E_MAP_ZOOMED_OUT,
- E_MAP_ZOOMING_IN,
- E_MAP_ZOOMING_OUT
-}
-EMapZoomState;
-
-/* The Tween struct used for zooming */
-
-typedef struct _EMapTween EMapTween;
-
-struct _EMapTween {
- guint start_time;
- guint end_time;
- gdouble longitude_offset;
- gdouble latitude_offset;
- gdouble zoom_factor;
-};
-
-/* Private part of the EMap structure */
-
-struct _EMapPrivate {
- /* Pointer to map image */
- GdkPixbuf *map_pixbuf;
- cairo_surface_t *map_render_surface;
-
- /* Settings */
- gboolean frozen, smooth_zoom;
-
- /* Adjustments for scrolling */
- GtkAdjustment *hadjustment;
- GtkAdjustment *vadjustment;
-
- /* GtkScrollablePolicy needs to be checked when
- * driving the scrollable adjustment values */
- guint hscroll_policy : 1;
- guint vscroll_policy : 1;
-
- /* Current scrolling offsets */
- gint xofs, yofs;
-
- /* Realtime zoom data */
- EMapZoomState zoom_state;
- gdouble zoom_target_long, zoom_target_lat;
-
- /* Dots */
- GPtrArray *points;
-
- /* Tweens */
- GSList *tweens;
- GTimer *timer;
- guint timer_current_ms;
- guint tween_id;
-};
-
-/* Properties */
-
-enum {
- PROP_0,
-
- /* For scrollable interface */
- PROP_HADJUSTMENT,
- PROP_VADJUSTMENT,
- PROP_HSCROLL_POLICY,
- PROP_VSCROLL_POLICY
-};
-
-/* Internal prototypes */
-
-static void update_render_surface (EMap *map, gboolean render_overlays);
-static void set_scroll_area (EMap *map, gint width, gint height);
-static void center_at (EMap *map, gdouble longitude, gdouble latitude);
-static void scroll_to (EMap *map, gint x, gint y);
-static gint load_map_background (EMap *map, gchar *name);
-static void update_and_paint (EMap *map);
-static void update_render_point (EMap *map, EMapPoint *point);
-static void repaint_point (EMap *map, EMapPoint *point);
-
-/* ------ *
- * Tweens *
- * ------ */
-
-static gboolean
-e_map_is_tweening (EMap *map)
-{
- return map->priv->timer != NULL;
-}
-
-static void
-e_map_stop_tweening (EMap *map)
-{
- g_assert (map->priv->tweens == NULL);
-
- if (!e_map_is_tweening (map))
- return;
-
- g_timer_destroy (map->priv->timer);
- map->priv->timer = NULL;
- g_source_remove (map->priv->tween_id);
- map->priv->tween_id = 0;
-}
-
-static void
-e_map_tween_destroy (EMap *map,
- EMapTween *tween)
-{
- map->priv->tweens = g_slist_remove (map->priv->tweens, tween);
- g_slice_free (EMapTween, tween);
-
- if (map->priv->tweens == NULL)
- e_map_stop_tweening (map);
-}
-
-static gboolean
-e_map_do_tween_cb (gpointer data)
-{
- EMap *map = data;
- GSList *walk;
-
- map->priv->timer_current_ms =
- g_timer_elapsed (map->priv->timer, NULL) * 1000;
- gtk_widget_queue_draw (GTK_WIDGET (map));
-
- /* Can't use for loop here, because we need to advance
- * the list before deleting.
- */
- walk = map->priv->tweens;
- while (walk)
- {
- EMapTween *tween = walk->data;
-
- walk = walk->next;
-
- if (tween->end_time <= map->priv->timer_current_ms)
- e_map_tween_destroy (map, tween);
- }
-
- return TRUE;
-}
-
-static void
-e_map_start_tweening (EMap *map)
-{
- if (e_map_is_tweening (map))
- return;
-
- map->priv->timer = g_timer_new ();
- map->priv->timer_current_ms = 0;
- map->priv->tween_id = g_timeout_add (
- E_MAP_TWEEN_TIMEOUT_MSECS, e_map_do_tween_cb, map);
- g_timer_start (map->priv->timer);
-}
-
-static void
-e_map_tween_new (EMap *map,
- guint msecs,
- gdouble longitude_offset,
- gdouble latitude_offset,
- gdouble zoom_factor)
-{
- EMapTween *tween;
-
- if (!map->priv->smooth_zoom)
- return;
-
- e_map_start_tweening (map);
-
- tween = g_slice_new (EMapTween);
-
- tween->start_time = map->priv->timer_current_ms;
- tween->end_time = tween->start_time + msecs;
- tween->longitude_offset = longitude_offset;
- tween->latitude_offset = latitude_offset;
- tween->zoom_factor = zoom_factor;
-
- map->priv->tweens = g_slist_prepend (map->priv->tweens, tween);
-
- gtk_widget_queue_draw (GTK_WIDGET (map));
-}
-
-G_DEFINE_TYPE_WITH_CODE (
- EMap,
- e_map,
- GTK_TYPE_WIDGET,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
-
-static void
-e_map_get_current_location (EMap *map,
- gdouble *longitude,
- gdouble *latitude)
-{
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- e_map_window_to_world (
- map, allocation.width / 2.0,
- allocation.height / 2.0,
- longitude, latitude);
-}
-
-static void
-e_map_world_to_render_surface (EMap *map,
- gdouble world_longitude,
- gdouble world_latitude,
- gdouble *win_x,
- gdouble *win_y)
-{
- gint width, height;
-
- width = E_MAP_GET_WIDTH (map);
- height = E_MAP_GET_HEIGHT (map);
-
- *win_x = (width / 2.0 + (width / 2.0) * world_longitude / 180.0);
- *win_y = (height / 2.0 - (height / 2.0) * world_latitude / 90.0);
-}
-
-static void
-e_map_tween_new_from (EMap *map,
- guint msecs,
- gdouble longitude,
- gdouble latitude,
- gdouble zoom)
-{
- gdouble current_longitude, current_latitude;
-
- e_map_get_current_location (
- map, &current_longitude, &current_latitude);
-
- e_map_tween_new (
- map, msecs,
- longitude - current_longitude,
- latitude - current_latitude,
- zoom / e_map_get_magnification (map));
-}
-
-static gdouble
-e_map_get_tween_effect (EMap *map,
- EMapTween *tween)
-{
- gdouble elapsed;
-
- elapsed = (gdouble)
- (map->priv->timer_current_ms - tween->start_time) /
- tween->end_time;
-
- return MAX (0.0, 1.0 - elapsed);
-}
-
-static void
-e_map_apply_tween (EMapTween *tween,
- gdouble effect,
- gdouble *longitude,
- gdouble *latitude,
- gdouble *zoom)
-{
- *zoom *= pow (tween->zoom_factor, effect);
- *longitude += tween->longitude_offset * effect;
- *latitude += tween->latitude_offset * effect;
-}
-
-static void
-e_map_tweens_compute_matrix (EMap *map,
- cairo_matrix_t *matrix)
-{
- GSList *walk;
- gdouble zoom, x, y, latitude, longitude, effect;
- GtkAllocation allocation;
-
- if (!e_map_is_tweening (map)) {
- cairo_matrix_init_translate (
- matrix, -map->priv->xofs, -map->priv->yofs);
- return;
- }
-
- e_map_get_current_location (map, &longitude, &latitude);
- zoom = 1.0;
-
- for (walk = map->priv->tweens; walk; walk = walk->next) {
- EMapTween *tween = walk->data;
-
- effect = e_map_get_tween_effect (map, tween);
- e_map_apply_tween (tween, effect, &longitude, &latitude, &zoom);
- }
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
- cairo_matrix_init_translate (
- matrix,
- allocation.width / 2.0,
- allocation.height / 2.0);
-
- e_map_world_to_render_surface (map, longitude, latitude, &x, &y);
- cairo_matrix_scale (matrix, zoom, zoom);
- cairo_matrix_translate (matrix, -x, -y);
-}
-
-/* GtkScrollable implementation */
-
-static void
-e_map_adjustment_changed (GtkAdjustment *adjustment,
- EMap *map)
-{
- EMapPrivate *priv = map->priv;
-
- if (gtk_widget_get_realized (GTK_WIDGET (map))) {
- gint hadj_value;
- gint vadj_value;
-
- hadj_value = gtk_adjustment_get_value (priv->hadjustment);
- vadj_value = gtk_adjustment_get_value (priv->vadjustment);
-
- scroll_to (map, hadj_value, vadj_value);
- }
-}
-
-static void
-e_map_set_hadjustment_values (EMap *map)
-{
- GtkAllocation allocation;
- EMapPrivate *priv = map->priv;
- GtkAdjustment *adj = priv->hadjustment;
- gdouble old_value;
- gdouble new_value;
- gdouble new_upper;
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- old_value = gtk_adjustment_get_value (adj);
- new_upper = MAX (allocation.width, gdk_pixbuf_get_width (priv->map_pixbuf));
-
- g_object_set (
- adj,
- "lower", 0.0,
- "upper", new_upper,
- "page-size", (gdouble) allocation.height,
- "step-increment", allocation.height * 0.1,
- "page-increment", allocation.height * 0.9,
- NULL);
-
- new_value = CLAMP (old_value, 0, new_upper - allocation.width);
- if (new_value != old_value)
- gtk_adjustment_set_value (adj, new_value);
-}
-
-static void
-e_map_set_vadjustment_values (EMap *map)
-{
- GtkAllocation allocation;
- EMapPrivate *priv = map->priv;
- GtkAdjustment *adj = priv->vadjustment;
- gdouble old_value;
- gdouble new_value;
- gdouble new_upper;
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- old_value = gtk_adjustment_get_value (adj);
- new_upper = MAX (allocation.height, gdk_pixbuf_get_height (priv->map_pixbuf));
-
- g_object_set (
- adj,
- "lower", 0.0,
- "upper", new_upper,
- "page-size", (gdouble) allocation.height,
- "step-increment", allocation.height * 0.1,
- "page-increment", allocation.height * 0.9,
- NULL);
-
- new_value = CLAMP (old_value, 0, new_upper - allocation.height);
- if (new_value != old_value)
- gtk_adjustment_set_value (adj, new_value);
-}
-
-static void
-e_map_set_hadjustment (EMap *map,
- GtkAdjustment *adjustment)
-{
- EMapPrivate *priv = map->priv;
-
- if (adjustment && priv->hadjustment == adjustment)
- return;
-
- if (priv->hadjustment != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->hadjustment, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, map);
- g_object_unref (priv->hadjustment);
- }
-
- if (!adjustment)
- adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
-
- g_signal_connect (
- adjustment, "value-changed",
- G_CALLBACK (e_map_adjustment_changed), map);
- priv->hadjustment = g_object_ref_sink (adjustment);
- e_map_set_hadjustment_values (map);
-
- g_object_notify (G_OBJECT (map), "hadjustment");
-}
-
-static void
-e_map_set_vadjustment (EMap *map,
- GtkAdjustment *adjustment)
-{
- EMapPrivate *priv = map->priv;
-
- if (adjustment && priv->vadjustment == adjustment)
- return;
-
- if (priv->vadjustment != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->vadjustment, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, map);
- g_object_unref (priv->vadjustment);
- }
-
- if (!adjustment)
- adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
-
- g_signal_connect (
- adjustment, "value-changed",
- G_CALLBACK (e_map_adjustment_changed), map);
- priv->vadjustment = g_object_ref_sink (adjustment);
- e_map_set_vadjustment_values (map);
-
- g_object_notify (G_OBJECT (map), "vadjustment");
-}
-
-/* ----------------- *
- * Widget management *
- * ----------------- */
-
-static void
-e_map_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EMap *map;
-
- map = E_MAP (object);
-
- switch (property_id) {
- case PROP_HADJUSTMENT:
- e_map_set_hadjustment (map, g_value_get_object (value));
- break;
- case PROP_VADJUSTMENT:
- e_map_set_vadjustment (map, g_value_get_object (value));
- break;
- case PROP_HSCROLL_POLICY:
- map->priv->hscroll_policy = g_value_get_enum (value);
- gtk_widget_queue_resize (GTK_WIDGET (map));
- break;
- case PROP_VSCROLL_POLICY:
- map->priv->vscroll_policy = g_value_get_enum (value);
- gtk_widget_queue_resize (GTK_WIDGET (map));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_map_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EMap *map;
-
- map = E_MAP (object);
-
- switch (property_id) {
- case PROP_HADJUSTMENT:
- g_value_set_object (value, map->priv->hadjustment);
- break;
- case PROP_VADJUSTMENT:
- g_value_set_object (value, map->priv->vadjustment);
- break;
- case PROP_HSCROLL_POLICY:
- g_value_set_enum (value, map->priv->hscroll_policy);
- break;
- case PROP_VSCROLL_POLICY:
- g_value_set_enum (value, map->priv->vscroll_policy);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_map_finalize (GObject *object)
-{
- EMap *map;
-
- map = E_MAP (object);
-
- while (map->priv->tweens)
- e_map_tween_destroy (map, map->priv->tweens->data);
- e_map_stop_tweening (map);
-
- if (map->priv->map_pixbuf) {
- g_object_unref (map->priv->map_pixbuf);
- map->priv->map_pixbuf = NULL;
- }
-
- /* gone in unrealize */
- g_assert (map->priv->map_render_surface == NULL);
-
- G_OBJECT_CLASS (e_map_parent_class)->finalize (object);
-}
-
-static void
-e_map_realize (GtkWidget *widget)
-{
- GtkAllocation allocation;
- GdkWindowAttr attr;
- GdkWindow *window;
- gint attr_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_MAP (widget));
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attr.window_type = GDK_WINDOW_CHILD;
- attr.x = allocation.x;
- attr.y = allocation.y;
- attr.width = allocation.width;
- attr.height = allocation.height;
- attr.wclass = GDK_INPUT_OUTPUT;
- attr.visual = gtk_widget_get_visual (widget);
- attr.event_mask = gtk_widget_get_events (widget) |
- GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK |
- GDK_POINTER_MOTION_MASK;
-
- attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
-
- window = gdk_window_new (
- gtk_widget_get_parent_window (widget), &attr, attr_mask);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
-
- update_render_surface (E_MAP (widget), TRUE);
-}
-
-static void
-e_map_unrealize (GtkWidget *widget)
-{
- EMap *map = E_MAP (widget);
-
- cairo_surface_destroy (map->priv->map_render_surface);
- map->priv->map_render_surface = NULL;
-
- if (GTK_WIDGET_CLASS (e_map_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_map_parent_class)->unrealize) (widget);
-}
-
-static void
-e_map_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- EMap *map;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_MAP (widget));
-
- map = E_MAP (widget);
-
- /* TODO: Put real sizes here. */
-
- *minimum = *natural = gdk_pixbuf_get_width (map->priv->map_pixbuf);
-}
-
-static void
-e_map_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- EMap *view;
- EMapPrivate *priv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_MAP (widget));
-
- view = E_MAP (widget);
- priv = view->priv;
-
- /* TODO: Put real sizes here. */
-
- *minimum = *natural = gdk_pixbuf_get_height (priv->map_pixbuf);
-}
-
-static void
-e_map_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EMap *map;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_MAP (widget));
- g_return_if_fail (allocation != NULL);
-
- map = E_MAP (widget);
-
- /* Resize the window */
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_widget_get_realized (widget)) {
- GdkWindow *window;
-
- window = gtk_widget_get_window (widget);
-
- gdk_window_move_resize (
- window, allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- gtk_widget_queue_draw (widget);
- }
-
- update_render_surface (map, TRUE);
-}
-
-static gboolean
-e_map_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- EMap *map;
- cairo_matrix_t matrix;
-
- if (!gtk_widget_is_drawable (widget))
- return FALSE;
-
- map = E_MAP (widget);
-
- cairo_save (cr);
-
- e_map_tweens_compute_matrix (map, &matrix);
- cairo_transform (cr, &matrix);
-
- cairo_set_source_surface (cr, map->priv->map_render_surface, 0, 0);
- cairo_paint (cr);
-
- cairo_restore (cr);
-
- return FALSE;
-}
-
-static gint
-e_map_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- if (!gtk_widget_has_focus (widget))
- gtk_widget_grab_focus (widget);
-
- return TRUE;
-}
-
-static gint
-e_map_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- if (event->button != 1)
- return FALSE;
-
- gdk_device_ungrab (event->device, event->time);
- return TRUE;
-}
-
-static gint
-e_map_motion (GtkWidget *widget,
- GdkEventMotion *event)
-{
- return FALSE;
-}
-
-static gint
-e_map_key_press (GtkWidget *widget,
- GdkEventKey *event)
-{
- EMap *map;
- gboolean do_scroll;
- gint xofs, yofs;
-
- map = E_MAP (widget);
-
- switch (event->keyval)
- {
- case GDK_KEY_Up:
- do_scroll = TRUE;
- xofs = 0;
- yofs = -SCROLL_STEP_SIZE;
- break;
-
- case GDK_KEY_Down:
- do_scroll = TRUE;
- xofs = 0;
- yofs = SCROLL_STEP_SIZE;
- break;
-
- case GDK_KEY_Left:
- do_scroll = TRUE;
- xofs = -SCROLL_STEP_SIZE;
- yofs = 0;
- break;
-
- case GDK_KEY_Right:
- do_scroll = TRUE;
- xofs = SCROLL_STEP_SIZE;
- yofs = 0;
- break;
-
- default:
- return FALSE;
- }
-
- if (do_scroll) {
- gint page_size;
- gint upper;
- gint x, y;
-
- page_size = gtk_adjustment_get_page_size (map->priv->hadjustment);
- upper = gtk_adjustment_get_upper (map->priv->hadjustment);
- x = CLAMP (map->priv->xofs + xofs, 0, upper - page_size);
-
- page_size = gtk_adjustment_get_page_size (map->priv->vadjustment);
- upper = gtk_adjustment_get_upper (map->priv->vadjustment);
- y = CLAMP (map->priv->yofs + yofs, 0, upper - page_size);
-
- scroll_to (map, x, y);
-
- gtk_adjustment_set_value (map->priv->hadjustment, x);
- gtk_adjustment_set_value (map->priv->vadjustment, y);
- }
-
- return TRUE;
-}
-
-static void
-e_map_class_init (EMapClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EMapPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = e_map_set_property;
- object_class->get_property = e_map_get_property;
- object_class->finalize = e_map_finalize;
-
- /* Scrollable interface properties */
- g_object_class_override_property (
- object_class, PROP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property (
- object_class, PROP_VADJUSTMENT, "vadjustment");
- g_object_class_override_property (
- object_class, PROP_HSCROLL_POLICY, "hscroll-policy");
- g_object_class_override_property (
- object_class, PROP_VSCROLL_POLICY, "vscroll-policy");
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->realize = e_map_realize;
- widget_class->unrealize = e_map_unrealize;
- widget_class->get_preferred_height = e_map_get_preferred_height;
- widget_class->get_preferred_width = e_map_get_preferred_width;
- widget_class->size_allocate = e_map_size_allocate;
- widget_class->draw = e_map_draw;
- widget_class->button_press_event = e_map_button_press;
- widget_class->button_release_event = e_map_button_release;
- widget_class->motion_notify_event = e_map_motion;
- widget_class->key_press_event = e_map_key_press;
-}
-
-static void
-e_map_init (EMap *map)
-{
- GtkWidget *widget;
- gchar *map_file_name;
-
- map_file_name = g_build_filename (
- EVOLUTION_IMAGESDIR, "world_map-960.png", NULL);
-
- widget = GTK_WIDGET (map);
-
- map->priv = E_MAP_GET_PRIVATE (map);
-
- load_map_background (map, map_file_name);
- g_free (map_file_name);
- map->priv->frozen = FALSE;
- map->priv->smooth_zoom = TRUE;
- map->priv->zoom_state = E_MAP_ZOOMED_OUT;
- map->priv->points = g_ptr_array_new ();
-
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_widget_set_has_window (widget, TRUE);
-}
-
-/* ---------------- *
- * Widget interface *
- * ---------------- */
-
-/**
- * e_map_new:
- * @void:
- *
- * Creates a new empty map widget.
- *
- * Return value: A newly-created map widget.
- **/
-
-EMap *
-e_map_new (void)
-{
- GtkWidget *widget;
- AtkObject *a11y;
-
- widget = g_object_new (E_TYPE_MAP, NULL);
- a11y = gtk_widget_get_accessible (widget);
- atk_object_set_name (a11y, _("World Map"));
- atk_object_set_role (a11y, ATK_ROLE_IMAGE);
- atk_object_set_description (
- a11y, _("Mouse-based interactive map widget for selecting "
- "timezone. Keyboard users should instead select the timezone "
- "from the drop-down combination box below."));
- return (E_MAP (widget));
-}
-
-/* --- Coordinate translation --- */
-
-/* These functions translate coordinates between longitude/latitude and
- * the image x/y offsets, using the equidistant cylindrical projection.
- *
- * Longitude E <-180, 180]
- * Latitude E <-90, 90] */
-
-void
-e_map_window_to_world (EMap *map,
- gdouble win_x,
- gdouble win_y,
- gdouble *world_longitude,
- gdouble *world_latitude)
-{
- gint width, height;
-
- g_return_if_fail (map);
-
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
-
- width = E_MAP_GET_WIDTH (map);
- height = E_MAP_GET_HEIGHT (map);
-
- *world_longitude = (win_x + map->priv->xofs - (gdouble) width / 2.0) /
- ((gdouble) width / 2.0) * 180.0;
- *world_latitude = ((gdouble) height / 2.0 - win_y - map->priv->yofs) /
- ((gdouble) height / 2.0) * 90.0;
-}
-
-void
-e_map_world_to_window (EMap *map,
- gdouble world_longitude,
- gdouble world_latitude,
- gdouble *win_x,
- gdouble *win_y)
-{
- g_return_if_fail (E_IS_MAP (map));
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
- g_return_if_fail (world_longitude >= -180.0 && world_longitude <= 180.0);
- g_return_if_fail (world_latitude >= -90.0 && world_latitude <= 90.0);
-
- e_map_world_to_render_surface (
- map, world_longitude, world_latitude, win_x, win_y);
-
- *win_x -= map->priv->xofs;
- *win_y -= map->priv->yofs;
-}
-
-/* --- Zoom --- */
-
-gdouble
-e_map_get_magnification (EMap *map)
-{
- if (map->priv->zoom_state == E_MAP_ZOOMED_IN) return 2.0;
- else return 1.0;
-}
-
-static void
-e_map_set_zoom (EMap *map,
- EMapZoomState zoom)
-{
- if (map->priv->zoom_state == zoom)
- return;
-
- map->priv->zoom_state = zoom;
- update_render_surface (map, TRUE);
- gtk_widget_queue_draw (GTK_WIDGET (map));
-}
-
-void
-e_map_zoom_to_location (EMap *map,
- gdouble longitude,
- gdouble latitude)
-{
- gdouble prevlong, prevlat;
- gdouble prevzoom;
-
- g_return_if_fail (map);
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
-
- e_map_get_current_location (map, &prevlong, &prevlat);
- prevzoom = e_map_get_magnification (map);
-
- e_map_set_zoom (map, E_MAP_ZOOMED_IN);
- center_at (map, longitude, latitude);
-
- e_map_tween_new_from (
- map, E_MAP_TWEEN_DURATION_MSECS,
- prevlong, prevlat, prevzoom);
-}
-
-void
-e_map_zoom_out (EMap *map)
-{
- gdouble longitude, latitude;
- gdouble prevzoom;
-
- g_return_if_fail (map);
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
-
- e_map_get_current_location (map, &longitude, &latitude);
- prevzoom = e_map_get_magnification (map);
- e_map_set_zoom (map, E_MAP_ZOOMED_OUT);
- center_at (map, longitude, latitude);
-
- e_map_tween_new_from (
- map, E_MAP_TWEEN_DURATION_MSECS,
- longitude, latitude, prevzoom);
-}
-
-void
-e_map_set_smooth_zoom (EMap *map,
- gboolean state)
-{
- ((EMapPrivate *) map->priv)->smooth_zoom = state;
-}
-
-gboolean
-e_map_get_smooth_zoom (EMap *map)
-{
- return (((EMapPrivate *) map->priv)->smooth_zoom);
-}
-
-void
-e_map_freeze (EMap *map)
-{
- ((EMapPrivate *) map->priv)->frozen = TRUE;
-}
-
-void
-e_map_thaw (EMap *map)
-{
- ((EMapPrivate *) map->priv)->frozen = FALSE;
- update_and_paint (map);
-}
-
-/* --- Point manipulation --- */
-
-EMapPoint *
-e_map_add_point (EMap *map,
- gchar *name,
- gdouble longitude,
- gdouble latitude,
- guint32 color_rgba)
-{
- EMapPoint *point;
-
- point = g_new0 (EMapPoint, 1);
-
- point->name = name; /* Can be NULL */
- point->longitude = longitude;
- point->latitude = latitude;
- point->rgba = color_rgba;
-
- g_ptr_array_add (map->priv->points, (gpointer) point);
-
- if (!map->priv->frozen)
- {
- update_render_point (map, point);
- repaint_point (map, point);
- }
-
- return point;
-}
-
-void
-e_map_remove_point (EMap *map,
- EMapPoint *point)
-{
- g_ptr_array_remove (map->priv->points, point);
-
- if (!((EMapPrivate *) map->priv)->frozen)
- {
- /* FIXME: Re-scaling the whole pixbuf is more than a little
- * overkill when just one point is removed */
-
- update_render_surface (map, TRUE);
- repaint_point (map, point);
- }
-
- g_free (point);
-}
-
-void
-e_map_point_get_location (EMapPoint *point,
- gdouble *longitude,
- gdouble *latitude)
-{
- *longitude = point->longitude;
- *latitude = point->latitude;
-}
-
-gchar *
-e_map_point_get_name (EMapPoint *point)
-{
- return point->name;
-}
-
-guint32
-e_map_point_get_color_rgba (EMapPoint *point)
-{
- return point->rgba;
-}
-
-void
-e_map_point_set_color_rgba (EMap *map,
- EMapPoint *point,
- guint32 color_rgba)
-{
- point->rgba = color_rgba;
-
- if (!((EMapPrivate *) map->priv)->frozen)
- {
- /* TODO: Redraw area around point only */
-
- update_render_point (map, point);
- repaint_point (map, point);
- }
-}
-
-void
-e_map_point_set_data (EMapPoint *point,
- gpointer data)
-{
- point->user_data = data;
-}
-
-gpointer
-e_map_point_get_data (EMapPoint *point)
-{
- return point->user_data;
-}
-
-gboolean
-e_map_point_is_in_view (EMap *map,
- EMapPoint *point)
-{
- GtkAllocation allocation;
- gdouble x, y;
-
- if (!map->priv->map_render_surface) return FALSE;
-
- e_map_world_to_window (map, point->longitude, point->latitude, &x, &y);
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- if (x >= 0 && x < allocation.width &&
- y >= 0 && y < allocation.height)
- return TRUE;
-
- return FALSE;
-}
-
-EMapPoint *
-e_map_get_closest_point (EMap *map,
- gdouble longitude,
- gdouble latitude,
- gboolean in_view)
-{
- EMapPoint *point_chosen = NULL, *point;
- gdouble min_dist = 0.0, dist;
- gdouble dx, dy;
- gint i;
-
- for (i = 0; i < map->priv->points->len; i++)
- {
- point = g_ptr_array_index (map->priv->points, i);
- if (in_view && !e_map_point_is_in_view (map, point)) continue;
-
- dx = point->longitude - longitude;
- dy = point->latitude - latitude;
- dist = dx * dx + dy * dy;
-
- if (!point_chosen || dist < min_dist)
- {
- min_dist = dist;
- point_chosen = point;
- }
- }
-
- return point_chosen;
-}
-
-/* ------------------ *
- * Internal functions *
- * ------------------ */
-
-static void
-update_and_paint (EMap *map)
-{
- update_render_surface (map, TRUE);
- gtk_widget_queue_draw (GTK_WIDGET (map));
-}
-
-static gint
-load_map_background (EMap *map,
- gchar *name)
-{
- GdkPixbuf *pb0;
-
- pb0 = gdk_pixbuf_new_from_file (name, NULL);
- if (!pb0)
- return FALSE;
-
- if (map->priv->map_pixbuf) g_object_unref (map->priv->map_pixbuf);
- map->priv->map_pixbuf = pb0;
- update_render_surface (map, TRUE);
-
- return TRUE;
-}
-
-static void
-update_render_surface (EMap *map,
- gboolean render_overlays)
-{
- EMapPoint *point;
- GtkAllocation allocation;
- gint width, height, orig_width, orig_height;
- gdouble zoom;
- gint i;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (map)))
- return;
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- /* Set up value shortcuts */
-
- width = allocation.width;
- height = allocation.height;
- orig_width = gdk_pixbuf_get_width (map->priv->map_pixbuf);
- orig_height = gdk_pixbuf_get_height (map->priv->map_pixbuf);
-
- /* Compute scaled width and height based on the extreme dimension */
-
- if ((gdouble) width / orig_width > (gdouble) height / orig_height)
- zoom = (gdouble) width / (gdouble) orig_width;
- else
- zoom = (gdouble) height / (gdouble) orig_height;
-
- if (map->priv->zoom_state == E_MAP_ZOOMED_IN)
- zoom *= 2.0;
- height = (orig_height * zoom) + 0.5;
- width = (orig_width * zoom) + 0.5;
-
- /* Reallocate the pixbuf */
-
- if (map->priv->map_render_surface)
- cairo_surface_destroy (map->priv->map_render_surface);
- map->priv->map_render_surface = gdk_window_create_similar_surface (
- gtk_widget_get_window (GTK_WIDGET (map)),
- CAIRO_CONTENT_COLOR, width, height);
-
- /* Scale the original map into the rendering pixbuf */
-
- if (width > 1 && height > 1) {
- cairo_t *cr = cairo_create (map->priv->map_render_surface);
- cairo_scale (
- cr,
- (gdouble) width / orig_width,
- (gdouble) height / orig_height);
- gdk_cairo_set_source_pixbuf (cr, map->priv->map_pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
- }
-
- /* Compute image offsets with respect to window */
-
- set_scroll_area (map, width, height);
-
- if (render_overlays) {
- /* Add points */
-
- for (i = 0; i < map->priv->points->len; i++) {
- point = g_ptr_array_index (map->priv->points, i);
- update_render_point (map, point);
- }
- }
-}
-
-/* Redraw point in client surface */
-
-static void
-update_render_point (EMap *map,
- EMapPoint *point)
-{
- cairo_t *cr;
- gdouble px, py;
- static guchar mask1[] = { 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static guchar mask2[] = { 0x00, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00 };
- cairo_surface_t *mask;
-
- if (map->priv->map_render_surface == NULL)
- return;
-
- cr = cairo_create (map->priv->map_render_surface);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-
- e_map_world_to_window (map, point->longitude, point->latitude, &px, &py);
- px = floor (px + map->priv->xofs);
- py = floor (py + map->priv->yofs);
-
- cairo_set_source_rgb (cr, 0, 0, 0);
- mask = cairo_image_surface_create_for_data (mask1, CAIRO_FORMAT_A8, 5, 5, 8);
- cairo_mask_surface (cr, mask, px - 2, py - 2);
- cairo_surface_destroy (mask);
-
- cairo_set_source_rgba (
- cr,
- ((point->rgba >> 24) & 0xff) / 255.0,
- ((point->rgba >> 16) & 0xff) / 255.0,
- ((point->rgba >> 8) & 0xff) / 255.0,
- ( point->rgba & 0xff) / 255.0);
- mask = cairo_image_surface_create_for_data (mask2, CAIRO_FORMAT_A8, 3, 3, 4);
- cairo_mask_surface (cr, mask, px - 1, py - 1);
- cairo_surface_destroy (mask);
-
- cairo_destroy (cr);
-}
-
-/* Repaint point on X server */
-
-static void
-repaint_point (EMap *map,
- EMapPoint *point)
-{
- gdouble px, py;
-
- if (!gtk_widget_is_drawable (GTK_WIDGET (map)))
- return;
-
- e_map_world_to_window (map, point->longitude, point->latitude, &px, &py);
-
- gtk_widget_queue_draw_area (
- GTK_WIDGET (map),
- (gint) px - 2, (gint) py - 2,
- 5, 5);
-}
-
-static void
-center_at (EMap *map,
- gdouble longitude,
- gdouble latitude)
-{
- GtkAllocation allocation;
- gint pb_width, pb_height;
- gdouble x, y;
-
- e_map_world_to_render_surface (map, longitude, latitude, &x, &y);
-
- pb_width = E_MAP_GET_WIDTH (map);
- pb_height = E_MAP_GET_HEIGHT (map);
-
- gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
-
- x = CLAMP (x - (allocation.width / 2), 0, pb_width - allocation.width);
- y = CLAMP (y - (allocation.height / 2), 0, pb_height - allocation.height);
-
- gtk_adjustment_set_value (map->priv->hadjustment, x);
- gtk_adjustment_set_value (map->priv->vadjustment, y);
-
- gtk_widget_queue_draw (GTK_WIDGET (map));
-}
-
-/* Scrolls the view to the specified offsets. Does not perform range checking! */
-
-static void
-scroll_to (EMap *map,
- gint x,
- gint y)
-{
- gint xofs, yofs;
-
- /* Compute offsets and check bounds */
-
- xofs = x - map->priv->xofs;
- yofs = y - map->priv->yofs;
-
- if (xofs == 0 && yofs == 0)
- return;
-
- map->priv->xofs = x;
- map->priv->yofs = y;
-
- gtk_widget_queue_draw (GTK_WIDGET (map));
-}
-
-static void
-set_scroll_area (EMap *view,
- gint width,
- gint height)
-{
- EMapPrivate *priv;
- GtkAllocation allocation;
-
- priv = view->priv;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (view)))
- return;
-
- if (!priv->hadjustment || !priv->vadjustment)
- return;
-
- g_object_freeze_notify (G_OBJECT (priv->hadjustment));
- g_object_freeze_notify (G_OBJECT (priv->vadjustment));
-
- gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
-
- priv->xofs = CLAMP (priv->xofs, 0, width - allocation.width);
- priv->yofs = CLAMP (priv->yofs, 0, height - allocation.height);
-
- gtk_adjustment_configure (
- priv->hadjustment,
- priv->xofs,
- 0, width,
- SCROLL_STEP_SIZE,
- allocation.width / 2,
- allocation.width);
- gtk_adjustment_configure (
- priv->vadjustment,
- priv->yofs,
- 0, height,
- SCROLL_STEP_SIZE,
- allocation.height / 2,
- allocation.height);
-
- g_object_thaw_notify (G_OBJECT (priv->hadjustment));
- g_object_thaw_notify (G_OBJECT (priv->vadjustment));
-}
diff --git a/widgets/misc/e-map.h b/widgets/misc/e-map.h
deleted file mode 100644
index 059da7c2a5..0000000000
--- a/widgets/misc/e-map.h
+++ /dev/null
@@ -1,151 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Hans Petter Jansson <hpj@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_MAP_H
-#define E_MAP_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MAP \
- (e_map_get_type ())
-#define E_MAP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MAP, EMap))
-#define E_MAP_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MAP, EMapClass))
-#define E_IS_MAP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MAP))
-#define E_IS_MAP_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MAP))
-#define E_MAP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MAP, EMapClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMap EMap;
-typedef struct _EMapClass EMapClass;
-typedef struct _EMapPrivate EMapPrivate;
-typedef struct _EMapPoint EMapPoint;
-
-struct _EMap {
- GtkWidget widget;
- EMapPrivate *priv;
-};
-
-struct _EMapClass {
- GtkWidgetClass parent_class;
-
- /* Notification signals */
- void (*zoom_fit) (EMap * view);
-
- /* GTK+ scrolling interface */
- void (*set_scroll_adjustments) (GtkWidget * widget,
- GtkAdjustment * hadj,
- GtkAdjustment * vadj);
-};
-
-/* The definition of Dot */
-
-struct _EMapPoint {
- gchar *name; /* Can be NULL */
- gdouble longitude, latitude;
- guint32 rgba;
- gpointer user_data;
-};
-
-/* --- Widget --- */
-
-GType e_map_get_type (void);
-
-EMap *e_map_new (void);
-
-/* Stop doing redraws when map data changes (e.g. by modifying points) */
-void e_map_freeze (EMap *map);
-
-/* Do an immediate repaint, and start doing realtime repaints again */
-void e_map_thaw (EMap *map);
-
-/* --- Coordinate translation --- */
-
-/* Translates window-relative coords to lat/long */
-void e_map_window_to_world (EMap *map,
- gdouble win_x, gdouble win_y,
- gdouble *world_longitude, gdouble *world_latitude);
-
-/* Translates lat/long to window-relative coordinates. Note that the
- * returned coordinates can be negative or greater than the current size
- * of the allocation area */
-void e_map_world_to_window (EMap *map,
- gdouble world_longitude, gdouble world_latitude,
- gdouble *win_x, gdouble *win_y);
-
-/* --- Zoom --- */
-
-gdouble e_map_get_magnification (EMap *map);
-
-/* Pass TRUE if we want the smooth zoom hack */
-void e_map_set_smooth_zoom (EMap *map, gboolean state);
-
-/* TRUE if smooth zoom hack will be employed */
-gboolean e_map_get_smooth_zoom (EMap *map);
-
-/* NB: Function definition will change shortly */
-void e_map_zoom_to_location (EMap *map, gdouble longitude, gdouble latitude);
-
-/* Zoom to mag factor 1.0 */
-void e_map_zoom_out (EMap *map);
-
-/* --- Points --- */
-
-EMapPoint *e_map_add_point (EMap *map, gchar *name,
- gdouble longitude, gdouble latitude,
- guint32 color_rgba);
-
-void e_map_remove_point (EMap *map, EMapPoint *point);
-
-void e_map_point_get_location (EMapPoint *point,
- gdouble *longitude, gdouble *latitude);
-
-gchar *e_map_point_get_name (EMapPoint *point);
-
-guint32 e_map_point_get_color_rgba (EMapPoint *point);
-
-void e_map_point_set_color_rgba (EMap *map, EMapPoint *point, guint32 color_rgba);
-
-void e_map_point_set_data (EMapPoint *point, gpointer data);
-
-gpointer e_map_point_get_data (EMapPoint *point);
-
-gboolean e_map_point_is_in_view (EMap *map, EMapPoint *point);
-
-EMapPoint *e_map_get_closest_point (EMap *map, gdouble longitude, gdouble latitude,
- gboolean in_view);
-
-G_END_DECLS
-
-#endif
diff --git a/widgets/misc/e-menu-tool-action.c b/widgets/misc/e-menu-tool-action.c
deleted file mode 100644
index 3ed37cb008..0000000000
--- a/widgets/misc/e-menu-tool-action.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * e-menu-tool-action.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-menu-tool-action.h"
-
-G_DEFINE_TYPE (
- EMenuToolAction,
- e_menu_tool_action,
- GTK_TYPE_ACTION)
-
-static void
-e_menu_tool_action_class_init (EMenuToolActionClass *class)
-{
- GtkActionClass *action_class;
-
- action_class = GTK_ACTION_CLASS (class);
- action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
-}
-
-static void
-e_menu_tool_action_init (EMenuToolAction *action)
-{
-}
-
-EMenuToolAction *
-e_menu_tool_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (
- E_TYPE_MENU_TOOL_ACTION,
- "name", name, "label", label, "tooltip",
- tooltip, "stock-id", stock_id, NULL);
-}
diff --git a/widgets/misc/e-menu-tool-action.h b/widgets/misc/e-menu-tool-action.h
deleted file mode 100644
index e642edf958..0000000000
--- a/widgets/misc/e-menu-tool-action.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * e-menu-tool-action.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* This is a trivial GtkAction subclass that sets the toolbar
- * item type to GtkMenuToolButton instead of GtkToolButton. */
-
-#ifndef E_MENU_TOOL_ACTION_H
-#define E_MENU_TOOL_ACTION_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MENU_TOOL_ACTION \
- (e_menu_tool_action_get_type ())
-#define E_MENU_TOOL_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolAction))
-#define E_MENU_TOOL_ACTION_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass))
-#define E_IS_MENU_TOOL_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MENU_TOOL_ACTION))
-#define E_IS_MENU_TOOL_ACTION_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MENU_TOOL_ACTION))
-#define E_MENU_TOOL_ACTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMenuToolAction EMenuToolAction;
-typedef struct _EMenuToolActionClass EMenuToolActionClass;
-
-struct _EMenuToolAction {
- GtkAction parent;
-};
-
-struct _EMenuToolActionClass {
- GtkActionClass parent_class;
-};
-
-GType e_menu_tool_action_get_type (void);
-EMenuToolAction *
- e_menu_tool_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id);
-
-G_END_DECLS
-
-#endif /* E_MENU_TOOL_ACTION_H */
diff --git a/widgets/misc/e-menu-tool-button.c b/widgets/misc/e-menu-tool-button.c
deleted file mode 100644
index c2a68d0c05..0000000000
--- a/widgets/misc/e-menu-tool-button.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * e-menu-tool-button.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-menu-tool-button.h"
-
-#define E_MENU_TOOL_BUTTON_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonPrivate))
-
-struct _EMenuToolButtonPrivate {
- gchar *prefer_item;
-};
-
-enum {
- PROP_0,
- PROP_PREFER_ITEM
-};
-
-G_DEFINE_TYPE (
- EMenuToolButton,
- e_menu_tool_button,
- GTK_TYPE_MENU_TOOL_BUTTON)
-
-static GtkWidget *
-menu_tool_button_clone_image (GtkWidget *source)
-{
- GtkIconSize size;
- GtkImageType image_type;
- const gchar *icon_name;
-
- /* XXX This isn't general purpose because it requires that the
- * source image be using a named icon. Somewhat surprised
- * GTK+ doesn't offer something like this. */
- image_type = gtk_image_get_storage_type (GTK_IMAGE (source));
- g_return_val_if_fail (image_type == GTK_IMAGE_ICON_NAME, NULL);
- gtk_image_get_icon_name (GTK_IMAGE (source), &icon_name, &size);
-
- return gtk_image_new_from_icon_name (icon_name, size);
-}
-
-static GtkMenuItem *
-menu_tool_button_get_prefer_menu_item (GtkMenuToolButton *menu_tool_button)
-{
- GtkWidget *menu;
- GtkMenuItem *item = NULL;
- GList *children;
- const gchar *prefer_item;
-
- menu = gtk_menu_tool_button_get_menu (menu_tool_button);
- if (!GTK_IS_MENU (menu))
- return NULL;
-
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- if (children == NULL)
- return NULL;
-
- prefer_item = e_menu_tool_button_get_prefer_item (
- E_MENU_TOOL_BUTTON (menu_tool_button));
- if (prefer_item != NULL && *prefer_item != '\0') {
- GtkAction *action;
- GList *iter;
-
- for (iter = children; iter != NULL; iter = iter->next) {
- item = GTK_MENU_ITEM (iter->data);
-
- if (!item)
- continue;
-
- action = gtk_activatable_get_related_action (
- GTK_ACTIVATABLE (item));
- if (action && g_strcmp0 (gtk_action_get_name (action), prefer_item) == 0)
- break;
- else if (!action && g_strcmp0 (gtk_widget_get_name (GTK_WIDGET (item)), prefer_item) == 0)
- break;
-
- item = NULL;
- }
- }
-
- if (!item)
- item = GTK_MENU_ITEM (children->data);
-
- g_list_free (children);
-
- return item;
-}
-
-static void
-menu_tool_button_update_button (GtkToolButton *tool_button)
-{
- GtkMenuItem *menu_item;
- GtkMenuToolButton *menu_tool_button;
- GtkImageMenuItem *image_menu_item;
- GtkAction *action;
- GtkWidget *image;
- gchar *tooltip = NULL;
-
- menu_tool_button = GTK_MENU_TOOL_BUTTON (tool_button);
- menu_item = menu_tool_button_get_prefer_menu_item (menu_tool_button);
- if (!GTK_IS_IMAGE_MENU_ITEM (menu_item))
- return;
-
- image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
- image = gtk_image_menu_item_get_image (image_menu_item);
- if (!GTK_IS_IMAGE (image))
- return;
-
- image = menu_tool_button_clone_image (image);
- gtk_tool_button_set_icon_widget (tool_button, image);
- gtk_widget_show (image);
-
- /* If the menu item is a proxy for a GtkAction, extract
- * the action's tooltip and use it as our own tooltip. */
- action = gtk_activatable_get_related_action (
- GTK_ACTIVATABLE (menu_item));
- if (action != NULL)
- g_object_get (action, "tooltip", &tooltip, NULL);
- gtk_widget_set_tooltip_text (GTK_WIDGET (tool_button), tooltip);
- g_free (tooltip);
-}
-
-static void
-menu_tool_button_clicked (GtkToolButton *tool_button)
-{
- GtkMenuItem *menu_item;
- GtkMenuToolButton *menu_tool_button;
-
- menu_tool_button = GTK_MENU_TOOL_BUTTON (tool_button);
- menu_item = menu_tool_button_get_prefer_menu_item (menu_tool_button);
-
- if (GTK_IS_MENU_ITEM (menu_item))
- gtk_menu_item_activate (menu_item);
-}
-
-static void
-menu_tool_button_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PREFER_ITEM:
- e_menu_tool_button_set_prefer_item (
- E_MENU_TOOL_BUTTON (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-menu_tool_button_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PREFER_ITEM:
- g_value_set_string (
- value, e_menu_tool_button_get_prefer_item (
- E_MENU_TOOL_BUTTON (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-menu_tool_button_dispose (GObject *object)
-{
- EMenuToolButtonPrivate *priv = E_MENU_TOOL_BUTTON (object)->priv;
-
- if (priv->prefer_item) {
- g_free (priv->prefer_item);
- priv->prefer_item = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_menu_tool_button_parent_class)->dispose (object);
-}
-
-static void
-e_menu_tool_button_class_init (EMenuToolButtonClass *class)
-{
- GObjectClass *object_class;
- GtkToolButtonClass *tool_button_class;
-
- g_type_class_add_private (class, sizeof (EMenuToolButtonPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = menu_tool_button_set_property;
- object_class->get_property = menu_tool_button_get_property;
- object_class->dispose = menu_tool_button_dispose;
-
- tool_button_class = GTK_TOOL_BUTTON_CLASS (class);
- tool_button_class->clicked = menu_tool_button_clicked;
-
- g_object_class_install_property (
- object_class,
- PROP_PREFER_ITEM,
- g_param_spec_string (
- "prefer-item",
- "Prefer Item",
- "Name of an item to show instead of the first",
- NULL,
- G_PARAM_READWRITE));
-}
-
-static void
-e_menu_tool_button_init (EMenuToolButton *button)
-{
- button->priv = E_MENU_TOOL_BUTTON_GET_PRIVATE (button);
-
- button->priv->prefer_item = NULL;
-
- g_signal_connect (
- button, "notify::menu",
- G_CALLBACK (menu_tool_button_update_button), NULL);
-}
-
-GtkToolItem *
-e_menu_tool_button_new (const gchar *label)
-{
- return g_object_new (E_TYPE_MENU_TOOL_BUTTON, "label", label, NULL);
-}
-
-void
-e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
- const gchar *prefer_item)
-{
- g_return_if_fail (button != NULL);
- g_return_if_fail (E_IS_MENU_TOOL_BUTTON (button));
-
- if (g_strcmp0 (button->priv->prefer_item, prefer_item) == 0)
- return;
-
- g_free (button->priv->prefer_item);
- button->priv->prefer_item = g_strdup (prefer_item);
-
- g_object_notify (G_OBJECT (button), "prefer-item");
-}
-
-const gchar *
-e_menu_tool_button_get_prefer_item (EMenuToolButton *button)
-{
- g_return_val_if_fail (button != NULL, NULL);
- g_return_val_if_fail (E_IS_MENU_TOOL_BUTTON (button), NULL);
-
- return button->priv->prefer_item;
-}
diff --git a/widgets/misc/e-menu-tool-button.h b/widgets/misc/e-menu-tool-button.h
deleted file mode 100644
index 803ec8ff58..0000000000
--- a/widgets/misc/e-menu-tool-button.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * e-menu-tool-button.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* EMenuToolButton is a variation of GtkMenuToolButton where the
- * button icon always reflects the first menu item, and clicking
- * the button activates the first menu item. */
-
-#ifndef E_MENU_TOOL_BUTTON_H
-#define E_MENU_TOOL_BUTTON_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MENU_TOOL_BUTTON \
- (e_menu_tool_button_get_type ())
-#define E_MENU_TOOL_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButton))
-#define E_MENU_TOOL_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonClass))
-#define E_IS_MENU_TOOL_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MENU_TOOL_BUTTON))
-#define E_IS_MENU_TOOL_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MENU_TOOL_BUTTON))
-#define E_MENU_TOOL_BUTTON_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMenuToolButton EMenuToolButton;
-typedef struct _EMenuToolButtonPrivate EMenuToolButtonPrivate;
-typedef struct _EMenuToolButtonClass EMenuToolButtonClass;
-
-struct _EMenuToolButton {
- GtkMenuToolButton parent;
- EMenuToolButtonPrivate *priv;
-};
-
-struct _EMenuToolButtonClass {
- GtkMenuToolButtonClass parent_class;
-};
-
-GType e_menu_tool_button_get_type (void);
-GtkToolItem * e_menu_tool_button_new (const gchar *label);
-void e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
- const gchar *prefer_item);
-const gchar * e_menu_tool_button_get_prefer_item (EMenuToolButton *button);
-
-G_END_DECLS
-
-#endif /* E_MENU_TOOL_BUTTON_H */
diff --git a/widgets/misc/e-online-button.c b/widgets/misc/e-online-button.c
deleted file mode 100644
index a3921a779f..0000000000
--- a/widgets/misc/e-online-button.c
+++ /dev/null
@@ -1,210 +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 <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-online-button.h"
-
-#include <glib/gi18n.h>
-
-#define E_ONLINE_BUTTON_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ONLINE_BUTTON, EOnlineButtonPrivate))
-
-#define ONLINE_TOOLTIP \
- _("Evolution is currently online. Click this button to work offline.")
-
-#define OFFLINE_TOOLTIP \
- _("Evolution is currently offline. Click this button to work online.")
-
-#define NETWORK_UNAVAILABLE_TOOLTIP \
- _("Evolution is currently offline because the network is unavailable.")
-
-struct _EOnlineButtonPrivate {
- GtkWidget *image;
- gboolean online;
-};
-
-enum {
- PROP_0,
- PROP_ONLINE
-};
-
-G_DEFINE_TYPE (
- EOnlineButton,
- e_online_button,
- GTK_TYPE_BUTTON)
-
-static void
-online_button_update_tooltip (EOnlineButton *button)
-{
- const gchar *tooltip;
-
- if (e_online_button_get_online (button))
- tooltip = ONLINE_TOOLTIP;
- else if (gtk_widget_get_sensitive (GTK_WIDGET (button)))
- tooltip = OFFLINE_TOOLTIP;
- else
- tooltip = NETWORK_UNAVAILABLE_TOOLTIP;
-
- gtk_widget_set_tooltip_text (GTK_WIDGET (button), tooltip);
-}
-
-static void
-online_button_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ONLINE:
- e_online_button_set_online (
- E_ONLINE_BUTTON (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-online_button_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ONLINE:
- g_value_set_boolean (
- value, e_online_button_get_online (
- E_ONLINE_BUTTON (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-online_button_dispose (GObject *object)
-{
- EOnlineButtonPrivate *priv;
-
- priv = E_ONLINE_BUTTON_GET_PRIVATE (object);
-
- if (priv->image != NULL) {
- g_object_unref (priv->image);
- priv->image = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_online_button_parent_class)->dispose (object);
-}
-
-static void
-e_online_button_class_init (EOnlineButtonClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EOnlineButtonPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = online_button_set_property;
- object_class->get_property = online_button_get_property;
- object_class->dispose = online_button_dispose;
-
- g_object_class_install_property (
- object_class,
- PROP_ONLINE,
- g_param_spec_boolean (
- "online",
- "Online",
- "The button state is online",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-}
-
-static void
-e_online_button_init (EOnlineButton *button)
-{
- GtkWidget *widget;
-
- button->priv = E_ONLINE_BUTTON_GET_PRIVATE (button);
-
- gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-
- widget = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (button), widget);
- button->priv->image = g_object_ref (widget);
- gtk_widget_show (widget);
-
- g_signal_connect (
- button, "notify::online",
- G_CALLBACK (online_button_update_tooltip), NULL);
-
- g_signal_connect (
- button, "notify::sensitive",
- G_CALLBACK (online_button_update_tooltip), NULL);
-}
-
-GtkWidget *
-e_online_button_new (void)
-{
- return g_object_new (E_TYPE_ONLINE_BUTTON, NULL);
-}
-
-gboolean
-e_online_button_get_online (EOnlineButton *button)
-{
- g_return_val_if_fail (E_IS_ONLINE_BUTTON (button), FALSE);
-
- return button->priv->online;
-}
-
-void
-e_online_button_set_online (EOnlineButton *button,
- gboolean online)
-{
- GtkImage *image;
- GtkIconInfo *icon_info;
- GtkIconTheme *icon_theme;
- const gchar *filename;
- const gchar *icon_name;
-
- g_return_if_fail (E_IS_ONLINE_BUTTON (button));
-
- if (button->priv->online == online)
- return;
-
- button->priv->online = online;
-
- image = GTK_IMAGE (button->priv->image);
- icon_name = online ? "online" : "offline";
- icon_theme = gtk_icon_theme_get_default ();
-
- /* Prevent GTK+ from scaling these rectangular icons. */
- icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, icon_name, GTK_ICON_SIZE_BUTTON, 0);
- filename = gtk_icon_info_get_filename (icon_info);
- gtk_image_set_from_file (image, filename);
- gtk_icon_info_free (icon_info);
-
- g_object_notify (G_OBJECT (button), "online");
-}
diff --git a/widgets/misc/e-online-button.h b/widgets/misc/e-online-button.h
deleted file mode 100644
index 03f676d75c..0000000000
--- a/widgets/misc/e-online-button.h
+++ /dev/null
@@ -1,65 +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 <http://www.gnu.org/licenses/>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#ifndef E_ONLINE_BUTTON_H
-#define E_ONLINE_BUTTON_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ONLINE_BUTTON \
- (e_online_button_get_type ())
-#define E_ONLINE_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ONLINE_BUTTON, EOnlineButton))
-#define E_ONLINE_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ONLINE_BUTTON, EOnlineButtonClass))
-#define E_IS_ONLINE_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ONLINE_BUTTON))
-#define E_IS_ONLINE_BUTTON_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ONLINE_BUTTON))
-#define E_ONLINE_BUTTON_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ONLINE_BUTTON, EOnlineButtonClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EOnlineButton EOnlineButton;
-typedef struct _EOnlineButtonClass EOnlineButtonClass;
-typedef struct _EOnlineButtonPrivate EOnlineButtonPrivate;
-
-struct _EOnlineButton {
- GtkButton parent;
- EOnlineButtonPrivate *priv;
-};
-
-struct _EOnlineButtonClass {
- GtkButtonClass parent_class;
-};
-
-GType e_online_button_get_type (void);
-GtkWidget * e_online_button_new (void);
-gboolean e_online_button_get_online (EOnlineButton *button);
-void e_online_button_set_online (EOnlineButton *button,
- gboolean online);
-
-G_END_DECLS
-
-#endif /* E_ONLINE_BUTTON_H */
diff --git a/widgets/misc/e-paned.c b/widgets/misc/e-paned.c
deleted file mode 100644
index 3b8f16bbec..0000000000
--- a/widgets/misc/e-paned.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * e-paned.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-paned.h"
-
-#include <glib/gi18n-lib.h>
-
-#define E_PANED_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_PANED, EPanedPrivate))
-
-#define SYNC_REQUEST_NONE 0
-#define SYNC_REQUEST_POSITION 1
-#define SYNC_REQUEST_PROPORTION 2
-
-struct _EPanedPrivate {
- gint hposition;
- gint vposition;
- gdouble proportion;
-
- gulong wse_handler_id;
-
- guint fixed_resize : 1;
- guint sync_request : 2;
- guint toplevel_ready : 1;
-};
-
-enum {
- PROP_0,
- PROP_HPOSITION,
- PROP_VPOSITION,
- PROP_PROPORTION,
- PROP_FIXED_RESIZE
-};
-
-G_DEFINE_TYPE (
- EPaned,
- e_paned,
- GTK_TYPE_PANED)
-
-static gboolean
-paned_queue_resize_on_idle (GtkWidget *paned)
-{
- gtk_widget_queue_resize_no_redraw (paned);
-
- return FALSE;
-}
-
-static gboolean
-paned_window_state_event_cb (EPaned *paned,
- GdkEventWindowState *event,
- GtkWidget *toplevel)
-{
- /* Wait for WITHDRAWN to change from 1 to 0. */
- if (!(event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN))
- return FALSE;
-
- /* The whole point of this hack is to trap a point where if
- * the window were to be maximized initially, the maximized
- * allocation would already be negotiated. We're there now.
- * Set a flag so we know it's safe to set GtkPaned position. */
- paned->priv->toplevel_ready = TRUE;
-
- if (paned->priv->sync_request != SYNC_REQUEST_NONE)
- gtk_widget_queue_resize (GTK_WIDGET (paned));
-
- /* We don't need to listen for window state events anymore. */
- g_signal_handler_disconnect (toplevel, paned->priv->wse_handler_id);
- paned->priv->wse_handler_id = 0;
-
- return FALSE;
-}
-
-static void
-paned_notify_orientation_cb (EPaned *paned)
-{
- /* Ignore the next "notify::position" emission. */
- if (e_paned_get_fixed_resize (paned))
- paned->priv->sync_request = SYNC_REQUEST_POSITION;
- else
- paned->priv->sync_request = SYNC_REQUEST_PROPORTION;
- gtk_widget_queue_resize (GTK_WIDGET (paned));
-}
-
-static void
-paned_notify_position_cb (EPaned *paned)
-{
- GtkAllocation allocation;
- GtkOrientable *orientable;
- GtkOrientation orientation;
- gdouble proportion;
- gint position;
-
- /* If a sync has already been requested, do nothing. */
- if (paned->priv->sync_request != SYNC_REQUEST_NONE)
- return;
-
- orientable = GTK_ORIENTABLE (paned);
- orientation = gtk_orientable_get_orientation (orientable);
-
- gtk_widget_get_allocation (GTK_WIDGET (paned), &allocation);
- position = gtk_paned_get_position (GTK_PANED (paned));
-
- g_object_freeze_notify (G_OBJECT (paned));
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- position = MAX (0, allocation.width - position);
- proportion = (gdouble) position / allocation.width;
-
- paned->priv->hposition = position;
- g_object_notify (G_OBJECT (paned), "hposition");
- } else {
- position = MAX (0, allocation.height - position);
- proportion = (gdouble) position / allocation.height;
-
- paned->priv->vposition = position;
- g_object_notify (G_OBJECT (paned), "vposition");
- }
-
- paned->priv->proportion = proportion;
- g_object_notify (G_OBJECT (paned), "proportion");
-
- if (e_paned_get_fixed_resize (paned))
- paned->priv->sync_request = SYNC_REQUEST_POSITION;
- else
- paned->priv->sync_request = SYNC_REQUEST_PROPORTION;
-
- g_object_thaw_notify (G_OBJECT (paned));
-}
-
-static void
-paned_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_HPOSITION:
- e_paned_set_hposition (
- E_PANED (object),
- g_value_get_int (value));
- return;
-
- case PROP_VPOSITION:
- e_paned_set_vposition (
- E_PANED (object),
- g_value_get_int (value));
- return;
-
- case PROP_PROPORTION:
- e_paned_set_proportion (
- E_PANED (object),
- g_value_get_double (value));
- return;
-
- case PROP_FIXED_RESIZE:
- e_paned_set_fixed_resize (
- E_PANED (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-paned_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_HPOSITION:
- g_value_set_int (
- value, e_paned_get_hposition (
- E_PANED (object)));
- return;
-
- case PROP_VPOSITION:
- g_value_set_int (
- value, e_paned_get_vposition (
- E_PANED (object)));
- return;
-
- case PROP_PROPORTION:
- g_value_set_double (
- value, e_paned_get_proportion (
- E_PANED (object)));
- return;
-
- case PROP_FIXED_RESIZE:
- g_value_set_boolean (
- value, e_paned_get_fixed_resize (
- E_PANED (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-paned_realize (GtkWidget *widget)
-{
- EPanedPrivate *priv;
- GtkWidget *toplevel;
- GdkWindowState state;
- GdkWindow *window;
-
- priv = E_PANED_GET_PRIVATE (widget);
-
- /* Chain up to parent's realize() method. */
- GTK_WIDGET_CLASS (e_paned_parent_class)->realize (widget);
-
- /* XXX This would be easier if we could be notified of
- * window state events directly, but I can't seem
- * to make that happen. */
-
- toplevel = gtk_widget_get_toplevel (widget);
- window = gtk_widget_get_window (toplevel);
- state = gdk_window_get_state (window);
-
- /* If the window is withdrawn, wait for it to be shown before
- * setting the pane position. If the window is already shown,
- * it's safe to set the pane position immediately. */
- if (state & GDK_WINDOW_STATE_WITHDRAWN)
- priv->wse_handler_id = g_signal_connect_swapped (
- toplevel, "window-state-event",
- G_CALLBACK (paned_window_state_event_cb), widget);
- else
- priv->toplevel_ready = TRUE;
-}
-
-static void
-paned_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EPaned *paned = E_PANED (widget);
- GtkOrientable *orientable;
- GtkOrientation orientation;
- gdouble proportion;
- gint allocated;
- gint position;
-
- /* Chain up to parent's size_allocate() method. */
- GTK_WIDGET_CLASS (e_paned_parent_class)->
- size_allocate (widget, allocation);
-
- if (!paned->priv->toplevel_ready)
- return;
-
- if (paned->priv->sync_request == SYNC_REQUEST_NONE)
- return;
-
- orientable = GTK_ORIENTABLE (paned);
- orientation = gtk_orientable_get_orientation (orientable);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- allocated = allocation->width;
- position = e_paned_get_hposition (paned);
- } else {
- allocated = allocation->height;
- position = e_paned_get_vposition (paned);
- }
-
- proportion = e_paned_get_proportion (paned);
-
- if (paned->priv->sync_request == SYNC_REQUEST_POSITION)
- position = MAX (0, allocated - position);
- else
- position = (1.0 - proportion) * allocated;
-
- gtk_paned_set_position (GTK_PANED (paned), position);
-
- paned->priv->sync_request = SYNC_REQUEST_NONE;
-
- /* gtk_paned_set_position() calls queue_resize, which cannot
- * be called from size_allocate, so schedule it from an idle
- * callback so the change takes effect. */
- g_idle_add_full (
- G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc) paned_queue_resize_on_idle,
- g_object_ref (paned),
- (GDestroyNotify) g_object_unref);
-}
-
-static void
-e_paned_class_init (EPanedClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EPanedPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = paned_set_property;
- object_class->get_property = paned_get_property;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->realize = paned_realize;
- widget_class->size_allocate = paned_size_allocate;
-
- g_object_class_install_property (
- object_class,
- PROP_HPOSITION,
- g_param_spec_int (
- "hposition",
- "Horizontal Position",
- "Pane position when oriented horizontally",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_VPOSITION,
- g_param_spec_int (
- "vposition",
- "Vertical Position",
- "Pane position when oriented vertically",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_PROPORTION,
- g_param_spec_double (
- "proportion",
- "Proportion",
- "Proportion of the 2nd pane size",
- 0.0,
- 1.0,
- 0.0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_FIXED_RESIZE,
- g_param_spec_boolean (
- "fixed-resize",
- "Fixed Resize",
- "Keep the 2nd pane fixed during resize",
- TRUE,
- G_PARAM_READWRITE));
-}
-
-static void
-e_paned_init (EPaned *paned)
-{
- paned->priv = E_PANED_GET_PRIVATE (paned);
-
- paned->priv->proportion = 0.5;
- paned->priv->fixed_resize = TRUE;
-
- g_signal_connect (
- paned, "notify::orientation",
- G_CALLBACK (paned_notify_orientation_cb), NULL);
-
- g_signal_connect (
- paned, "notify::position",
- G_CALLBACK (paned_notify_position_cb), NULL);
-}
-
-GtkWidget *
-e_paned_new (GtkOrientation orientation)
-{
- return g_object_new (E_TYPE_PANED, "orientation", orientation, NULL);
-}
-
-gint
-e_paned_get_hposition (EPaned *paned)
-{
- g_return_val_if_fail (E_IS_PANED (paned), 0);
-
- return paned->priv->hposition;
-}
-
-void
-e_paned_set_hposition (EPaned *paned,
- gint hposition)
-{
- GtkOrientable *orientable;
- GtkOrientation orientation;
-
- g_return_if_fail (E_IS_PANED (paned));
-
- if (hposition == paned->priv->hposition)
- return;
-
- paned->priv->hposition = hposition;
-
- g_object_notify (G_OBJECT (paned), "hposition");
-
- orientable = GTK_ORIENTABLE (paned);
- orientation = gtk_orientable_get_orientation (orientable);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- paned->priv->sync_request = SYNC_REQUEST_POSITION;
- gtk_widget_queue_resize (GTK_WIDGET (paned));
- }
-}
-
-gint
-e_paned_get_vposition (EPaned *paned)
-{
- g_return_val_if_fail (E_IS_PANED (paned), 0);
-
- return paned->priv->vposition;
-}
-
-void
-e_paned_set_vposition (EPaned *paned,
- gint vposition)
-{
- GtkOrientable *orientable;
- GtkOrientation orientation;
-
- g_return_if_fail (E_IS_PANED (paned));
-
- if (vposition == paned->priv->vposition)
- return;
-
- paned->priv->vposition = vposition;
-
- g_object_notify (G_OBJECT (paned), "vposition");
-
- orientable = GTK_ORIENTABLE (paned);
- orientation = gtk_orientable_get_orientation (orientable);
-
- if (orientation == GTK_ORIENTATION_VERTICAL) {
- paned->priv->sync_request = SYNC_REQUEST_POSITION;
- gtk_widget_queue_resize (GTK_WIDGET (paned));
- }
-}
-
-gdouble
-e_paned_get_proportion (EPaned *paned)
-{
- g_return_val_if_fail (E_IS_PANED (paned), 0.5);
-
- return paned->priv->proportion;
-}
-
-void
-e_paned_set_proportion (EPaned *paned,
- gdouble proportion)
-{
- g_return_if_fail (E_IS_PANED (paned));
- g_return_if_fail (CLAMP (proportion, 0.0, 1.0) == proportion);
-
- paned->priv->proportion = proportion;
-
- paned->priv->sync_request = SYNC_REQUEST_PROPORTION;
- gtk_widget_queue_resize (GTK_WIDGET (paned));
-
- g_object_notify (G_OBJECT (paned), "proportion");
-}
-
-gboolean
-e_paned_get_fixed_resize (EPaned *paned)
-{
- g_return_val_if_fail (E_IS_PANED (paned), FALSE);
-
- return paned->priv->fixed_resize;
-}
-
-void
-e_paned_set_fixed_resize (EPaned *paned,
- gboolean fixed_resize)
-{
- g_return_if_fail (E_IS_PANED (paned));
-
- if (fixed_resize == paned->priv->fixed_resize)
- return;
-
- paned->priv->fixed_resize = fixed_resize;
-
- g_object_notify (G_OBJECT (paned), "fixed-resize");
-}
diff --git a/widgets/misc/e-paned.h b/widgets/misc/e-paned.h
deleted file mode 100644
index 1867a0439e..0000000000
--- a/widgets/misc/e-paned.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * e-paned.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_PANED_H
-#define E_PANED_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_PANED \
- (e_paned_get_type ())
-#define E_PANED(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_PANED, EPaned))
-#define E_PANED_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_PANED, EPanedClass))
-#define E_IS_PANED(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_PANED))
-#define E_IS_PANED_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_PANED))
-#define E_PANED_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_PANED, EPanedClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPaned EPaned;
-typedef struct _EPanedClass EPanedClass;
-typedef struct _EPanedPrivate EPanedPrivate;
-
-struct _EPaned {
- GtkPaned parent;
- EPanedPrivate *priv;
-};
-
-struct _EPanedClass {
- GtkPanedClass parent_class;
-};
-
-GType e_paned_get_type (void);
-GtkWidget * e_paned_new (GtkOrientation orientation);
-gint e_paned_get_hposition (EPaned *paned);
-void e_paned_set_hposition (EPaned *paned,
- gint hposition);
-gint e_paned_get_vposition (EPaned *paned);
-void e_paned_set_vposition (EPaned *paned,
- gint vposition);
-gdouble e_paned_get_proportion (EPaned *paned);
-void e_paned_set_proportion (EPaned *paned,
- gdouble proportion);
-gboolean e_paned_get_fixed_resize (EPaned *paned);
-void e_paned_set_fixed_resize (EPaned *paned,
- gboolean fixed_resize);
-
-G_END_DECLS
-
-#endif /* E_PANED_H */
diff --git a/widgets/misc/e-picture-gallery.c b/widgets/misc/e-picture-gallery.c
deleted file mode 100644
index 40e621b1ca..0000000000
--- a/widgets/misc/e-picture-gallery.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * e-picture-gallery.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-util/e-icon-factory.h"
-
-#include "e-picture-gallery.h"
-
-#define E_PICTURE_GALLERY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_PICTURE_GALLERY, EPictureGalleryPrivate))
-
-struct _EPictureGalleryPrivate {
- gboolean initialized;
- gchar *path;
- GFileMonitor *monitor;
-};
-
-enum {
- PROP_0,
- PROP_PATH
-};
-
-enum {
- COL_PIXBUF = 0,
- COL_URI,
- COL_FILENAME_TEXT
-};
-
-G_DEFINE_TYPE (EPictureGallery, e_picture_gallery, GTK_TYPE_ICON_VIEW)
-
-static gboolean
-update_file_iter (GtkListStore *list_store,
- GtkTreeIter *iter,
- GFile *file,
- gboolean force_thumbnail_update)
-{
- GFileInfo *file_info;
- gchar *uri;
- gboolean res = FALSE;
-
- g_return_val_if_fail (list_store != NULL, FALSE);
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (file != NULL, FALSE);
-
- uri = g_file_get_uri (file);
-
- file_info = g_file_query_info (
- file,
- G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
- G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
- G_FILE_ATTRIBUTE_STANDARD_SIZE,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- NULL);
-
- if (file_info != NULL) {
- const gchar *existing_thumb = g_file_info_get_attribute_byte_string (file_info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
- gchar *new_thumb = NULL;
-
- if (!existing_thumb || force_thumbnail_update) {
- gchar *filename;
-
- filename = g_file_get_path (file);
- if (filename) {
- new_thumb = e_icon_factory_create_thumbnail (filename);
- if (new_thumb)
- existing_thumb = new_thumb;
- g_free (filename);
- }
- }
-
- if (existing_thumb && !g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)) {
- GdkPixbuf * pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (existing_thumb, NULL);
-
- if (pixbuf) {
- const gchar *filename;
- gchar *filename_text = NULL;
- guint64 filesize;
-
- filename = g_file_info_get_attribute_string (file_info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
- if (filename) {
- filesize = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
- if (filesize) {
- gchar *tmp = g_format_size ((goffset) filesize);
- filename_text = g_strdup_printf ("%s (%s)", filename, tmp);
- g_free (tmp);
- }
-
- res = TRUE;
- gtk_list_store_set (
- list_store, iter,
- COL_PIXBUF, pixbuf,
- COL_URI, uri,
- COL_FILENAME_TEXT, filename_text ? filename_text : filename,
- -1);
- }
-
- g_object_unref (pixbuf);
- g_free (filename_text);
- }
- }
-
- g_free (new_thumb);
- }
-
- g_free (uri);
-
- return res;
-}
-
-static void
-add_file (GtkListStore *list_store,
- GFile *file)
-{
- GtkTreeIter iter;
-
- g_return_if_fail (list_store != NULL);
- g_return_if_fail (file != NULL);
-
- gtk_list_store_append (list_store, &iter);
- if (!update_file_iter (list_store, &iter, file, FALSE))
- gtk_list_store_remove (list_store, &iter);
-}
-
-static gboolean
-find_file_uri (GtkListStore *list_store,
- const gchar *uri,
- GtkTreeIter *iter)
-{
- GtkTreeModel *model;
-
- g_return_val_if_fail (list_store != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (iter != NULL, FALSE);
-
- model = GTK_TREE_MODEL (list_store);
- g_return_val_if_fail (model != NULL, FALSE);
-
- if (!gtk_tree_model_get_iter_first (model, iter))
- return FALSE;
-
- do {
- gchar *iter_uri = NULL;
-
- gtk_tree_model_get (
- model, iter,
- COL_URI, &iter_uri,
- -1);
-
- if (iter_uri && g_ascii_strcasecmp (uri, iter_uri) == 0) {
- g_free (iter_uri);
- return TRUE;
- }
-
- g_free (iter_uri);
- } while (gtk_tree_model_iter_next (model, iter));
-
- return FALSE;
-}
-
-static void
-picture_gallery_dir_changed_cb (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- EPictureGallery *gallery)
-{
- gchar *uri;
- GtkListStore *list_store;
- GtkTreeIter iter;
-
- g_return_if_fail (file != NULL);
-
- list_store = GTK_LIST_STORE (gtk_icon_view_get_model (GTK_ICON_VIEW (gallery)));
- g_return_if_fail (list_store != NULL);
-
- uri = g_file_get_uri (file);
- if (!uri)
- return;
-
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CREATED:
- if (find_file_uri (list_store, uri, &iter)) {
- if (!update_file_iter (list_store, &iter, file, TRUE))
- gtk_list_store_remove (list_store, &iter);
- } else {
- add_file (list_store, file);
- }
- break;
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- if (find_file_uri (list_store, uri, &iter)) {
- if (!update_file_iter (list_store, &iter, file, TRUE))
- gtk_list_store_remove (list_store, &iter);
- }
- break;
- case G_FILE_MONITOR_EVENT_DELETED:
- if (find_file_uri (list_store, uri, &iter))
- gtk_list_store_remove (list_store, &iter);
- break;
- default:
- break;
- }
-
- g_free (uri);
-}
-
-static gboolean
-picture_gallery_start_loading_cb (EPictureGallery *gallery)
-{
- GtkIconView *icon_view;
- GtkListStore *list_store;
- GDir *dir;
- const gchar *dirname;
-
- icon_view = GTK_ICON_VIEW (gallery);
- list_store = GTK_LIST_STORE (gtk_icon_view_get_model (icon_view));
- g_return_val_if_fail (list_store != NULL, FALSE);
-
- dirname = e_picture_gallery_get_path (gallery);
- if (!dirname)
- return FALSE;
-
- dir = g_dir_open (dirname, 0, NULL);
- if (dir) {
- GFile *file;
- const gchar *basename;
-
- while ((basename = g_dir_read_name (dir)) != NULL) {
- gchar *filename;
-
- filename = g_build_filename (dirname, basename, NULL);
- file = g_file_new_for_path (filename);
-
- add_file (list_store, file);
-
- g_free (filename);
- g_object_unref (file);
- }
-
- g_dir_close (dir);
-
- file = g_file_new_for_path (dirname);
- gallery->priv->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
- g_object_unref (file);
-
- if (gallery->priv->monitor)
- g_signal_connect (
- gallery->priv->monitor, "changed",
- G_CALLBACK (picture_gallery_dir_changed_cb),
- gallery);
- }
-
- g_object_unref (icon_view);
-
- return FALSE;
-}
-
-const gchar *
-e_picture_gallery_get_path (EPictureGallery *gallery)
-{
- g_return_val_if_fail (gallery != NULL, NULL);
- g_return_val_if_fail (E_IS_PICTURE_GALLERY (gallery), NULL);
- g_return_val_if_fail (gallery->priv != NULL, NULL);
-
- return gallery->priv->path;
-}
-
-static void
-picture_gallery_set_path (EPictureGallery *gallery,
- const gchar *path)
-{
- g_return_if_fail (E_IS_PICTURE_GALLERY (gallery));
- g_return_if_fail (gallery->priv != NULL);
-
- g_free (gallery->priv->path);
-
- if (!path || !*path || !g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- gallery->priv->path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
- else
- gallery->priv->path = g_strdup (path);
-}
-
-static void
-picture_gallery_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PATH:
- g_value_set_string (value, e_picture_gallery_get_path (E_PICTURE_GALLERY (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-picture_gallery_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PATH:
- picture_gallery_set_path (E_PICTURE_GALLERY (object), g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-visible_cb (EPictureGallery *gallery)
-{
- if (!gallery->priv->initialized && gtk_widget_get_visible (GTK_WIDGET (gallery))) {
- gallery->priv->initialized = TRUE;
-
- g_idle_add ((GSourceFunc) picture_gallery_start_loading_cb, gallery);
- }
-}
-
-static void
-picture_gallery_constructed (GObject *object)
-{
- GtkIconView *icon_view;
- GtkListStore *list_store;
- GtkTargetEntry *targets;
- GtkTargetList *list;
- gint n_targets;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_picture_gallery_parent_class)->constructed (object);
-
- icon_view = GTK_ICON_VIEW (object);
-
- list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
- gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (list_store));
- g_object_unref (list_store);
-
- gtk_icon_view_set_pixbuf_column (icon_view, COL_PIXBUF);
- gtk_icon_view_set_text_column (icon_view, COL_FILENAME_TEXT);
- gtk_icon_view_set_tooltip_column (icon_view, -1);
-
- list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (list, 0);
- targets = gtk_target_table_new_from_list (list, &n_targets);
-
- gtk_icon_view_enable_model_drag_source (
- icon_view, GDK_BUTTON1_MASK,
- targets, n_targets, GDK_ACTION_COPY);
-
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (list);
-
- g_signal_connect (object, "notify::visible", G_CALLBACK (visible_cb), NULL);
-}
-
-static void
-picture_gallery_dispose (GObject *object)
-{
- EPictureGallery *gallery;
-
- gallery = E_PICTURE_GALLERY (object);
-
- if (gallery->priv->monitor) {
- g_object_unref (gallery->priv->monitor);
- gallery->priv->monitor = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_picture_gallery_parent_class)->dispose (object);
-}
-
-static void
-e_picture_gallery_class_init (EPictureGalleryClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EPictureGalleryPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->get_property = picture_gallery_get_property;
- object_class->set_property = picture_gallery_set_property;
- object_class->constructed = picture_gallery_constructed;
- object_class->dispose = picture_gallery_dispose;
-
- g_object_class_install_property (
- object_class,
- PROP_PATH,
- g_param_spec_string (
- "path",
- "Gallery path",
- NULL,
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-e_picture_gallery_init (EPictureGallery *gallery)
-{
- gallery->priv = E_PICTURE_GALLERY_GET_PRIVATE (gallery);
- gallery->priv->initialized = FALSE;
- gallery->priv->monitor = NULL;
- picture_gallery_set_path (gallery, NULL);
-}
-
-GtkWidget *
-e_picture_gallery_new (const gchar *path)
-{
- return g_object_new (E_TYPE_PICTURE_GALLERY, "path", path, NULL);
-}
diff --git a/widgets/misc/e-picture-gallery.h b/widgets/misc/e-picture-gallery.h
deleted file mode 100644
index 6da23294c4..0000000000
--- a/widgets/misc/e-picture-gallery.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * e-picture-gallery.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_PICTURE_GALLERY_H
-#define E_PICTURE_GALLERY_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_PICTURE_GALLERY \
- (e_picture_gallery_get_type ())
-#define E_PICTURE_GALLERY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_PICTURE_GALLERY, EPictureGallery))
-#define E_PICTURE_GALLERY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_PICTURE_GALLERY, EPictureGalleryClass))
-#define E_IS_PICTURE_GALLERY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_PICTURE_GALLERY))
-#define E_IS_PICTURE_GALLERY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_PICTURE_GALLERY))
-#define E_PICTURE_GALLERY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_PICTURE_GALLERY, EPictureGalleryClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPictureGallery EPictureGallery;
-typedef struct _EPictureGalleryClass EPictureGalleryClass;
-typedef struct _EPictureGalleryPrivate EPictureGalleryPrivate;
-
-struct _EPictureGallery {
- GtkIconView parent;
- EPictureGalleryPrivate *priv;
-};
-
-struct _EPictureGalleryClass {
- GtkIconViewClass parent_class;
-};
-
-GType e_picture_gallery_get_type (void);
-GtkWidget * e_picture_gallery_new (const gchar *path);
-const gchar * e_picture_gallery_get_path (EPictureGallery *gallery);
-
-G_END_DECLS
-
-#endif /* E_PICTURE_GALLERY_H */
diff --git a/widgets/misc/e-popup-action.c b/widgets/misc/e-popup-action.c
deleted file mode 100644
index 27c90f67c3..0000000000
--- a/widgets/misc/e-popup-action.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * e-popup-action.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-popup-action.h"
-
-#include <glib/gi18n.h>
-
-#define E_POPUP_ACTION_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_POPUP_ACTION, EPopupActionPrivate))
-
-enum {
- PROP_0,
- PROP_RELATED_ACTION,
- PROP_USE_ACTION_APPEARANCE
-};
-
-struct _EPopupActionPrivate {
- GtkAction *related_action;
- gboolean use_action_appearance;
- gulong activate_handler_id;
- gulong notify_handler_id;
-};
-
-/* Forward Declarations */
-static void e_popup_action_activatable_init (GtkActivatableIface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EPopupAction,
- e_popup_action,
- GTK_TYPE_ACTION,
- G_IMPLEMENT_INTERFACE (
- GTK_TYPE_ACTIVATABLE,
- e_popup_action_activatable_init))
-
-static void
-popup_action_notify_cb (GtkAction *action,
- GParamSpec *pspec,
- GtkActivatable *activatable)
-{
- GtkActivatableIface *iface;
-
- iface = GTK_ACTIVATABLE_GET_IFACE (activatable);
- g_return_if_fail (iface->update != NULL);
-
- iface->update (activatable, action, pspec->name);
-}
-
-static GtkAction *
-popup_action_get_related_action (EPopupAction *popup_action)
-{
- return popup_action->priv->related_action;
-}
-
-static void
-popup_action_set_related_action (EPopupAction *popup_action,
- GtkAction *related_action)
-{
- GtkActivatable *activatable;
-
- /* Do not call gtk_activatable_do_set_related_action() because
- * it assumes the activatable object is a widget and tries to add
- * it to the related actions's proxy list. Instead we'll just do
- * the relevant steps manually. */
-
- activatable = GTK_ACTIVATABLE (popup_action);
-
- if (related_action == popup_action->priv->related_action)
- return;
-
- if (related_action != NULL)
- g_object_ref (related_action);
-
- if (popup_action->priv->related_action != NULL) {
- g_signal_handler_disconnect (
- popup_action,
- popup_action->priv->activate_handler_id);
- g_signal_handler_disconnect (
- popup_action->priv->related_action,
- popup_action->priv->notify_handler_id);
- popup_action->priv->activate_handler_id = 0;
- popup_action->priv->notify_handler_id = 0;
- g_object_unref (popup_action->priv->related_action);
- }
-
- popup_action->priv->related_action = related_action;
-
- if (related_action != NULL) {
- popup_action->priv->activate_handler_id =
- g_signal_connect_swapped (
- popup_action, "activate",
- G_CALLBACK (gtk_action_activate),
- related_action);
- popup_action->priv->notify_handler_id =
- g_signal_connect (
- related_action, "notify",
- G_CALLBACK (popup_action_notify_cb),
- popup_action);
- gtk_activatable_sync_action_properties (
- activatable, related_action);
- } else
- gtk_action_set_visible (GTK_ACTION (popup_action), FALSE);
-
- g_object_notify (G_OBJECT (popup_action), "related-action");
-}
-
-static gboolean
-popup_action_get_use_action_appearance (EPopupAction *popup_action)
-{
- return popup_action->priv->use_action_appearance;
-}
-
-static void
-popup_action_set_use_action_appearance (EPopupAction *popup_action,
- gboolean use_action_appearance)
-{
- GtkActivatable *activatable;
- GtkAction *related_action;
-
- if (popup_action->priv->use_action_appearance == use_action_appearance)
- return;
-
- popup_action->priv->use_action_appearance = use_action_appearance;
-
- g_object_notify (G_OBJECT (popup_action), "use-action-appearance");
-
- activatable = GTK_ACTIVATABLE (popup_action);
- related_action = popup_action_get_related_action (popup_action);
- gtk_activatable_sync_action_properties (activatable, related_action);
-}
-
-static void
-popup_action_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_RELATED_ACTION:
- popup_action_set_related_action (
- E_POPUP_ACTION (object),
- g_value_get_object (value));
- return;
-
- case PROP_USE_ACTION_APPEARANCE:
- popup_action_set_use_action_appearance (
- E_POPUP_ACTION (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-popup_action_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_RELATED_ACTION:
- g_value_set_object (
- value,
- popup_action_get_related_action (
- E_POPUP_ACTION (object)));
- return;
-
- case PROP_USE_ACTION_APPEARANCE:
- g_value_set_boolean (
- value,
- popup_action_get_use_action_appearance (
- E_POPUP_ACTION (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-popup_action_dispose (GObject *object)
-{
- EPopupActionPrivate *priv;
-
- priv = E_POPUP_ACTION_GET_PRIVATE (object);
-
- if (priv->related_action != NULL) {
- g_signal_handler_disconnect (
- object,
- priv->activate_handler_id);
- g_signal_handler_disconnect (
- priv->related_action,
- priv->notify_handler_id);
- g_object_unref (priv->related_action);
- priv->related_action = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_popup_action_parent_class)->dispose (object);
-}
-
-static void
-popup_action_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
-{
- GObjectClass *class;
- GParamSpec *pspec;
- GValue *value;
-
- /* Ignore "action-group" changes" */
- if (strcmp (property_name, "action-group") == 0)
- return;
-
- /* Ignore "visible" changes. */
- if (strcmp (property_name, "visible") == 0)
- return;
-
- value = g_slice_new0 (GValue);
- class = G_OBJECT_GET_CLASS (action);
- pspec = g_object_class_find_property (class, property_name);
- g_value_init (value, pspec->value_type);
-
- g_object_get_property (G_OBJECT (action), property_name, value);
-
- if (strcmp (property_name, "sensitive") == 0)
- property_name = "visible";
- else if (!gtk_activatable_get_use_action_appearance (activatable))
- goto exit;
-
- g_object_set_property (G_OBJECT (activatable), property_name, value);
-
-exit:
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
-static void
-popup_action_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action)
-{
- if (action == NULL)
- return;
-
- /* XXX GTK+ 2.18 is still missing accessor functions for
- * "hide-if-empty" and "visible-overflown" properties.
- * These are rarely used so we'll skip them for now. */
-
- /* A popup action is never shown as insensitive. */
- gtk_action_set_sensitive (GTK_ACTION (activatable), TRUE);
-
- gtk_action_set_visible (
- GTK_ACTION (activatable),
- gtk_action_get_sensitive (action));
-
- gtk_action_set_visible_horizontal (
- GTK_ACTION (activatable),
- gtk_action_get_visible_horizontal (action));
-
- gtk_action_set_visible_vertical (
- GTK_ACTION (activatable),
- gtk_action_get_visible_vertical (action));
-
- gtk_action_set_is_important (
- GTK_ACTION (activatable),
- gtk_action_get_is_important (action));
-
- if (!gtk_activatable_get_use_action_appearance (activatable))
- return;
-
- gtk_action_set_label (
- GTK_ACTION (activatable),
- gtk_action_get_label (action));
-
- gtk_action_set_short_label (
- GTK_ACTION (activatable),
- gtk_action_get_short_label (action));
-
- gtk_action_set_tooltip (
- GTK_ACTION (activatable),
- gtk_action_get_tooltip (action));
-
- gtk_action_set_stock_id (
- GTK_ACTION (activatable),
- gtk_action_get_stock_id (action));
-
- gtk_action_set_gicon (
- GTK_ACTION (activatable),
- gtk_action_get_gicon (action));
-
- gtk_action_set_icon_name (
- GTK_ACTION (activatable),
- gtk_action_get_icon_name (action));
-}
-
-static void
-e_popup_action_class_init (EPopupActionClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EPopupActionPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = popup_action_set_property;
- object_class->get_property = popup_action_get_property;
- object_class->dispose = popup_action_dispose;
-
- g_object_class_override_property (
- object_class,
- PROP_RELATED_ACTION,
- "related-action");
-
- g_object_class_override_property (
- object_class,
- PROP_USE_ACTION_APPEARANCE,
- "use-action-appearance");
-}
-
-static void
-e_popup_action_init (EPopupAction *popup_action)
-{
- popup_action->priv = E_POPUP_ACTION_GET_PRIVATE (popup_action);
- popup_action->priv->use_action_appearance = TRUE;
-
- /* Remain invisible until we have a related action. */
- gtk_action_set_visible (GTK_ACTION (popup_action), FALSE);
-}
-
-static void
-e_popup_action_activatable_init (GtkActivatableIface *interface)
-{
- interface->update = popup_action_update;
- interface->sync_action_properties = popup_action_sync_action_properties;
-}
-
-EPopupAction *
-e_popup_action_new (const gchar *name)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (E_TYPE_POPUP_ACTION, "name", name, NULL);
-}
-
-void
-e_action_group_add_popup_actions (GtkActionGroup *action_group,
- const EPopupActionEntry *entries,
- guint n_entries)
-{
- guint ii;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- for (ii = 0; ii < n_entries; ii++) {
- EPopupAction *popup_action;
- GtkAction *related_action;
- const gchar *label;
-
- label = gtk_action_group_translate_string (
- action_group, entries[ii].label);
-
- related_action = gtk_action_group_get_action (
- action_group, entries[ii].related);
-
- if (related_action == NULL) {
- g_warning (
- "Related action '%s' not found in "
- "action group '%s'", entries[ii].related,
- gtk_action_group_get_name (action_group));
- continue;
- }
-
- popup_action = e_popup_action_new (entries[ii].name);
-
- gtk_activatable_set_related_action (
- GTK_ACTIVATABLE (popup_action), related_action);
-
- if (label != NULL && *label != '\0')
- gtk_action_set_label (
- GTK_ACTION (popup_action), label);
-
- gtk_action_group_add_action (
- action_group, GTK_ACTION (popup_action));
-
- g_object_unref (popup_action);
- }
-}
diff --git a/widgets/misc/e-popup-action.h b/widgets/misc/e-popup-action.h
deleted file mode 100644
index 02469375d5..0000000000
--- a/widgets/misc/e-popup-action.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * e-popup-action.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* A popup action is an action that lives in a popup menu. It proxies an
- * equivalent action in the main menu, with two differences:
- *
- * 1) If the main menu action is insensitive, the popup action is invisible.
- * 2) The popup action may have a different label than the main menu action.
- *
- * To use:
- *
- * Create an array of EPopupActionEntry structs. Add the main menu actions
- * that serve as related actions for the popup actions to an action group
- * first. Then pass the same action group and the EPopupActionEntry array
- * to e_action_group_add_popup_actions() to add popup actions.
- */
-
-#ifndef E_POPUP_ACTION_H
-#define E_POPUP_ACTION_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_POPUP_ACTION \
- (e_popup_action_get_type ())
-#define E_POPUP_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_POPUP_ACTION, EPopupAction))
-#define E_POPUP_ACTION_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_POPUP_ACTION, EPopupActionClass))
-#define E_IS_POPUP_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_POPUP_ACTION))
-#define E_IS_POPUP_ACTION_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_POPUP_ACTION))
-#define E_POPUP_ACTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_POPUP_ACTION, EPopupActionClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPopupAction EPopupAction;
-typedef struct _EPopupActionClass EPopupActionClass;
-typedef struct _EPopupActionPrivate EPopupActionPrivate;
-typedef struct _EPopupActionEntry EPopupActionEntry;
-
-struct _EPopupAction {
- GtkAction parent;
- EPopupActionPrivate *priv;
-};
-
-struct _EPopupActionClass {
- GtkActionClass parent_class;
-};
-
-struct _EPopupActionEntry {
- const gchar *name;
- const gchar *label; /* optional: overrides the related action */
- const gchar *related; /* name of the related action */
-};
-
-GType e_popup_action_get_type (void);
-EPopupAction * e_popup_action_new (const gchar *name);
-
-void e_action_group_add_popup_actions
- (GtkActionGroup *action_group,
- const EPopupActionEntry *entries,
- guint n_entries);
-
-G_END_DECLS
-
-#endif /* E_POPUP_ACTION_H */
diff --git a/widgets/misc/e-port-entry.c b/widgets/misc/e-port-entry.c
deleted file mode 100644
index cf857b5d55..0000000000
--- a/widgets/misc/e-port-entry.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * This library 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 Library General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- * Authors:
- * Dan Vratil <dvratil@redhat.com>
- */
-
-#include "e-port-entry.h"
-
-#include <config.h>
-#include <errno.h>
-#include <stddef.h>
-#include <string.h>
-
-#define E_PORT_ENTRY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_PORT_ENTRY, EPortEntryPrivate))
-
-struct _EPortEntryPrivate {
- CamelNetworkSecurityMethod method;
- CamelProviderPortEntry *entries;
-};
-
-enum {
- PORT_NUM_COLUMN,
- PORT_DESC_COLUMN,
- PORT_IS_SSL_COLUMN
-};
-
-enum {
- PROP_0,
- PROP_IS_VALID,
- PROP_PORT,
- PROP_SECURITY_METHOD
-};
-
-G_DEFINE_TYPE (
- EPortEntry,
- e_port_entry,
- GTK_TYPE_COMBO_BOX)
-
-static GtkEntry *
-port_entry_get_entry (EPortEntry *port_entry)
-{
- return GTK_ENTRY (gtk_bin_get_child (GTK_BIN (port_entry)));
-}
-
-static gboolean
-port_entry_get_numeric_port (EPortEntry *port_entry,
- gint *out_port)
-{
- GtkEntry *entry;
- const gchar *port_string;
- gboolean valid;
- gint port;
-
- entry = port_entry_get_entry (port_entry);
-
- port_string = gtk_entry_get_text (entry);
- g_return_val_if_fail (port_string != NULL, FALSE);
-
- errno = 0;
- port = strtol (port_string, NULL, 10);
- valid = (errno == 0) && (port == CLAMP (port, 1, G_MAXUINT16));
-
- if (valid && out_port != NULL)
- *out_port = port;
-
- return valid;
-}
-
-static void
-port_entry_text_changed (GtkEditable *editable,
- EPortEntry *port_entry)
-{
- GObject *object = G_OBJECT (port_entry);
- const gchar *desc = NULL;
- gint port = 0;
- gint ii = 0;
-
- g_object_freeze_notify (object);
-
- port_entry_get_numeric_port (port_entry, &port);
-
- if (port_entry->priv->entries != NULL) {
- while (port_entry->priv->entries[ii].port > 0) {
- if (port == port_entry->priv->entries[ii].port) {
- desc = port_entry->priv->entries[ii].desc;
- break;
- }
- ii++;
- }
- }
-
- if (desc != NULL)
- gtk_widget_set_tooltip_text (GTK_WIDGET (port_entry), desc);
- else
- gtk_widget_set_has_tooltip (GTK_WIDGET (port_entry), FALSE);
-
- g_object_notify (object, "port");
- g_object_notify (object, "is-valid");
-
- g_object_thaw_notify (object);
-}
-
-static void
-port_entry_method_changed (EPortEntry *port_entry)
-{
- CamelNetworkSecurityMethod method;
- gboolean standard_port = FALSE;
- gboolean valid, have_ssl = FALSE, have_nossl = FALSE;
- gint port = 0;
- gint ii;
-
- method = e_port_entry_get_security_method (port_entry);
- valid = port_entry_get_numeric_port (port_entry, &port);
-
- /* Only change the port number if it's currently on a standard
- * port (i.e. listed in a CamelProviderPortEntry). Otherwise,
- * leave custom port numbers alone. */
-
- if (valid && port_entry->priv->entries != NULL) {
- for (ii = 0; port_entry->priv->entries[ii].port > 0 && (!have_ssl || !have_nossl); ii++) {
- /* Use only the first SSL/no-SSL port as a default in the list
- * and skip the others */
- if (port_entry->priv->entries[ii].is_ssl) {
- if (have_ssl)
- continue;
- have_ssl = TRUE;
- } else {
- if (have_nossl)
- continue;
- have_nossl = TRUE;
- }
-
- if (port == port_entry->priv->entries[ii].port) {
- standard_port = TRUE;
- break;
- }
- }
- }
-
- if (valid && !standard_port)
- return;
-
- switch (method) {
- case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
- e_port_entry_activate_secured_port (port_entry, 0);
- break;
- default:
- e_port_entry_activate_nonsecured_port (port_entry, 0);
- break;
- }
-}
-
-static void
-port_entry_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_PORT:
- e_port_entry_set_port (
- E_PORT_ENTRY (object),
- g_value_get_uint (value));
- return;
-
- case PROP_SECURITY_METHOD:
- e_port_entry_set_security_method (
- E_PORT_ENTRY (object),
- g_value_get_enum (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-port_entry_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_IS_VALID:
- g_value_set_boolean (
- value, e_port_entry_is_valid (
- E_PORT_ENTRY (object)));
- return;
-
- case PROP_PORT:
- g_value_set_uint (
- value, e_port_entry_get_port (
- E_PORT_ENTRY (object)));
- return;
-
- case PROP_SECURITY_METHOD:
- g_value_set_enum (
- value, e_port_entry_get_security_method (
- E_PORT_ENTRY (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-port_entry_constructed (GObject *object)
-{
- GtkEntry *entry;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_port_entry_parent_class)->constructed (object);
-
- entry = port_entry_get_entry (E_PORT_ENTRY (object));
-
- g_signal_connect_after (
- entry, "changed",
- G_CALLBACK (port_entry_text_changed), object);
-}
-
-static void
-port_entry_get_preferred_width (GtkWidget *widget,
- gint *minimum_size,
- gint *natural_size)
-{
- PangoContext *context;
- PangoFontMetrics *metrics;
- PangoFontDescription *font_desc;
- GtkStyleContext *style_context;
- GtkStateFlags state;
- gint digit_width;
- gint parent_entry_width_min;
- gint parent_width_min;
- GtkWidget *entry;
-
- style_context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_get (
- style_context, state, "font", &font_desc, NULL);
- context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
- metrics = pango_context_get_metrics (
- context, font_desc, pango_context_get_language (context));
-
- digit_width = PANGO_PIXELS (
- pango_font_metrics_get_approximate_digit_width (metrics));
-
- /* Preferred width of the entry */
- entry = gtk_bin_get_child (GTK_BIN (widget));
- gtk_widget_get_preferred_width (entry, NULL, &parent_entry_width_min);
-
- /* Preferred width of a standard combobox */
- GTK_WIDGET_CLASS (e_port_entry_parent_class)->
- get_preferred_width (widget, &parent_width_min, NULL);
-
- /* 6 * digit_width - port number has max 5
- * digits + extra free space for better look */
- if (minimum_size != NULL)
- *minimum_size =
- parent_width_min - parent_entry_width_min +
- 6 * digit_width;
-
- if (natural_size != NULL)
- *natural_size =
- parent_width_min - parent_entry_width_min +
- 6 * digit_width;
-
- pango_font_metrics_unref (metrics);
- pango_font_description_free (font_desc);
-}
-
-static void
-e_port_entry_class_init (EPortEntryClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EPortEntryPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = port_entry_set_property;
- object_class->get_property = port_entry_get_property;
- object_class->constructed = port_entry_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->get_preferred_width = port_entry_get_preferred_width;
-
- g_object_class_install_property (
- object_class,
- PROP_IS_VALID,
- g_param_spec_boolean (
- "is-valid",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_PORT,
- g_param_spec_uint (
- "port",
- NULL,
- NULL,
- 0, /* Min port, 0 = invalid port */
- G_MAXUINT16, /* Max port */
- 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_SECURITY_METHOD,
- g_param_spec_enum (
- "security-method",
- "Security Method",
- "Method used to establish a network connection",
- CAMEL_TYPE_NETWORK_SECURITY_METHOD,
- CAMEL_NETWORK_SECURITY_METHOD_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_port_entry_init (EPortEntry *port_entry)
-{
- GtkCellRenderer *renderer;
- GtkListStore *store;
-
- port_entry->priv = E_PORT_ENTRY_GET_PRIVATE (port_entry);
-
- store = gtk_list_store_new (
- 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-
- gtk_combo_box_set_model (
- GTK_COMBO_BOX (port_entry), GTK_TREE_MODEL (store));
- gtk_combo_box_set_entry_text_column (
- GTK_COMBO_BOX (port_entry), PORT_NUM_COLUMN);
- gtk_combo_box_set_id_column (
- GTK_COMBO_BOX (port_entry), PORT_NUM_COLUMN);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_renderer_set_sensitive (renderer, TRUE);
- gtk_cell_layout_pack_start (
- GTK_CELL_LAYOUT (port_entry), renderer, FALSE);
- gtk_cell_layout_add_attribute (
- GTK_CELL_LAYOUT (port_entry),
- renderer, "text", PORT_NUM_COLUMN);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_renderer_set_sensitive (renderer, FALSE);
- gtk_cell_layout_pack_start (
- GTK_CELL_LAYOUT (port_entry), renderer, TRUE);
- gtk_cell_layout_add_attribute (
- GTK_CELL_LAYOUT (port_entry),
- renderer, "text", PORT_DESC_COLUMN);
-}
-
-GtkWidget *
-e_port_entry_new (void)
-{
- return g_object_new (
- E_TYPE_PORT_ENTRY, "has-entry", TRUE, NULL);
-}
-
-void
-e_port_entry_set_camel_entries (EPortEntry *port_entry,
- CamelProviderPortEntry *entries)
-{
- GtkComboBox *combo_box;
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkListStore *store;
- gint port = 0;
- gint i = 0;
-
- g_return_if_fail (E_IS_PORT_ENTRY (port_entry));
- g_return_if_fail (entries);
-
- port_entry->priv->entries = entries;
-
- combo_box = GTK_COMBO_BOX (port_entry);
- model = gtk_combo_box_get_model (combo_box);
-
- store = GTK_LIST_STORE (model);
- gtk_list_store_clear (store);
-
- while (entries[i].port > 0) {
- gchar *port_string;
-
- /* Grab the first port number. */
- if (port == 0)
- port = entries[i].port;
-
- port_string = g_strdup_printf ("%i", entries[i].port);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (
- store, &iter,
- PORT_NUM_COLUMN, port_string,
- PORT_DESC_COLUMN, entries[i].desc,
- PORT_IS_SSL_COLUMN, entries[i].is_ssl,
- -1);
- i++;
-
- g_free (port_string);
- }
-
- e_port_entry_set_port (port_entry, port);
-}
-
-gint
-e_port_entry_get_port (EPortEntry *port_entry)
-{
- gint port = 0;
-
- g_return_val_if_fail (E_IS_PORT_ENTRY (port_entry), 0);
-
- port_entry_get_numeric_port (port_entry, &port);
-
- return port;
-}
-
-void
-e_port_entry_set_port (EPortEntry *port_entry,
- gint port)
-{
- GtkEntry *entry;
- gchar *port_string;
-
- g_return_if_fail (E_IS_PORT_ENTRY (port_entry));
-
- entry = port_entry_get_entry (port_entry);
- port_string = g_strdup_printf ("%i", port);
- gtk_entry_set_text (entry, port_string);
- g_free (port_string);
-}
-
-gboolean
-e_port_entry_is_valid (EPortEntry *port_entry)
-{
- g_return_val_if_fail (E_IS_PORT_ENTRY (port_entry), FALSE);
-
- return port_entry_get_numeric_port (port_entry, NULL);
-}
-
-CamelNetworkSecurityMethod
-e_port_entry_get_security_method (EPortEntry *port_entry)
-{
- g_return_val_if_fail (
- E_IS_PORT_ENTRY (port_entry),
- CAMEL_NETWORK_SECURITY_METHOD_NONE);
-
- return port_entry->priv->method;
-}
-
-void
-e_port_entry_set_security_method (EPortEntry *port_entry,
- CamelNetworkSecurityMethod method)
-{
- g_return_if_fail (E_IS_PORT_ENTRY (port_entry));
-
- port_entry->priv->method = method;
-
- port_entry_method_changed (port_entry);
-
- g_object_notify (G_OBJECT (port_entry), "security-method");
-}
-
-/**
- * If there are more then one secured port in the model, you can specify
- * which of the secured ports should be activated by specifying the index.
- * The index counts only for secured ports, so if you have 5 ports of which
- * ports 1, 3 and 5 are secured, the association is 0=>1, 1=>3, 2=>5
- */
-void
-e_port_entry_activate_secured_port (EPortEntry *port_entry,
- gint index)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean is_ssl;
- gint iters = 0;
-
- g_return_if_fail (E_IS_PORT_ENTRY (port_entry));
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (port_entry));
-
- if (!gtk_tree_model_get_iter_first (model, &iter))
- return;
-
- do {
- gtk_tree_model_get (
- model, &iter, PORT_IS_SSL_COLUMN, &is_ssl, -1);
- if (is_ssl && (iters == index)) {
- gtk_combo_box_set_active_iter (
- GTK_COMBO_BOX (port_entry), &iter);
- return;
- }
-
- if (is_ssl)
- iters++;
-
- } while (gtk_tree_model_iter_next (model, &iter));
-}
-
-/**
- * If there are more then one unsecured port in the model, you can specify
- * which of the unsecured ports should be activated by specifiying the index.
- * The index counts only for unsecured ports, so if you have 5 ports, of which
- * ports 2 and 4 are unsecured, the associtation is 0=>2, 1=>4
- */
-void
-e_port_entry_activate_nonsecured_port (EPortEntry *port_entry,
- gint index)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean is_ssl;
- gint iters = 0;
-
- g_return_if_fail (E_IS_PORT_ENTRY (port_entry));
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (port_entry));
-
- if (!gtk_tree_model_get_iter_first (model, &iter))
- return;
-
- do {
- gtk_tree_model_get (model, &iter, PORT_IS_SSL_COLUMN, &is_ssl, -1);
- if (!is_ssl && (iters == index)) {
- gtk_combo_box_set_active_iter (
- GTK_COMBO_BOX (port_entry), &iter);
- return;
- }
-
- if (!is_ssl)
- iters++;
-
- } while (gtk_tree_model_iter_next (model, &iter));
-}
diff --git a/widgets/misc/e-port-entry.h b/widgets/misc/e-port-entry.h
deleted file mode 100644
index 2ef9b45cf7..0000000000
--- a/widgets/misc/e-port-entry.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library 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:
- * Dan Vratil <dvratil@redhat.com>
- */
-
-#ifndef E_PORT_ENTRY_H
-#define E_PORT_ENTRY_H
-
-#include <gtk/gtk.h>
-#include <camel/camel.h>
-
-/* Standard GObject macros */
-#define E_TYPE_PORT_ENTRY \
- (e_port_entry_get_type ())
-#define E_PORT_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_PORT_ENTRY, EPortEntry))
-#define E_PORT_ENTRY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_PORT_ENTRY, EPortEntryClass))
-#define E_IS_PORT_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_PORT_ENTRY))
-#define E_IS_PORT_ENTRY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_PORT_ENTRY))
-#define E_PORT_ENTRY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_PORT_ENTRY, EPortEntryClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPortEntry EPortEntry;
-typedef struct _EPortEntryClass EPortEntryClass;
-typedef struct _EPortEntryPrivate EPortEntryPrivate;
-
-struct _EPortEntry {
- GtkComboBox parent;
- EPortEntryPrivate *priv;
-};
-
-struct _EPortEntryClass {
- GtkComboBoxClass parent_class;
-};
-
-GType e_port_entry_get_type (void) G_GNUC_CONST;
-GtkWidget * e_port_entry_new (void);
-void e_port_entry_set_camel_entries
- (EPortEntry *port_entry,
- CamelProviderPortEntry *entries);
-gint e_port_entry_get_port (EPortEntry *port_entry);
-void e_port_entry_set_port (EPortEntry *port_entry,
- gint port);
-gboolean e_port_entry_is_valid (EPortEntry *port_entry);
-CamelNetworkSecurityMethod
- e_port_entry_get_security_method
- (EPortEntry *port_entry);
-void e_port_entry_set_security_method
- (EPortEntry *port_entry,
- CamelNetworkSecurityMethod method);
-void e_port_entry_activate_secured_port
- (EPortEntry *port_entry,
- gint index);
-void e_port_entry_activate_nonsecured_port
- (EPortEntry *port_entry,
- gint index);
-
-G_END_DECLS
-
-#endif /* E_PORT_ENTRY_H */
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
deleted file mode 100644
index 83c5ed0fd6..0000000000
--- a/widgets/misc/e-preferences-window.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * e-preferences-window.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-preferences-window.h"
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <e-util/e-util.h>
-
-#define SWITCH_PAGE_INTERVAL 250
-
-#define E_PREFERENCES_WINDOW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowPrivate))
-
-struct _EPreferencesWindowPrivate {
- gboolean setup;
- gpointer shell;
-
- GtkWidget *icon_view;
- GtkWidget *scroll;
- GtkWidget *notebook;
- GHashTable *index;
-
- GtkListStore *store;
- GtkTreeModelFilter *filter;
- const gchar *filter_view;
-};
-
-enum {
- COLUMN_ID, /* G_TYPE_STRING */
- COLUMN_TEXT, /* G_TYPE_STRING */
- COLUMN_HELP, /* G_TYPE_STRING */
- COLUMN_PIXBUF, /* GDK_TYPE_PIXBUF */
- COLUMN_PAGE, /* G_TYPE_INT */
- COLUMN_SORT /* G_TYPE_INT */
-};
-
-G_DEFINE_TYPE (
- EPreferencesWindow,
- e_preferences_window,
- GTK_TYPE_WINDOW)
-
-static gboolean
-preferences_window_filter_view (GtkTreeModel *model,
- GtkTreeIter *iter,
- EPreferencesWindow *window)
-{
- gchar *str;
- gboolean visible = FALSE;
-
- if (!window->priv->filter_view)
- return TRUE;
-
- gtk_tree_model_get (model, iter, COLUMN_ID, &str, -1);
- if (strncmp (window->priv->filter_view, "mail", 4) == 0) {
- /* Show everything except calendar */
- if (str && (strncmp (str, "cal", 3) == 0))
- visible = FALSE;
- else
- visible = TRUE;
- } else if (strncmp (window->priv->filter_view, "cal", 3) == 0) {
- /* Show only calendar and nothing else */
- if (str && (strncmp (str, "cal", 3) != 0))
- visible = FALSE;
- else
- visible = TRUE;
-
- } else /* In any other case, show everything */
- visible = TRUE;
-
- g_free (str);
-
- return visible;
-}
-
-static GdkPixbuf *
-preferences_window_load_pixbuf (const gchar *icon_name)
-{
- GtkIconTheme *icon_theme;
- GtkIconInfo *icon_info;
- GdkPixbuf *pixbuf;
- const gchar *filename;
- gint size;
- GError *error = NULL;
-
- icon_theme = gtk_icon_theme_get_default ();
-
- if (!gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, 0))
- return NULL;
-
- icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, icon_name, size, 0);
-
- if (icon_info == NULL)
- return NULL;
-
- filename = gtk_icon_info_get_filename (icon_info);
-
- pixbuf = gdk_pixbuf_new_from_file (filename, &error);
-
- gtk_icon_info_free (icon_info);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- return pixbuf;
-}
-
-static void
-preferences_window_help_clicked_cb (EPreferencesWindow *window)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GList *list;
- gchar *help = NULL;
-
- g_return_if_fail (window != NULL);
-
- model = GTK_TREE_MODEL (window->priv->filter);
- list = gtk_icon_view_get_selected_items (
- GTK_ICON_VIEW (window->priv->icon_view));
-
- if (list != NULL) {
- gtk_tree_model_get_iter (model, &iter, list->data);
- gtk_tree_model_get (model, &iter, COLUMN_HELP, &help, -1);
-
- } else if (gtk_tree_model_get_iter_first (model, &iter)) {
- gint page_index, current_index;
-
- current_index = gtk_notebook_get_current_page (
- GTK_NOTEBOOK (window->priv->notebook));
- do {
- gtk_tree_model_get (
- model, &iter, COLUMN_PAGE, &page_index, -1);
-
- if (page_index == current_index) {
- gtk_tree_model_get (
- model, &iter, COLUMN_HELP, &help, -1);
- break;
- }
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
- e_display_help (GTK_WINDOW (window), help ? help : "index");
-
- g_free (help);
-}
-
-static void
-preferences_window_selection_changed_cb (EPreferencesWindow *window)
-{
- GtkIconView *icon_view;
- GtkNotebook *notebook;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GList *list;
- gint page;
-
- icon_view = GTK_ICON_VIEW (window->priv->icon_view);
- list = gtk_icon_view_get_selected_items (icon_view);
- if (list == NULL)
- return;
-
- model = GTK_TREE_MODEL (window->priv->filter);
- gtk_tree_model_get_iter (model, &iter, list->data);
- gtk_tree_model_get (model, &iter, COLUMN_PAGE, &page, -1);
-
- notebook = GTK_NOTEBOOK (window->priv->notebook);
- gtk_notebook_set_current_page (notebook, page);
-
- g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (list);
-
- gtk_widget_grab_focus (GTK_WIDGET (icon_view));
-}
-
-static void
-preferences_window_dispose (GObject *object)
-{
- EPreferencesWindowPrivate *priv;
-
- priv = E_PREFERENCES_WINDOW_GET_PRIVATE (object);
-
- if (priv->icon_view != NULL) {
- g_object_unref (priv->icon_view);
- priv->icon_view = NULL;
- }
-
- if (priv->notebook != NULL) {
- g_object_unref (priv->notebook);
- priv->notebook = NULL;
- }
-
- if (priv->shell) {
- g_object_remove_weak_pointer (priv->shell, &priv->shell);
- priv->shell = NULL;
- }
-
- g_hash_table_remove_all (priv->index);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_preferences_window_parent_class)->dispose (object);
-}
-
-static void
-preferences_window_finalize (GObject *object)
-{
- EPreferencesWindowPrivate *priv;
-
- priv = E_PREFERENCES_WINDOW_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->index);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_preferences_window_parent_class)->finalize (object);
-}
-
-static void
-preferences_window_show (GtkWidget *widget)
-{
- EPreferencesWindowPrivate *priv;
- GtkIconView *icon_view;
- GtkTreePath *path;
-
- priv = E_PREFERENCES_WINDOW_GET_PRIVATE (widget);
- if (!priv->setup)
- g_warning ("Preferences window has not been setup correctly");
-
- icon_view = GTK_ICON_VIEW (priv->icon_view);
-
- path = gtk_tree_path_new_first ();
- gtk_icon_view_select_path (icon_view, path);
- gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
-
- gtk_widget_grab_focus (priv->icon_view);
-
- /* Chain up to parent's show() method. */
- GTK_WIDGET_CLASS (e_preferences_window_parent_class)->show (widget);
-}
-
-static void
-e_preferences_window_class_init (EPreferencesWindowClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EPreferencesWindowPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = preferences_window_dispose;
- object_class->finalize = preferences_window_finalize;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->show = preferences_window_show;
-}
-
-static void
-e_preferences_window_init (EPreferencesWindow *window)
-{
- GtkListStore *store;
- GtkWidget *container;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *widget;
- GHashTable *index;
- const gchar *title;
- GtkAccelGroup *accel_group;
-
- index = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) gtk_tree_row_reference_free);
-
- window->priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window);
- window->priv->index = index;
- window->priv->filter_view = NULL;
-
- store = gtk_list_store_new (
- 6, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
- gtk_tree_sortable_set_sort_column_id (
- GTK_TREE_SORTABLE (store), COLUMN_SORT, GTK_SORT_ASCENDING);
- window->priv->store = store;
-
- window->priv->filter = (GtkTreeModelFilter *)
- gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
- gtk_tree_model_filter_set_visible_func (
- window->priv->filter, (GtkTreeModelFilterVisibleFunc)
- preferences_window_filter_view, window, NULL);
-
- title = _("Evolution Preferences");
- gtk_window_set_title (GTK_WINDOW (window), title);
- gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (window), 12);
-
- g_signal_connect (
- window, "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), NULL);
-
- widget = gtk_vbox_new (FALSE, 12);
- gtk_container_add (GTK_CONTAINER (window), widget);
- gtk_widget_show (widget);
-
- vbox = widget;
-
- widget = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- hbox = widget;
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (
- GTK_SCROLLED_WINDOW (widget),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, TRUE, 0);
- window->priv->scroll = widget;
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_icon_view_new_with_model (
- GTK_TREE_MODEL (window->priv->filter));
- gtk_icon_view_set_columns (GTK_ICON_VIEW (widget), 1);
- gtk_icon_view_set_text_column (GTK_ICON_VIEW (widget), COLUMN_TEXT);
- gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (widget), COLUMN_PIXBUF);
- g_signal_connect_swapped (
- widget, "selection-changed",
- G_CALLBACK (preferences_window_selection_changed_cb), window);
- gtk_container_add (GTK_CONTAINER (container), widget);
- window->priv->icon_view = g_object_ref (widget);
- gtk_widget_show (widget);
- g_object_unref (store);
-
- widget = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
- window->priv->notebook = g_object_ref (widget);
- gtk_widget_show (widget);
-
- widget = gtk_hbutton_box_new ();
- gtk_button_box_set_layout (
- GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_button_new_from_stock (GTK_STOCK_HELP);
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (preferences_window_help_clicked_cb), window);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_button_box_set_child_secondary (
- GTK_BUTTON_BOX (container), widget, TRUE);
- gtk_widget_show (widget);
-
- widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (gtk_widget_hide), window);
- gtk_widget_set_can_default (widget, TRUE);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- accel_group = gtk_accel_group_new ();
- gtk_widget_add_accelerator (
- widget, "activate", accel_group,
- GDK_KEY_Escape, (GdkModifierType) 0,
- GTK_ACCEL_VISIBLE);
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
- gtk_widget_grab_default (widget);
- gtk_widget_show (widget);
-}
-
-GtkWidget *
-e_preferences_window_new (gpointer shell)
-{
- EPreferencesWindow *window;
-
- window = g_object_new (E_TYPE_PREFERENCES_WINDOW, NULL);
-
- /* ideally should be an object property */
- window->priv->shell = shell;
- if (shell)
- g_object_add_weak_pointer (shell, &window->priv->shell);
-
- return GTK_WIDGET (window);
-}
-
-gpointer
-e_preferences_window_get_shell (EPreferencesWindow *window)
-{
- g_return_val_if_fail (E_IS_PREFERENCES_WINDOW (window), NULL);
-
- return window->priv->shell;
-}
-
-void
-e_preferences_window_add_page (EPreferencesWindow *window,
- const gchar *page_name,
- const gchar *icon_name,
- const gchar *caption,
- const gchar *help_target,
- EPreferencesWindowCreatePageFn create_fn,
- gint sort_order)
-{
- GtkTreeRowReference *reference;
- GtkIconView *icon_view;
- GtkNotebook *notebook;
- GtkTreeModel *model;
- GtkTreePath *path;
- GHashTable *index;
- GdkPixbuf *pixbuf;
- GtkTreeIter iter;
- GtkWidget *align;
- gint page;
-
- g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
- g_return_if_fail (create_fn != NULL);
- g_return_if_fail (page_name != NULL);
- g_return_if_fail (icon_name != NULL);
- g_return_if_fail (caption != NULL);
-
- icon_view = GTK_ICON_VIEW (window->priv->icon_view);
- notebook = GTK_NOTEBOOK (window->priv->notebook);
-
- page = gtk_notebook_get_n_pages (notebook);
- model = GTK_TREE_MODEL (window->priv->store);
- pixbuf = preferences_window_load_pixbuf (icon_name);
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- gtk_list_store_set (
- GTK_LIST_STORE (model), &iter,
- COLUMN_ID, page_name,
- COLUMN_TEXT, caption,
- COLUMN_HELP, help_target,
- COLUMN_PIXBUF, pixbuf,
- COLUMN_PAGE, page,
- COLUMN_SORT, sort_order,
- -1);
-
- index = window->priv->index;
- path = gtk_tree_model_get_path (model, &iter);
- reference = gtk_tree_row_reference_new (model, path);
- g_hash_table_insert (index, g_strdup (page_name), reference);
- gtk_tree_path_free (path);
-
- align = g_object_new (GTK_TYPE_ALIGNMENT, NULL);
- gtk_widget_show (GTK_WIDGET (align));
- g_object_set_data (G_OBJECT (align), "create_fn", create_fn);
- gtk_notebook_append_page (notebook, align, NULL);
- gtk_container_child_set (
- GTK_CONTAINER (notebook), align,
- "tab-fill", FALSE, "tab-expand", FALSE, NULL);
-
- /* Force GtkIconView to recalculate the text wrap width,
- * otherwise we get a really narrow icon list on the left
- * side of the preferences window. */
- gtk_icon_view_set_item_width (icon_view, -1);
- gtk_widget_queue_resize (GTK_WIDGET (window));
-}
-
-void
-e_preferences_window_show_page (EPreferencesWindow *window,
- const gchar *page_name)
-{
- GtkTreeRowReference *reference;
- GtkIconView *icon_view;
- GtkTreePath *path;
-
- g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
- g_return_if_fail (page_name != NULL);
- g_return_if_fail (window->priv->setup);
-
- icon_view = GTK_ICON_VIEW (window->priv->icon_view);
- reference = g_hash_table_lookup (window->priv->index, page_name);
- g_return_if_fail (reference != NULL);
-
- path = gtk_tree_row_reference_get_path (reference);
- gtk_icon_view_select_path (icon_view, path);
- gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
-}
-
-void
-e_preferences_window_filter_page (EPreferencesWindow *window,
- const gchar *page_name)
-{
- GtkTreeRowReference *reference;
- GtkIconView *icon_view;
- GtkTreePath *path;
-
- g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
- g_return_if_fail (page_name != NULL);
- g_return_if_fail (window->priv->setup);
-
- icon_view = GTK_ICON_VIEW (window->priv->icon_view);
- reference = g_hash_table_lookup (window->priv->index, page_name);
- g_return_if_fail (reference != NULL);
-
- path = gtk_tree_row_reference_get_path (reference);
- gtk_icon_view_select_path (icon_view, path);
- gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
-
- window->priv->filter_view = page_name;
- gtk_tree_model_filter_refilter (window->priv->filter);
-
- /* XXX: We need a better solution to hide the icon view when
- * there is just one entry */
- if (strncmp (page_name, "cal", 3) == 0) {
- gtk_widget_hide (window->priv->scroll);
- } else
- gtk_widget_show (window->priv->scroll);
-}
-
-/*
- * Create all the deferred configuration pages.
- */
-void
-e_preferences_window_setup (EPreferencesWindow *window)
-{
- gint i, num;
- GtkNotebook *notebook;
- GtkRequisition requisition;
- gint width = -1, height = -1, content_width = -1, content_height = -1;
- EPreferencesWindowPrivate *priv;
-
- g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
-
- priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window);
-
- if (priv->setup)
- return;
-
- gtk_window_get_default_size (GTK_WINDOW (window), &width, &height);
- if (width < 0 || height < 0) {
- gtk_widget_get_preferred_size (GTK_WIDGET (window), &requisition, NULL);
-
- width = requisition.width;
- height = requisition.height;
- }
-
- notebook = GTK_NOTEBOOK (priv->notebook);
- num = gtk_notebook_get_n_pages (notebook);
-
- for (i = 0; i < num; i++) {
- GtkBin *align;
- GtkWidget *content;
- EPreferencesWindowCreatePageFn create_fn;
-
- align = GTK_BIN (gtk_notebook_get_nth_page (notebook, i));
- create_fn = g_object_get_data (G_OBJECT (align), "create_fn");
-
- if (!create_fn || gtk_bin_get_child (align))
- continue;
-
- content = create_fn (window);
- if (content) {
- GtkScrolledWindow *scrolled;
-
- scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
- gtk_scrolled_window_add_with_viewport (scrolled, content);
- gtk_scrolled_window_set_min_content_width (scrolled, 320);
- gtk_scrolled_window_set_min_content_height (scrolled, 240);
- gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_NONE);
-
- gtk_viewport_set_shadow_type (
- GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))),
- GTK_SHADOW_NONE);
-
- gtk_widget_show (content);
-
- gtk_widget_get_preferred_size (GTK_WIDGET (content), &requisition, NULL);
-
- if (requisition.width > content_width)
- content_width = requisition.width;
- if (requisition.height > content_height)
- content_height = requisition.height;
-
- gtk_widget_show (GTK_WIDGET (scrolled));
-
- gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (scrolled));
- }
- }
-
- if (content_width > 0 && content_height > 0 && width > 0 && height > 0) {
- GdkScreen *screen;
- GdkRectangle monitor_area;
- gint x = 0, y = 0, monitor;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
- gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-
- monitor = gdk_screen_get_monitor_at_point (screen, x, y);
- if (monitor < 0 || monitor >= gdk_screen_get_n_monitors (screen))
- monitor = 0;
-
- gdk_screen_get_monitor_workarea (screen, monitor, &monitor_area);
-
- if (content_width > monitor_area.width - width)
- content_width = monitor_area.width - width;
-
- if (content_height > monitor_area.height - height)
- content_height = monitor_area.height - height;
-
- if (content_width > 0 && content_height > 0)
- gtk_window_set_default_size (GTK_WINDOW (window), width + content_width, height + content_height);
- }
-
- priv->setup = TRUE;
-}
diff --git a/widgets/misc/e-preferences-window.h b/widgets/misc/e-preferences-window.h
deleted file mode 100644
index 72ae63eb7e..0000000000
--- a/widgets/misc/e-preferences-window.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * e-preferences-window.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_PREFERENCES_WINDOW_H
-#define E_PREFERENCES_WINDOW_H
-
-#include <gtk/gtk.h>
-
-/* Standard GObject macros */
-#define E_TYPE_PREFERENCES_WINDOW \
- (e_preferences_window_get_type ())
-#define E_PREFERENCES_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindow))
-#define E_PREFERENCES_WINDOW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowClass))
-#define E_IS_PREFERENCES_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_PREFERENCES_WINDOW))
-#define E_IS_PREFERENCES_WINDOW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((obj), E_TYPE_PREFERENCES_WINDOW))
-#define E_PREFERENCES_WINDOW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_TYPE \
- ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPreferencesWindow EPreferencesWindow;
-typedef struct _EPreferencesWindowClass EPreferencesWindowClass;
-typedef struct _EPreferencesWindowPrivate EPreferencesWindowPrivate;
-
-struct _EPreferencesWindow {
- GtkWindow parent;
- EPreferencesWindowPrivate *priv;
-};
-
-struct _EPreferencesWindowClass {
- GtkWindowClass parent_class;
-};
-
-typedef GtkWidget *
- (*EPreferencesWindowCreatePageFn)
- (EPreferencesWindow *window);
-
-GType e_preferences_window_get_type (void);
-GtkWidget * e_preferences_window_new (gpointer shell);
-gpointer e_preferences_window_get_shell (EPreferencesWindow *window);
-void e_preferences_window_setup (EPreferencesWindow *window);
-void e_preferences_window_add_page (EPreferencesWindow *window,
- const gchar *page_name,
- const gchar *icon_name,
- const gchar *caption,
- const gchar *help_target,
- EPreferencesWindowCreatePageFn create_fn,
- gint sort_order);
-void e_preferences_window_show_page (EPreferencesWindow *window,
- const gchar *page_name);
-void e_preferences_window_filter_page
- (EPreferencesWindow *window,
- const gchar *page_name);
-
-G_END_DECLS
-
-#endif /* E_PREFERENCES_WINDOW_H */
diff --git a/widgets/misc/e-preview-pane.c b/widgets/misc/e-preview-pane.c
deleted file mode 100644
index 92644ec883..0000000000
--- a/widgets/misc/e-preview-pane.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * e-preview-pane.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-preview-pane.h"
-
-#include <gdk/gdkkeysyms.h>
-
-#include <libevolution-utils/e-alert-sink.h>
-#include <libevolution-utils/e-alert-dialog.h>
-
-#include "e-alert-bar.h"
-
-#define E_PREVIEW_PANE_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_PREVIEW_PANE, EPreviewPanePrivate))
-
-struct _EPreviewPanePrivate {
- GtkWidget *alert_bar;
- GtkWidget *web_view;
- GtkWidget *search_bar;
-};
-
-enum {
- PROP_0,
- PROP_SEARCH_BAR,
- PROP_WEB_VIEW
-};
-
-enum {
- SHOW_SEARCH_BAR,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-/* Forward Declarations */
-static void e_preview_pane_alert_sink_init
- (EAlertSinkInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EPreviewPane,
- e_preview_pane,
- GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ALERT_SINK,
- e_preview_pane_alert_sink_init))
-
-static void
-preview_pane_set_web_view (EPreviewPane *preview_pane,
- EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_return_if_fail (preview_pane->priv->web_view == NULL);
-
- preview_pane->priv->web_view = g_object_ref_sink (web_view);
-}
-
-static void
-preview_pane_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_WEB_VIEW:
- preview_pane_set_web_view (
- E_PREVIEW_PANE (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-preview_pane_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SEARCH_BAR:
- g_value_set_object (
- value, e_preview_pane_get_search_bar (
- E_PREVIEW_PANE (object)));
- return;
-
- case PROP_WEB_VIEW:
- g_value_set_object (
- value, e_preview_pane_get_web_view (
- E_PREVIEW_PANE (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-preview_pane_dispose (GObject *object)
-{
- EPreviewPanePrivate *priv;
-
- priv = E_PREVIEW_PANE_GET_PRIVATE (object);
-
- if (priv->alert_bar != NULL) {
- g_object_unref (priv->alert_bar);
- priv->alert_bar = NULL;
- }
-
- if (priv->search_bar != NULL) {
- g_object_unref (priv->search_bar);
- priv->search_bar = NULL;
- }
-
- if (priv->web_view != NULL) {
- g_object_unref (priv->web_view);
- priv->web_view = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_preview_pane_parent_class)->dispose (object);
-}
-
-static void
-preview_pane_constructed (GObject *object)
-{
- EPreviewPanePrivate *priv;
- GtkWidget *widget;
-
- priv = E_PREVIEW_PANE_GET_PRIVATE (object);
-
- widget = e_alert_bar_new ();
- gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
- priv->alert_bar = g_object_ref (widget);
- /* EAlertBar controls its own visibility. */
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (object), widget, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (widget), priv->web_view);
- gtk_widget_show (widget);
- gtk_widget_show (priv->web_view);
-
- widget = e_search_bar_new (E_WEB_VIEW (priv->web_view));
- gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
- priv->search_bar = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_preview_pane_parent_class)->constructed (object);
-}
-
-static void
-preview_pane_show_search_bar (EPreviewPane *preview_pane)
-{
- GtkWidget *search_bar;
-
- search_bar = preview_pane->priv->search_bar;
-
- if (!gtk_widget_get_visible (search_bar))
- gtk_widget_show (search_bar);
-}
-
-static void
-preview_pane_submit_alert (EAlertSink *alert_sink,
- EAlert *alert)
-{
- EPreviewPane *preview_pane;
- EAlertBar *alert_bar;
- GtkWidget *dialog;
- GtkWindow *parent;
-
- preview_pane = E_PREVIEW_PANE (alert_sink);
- alert_bar = E_ALERT_BAR (preview_pane->priv->alert_bar);
-
- switch (e_alert_get_message_type (alert)) {
- case GTK_MESSAGE_INFO:
- case GTK_MESSAGE_WARNING:
- case GTK_MESSAGE_QUESTION:
- case GTK_MESSAGE_ERROR:
- e_alert_bar_add_alert (alert_bar, alert);
- break;
-
- default:
- parent = GTK_WINDOW (alert_sink);
- dialog = e_alert_dialog_new (parent, alert);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- break;
- }
-}
-
-static void
-e_preview_pane_class_init (EPreviewPaneClass *class)
-{
- GObjectClass *object_class;
- GtkBindingSet *binding_set;
-
- g_type_class_add_private (class, sizeof (EPreviewPanePrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = preview_pane_set_property;
- object_class->get_property = preview_pane_get_property;
- object_class->dispose = preview_pane_dispose;
- object_class->constructed = preview_pane_constructed;
-
- class->show_search_bar = preview_pane_show_search_bar;
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_BAR,
- g_param_spec_object (
- "search-bar",
- "Search Bar",
- NULL,
- E_TYPE_SEARCH_BAR,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_WEB_VIEW,
- g_param_spec_object (
- "web-view",
- "Web View",
- NULL,
- E_TYPE_WEB_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- signals[SHOW_SEARCH_BAR] = g_signal_new (
- "show-search-bar",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EPreviewPaneClass, show_search_bar),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- binding_set = gtk_binding_set_by_class (class);
-
- gtk_binding_entry_add_signal (
- binding_set, GDK_KEY_f, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
- "show-search-bar", 0);
-}
-
-static void
-e_preview_pane_alert_sink_init (EAlertSinkInterface *interface)
-{
- interface->submit_alert = preview_pane_submit_alert;
-}
-
-static void
-e_preview_pane_init (EPreviewPane *preview_pane)
-{
- preview_pane->priv = E_PREVIEW_PANE_GET_PRIVATE (preview_pane);
-
- gtk_box_set_spacing (GTK_BOX (preview_pane), 1);
-}
-
-GtkWidget *
-e_preview_pane_new (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return g_object_new (
- E_TYPE_PREVIEW_PANE,
- "web-view", web_view, NULL);
-}
-
-EWebView *
-e_preview_pane_get_web_view (EPreviewPane *preview_pane)
-{
- g_return_val_if_fail (E_IS_PREVIEW_PANE (preview_pane), NULL);
-
- return E_WEB_VIEW (preview_pane->priv->web_view);
-}
-
-ESearchBar *
-e_preview_pane_get_search_bar (EPreviewPane *preview_pane)
-{
- g_return_val_if_fail (E_IS_PREVIEW_PANE (preview_pane), NULL);
-
- return E_SEARCH_BAR (preview_pane->priv->search_bar);
-}
-
-void
-e_preview_pane_clear_alerts (EPreviewPane *preview_pane)
-{
- g_return_if_fail (E_IS_PREVIEW_PANE (preview_pane));
-
- e_alert_bar_clear (E_ALERT_BAR (preview_pane->priv->alert_bar));
-}
-
-void
-e_preview_pane_show_search_bar (EPreviewPane *preview_pane)
-{
- g_return_if_fail (E_IS_PREVIEW_PANE (preview_pane));
-
- g_signal_emit (preview_pane, signals[SHOW_SEARCH_BAR], 0);
-}
diff --git a/widgets/misc/e-preview-pane.h b/widgets/misc/e-preview-pane.h
deleted file mode 100644
index 01e216c1cc..0000000000
--- a/widgets/misc/e-preview-pane.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * e-preview-pane.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_PREVIEW_PANE_H
-#define E_PREVIEW_PANE_H
-
-#include <gtk/gtk.h>
-#include <misc/e-search-bar.h>
-#include <misc/e-web-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_PREVIEW_PANE \
- (e_preview_pane_get_type ())
-#define E_PREVIEW_PANE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_PREVIEW_PANE, EPreviewPane))
-#define E_PREVIEW_PANE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_PREVIEW_PANE, EPreviewPaneClass))
-#define E_IS_PREVIEW_PANE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_PREVIEW_PANE))
-#define E_IS_PREVIEW_PANE_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_PREVIEW_PANE))
-#define E_PREVIEW_PANE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_PREVIEW_PANE, EPreviewPaneClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EPreviewPane EPreviewPane;
-typedef struct _EPreviewPaneClass EPreviewPaneClass;
-typedef struct _EPreviewPanePrivate EPreviewPanePrivate;
-
-struct _EPreviewPane {
- GtkBox parent;
- EPreviewPanePrivate *priv;
-};
-
-struct _EPreviewPaneClass {
- GtkBoxClass parent_class;
-
- /* Signals */
- void (*show_search_bar) (EPreviewPane *preview_pane);
-};
-
-GType e_preview_pane_get_type (void);
-GtkWidget * e_preview_pane_new (EWebView *web_view);
-EWebView * e_preview_pane_get_web_view (EPreviewPane *preview_pane);
-ESearchBar * e_preview_pane_get_search_bar (EPreviewPane *preview_pane);
-void e_preview_pane_clear_alerts (EPreviewPane *preview_pane);
-void e_preview_pane_show_search_bar (EPreviewPane *preview_pane);
-
-G_END_DECLS
-
-#endif /* E_PREVIEW_PANE_H */
diff --git a/widgets/misc/e-printable.c b/widgets/misc/e-printable.c
deleted file mode 100644
index 2e98143b1a..0000000000
--- a/widgets/misc/e-printable.c
+++ /dev/null
@@ -1,226 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include "e-util/e-util.h"
-
-#include "e-printable.h"
-
-#define EP_CLASS(e) ((EPrintableClass *)((GObject *)e)->class)
-
-G_DEFINE_TYPE (
- EPrintable,
- e_printable,
- G_TYPE_INITIALLY_UNOWNED)
-
-enum {
- PRINT_PAGE,
- DATA_LEFT,
- RESET,
- HEIGHT,
- WILL_FIT,
- LAST_SIGNAL
-};
-
-static guint e_printable_signals[LAST_SIGNAL] = { 0, };
-
-static void
-e_printable_class_init (EPrintableClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- e_printable_signals[PRINT_PAGE] = g_signal_new (
- "print_page",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EPrintableClass, print_page),
- NULL, NULL,
- e_marshal_NONE__OBJECT_DOUBLE_DOUBLE_BOOLEAN,
- G_TYPE_NONE, 4,
- G_TYPE_OBJECT,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_BOOLEAN);
-
- e_printable_signals[DATA_LEFT] = g_signal_new (
- "data_left",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EPrintableClass, data_left),
- NULL, NULL,
- e_marshal_BOOLEAN__NONE,
- G_TYPE_BOOLEAN, 0,
- G_TYPE_NONE);
-
- e_printable_signals[RESET] = g_signal_new (
- "reset",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EPrintableClass, reset),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0,
- G_TYPE_NONE);
-
- e_printable_signals[HEIGHT] = g_signal_new (
- "height",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EPrintableClass, height),
- NULL, NULL,
- e_marshal_DOUBLE__OBJECT_DOUBLE_DOUBLE_BOOLEAN,
- G_TYPE_DOUBLE, 4,
- G_TYPE_OBJECT,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_BOOLEAN);
-
- e_printable_signals[WILL_FIT] = g_signal_new (
- "will_fit",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EPrintableClass, will_fit),
- NULL, NULL,
- e_marshal_BOOLEAN__OBJECT_DOUBLE_DOUBLE_BOOLEAN,
- G_TYPE_BOOLEAN, 4,
- G_TYPE_OBJECT,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_BOOLEAN);
-
- class->print_page = NULL;
- class->data_left = NULL;
- class->reset = NULL;
- class->height = NULL;
- class->will_fit = NULL;
-}
-
-static void
-e_printable_init (EPrintable *e_printable)
-{
- /* nothing to do */
-}
-
-EPrintable *
-e_printable_new (void)
-{
- return E_PRINTABLE (g_object_new (E_PRINTABLE_TYPE, NULL));
-}
-
-void
-e_printable_print_page (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble height,
- gboolean quantized)
-{
- g_return_if_fail (e_printable != NULL);
- g_return_if_fail (E_IS_PRINTABLE (e_printable));
-
- g_signal_emit (
- e_printable,
- e_printable_signals[PRINT_PAGE], 0,
- context,
- width,
- height,
- quantized);
-}
-
-gboolean
-e_printable_data_left (EPrintable *e_printable)
-{
- gboolean ret_val;
-
- g_return_val_if_fail (e_printable != NULL, FALSE);
- g_return_val_if_fail (E_IS_PRINTABLE (e_printable), FALSE);
-
- g_signal_emit (
- e_printable,
- e_printable_signals[DATA_LEFT], 0,
- &ret_val);
-
- return ret_val;
-}
-
-void
-e_printable_reset (EPrintable *e_printable)
-{
- g_return_if_fail (e_printable != NULL);
- g_return_if_fail (E_IS_PRINTABLE (e_printable));
-
- g_signal_emit (
- e_printable,
- e_printable_signals[RESET], 0);
-}
-
-gdouble
-e_printable_height (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble max_height,
- gboolean quantized)
-{
- gdouble ret_val;
-
- g_return_val_if_fail (e_printable != NULL, -1);
- g_return_val_if_fail (E_IS_PRINTABLE (e_printable), -1);
-
- g_signal_emit (
- e_printable,
- e_printable_signals[HEIGHT], 0,
- context,
- width,
- max_height,
- quantized,
- &ret_val);
-
- return ret_val;
-}
-
-gboolean
-e_printable_will_fit (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble max_height,
- gboolean quantized)
-{
- gboolean ret_val;
-
- g_return_val_if_fail (e_printable != NULL, FALSE);
- g_return_val_if_fail (E_IS_PRINTABLE (e_printable), FALSE);
-
- g_signal_emit (
- e_printable,
- e_printable_signals[WILL_FIT], 0,
- context,
- width,
- max_height,
- quantized,
- &ret_val);
-
- return ret_val;
-}
diff --git a/widgets/misc/e-printable.h b/widgets/misc/e-printable.h
deleted file mode 100644
index b8d9893799..0000000000
--- a/widgets/misc/e-printable.h
+++ /dev/null
@@ -1,89 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_PRINTABLE_H_
-#define _E_PRINTABLE_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define E_PRINTABLE_TYPE (e_printable_get_type ())
-#define E_PRINTABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_PRINTABLE_TYPE, EPrintable))
-#define E_PRINTABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_PRINTABLE_TYPE, EPrintableClass))
-#define E_IS_PRINTABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_PRINTABLE_TYPE))
-#define E_IS_PRINTABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_PRINTABLE_TYPE))
-
-typedef struct {
- GObject base;
-} EPrintable;
-
-typedef struct {
- GObjectClass parent_class;
-
- /*
- * Signals
- */
-
- void (*print_page) (EPrintable *etm, GtkPrintContext *context, gdouble width, gdouble height, gboolean quantized);
- gboolean (*data_left) (EPrintable *etm);
- void (*reset) (EPrintable *etm);
- gdouble (*height) (EPrintable *etm, GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantized);
-
- /* e_printable_will_fit (ep, ...) should be equal in value to
- * (e_printable_print_page (ep, ...),
- * !e_printable_data_left(ep)) except that the latter has the
- * side effect of doing the printing and advancing the
- * position of the printable.
- */
-
- gboolean (*will_fit) (EPrintable *etm, GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantized);
-} EPrintableClass;
-
-GType e_printable_get_type (void);
-
-EPrintable *e_printable_new (void);
-
-/*
- * Routines for emitting signals on the e_table */
-void e_printable_print_page (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble height,
- gboolean quantized);
-gboolean e_printable_data_left (EPrintable *e_printable);
-void e_printable_reset (EPrintable *e_printable);
-gdouble e_printable_height (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble max_height,
- gboolean quantized);
-gboolean e_printable_will_fit (EPrintable *e_printable,
- GtkPrintContext *context,
- gdouble width,
- gdouble max_height,
- gboolean quantized);
-
-G_END_DECLS
-
-#endif /* _E_PRINTABLE_H_ */
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
deleted file mode 100644
index 9ed0c2d1c9..0000000000
--- a/widgets/misc/e-search-bar.c
+++ /dev/null
@@ -1,771 +0,0 @@
-/*
- * e-search-bar.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-search-bar.h"
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-
-#define E_SEARCH_BAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SEARCH_BAR, ESearchBarPrivate))
-
-struct _ESearchBarPrivate {
- EWebView *web_view;
- GtkWidget *entry;
- GtkWidget *case_sensitive_button;
- GtkWidget *wrapped_next_box;
- GtkWidget *wrapped_prev_box;
- GtkWidget *matches_label;
-
- gchar *active_search;
-
- guint rerun_search : 1;
-};
-
-enum {
- PROP_0,
- PROP_ACTIVE_SEARCH,
- PROP_CASE_SENSITIVE,
- PROP_TEXT,
- PROP_WEB_VIEW
-};
-
-enum {
- CHANGED,
- CLEAR,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (
- ESearchBar,
- e_search_bar,
- GTK_TYPE_HBOX)
-
-static void
-search_bar_update_matches (ESearchBar *search_bar,
- guint matches)
-{
- GtkWidget *matches_label;
- gchar *text;
-
- search_bar->priv->rerun_search = FALSE;
- matches_label = search_bar->priv->matches_label;
-
- text = g_strdup_printf (_("Matches: %u"), matches);
- gtk_label_set_text (GTK_LABEL (matches_label), text);
- gtk_widget_show (matches_label);
- g_free (text);
-}
-
-static void
-search_bar_update_highlights (ESearchBar *search_bar)
-{
- EWebView *web_view;
- gboolean visible;
-
- web_view = e_search_bar_get_web_view (search_bar);
-
- visible = gtk_widget_get_visible (GTK_WIDGET (search_bar));
-
- webkit_web_view_set_highlight_text_matches (
- WEBKIT_WEB_VIEW (web_view), visible);
-
- e_search_bar_changed (search_bar);
-}
-
-static void
-search_bar_find (ESearchBar *search_bar,
- gboolean search_forward)
-{
- EWebView *web_view;
- GtkWidget *widget;
- gboolean case_sensitive;
- gboolean new_search;
- gboolean wrapped = FALSE;
- gboolean success;
- gchar *text;
-
- web_view = e_search_bar_get_web_view (search_bar);
- case_sensitive = e_search_bar_get_case_sensitive (search_bar);
- text = e_search_bar_get_text (search_bar);
-
- if (text == NULL || *text == '\0') {
- e_search_bar_clear (search_bar);
- g_free (text);
- return;
- }
-
- new_search =
- (search_bar->priv->active_search == NULL) ||
- (g_strcmp0 (text, search_bar->priv->active_search) != 0);
-
- if (new_search) {
- guint matches;
-
- webkit_web_view_unmark_text_matches (
- WEBKIT_WEB_VIEW (web_view));
- matches = webkit_web_view_mark_text_matches (
- WEBKIT_WEB_VIEW (web_view),
- text, case_sensitive, 0);
- webkit_web_view_set_highlight_text_matches (
- WEBKIT_WEB_VIEW (web_view), TRUE);
- search_bar_update_matches (search_bar, matches);
- }
-
- success = webkit_web_view_search_text (
- WEBKIT_WEB_VIEW (web_view),
- text, case_sensitive, search_forward, FALSE);
-
- if (!success)
- wrapped = webkit_web_view_search_text (
- WEBKIT_WEB_VIEW (web_view),
- text, case_sensitive, search_forward, TRUE);
-
- g_free (search_bar->priv->active_search);
- search_bar->priv->active_search = text;
-
- g_object_notify (G_OBJECT (search_bar), "active-search");
-
- /* Update wrapped label visibility. */
-
- widget = search_bar->priv->wrapped_next_box;
-
- if (wrapped && search_forward)
- gtk_widget_show (widget);
- else
- gtk_widget_hide (widget);
-
- widget = search_bar->priv->wrapped_prev_box;
-
- if (wrapped && !search_forward)
- gtk_widget_show (widget);
- else
- gtk_widget_hide (widget);
-}
-
-static void
-search_bar_changed_cb (ESearchBar *search_bar)
-{
- g_object_notify (G_OBJECT (search_bar), "text");
-}
-
-static void
-search_bar_find_next_cb (ESearchBar *search_bar)
-{
- search_bar_find (search_bar, TRUE);
-}
-
-static void
-search_bar_find_previous_cb (ESearchBar *search_bar)
-{
- search_bar_find (search_bar, FALSE);
-}
-
-static void
-search_bar_icon_release_cb (ESearchBar *search_bar,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event)
-{
- g_return_if_fail (icon_pos == GTK_ENTRY_ICON_SECONDARY);
-
- e_search_bar_clear (search_bar);
- gtk_widget_grab_focus (search_bar->priv->entry);
-}
-
-static void
-search_bar_toggled_cb (ESearchBar *search_bar)
-{
- g_free (search_bar->priv->active_search);
- search_bar->priv->active_search = NULL;
-
- g_object_notify (G_OBJECT (search_bar), "active-search");
- g_object_notify (G_OBJECT (search_bar), "case-sensitive");
-}
-
-static void
-search_bar_set_web_view (ESearchBar *search_bar,
- EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_return_if_fail (search_bar->priv->web_view == NULL);
-
- search_bar->priv->web_view = g_object_ref (web_view);
-}
-
-static void
-search_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CASE_SENSITIVE:
- e_search_bar_set_case_sensitive (
- E_SEARCH_BAR (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_TEXT:
- e_search_bar_set_text (
- E_SEARCH_BAR (object),
- g_value_get_string (value));
- return;
-
- case PROP_WEB_VIEW:
- search_bar_set_web_view (
- E_SEARCH_BAR (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-search_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACTIVE_SEARCH:
- g_value_set_boolean (
- value, e_search_bar_get_active_search (
- E_SEARCH_BAR (object)));
- return;
-
- case PROP_CASE_SENSITIVE:
- g_value_set_boolean (
- value, e_search_bar_get_case_sensitive (
- E_SEARCH_BAR (object)));
- return;
-
- case PROP_TEXT:
- g_value_take_string (
- value, e_search_bar_get_text (
- E_SEARCH_BAR (object)));
- return;
-
- case PROP_WEB_VIEW:
- g_value_set_object (
- value, e_search_bar_get_web_view (
- E_SEARCH_BAR (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-search_bar_dispose (GObject *object)
-{
- ESearchBarPrivate *priv;
-
- priv = E_SEARCH_BAR_GET_PRIVATE (object);
-
- if (priv->web_view != NULL) {
- g_object_unref (priv->web_view);
- priv->web_view = NULL;
- }
-
- if (priv->entry != NULL) {
- g_object_unref (priv->entry);
- priv->entry = NULL;
- }
-
- if (priv->case_sensitive_button != NULL) {
- g_object_unref (priv->case_sensitive_button);
- priv->case_sensitive_button = NULL;
- }
-
- if (priv->wrapped_next_box != NULL) {
- g_object_unref (priv->wrapped_next_box);
- priv->wrapped_next_box = NULL;
- }
-
- if (priv->wrapped_prev_box != NULL) {
- g_object_unref (priv->wrapped_prev_box);
- priv->wrapped_prev_box = NULL;
- }
-
- if (priv->matches_label != NULL) {
- g_object_unref (priv->matches_label);
- priv->matches_label = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_search_bar_parent_class)->dispose (object);
-}
-
-static void
-search_bar_finalize (GObject *object)
-{
- ESearchBarPrivate *priv;
-
- priv = E_SEARCH_BAR_GET_PRIVATE (object);
-
- g_free (priv->active_search);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_search_bar_parent_class)->finalize (object);
-}
-
-static void
-search_bar_constructed (GObject *object)
-{
- ESearchBarPrivate *priv;
-
- priv = E_SEARCH_BAR_GET_PRIVATE (object);
-
- g_object_bind_property (
- object, "case-sensitive",
- priv->case_sensitive_button, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_search_bar_parent_class)->constructed (object);
-}
-
-static void
-search_bar_show (GtkWidget *widget)
-{
- ESearchBar *search_bar;
-
- search_bar = E_SEARCH_BAR (widget);
-
- /* Chain up to parent's show() method. */
- GTK_WIDGET_CLASS (e_search_bar_parent_class)->show (widget);
-
- gtk_widget_grab_focus (search_bar->priv->entry);
-
- search_bar_update_highlights (search_bar);
-}
-
-static void
-search_bar_hide (GtkWidget *widget)
-{
- ESearchBar *search_bar;
-
- search_bar = E_SEARCH_BAR (widget);
-
- /* Chain up to parent's hide() method. */
- GTK_WIDGET_CLASS (e_search_bar_parent_class)->hide (widget);
-
- search_bar_update_highlights (search_bar);
-}
-
-static gboolean
-search_bar_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- GtkWidgetClass *widget_class;
-
- if (event->keyval == GDK_KEY_Escape) {
- gtk_widget_hide (widget);
- return TRUE;
- }
-
- /* Chain up to parent's key_press_event() method. */
- widget_class = GTK_WIDGET_CLASS (e_search_bar_parent_class);
- return widget_class->key_press_event (widget, event);
-}
-
-static void
-search_bar_clear (ESearchBar *search_bar)
-{
- WebKitWebView *web_view;
-
- g_free (search_bar->priv->active_search);
- search_bar->priv->active_search = NULL;
-
- gtk_entry_set_text (GTK_ENTRY (search_bar->priv->entry), "");
-
- gtk_widget_hide (search_bar->priv->wrapped_next_box);
- gtk_widget_hide (search_bar->priv->wrapped_prev_box);
- gtk_widget_hide (search_bar->priv->matches_label);
-
- search_bar_update_highlights (search_bar);
-
- web_view = WEBKIT_WEB_VIEW (search_bar->priv->web_view);
- webkit_web_view_unmark_text_matches (web_view);
-
- g_object_notify (G_OBJECT (search_bar), "active-search");
-}
-
-static void
-e_search_bar_class_init (ESearchBarClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (ESearchBarPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = search_bar_set_property;
- object_class->get_property = search_bar_get_property;
- object_class->dispose = search_bar_dispose;
- object_class->finalize = search_bar_finalize;
- object_class->constructed = search_bar_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->show = search_bar_show;
- widget_class->hide = search_bar_hide;
- widget_class->key_press_event = search_bar_key_press_event;
-
- class->clear = search_bar_clear;
-
- g_object_class_install_property (
- object_class,
- PROP_ACTIVE_SEARCH,
- g_param_spec_boolean (
- "active-search",
- "Active Search",
- NULL,
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_CASE_SENSITIVE,
- g_param_spec_boolean (
- "case-sensitive",
- "Case Sensitive",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_TEXT,
- g_param_spec_string (
- "text",
- "Search Text",
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_WEB_VIEW,
- g_param_spec_object (
- "web-view",
- "Web View",
- NULL,
- E_TYPE_WEB_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- signals[CHANGED] = g_signal_new (
- "changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ESearchBarClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[CLEAR] = g_signal_new (
- "clear",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ESearchBarClass, clear),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_search_bar_init (ESearchBar *search_bar)
-{
- GtkWidget *label;
- GtkWidget *widget;
- GtkWidget *container;
-
- search_bar->priv = E_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- gtk_box_set_spacing (GTK_BOX (search_bar), 12);
-
- container = GTK_WIDGET (search_bar);
-
- widget = gtk_hbox_new (FALSE, 1);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_button_new ();
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_stock (
- GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
- gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
- gtk_widget_set_tooltip_text (widget, _("Close the find bar"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (gtk_widget_hide), search_bar);
-
- widget = gtk_label_new_with_mnemonic (_("Fin_d:"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 3);
- gtk_widget_show (widget);
-
- label = widget;
-
- widget = gtk_entry_new ();
- gtk_entry_set_icon_from_stock (
- GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY,
- GTK_STOCK_CLEAR);
- gtk_entry_set_icon_tooltip_text (
- GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY,
- _("Clear the search"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
- gtk_widget_set_size_request (widget, 200, -1);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- search_bar->priv->entry = g_object_ref (widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- search_bar, "active-search",
- widget, "secondary-icon-sensitive",
- G_BINDING_SYNC_CREATE);
-
- g_signal_connect_swapped (
- widget, "activate",
- G_CALLBACK (search_bar_find_next_cb), search_bar);
-
- g_signal_connect_swapped (
- widget, "changed",
- G_CALLBACK (search_bar_changed_cb), search_bar);
-
- g_signal_connect_swapped (
- widget, "icon-release",
- G_CALLBACK (search_bar_icon_release_cb), search_bar);
-
- widget = gtk_button_new_with_mnemonic (_("_Previous"));
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_stock (
- GTK_STOCK_GO_BACK, GTK_ICON_SIZE_MENU));
- gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
- gtk_widget_set_tooltip_text (
- widget, _("Find the previous occurrence of the phrase"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- search_bar, "active-search",
- widget, "sensitive",
- G_BINDING_SYNC_CREATE);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (search_bar_find_previous_cb), search_bar);
-
- widget = gtk_button_new_with_mnemonic (_("_Next"));
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_stock (
- GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU));
- gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
- gtk_widget_set_tooltip_text (
- widget, _("Find the next occurrence of the phrase"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- search_bar, "active-search",
- widget, "sensitive",
- G_BINDING_SYNC_CREATE);
-
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (search_bar_find_next_cb), search_bar);
-
- widget = gtk_check_button_new_with_mnemonic (_("Mat_ch case"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- search_bar->priv->case_sensitive_button = g_object_ref (widget);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "toggled",
- G_CALLBACK (search_bar_toggled_cb), search_bar);
-
- g_signal_connect_swapped (
- widget, "toggled",
- G_CALLBACK (search_bar_find_next_cb), search_bar);
-
- container = GTK_WIDGET (search_bar);
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- search_bar->priv->wrapped_next_box = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_icon_name (
- "wrapped", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (
- _("Reached bottom of page, continued from top"));
- gtk_label_set_ellipsize (
- GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = GTK_WIDGET (search_bar);
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- search_bar->priv->wrapped_prev_box = g_object_ref (widget);
- gtk_widget_hide (widget);
-
- container = widget;
-
- widget = gtk_image_new_from_icon_name (
- "wrapped", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (
- _("Reached top of page, continued from bottom"));
- gtk_label_set_ellipsize (
- GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = GTK_WIDGET (search_bar);
-
- widget = gtk_label_new (NULL);
- gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 12);
- search_bar->priv->matches_label = g_object_ref (widget);
- gtk_widget_show (widget);
-}
-
-GtkWidget *
-e_search_bar_new (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return g_object_new (
- E_TYPE_SEARCH_BAR, "web-view", web_view, NULL);
-}
-
-void
-e_search_bar_clear (ESearchBar *search_bar)
-{
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
-
- g_signal_emit (search_bar, signals[CLEAR], 0);
-}
-
-void
-e_search_bar_changed (ESearchBar *search_bar)
-{
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
-
- g_signal_emit (search_bar, signals[CHANGED], 0);
-}
-
-EWebView *
-e_search_bar_get_web_view (ESearchBar *search_bar)
-{
- g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL);
-
- return search_bar->priv->web_view;
-}
-
-gboolean
-e_search_bar_get_active_search (ESearchBar *search_bar)
-{
- g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), FALSE);
-
- return (search_bar->priv->active_search != NULL);
-}
-
-gboolean
-e_search_bar_get_case_sensitive (ESearchBar *search_bar)
-{
- GtkToggleButton *button;
-
- g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), FALSE);
-
- button = GTK_TOGGLE_BUTTON (search_bar->priv->case_sensitive_button);
-
- return gtk_toggle_button_get_active (button);
-}
-
-void
-e_search_bar_set_case_sensitive (ESearchBar *search_bar,
- gboolean case_sensitive)
-{
- GtkToggleButton *button;
-
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
-
- button = GTK_TOGGLE_BUTTON (search_bar->priv->case_sensitive_button);
-
- gtk_toggle_button_set_active (button, case_sensitive);
-
- g_object_notify (G_OBJECT (search_bar), "case-sensitive");
-}
-
-gchar *
-e_search_bar_get_text (ESearchBar *search_bar)
-{
- GtkEntry *entry;
- const gchar *text;
-
- g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL);
-
- entry = GTK_ENTRY (search_bar->priv->entry);
- text = gtk_entry_get_text (entry);
-
- return g_strstrip (g_strdup (text));
-}
-
-void
-e_search_bar_set_text (ESearchBar *search_bar,
- const gchar *text)
-{
- GtkEntry *entry;
-
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
-
- entry = GTK_ENTRY (search_bar->priv->entry);
-
- if (text == NULL)
- text = "";
-
- /* This will trigger a "notify::text" signal. */
- gtk_entry_set_text (entry, text);
-}
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
deleted file mode 100644
index 939a476e17..0000000000
--- a/widgets/misc/e-search-bar.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * e-search-bar.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_SEARCH_BAR_H
-#define E_SEARCH_BAR_H
-
-#include <gtk/gtk.h>
-#include <misc/e-web-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SEARCH_BAR \
- (e_search_bar_get_type ())
-#define E_SEARCH_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SEARCH_BAR, ESearchBar))
-#define E_SEARCH_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SEARCH_BAR, ESearchBarClass))
-#define E_IS_SEARCH_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SEARCH_BAR))
-#define E_IS_SEARCH_BAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SEARCH_BAR))
-#define E_SEARCH_BAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SEARCH_BAR, ESearchBarClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESearchBar ESearchBar;
-typedef struct _ESearchBarClass ESearchBarClass;
-typedef struct _ESearchBarPrivate ESearchBarPrivate;
-
-struct _ESearchBar {
- GtkBox parent;
- ESearchBarPrivate *priv;
-};
-
-struct _ESearchBarClass {
- GtkBoxClass parent_class;
-
- /* Signals */
- void (*changed) (ESearchBar *search_bar);
- void (*clear) (ESearchBar *search_bar);
-};
-
-GType e_search_bar_get_type (void);
-GtkWidget * e_search_bar_new (EWebView *web_view);
-void e_search_bar_clear (ESearchBar *search_bar);
-void e_search_bar_changed (ESearchBar *search_bar);
-EWebView * e_search_bar_get_web_view (ESearchBar *search_bar);
-gboolean e_search_bar_get_active_search
- (ESearchBar *search_bar);
-gboolean e_search_bar_get_case_sensitive
- (ESearchBar *search_bar);
-void e_search_bar_set_case_sensitive
- (ESearchBar *search_bar,
- gboolean case_sensitive);
-gchar * e_search_bar_get_text (ESearchBar *search_bar);
-void e_search_bar_set_text (ESearchBar *search_bar,
- const gchar *text);
-
-G_END_DECLS
-
-#endif /* E_SEARCH_BAR_H */
diff --git a/widgets/misc/e-selectable.c b/widgets/misc/e-selectable.c
deleted file mode 100644
index b8e4337fef..0000000000
--- a/widgets/misc/e-selectable.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * e-selectable.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-selectable.h"
-
-G_DEFINE_INTERFACE (
- ESelectable,
- e_selectable,
- GTK_TYPE_WIDGET)
-
-static void
-e_selectable_default_init (ESelectableInterface *interface)
-{
- g_object_interface_install_property (
- interface,
- g_param_spec_boxed (
- "copy-target-list",
- "Copy Target List",
- NULL,
- GTK_TYPE_TARGET_LIST,
- G_PARAM_READABLE));
-
- g_object_interface_install_property (
- interface,
- g_param_spec_boxed (
- "paste-target-list",
- "Paste Target List",
- NULL,
- GTK_TYPE_TARGET_LIST,
- G_PARAM_READABLE));
-}
-
-void
-e_selectable_update_actions (ESelectable *selectable,
- EFocusTracker *focus_tracker,
- GdkAtom *clipboard_targets,
- gint n_clipboard_targets)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
- g_return_if_fail (interface->update_actions != NULL);
-
- interface->update_actions (
- selectable, focus_tracker,
- clipboard_targets, n_clipboard_targets);
-}
-
-void
-e_selectable_cut_clipboard (ESelectable *selectable)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- if (interface->cut_clipboard != NULL)
- interface->cut_clipboard (selectable);
-}
-
-void
-e_selectable_copy_clipboard (ESelectable *selectable)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- if (interface->copy_clipboard != NULL)
- interface->copy_clipboard (selectable);
-}
-
-void
-e_selectable_paste_clipboard (ESelectable *selectable)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- if (interface->paste_clipboard != NULL)
- interface->paste_clipboard (selectable);
-}
-
-void
-e_selectable_delete_selection (ESelectable *selectable)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- if (interface->delete_selection != NULL)
- interface->delete_selection (selectable);
-}
-
-void
-e_selectable_select_all (ESelectable *selectable)
-{
- ESelectableInterface *interface;
-
- g_return_if_fail (E_IS_SELECTABLE (selectable));
-
- interface = E_SELECTABLE_GET_INTERFACE (selectable);
-
- if (interface->select_all != NULL)
- interface->select_all (selectable);
-}
-
-GtkTargetList *
-e_selectable_get_copy_target_list (ESelectable *selectable)
-{
- GtkTargetList *target_list;
-
- g_return_val_if_fail (E_IS_SELECTABLE (selectable), NULL);
-
- g_object_get (selectable, "copy-target-list", &target_list, NULL);
-
- /* We want to return a borrowed reference to the target
- * list, so undo the reference that g_object_get() added. */
- gtk_target_list_unref (target_list);
-
- return target_list;
-}
-
-GtkTargetList *
-e_selectable_get_paste_target_list (ESelectable *selectable)
-{
- GtkTargetList *target_list;
-
- g_return_val_if_fail (E_IS_SELECTABLE (selectable), NULL);
-
- g_object_get (selectable, "paste-target-list", &target_list, NULL);
-
- /* We want to return a borrowed reference to the target
- * list, so undo the reference that g_object_get() added. */
- gtk_target_list_unref (target_list);
-
- return target_list;
-}
diff --git a/widgets/misc/e-selectable.h b/widgets/misc/e-selectable.h
deleted file mode 100644
index c9a0b6dded..0000000000
--- a/widgets/misc/e-selectable.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * e-selectable.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_SELECTABLE_H
-#define E_SELECTABLE_H
-
-#include <gtk/gtk.h>
-#include <misc/e-focus-tracker.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SELECTABLE \
- (e_selectable_get_type ())
-#define E_SELECTABLE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SELECTABLE, ESelectable))
-#define E_IS_SELECTABLE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SELECTABLE))
-#define E_SELECTABLE_GET_INTERFACE(obj) \
- (G_TYPE_INSTANCE_GET_INTERFACE \
- ((obj), E_TYPE_SELECTABLE, ESelectableInterface))
-
-G_BEGIN_DECLS
-
-typedef struct _ESelectable ESelectable;
-typedef struct _ESelectableInterface ESelectableInterface;
-
-struct _ESelectableInterface {
- GTypeInterface parent_iface;
-
- /* Required Methods */
- void (*update_actions) (ESelectable *selectable,
- EFocusTracker *focus_tracker,
- GdkAtom *clipboard_targets,
- gint n_clipboard_targets);
-
- /* Optional Methods */
- void (*cut_clipboard) (ESelectable *selectable);
- void (*copy_clipboard) (ESelectable *selectable);
- void (*paste_clipboard) (ESelectable *selectable);
- void (*delete_selection) (ESelectable *selectable);
- void (*select_all) (ESelectable *selectable);
-};
-
-GType e_selectable_get_type (void);
-void e_selectable_update_actions (ESelectable *selectable,
- EFocusTracker *focus_tracker,
- GdkAtom *clipboard_targets,
- gint n_clipboard_targets);
-void e_selectable_cut_clipboard (ESelectable *selectable);
-void e_selectable_copy_clipboard (ESelectable *selectable);
-void e_selectable_paste_clipboard (ESelectable *selectable);
-void e_selectable_delete_selection (ESelectable *selectable);
-void e_selectable_select_all (ESelectable *selectable);
-GtkTargetList * e_selectable_get_copy_target_list
- (ESelectable *selectable);
-GtkTargetList * e_selectable_get_paste_target_list
- (ESelectable *selectable);
-
-G_END_DECLS
-
-#endif /* E_SELECTABLE_H */
diff --git a/widgets/misc/e-selection-model-array.c b/widgets/misc/e-selection-model-array.c
deleted file mode 100644
index f2f5b93379..0000000000
--- a/widgets/misc/e-selection-model-array.c
+++ /dev/null
@@ -1,647 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include <glib/gi18n.h>
-#include "e-util/e-util.h"
-
-#include "e-selection-model-array.h"
-
-G_DEFINE_TYPE (
- ESelectionModelArray,
- e_selection_model_array,
- E_TYPE_SELECTION_MODEL)
-
-enum {
- PROP_0,
- PROP_CURSOR_ROW,
- PROP_CURSOR_COL
-};
-
-void
-e_selection_model_array_confirm_row_count (ESelectionModelArray *esma)
-{
- if (esma->eba == NULL) {
- gint row_count = e_selection_model_array_get_row_count (esma);
- esma->eba = e_bit_array_new (row_count);
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- }
-}
-
-static gint
-es_row_model_to_sorted (ESelectionModelArray *esma,
- gint model_row)
-{
- if (model_row >= 0 && esma && esma->base.sorter && e_sorter_needs_sorting (esma->base.sorter))
- return e_sorter_model_to_sorted (esma->base.sorter, model_row);
-
- return model_row;
-}
-
-static gint
-es_row_sorted_to_model (ESelectionModelArray *esma,
- gint sorted_row)
-{
- if (sorted_row >= 0 && esma && esma->base.sorter && e_sorter_needs_sorting (esma->base.sorter))
- return e_sorter_sorted_to_model (esma->base.sorter, sorted_row);
-
- return sorted_row;
-}
-
-/* FIXME: Should this deal with moving the selection if it's in single mode? */
-void
-e_selection_model_array_delete_rows (ESelectionModelArray *esma,
- gint row,
- gint count)
-{
- if (esma->eba) {
- if (E_SELECTION_MODEL (esma)->mode == GTK_SELECTION_SINGLE)
- e_bit_array_delete_single_mode (esma->eba, row, count);
- else
- e_bit_array_delete (esma->eba, row, count);
-
- if (esma->cursor_row >= row && esma->cursor_row < row + count) {
- /* we should move the cursor_row, because some lines before us are going to be removed */
- if (esma->cursor_row_sorted >= e_bit_array_bit_count (esma->eba)) {
- esma->cursor_row_sorted = e_bit_array_bit_count (esma->eba) - 1;
- }
-
- if (esma->cursor_row_sorted >= 0) {
- esma->cursor_row = es_row_sorted_to_model (esma, esma->cursor_row_sorted);
- esma->selection_start_row = 0;
- e_bit_array_change_one_row (esma->eba, esma->cursor_row, TRUE);
- } else {
- esma->cursor_row = -1;
- esma->cursor_row_sorted = -1;
- esma->selection_start_row = 0;
- }
- } else {
- /* some code earlier changed the selected row, so just update the sorted one */
- if (esma->cursor_row >= row)
- esma->cursor_row = MAX (0, esma->cursor_row - count);
-
- if (esma->cursor_row >= e_bit_array_bit_count (esma->eba))
- esma->cursor_row = e_bit_array_bit_count (esma->eba) - 1;
-
- if (esma->cursor_row >= 0) {
- esma->cursor_row_sorted = es_row_model_to_sorted (esma, esma->cursor_row);
- esma->selection_start_row = 0;
- e_bit_array_change_one_row (esma->eba, esma->cursor_row, TRUE);
- } else {
- esma->cursor_row = -1;
- esma->cursor_row_sorted = -1;
- esma->selection_start_row = 0;
- }
- }
-
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (E_SELECTION_MODEL (esma));
- e_selection_model_cursor_changed (E_SELECTION_MODEL (esma), esma->cursor_row, esma->cursor_col);
- }
-}
-
-void
-e_selection_model_array_insert_rows (ESelectionModelArray *esma,
- gint row,
- gint count)
-{
- if (esma->eba) {
- e_bit_array_insert (esma->eba, row, count);
-
- /* just recalculate new position of the previously set cursor row */
- esma->cursor_row = es_row_sorted_to_model (esma, esma->cursor_row_sorted);
-
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (E_SELECTION_MODEL (esma));
- e_selection_model_cursor_changed (E_SELECTION_MODEL (esma), esma->cursor_row, esma->cursor_col);
- }
-}
-
-void
-e_selection_model_array_move_row (ESelectionModelArray *esma,
- gint old_row,
- gint new_row)
-{
- ESelectionModel *esm = E_SELECTION_MODEL (esma);
-
- if (esma->eba) {
- gboolean selected = e_bit_array_value_at (esma->eba, old_row);
- gboolean cursor = (esma->cursor_row == old_row);
- gint old_row_sorted, new_row_sorted;
-
- old_row_sorted = es_row_model_to_sorted (esma, old_row);
- new_row_sorted = es_row_model_to_sorted (esma, new_row);
-
- if (old_row_sorted < esma->cursor_row_sorted && esma->cursor_row_sorted < new_row_sorted)
- esma->cursor_row_sorted--;
- else if (new_row_sorted < esma->cursor_row_sorted && esma->cursor_row_sorted < old_row_sorted)
- esma->cursor_row_sorted++;
-
- e_bit_array_move_row (esma->eba, old_row, new_row);
-
- if (selected) {
- if (esm->mode == GTK_SELECTION_SINGLE)
- e_bit_array_select_single_row (esma->eba, new_row);
- else
- e_bit_array_change_one_row (esma->eba, new_row, TRUE);
- }
- if (cursor) {
- esma->cursor_row = new_row;
- esma->cursor_row_sorted = es_row_model_to_sorted (esma, esma->cursor_row);
- } else
- esma->cursor_row = es_row_sorted_to_model (esma, esma->cursor_row_sorted);
-
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (esm);
- e_selection_model_cursor_changed (esm, esma->cursor_row, esma->cursor_col);
- }
-}
-
-static void
-esma_dispose (GObject *object)
-{
- ESelectionModelArray *esma;
-
- esma = E_SELECTION_MODEL_ARRAY (object);
-
- if (esma->eba) {
- g_object_unref (esma->eba);
- esma->eba = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_selection_model_array_parent_class)->dispose (object);
-}
-
-static void
-esma_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (object);
-
- switch (property_id) {
- case PROP_CURSOR_ROW:
- g_value_set_int (value, esma->cursor_row);
- break;
-
- case PROP_CURSOR_COL:
- g_value_set_int (value, esma->cursor_col);
- break;
- }
-}
-
-static void
-esma_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ESelectionModel *esm = E_SELECTION_MODEL (object);
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (object);
-
- switch (property_id) {
- case PROP_CURSOR_ROW:
- e_selection_model_do_something (esm, g_value_get_int (value), esma->cursor_col, 0);
- break;
-
- case PROP_CURSOR_COL:
- e_selection_model_do_something (esm, esma->cursor_row, g_value_get_int (value), 0);
- break;
- }
-}
-
-/**
- * e_selection_model_is_row_selected
- * @selection: #ESelectionModel to check
- * @n: The row to check
- *
- * This routine calculates whether the given row is selected.
- *
- * Returns: %TRUE if the given row is selected
- */
-static gboolean
-esma_is_row_selected (ESelectionModel *selection,
- gint n)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- if (esma->eba)
- return e_bit_array_value_at (esma->eba, n);
- else
- return FALSE;
-}
-
-/**
- * e_selection_model_foreach
- * @selection: #ESelectionModel to traverse
- * @callback: The callback function to call back.
- * @closure: The closure
- *
- * This routine calls the given callback function once for each
- * selected row, passing closure as the closure.
- */
-static void
-esma_foreach (ESelectionModel *selection,
- EForeachFunc callback,
- gpointer closure)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- if (esma->eba)
- e_bit_array_foreach (esma->eba, callback, closure);
-}
-
-/**
- * e_selection_model_clear
- * @selection: #ESelectionModel to clear
- *
- * This routine clears the selection to no rows selected.
- */
-static void
-esma_clear (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- if (esma->eba) {
- g_object_unref (esma->eba);
- esma->eba = NULL;
- }
- esma->cursor_row = -1;
- esma->cursor_col = -1;
- esma->cursor_row_sorted = -1;
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (E_SELECTION_MODEL (esma));
- e_selection_model_cursor_changed (E_SELECTION_MODEL (esma), -1, -1);
-}
-
-#define PART(x,n) (((x) & (0x01010101 << n)) >> n)
-#define SECTION(x, n) (((x) >> (n * 8)) & 0xff)
-
-/**
- * e_selection_model_selected_count
- * @selection: #ESelectionModel to count
- *
- * This routine calculates the number of rows selected.
- *
- * Returns: The number of rows selected in the given model.
- */
-static gint
-esma_selected_count (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- if (esma->eba)
- return e_bit_array_selected_count (esma->eba);
- else
- return 0;
-}
-
-/**
- * e_selection_model_select_all
- * @selection: #ESelectionModel to select all
- *
- * This routine selects all the rows in the given
- * #ESelectionModel.
- */
-static void
-esma_select_all (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
-
- e_selection_model_array_confirm_row_count (esma);
-
- e_bit_array_select_all (esma->eba);
-
- esma->cursor_col = 0;
- esma->cursor_row_sorted = 0;
- esma->cursor_row = es_row_sorted_to_model (esma, esma->cursor_row_sorted);
- esma->selection_start_row = esma->cursor_row;
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (E_SELECTION_MODEL (esma));
- e_selection_model_cursor_changed (E_SELECTION_MODEL (esma), 0, 0);
-}
-
-/**
- * e_selection_model_invert_selection
- * @selection: #ESelectionModel to invert
- *
- * This routine inverts all the rows in the given
- * #ESelectionModel.
- */
-static void
-esma_invert_selection (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
-
- e_selection_model_array_confirm_row_count (esma);
-
- e_bit_array_invert_selection (esma->eba);
-
- esma->cursor_col = -1;
- esma->cursor_row = -1;
- esma->cursor_row_sorted = -1;
- esma->selection_start_row = 0;
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_changed (E_SELECTION_MODEL (esma));
- e_selection_model_cursor_changed (E_SELECTION_MODEL (esma), -1, -1);
-}
-
-static gint
-esma_row_count (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- e_selection_model_array_confirm_row_count (esma);
- return e_bit_array_bit_count (esma->eba);
-}
-
-static void
-esma_change_one_row (ESelectionModel *selection,
- gint row,
- gboolean grow)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- e_selection_model_array_confirm_row_count (esma);
- e_bit_array_change_one_row (esma->eba, row, grow);
-}
-
-static void
-esma_change_cursor (ESelectionModel *selection,
- gint row,
- gint col)
-{
- ESelectionModelArray *esma;
-
- g_return_if_fail (selection != NULL);
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- esma = E_SELECTION_MODEL_ARRAY (selection);
-
- esma->cursor_row = row;
- esma->cursor_col = col;
- esma->cursor_row_sorted = es_row_model_to_sorted (esma, esma->cursor_row);
-}
-
-static void
-esma_change_range (ESelectionModel *selection,
- gint start,
- gint end,
- gboolean grow)
-{
- gint i;
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- if (start != end) {
- if (selection->sorter && e_sorter_needs_sorting (selection->sorter)) {
- for (i = start; i < end; i++) {
- e_bit_array_change_one_row (esma->eba, e_sorter_sorted_to_model (selection->sorter, i), grow);
- }
- } else {
- e_selection_model_array_confirm_row_count (esma);
- e_bit_array_change_range (esma->eba, start, end, grow);
- }
- }
-}
-
-static gint
-esma_cursor_row (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- return esma->cursor_row;
-}
-
-static gint
-esma_cursor_col (ESelectionModel *selection)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- return esma->cursor_col;
-}
-
-static void
-esma_real_select_single_row (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
-
- e_selection_model_array_confirm_row_count (esma);
-
- e_bit_array_select_single_row (esma->eba, row);
-
- esma->selection_start_row = row;
- esma->selected_row = row;
- esma->selected_range_end = row;
-}
-
-static void
-esma_select_single_row (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- gint selected_row = esma->selected_row;
- esma_real_select_single_row (selection, row);
-
- if (selected_row != -1 && esma->eba && selected_row < e_bit_array_bit_count (esma->eba)) {
- if (selected_row != row) {
- e_selection_model_selection_row_changed (selection, selected_row);
- e_selection_model_selection_row_changed (selection, row);
- }
- } else {
- e_selection_model_selection_changed (selection);
- }
-}
-
-static void
-esma_toggle_single_row (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
-
- e_selection_model_array_confirm_row_count (esma);
- e_bit_array_toggle_single_row (esma->eba, row);
-
- esma->selection_start_row = row;
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- e_selection_model_selection_row_changed (E_SELECTION_MODEL (esma), row);
-}
-
-static void
-esma_real_move_selection_end (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- gint old_start;
- gint old_end;
- gint new_start;
- gint new_end;
- if (selection->sorter && e_sorter_needs_sorting (selection->sorter)) {
- old_start = MIN (
- e_sorter_model_to_sorted (selection->sorter, esma->selection_start_row),
- e_sorter_model_to_sorted (selection->sorter, esma->cursor_row));
- old_end = MAX (
- e_sorter_model_to_sorted (selection->sorter, esma->selection_start_row),
- e_sorter_model_to_sorted (selection->sorter, esma->cursor_row)) + 1;
- new_start = MIN (
- e_sorter_model_to_sorted (selection->sorter, esma->selection_start_row),
- e_sorter_model_to_sorted (selection->sorter, row));
- new_end = MAX (
- e_sorter_model_to_sorted (selection->sorter, esma->selection_start_row),
- e_sorter_model_to_sorted (selection->sorter, row)) + 1;
- } else {
- old_start = MIN (esma->selection_start_row, esma->cursor_row);
- old_end = MAX (esma->selection_start_row, esma->cursor_row) + 1;
- new_start = MIN (esma->selection_start_row, row);
- new_end = MAX (esma->selection_start_row, row) + 1;
- }
- /* This wouldn't work nearly so smoothly if one end of the selection weren't held in place. */
- if (old_start < new_start)
- esma_change_range (selection, old_start, new_start, FALSE);
- if (new_start < old_start)
- esma_change_range (selection, new_start, old_start, TRUE);
- if (old_end < new_end)
- esma_change_range (selection, old_end, new_end, TRUE);
- if (new_end < old_end)
- esma_change_range (selection, new_end, old_end, FALSE);
- esma->selected_row = -1;
- esma->selected_range_end = -1;
-}
-
-static void
-esma_move_selection_end (ESelectionModel *selection,
- gint row)
-{
- esma_real_move_selection_end (selection, row);
- e_selection_model_selection_changed (selection);
-}
-
-static void
-esma_set_selection_end (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (selection);
- gint selected_range_end = esma->selected_range_end;
- gint view_row = e_sorter_model_to_sorted (selection->sorter, row);
-
- esma_real_select_single_row (selection, esma->selection_start_row);
- esma->cursor_row = esma->selection_start_row;
- esma->cursor_row_sorted = es_row_model_to_sorted (esma, esma->cursor_row);
- esma_real_move_selection_end (selection, row);
-
- esma->selected_range_end = view_row;
- if (selected_range_end != -1 && view_row != -1) {
- if (selected_range_end == view_row - 1 ||
- selected_range_end == view_row + 1) {
- e_selection_model_selection_row_changed (selection, selected_range_end);
- e_selection_model_selection_row_changed (selection, view_row);
- }
- }
- e_selection_model_selection_changed (selection);
-}
-
-gint
-e_selection_model_array_get_row_count (ESelectionModelArray *esma)
-{
- g_return_val_if_fail (esma != NULL, 0);
- g_return_val_if_fail (E_IS_SELECTION_MODEL_ARRAY (esma), 0);
-
- if (E_SELECTION_MODEL_ARRAY_GET_CLASS (esma)->get_row_count)
- return E_SELECTION_MODEL_ARRAY_GET_CLASS (esma)->get_row_count (esma);
- else
- return 0;
-}
-
-static void
-e_selection_model_array_init (ESelectionModelArray *esma)
-{
- esma->eba = NULL;
- esma->selection_start_row = 0;
- esma->cursor_row = -1;
- esma->cursor_col = -1;
- esma->cursor_row_sorted = -1;
-
- esma->selected_row = -1;
- esma->selected_range_end = -1;
-}
-
-static void
-e_selection_model_array_class_init (ESelectionModelArrayClass *class)
-{
- GObjectClass *object_class;
- ESelectionModelClass *esm_class;
-
- object_class = G_OBJECT_CLASS (class);
- esm_class = E_SELECTION_MODEL_CLASS (class);
-
- object_class->dispose = esma_dispose;
- object_class->get_property = esma_get_property;
- object_class->set_property = esma_set_property;
-
- esm_class->is_row_selected = esma_is_row_selected;
- esm_class->foreach = esma_foreach;
- esm_class->clear = esma_clear;
- esm_class->selected_count = esma_selected_count;
- esm_class->select_all = esma_select_all;
- esm_class->invert_selection = esma_invert_selection;
- esm_class->row_count = esma_row_count;
-
- esm_class->change_one_row = esma_change_one_row;
- esm_class->change_cursor = esma_change_cursor;
- esm_class->cursor_row = esma_cursor_row;
- esm_class->cursor_col = esma_cursor_col;
-
- esm_class->select_single_row = esma_select_single_row;
- esm_class->toggle_single_row = esma_toggle_single_row;
- esm_class->move_selection_end = esma_move_selection_end;
- esm_class->set_selection_end = esma_set_selection_end;
-
- class->get_row_count = NULL;
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_ROW,
- g_param_spec_int (
- "cursor_row",
- "Cursor Row",
- NULL,
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_COL,
- g_param_spec_int (
- "cursor_col",
- "Cursor Column",
- NULL,
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
-}
-
diff --git a/widgets/misc/e-selection-model-array.h b/widgets/misc/e-selection-model-array.h
deleted file mode 100644
index 4e59789d95..0000000000
--- a/widgets/misc/e-selection-model-array.h
+++ /dev/null
@@ -1,91 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_SELECTION_MODEL_ARRAY_H_
-#define _E_SELECTION_MODEL_ARRAY_H_
-
-#include <misc/e-selection-model.h>
-#include <e-util/e-bit-array.h>
-
-G_BEGIN_DECLS
-
-#define E_SELECTION_MODEL_ARRAY_TYPE (e_selection_model_array_get_type ())
-#define E_SELECTION_MODEL_ARRAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SELECTION_MODEL_ARRAY_TYPE, ESelectionModelArray))
-#define E_SELECTION_MODEL_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SELECTION_MODEL_ARRAY_TYPE, ESelectionModelArrayClass))
-#define E_IS_SELECTION_MODEL_ARRAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SELECTION_MODEL_ARRAY_TYPE))
-#define E_IS_SELECTION_MODEL_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SELECTION_MODEL_ARRAY_TYPE))
-#define E_SELECTION_MODEL_ARRAY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_SELECTION_MODEL_ARRAY_TYPE, ESelectionModelArrayClass))
-
-typedef struct {
- ESelectionModel base;
-
- EBitArray *eba;
-
- gint cursor_row;
- gint cursor_col;
- gint selection_start_row;
- gint cursor_row_sorted; /* cursor_row passed through base::sorter if necessary */
-
- guint model_changed_id;
- guint model_row_inserted_id, model_row_deleted_id;
-
- /* Anything other than -1 means that the selection is a single
- * row. This being -1 does not impart any information. */
- gint selected_row;
- /* Anything other than -1 means that the selection is a all
- * rows between selection_start_path and cursor_path where
- * selected_range_end is the rwo number of cursor_path. This
- * being -1 does not impart any information. */
- gint selected_range_end;
-
- guint frozen : 1;
- guint selection_model_changed : 1;
- guint group_info_changed : 1;
-} ESelectionModelArray;
-
-typedef struct {
- ESelectionModelClass parent_class;
-
- gint (*get_row_count) (ESelectionModelArray *selection);
-} ESelectionModelArrayClass;
-
-GType e_selection_model_array_get_type (void);
-
-/* Protected Functions */
-void e_selection_model_array_insert_rows (ESelectionModelArray *esm,
- gint row,
- gint count);
-void e_selection_model_array_delete_rows (ESelectionModelArray *esm,
- gint row,
- gint count);
-void e_selection_model_array_move_row (ESelectionModelArray *esm,
- gint old_row,
- gint new_row);
-void e_selection_model_array_confirm_row_count (ESelectionModelArray *esm);
-
-/* Protected Virtual Function */
-gint e_selection_model_array_get_row_count (ESelectionModelArray *esm);
-
-G_END_DECLS
-
-#endif /* _E_SELECTION_MODEL_ARRAY_H_ */
diff --git a/widgets/misc/e-selection-model-simple.c b/widgets/misc/e-selection-model-simple.c
deleted file mode 100644
index e7bd0c2f16..0000000000
--- a/widgets/misc/e-selection-model-simple.c
+++ /dev/null
@@ -1,119 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-util/e-util.h"
-
-#include "e-selection-model-array.h"
-#include "e-selection-model-simple.h"
-
-static gint esms_get_row_count (ESelectionModelArray *esma);
-
-G_DEFINE_TYPE (
- ESelectionModelSimple,
- e_selection_model_simple,
- E_SELECTION_MODEL_ARRAY_TYPE)
-
-static void
-e_selection_model_simple_init (ESelectionModelSimple *selection)
-{
- selection->row_count = 0;
-}
-
-static void
-e_selection_model_simple_class_init (ESelectionModelSimpleClass *class)
-{
- ESelectionModelArrayClass *esma_class;
-
- esma_class = E_SELECTION_MODEL_ARRAY_CLASS (class);
- esma_class->get_row_count = esms_get_row_count;
-}
-
-/**
- * e_selection_model_simple_new
- *
- * This routine creates a new #ESelectionModelSimple.
- *
- * Returns: The new #ESelectionModelSimple.
- */
-ESelectionModelSimple *
-e_selection_model_simple_new (void)
-{
- return g_object_new (E_SELECTION_MODEL_SIMPLE_TYPE, NULL);
-}
-
-void
-e_selection_model_simple_set_row_count (ESelectionModelSimple *esms,
- gint row_count)
-{
- if (esms->row_count != row_count) {
- ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (esms);
- if (esma->eba)
- g_object_unref (esma->eba);
- esma->eba = NULL;
- esma->selected_row = -1;
- esma->selected_range_end = -1;
- }
-
- esms->row_count = row_count;
-}
-
-static gint
-esms_get_row_count (ESelectionModelArray *esma)
-{
- ESelectionModelSimple *esms = E_SELECTION_MODEL_SIMPLE (esma);
-
- return esms->row_count;
-}
-
-void
-e_selection_model_simple_insert_rows (ESelectionModelSimple *esms,
- gint row,
- gint count)
-{
- esms->row_count += count;
- e_selection_model_array_insert_rows (
- E_SELECTION_MODEL_ARRAY (esms), row, count);
-}
-
-void
-e_selection_model_simple_delete_rows (ESelectionModelSimple *esms,
- gint row,
- gint count)
-{
- esms->row_count -= count;
- e_selection_model_array_delete_rows (
- E_SELECTION_MODEL_ARRAY (esms), row, count);
-}
-
-void
-e_selection_model_simple_move_row (ESelectionModelSimple *esms,
- gint old_row,
- gint new_row)
-{
- e_selection_model_array_move_row (
- E_SELECTION_MODEL_ARRAY (esms), old_row, new_row);
-}
diff --git a/widgets/misc/e-selection-model-simple.h b/widgets/misc/e-selection-model-simple.h
deleted file mode 100644
index 2433543ade..0000000000
--- a/widgets/misc/e-selection-model-simple.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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_SELECTION_MODEL_SIMPLE_H_
-#define _E_SELECTION_MODEL_SIMPLE_H_
-
-#include <misc/e-selection-model-array.h>
-
-G_BEGIN_DECLS
-
-#define E_SELECTION_MODEL_SIMPLE_TYPE (e_selection_model_simple_get_type ())
-#define E_SELECTION_MODEL_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SELECTION_MODEL_SIMPLE_TYPE, ESelectionModelSimple))
-#define E_SELECTION_MODEL_SIMPLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SELECTION_MODEL_SIMPLE_TYPE, ESelectionModelSimpleClass))
-#define E_IS_SELECTION_MODEL_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SELECTION_MODEL_SIMPLE_TYPE))
-#define E_IS_SELECTION_MODEL_SIMPLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SELECTION_MODEL_SIMPLE_TYPE))
-
-typedef struct {
- ESelectionModelArray parent;
-
- gint row_count;
-} ESelectionModelSimple;
-
-typedef struct {
- ESelectionModelArrayClass parent_class;
-} ESelectionModelSimpleClass;
-
-GType e_selection_model_simple_get_type (void);
-ESelectionModelSimple *e_selection_model_simple_new (void);
-
-void e_selection_model_simple_insert_rows (ESelectionModelSimple *esms,
- gint row,
- gint count);
-void e_selection_model_simple_delete_rows (ESelectionModelSimple *esms,
- gint row,
- gint count);
-void e_selection_model_simple_move_row (ESelectionModelSimple *esms,
- gint old_row,
- gint new_row);
-
-void e_selection_model_simple_set_row_count (ESelectionModelSimple *selection,
- gint row_count);
-
-G_END_DECLS
-
-#endif /* _E_SELECTION_MODEL_SIMPLE_H_ */
-
diff --git a/widgets/misc/e-selection-model.c b/widgets/misc/e-selection-model.c
deleted file mode 100644
index fece615838..0000000000
--- a/widgets/misc/e-selection-model.c
+++ /dev/null
@@ -1,813 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gdk/gdkkeysyms.h>
-
-#include <glib/gi18n.h>
-#include "e-util/e-util.h"
-
-#include "e-selection-model.h"
-
-G_DEFINE_TYPE (
- ESelectionModel,
- e_selection_model,
- G_TYPE_OBJECT)
-
-enum {
- CURSOR_CHANGED,
- CURSOR_ACTIVATED,
- SELECTION_CHANGED,
- SELECTION_ROW_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0, };
-
-enum {
- PROP_0,
- PROP_SORTER,
- PROP_SELECTION_MODE,
- PROP_CURSOR_MODE
-};
-
-inline static void
-add_sorter (ESelectionModel *esm,
- ESorter *sorter)
-{
- esm->sorter = sorter;
- if (sorter) {
- g_object_ref (sorter);
- }
-}
-
-inline static void
-drop_sorter (ESelectionModel *esm)
-{
- if (esm->sorter) {
- g_object_unref (esm->sorter);
- }
- esm->sorter = NULL;
-}
-
-static void
-esm_dispose (GObject *object)
-{
- ESelectionModel *esm;
-
- esm = E_SELECTION_MODEL (object);
-
- drop_sorter (esm);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_selection_model_parent_class)->dispose (object);
-}
-
-static void
-esm_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ESelectionModel *esm = E_SELECTION_MODEL (object);
-
- switch (property_id) {
- case PROP_SORTER:
- g_value_set_object (value, esm->sorter);
- break;
-
- case PROP_SELECTION_MODE:
- g_value_set_int (value, esm->mode);
- break;
-
- case PROP_CURSOR_MODE:
- g_value_set_int (value, esm->cursor_mode);
- break;
- }
-}
-
-static void
-esm_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ESelectionModel *esm = E_SELECTION_MODEL (object);
-
- switch (property_id) {
- case PROP_SORTER:
- drop_sorter (esm);
- add_sorter (
- esm, g_value_get_object (value) ?
- E_SORTER (g_value_get_object (value)) : NULL);
- break;
-
- case PROP_SELECTION_MODE:
- esm->mode = g_value_get_int (value);
- if (esm->mode == GTK_SELECTION_SINGLE) {
- gint cursor_row = e_selection_model_cursor_row (esm);
- gint cursor_col = e_selection_model_cursor_col (esm);
- e_selection_model_do_something (esm, cursor_row, cursor_col, 0);
- }
- break;
-
- case PROP_CURSOR_MODE:
- esm->cursor_mode = g_value_get_int (value);
- break;
- }
-}
-
-static void
-e_selection_model_init (ESelectionModel *selection)
-{
- selection->mode = GTK_SELECTION_MULTIPLE;
- selection->cursor_mode = E_CURSOR_SIMPLE;
- selection->old_selection = -1;
-}
-
-static void
-e_selection_model_class_init (ESelectionModelClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = esm_dispose;
- object_class->get_property = esm_get_property;
- object_class->set_property = esm_set_property;
-
- signals[CURSOR_CHANGED] = g_signal_new (
- "cursor_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, cursor_changed),
- NULL, NULL,
- e_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[CURSOR_ACTIVATED] = g_signal_new (
- "cursor_activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, cursor_activated),
- NULL, NULL,
- e_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[SELECTION_CHANGED] = g_signal_new (
- "selection_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[SELECTION_ROW_CHANGED] = g_signal_new (
- "selection_row_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, selection_row_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- g_object_class_install_property (
- object_class,
- PROP_SORTER,
- g_param_spec_object (
- "sorter",
- "Sorter",
- NULL,
- E_SORTER_TYPE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SELECTION_MODE,
- g_param_spec_int (
- "selection_mode",
- "Selection Mode",
- NULL,
- GTK_SELECTION_NONE,
- GTK_SELECTION_MULTIPLE,
- GTK_SELECTION_SINGLE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_MODE,
- g_param_spec_int (
- "cursor_mode",
- "Cursor Mode",
- NULL,
- E_CURSOR_LINE,
- E_CURSOR_SPREADSHEET,
- E_CURSOR_LINE,
- G_PARAM_READWRITE));
-}
-
-/**
- * e_selection_model_is_row_selected
- * @selection: #ESelectionModel to check
- * @n: The row to check
- *
- * This routine calculates whether the given row is selected.
- *
- * Returns: %TRUE if the given row is selected
- */
-gboolean
-e_selection_model_is_row_selected (ESelectionModel *selection,
- gint n)
-{
- ESelectionModelClass *class;
-
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_val_if_fail (class->is_row_selected != NULL, FALSE);
-
- return class->is_row_selected (selection, n);
-}
-
-/**
- * e_selection_model_foreach
- * @selection: #ESelectionModel to traverse
- * @callback: The callback function to call back.
- * @closure: The closure
- *
- * This routine calls the given callback function once for each
- * selected row, passing closure as the closure.
- */
-void
-e_selection_model_foreach (ESelectionModel *selection,
- EForeachFunc callback,
- gpointer closure)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
- g_return_if_fail (callback != NULL);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->foreach != NULL);
-
- class->foreach (selection, callback, closure);
-}
-
-/**
- * e_selection_model_clear
- * @selection: #ESelectionModel to clear
- *
- * This routine clears the selection to no rows selected.
- */
-void
-e_selection_model_clear (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->clear != NULL);
-
- class->clear (selection);
-}
-
-/**
- * e_selection_model_selected_count
- * @selection: #ESelectionModel to count
- *
- * This routine calculates the number of rows selected.
- *
- * Returns: The number of rows selected in the given model.
- */
-gint
-e_selection_model_selected_count (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), 0);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_val_if_fail (class->selected_count != NULL, 0);
-
- return class->selected_count (selection);
-}
-
-/**
- * e_selection_model_select_all
- * @selection: #ESelectionModel to select all
- *
- * This routine selects all the rows in the given
- * #ESelectionModel.
- */
-void
-e_selection_model_select_all (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->select_all != NULL);
-
- class->select_all (selection);
-}
-
-/**
- * e_selection_model_invert_selection
- * @selection: #ESelectionModel to invert
- *
- * This routine inverts all the rows in the given
- * #ESelectionModel.
- */
-void
-e_selection_model_invert_selection (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->invert_selection != NULL);
-
- class->invert_selection (selection);
-}
-
-gint
-e_selection_model_row_count (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), 0);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_val_if_fail (class->row_count != NULL, 0);
-
- return class->row_count (selection);
-}
-
-void
-e_selection_model_change_one_row (ESelectionModel *selection,
- gint row,
- gboolean grow)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->change_one_row != NULL);
-
- return class->change_one_row (selection, row, grow);
-}
-
-void
-e_selection_model_change_cursor (ESelectionModel *selection,
- gint row,
- gint col)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->change_cursor != NULL);
-
- class->change_cursor (selection, row, col);
-}
-
-gint
-e_selection_model_cursor_row (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), -1);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_val_if_fail (class->cursor_row != NULL, -1);
-
- return class->cursor_row (selection);
-}
-
-gint
-e_selection_model_cursor_col (ESelectionModel *selection)
-{
- ESelectionModelClass *class;
-
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), -1);
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_val_if_fail (class->cursor_col != NULL, -1);
-
- return class->cursor_col (selection);
-}
-
-void
-e_selection_model_select_single_row (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->select_single_row != NULL);
-
- class->select_single_row (selection, row);
-}
-
-void
-e_selection_model_toggle_single_row (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->toggle_single_row != NULL);
-
- class->toggle_single_row (selection, row);
-}
-
-void
-e_selection_model_move_selection_end (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->move_selection_end != NULL);
-
- class->move_selection_end (selection, row);
-}
-
-void
-e_selection_model_set_selection_end (ESelectionModel *selection,
- gint row)
-{
- ESelectionModelClass *class;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- class = E_SELECTION_MODEL_GET_CLASS (selection);
- g_return_if_fail (class->set_selection_end != NULL);
-
- class->set_selection_end (selection, row);
-}
-
-/**
- * e_selection_model_do_something
- * @selection: #ESelectionModel to do something to.
- * @row: The row to do something in.
- * @col: The col to do something in.
- * @state: The state in which to do something.
- *
- * This routine does whatever is appropriate as if the user clicked
- * the mouse in the given row and column.
- */
-void
-e_selection_model_do_something (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
-{
- gint shift_p = state & GDK_SHIFT_MASK;
- gint ctrl_p = state & GDK_CONTROL_MASK;
- gint row_count;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- selection->old_selection = -1;
-
- if (row == -1 && col != -1)
- row = 0;
- if (col == -1 && row != -1)
- col = 0;
-
- row_count = e_selection_model_row_count (selection);
- if (row_count >= 0 && row < row_count) {
- switch (selection->mode) {
- case GTK_SELECTION_SINGLE:
- e_selection_model_select_single_row (selection, row);
- break;
- case GTK_SELECTION_BROWSE:
- case GTK_SELECTION_MULTIPLE:
- if (shift_p) {
- e_selection_model_set_selection_end (selection, row);
- } else {
- if (ctrl_p) {
- e_selection_model_toggle_single_row (selection, row);
- } else {
- e_selection_model_select_single_row (selection, row);
- }
- }
- break;
- default:
- g_return_if_reached ();
- break;
- }
- e_selection_model_change_cursor (selection, row, col);
- g_signal_emit (
- selection,
- signals[CURSOR_CHANGED], 0,
- row, col);
- g_signal_emit (
- selection,
- signals[CURSOR_ACTIVATED], 0,
- row, col);
- }
-}
-
-/**
- * e_selection_model_maybe_do_something
- * @selection: #ESelectionModel to do something to.
- * @row: The row to do something in.
- * @col: The col to do something in.
- * @state: The state in which to do something.
- *
- * If this row is selected, this routine just moves the cursor row and
- * column. Otherwise, it does the same thing as
- * e_selection_model_do_something(). This is for being used on
- * right clicks and other events where if the user hit the selection,
- * they don't want it to change.
- */
-gboolean
-e_selection_model_maybe_do_something (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
-{
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
-
- selection->old_selection = -1;
-
- if (e_selection_model_is_row_selected (selection, row)) {
- e_selection_model_change_cursor (selection, row, col);
- g_signal_emit (
- selection,
- signals[CURSOR_CHANGED], 0,
- row, col);
- return FALSE;
- } else {
- e_selection_model_do_something (selection, row, col, state);
- return TRUE;
- }
-}
-
-void
-e_selection_model_right_click_down (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- if (selection->mode == GTK_SELECTION_SINGLE) {
- selection->old_selection =
- e_selection_model_cursor_row (selection);
- e_selection_model_select_single_row (selection, row);
- } else {
- e_selection_model_maybe_do_something (
- selection, row, col, state);
- }
-}
-
-void
-e_selection_model_right_click_up (ESelectionModel *selection)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- if (selection->mode != GTK_SELECTION_SINGLE)
- return;
-
- if (selection->old_selection == -1)
- return;
-
- e_selection_model_select_single_row (
- selection, selection->old_selection);
-}
-
-void
-e_selection_model_select_as_key_press (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
-{
- gint cursor_activated = TRUE;
-
- gint shift_p = state & GDK_SHIFT_MASK;
- gint ctrl_p = state & GDK_CONTROL_MASK;
-
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- selection->old_selection = -1;
-
- switch (selection->mode) {
- case GTK_SELECTION_BROWSE:
- case GTK_SELECTION_MULTIPLE:
- if (shift_p) {
- e_selection_model_set_selection_end (selection, row);
- } else if (!ctrl_p) {
- e_selection_model_select_single_row (selection, row);
- } else
- cursor_activated = FALSE;
- break;
- case GTK_SELECTION_SINGLE:
- e_selection_model_select_single_row (selection, row);
- break;
- default:
- g_return_if_reached ();
- break;
- }
- if (row != -1) {
- e_selection_model_change_cursor (selection, row, col);
- g_signal_emit (
- selection,
- signals[CURSOR_CHANGED], 0,
- row, col);
- if (cursor_activated)
- g_signal_emit (
- selection,
- signals[CURSOR_ACTIVATED], 0,
- row, col);
- }
-}
-
-static gint
-move_selection (ESelectionModel *selection,
- gboolean up,
- GdkModifierType state)
-{
- gint row = e_selection_model_cursor_row (selection);
- gint col = e_selection_model_cursor_col (selection);
- gint row_count;
-
- /* there is no selected row when row is -1 */
- if (row != -1)
- row = e_sorter_model_to_sorted (selection->sorter, row);
-
- if (up)
- row--;
- else
- row++;
- if (row < 0)
- row = 0;
- row_count = e_selection_model_row_count (selection);
- if (row >= row_count)
- row = row_count - 1;
- row = e_sorter_sorted_to_model (selection->sorter, row);
-
- e_selection_model_select_as_key_press (selection, row, col, state);
- return TRUE;
-}
-
-/**
- * e_selection_model_key_press
- * @selection: #ESelectionModel to affect.
- * @key: The event.
- *
- * This routine does whatever is appropriate as if the user pressed
- * the given key.
- *
- * Returns: %TRUE if the #ESelectionModel used the key.
- */
-gboolean
-e_selection_model_key_press (ESelectionModel *selection,
- GdkEventKey *key)
-{
- g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
-
- selection->old_selection = -1;
-
- switch (key->keyval) {
- case GDK_KEY_Up:
- case GDK_KEY_KP_Up:
- return move_selection (selection, TRUE, key->state);
- case GDK_KEY_Down:
- case GDK_KEY_KP_Down:
- return move_selection (selection, FALSE, key->state);
- case GDK_KEY_space:
- case GDK_KEY_KP_Space:
- if (selection->mode != GTK_SELECTION_SINGLE) {
- gint row = e_selection_model_cursor_row (selection);
- gint col = e_selection_model_cursor_col (selection);
- if (row == -1)
- break;
-
- e_selection_model_toggle_single_row (selection, row);
- g_signal_emit (
- selection,
- signals[CURSOR_ACTIVATED], 0,
- row, col);
- return TRUE;
- }
- break;
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- if (selection->mode != GTK_SELECTION_SINGLE) {
- gint row = e_selection_model_cursor_row (selection);
- gint col = e_selection_model_cursor_col (selection);
- e_selection_model_select_single_row (selection, row);
- g_signal_emit (
- selection,
- signals[CURSOR_ACTIVATED], 0,
- row, col);
- return TRUE;
- }
- break;
- case GDK_KEY_Home:
- case GDK_KEY_KP_Home:
- if (selection->cursor_mode == E_CURSOR_LINE) {
- gint row = 0;
- gint cursor_col = e_selection_model_cursor_col (selection);
-
- row = e_sorter_sorted_to_model (selection->sorter, row);
- e_selection_model_select_as_key_press (
- selection, row, cursor_col, key->state);
- return TRUE;
- }
- break;
- case GDK_KEY_End:
- case GDK_KEY_KP_End:
- if (selection->cursor_mode == E_CURSOR_LINE) {
- gint row = e_selection_model_row_count (selection) - 1;
- gint cursor_col = e_selection_model_cursor_col (selection);
-
- row = e_sorter_sorted_to_model (selection->sorter, row);
- e_selection_model_select_as_key_press (
- selection, row, cursor_col, key->state);
- return TRUE;
- }
- break;
- }
- return FALSE;
-}
-
-void
-e_selection_model_cursor_changed (ESelectionModel *selection,
- gint row,
- gint col)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- g_signal_emit (selection, signals[CURSOR_CHANGED], 0, row, col);
-}
-
-void
-e_selection_model_cursor_activated (ESelectionModel *selection,
- gint row,
- gint col)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- g_signal_emit (selection, signals[CURSOR_ACTIVATED], 0, row, col);
-}
-
-void
-e_selection_model_selection_changed (ESelectionModel *selection)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- g_signal_emit (selection, signals[SELECTION_CHANGED], 0);
-}
-
-void
-e_selection_model_selection_row_changed (ESelectionModel *selection,
- gint row)
-{
- g_return_if_fail (E_IS_SELECTION_MODEL (selection));
-
- g_signal_emit (selection, signals[SELECTION_ROW_CHANGED], 0, row);
-}
diff --git a/widgets/misc/e-selection-model.h b/widgets/misc/e-selection-model.h
deleted file mode 100644
index 355734b6a5..0000000000
--- a/widgets/misc/e-selection-model.h
+++ /dev/null
@@ -1,205 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_SELECTION_MODEL_H
-#define E_SELECTION_MODEL_H
-
-#include <gtk/gtk.h>
-#include <e-util/e-sorter.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SELECTION_MODEL \
- (e_selection_model_get_type ())
-#define E_SELECTION_MODEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SELECTION_MODEL, ESelectionModel))
-#define E_SELECTION_MODEL_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SELECTION_MODEL, ESelectionModelClass))
-#define E_IS_SELECTION_MODEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SELECTION_MODEL))
-#define E_IS_SELECTION_MODEL_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SELECTION_MODEL))
-#define E_SELECTION_MODEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SELECTION_MODEL, ESelectionModelClass))
-
-G_BEGIN_DECLS
-
-#ifndef _E_FOREACH_FUNC_H_
-#define _E_FOREACH_FUNC_H_
-typedef void (*EForeachFunc) (gint model_row,
- gpointer closure);
-#endif
-
-typedef struct _ESelectionModel ESelectionModel;
-typedef struct _ESelectionModelClass ESelectionModelClass;
-
-/* list selection modes */
-typedef enum {
- E_CURSOR_LINE,
- E_CURSOR_SIMPLE,
- E_CURSOR_SPREADSHEET
-} ECursorMode;
-
-struct _ESelectionModel {
- GObject parent;
-
- ESorter *sorter;
-
- GtkSelectionMode mode;
- ECursorMode cursor_mode;
-
- gint old_selection;
-};
-
-struct _ESelectionModelClass {
- GObjectClass parent_class;
-
- /* Virtual methods */
- gboolean (*is_row_selected) (ESelectionModel *esm,
- gint row);
- void (*foreach) (ESelectionModel *esm,
- EForeachFunc callback,
- gpointer closure);
- void (*clear) (ESelectionModel *esm);
- gint (*selected_count) (ESelectionModel *esm);
- void (*select_all) (ESelectionModel *esm);
- void (*invert_selection) (ESelectionModel *esm);
- gint (*row_count) (ESelectionModel *esm);
-
- /* Protected virtual methods. */
- void (*change_one_row) (ESelectionModel *esm,
- gint row,
- gboolean on);
- void (*change_cursor) (ESelectionModel *esm,
- gint row,
- gint col);
- gint (*cursor_row) (ESelectionModel *esm);
- gint (*cursor_col) (ESelectionModel *esm);
-
- void (*select_single_row) (ESelectionModel *selection,
- gint row);
- void (*toggle_single_row) (ESelectionModel *selection,
- gint row);
- void (*move_selection_end) (ESelectionModel *selection,
- gint row);
- void (*set_selection_end) (ESelectionModel *selection,
- gint row);
-
- /* Signals */
- void (*cursor_changed) (ESelectionModel *esm,
- gint row,
- gint col);
- void (*cursor_activated) (ESelectionModel *esm,
- gint row,
- gint col);
- void (*selection_row_changed)(ESelectionModel *esm,
- gint row);
- void (*selection_changed) (ESelectionModel *esm);
-};
-
-GType e_selection_model_get_type (void);
-void e_selection_model_do_something (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
-gboolean e_selection_model_maybe_do_something
- (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
-void e_selection_model_right_click_down
- (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state);
-void e_selection_model_right_click_up
- (ESelectionModel *selection);
-gboolean e_selection_model_key_press (ESelectionModel *esm,
- GdkEventKey *key);
-void e_selection_model_select_as_key_press
- (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
-
-/* Virtual functions */
-gboolean e_selection_model_is_row_selected
- (ESelectionModel *esm,
- gint n);
-void e_selection_model_foreach (ESelectionModel *esm,
- EForeachFunc callback,
- gpointer closure);
-void e_selection_model_clear (ESelectionModel *esm);
-gint e_selection_model_selected_count
- (ESelectionModel *esm);
-void e_selection_model_select_all (ESelectionModel *esm);
-void e_selection_model_invert_selection
- (ESelectionModel *esm);
-gint e_selection_model_row_count (ESelectionModel *esm);
-
-/* Private virtual Functions */
-void e_selection_model_change_one_row
- (ESelectionModel *esm,
- gint row,
- gboolean on);
-void e_selection_model_change_cursor (ESelectionModel *esm,
- gint row,
- gint col);
-gint e_selection_model_cursor_row (ESelectionModel *esm);
-gint e_selection_model_cursor_col (ESelectionModel *esm);
-void e_selection_model_select_single_row
- (ESelectionModel *selection,
- gint row);
-void e_selection_model_toggle_single_row
- (ESelectionModel *selection,
- gint row);
-void e_selection_model_move_selection_end
- (ESelectionModel *selection,
- gint row);
-void e_selection_model_set_selection_end
- (ESelectionModel *selection,
- gint row);
-
-/* Signals */
-void e_selection_model_cursor_changed
- (ESelectionModel *selection,
- gint row,
- gint col);
-void e_selection_model_cursor_activated
- (ESelectionModel *selection,
- gint row,
- gint col);
-void e_selection_model_selection_row_changed
- (ESelectionModel *selection,
- gint row);
-void e_selection_model_selection_changed
- (ESelectionModel *selection);
-
-G_END_DECLS
-
-#endif /* E_SELECTION_MODEL_H */
-
diff --git a/widgets/misc/e-send-options.c b/widgets/misc/e-send-options.c
deleted file mode 100644
index d84b8659e4..0000000000
--- a/widgets/misc/e-send-options.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * Evolution calendar - Main page of the Groupwise send options Dialog
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chenthill Palanisamy <pchenthill@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <time.h>
-
-#include "e-util/e-util.h"
-#include "e-util/e-util-private.h"
-
-#include "e-dateedit.h"
-#include "e-send-options.h"
-
-#define E_SEND_OPTIONS_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SEND_OPTIONS_DIALOG, ESendOptionsDialogPrivate))
-
-struct _ESendOptionsDialogPrivate {
- GtkBuilder *builder;
-
- gboolean gopts_needed;
- gboolean global;
-
- /* Widgets */
-
- GtkWidget *main;
-
- /* Noteboook to add options page and status tracking page*/
- GtkNotebook *notebook;
-
- GtkWidget *status;
-
- /* priority */
- GtkWidget *priority;
-
- /* Security */
- GtkWidget *security;
-
- /* Widgets for Reply Requestion options */
- GtkWidget *reply_request;
- GtkWidget *reply_convenient;
- GtkWidget *reply_within;
- GtkWidget *within_days;
-
- /* Widgets for delay delivery Option */
- GtkWidget *delay_delivery;
- GtkWidget *delay_until;
-
- /* Widgets for Choosing expiration date */
- GtkWidget *expiration;
- GtkWidget *expire_after;
-
- /* Widgets to for tracking information through sent Item */
- GtkWidget *create_sent;
- GtkWidget *delivered;
- GtkWidget *delivered_opened;
- GtkWidget *all_info;
- GtkWidget *autodelete;
-
- /* Widgets for setting the Return Notification */
- GtkWidget *when_opened;
- GtkWidget *when_declined;
- GtkWidget *when_accepted;
- GtkWidget *when_completed;
-
- /* label widgets */
- GtkWidget *security_label;
- GtkWidget *priority_label;
- GtkWidget *gopts_label;
- GtkWidget *opened_label;
- GtkWidget *declined_label;
- GtkWidget *accepted_label;
- GtkWidget *completed_label;
- GtkWidget *until_label;
- gchar *help_section;
-};
-
-static void e_send_options_dialog_finalize (GObject *object);
-static void e_send_options_cb (GtkDialog *dialog, gint state, gpointer func_data);
-
-enum {
- SOD_RESPONSE,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE (
- ESendOptionsDialog,
- e_send_options_dialog,
- G_TYPE_OBJECT)
-
-static void
-e_send_options_get_widgets_data (ESendOptionsDialog *sod)
-{
- ESendOptionsDialogPrivate *priv;
- ESendOptionsGeneral *gopts;
- ESendOptionsStatusTracking *sopts;
-
- priv = sod->priv;
- gopts = sod->data->gopts;
- sopts = sod->data->sopts;
-
- gopts->priority = gtk_combo_box_get_active ((GtkComboBox *) priv->priority);
- gopts->security = gtk_combo_box_get_active ((GtkComboBox *) priv->security);
-
- gopts->reply_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reply_request));
- gopts->reply_convenient = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reply_convenient));
- gopts->reply_within = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->within_days));
-
- gopts->expiration_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->expiration));
- gopts->expire_after = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->expire_after));
- gopts->delay_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delay_delivery));
-
- if (e_date_edit_date_is_valid (E_DATE_EDIT (priv->delay_until)) &&
- e_date_edit_time_is_valid (E_DATE_EDIT (priv->delay_until)))
- gopts->delay_until = e_date_edit_get_time (E_DATE_EDIT (priv->delay_until));
-
- sopts->tracking_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->create_sent));
-
- sopts->autodelete = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->autodelete));
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivered)))
- sopts->track_when = E_DELIVERED;
- else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivered_opened)))
- sopts->track_when = E_DELIVERED_OPENED;
- else
- sopts->track_when = E_ALL;
-
- sopts->opened = gtk_combo_box_get_active ((GtkComboBox *) priv->when_opened);
- sopts->accepted = gtk_combo_box_get_active ((GtkComboBox *) priv->when_accepted);
- sopts->declined = gtk_combo_box_get_active ((GtkComboBox *) priv->when_declined);
- sopts->completed = gtk_combo_box_get_active ((GtkComboBox *) priv->when_completed);
-}
-
-static void
-e_send_options_fill_widgets_with_data (ESendOptionsDialog *sod)
-{
- ESendOptionsDialogPrivate *priv;
- ESendOptionsGeneral *gopts;
- ESendOptionsStatusTracking *sopts;
- time_t tmp;
-
- priv = sod->priv;
- gopts = sod->data->gopts;
- sopts = sod->data->sopts;
- tmp = time (NULL);
-
- gtk_combo_box_set_active ((GtkComboBox *) priv->priority, gopts->priority);
- gtk_combo_box_set_active ((GtkComboBox *) priv->security, gopts->security);
-
- if (gopts->reply_enabled)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_request), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_request), FALSE);
-
- if (gopts->reply_convenient)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_convenient), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_within), TRUE);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->within_days), (gdouble) gopts->reply_within);
-
- if (gopts->expiration_enabled)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->expiration), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->expiration), FALSE);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->expire_after), (gdouble) gopts->expire_after);
-
- if (gopts->delay_enabled)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delay_delivery), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delay_delivery), FALSE);
-
- if (!gopts->delay_until || difftime (gopts->delay_until, tmp) < 0)
- e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), 0);
- else
- e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), gopts->delay_until);
-
- if (sopts->tracking_enabled)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->create_sent), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->create_sent), FALSE);
-
- if (sopts->autodelete)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autodelete), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autodelete), FALSE);
-
- switch (sopts->track_when) {
- case E_DELIVERED:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivered), TRUE);
- break;
- case E_DELIVERED_OPENED:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivered_opened), TRUE);
- break;
- case E_ALL:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_info), TRUE);
- }
-
- gtk_combo_box_set_active ((GtkComboBox *) priv->when_opened, sopts->opened);
- gtk_combo_box_set_active ((GtkComboBox *) priv->when_declined, sopts->declined);
- gtk_combo_box_set_active ((GtkComboBox *) priv->when_accepted, sopts->accepted);
- gtk_combo_box_set_active ((GtkComboBox *) priv->when_completed, sopts->completed);
-}
-
-static void
-sensitize_widgets (ESendOptionsDialog *sod)
-{
- ESendOptionsDialogPrivate *priv;
- ESendOptionsGeneral *gopts;
- ESendOptionsStatusTracking *sopts;
-
- priv = sod->priv;
- gopts = sod->data->gopts;
- sopts = sod->data->sopts;
-
- if (!gopts->reply_enabled) {
- gtk_widget_set_sensitive (priv->reply_convenient, FALSE);
- gtk_widget_set_sensitive (priv->reply_within, FALSE);
- gtk_widget_set_sensitive (priv->within_days, FALSE);
- }
-
- if (!gopts->expiration_enabled)
- gtk_widget_set_sensitive (priv->expire_after, FALSE);
-
- if (!gopts->delay_enabled) {
- gtk_widget_set_sensitive (priv->delay_until, FALSE);
- }
-
- if (!sopts->tracking_enabled) {
- gtk_widget_set_sensitive (priv->delivered, FALSE);
- gtk_widget_set_sensitive (priv->delivered_opened, FALSE);
- gtk_widget_set_sensitive (priv->all_info, FALSE);
- gtk_widget_set_sensitive (priv->autodelete, FALSE);
- }
-}
-
-static void
-expiration_toggled_cb (GtkToggleButton *toggle,
- gpointer data)
-{
- gboolean active;
- ESendOptionsDialog *sod;
- ESendOptionsDialogPrivate *priv;
-
- sod = data;
- priv = sod->priv;
-
- active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (priv->expire_after, active);
-}
-
-static void
-reply_request_toggled_cb (GtkToggleButton *toggle,
- gpointer data)
-{
- gboolean active;
- ESendOptionsDialog *sod;
- ESendOptionsDialogPrivate *priv;
-
- sod = data;
- priv = sod->priv;
- active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (priv->reply_convenient, active);
- gtk_widget_set_sensitive (priv->reply_within, active);
- gtk_widget_set_sensitive (priv->within_days, active);
-
-}
-
-static void
-delay_delivery_toggled_cb (GtkToggleButton *toggle,
- gpointer data)
-{
- gboolean active;
- ESendOptionsDialog *sod;
- ESendOptionsDialogPrivate *priv;
-
- sod = data;
- priv = sod->priv;
- active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (priv->delay_until, active);
-}
-
-static void
-sent_item_toggled_cb (GtkToggleButton *toggle,
- gpointer data)
-{
- gboolean active;
- ESendOptionsDialog *sod;
- ESendOptionsDialogPrivate *priv;
-
- sod = data;
- priv = sod->priv;
- active = gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (priv->delivered, active);
- gtk_widget_set_sensitive (priv->delivered_opened, active);
- gtk_widget_set_sensitive (priv->all_info, active);
- gtk_widget_set_sensitive (priv->autodelete, active);
-}
-
-static void
-delay_until_date_changed_cb (GtkWidget *dedit,
- gpointer data)
-{
- ESendOptionsDialog *sod;
- ESendOptionsDialogPrivate *priv;
- time_t tmp, current;
-
- sod = data;
- priv = sod->priv;
-
- current = time (NULL);
- tmp = e_date_edit_get_time (E_DATE_EDIT (priv->delay_until));
-
- if ((difftime (tmp, current) < 0) || !e_date_edit_time_is_valid (E_DATE_EDIT (priv->delay_until))
- || !e_date_edit_date_is_valid (E_DATE_EDIT (priv->delay_until)))
- e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), 0);
-
-}
-static void
-page_changed_cb (GtkNotebook *notebook,
- GtkWidget *page,
- gint num,
- gpointer data)
-{
- ESendOptionsDialog *sod = data;
- ESendOptionsDialogPrivate *priv = sod->priv;
-
- e_send_options_get_widgets_data (sod);
- if (num > 0) {
- GtkWidget *child;
-
- if (num == 1) {
- gtk_widget_hide (priv->accepted_label);
- gtk_widget_hide (priv->when_accepted);
- gtk_widget_hide (priv->completed_label);
- gtk_widget_hide (priv->when_completed);
- gtk_widget_set_sensitive (priv->autodelete, TRUE);
- sod->data->sopts = sod->data->mopts;
-
- child = gtk_notebook_get_nth_page (notebook, 1);
- if (child != priv->status && (!GTK_IS_BIN (child) || gtk_bin_get_child (GTK_BIN (child)) != priv->status))
- gtk_widget_reparent (priv->status, child);
- } else if (num == 2) {
- gtk_widget_hide (priv->completed_label);
- gtk_widget_hide (priv->when_completed);
- gtk_widget_set_sensitive (priv->autodelete, FALSE);
-
- gtk_widget_show (priv->accepted_label);
- gtk_widget_show (priv->when_accepted);
- sod->data->sopts = sod->data->copts;
-
- child = gtk_notebook_get_nth_page (notebook, 2);
- if (gtk_bin_get_child (GTK_BIN (child)) != priv->status)
- gtk_widget_reparent (priv->status, child);
- } else {
- gtk_widget_set_sensitive (priv->autodelete, FALSE);
-
- gtk_widget_show (priv->completed_label);
- gtk_widget_show (priv->when_completed);
- gtk_widget_show (priv->accepted_label);
- gtk_widget_show (priv->when_accepted);
- sod->data->sopts = sod->data->topts;
-
- child = gtk_notebook_get_nth_page (notebook, 3);
- if (gtk_bin_get_child (GTK_BIN (child)) != priv->status)
- gtk_widget_reparent (priv->status, child);
- }
- }
- e_send_options_fill_widgets_with_data (sod);
-}
-
-static void
-init_widgets (ESendOptionsDialog *sod)
-{
- ESendOptionsDialogPrivate *priv;
-
- priv = sod->priv;
-
- g_signal_connect (
- priv->expiration, "toggled",
- G_CALLBACK (expiration_toggled_cb), sod);
- g_signal_connect (
- priv->reply_request, "toggled",
- G_CALLBACK (reply_request_toggled_cb), sod);
- g_signal_connect (
- priv->delay_delivery, "toggled",
- G_CALLBACK (delay_delivery_toggled_cb), sod);
- g_signal_connect (
- priv->create_sent, "toggled",
- G_CALLBACK (sent_item_toggled_cb), sod);
-
- g_signal_connect (
- priv->main, "response",
- G_CALLBACK (e_send_options_cb), sod);
- g_signal_connect (
- priv->delay_until, "changed",
- G_CALLBACK (delay_until_date_changed_cb), sod);
-
- if (priv->global)
- g_signal_connect (
- priv->notebook, "switch-page",
- G_CALLBACK (page_changed_cb), sod);
-
-}
-
-static gboolean
-get_widgets (ESendOptionsDialog *sod)
-{
- ESendOptionsDialogPrivate *priv;
- GtkBuilder *builder;
-
- priv = sod->priv;
- builder = sod->priv->builder;
-
- priv->main = e_builder_get_widget (builder, "send-options-dialog");
- if (!priv->main)
- return FALSE;
-
- priv->priority = e_builder_get_widget (builder, "combo-priority");
- priv->status = e_builder_get_widget (builder, "status-tracking");
- priv->security = e_builder_get_widget (builder, "security-combo");
- priv->notebook = (GtkNotebook *) e_builder_get_widget (builder, "notebook");
- priv->reply_request = e_builder_get_widget (builder, "reply-request-button");
- priv->reply_convenient = e_builder_get_widget (builder, "reply-convinient");
- priv->reply_within = e_builder_get_widget (builder, "reply-within");
- priv->within_days = e_builder_get_widget (builder, "within-days");
- priv->delay_delivery = e_builder_get_widget (builder, "delay-delivery-button");
- priv->delay_until = e_builder_get_widget (builder, "until-date");
- gtk_widget_show (priv->delay_until);
- priv->expiration = e_builder_get_widget (builder, "expiration-button");
- priv->expire_after = e_builder_get_widget (builder, "expire-after");
- priv->create_sent = e_builder_get_widget (builder, "create-sent-button");
- priv->delivered = e_builder_get_widget (builder, "delivered");
- priv->delivered_opened = e_builder_get_widget (builder, "delivered-opened");
- priv->all_info = e_builder_get_widget (builder, "all-info");
- priv->autodelete = e_builder_get_widget (builder, "autodelete");
- priv->when_opened = e_builder_get_widget (builder, "open-combo");
- priv->when_declined = e_builder_get_widget (builder, "delete-combo");
- priv->when_accepted = e_builder_get_widget (builder, "accept-combo");
- priv->when_completed = e_builder_get_widget (builder, "complete-combo");
- priv->security_label = e_builder_get_widget (builder, "security-label");
- priv->gopts_label = e_builder_get_widget (builder, "gopts-label");
- priv->priority_label = e_builder_get_widget (builder, "priority-label");
- priv->until_label = e_builder_get_widget (builder, "until-label");
- priv->opened_label = e_builder_get_widget (builder, "opened-label");
- priv->declined_label = e_builder_get_widget (builder, "declined-label");
- priv->accepted_label = e_builder_get_widget (builder, "accepted-label");
- priv->completed_label = e_builder_get_widget (builder, "completed-label");
-
- return (priv->priority
- && priv->security
- && priv->status
- && priv->reply_request
- && priv->reply_convenient
- && priv->reply_within
- && priv->within_days
- && priv->delay_delivery
- && priv->delay_until
- && priv->expiration
- && priv->expire_after
- && priv->create_sent
- && priv->delivered
- && priv->delivered_opened
- && priv->autodelete
- && priv->all_info
- && priv->when_opened
- && priv->when_declined
- && priv->when_accepted
- && priv->when_completed
- && priv->security_label
- && priv->priority_label
- && priv->opened_label
- && priv->gopts_label
- && priv->declined_label
- && priv->accepted_label
- && priv->completed_label);
-
-}
-
-static void
-setup_widgets (ESendOptionsDialog *sod,
- Item_type type)
-{
- ESendOptionsDialogPrivate *priv;
-
- priv = sod->priv;
-
- if (!priv->gopts_needed) {
- gtk_notebook_set_show_tabs (priv->notebook, FALSE);
- gtk_notebook_set_current_page (priv->notebook, 1);
- gtk_widget_hide (priv->delay_until);
- } else
- gtk_notebook_set_show_tabs (priv->notebook, TRUE);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->priority_label), priv->priority);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->security_label), priv->security);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->accepted_label), priv->when_accepted);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->declined_label), priv->when_declined);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->opened_label), priv->when_opened);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->completed_label), priv->when_completed);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->until_label), priv->delay_until);
-
- if (priv->global) {
- GtkWidget *widget, *page;
-
- widget = gtk_label_new (_("Mail"));
- page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_widget_reparent (priv->status, page);
- gtk_notebook_append_page (priv->notebook, page, widget);
- gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
- gtk_widget_show (page);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (_("Calendar"));
- page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_notebook_append_page (priv->notebook, page, widget);
- gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
- gtk_widget_show (page);
- gtk_widget_show (widget);
-
- widget = gtk_label_new (_("Task"));
- page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_notebook_append_page (priv->notebook, page, widget);
- gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
- gtk_widget_show (page);
- gtk_widget_show (widget);
-
- gtk_notebook_set_show_tabs (priv->notebook, TRUE);
- }
-
- switch (type) {
- case E_ITEM_MAIL:
- priv->help_section = g_strdup ("groupwise-placeholder");
- gtk_widget_hide (priv->accepted_label);
- gtk_widget_hide (priv->when_accepted);
- gtk_widget_hide (priv->completed_label);
- gtk_widget_hide (priv->when_completed);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->declined_label), (_("When de_leted:")));
- break;
- case E_ITEM_CALENDAR:
- priv->help_section = g_strdup ("groupwise-placeholder");
- gtk_widget_hide (priv->completed_label);
- gtk_widget_hide (priv->when_completed);
- case E_ITEM_TASK:
- priv->help_section = g_strdup ("groupwise-placeholder");
- gtk_widget_hide (priv->security_label);
- gtk_widget_hide (priv->security);
- gtk_widget_set_sensitive (priv->autodelete, FALSE);
- break;
- default:
- break;
- }
-}
-
-ESendOptionsDialog *
-e_send_options_dialog_new (void)
-{
- ESendOptionsDialog *sod;
-
- sod = g_object_new (E_TYPE_SEND_OPTIONS_DIALOG, NULL);
-
- return sod;
-}
-
-void
-e_send_options_set_need_general_options (ESendOptionsDialog *sod,
- gboolean needed)
-{
- g_return_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod));
-
- sod->priv->gopts_needed = needed;
-}
-
-gboolean
-e_send_options_get_need_general_options (ESendOptionsDialog *sod)
-{
- g_return_val_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
-
- return sod->priv->gopts_needed;
-}
-
-gboolean
-e_send_options_set_global (ESendOptionsDialog *sod,
- gboolean set)
-{
- g_return_val_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
-
- sod->priv->global = set;
-
- return TRUE;
-}
-
-static void
-e_send_options_cb (GtkDialog *dialog,
- gint state,
- gpointer func_data)
-{
- ESendOptionsDialogPrivate *priv;
- ESendOptionsDialog *sod;
-
- sod = func_data;
- priv = sod->priv;
-
- switch (state) {
- case GTK_RESPONSE_OK:
- e_send_options_get_widgets_data (sod);
- case GTK_RESPONSE_CANCEL:
- gtk_widget_hide (priv->main);
- gtk_widget_destroy (priv->main);
- g_object_unref (priv->builder);
- break;
- case GTK_RESPONSE_HELP:
- e_display_help (
- GTK_WINDOW (priv->main),
- priv->help_section);
- break;
- }
-
- g_signal_emit (func_data, signals[SOD_RESPONSE], 0, state);
-}
-
-gboolean
-e_send_options_dialog_run (ESendOptionsDialog *sod,
- GtkWidget *parent,
- Item_type type)
-{
- ESendOptionsDialogPrivate *priv;
- GtkWidget *toplevel;
-
- g_return_val_if_fail (sod != NULL || E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
-
- priv = sod->priv;
-
- /* Make sure our custom widget classes are registered with
- * GType before we load the GtkBuilder definition file. */
- E_TYPE_DATE_EDIT;
-
- priv->builder = gtk_builder_new ();
- e_load_ui_builder_definition (priv->builder, "e-send-options.ui");
-
- if (!get_widgets (sod)) {
- g_object_unref (priv->builder);
- g_message (G_STRLOC ": Could not get the Widgets \n");
- return FALSE;
- }
-
- if (priv->global) {
- g_free (sod->data->sopts);
- sod->data->sopts = sod->data->mopts;
- }
-
- setup_widgets (sod, type);
-
- toplevel = gtk_widget_get_toplevel (priv->main);
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW (toplevel),
- GTK_WINDOW (parent));
-
- e_send_options_fill_widgets_with_data (sod);
- sensitize_widgets (sod);
- init_widgets (sod);
- gtk_window_set_modal ((GtkWindow *) priv->main, TRUE);
-
- gtk_widget_show (priv->main);
-
- return TRUE;
-}
-
-static void
-e_send_options_dialog_finalize (GObject *object)
-{
- ESendOptionsDialog *sod;
-
- sod = E_SEND_OPTIONS_DIALOG (object);
-
- g_free (sod->priv->help_section);
-
- g_free (sod->data->gopts);
-
- if (!sod->priv->global)
- g_free (sod->data->sopts);
-
- g_free (sod->data->mopts);
- g_free (sod->data->copts);
- g_free (sod->data->topts);
- g_free (sod->data);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_send_options_dialog_parent_class)->finalize (object);
-}
-
-/* Object initialization function for the task page */
-static void
-e_send_options_dialog_init (ESendOptionsDialog *sod)
-{
- ESendOptionsData *new;
-
- new = g_new0 (ESendOptionsData, 1);
- new->gopts = g_new0 (ESendOptionsGeneral, 1);
- new->sopts = g_new0 (ESendOptionsStatusTracking, 1);
- new->mopts = g_new0 (ESendOptionsStatusTracking, 1);
- new->copts = g_new0 (ESendOptionsStatusTracking, 1);
- new->topts = g_new0 (ESendOptionsStatusTracking, 1);
-
- sod->priv = E_SEND_OPTIONS_DIALOG_GET_PRIVATE (sod);
-
- sod->data = new;
- sod->data->initialized = FALSE;
- sod->data->gopts->security = 0;
-
- sod->priv->gopts_needed = TRUE;
-}
-
-/* Class initialization function for the Send Options */
-static void
-e_send_options_dialog_class_init (ESendOptionsDialogClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (ESendOptionsDialogPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = e_send_options_dialog_finalize;
-
- signals[SOD_RESPONSE] = g_signal_new (
- "sod_response",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ESendOptionsDialogClass, sod_response),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
-}
diff --git a/widgets/misc/e-send-options.h b/widgets/misc/e-send-options.h
deleted file mode 100644
index 2e8ef1d381..0000000000
--- a/widgets/misc/e-send-options.h
+++ /dev/null
@@ -1,127 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_SEND_OPTIONS_DIALOG_H__
-#define __E_SEND_OPTIONS_DIALOG_H__
-
-#include <gtk/gtk.h>
-#include <time.h>
-
-#define E_TYPE_SEND_OPTIONS_DIALOG (e_send_options_dialog_get_type ())
-#define E_SEND_OPTIONS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SEND_OPTIONS_DIALOG, ESendOptionsDialog))
-#define E_SEND_OPTIONS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SEND_OPTIONS_DIALOG, ESendOptionsDialogClass))
-#define E_IS_SEND_OPTIONS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SEND_OPTIONS_DIALOG))
-#define E_IS_SEND_OPTIONS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SEND_OPTIONS_DIALOG))
-
-typedef struct _ESendOptionsDialog ESendOptionsDialog;
-typedef struct _ESendOptionsDialogClass ESendOptionsDialogClass;
-typedef struct _ESendOptionsDialogPrivate ESendOptionsDialogPrivate;
-
-typedef enum {
- E_ITEM_NONE,
- E_ITEM_MAIL,
- E_ITEM_CALENDAR,
- E_ITEM_TASK
-} Item_type;
-
-typedef enum {
- E_PRIORITY_UNDEFINED,
- E_PRIORITY_HIGH,
- E_PRIORITY_STANDARD,
- E_PRIORITY_LOW
-} ESendOptionsPriority;
-
-typedef enum {
- E_SECURITY_NORMAL,
- E_SECURITY_PROPRIETARY,
- E_SECURITY_CONFIDENTIAL,
- E_SECURITY_SECRET,
- E_SECURITY_TOP_SECRET,
- E_SECURITY_FOR_YOUR_EYES_ONLY
-} ESendOptionsSecurity;
-
-typedef enum {
- E_RETURN_NOTIFY_NONE,
- E_RETURN_NOTIFY_MAIL
-} ESendOptionsReturnNotify;
-
-typedef enum {
- E_DELIVERED = 1,
- E_DELIVERED_OPENED = 2,
- E_ALL = 3
-} TrackInfo;
-
-typedef struct {
- ESendOptionsPriority priority;
- gint classify;
- gboolean reply_enabled;
- gboolean reply_convenient;
- gint reply_within;
- gboolean expiration_enabled;
- gint expire_after;
- gboolean delay_enabled;
- time_t delay_until;
- gint security;
-} ESendOptionsGeneral;
-
-typedef struct {
- gboolean tracking_enabled;
- TrackInfo track_when;
- gboolean autodelete;
- ESendOptionsReturnNotify opened;
- ESendOptionsReturnNotify accepted;
- ESendOptionsReturnNotify declined;
- ESendOptionsReturnNotify completed;
-} ESendOptionsStatusTracking;
-
-typedef struct {
- gboolean initialized;
-
- ESendOptionsGeneral *gopts;
- ESendOptionsStatusTracking *sopts;
- ESendOptionsStatusTracking *mopts;
- ESendOptionsStatusTracking *copts;
- ESendOptionsStatusTracking *topts;
-
-} ESendOptionsData;
-
-struct _ESendOptionsDialog {
- GObject object;
-
- ESendOptionsData *data;
- /* Private data */
- ESendOptionsDialogPrivate *priv;
-};
-
-struct _ESendOptionsDialogClass {
- GObjectClass parent_class;
- void (* sod_response) (ESendOptionsDialog *sd, gint status);
-};
-
-GType e_send_options_dialog_get_type (void);
-ESendOptionsDialog *e_send_options_dialog_new (void);
-void e_send_options_set_need_general_options (ESendOptionsDialog *sod, gboolean needed);
-gboolean e_send_options_get_need_general_options (ESendOptionsDialog *sod);
-gboolean e_send_options_dialog_run (ESendOptionsDialog *sod, GtkWidget *parent, Item_type type);
-gboolean e_send_options_set_global (ESendOptionsDialog *sod, gboolean set);
-#endif
diff --git a/widgets/misc/e-send-options.ui b/widgets/misc/e-send-options.ui
deleted file mode 100644
index 681e6e0693..0000000000
--- a/widgets/misc/e-send-options.ui
+++ /dev/null
@@ -1,949 +0,0 @@
-<?xml version="1.0"?>
-<interface>
- <object class="GtkAdjustment" id="adjustment1">
- <property name="upper">100</property>
- <property name="lower">0</property>
- <property name="page_increment">10</property>
- <property name="step_increment">1</property>
- <property name="page_size">0</property>
- <property name="value">5</property>
- </object>
- <object class="GtkAdjustment" id="adjustment2">
- <property name="upper">100</property>
- <property name="lower">0</property>
- <property name="page_increment">10</property>
- <property name="step_increment">1</property>
- <property name="page_size">0</property>
- <property name="value">2</property>
- </object>
- <object class="GtkListStore" id="model1">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">Undefined</col>
- </row>
- <row>
- <col id="0" translatable="yes">High</col>
- </row>
- <row>
- <col id="0" translatable="yes">Standard</col>
- </row>
- <row>
- <col id="0" translatable="yes">Low</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model2">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">Normal</col>
- </row>
- <row>
- <col id="0" translatable="yes">Proprietary</col>
- </row>
- <row>
- <col id="0" translatable="yes">Confidential</col>
- </row>
- <row>
- <col id="0" translatable="yes">Secret</col>
- </row>
- <row>
- <col id="0" translatable="yes">Top Secret</col>
- </row>
- <row>
- <col id="0" translatable="yes">For Your Eyes Only</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model3">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="send-options" comments="Translators: Used in send options dialog">None</col>
- </row>
- <row>
- <col id="0" translatable="yes">Mail Receipt</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model4">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="send-options">None</col>
- </row>
- <row>
- <col id="0" translatable="yes">Mail Receipt</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model5">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="send-options">None</col>
- </row>
- <row>
- <col id="0" translatable="yes">Mail Receipt</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model6">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="send-options">None</col>
- </row>
- <row>
- <col id="0" translatable="yes">Mail Receipt</col>
- </row>
- </data>
- </object>
- <!-- interface-requires gtk+ 2.16 -->
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkDialog" id="send-options-dialog">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="title" translatable="yes">Send Options</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="window_position">mouse</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="vbox">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <child>
- <object class="GtkNotebook" id="notebook">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkTable" id="general-options">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="n_rows">4</property>
- <property name="n_columns">4</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
- <child>
- <object class="GtkLabel" id="label92">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">4</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame16">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkTable" id="table32">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="n_rows">2</property>
- <property name="n_columns">3</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
- <child>
- <object class="GtkCheckButton" id="reply-request-button">
- <property name="label" translatable="yes">R_eply requested</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="right_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment38">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="table33">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">3</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
- <child>
- <object class="GtkRadioButton" id="reply-within">
- <property name="label" translatable="yes" comments="Translators: This is part of 'Within [ X ] days', where [ X ] is a spinner with a number" context="ESendOptionsWithin">Wi_thin</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="within-days">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment1</property>
- <property name="climb_rate">1</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label93">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translators: This is part of 'Within [ X ] days', where [ X ] is a spinner with a number" context="ESendOptionsWithin">days</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="reply-convinient">
- <property name="label" translatable="yes">_When convenient</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">reply-within</property>
- </object>
- <packing>
- <property name="right_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"/>
- <property name="y_options"/>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label94">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Replies</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame17">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkTable" id="table34">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <child>
- <object class="GtkCheckButton" id="delay-delivery-button">
- <property comments="To translators: This means Delay the message delivery for some time" name="label" translatable="yes">_Delay message delivery</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label95">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment39">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkHBox" id="hbox11">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="label96">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translators: This is part of 'After [ X ] days', where [ X ] is a spinner with a number" context="ESendOptionsAfter">_After</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">expire-after</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="expire-after">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment2</property>
- <property name="climb_rate">1</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label97">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translators: This is part of 'After [ X ] days', where [ X ] is a spinner with a number" context="ESendOptionsAfter">days</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="expiration-button">
- <property name="label" translatable="yes">_Set expiration date</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label98">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment40">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkHBox" id="hbox13">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="until-label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translators: This is part of 'Until [ date ]', where [ date ] is a date picker" context="ESendOptions">_Until</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">until-date</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="EDateEdit" id="until-date">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label103">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Delivery Options</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="right_attach">4</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="combo-priority">
- <property name="visible">True</property>
- <property name="model">model1</property>
- <child>
- <object class="GtkCellRendererText" id="renderer1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="priority-label">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Priority:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">combo-priority</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="security-label">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Classification:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">security-combo</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="security-combo">
- <property name="visible">True</property>
- <property name="model">model2</property>
- <child>
- <object class="GtkCellRendererText" id="renderer2"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="gopts-label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Gene_ral Options</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="status-tracking">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkFrame" id="frame18">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment42">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox10">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkCheckButton" id="create-sent-button">
- <property name="label" translatable="yes">Creat_e a sent item to track information</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment46">
- <property name="visible">True</property>
- <property name="left_padding">19</property>
- <child>
- <object class="GtkRadioButton" id="delivered">
- <property name="label" translatable="yes">_Delivered</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment47">
- <property name="visible">True</property>
- <property name="left_padding">19</property>
- <child>
- <object class="GtkRadioButton" id="delivered-opened">
- <property name="label" translatable="yes">Deli_vered and opened</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">delivered</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment48">
- <property name="visible">True</property>
- <property name="left_padding">19</property>
- <child>
- <object class="GtkRadioButton" id="all-info">
- <property name="label" translatable="yes">_All information</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">delivered</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment56">
- <property name="visible">True</property>
- <property name="left_padding">19</property>
- <child>
- <object class="GtkCheckButton" id="autodelete">
- <property name="label" translatable="yes">A_uto-delete sent item</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label106">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Status Tracking</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame19">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment43">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="table35">
- <property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
- <child>
- <object class="GtkLabel" id="opened-label">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_When opened:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">open-combo</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="declined-label">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">When decli_ned:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">delete-combo</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="completed-label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">When co_mpleted:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">complete-combo</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="accepted-label">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">When acce_pted:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">accept-combo</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="open-combo">
- <property name="visible">True</property>
- <property name="model">model3</property>
- <child>
- <object class="GtkCellRendererText" id="renderer3"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="delete-combo">
- <property name="visible">True</property>
- <property name="model">model4</property>
- <child>
- <object class="GtkCellRendererText" id="renderer4"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="accept-combo">
- <property name="visible">True</property>
- <property name="model">model5</property>
- <child>
- <object class="GtkCellRendererText" id="renderer5"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="complete-combo">
- <property name="visible">True</property>
- <property name="model">model6</property>
- <child>
- <object class="GtkCellRendererText" id="renderer6"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label111">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Return Notification</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="slabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Sta_tus Tracking</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="helpbutton1">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="cancelbutton1">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="okbutton1">
- <property name="label">gtk-ok</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-11">helpbutton1</action-widget>
- <action-widget response="-6">cancelbutton1</action-widget>
- <action-widget response="-5">okbutton1</action-widget>
- </action-widgets>
- </object>
-</interface>
diff --git a/widgets/misc/e-source-config-backend.c b/widgets/misc/e-source-config-backend.c
deleted file mode 100644
index e6802f99ae..0000000000
--- a/widgets/misc/e-source-config-backend.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * e-source-config-backend.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-source-config-backend.h"
-
-G_DEFINE_TYPE (
- ESourceConfigBackend,
- e_source_config_backend,
- E_TYPE_EXTENSION)
-
-static gboolean
-source_config_backend_allow_creation (ESourceConfigBackend *backend)
-{
- return TRUE;
-}
-
-static void
-source_config_backend_insert_widgets (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- /* does nothing */
-}
-
-static gboolean
-source_config_backend_check_complete (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- return TRUE;
-}
-
-static void
-source_config_backend_commit_changes (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- /* does nothing */
-}
-
-static void
-e_source_config_backend_class_init (ESourceConfigBackendClass *class)
-{
- EExtensionClass *extension_class;
-
- extension_class = E_EXTENSION_CLASS (class);
- extension_class->extensible_type = E_TYPE_SOURCE_CONFIG;
-
- class->allow_creation = source_config_backend_allow_creation;
- class->insert_widgets = source_config_backend_insert_widgets;
- class->check_complete = source_config_backend_check_complete;
- class->commit_changes = source_config_backend_commit_changes;
-}
-
-static void
-e_source_config_backend_init (ESourceConfigBackend *backend)
-{
-}
-
-ESourceConfig *
-e_source_config_backend_get_config (ESourceConfigBackend *backend)
-{
- EExtensible *extensible;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), NULL);
-
- extensible = e_extension_get_extensible (E_EXTENSION (backend));
-
- return E_SOURCE_CONFIG (extensible);
-}
-
-gboolean
-e_source_config_backend_allow_creation (ESourceConfigBackend *backend)
-{
- ESourceConfigBackendClass *class;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), FALSE);
-
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
- g_return_val_if_fail (class->allow_creation != NULL, FALSE);
-
- return class->allow_creation (backend);
-}
-
-void
-e_source_config_backend_insert_widgets (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- ESourceConfigBackendClass *class;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
- g_return_if_fail (class->insert_widgets != NULL);
-
- class->insert_widgets (backend, scratch_source);
-}
-
-gboolean
-e_source_config_backend_check_complete (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- ESourceConfigBackendClass *class;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (scratch_source), FALSE);
-
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
- g_return_val_if_fail (class->check_complete != NULL, FALSE);
-
- return class->check_complete (backend, scratch_source);
-}
-
-void
-e_source_config_backend_commit_changes (ESourceConfigBackend *backend,
- ESource *scratch_source)
-{
- ESourceConfigBackendClass *class;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
- g_return_if_fail (class->commit_changes != NULL);
-
- class->commit_changes (backend, scratch_source);
-}
diff --git a/widgets/misc/e-source-config-backend.h b/widgets/misc/e-source-config-backend.h
deleted file mode 100644
index 8141cea1a5..0000000000
--- a/widgets/misc/e-source-config-backend.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * e-source-config-backend.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_SOURCE_CONFIG_BACKEND_H
-#define E_SOURCE_CONFIG_BACKEND_H
-
-#include <libebackend/libebackend.h>
-
-#include <misc/e-source-config.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SOURCE_CONFIG_BACKEND \
- (e_source_config_backend_get_type ())
-#define E_SOURCE_CONFIG_BACKEND(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SOURCE_CONFIG_BACKEND, ESourceConfigBackend))
-#define E_SOURCE_CONFIG_BACKEND_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SOURCE_CONFIG_BACKEND, ESourceConfigBackendClass))
-#define E_IS_SOURCE_CONFIG_BACKEND(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SOURCE_CONFIG_BACKEND))
-#define E_IS_SOURCE_CONFIG_BACKEND_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SOURCE_CONFIG_BACKEND))
-#define E_SOURCE_CONFIG_BACKEND_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SOURCE_CONFIG_BACKEND, ESourceConfigBackendClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESourceConfigBackend ESourceConfigBackend;
-typedef struct _ESourceConfigBackendClass ESourceConfigBackendClass;
-typedef struct _ESourceConfigBackendPrivate ESourceConfigBackendPrivate;
-
-struct _ESourceConfigBackend {
- EExtension parent;
- ESourceConfigBackendPrivate *priv;
-};
-
-struct _ESourceConfigBackendClass {
- EExtensionClass parent_class;
-
- /* This should match backend names used in ESourceBackend. */
- const gchar *backend_name;
-
- /* Optional. Collection-based backends can leave this NULL.
- * This is only for sources which have a fixed parent source,
- * usually one of the "stub" placeholders ("local-stub", etc). */
- const gchar *parent_uid;
-
- gboolean (*allow_creation) (ESourceConfigBackend *backend);
- void (*insert_widgets) (ESourceConfigBackend *backend,
- ESource *scratch_source);
- gboolean (*check_complete) (ESourceConfigBackend *backend,
- ESource *scratch_source);
- void (*commit_changes) (ESourceConfigBackend *backend,
- ESource *scratch_source);
-};
-
-GType e_source_config_backend_get_type
- (void) G_GNUC_CONST;
-ESourceConfig * e_source_config_backend_get_config
- (ESourceConfigBackend *backend);
-gboolean e_source_config_backend_allow_creation
- (ESourceConfigBackend *backend);
-void e_source_config_backend_insert_widgets
- (ESourceConfigBackend *backend,
- ESource *scratch_source);
-gboolean e_source_config_backend_check_complete
- (ESourceConfigBackend *backend,
- ESource *scratch_source);
-void e_source_config_backend_commit_changes
- (ESourceConfigBackend *backend,
- ESource *scratch_source);
-
-G_END_DECLS
-
-#endif /* E_SOURCE_CONFIG_BACKEND_H */
diff --git a/widgets/misc/e-source-config-dialog.c b/widgets/misc/e-source-config-dialog.c
deleted file mode 100644
index 437027e498..0000000000
--- a/widgets/misc/e-source-config-dialog.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * e-source-config-dialog.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-source-config-dialog.h"
-
-#include <libevolution-utils/e-alert-dialog.h>
-#include <libevolution-utils/e-alert-sink.h>
-#include <misc/e-alert-bar.h>
-
-#define E_SOURCE_CONFIG_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SOURCE_CONFIG_DIALOG, ESourceConfigDialogPrivate))
-
-struct _ESourceConfigDialogPrivate {
- ESourceConfig *config;
- ESourceRegistry *registry;
-
- GtkWidget *alert_bar;
- gulong alert_bar_visible_handler_id;
-};
-
-enum {
- PROP_0,
- PROP_CONFIG
-};
-
-/* Forward Declarations */
-static void e_source_config_dialog_alert_sink_init
- (EAlertSinkInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- ESourceConfigDialog,
- e_source_config_dialog,
- GTK_TYPE_DIALOG,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ALERT_SINK,
- e_source_config_dialog_alert_sink_init))
-
-static void
-source_config_dialog_commit_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ESourceConfig *config;
- ESourceConfigDialog *dialog;
- GdkWindow *gdk_window;
- GError *error = NULL;
-
- config = E_SOURCE_CONFIG (object);
- dialog = E_SOURCE_CONFIG_DIALOG (user_data);
-
- /* Set the cursor back to normal. */
- gdk_window = gtk_widget_get_window (GTK_WIDGET (dialog));
- gdk_window_set_cursor (gdk_window, NULL);
-
- /* Allow user interaction with window content. */
- gtk_widget_set_sensitive (GTK_WIDGET (dialog), TRUE);
-
- e_source_config_commit_finish (config, result, &error);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_object_unref (dialog);
- g_error_free (error);
-
- } else if (error != NULL) {
- e_alert_submit (
- E_ALERT_SINK (dialog),
- "system:simple-error",
- error->message, NULL);
- g_object_unref (dialog);
- g_error_free (error);
-
- } else {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
-}
-
-static void
-source_config_dialog_commit (ESourceConfigDialog *dialog)
-{
- GdkCursor *gdk_cursor;
- GdkWindow *gdk_window;
- ESourceConfig *config;
-
- config = e_source_config_dialog_get_config (dialog);
-
- /* Clear any previous alerts. */
- e_alert_bar_clear (E_ALERT_BAR (dialog->priv->alert_bar));
-
- /* Make the cursor appear busy. */
- gdk_cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window = gtk_widget_get_window (GTK_WIDGET (dialog));
- gdk_window_set_cursor (gdk_window, gdk_cursor);
- g_object_unref (gdk_cursor);
-
- /* Prevent user interaction with window content. */
- gtk_widget_set_sensitive (GTK_WIDGET (dialog), FALSE);
-
- /* XXX This operation is not cancellable. */
- e_source_config_commit (
- config, NULL,
- source_config_dialog_commit_cb,
- g_object_ref (dialog));
-}
-
-static void
-source_config_dialog_source_removed_cb (ESourceRegistry *registry,
- ESource *removed_source,
- ESourceConfigDialog *dialog)
-{
- ESourceConfig *config;
- ESource *original_source;
-
- /* If the ESource being edited is removed, cancel the dialog. */
-
- config = e_source_config_dialog_get_config (dialog);
- original_source = e_source_config_get_original_source (config);
-
- if (original_source == NULL)
- return;
-
- if (!e_source_equal (original_source, removed_source))
- return;
-
- gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-}
-
-static void
-source_config_alert_bar_visible_cb (EAlertBar *alert_bar,
- GParamSpec *pspec,
- ESourceConfigDialog *dialog)
-{
- e_source_config_resize_window (dialog->priv->config);
-}
-
-static void
-source_config_dialog_set_config (ESourceConfigDialog *dialog,
- ESourceConfig *config)
-{
- ESourceRegistry *registry;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (dialog->priv->config == NULL);
-
- dialog->priv->config = g_object_ref (config);
-
- registry = e_source_config_get_registry (config);
- dialog->priv->registry = g_object_ref (registry);
-
- g_signal_connect (
- registry, "source-removed",
- G_CALLBACK (source_config_dialog_source_removed_cb), dialog);
-}
-
-static void
-source_config_dialog_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CONFIG:
- source_config_dialog_set_config (
- E_SOURCE_CONFIG_DIALOG (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-source_config_dialog_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CONFIG:
- g_value_set_object (
- value,
- e_source_config_dialog_get_config (
- E_SOURCE_CONFIG_DIALOG (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-source_config_dialog_dispose (GObject *object)
-{
- ESourceConfigDialogPrivate *priv;
-
- priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (object);
-
- if (priv->config != NULL) {
- g_object_unref (priv->config);
- priv->config = NULL;
- }
-
- if (priv->registry != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->registry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->alert_bar != NULL) {
- g_signal_handler_disconnect (
- priv->alert_bar,
- priv->alert_bar_visible_handler_id);
- g_object_unref (priv->alert_bar);
- priv->alert_bar = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_source_config_dialog_parent_class)->dispose (object);
-}
-
-static void
-source_config_dialog_constructed (GObject *object)
-{
- ESourceConfigDialogPrivate *priv;
- GtkWidget *content_area;
- GtkWidget *config;
- GtkWidget *widget;
- gulong handler_id;
-
- priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (object);
-
- config = GTK_WIDGET (priv->config);
-
- widget = gtk_dialog_get_widget_for_response (
- GTK_DIALOG (object), GTK_RESPONSE_OK);
-
- gtk_container_set_border_width (GTK_CONTAINER (object), 5);
- gtk_container_set_border_width (GTK_CONTAINER (config), 5);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (object));
- gtk_box_pack_start (GTK_BOX (content_area), config, TRUE, TRUE, 0);
- gtk_widget_show (config);
-
- /* Don't use G_BINDING_SYNC_CREATE here. The ESourceConfig widget
- * is not ready to run check_complete() until after it's realized. */
- g_object_bind_property (
- config, "complete",
- widget, "sensitive",
- G_BINDING_DEFAULT);
-
- widget = e_alert_bar_new ();
- gtk_box_pack_start (GTK_BOX (content_area), widget, FALSE, FALSE, 0);
- priv->alert_bar = g_object_ref (widget);
- /* EAlertBar controls its own visibility. */
-
- handler_id = g_signal_connect (
- priv->alert_bar, "notify::visible",
- G_CALLBACK (source_config_alert_bar_visible_cb), object);
-
- priv->alert_bar_visible_handler_id = handler_id;
-}
-
-static void
-source_config_dialog_response (GtkDialog *dialog,
- gint response_id)
-{
- /* Do not chain up. GtkDialog does not implement this method. */
-
- switch (response_id) {
- case GTK_RESPONSE_OK:
- source_config_dialog_commit (
- E_SOURCE_CONFIG_DIALOG (dialog));
- break;
- case GTK_RESPONSE_CANCEL:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
- default:
- break;
- }
-}
-
-static void
-source_config_dialog_submit_alert (EAlertSink *alert_sink,
- EAlert *alert)
-{
- ESourceConfigDialogPrivate *priv;
- EAlertBar *alert_bar;
- GtkWidget *dialog;
- GtkWindow *parent;
-
- priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (alert_sink);
-
- switch (e_alert_get_message_type (alert)) {
- case GTK_MESSAGE_INFO:
- case GTK_MESSAGE_WARNING:
- case GTK_MESSAGE_ERROR:
- alert_bar = E_ALERT_BAR (priv->alert_bar);
- e_alert_bar_add_alert (alert_bar, alert);
- break;
-
- default:
- parent = GTK_WINDOW (alert_sink);
- dialog = e_alert_dialog_new (parent, alert);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- break;
- }
-}
-
-static void
-e_source_config_dialog_class_init (ESourceConfigDialogClass *class)
-{
- GObjectClass *object_class;
- GtkDialogClass *dialog_class;
-
- g_type_class_add_private (class, sizeof (ESourceConfigDialogPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = source_config_dialog_set_property;
- object_class->get_property = source_config_dialog_get_property;
- object_class->dispose = source_config_dialog_dispose;
- object_class->constructed = source_config_dialog_constructed;
-
- dialog_class = GTK_DIALOG_CLASS (class);
- dialog_class->response = source_config_dialog_response;
-
- g_object_class_install_property (
- object_class,
- PROP_CONFIG,
- g_param_spec_object (
- "config",
- "Config",
- "The ESourceConfig instance",
- E_TYPE_SOURCE_CONFIG,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-static void
-e_source_config_dialog_alert_sink_init (EAlertSinkInterface *interface)
-{
- interface->submit_alert = source_config_dialog_submit_alert;
-}
-
-static void
-e_source_config_dialog_init (ESourceConfigDialog *dialog)
-{
- dialog->priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (dialog);
-
- gtk_dialog_add_buttons (
- GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- gtk_dialog_set_default_response (
- GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-}
-
-GtkWidget *
-e_source_config_dialog_new (ESourceConfig *config)
-{
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- return g_object_new (
- E_TYPE_SOURCE_CONFIG_DIALOG,
- "config", config, NULL);
-}
-
-ESourceConfig *
-e_source_config_dialog_get_config (ESourceConfigDialog *dialog)
-{
- g_return_val_if_fail (E_IS_SOURCE_CONFIG_DIALOG (dialog), NULL);
-
- return dialog->priv->config;
-}
diff --git a/widgets/misc/e-source-config-dialog.h b/widgets/misc/e-source-config-dialog.h
deleted file mode 100644
index b4e49efc63..0000000000
--- a/widgets/misc/e-source-config-dialog.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * e-source-config-dialog.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_SOURCE_CONFIG_DIALOG_H
-#define E_SOURCE_CONFIG_DIALOG_H
-
-#include <misc/e-source-config.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SOURCE_CONFIG_DIALOG \
- (e_source_config_dialog_get_type ())
-#define E_SOURCE_CONFIG_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SOURCE_CONFIG_DIALOG, ESourceConfigDialog))
-#define E_SOURCE_CONFIG_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SOURCE_CONFIG_DIALOG, ESourceConfigDialogClass))
-#define E_IS_SOURCE_CONFIG_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SOURCE_CONFIG_DIALOG))
-#define E_IS_SOURCE_CONFIG_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SOURCE_CONFIG_DIALOG))
-#define E_SOURCE_CONFIG_DIALOG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SOURCE_CONFIG_DIALOG, ESourceConfigDialogClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESourceConfigDialog ESourceConfigDialog;
-typedef struct _ESourceConfigDialogClass ESourceConfigDialogClass;
-typedef struct _ESourceConfigDialogPrivate ESourceConfigDialogPrivate;
-
-struct _ESourceConfigDialog {
- GtkDialog parent;
- ESourceConfigDialogPrivate *priv;
-};
-
-struct _ESourceConfigDialogClass {
- GtkDialogClass parent_class;
-};
-
-GType e_source_config_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget * e_source_config_dialog_new (ESourceConfig *config);
-ESourceConfig * e_source_config_dialog_get_config
- (ESourceConfigDialog *dialog);
-
-G_END_DECLS
-
-#endif /* E_SOURCE_CONFIG_DIALOG_H */
diff --git a/widgets/misc/e-source-config.c b/widgets/misc/e-source-config.c
deleted file mode 100644
index f5ef35287c..0000000000
--- a/widgets/misc/e-source-config.c
+++ /dev/null
@@ -1,1448 +0,0 @@
-/*
- * e-source-config.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-source-config.h"
-
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#include <libebackend/libebackend.h>
-
-#include <e-util/e-marshal.h>
-#include <misc/e-interval-chooser.h>
-
-#include "e-source-config-backend.h"
-
-#define E_SOURCE_CONFIG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SOURCE_CONFIG, ESourceConfigPrivate))
-
-typedef struct _Candidate Candidate;
-
-struct _ESourceConfigPrivate {
- ESource *original_source;
- ESource *collection_source;
- ESourceRegistry *registry;
-
- GHashTable *backends;
- GPtrArray *candidates;
-
- GtkWidget *type_label;
- GtkWidget *type_combo;
- GtkWidget *name_label;
- GtkWidget *name_entry;
- GtkWidget *backend_box;
- GtkSizeGroup *size_group;
-
- gboolean complete;
-};
-
-struct _Candidate {
- GtkWidget *page;
- ESource *scratch_source;
- ESourceConfigBackend *backend;
- gulong changed_handler_id;
-};
-
-enum {
- PROP_0,
- PROP_COLLECTION_SOURCE,
- PROP_COMPLETE,
- PROP_ORIGINAL_SOURCE,
- PROP_REGISTRY
-};
-
-enum {
- CHECK_COMPLETE,
- COMMIT_CHANGES,
- INIT_CANDIDATE,
- RESIZE_WINDOW,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (
- ESourceConfig,
- e_source_config,
- GTK_TYPE_BOX,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL))
-
-static void
-source_config_init_backends (ESourceConfig *config)
-{
- GList *list, *iter;
-
- config->priv->backends = g_hash_table_new_full (
- (GHashFunc) g_str_hash,
- (GEqualFunc) g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_object_unref);
-
- e_extensible_load_extensions (E_EXTENSIBLE (config));
-
- list = e_extensible_list_extensions (
- E_EXTENSIBLE (config), E_TYPE_SOURCE_CONFIG_BACKEND);
-
- for (iter = list; iter != NULL; iter = g_list_next (iter)) {
- ESourceConfigBackend *backend;
- ESourceConfigBackendClass *class;
-
- backend = E_SOURCE_CONFIG_BACKEND (iter->data);
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
-
- if (class->backend_name != NULL)
- g_hash_table_insert (
- config->priv->backends,
- g_strdup (class->backend_name),
- g_object_ref (backend));
- }
-
- g_list_free (list);
-}
-
-static gint
-source_config_compare_sources (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- ESource *source_a;
- ESource *source_b;
- ESource *parent_a;
- ESource *parent_b;
- ESourceConfig *config;
- ESourceRegistry *registry;
- const gchar *parent_uid_a;
- const gchar *parent_uid_b;
- gint result;
-
- source_a = E_SOURCE (a);
- source_b = E_SOURCE (b);
- config = E_SOURCE_CONFIG (user_data);
-
- if (e_source_equal (source_a, source_b))
- return 0;
-
- /* "On This Computer" always comes first. */
-
- parent_uid_a = e_source_get_parent (source_a);
- parent_uid_b = e_source_get_parent (source_b);
-
- if (g_strcmp0 (parent_uid_a, "local-stub") == 0)
- return -1;
-
- if (g_strcmp0 (parent_uid_b, "local-stub") == 0)
- return 1;
-
- registry = e_source_config_get_registry (config);
-
- parent_a = e_source_registry_ref_source (registry, parent_uid_a);
- parent_b = e_source_registry_ref_source (registry, parent_uid_b);
-
- g_return_val_if_fail (parent_a != NULL, 1);
- g_return_val_if_fail (parent_b != NULL, -1);
-
- result = e_source_compare_by_display_name (parent_a, parent_b);
-
- g_object_unref (parent_a);
- g_object_unref (parent_b);
-
- return result;
-}
-
-static void
-source_config_add_candidate (ESourceConfig *config,
- ESource *scratch_source,
- ESourceConfigBackend *backend)
-{
- Candidate *candidate;
- GtkBox *backend_box;
- GtkLabel *type_label;
- GtkComboBoxText *type_combo;
- ESource *parent_source;
- ESourceRegistry *registry;
- const gchar *display_name;
- const gchar *parent_uid;
- gulong handler_id;
-
- backend_box = GTK_BOX (config->priv->backend_box);
- type_label = GTK_LABEL (config->priv->type_label);
- type_combo = GTK_COMBO_BOX_TEXT (config->priv->type_combo);
-
- registry = e_source_config_get_registry (config);
- parent_uid = e_source_get_parent (scratch_source);
- parent_source = e_source_registry_ref_source (registry, parent_uid);
- g_return_if_fail (parent_source != NULL);
-
- candidate = g_slice_new (Candidate);
- candidate->backend = g_object_ref (backend);
- candidate->scratch_source = g_object_ref (scratch_source);
-
- /* Do not show the page here. */
- candidate->page = g_object_ref_sink (gtk_vbox_new (FALSE, 6));
- gtk_box_pack_start (backend_box, candidate->page, FALSE, FALSE, 0);
-
- g_ptr_array_add (config->priv->candidates, candidate);
-
- display_name = e_source_get_display_name (parent_source);
- gtk_combo_box_text_append_text (type_combo, display_name);
- gtk_label_set_text (type_label, display_name);
-
- /* Make sure the combo box has a valid active item before
- * adding widgets. Otherwise we'll get run-time warnings
- * as property bindings are set up. */
- if (gtk_combo_box_get_active (GTK_COMBO_BOX (type_combo)) == -1)
- gtk_combo_box_set_active (GTK_COMBO_BOX (type_combo), 0);
-
- /* Bind the standard widgets to the new scratch source. */
- g_signal_emit (
- config, signals[INIT_CANDIDATE], 0,
- candidate->scratch_source);
-
- /* Insert any backend-specific widgets. */
- e_source_config_backend_insert_widgets (
- candidate->backend, candidate->scratch_source);
-
- handler_id = g_signal_connect_swapped (
- candidate->scratch_source, "changed",
- G_CALLBACK (e_source_config_check_complete), config);
-
- candidate->changed_handler_id = handler_id;
-
- /* Trigger the "changed" handler we just connected to set the
- * initial "complete" state based on the widgets we just added. */
- e_source_changed (candidate->scratch_source);
-
- g_object_unref (parent_source);
-}
-
-static void
-source_config_free_candidate (Candidate *candidate)
-{
- g_signal_handler_disconnect (
- candidate->scratch_source,
- candidate->changed_handler_id);
-
- g_object_unref (candidate->page);
- g_object_unref (candidate->scratch_source);
- g_object_unref (candidate->backend);
-
- g_slice_free (Candidate, candidate);
-}
-
-static Candidate *
-source_config_get_active_candidate (ESourceConfig *config)
-{
- GtkComboBox *type_combo;
- gint index;
-
- type_combo = GTK_COMBO_BOX (config->priv->type_combo);
- index = gtk_combo_box_get_active (type_combo);
- g_return_val_if_fail (index >= 0, NULL);
-
- return g_ptr_array_index (config->priv->candidates, index);
-}
-
-static void
-source_config_type_combo_changed_cb (GtkComboBox *type_combo,
- ESourceConfig *config)
-{
- Candidate *candidate;
- GPtrArray *array;
- gint index;
-
- array = config->priv->candidates;
-
- for (index = 0; index < array->len; index++) {
- candidate = g_ptr_array_index (array, index);
- gtk_widget_hide (candidate->page);
- }
-
- index = gtk_combo_box_get_active (type_combo);
- if (index == CLAMP (index, 0, array->len)) {
- candidate = g_ptr_array_index (array, index);
- gtk_widget_show (candidate->page);
- }
-
- e_source_config_resize_window (config);
- e_source_config_check_complete (config);
-}
-
-static gboolean
-source_config_init_for_adding_source_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- ESource *scratch_source;
- ESourceBackend *extension;
- ESourceConfig *config;
- ESourceConfigBackend *backend;
- ESourceConfigBackendClass *class;
- const gchar *extension_name;
-
- scratch_source = E_SOURCE (key);
- backend = E_SOURCE_CONFIG_BACKEND (value);
- config = E_SOURCE_CONFIG (user_data);
-
- /* This may not be the correct backend name for the child of a
- * collection. For example, the "yahoo" collection backend uses
- * the "caldav" calender backend for calendar children. But the
- * ESourceCollectionBackend can override our setting if needed. */
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
- extension_name = e_source_config_get_backend_extension_name (config);
- extension = e_source_get_extension (scratch_source, extension_name);
- e_source_backend_set_backend_name (extension, class->backend_name);
-
- source_config_add_candidate (config, scratch_source, backend);
-
- return FALSE; /* don't stop traversal */
-}
-
-static void
-source_config_init_for_adding_source (ESourceConfig *config)
-{
- GList *list, *link;
- ESourceRegistry *registry;
- GTree *scratch_source_tree;
-
- /* Candidates are drawn from two sources:
- *
- * ESourceConfigBackend classes that specify a fixed parent UID,
- * meaning there exists one only possible parent source for any
- * scratch source created by the backend. The fixed parent UID
- * should be a built-in "stub" placeholder ("local-stub", etc).
- *
- * -and-
- *
- * Collection sources. We let ESourceConfig subclasses gather
- * eligible collection sources to serve as parents for scratch
- * sources. A scratch source is matched to a backend based on
- * the collection's backend name. The "calendar-enabled" and
- * "contacts-enabled" settings also factor into eligibility.
- */
-
- /* Use a GTree instead of a GHashTable so inserted scratch
- * sources automatically sort themselves by their parent's
- * display name. */
- scratch_source_tree = g_tree_new_full (
- source_config_compare_sources, config,
- (GDestroyNotify) g_object_unref,
- (GDestroyNotify) g_object_unref);
-
- registry = e_source_config_get_registry (config);
-
- /* First pick out the backends with a fixed parent UID. */
-
- list = g_hash_table_get_values (config->priv->backends);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESourceConfigBackend *backend;
- ESourceConfigBackendClass *class;
- ESource *scratch_source;
- ESource *parent_source;
- gboolean parent_is_disabled;
-
- backend = E_SOURCE_CONFIG_BACKEND (link->data);
- class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
-
- if (class->parent_uid == NULL)
- continue;
-
- /* Verify the fixed parent UID is valid. */
- parent_source = e_source_registry_ref_source (
- registry, class->parent_uid);
- if (parent_source == NULL) {
- g_warning (
- "%s: %sClass specifies "
- "an invalid parent_uid '%s'",
- G_STRFUNC,
- G_OBJECT_TYPE_NAME (backend),
- class->parent_uid);
- continue;
- }
- parent_is_disabled = !e_source_get_enabled (parent_source);
- g_object_unref (parent_source);
-
- /* It's unusual for a fixed parent source to be disabled.
- * A user would have to go out of his way to do this, but
- * we should honor it regardless. */
- if (parent_is_disabled)
- continue;
-
- /* Some backends don't allow new sources to be created.
- * The "contacts" calendar backend is one such example. */
- if (!e_source_config_backend_allow_creation (backend))
- continue;
-
- scratch_source = e_source_new (NULL, NULL, NULL);
- g_return_if_fail (scratch_source != NULL);
-
- e_source_set_parent (scratch_source, class->parent_uid);
-
- g_tree_insert (
- scratch_source_tree,
- g_object_ref (scratch_source),
- g_object_ref (backend));
-
- g_object_unref (scratch_source);
- }
-
- g_list_free (list);
-
- /* Next gather eligible collection sources to serve as parents. */
-
- list = e_source_config_list_eligible_collections (config);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESource *parent_source;
- ESource *scratch_source;
- ESourceBackend *extension;
- ESourceConfigBackend *backend = NULL;
- const gchar *backend_name;
- const gchar *parent_uid;
-
- parent_source = E_SOURCE (link->data);
- parent_uid = e_source_get_uid (parent_source);
-
- extension = e_source_get_extension (
- parent_source, E_SOURCE_EXTENSION_COLLECTION);
- backend_name = e_source_backend_get_backend_name (extension);
-
- if (backend_name != NULL)
- backend = g_hash_table_lookup (
- config->priv->backends, backend_name);
-
- if (backend == NULL)
- continue;
-
- /* Some backends disallow creating certain types of
- * resources. For example, the Exchange Web Services
- * backend disallows creating new memo lists. */
- if (!e_source_config_backend_allow_creation (backend))
- continue;
-
- scratch_source = e_source_new (NULL, NULL, NULL);
- g_return_if_fail (scratch_source != NULL);
-
- e_source_set_parent (scratch_source, parent_uid);
-
- g_tree_insert (
- scratch_source_tree,
- g_object_ref (scratch_source),
- g_object_ref (backend));
-
- g_object_unref (scratch_source);
- }
-
- g_list_free_full (list, (GDestroyNotify) g_object_unref);
-
- /* XXX GTree doesn't get as much love as GHashTable.
- * It's missing an equivalent to GHashTableIter. */
- g_tree_foreach (
- scratch_source_tree,
- source_config_init_for_adding_source_foreach, config);
-
- g_tree_unref (scratch_source_tree);
-}
-
-static void
-source_config_init_for_editing_source (ESourceConfig *config)
-{
- ESource *original_source;
- ESource *scratch_source;
- ESourceBackend *extension;
- ESourceConfigBackend *backend;
- GDBusObject *dbus_object;
- const gchar *backend_name;
- const gchar *extension_name;
-
- original_source = e_source_config_get_original_source (config);
- g_return_if_fail (original_source != NULL);
-
- extension_name = e_source_config_get_backend_extension_name (config);
- extension = e_source_get_extension (original_source, extension_name);
- backend_name = e_source_backend_get_backend_name (extension);
- g_return_if_fail (backend_name != NULL);
-
- backend = g_hash_table_lookup (config->priv->backends, backend_name);
- g_return_if_fail (backend != NULL);
-
- dbus_object = e_source_ref_dbus_object (original_source);
- g_return_if_fail (dbus_object != NULL);
-
- scratch_source = e_source_new (dbus_object, NULL, NULL);
- g_return_if_fail (scratch_source != NULL);
-
- source_config_add_candidate (config, scratch_source, backend);
-
- g_object_unref (scratch_source);
- g_object_unref (dbus_object);
-}
-
-static void
-source_config_set_original_source (ESourceConfig *config,
- ESource *original_source)
-{
- g_return_if_fail (config->priv->original_source == NULL);
-
- if (original_source != NULL)
- g_object_ref (original_source);
-
- config->priv->original_source = original_source;
-}
-
-static void
-source_config_set_registry (ESourceConfig *config,
- ESourceRegistry *registry)
-{
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
- g_return_if_fail (config->priv->registry == NULL);
-
- config->priv->registry = g_object_ref (registry);
-}
-
-static void
-source_config_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ORIGINAL_SOURCE:
- source_config_set_original_source (
- E_SOURCE_CONFIG (object),
- g_value_get_object (value));
- return;
-
- case PROP_REGISTRY:
- source_config_set_registry (
- E_SOURCE_CONFIG (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-source_config_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_COLLECTION_SOURCE:
- g_value_set_object (
- value,
- e_source_config_get_collection_source (
- E_SOURCE_CONFIG (object)));
- return;
-
- case PROP_COMPLETE:
- g_value_set_boolean (
- value,
- e_source_config_check_complete (
- E_SOURCE_CONFIG (object)));
- return;
-
- case PROP_ORIGINAL_SOURCE:
- g_value_set_object (
- value,
- e_source_config_get_original_source (
- E_SOURCE_CONFIG (object)));
- return;
-
- case PROP_REGISTRY:
- g_value_set_object (
- value,
- e_source_config_get_registry (
- E_SOURCE_CONFIG (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-source_config_dispose (GObject *object)
-{
- ESourceConfigPrivate *priv;
-
- priv = E_SOURCE_CONFIG_GET_PRIVATE (object);
-
- if (priv->original_source != NULL) {
- g_object_unref (priv->original_source);
- priv->original_source = NULL;
- }
-
- if (priv->collection_source != NULL) {
- g_object_unref (priv->collection_source);
- priv->collection_source = NULL;
- }
-
- if (priv->registry != NULL) {
- g_object_unref (priv->registry);
- priv->registry = NULL;
- }
-
- if (priv->type_label != NULL) {
- g_object_unref (priv->type_label);
- priv->type_label = NULL;
- }
-
- if (priv->type_combo != NULL) {
- g_object_unref (priv->type_combo);
- priv->type_combo = NULL;
- }
-
- if (priv->name_label != NULL) {
- g_object_unref (priv->name_label);
- priv->name_label = NULL;
- }
-
- if (priv->name_entry != NULL) {
- g_object_unref (priv->name_entry);
- priv->name_entry = NULL;
- }
-
- if (priv->backend_box != NULL) {
- g_object_unref (priv->backend_box);
- priv->backend_box = NULL;
- }
-
- if (priv->size_group != NULL) {
- g_object_unref (priv->size_group);
- priv->size_group = NULL;
- }
-
- g_hash_table_remove_all (priv->backends);
- g_ptr_array_set_size (priv->candidates, 0);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_source_config_parent_class)->dispose (object);
-}
-
-static void
-source_config_finalize (GObject *object)
-{
- ESourceConfigPrivate *priv;
-
- priv = E_SOURCE_CONFIG_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->backends);
- g_ptr_array_free (priv->candidates, TRUE);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_source_config_parent_class)->finalize (object);
-}
-
-static void
-source_config_constructed (GObject *object)
-{
- ESourceConfig *config;
- ESourceRegistry *registry;
- ESource *original_source;
- ESource *collection_source = NULL;
-
- config = E_SOURCE_CONFIG (object);
- registry = e_source_config_get_registry (config);
- original_source = e_source_config_get_original_source (config);
-
- /* If we have an original source, see if it's part
- * of a collection and note the collection source. */
- if (original_source != NULL) {
- const gchar *extension_name;
-
- extension_name = E_SOURCE_EXTENSION_COLLECTION;
- collection_source = e_source_registry_find_extension (
- registry, original_source, extension_name);
- config->priv->collection_source = collection_source;
- }
-
- if (original_source != NULL)
- e_source_config_insert_widget (
- config, NULL, _("Type:"),
- config->priv->type_label);
- else
- e_source_config_insert_widget (
- config, NULL, _("Type:"),
- config->priv->type_combo);
-
- /* If the original source is part of a collection then we assume
- * the display name is server-assigned and not user-assigned, at
- * least not assigned through Evolution. */
- if (collection_source != NULL)
- e_source_config_insert_widget (
- config, NULL, _("Name:"),
- config->priv->name_label);
- else
- e_source_config_insert_widget (
- config, NULL, _("Name:"),
- config->priv->name_entry);
-
- source_config_init_backends (config);
-}
-
-static void
-source_config_realize (GtkWidget *widget)
-{
- ESourceConfig *config;
- ESource *original_source;
-
- /* Chain up to parent's realize() method. */
- GTK_WIDGET_CLASS (e_source_config_parent_class)->realize (widget);
-
- /* Do this after constructed() so subclasses can fully
- * initialize themselves before we add candidates. */
-
- config = E_SOURCE_CONFIG (widget);
- original_source = e_source_config_get_original_source (config);
-
- if (original_source == NULL)
- source_config_init_for_adding_source (config);
- else
- source_config_init_for_editing_source (config);
-}
-
-static GList *
-source_config_list_eligible_collections (ESourceConfig *config)
-{
- ESourceRegistry *registry;
- GQueue trash = G_QUEUE_INIT;
- GList *list, *link;
- const gchar *extension_name;
-
- extension_name = E_SOURCE_EXTENSION_COLLECTION;
- registry = e_source_config_get_registry (config);
-
- list = e_source_registry_list_sources (registry, extension_name);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESource *source = E_SOURCE (link->data);
- gboolean elligible;
-
- elligible =
- e_source_get_enabled (source) &&
- e_source_get_remote_creatable (source);
-
- if (!elligible)
- g_queue_push_tail (&trash, link);
- }
-
- /* Remove ineligible collections from the list. */
- while ((link = g_queue_pop_head (&trash)) != NULL) {
- g_object_unref (link->data);
- list = g_list_delete_link (list, link);
- }
-
- return list;
-}
-
-static void
-source_config_init_candidate (ESourceConfig *config,
- ESource *scratch_source)
-{
- g_object_bind_property (
- scratch_source, "display-name",
- config->priv->name_label, "label",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- scratch_source, "display-name",
- config->priv->name_entry, "text",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
-
-static gboolean
-source_config_check_complete (ESourceConfig *config,
- ESource *scratch_source)
-{
- GtkEntry *name_entry;
- GtkComboBox *type_combo;
- const gchar *text;
-
- /* Make sure the Type: combo box has a valid item. */
- type_combo = GTK_COMBO_BOX (config->priv->type_combo);
- if (gtk_combo_box_get_active (type_combo) < 0)
- return FALSE;
-
- /* Make sure the Name: entry field is not empty. */
- name_entry = GTK_ENTRY (config->priv->name_entry);
- text = gtk_entry_get_text (name_entry);
- if (text == NULL || *text == '\0')
- return FALSE;
-
- return TRUE;
-}
-
-static void
-source_config_commit_changes (ESourceConfig *config,
- ESource *scratch_source)
-{
- /* Placeholder so subclasses can safely chain up. */
-}
-
-static void
-source_config_resize_window (ESourceConfig *config)
-{
- GtkWidget *toplevel;
-
- /* Expand or shrink our parent window vertically to accommodate
- * the newly selected backend's options. Some backends have tons
- * of options, some have few. This avoids the case where you
- * select a backend with tons of options and then a backend with
- * few options and wind up with lots of unused vertical space. */
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (config));
-
- if (GTK_IS_WINDOW (toplevel)) {
- GtkWindow *window = GTK_WINDOW (toplevel);
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (toplevel, &allocation);
- gtk_window_resize (window, allocation.width, 1);
- }
-}
-
-static gboolean
-source_config_check_complete_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer unused)
-{
- gboolean v_boolean;
-
- /* Abort emission if a handler returns FALSE. */
- v_boolean = g_value_get_boolean (handler_return);
- g_value_set_boolean (return_accu, v_boolean);
-
- return v_boolean;
-}
-
-static void
-e_source_config_class_init (ESourceConfigClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (ESourceConfigPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = source_config_set_property;
- object_class->get_property = source_config_get_property;
- object_class->dispose = source_config_dispose;
- object_class->finalize = source_config_finalize;
- object_class->constructed = source_config_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->realize = source_config_realize;
-
- class->list_eligible_collections =
- source_config_list_eligible_collections;
- class->init_candidate = source_config_init_candidate;
- class->check_complete = source_config_check_complete;
- class->commit_changes = source_config_commit_changes;
- class->resize_window = source_config_resize_window;
-
- g_object_class_install_property (
- object_class,
- PROP_COLLECTION_SOURCE,
- g_param_spec_object (
- "collection-source",
- "Collection Source",
- "The collection ESource to which "
- "the ESource being edited belongs",
- E_TYPE_SOURCE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_COMPLETE,
- g_param_spec_boolean (
- "complete",
- "Complete",
- "Are the required fields complete?",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_ORIGINAL_SOURCE,
- g_param_spec_object (
- "original-source",
- "Original Source",
- "The original ESource",
- E_TYPE_SOURCE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_REGISTRY,
- g_param_spec_object (
- "registry",
- "Registry",
- "Registry of ESources",
- E_TYPE_SOURCE_REGISTRY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- signals[CHECK_COMPLETE] = g_signal_new (
- "check-complete",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceConfigClass, check_complete),
- source_config_check_complete_accumulator, NULL,
- e_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN, 1,
- E_TYPE_SOURCE);
-
- signals[COMMIT_CHANGES] = g_signal_new (
- "commit-changes",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceConfigClass, commit_changes),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- E_TYPE_SOURCE);
-
- signals[INIT_CANDIDATE] = g_signal_new (
- "init-candidate",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceConfigClass, init_candidate),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- E_TYPE_SOURCE);
-
- signals[RESIZE_WINDOW] = g_signal_new (
- "resize-window",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceConfigClass, resize_window),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_source_config_init (ESourceConfig *config)
-{
- GPtrArray *candidates;
- GtkSizeGroup *size_group;
- PangoAttribute *attr;
- PangoAttrList *attr_list;
- GtkWidget *widget;
-
- /* The candidates array holds scratch ESources, one for each
- * item in the "type" combo box. Scratch ESources are never
- * added to the registry, so backend extensions can make any
- * changes they want to them. Whichever scratch ESource is
- * "active" (selected in the "type" combo box) when the user
- * clicks OK wins and is written to disk. The others are
- * discarded. */
- candidates = g_ptr_array_new_with_free_func (
- (GDestroyNotify) source_config_free_candidate);
-
- /* The size group is used for caption labels. */
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- gtk_box_set_spacing (GTK_BOX (config), 6);
-
- gtk_orientable_set_orientation (
- GTK_ORIENTABLE (config), GTK_ORIENTATION_VERTICAL);
-
- config->priv = E_SOURCE_CONFIG_GET_PRIVATE (config);
- config->priv->candidates = candidates;
- config->priv->size_group = size_group;
-
- attr_list = pango_attr_list_new ();
-
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- pango_attr_list_insert (attr_list, attr);
-
- /* Either the source type combo box or the label is shown,
- * never both. But we create both widgets and keep them
- * both up-to-date because it makes the logic simpler. */
-
- widget = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_label_set_attributes (GTK_LABEL (widget), attr_list);
- config->priv->type_label = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- widget = gtk_combo_box_text_new ();
- config->priv->type_combo = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- /* Similarly for the display name. Either the text entry
- * or the label is shown, depending on whether the source
- * is a collection member (new sources never are). */
-
- widget = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_label_set_attributes (GTK_LABEL (widget), attr_list);
- config->priv->name_label = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- widget = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE);
- config->priv->name_entry = g_object_ref_sink (widget);
- gtk_widget_show (widget);
-
- /* The backend box holds backend-specific options. Each backend
- * gets a child widget. Only one child widget is visible at once. */
- widget = gtk_vbox_new (FALSE, 12);
- gtk_box_pack_end (GTK_BOX (config), widget, TRUE, TRUE, 0);
- config->priv->backend_box = g_object_ref (widget);
- gtk_widget_show (widget);
-
- pango_attr_list_unref (attr_list);
-
- g_signal_connect (
- config->priv->type_combo, "changed",
- G_CALLBACK (source_config_type_combo_changed_cb), config);
-}
-
-GtkWidget *
-e_source_config_new (ESourceRegistry *registry,
- ESource *original_source)
-{
- g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
-
- if (original_source != NULL)
- g_return_val_if_fail (E_IS_SOURCE (original_source), NULL);
-
- return g_object_new (
- E_TYPE_SOURCE_CONFIG, "registry", registry,
- "original-source", original_source, NULL);
-}
-
-void
-e_source_config_insert_widget (ESourceConfig *config,
- ESource *scratch_source,
- const gchar *caption,
- GtkWidget *widget)
-{
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *label;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (scratch_source == NULL)
- vbox = GTK_WIDGET (config);
- else
- vbox = e_source_config_get_page (config, scratch_source);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- g_object_bind_property (
- widget, "visible",
- hbox, "visible",
- G_BINDING_SYNC_CREATE);
-
- label = gtk_label_new (caption);
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- gtk_size_group_add_widget (config->priv->size_group, label);
- gtk_widget_show (label);
-
- gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
-}
-
-GtkWidget *
-e_source_config_get_page (ESourceConfig *config,
- ESource *scratch_source)
-{
- Candidate *candidate;
- GtkWidget *page = NULL;
- GPtrArray *array;
- gint index;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
- g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
-
- array = config->priv->candidates;
-
- for (index = 0; page == NULL && index < array->len; index++) {
- candidate = g_ptr_array_index (array, index);
- if (e_source_equal (scratch_source, candidate->scratch_source))
- page = candidate->page;
- }
-
- g_return_val_if_fail (GTK_IS_BOX (page), NULL);
-
- return page;
-}
-
-const gchar *
-e_source_config_get_backend_extension_name (ESourceConfig *config)
-{
- ESourceConfigClass *class;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- class = E_SOURCE_CONFIG_GET_CLASS (config);
- g_return_val_if_fail (class->get_backend_extension_name != NULL, NULL);
-
- return class->get_backend_extension_name (config);
-}
-
-GList *
-e_source_config_list_eligible_collections (ESourceConfig *config)
-{
- ESourceConfigClass *class;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- class = E_SOURCE_CONFIG_GET_CLASS (config);
- g_return_val_if_fail (class->list_eligible_collections != NULL, NULL);
-
- return class->list_eligible_collections (config);
-}
-
-gboolean
-e_source_config_check_complete (ESourceConfig *config)
-{
- Candidate *candidate;
- gboolean complete;
-
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), FALSE);
-
- candidate = source_config_get_active_candidate (config);
- g_return_val_if_fail (candidate != NULL, FALSE);
-
- g_signal_emit (
- config, signals[CHECK_COMPLETE], 0,
- candidate->scratch_source, &complete);
-
- complete &= e_source_config_backend_check_complete (
- candidate->backend, candidate->scratch_source);
-
- /* XXX Emitting "notify::complete" may cause this function
- * to be called repeatedly by signal handlers. The IF
- * check below should break any recursive cycles. Not
- * very efficient but I think we can live with it. */
-
- if (complete != config->priv->complete) {
- config->priv->complete = complete;
- g_object_notify (G_OBJECT (config), "complete");
- }
-
- return complete;
-}
-
-ESource *
-e_source_config_get_original_source (ESourceConfig *config)
-{
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- return config->priv->original_source;
-}
-
-ESource *
-e_source_config_get_collection_source (ESourceConfig *config)
-{
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- return config->priv->collection_source;
-}
-
-ESourceRegistry *
-e_source_config_get_registry (ESourceConfig *config)
-{
- g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL);
-
- return config->priv->registry;
-}
-
-void
-e_source_config_resize_window (ESourceConfig *config)
-{
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
-
- g_signal_emit (config, signals[RESIZE_WINDOW], 0);
-}
-
-/* Helper for e_source_config_commit() */
-static void
-source_config_commit_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
-
- e_source_registry_commit_source_finish (
- E_SOURCE_REGISTRY (object), result, &error);
-
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-void
-e_source_config_commit (ESourceConfig *config,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- ESourceRegistry *registry;
- Candidate *candidate;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
-
- registry = e_source_config_get_registry (config);
-
- candidate = source_config_get_active_candidate (config);
- g_return_if_fail (candidate != NULL);
-
- e_source_config_backend_commit_changes (
- candidate->backend, candidate->scratch_source);
-
- g_signal_emit (
- config, signals[COMMIT_CHANGES], 0,
- candidate->scratch_source);
-
- simple = g_simple_async_result_new (
- G_OBJECT (config), callback,
- user_data, e_source_config_commit);
-
- e_source_registry_commit_source (
- registry, candidate->scratch_source,
- cancellable, source_config_commit_cb, simple);
-}
-
-gboolean
-e_source_config_commit_finish (ESourceConfig *config,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (config),
- e_source_config_commit), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- /* Assume success unless a GError is set. */
- return !g_simple_async_result_propagate_error (simple, error);
-}
-
-void
-e_source_config_add_refresh_interval (ESourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget;
- GtkWidget *container;
- ESourceExtension *extension;
- const gchar *extension_name;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_REFRESH;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- widget = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
- e_source_config_insert_widget (config, scratch_source, NULL, widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- /* Translators: This is the first of a sequence of widgets:
- * "Refresh every [NUMERIC_ENTRY] [TIME_UNITS_COMBO]" */
- widget = gtk_label_new (_("Refresh every"));
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = e_interval_chooser_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- extension, "interval-minutes",
- widget, "interval-minutes",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
-
-void
-e_source_config_add_secure_connection (ESourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget;
- ESourceExtension *extension;
- const gchar *extension_name;
- const gchar *label;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_SECURITY;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- label = _("Use a secure connection");
- widget = gtk_check_button_new_with_label (label);
- e_source_config_insert_widget (config, scratch_source, NULL, widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- extension, "secure",
- widget, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
-
-static gboolean
-secure_to_port_cb (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
- gpointer user_data)
-{
- GObject *authentication_extension;
- guint16 port;
-
- authentication_extension = g_binding_get_target (binding);
- g_object_get (authentication_extension, "port", &port, NULL);
-
- if (port == 80 || port == 443 || port == 0)
- port = g_value_get_boolean (source_value) ? 443 : 80;
-
- g_value_set_uint (target_value, port);
-
- return TRUE;
-}
-
-void
-e_source_config_add_secure_connection_for_webdav (ESourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget1;
- GtkWidget *widget2;
- ESourceExtension *extension;
- ESourceAuthentication *authentication_extension;
- const gchar *extension_name;
- const gchar *label;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_SECURITY;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- label = _("Use a secure connection");
- widget1 = gtk_check_button_new_with_label (label);
- e_source_config_insert_widget (config, scratch_source, NULL, widget1);
- gtk_widget_show (widget1);
-
- g_object_bind_property (
- extension, "secure",
- widget1, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
- authentication_extension = e_source_get_extension (scratch_source, extension_name);
-
- g_object_bind_property_full (
- extension, "secure",
- authentication_extension, "port",
- G_BINDING_DEFAULT,
- secure_to_port_cb,
- NULL, NULL, NULL);
-
- extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- label = _("Ignore invalid SSL certificate");
- widget2 = gtk_check_button_new_with_label (label);
- gtk_widget_set_margin_left (widget2, 24);
- e_source_config_insert_widget (config, scratch_source, NULL, widget2);
- gtk_widget_show (widget2);
-
- g_object_bind_property (
- widget1, "active",
- widget2, "sensitive",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
- extension, "ignore-invalid-cert",
- widget2, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-}
-
-void
-e_source_config_add_user_entry (ESourceConfig *config,
- ESource *scratch_source)
-{
- GtkWidget *widget;
- ESource *original_source;
- ESourceExtension *extension;
- const gchar *extension_name;
-
- g_return_if_fail (E_IS_SOURCE_CONFIG (config));
- g_return_if_fail (E_IS_SOURCE (scratch_source));
-
- extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
- extension = e_source_get_extension (scratch_source, extension_name);
-
- original_source = e_source_config_get_original_source (config);
-
- widget = gtk_entry_new ();
- e_source_config_insert_widget (
- config, scratch_source, _("User"), widget);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- extension, "user",
- widget, "text",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* If this is a new data source, initialize the
- * GtkEntry to the user name of the current user. */
- if (original_source == NULL)
- gtk_entry_set_text (GTK_ENTRY (widget), g_get_user_name ());
-}
-
diff --git a/widgets/misc/e-source-config.h b/widgets/misc/e-source-config.h
deleted file mode 100644
index 5d9ff7c93a..0000000000
--- a/widgets/misc/e-source-config.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * e-source-config.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_SOURCE_CONFIG_H
-#define E_SOURCE_CONFIG_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/libedataserver.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SOURCE_CONFIG \
- (e_source_config_get_type ())
-#define E_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SOURCE_CONFIG, ESourceConfig))
-#define E_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SOURCE_CONFIG, ESourceConfigClass))
-#define E_IS_SOURCE_CONFIG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SOURCE_CONFIG))
-#define E_IS_SOURCE_CONFIG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SOURCE_CONFIG))
-#define E_SOURCE_CONFIG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SOURCE_CONFIG, ESourceConfigClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESourceConfig ESourceConfig;
-typedef struct _ESourceConfigClass ESourceConfigClass;
-typedef struct _ESourceConfigPrivate ESourceConfigPrivate;
-
-struct _ESourceConfig {
- GtkBox parent;
- ESourceConfigPrivate *priv;
-};
-
-struct _ESourceConfigClass {
- GtkBoxClass parent_class;
-
- /* Methods */
- const gchar * (*get_backend_extension_name)
- (ESourceConfig *config);
- GList * (*list_eligible_collections)
- (ESourceConfig *config);
-
- /* Signals */
- void (*init_candidate) (ESourceConfig *config,
- ESource *scratch_source);
- gboolean (*check_complete) (ESourceConfig *config,
- ESource *scratch_source);
- void (*commit_changes) (ESourceConfig *config,
- ESource *scratch_source);
- void (*resize_window) (ESourceConfig *config);
-};
-
-GType e_source_config_get_type (void) G_GNUC_CONST;
-GtkWidget * e_source_config_new (ESourceRegistry *registry,
- ESource *original_source);
-void e_source_config_insert_widget (ESourceConfig *config,
- ESource *scratch_source,
- const gchar *caption,
- GtkWidget *widget);
-GtkWidget * e_source_config_get_page (ESourceConfig *config,
- ESource *scratch_source);
-const gchar * e_source_config_get_backend_extension_name
- (ESourceConfig *config);
-GList * e_source_config_list_eligible_collections
- (ESourceConfig *config);
-gboolean e_source_config_check_complete (ESourceConfig *config);
-ESource * e_source_config_get_original_source
- (ESourceConfig *config);
-ESource * e_source_config_get_collection_source
- (ESourceConfig *config);
-ESourceRegistry *
- e_source_config_get_registry (ESourceConfig *config);
-void e_source_config_resize_window (ESourceConfig *config);
-void e_source_config_commit (ESourceConfig *config,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean e_source_config_commit_finish (ESourceConfig *config,
- GAsyncResult *result,
- GError **error);
-
-/* Convenience functions for common settings. */
-void e_source_config_add_refresh_interval
- (ESourceConfig *config,
- ESource *scratch_source);
-void e_source_config_add_secure_connection
- (ESourceConfig *config,
- ESource *scratch_source);
-void e_source_config_add_secure_connection_for_webdav
- (ESourceConfig *config,
- ESource *scratch_source);
-void e_source_config_add_user_entry (ESourceConfig *config,
- ESource *scratch_source);
-
-#endif /* E_SOURCE_CONFIG_H */
diff --git a/widgets/misc/e-spell-entry.c b/widgets/misc/e-spell-entry.c
deleted file mode 100644
index 56f7c14f8c..0000000000
--- a/widgets/misc/e-spell-entry.c
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * e-spell-entry.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/* This code is based on libsexy's SexySpellEntry */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-
-#include <editor/gtkhtml-spell-language.h>
-#include <editor/gtkhtml-spell-checker.h>
-
-#include "e-spell-entry.h"
-
-enum {
- PROP_0,
- PROP_CHECKING_ENABLED
-};
-
-struct _ESpellEntryPrivate
-{
- PangoAttrList *attr_list;
- gint mark_character;
- gint entry_scroll_offset;
- GSettings *settings;
- gboolean custom_checkers;
- gboolean checking_enabled;
- GSList *checkers;
- gchar **words;
- gint *word_starts;
- gint *word_ends;
-};
-
-#define E_SPELL_ENTRY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SPELL_ENTRY, ESpellEntryPrivate))
-
-G_DEFINE_TYPE (ESpellEntry, e_spell_entry, GTK_TYPE_ENTRY);
-
-static gboolean
-word_misspelled (ESpellEntry *entry,
- gint start,
- gint end)
-{
- const gchar *text;
- gchar *word;
- gboolean result = TRUE;
-
- if (start == end)
- return FALSE;
-
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- word = g_new0 (gchar, end - start + 2);
-
- g_strlcpy (word, text + start, end - start + 1);
-
- if (g_unichar_isalpha (*word)) {
- GSList *li;
- gssize wlen = strlen (word);
-
- for (li = entry->priv->checkers; li; li = g_slist_next (li)) {
- GtkhtmlSpellChecker *checker = li->data;
- if (gtkhtml_spell_checker_check_word (checker, word, wlen)) {
- result = FALSE;
- break;
- }
- }
- }
- g_free (word);
-
- return result;
-}
-
-static void
-insert_underline (ESpellEntry *entry,
- guint start,
- guint end)
-{
- PangoAttribute *ucolor = pango_attr_underline_color_new (65535, 0, 0);
- PangoAttribute *unline = pango_attr_underline_new (PANGO_UNDERLINE_ERROR);
-
- ucolor->start_index = start;
- unline->start_index = start;
-
- ucolor->end_index = end;
- unline->end_index = end;
-
- pango_attr_list_insert (entry->priv->attr_list, ucolor);
- pango_attr_list_insert (entry->priv->attr_list, unline);
-}
-
-static void
-check_word (ESpellEntry *entry,
- gint start,
- gint end)
-{
- PangoAttrIterator *it;
-
- /* Check to see if we've got any attributes at this position.
- * If so, free them, since we'll readd it if the word is misspelled */
- it = pango_attr_list_get_iterator (entry->priv->attr_list);
-
- if (it == NULL)
- return;
- do {
- gint s, e;
- pango_attr_iterator_range (it, &s, &e);
- if (s == start) {
- GSList *attrs = pango_attr_iterator_get_attrs (it);
- g_slist_foreach (attrs, (GFunc) pango_attribute_destroy, NULL);
- g_slist_free (attrs);
- }
- } while (pango_attr_iterator_next (it));
- pango_attr_iterator_destroy (it);
-
- if (word_misspelled (entry, start, end))
- insert_underline (entry, start, end);
-}
-
-static void
-spell_entry_recheck_all (ESpellEntry *entry)
-{
- GtkWidget *widget = GTK_WIDGET (entry);
- PangoLayout *layout;
- gint length, i;
-
- if (!entry->priv->words)
- return;
-
- /* Remove all existing pango attributes. These will get read as we check */
- pango_attr_list_unref (entry->priv->attr_list);
- entry->priv->attr_list = pango_attr_list_new ();
-
- if (entry->priv->checkers && entry->priv->checking_enabled) {
- /* Loop through words */
- for (i = 0; entry->priv->words[i]; i++) {
- length = strlen (entry->priv->words[i]);
- if (length == 0)
- continue;
- check_word (entry, entry->priv->word_starts[i], entry->priv->word_ends[i]);
- }
-
- layout = gtk_entry_get_layout (GTK_ENTRY (entry));
- pango_layout_set_attributes (layout, entry->priv->attr_list);
- }
-
- if (gtk_widget_get_realized (widget))
- gtk_widget_queue_draw (widget);
-}
-
-static void
-get_word_extents_from_position (ESpellEntry *entry,
- gint *start,
- gint *end,
- guint position)
-{
- const gchar *text;
- gint i, bytes_pos;
-
- *start = -1;
- *end = -1;
-
- if (entry->priv->words == NULL)
- return;
-
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- bytes_pos = (gint) (g_utf8_offset_to_pointer (text, position) - text);
-
- for (i = 0; entry->priv->words[i]; i++) {
- if (bytes_pos >= entry->priv->word_starts[i] &&
- bytes_pos <= entry->priv->word_ends[i]) {
- *start = entry->priv->word_starts[i];
- *end = entry->priv->word_ends[i];
- return;
- }
- }
-}
-
-static void
-entry_strsplit_utf8 (GtkEntry *entry,
- gchar ***set,
- gint **starts,
- gint **ends)
-{
- PangoLayout *layout;
- PangoLogAttr *log_attrs;
- const gchar *text;
- gint n_attrs, n_strings, i, j;
-
- layout = gtk_entry_get_layout (GTK_ENTRY (entry));
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
-
- /* Find how many words we have */
- n_strings = 0;
- for (i = 0; i < n_attrs; i++)
- if (log_attrs[i].is_word_start)
- n_strings++;
-
- *set = g_new0 (gchar *, n_strings + 1);
- *starts = g_new0 (gint, n_strings);
- *ends = g_new0 (gint, n_strings);
-
- /* Copy out strings */
- for (i = 0, j = 0; i < n_attrs; i++) {
- if (log_attrs[i].is_word_start) {
- gint cend, bytes;
- gchar *start;
-
- /* Find the end of this string */
- cend = i;
- while (!(log_attrs[cend].is_word_end))
- cend++;
-
- /* Copy sub-string */
- start = g_utf8_offset_to_pointer (text, i);
- bytes = (gint) (g_utf8_offset_to_pointer (text, cend) - start);
- (*set)[j] = g_new0 (gchar, bytes + 1);
- (*starts)[j] = (gint) (start - text);
- (*ends)[j] = (gint) (start - text + bytes);
- g_utf8_strncpy ((*set)[j], start, cend - i);
-
- /* Move on to the next word */
- j++;
- }
- }
-
- g_free (log_attrs);
-}
-
-static void
-add_to_dictionary (GtkWidget *menuitem,
- ESpellEntry *entry)
-{
- gchar *word;
- gint start, end;
- GtkhtmlSpellChecker *checker;
-
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
- word = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-
- checker = g_object_get_data (G_OBJECT (menuitem), "spell-entry-checker");
- if (checker)
- gtkhtml_spell_checker_add_word (checker, word, -1);
-
- g_free (word);
-
- if (entry->priv->words) {
- g_strfreev (entry->priv->words);
- g_free (entry->priv->word_starts);
- g_free (entry->priv->word_ends);
- }
-
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
- spell_entry_recheck_all (entry);
-}
-
-static void
-ignore_all (GtkWidget *menuitem,
- ESpellEntry *entry)
-{
- gchar *word;
- gint start, end;
- GSList *li;
-
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
- word = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-
- for (li = entry->priv->checkers; li; li = g_slist_next (li)) {
- GtkhtmlSpellChecker *checker = li->data;
- gtkhtml_spell_checker_add_word_to_session (checker, word, -1);
- }
-
- g_free (word);
-
- if (entry->priv->words) {
- g_strfreev (entry->priv->words);
- g_free (entry->priv->word_starts);
- g_free (entry->priv->word_ends);
- }
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
- spell_entry_recheck_all (entry);
-}
-
-static void
-replace_word (GtkWidget *menuitem,
- ESpellEntry *entry)
-{
- gchar *oldword;
- const gchar *newword;
- gint start, end;
- gint cursor;
- GtkhtmlSpellChecker *checker;
-
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
- oldword = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
- newword = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (menuitem))));
-
- cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
- /* is the cursor at the end? If so, restore it there */
- if (g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (entry)), -1) == cursor)
- cursor = -1;
- else if (cursor > start && cursor <= end)
- cursor = start;
-
- gtk_editable_delete_text (GTK_EDITABLE (entry), start, end);
- gtk_editable_set_position (GTK_EDITABLE (entry), start);
- gtk_editable_insert_text (
- GTK_EDITABLE (entry), newword, strlen (newword),
- &start);
- gtk_editable_set_position (GTK_EDITABLE (entry), cursor);
-
- checker = g_object_get_data (G_OBJECT (menuitem), "spell-entry-checker");
-
- if (checker)
- gtkhtml_spell_checker_store_replacement (checker, oldword, -1, newword, -1);
-
- g_free (oldword);
-}
-
-static void
-build_suggestion_menu (ESpellEntry *entry,
- GtkWidget *menu,
- GtkhtmlSpellChecker *checker,
- const gchar *word)
-{
- GtkWidget *mi;
- GList *suggestions, *iter;
-
- suggestions = gtkhtml_spell_checker_get_suggestions (checker, word, -1);
-
- if (!suggestions) {
- /* no suggestions. Put something in the menu anyway... */
- GtkWidget *label = gtk_label_new (_("(no suggestions)"));
- PangoAttribute *attribute;
- PangoAttrList *attribute_list;
-
- attribute_list = pango_attr_list_new ();
- attribute = pango_attr_style_new (PANGO_STYLE_ITALIC);
- pango_attr_list_insert (attribute_list, attribute);
- gtk_label_set_attributes (GTK_LABEL (label), attribute_list);
- pango_attr_list_unref (attribute_list);
-
- mi = gtk_separator_menu_item_new ();
- gtk_container_add (GTK_CONTAINER (mi), label);
- gtk_widget_show_all (mi);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
- } else {
- gint ii = 0;
-
- /* build a set of menus with suggestions */
- for (iter = suggestions; iter; iter = g_list_next (iter), ii++) {
- if ((ii != 0) && (ii % 10 == 0)) {
- mi = gtk_separator_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
- mi = gtk_menu_item_new_with_label (_("More..."));
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
- menu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
- }
-
- mi = gtk_menu_item_new_with_label (iter->data);
- g_object_set_data (G_OBJECT (mi), "spell-entry-checker", checker);
- g_signal_connect (mi, "activate", G_CALLBACK (replace_word), entry);
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
- }
- }
-
- g_list_free_full (suggestions, g_free);
-}
-
-static GtkWidget *
-build_spelling_menu (ESpellEntry *entry,
- const gchar *word)
-{
- GtkhtmlSpellChecker *checker;
- GtkWidget *topmenu, *mi;
- gchar *label;
-
- topmenu = gtk_menu_new ();
-
- if (!entry->priv->checkers)
- return topmenu;
-
- /* Suggestions */
- if (!entry->priv->checkers->next) {
- checker = entry->priv->checkers->data;
- build_suggestion_menu (entry, topmenu, checker, word);
- } else {
- GSList *li;
- GtkWidget *menu;
- const gchar *lang_name;
-
- for (li = entry->priv->checkers; li; li = g_slist_next (li)) {
- const GtkhtmlSpellLanguage *language;
-
- checker = li->data;
- language = gtkhtml_spell_checker_get_language (checker);
- if (!language)
- continue;
-
- lang_name = gtkhtml_spell_language_get_name (language);
- if (!lang_name)
- lang_name = gtkhtml_spell_language_get_code (language);
-
- mi = gtk_menu_item_new_with_label (lang_name ? lang_name : "???");
-
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
- menu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
- build_suggestion_menu (entry, menu, checker, word);
- }
- }
-
- /* Separator */
- mi = gtk_separator_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* + Add to Dictionary */
- label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
- mi = gtk_image_menu_item_new_with_label (label);
- g_free (label);
-
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
-
- if (!entry->priv->checkers->next) {
- checker = entry->priv->checkers->data;
- g_object_set_data (G_OBJECT (mi), "spell-entry-checker", checker);
- g_signal_connect (mi, "activate", G_CALLBACK (add_to_dictionary), entry);
- } else {
- GSList *li;
- GtkWidget *menu, *submi;
- const gchar *lang_name;
-
- menu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
-
- for (li = entry->priv->checkers; li; li = g_slist_next (li)) {
- const GtkhtmlSpellLanguage *language;
-
- checker = li->data;
- language = gtkhtml_spell_checker_get_language (checker);
- if (!language)
- continue;
-
- lang_name = gtkhtml_spell_language_get_name (language);
- if (!lang_name)
- lang_name = gtkhtml_spell_language_get_code (language);
-
- submi = gtk_menu_item_new_with_label (lang_name ? lang_name : "???");
- g_object_set_data (G_OBJECT (submi), "spell-entry-checker", checker);
- g_signal_connect (submi, "activate", G_CALLBACK (add_to_dictionary), entry);
-
- gtk_widget_show (submi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), submi);
- }
- }
-
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* - Ignore All */
- mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
- g_signal_connect (mi, "activate", G_CALLBACK (ignore_all), entry);
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- return topmenu;
-}
-
-static void
-spell_entry_add_suggestions_menu (ESpellEntry *entry,
- GtkMenu *menu,
- const gchar *word)
-{
- GtkWidget *icon, *mi;
-
- g_return_if_fail (menu != NULL);
- g_return_if_fail (word != NULL);
-
- /* separator */
- mi = gtk_separator_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
-
- /* Above the separator, show the suggestions menu */
- icon = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
- mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), icon);
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), build_spelling_menu (entry, word));
-
- gtk_widget_show_all (mi);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
-}
-
-static gboolean
-spell_entry_popup_menu (ESpellEntry *entry)
-{
- /* Menu popped up from a keybinding (menu key or <shift>+F10). Use
- * the cursor position as the mark position */
- entry->priv->mark_character = gtk_editable_get_position (GTK_EDITABLE (entry));
-
- return FALSE;
-}
-
-static void
-spell_entry_populate_popup (ESpellEntry *entry,
- GtkMenu *menu,
- gpointer data)
-{
- gint start, end;
- gchar *word;
-
- if (!entry->priv->checkers)
- return;
-
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
- if (start == end)
- return;
-
- if (!word_misspelled (entry, start, end))
- return;
-
- word = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
- g_return_if_fail (word != NULL);
-
- spell_entry_add_suggestions_menu (entry, menu, word);
-
- g_free (word);
-}
-
-static void
-spell_entry_changed (GtkEditable *editable)
-{
- ESpellEntry *entry = E_SPELL_ENTRY (editable);
-
- if (!entry->priv->checkers)
- return;
-
- if (entry->priv->words) {
- g_strfreev (entry->priv->words);
- g_free (entry->priv->word_starts);
- g_free (entry->priv->word_ends);
- }
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
- spell_entry_recheck_all (entry);
-}
-
-static void
-spell_entry_notify_scroll_offset (ESpellEntry *spell_entry)
-{
- g_return_if_fail (spell_entry != NULL);
-
- g_object_get (G_OBJECT (spell_entry), "scroll-offset", &spell_entry->priv->entry_scroll_offset, NULL);
-}
-
-static GList *
-spell_entry_load_spell_languages (void)
-{
- GSettings *settings;
- GList *spell_languages = NULL;
- gchar **strv;
- gint ii;
-
- /* Ask GSettings for a list of spell check language codes. */
- settings = g_settings_new ("org.gnome.evolution.mail");
- strv = g_settings_get_strv (settings, "composer-spell-languages");
- g_object_unref (settings);
-
- /* Convert the codes to spell language structs. */
- for (ii = 0; strv[ii] != NULL; ii++) {
- gchar *language_code = strv[ii];
- const GtkhtmlSpellLanguage *language;
-
- language = gtkhtml_spell_language_lookup (language_code);
- if (language != NULL)
- spell_languages = g_list_prepend (
- spell_languages, (gpointer) language);
- }
-
- g_strfreev (strv);
-
- spell_languages = g_list_reverse (spell_languages);
-
- /* Pick a default spell language if it came back empty. */
- if (spell_languages == NULL) {
- const GtkhtmlSpellLanguage *language;
-
- language = gtkhtml_spell_language_lookup (NULL);
-
- if (language) {
- spell_languages = g_list_prepend (
- spell_languages, (gpointer) language);
- }
- }
-
- return spell_languages;
-}
-
-static void
-spell_entry_settings_changed (ESpellEntry *spell_entry,
- const gchar *key)
-{
- GList *languages;
-
- g_return_if_fail (spell_entry != NULL);
-
- if (spell_entry->priv->custom_checkers)
- return;
-
- if (key && !g_str_equal (key, "composer-spell-languages"))
- return;
-
- languages = spell_entry_load_spell_languages ();
- e_spell_entry_set_languages (spell_entry, languages);
- g_list_free (languages);
-
- spell_entry->priv->custom_checkers = FALSE;
-}
-
-static gint
-spell_entry_find_position (ESpellEntry *spell_entry,
- gint x)
-{
- PangoLayout *layout;
- PangoLayoutLine *line;
- gint index;
- gint pos;
- gint trailing;
- const gchar *text;
- GtkEntry *entry = GTK_ENTRY (spell_entry);
-
- layout = gtk_entry_get_layout (entry);
- text = pango_layout_get_text (layout);
-
- line = pango_layout_get_lines_readonly (layout)->data;
- pango_layout_line_x_to_index (line, x * PANGO_SCALE, &index, &trailing);
-
- pos = g_utf8_pointer_to_offset (text, text + index);
- pos += trailing;
-
- return pos;
-}
-
-static gboolean
-e_spell_entry_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
- GtkEntry *entry = GTK_ENTRY (widget);
- PangoLayout *layout;
-
- layout = gtk_entry_get_layout (entry);
- pango_layout_set_attributes (layout, spell_entry->priv->attr_list);
-
- return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->draw (widget, cr);
-}
-
-static gboolean
-e_spell_entry_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
-
- spell_entry->priv->mark_character = spell_entry_find_position (
- spell_entry, event->x + spell_entry->priv->entry_scroll_offset);
-
- return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->button_press_event (widget, event);
-}
-
-static void
-spell_entry_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CHECKING_ENABLED:
- e_spell_entry_set_checking_enabled (
- E_SPELL_ENTRY (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-spell_entry_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CHECKING_ENABLED:
- g_value_set_boolean (
- value,
- e_spell_entry_get_checking_enabled (
- E_SPELL_ENTRY (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-e_spell_entry_init (ESpellEntry *spell_entry)
-{
- spell_entry->priv = E_SPELL_ENTRY_GET_PRIVATE (spell_entry);
- spell_entry->priv->attr_list = pango_attr_list_new ();
- spell_entry->priv->checkers = NULL;
- spell_entry->priv->checking_enabled = TRUE;
-
- g_signal_connect (spell_entry, "popup-menu", G_CALLBACK (spell_entry_popup_menu), NULL);
- g_signal_connect (spell_entry, "populate-popup", G_CALLBACK (spell_entry_populate_popup), NULL);
- g_signal_connect (spell_entry, "changed", G_CALLBACK (spell_entry_changed), NULL);
- g_signal_connect (spell_entry, "notify::scroll-offset", G_CALLBACK (spell_entry_notify_scroll_offset), NULL);
-
- /* listen for languages changes */
- spell_entry->priv->settings = g_settings_new ("org.gnome.evolution.mail");
- g_signal_connect_swapped (spell_entry->priv->settings, "changed", G_CALLBACK (spell_entry_settings_changed), spell_entry);
-
- /* load current settings */
- spell_entry_settings_changed (spell_entry, NULL);
-}
-
-static void
-e_spell_entry_finalize (GObject *object)
-{
- ESpellEntry *entry;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_SPELL_ENTRY (object));
-
- entry = E_SPELL_ENTRY (object);
-
- if (entry->priv->settings)
- g_object_unref (entry->priv->settings);
- if (entry->priv->checkers)
- g_slist_free_full (entry->priv->checkers, g_object_unref);
- if (entry->priv->attr_list)
- pango_attr_list_unref (entry->priv->attr_list);
- if (entry->priv->words)
- g_strfreev (entry->priv->words);
- if (entry->priv->word_starts)
- g_free (entry->priv->word_starts);
- if (entry->priv->word_ends)
- g_free (entry->priv->word_ends);
-
- G_OBJECT_CLASS (e_spell_entry_parent_class)->finalize (object);
-}
-
-static void
-e_spell_entry_class_init (ESpellEntryClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (ESpellEntryPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = spell_entry_set_property;
- object_class->get_property = spell_entry_get_property;
- object_class->finalize = e_spell_entry_finalize;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->draw = e_spell_entry_draw;
- widget_class->button_press_event = e_spell_entry_button_press;
-
- g_object_class_install_property (
- object_class,
- PROP_CHECKING_ENABLED,
- g_param_spec_boolean (
- "checking-enabled",
- "checking enabled",
- "Spell Checking is Enabled",
- TRUE,
- G_PARAM_READWRITE));
-}
-
-GtkWidget *
-e_spell_entry_new (void)
-{
- return g_object_new (E_TYPE_SPELL_ENTRY, NULL);
-}
-
-/* 'languages' consists of 'const GtkhtmlSpellLanguage *' */
-void
-e_spell_entry_set_languages (ESpellEntry *spell_entry,
- GList *languages)
-{
- GList *iter;
-
- g_return_if_fail (spell_entry != NULL);
-
- spell_entry->priv->custom_checkers = TRUE;
-
- if (spell_entry->priv->checkers)
- g_slist_free_full (spell_entry->priv->checkers, g_object_unref);
- spell_entry->priv->checkers = NULL;
-
- for (iter = languages; iter; iter = g_list_next (iter)) {
- const GtkhtmlSpellLanguage *language = iter->data;
-
- if (language)
- spell_entry->priv->checkers = g_slist_prepend (
- spell_entry->priv->checkers,
- gtkhtml_spell_checker_new (language));
- }
-
- spell_entry->priv->checkers = g_slist_reverse (spell_entry->priv->checkers);
-
- if (gtk_widget_get_realized (GTK_WIDGET (spell_entry)))
- spell_entry_recheck_all (spell_entry);
-}
-
-gboolean
-e_spell_entry_get_checking_enabled (ESpellEntry *spell_entry)
-{
- g_return_val_if_fail (spell_entry != NULL, FALSE);
-
- return spell_entry->priv->checking_enabled;
-}
-
-void
-e_spell_entry_set_checking_enabled (ESpellEntry *spell_entry,
- gboolean enable_checking)
-{
- g_return_if_fail (spell_entry != NULL);
-
- if (spell_entry->priv->checking_enabled == enable_checking)
- return;
-
- spell_entry->priv->checking_enabled = enable_checking;
- spell_entry_recheck_all (spell_entry);
-
- g_object_notify (G_OBJECT (spell_entry), "checking-enabled");
-
-}
diff --git a/widgets/misc/e-spell-entry.h b/widgets/misc/e-spell-entry.h
deleted file mode 100644
index 2d6aabad95..0000000000
--- a/widgets/misc/e-spell-entry.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * e-spell-entry.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_SPELL_ENTRY_H
-#define E_SPELL_ENTRY_H
-
-#include <gtk/gtk.h>
-
-#define E_TYPE_SPELL_ENTRY (e_spell_entry_get_type())
-#define E_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), E_TYPE_SPELL_ENTRY, ESpellEntry))
-#define E_SPELL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), E_TYPE_SPELL_ENTRY, ESpellEntryClass))
-#define E_IS_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), E_TYPE_SPELL_ENTRY))
-#define E_IS_SPELL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), E_TYPE_SPELL_ENTRY))
-#define E_SPELL_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), E_TYPE_SPELL_ENTRY, ESpellEntryClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESpellEntry ESpellEntry;
-typedef struct _ESpellEntryClass ESpellEntryClass;
-typedef struct _ESpellEntryPrivate ESpellEntryPrivate;
-
-struct _ESpellEntry
-{
- GtkEntry parent_object;
-
- ESpellEntryPrivate *priv;
-};
-
-struct _ESpellEntryClass
-{
- GtkEntryClass parent_class;
-};
-
-GType e_spell_entry_get_type (void);
-GtkWidget * e_spell_entry_new (void);
-void e_spell_entry_set_languages (ESpellEntry *spell_entry,
- GList *languages);
-gboolean e_spell_entry_get_checking_enabled (ESpellEntry *spell_entry);
-void e_spell_entry_set_checking_enabled (ESpellEntry *spell_entry,
- gboolean enable_checking);
-
-G_END_DECLS
-
-#endif /* E_SPELL_ENTRY_H */
diff --git a/widgets/misc/e-url-entry.c b/widgets/misc/e-url-entry.c
deleted file mode 100644
index 68b8a8fac0..0000000000
--- a/widgets/misc/e-url-entry.c
+++ /dev/null
@@ -1,157 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include "e-url-entry.h"
-#include "e-util/e-util.h"
-
-#define E_URL_ENTRY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_URL_ENTRY, EUrlEntryPrivate))
-
-struct _EUrlEntryPrivate {
- GtkWidget *entry;
- GtkWidget *button;
-};
-
-static void button_clicked_cb (GtkWidget *widget, gpointer data);
-static void entry_changed_cb (GtkEditable *editable, gpointer data);
-
-static gboolean mnemonic_activate (GtkWidget *widget, gboolean group_cycling);
-
-G_DEFINE_TYPE (
- EUrlEntry,
- e_url_entry,
- GTK_TYPE_HBOX)
-
-static void
-e_url_entry_class_init (EUrlEntryClass *class)
-{
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EUrlEntryPrivate));
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->mnemonic_activate = mnemonic_activate;
-}
-
-static void
-e_url_entry_init (EUrlEntry *url_entry)
-{
- GtkWidget *pixmap;
-
- url_entry->priv = E_URL_ENTRY_GET_PRIVATE (url_entry);
-
- url_entry->priv->entry = gtk_entry_new ();
- gtk_box_pack_start (
- GTK_BOX (url_entry), url_entry->priv->entry, TRUE, TRUE, 0);
- url_entry->priv->button = gtk_button_new ();
- gtk_widget_set_sensitive (url_entry->priv->button, FALSE);
- gtk_box_pack_start (
- GTK_BOX (url_entry), url_entry->priv->button, FALSE, FALSE, 0);
- atk_object_set_name (
- gtk_widget_get_accessible (url_entry->priv->button),
- _("Click here to go to URL"));
- pixmap = gtk_image_new_from_icon_name ("go-jump", GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (url_entry->priv->button), pixmap);
- gtk_widget_show (pixmap);
-
- gtk_widget_show (url_entry->priv->button);
- gtk_widget_show (url_entry->priv->entry);
-
- g_signal_connect (
- url_entry->priv->button, "clicked",
- G_CALLBACK (button_clicked_cb), url_entry);
- g_signal_connect (
- url_entry->priv->entry, "changed",
- G_CALLBACK (entry_changed_cb), url_entry);
-}
-
-/* GtkWidget::mnemonic_activate() handler for the EUrlEntry */
-static gboolean
-mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling)
-{
- EUrlEntry *url_entry;
- EUrlEntryPrivate *priv;
-
- url_entry = E_URL_ENTRY (widget);
- priv = url_entry->priv;
-
- return gtk_widget_mnemonic_activate (priv->entry, group_cycling);
-}
-
-GtkWidget *
-e_url_entry_new (void)
-{
- return g_object_new (E_TYPE_URL_ENTRY, NULL);
-}
-
-GtkWidget *
-e_url_entry_get_entry (EUrlEntry *url_entry)
-{
- EUrlEntryPrivate *priv;
-
- g_return_val_if_fail (url_entry != NULL, NULL);
- g_return_val_if_fail (E_IS_URL_ENTRY (url_entry), NULL);
-
- priv = url_entry->priv;
-
- return priv->entry;
-}
-
-static void
-button_clicked_cb (GtkWidget *widget,
- gpointer data)
-{
- EUrlEntry *url_entry;
- EUrlEntryPrivate *priv;
- const gchar *uri;
-
- url_entry = E_URL_ENTRY (data);
- priv = url_entry->priv;
-
- uri = gtk_entry_get_text (GTK_ENTRY (priv->entry));
-
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, uri);
-}
-
-static void
-entry_changed_cb (GtkEditable *editable,
- gpointer data)
-{
- EUrlEntry *url_entry;
- EUrlEntryPrivate *priv;
- const gchar *url;
-
- url_entry = E_URL_ENTRY (data);
- priv = url_entry->priv;
-
- url = gtk_entry_get_text (GTK_ENTRY (priv->entry));
- gtk_widget_set_sensitive (priv->button, url != NULL && *url != '\0');
-}
diff --git a/widgets/misc/e-url-entry.h b/widgets/misc/e-url-entry.h
deleted file mode 100644
index 2393f823ac..0000000000
--- a/widgets/misc/e-url-entry.h
+++ /dev/null
@@ -1,56 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_URL_ENTRY_H_
-#define _E_URL_ENTRY_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define E_TYPE_URL_ENTRY (e_url_entry_get_type ())
-#define E_URL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_URL_ENTRY, EUrlEntry))
-#define E_URL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_URL_ENTRY, EUrlEntryClass))
-#define E_IS_URL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_URL_ENTRY))
-#define E_IS_URL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_URL_ENTRY))
-
-typedef struct _EUrlEntry EUrlEntry;
-typedef struct _EUrlEntryPrivate EUrlEntryPrivate;
-typedef struct _EUrlEntryClass EUrlEntryClass;
-
-struct _EUrlEntry {
- GtkBox parent;
-
- EUrlEntryPrivate *priv;
-};
-
-struct _EUrlEntryClass {
- GtkBoxClass parent_class;
-};
-
-GType e_url_entry_get_type (void);
-GtkWidget *e_url_entry_new (void);
-GtkWidget *e_url_entry_get_entry (EUrlEntry *url_entry);
-
-G_END_DECLS
-
-#endif /* _E_URL_ENTRY_H_ */
diff --git a/widgets/misc/e-web-view-gtkhtml.c b/widgets/misc/e-web-view-gtkhtml.c
deleted file mode 100644
index fddbd9ee90..0000000000
--- a/widgets/misc/e-web-view-gtkhtml.c
+++ /dev/null
@@ -1,2318 +0,0 @@
-/*
- * e-web-view-gtkhtml.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-web-view-gtkhtml.h"
-
-#include <string.h>
-#include <glib/gi18n-lib.h>
-
-#include <camel/camel.h>
-#include <libebackend/libebackend.h>
-
-#include <e-util/e-util.h>
-#include <e-util/e-plugin-ui.h>
-#include <libevolution-utils/e-alert-dialog.h>
-#include <libevolution-utils/e-alert-sink.h>
-
-#include "e-popup-action.h"
-#include "e-selectable.h"
-
-#define E_WEB_VIEW_GTKHTML_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLPrivate))
-
-typedef struct _EWebViewGtkHTMLRequest EWebViewGtkHTMLRequest;
-
-struct _EWebViewGtkHTMLPrivate {
- GList *requests;
- GtkUIManager *ui_manager;
- gchar *selected_uri;
- GdkPixbufAnimation *cursor_image;
-
- GtkAction *open_proxy;
- GtkAction *print_proxy;
- GtkAction *save_as_proxy;
-
- GtkTargetList *copy_target_list;
- GtkTargetList *paste_target_list;
-
- /* Lockdown Options */
- guint disable_printing : 1;
- guint disable_save_to_disk : 1;
-};
-
-struct _EWebViewGtkHTMLRequest {
- GFile *file;
- EWebViewGtkHTML *web_view;
- GCancellable *cancellable;
- GInputStream *input_stream;
- GtkHTMLStream *output_stream;
- gchar buffer[4096];
-};
-
-enum {
- PROP_0,
- PROP_ANIMATE,
- PROP_CARET_MODE,
- PROP_COPY_TARGET_LIST,
- PROP_DISABLE_PRINTING,
- PROP_DISABLE_SAVE_TO_DISK,
- PROP_EDITABLE,
- PROP_INLINE_SPELLING,
- PROP_MAGIC_LINKS,
- PROP_MAGIC_SMILEYS,
- PROP_OPEN_PROXY,
- PROP_PASTE_TARGET_LIST,
- PROP_PRINT_PROXY,
- PROP_SAVE_AS_PROXY,
- PROP_SELECTED_URI,
- PROP_CURSOR_IMAGE
-};
-
-enum {
- COPY_CLIPBOARD,
- CUT_CLIPBOARD,
- PASTE_CLIPBOARD,
- POPUP_EVENT,
- STATUS_MESSAGE,
- STOP_LOADING,
- UPDATE_ACTIONS,
- PROCESS_MAILTO,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <menuitem action='copy-clipboard'/>"
-" <separator/>"
-" <placeholder name='custom-actions-1'>"
-" <menuitem action='open'/>"
-" <menuitem action='save-as'/>"
-" <menuitem action='http-open'/>"
-" <menuitem action='send-message'/>"
-" <menuitem action='print'/>"
-" </placeholder>"
-" <placeholder name='custom-actions-2'>"
-" <menuitem action='uri-copy'/>"
-" <menuitem action='mailto-copy'/>"
-" <menuitem action='image-copy'/>"
-" </placeholder>"
-" <placeholder name='custom-actions-3'/>"
-" <separator/>"
-" <menuitem action='select-all'/>"
-" </popup>"
-"</ui>";
-
-/* Forward Declarations */
-static void e_web_view_gtkhtml_alert_sink_init (EAlertSinkInterface *interface);
-static void e_web_view_gtkhtml_selectable_init (ESelectableInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EWebViewGtkHTML,
- e_web_view_gtkhtml,
- GTK_TYPE_HTML,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ALERT_SINK,
- e_web_view_gtkhtml_alert_sink_init)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_SELECTABLE,
- e_web_view_gtkhtml_selectable_init))
-
-static EWebViewGtkHTMLRequest *
-web_view_gtkhtml_request_new (EWebViewGtkHTML *web_view,
- const gchar *uri,
- GtkHTMLStream *stream)
-{
- EWebViewGtkHTMLRequest *request;
- GList *list;
-
- request = g_slice_new (EWebViewGtkHTMLRequest);
-
- /* Try to detect file paths posing as URIs. */
- if (*uri == '/')
- request->file = g_file_new_for_path (uri);
- else
- request->file = g_file_new_for_uri (uri);
-
- request->web_view = g_object_ref (web_view);
- request->cancellable = g_cancellable_new ();
- request->input_stream = NULL;
- request->output_stream = stream;
-
- list = request->web_view->priv->requests;
- list = g_list_prepend (list, request);
- request->web_view->priv->requests = list;
-
- return request;
-}
-
-static void
-web_view_gtkhtml_request_free (EWebViewGtkHTMLRequest *request)
-{
- GList *list;
-
- list = request->web_view->priv->requests;
- list = g_list_remove (list, request);
- request->web_view->priv->requests = list;
-
- g_object_unref (request->file);
- g_object_unref (request->web_view);
- g_object_unref (request->cancellable);
-
- if (request->input_stream != NULL)
- g_object_unref (request->input_stream);
-
- g_slice_free (EWebViewGtkHTMLRequest, request);
-}
-
-static void
-web_view_gtkhtml_request_cancel (EWebViewGtkHTMLRequest *request)
-{
- g_cancellable_cancel (request->cancellable);
-}
-
-static gboolean
-web_view_gtkhtml_request_check_for_error (EWebViewGtkHTMLRequest *request,
- GError *error)
-{
- GtkHTML *html;
- GtkHTMLStream *stream;
-
- if (error == NULL)
- return FALSE;
-
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
- /* use this error, but do not close the stream */
- g_error_free (error);
- return TRUE;
- }
-
- /* XXX Should we log errors that are not cancellations? */
-
- html = GTK_HTML (request->web_view);
- stream = request->output_stream;
-
- gtk_html_end (html, stream, GTK_HTML_STREAM_ERROR);
- web_view_gtkhtml_request_free (request);
- g_error_free (error);
-
- return TRUE;
-}
-
-static void
-web_view_gtkhtml_request_stream_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- EWebViewGtkHTMLRequest *request)
-{
- gssize bytes_read;
- GError *error = NULL;
-
- bytes_read = g_input_stream_read_finish (input_stream, result, &error);
-
- if (web_view_gtkhtml_request_check_for_error (request, error))
- return;
-
- if (bytes_read == 0) {
- gtk_html_end (
- GTK_HTML (request->web_view),
- request->output_stream, GTK_HTML_STREAM_OK);
- web_view_gtkhtml_request_free (request);
- return;
- }
-
- gtk_html_write (
- GTK_HTML (request->web_view),
- request->output_stream, request->buffer, bytes_read);
-
- g_input_stream_read_async (
- request->input_stream, request->buffer,
- sizeof (request->buffer), G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- web_view_gtkhtml_request_stream_read_cb, request);
-}
-
-static void
-web_view_gtkhtml_request_read_cb (GFile *file,
- GAsyncResult *result,
- EWebViewGtkHTMLRequest *request)
-{
- GFileInputStream *input_stream;
- GError *error = NULL;
-
- /* Input stream might be NULL, so don't use cast macro. */
- input_stream = g_file_read_finish (file, result, &error);
- request->input_stream = (GInputStream *) input_stream;
-
- if (web_view_gtkhtml_request_check_for_error (request, error))
- return;
-
- g_input_stream_read_async (
- request->input_stream, request->buffer,
- sizeof (request->buffer), G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- web_view_gtkhtml_request_stream_read_cb, request);
-}
-
-static void
-action_copy_clipboard_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- e_web_view_gtkhtml_copy_clipboard (web_view);
-}
-
-static void
-action_http_open_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- const gchar *uri;
- gpointer parent;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- uri = e_web_view_gtkhtml_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- e_show_uri (parent, uri);
-}
-
-static void
-action_mailto_copy_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- CamelURL *curl;
- CamelInternetAddress *inet_addr;
- GtkClipboard *clipboard;
- const gchar *uri;
- gchar *text;
-
- uri = e_web_view_gtkhtml_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- /* This should work because we checked it in update_actions(). */
- curl = camel_url_new (uri, NULL);
- g_return_if_fail (curl != NULL);
-
- inet_addr = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
- text = camel_address_format (CAMEL_ADDRESS (inet_addr));
- if (text == NULL || *text == '\0')
- text = g_strdup (uri + strlen ("mailto:"));
-
- g_object_unref (inet_addr);
- camel_url_free (curl);
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
- gtk_clipboard_set_text (clipboard, text, -1);
- gtk_clipboard_store (clipboard);
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_set_text (clipboard, text, -1);
- gtk_clipboard_store (clipboard);
-
- g_free (text);
-}
-
-static void
-action_select_all_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- e_web_view_gtkhtml_select_all (web_view);
-}
-
-static void
-action_send_message_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- const gchar *uri;
- gpointer parent;
- gboolean handled;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- uri = e_web_view_gtkhtml_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- handled = FALSE;
- g_signal_emit (web_view, signals[PROCESS_MAILTO], 0, uri, &handled);
-
- if (!handled)
- e_show_uri (parent, uri);
-}
-
-static void
-action_uri_copy_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- GtkClipboard *clipboard;
- const gchar *uri;
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- uri = e_web_view_gtkhtml_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- gtk_clipboard_set_text (clipboard, uri, -1);
- gtk_clipboard_store (clipboard);
-}
-
-static void
-action_image_copy_cb (GtkAction *action,
- EWebViewGtkHTML *web_view)
-{
- GtkClipboard *clipboard;
- GdkPixbufAnimation *animation;
- GdkPixbuf *pixbuf;
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- animation = e_web_view_gtkhtml_get_cursor_image (web_view);
- g_return_if_fail (animation != NULL);
-
- pixbuf = gdk_pixbuf_animation_get_static_image (animation);
- if (!pixbuf)
- return;
-
- gtk_clipboard_set_image (clipboard, pixbuf);
- gtk_clipboard_store (clipboard);
-}
-
-static GtkActionEntry uri_entries[] = {
-
- { "uri-copy",
- GTK_STOCK_COPY,
- N_("_Copy Link Location"),
- NULL,
- N_("Copy the link to the clipboard"),
- G_CALLBACK (action_uri_copy_cb) }
-};
-
-static GtkActionEntry http_entries[] = {
-
- { "http-open",
- "emblem-web",
- N_("_Open Link in Browser"),
- NULL,
- N_("Open the link in a web browser"),
- G_CALLBACK (action_http_open_cb) }
-};
-
-static GtkActionEntry mailto_entries[] = {
-
- { "mailto-copy",
- GTK_STOCK_COPY,
- N_("_Copy Email Address"),
- NULL,
- N_("Copy the email address to the clipboard"),
- G_CALLBACK (action_mailto_copy_cb) },
-
- { "send-message",
- "mail-message-new",
- N_("_Send New Message To..."),
- NULL,
- N_("Send a mail message to this address"),
- G_CALLBACK (action_send_message_cb) }
-};
-
-static GtkActionEntry image_entries[] = {
-
- { "image-copy",
- GTK_STOCK_COPY,
- N_("_Copy Image"),
- NULL,
- N_("Copy the image to the clipboard"),
- G_CALLBACK (action_image_copy_cb) }
-};
-
-static GtkActionEntry selection_entries[] = {
-
- { "copy-clipboard",
- GTK_STOCK_COPY,
- NULL,
- NULL,
- N_("Copy the selection"),
- G_CALLBACK (action_copy_clipboard_cb) },
-};
-
-static GtkActionEntry standard_entries[] = {
-
- { "select-all",
- GTK_STOCK_SELECT_ALL,
- NULL,
- NULL,
- N_("Select all text and images"),
- G_CALLBACK (action_select_all_cb) }
-};
-
-static gboolean
-web_view_gtkhtml_button_press_event_cb (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkHTML *frame)
-{
- gboolean event_handled = FALSE;
- gchar *uri = NULL;
-
- if (event) {
- GdkPixbufAnimation *anim;
-
- if (frame == NULL)
- frame = GTK_HTML (web_view);
-
- anim = gtk_html_get_image_at (frame, event->x, event->y);
- e_web_view_gtkhtml_set_cursor_image (web_view, anim);
- if (anim != NULL)
- g_object_unref (anim);
- }
-
- if (event != NULL && event->button != 3)
- return FALSE;
-
- /* Only extract a URI if no selection is active. Selected text
- * implies the user is more likely to want to copy the selection
- * to the clipboard than open a link within the selection. */
- if (!e_web_view_gtkhtml_is_selection_active (web_view))
- uri = e_web_view_gtkhtml_extract_uri (web_view, event, frame);
-
- if (uri != NULL && g_str_has_prefix (uri, "##")) {
- g_free (uri);
- return FALSE;
- }
-
- g_signal_emit (
- web_view, signals[POPUP_EVENT], 0,
- event, uri, &event_handled);
-
- g_free (uri);
-
- return event_handled;
-}
-
-static void
-web_view_gtkhtml_menu_item_select_cb (EWebViewGtkHTML *web_view,
- GtkWidget *widget)
-{
- GtkAction *action;
- GtkActivatable *activatable;
- const gchar *tooltip;
-
- activatable = GTK_ACTIVATABLE (widget);
- action = gtk_activatable_get_related_action (activatable);
- tooltip = gtk_action_get_tooltip (action);
-
- if (tooltip == NULL)
- return;
-
- e_web_view_gtkhtml_status_message (web_view, tooltip);
-}
-
-static void
-web_view_gtkhtml_menu_item_deselect_cb (EWebViewGtkHTML *web_view)
-{
- e_web_view_gtkhtml_status_message (web_view, NULL);
-}
-
-static void
-web_view_gtkhtml_connect_proxy_cb (EWebViewGtkHTML *web_view,
- GtkAction *action,
- GtkWidget *proxy)
-{
- if (!GTK_IS_MENU_ITEM (proxy))
- return;
-
- g_signal_connect_swapped (
- proxy, "select",
- G_CALLBACK (web_view_gtkhtml_menu_item_select_cb), web_view);
-
- g_signal_connect_swapped (
- proxy, "deselect",
- G_CALLBACK (web_view_gtkhtml_menu_item_deselect_cb), web_view);
-}
-
-static void
-web_view_gtkhtml_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ANIMATE:
- e_web_view_gtkhtml_set_animate (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_CARET_MODE:
- e_web_view_gtkhtml_set_caret_mode (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_DISABLE_PRINTING:
- e_web_view_gtkhtml_set_disable_printing (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_DISABLE_SAVE_TO_DISK:
- e_web_view_gtkhtml_set_disable_save_to_disk (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_EDITABLE:
- e_web_view_gtkhtml_set_editable (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_INLINE_SPELLING:
- e_web_view_gtkhtml_set_inline_spelling (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_MAGIC_LINKS:
- e_web_view_gtkhtml_set_magic_links (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_MAGIC_SMILEYS:
- e_web_view_gtkhtml_set_magic_smileys (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_OPEN_PROXY:
- e_web_view_gtkhtml_set_open_proxy (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_object (value));
- return;
-
- case PROP_PRINT_PROXY:
- e_web_view_gtkhtml_set_print_proxy (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_object (value));
- return;
-
- case PROP_SAVE_AS_PROXY:
- e_web_view_gtkhtml_set_save_as_proxy (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_object (value));
- return;
-
- case PROP_SELECTED_URI:
- e_web_view_gtkhtml_set_selected_uri (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_string (value));
- return;
- case PROP_CURSOR_IMAGE:
- e_web_view_gtkhtml_set_cursor_image (
- E_WEB_VIEW_GTKHTML (object),
- g_value_get_object (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_gtkhtml_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ANIMATE:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_animate (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_CARET_MODE:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_caret_mode (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_COPY_TARGET_LIST:
- g_value_set_boxed (
- value, e_web_view_gtkhtml_get_copy_target_list (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_DISABLE_PRINTING:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_disable_printing (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_DISABLE_SAVE_TO_DISK:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_disable_save_to_disk (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_EDITABLE:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_editable (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_INLINE_SPELLING:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_inline_spelling (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_MAGIC_LINKS:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_magic_links (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_MAGIC_SMILEYS:
- g_value_set_boolean (
- value, e_web_view_gtkhtml_get_magic_smileys (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_OPEN_PROXY:
- g_value_set_object (
- value, e_web_view_gtkhtml_get_open_proxy (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_PASTE_TARGET_LIST:
- g_value_set_boxed (
- value, e_web_view_gtkhtml_get_paste_target_list (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_PRINT_PROXY:
- g_value_set_object (
- value, e_web_view_gtkhtml_get_print_proxy (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_SAVE_AS_PROXY:
- g_value_set_object (
- value, e_web_view_gtkhtml_get_save_as_proxy (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_SELECTED_URI:
- g_value_set_string (
- value, e_web_view_gtkhtml_get_selected_uri (
- E_WEB_VIEW_GTKHTML (object)));
- return;
-
- case PROP_CURSOR_IMAGE:
- g_value_set_object (
- value, e_web_view_gtkhtml_get_cursor_image (
- E_WEB_VIEW_GTKHTML (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_gtkhtml_dispose (GObject *object)
-{
- EWebViewGtkHTMLPrivate *priv;
-
- priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (object);
-
- if (priv->ui_manager != NULL) {
- g_object_unref (priv->ui_manager);
- priv->ui_manager = NULL;
- }
-
- if (priv->open_proxy != NULL) {
- g_object_unref (priv->open_proxy);
- priv->open_proxy = NULL;
- }
-
- if (priv->print_proxy != NULL) {
- g_object_unref (priv->print_proxy);
- priv->print_proxy = NULL;
- }
-
- if (priv->save_as_proxy != NULL) {
- g_object_unref (priv->save_as_proxy);
- priv->save_as_proxy = NULL;
- }
-
- if (priv->copy_target_list != NULL) {
- gtk_target_list_unref (priv->copy_target_list);
- priv->copy_target_list = NULL;
- }
-
- if (priv->paste_target_list != NULL) {
- gtk_target_list_unref (priv->paste_target_list);
- priv->paste_target_list = NULL;
- }
-
- if (priv->cursor_image != NULL) {
- g_object_unref (priv->cursor_image);
- priv->cursor_image = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_web_view_gtkhtml_parent_class)->dispose (object);
-}
-
-static void
-web_view_gtkhtml_finalize (GObject *object)
-{
- EWebViewGtkHTMLPrivate *priv;
-
- priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (object);
-
- /* All URI requests should be complete or cancelled by now. */
- if (priv->requests != NULL)
- g_warning ("Finalizing EWebViewGtkHTML with active URI requests");
-
- g_free (priv->selected_uri);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_web_view_gtkhtml_parent_class)->finalize (object);
-}
-
-static void
-web_view_gtkhtml_constructed (GObject *object)
-{
-#ifndef G_OS_WIN32
- GSettings *settings;
-
- settings = g_settings_new ("org.gnome.desktop.lockdown");
-
- g_settings_bind (
- settings, "disable-printing",
- object, "disable-printing",
- G_SETTINGS_BIND_GET);
-
- g_settings_bind (
- settings, "disable-save-to-disk",
- object, "disable-save-to-disk",
- G_SETTINGS_BIND_GET);
-
- g_object_unref (settings);
-#endif
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_web_view_gtkhtml_parent_class)->constructed (object);
-}
-
-static gboolean
-web_view_gtkhtml_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GtkWidgetClass *widget_class;
- EWebViewGtkHTML *web_view;
-
- web_view = E_WEB_VIEW_GTKHTML (widget);
-
- if (web_view_gtkhtml_button_press_event_cb (web_view, event, NULL))
- return TRUE;
-
- /* Chain up to parent's button_press_event() method. */
- widget_class = GTK_WIDGET_CLASS (e_web_view_gtkhtml_parent_class);
- return widget_class->button_press_event (widget, event);
-}
-
-static gboolean
-web_view_gtkhtml_scroll_event (GtkWidget *widget,
- GdkEventScroll *event)
-{
- if (event->state & GDK_CONTROL_MASK) {
- GdkScrollDirection direction = event->direction;
-
- #if GTK_CHECK_VERSION(3,3,18)
- if (direction == GDK_SCROLL_SMOOTH) {
- static gdouble total_delta_y = 0.0;
-
- total_delta_y += event->delta_y;
-
- if (total_delta_y >= 1.0) {
- total_delta_y = 0.0;
- direction = GDK_SCROLL_DOWN;
- } else if (total_delta_y <= -1.0) {
- total_delta_y = 0.0;
- direction = GDK_SCROLL_UP;
- } else {
- return FALSE;
- }
- }
- #endif
-
- switch (direction) {
- case GDK_SCROLL_UP:
- gtk_html_zoom_in (GTK_HTML (widget));
- return TRUE;
- case GDK_SCROLL_DOWN:
- gtk_html_zoom_out (GTK_HTML (widget));
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-web_view_gtkhtml_url_requested (GtkHTML *html,
- const gchar *uri,
- GtkHTMLStream *stream)
-{
- EWebViewGtkHTMLRequest *request;
-
- request = web_view_gtkhtml_request_new (E_WEB_VIEW_GTKHTML (html), uri, stream);
-
- g_file_read_async (
- request->file, G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- web_view_gtkhtml_request_read_cb, request);
-}
-
-static void
-web_view_gtkhtml_gtkhtml_link_clicked (GtkHTML *html,
- const gchar *uri)
-{
- EWebViewGtkHTMLClass *class;
- EWebViewGtkHTML *web_view;
-
- web_view = E_WEB_VIEW_GTKHTML (html);
-
- class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
- g_return_if_fail (class->link_clicked != NULL);
-
- class->link_clicked (web_view, uri);
-}
-
-static void
-web_view_gtkhtml_on_url (GtkHTML *html,
- const gchar *uri)
-{
- EWebViewGtkHTMLClass *class;
- EWebViewGtkHTML *web_view;
-
- web_view = E_WEB_VIEW_GTKHTML (html);
-
- class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
- g_return_if_fail (class->hovering_over_link != NULL);
-
- /* XXX WebKit would supply a title here. */
- class->hovering_over_link (web_view, NULL, uri);
-}
-
-static void
-web_view_gtkhtml_iframe_created (GtkHTML *html,
- GtkHTML *iframe)
-{
- g_signal_connect_swapped (
- iframe, "button-press-event",
- G_CALLBACK (web_view_gtkhtml_button_press_event_cb), html);
-}
-
-static gchar *
-web_view_gtkhtml_extract_uri (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkHTML *html)
-{
- gchar *uri;
-
- if (event != NULL)
- uri = gtk_html_get_url_at (html, event->x, event->y);
- else
- uri = gtk_html_get_cursor_url (html);
-
- return uri;
-}
-
-static void
-web_view_gtkhtml_hovering_over_link (EWebViewGtkHTML *web_view,
- const gchar *title,
- const gchar *uri)
-{
- CamelInternetAddress *address;
- CamelURL *curl;
- const gchar *format = NULL;
- gchar *message = NULL;
- gchar *who;
-
- if (uri == NULL || *uri == '\0')
- goto exit;
-
- if (g_str_has_prefix (uri, "mailto:"))
- format = _("Click to mail %s");
- else if (g_str_has_prefix (uri, "callto:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "h323:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "sip:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "##"))
- message = g_strdup (_("Click to hide/unhide addresses"));
- else
- message = g_strdup_printf (_("Click to open %s"), uri);
-
- if (format == NULL)
- goto exit;
-
- /* XXX Use something other than Camel here. Surely
- * there's other APIs around that can do this. */
- curl = camel_url_new (uri, NULL);
- address = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (address), curl->path);
- who = camel_address_format (CAMEL_ADDRESS (address));
- g_object_unref (address);
- camel_url_free (curl);
-
- if (who == NULL)
- who = g_strdup (strchr (uri, ':') + 1);
-
- message = g_strdup_printf (format, who);
-
- g_free (who);
-
-exit:
- e_web_view_gtkhtml_status_message (web_view, message);
-
- g_free (message);
-}
-
-static void
-web_view_gtkhtml_link_clicked (EWebViewGtkHTML *web_view,
- const gchar *uri)
-{
- gpointer parent;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- e_show_uri (parent, uri);
-}
-
-static void
-web_view_gtkhtml_load_string (EWebViewGtkHTML *web_view,
- const gchar *string)
-{
- if (string != NULL && *string != '\0')
- gtk_html_load_from_string (GTK_HTML (web_view), string, -1);
- else
- e_web_view_gtkhtml_clear (web_view);
-}
-
-static void
-web_view_gtkhtml_copy_clipboard (EWebViewGtkHTML *web_view)
-{
- gtk_html_command (GTK_HTML (web_view), "copy");
-}
-
-static void
-web_view_gtkhtml_cut_clipboard (EWebViewGtkHTML *web_view)
-{
- if (e_web_view_gtkhtml_get_editable (web_view))
- gtk_html_command (GTK_HTML (web_view), "cut");
-}
-
-static void
-web_view_gtkhtml_paste_clipboard (EWebViewGtkHTML *web_view)
-{
- if (e_web_view_gtkhtml_get_editable (web_view))
- gtk_html_command (GTK_HTML (web_view), "paste");
-}
-
-static gboolean
-web_view_gtkhtml_popup_event (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- const gchar *uri)
-{
- e_web_view_gtkhtml_set_selected_uri (web_view, uri);
- e_web_view_gtkhtml_show_popup_menu (web_view, event, NULL, NULL);
-
- return TRUE;
-}
-
-static void
-web_view_gtkhtml_stop_loading (EWebViewGtkHTML *web_view)
-{
- g_list_foreach (
- web_view->priv->requests, (GFunc)
- web_view_gtkhtml_request_cancel, NULL);
-
- gtk_html_stop (GTK_HTML (web_view));
-}
-
-static void
-web_view_gtkhtml_update_actions (EWebViewGtkHTML *web_view)
-{
- GtkActionGroup *action_group;
- gboolean have_selection;
- gboolean scheme_is_http = FALSE;
- gboolean scheme_is_mailto = FALSE;
- gboolean uri_is_valid = FALSE;
- gboolean has_cursor_image;
- gboolean visible;
- const gchar *group_name;
- const gchar *uri;
-
- uri = e_web_view_gtkhtml_get_selected_uri (web_view);
- have_selection = e_web_view_gtkhtml_is_selection_active (web_view);
- has_cursor_image = e_web_view_gtkhtml_get_cursor_image (web_view) != NULL;
-
- /* Parse the URI early so we know if the actions will work. */
- if (uri != NULL) {
- CamelURL *curl;
-
- curl = camel_url_new (uri, NULL);
- uri_is_valid = (curl != NULL);
- camel_url_free (curl);
-
- scheme_is_http =
- (g_ascii_strncasecmp (uri, "http:", 5) == 0) ||
- (g_ascii_strncasecmp (uri, "https:", 6) == 0);
-
- scheme_is_mailto =
- (g_ascii_strncasecmp (uri, "mailto:", 7) == 0);
- }
-
- /* Allow copying the URI even if it's malformed. */
- group_name = "uri";
- visible = (uri != NULL) && !scheme_is_mailto;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "http";
- visible = uri_is_valid && scheme_is_http;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "mailto";
- visible = uri_is_valid && scheme_is_mailto;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "image";
- visible = has_cursor_image;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "selection";
- visible = have_selection;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "standard";
- visible = (uri == NULL);
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "lockdown-printing";
- visible = (uri == NULL) && !web_view->priv->disable_printing;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "lockdown-save-to-disk";
- visible = (uri == NULL) && !web_view->priv->disable_save_to_disk;
- action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-}
-
-static void
-web_view_gtkhtml_submit_alert (EAlertSink *alert_sink,
- EAlert *alert)
-{
- GtkIconInfo *icon_info;
- EWebViewGtkHTML *web_view;
- GtkWidget *dialog;
- GString *buffer;
- const gchar *icon_name = NULL;
- const gchar *filename;
- gpointer parent;
- gchar *icon_uri;
- gint size = 0;
- GError *error = NULL;
-
- web_view = E_WEB_VIEW_GTKHTML (alert_sink);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- /* We use equivalent named icons instead of stock IDs,
- * since it's easier to get the filename of the icon. */
- switch (e_alert_get_message_type (alert)) {
- case GTK_MESSAGE_INFO:
- icon_name = "dialog-information";
- break;
-
- case GTK_MESSAGE_WARNING:
- icon_name = "dialog-warning";
- break;
-
- case GTK_MESSAGE_ERROR:
- icon_name = "dialog-error";
- break;
-
- default:
- dialog = e_alert_dialog_new (parent, alert);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return;
- }
-
- gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, NULL);
-
- icon_info = gtk_icon_theme_lookup_icon (
- gtk_icon_theme_get_default (),
- icon_name, size, GTK_ICON_LOOKUP_NO_SVG);
- g_return_if_fail (icon_info != NULL);
-
- filename = gtk_icon_info_get_filename (icon_info);
- icon_uri = g_filename_to_uri (filename, NULL, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- buffer = g_string_sized_new (512);
-
- g_string_append (
- buffer,
- "<html>"
- "<head>"
- "<meta http-equiv=\"content-type\""
- " content=\"text/html; charset=utf-8\">"
- "</head>"
- "<body>");
-
- g_string_append (
- buffer,
- "<table bgcolor='#000000' width='100%'"
- " cellpadding='1' cellspacing='0'>"
- "<tr>"
- "<td>"
- "<table bgcolor='#dddddd' width='100%' cellpadding='6'>"
- "<tr>");
-
- g_string_append_printf (
- buffer,
- "<tr>"
- "<td valign='top'>"
- "<img src='%s'/>"
- "</td>"
- "<td align='left' width='100%%'>"
- "<h3>%s</h3>"
- "%s"
- "</td>"
- "</tr>",
- icon_uri,
- e_alert_get_primary_text (alert),
- e_alert_get_secondary_text (alert));
-
- g_string_append (
- buffer,
- "</table>"
- "</td>"
- "</tr>"
- "</table>"
- "</body>"
- "</html>");
-
- e_web_view_gtkhtml_load_string (web_view, buffer->str);
-
- g_string_free (buffer, TRUE);
-
- gtk_icon_info_free (icon_info);
- g_free (icon_uri);
-}
-
-static void
-web_view_gtkhtml_selectable_update_actions (ESelectable *selectable,
- EFocusTracker *focus_tracker,
- GdkAtom *clipboard_targets,
- gint n_clipboard_targets)
-{
- EWebViewGtkHTML *web_view;
- GtkAction *action;
- /*GtkTargetList *target_list;*/
- gboolean can_paste = FALSE;
- gboolean editable;
- gboolean have_selection;
- gboolean sensitive;
- const gchar *tooltip;
- /*gint ii;*/
-
- web_view = E_WEB_VIEW_GTKHTML (selectable);
- editable = e_web_view_gtkhtml_get_editable (web_view);
- have_selection = e_web_view_gtkhtml_is_selection_active (web_view);
-
- /* XXX GtkHtml implements its own clipboard instead of using
- * GDK_SELECTION_CLIPBOARD, so we don't get notifications
- * when the clipboard contents change. The logic below
- * is what we would do if GtkHtml worked properly.
- * Instead, we need to keep the Paste action sensitive so
- * its accelerator overrides GtkHtml's key binding. */
-#if 0
- target_list = e_selectable_get_paste_target_list (selectable);
- for (ii = 0; ii < n_clipboard_targets && !can_paste; ii++)
- can_paste = gtk_target_list_find (
- target_list, clipboard_targets[ii], NULL);
-#endif
- can_paste = TRUE;
-
- action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
- sensitive = editable && have_selection;
- tooltip = _("Cut the selection");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
- sensitive = have_selection;
- tooltip = _("Copy the selection");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
- sensitive = editable && can_paste;
- tooltip = _("Paste the clipboard");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_select_all_action (focus_tracker);
- sensitive = TRUE;
- tooltip = _("Select all text and images");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-}
-
-static void
-web_view_gtkhtml_selectable_cut_clipboard (ESelectable *selectable)
-{
- e_web_view_gtkhtml_cut_clipboard (E_WEB_VIEW_GTKHTML (selectable));
-}
-
-static void
-web_view_gtkhtml_selectable_copy_clipboard (ESelectable *selectable)
-{
- e_web_view_gtkhtml_copy_clipboard (E_WEB_VIEW_GTKHTML (selectable));
-}
-
-static void
-web_view_gtkhtml_selectable_paste_clipboard (ESelectable *selectable)
-{
- e_web_view_gtkhtml_paste_clipboard (E_WEB_VIEW_GTKHTML (selectable));
-}
-
-static void
-web_view_gtkhtml_selectable_select_all (ESelectable *selectable)
-{
- e_web_view_gtkhtml_select_all (E_WEB_VIEW_GTKHTML (selectable));
-}
-
-static void
-e_web_view_gtkhtml_class_init (EWebViewGtkHTMLClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkHTMLClass *html_class;
-
- g_type_class_add_private (class, sizeof (EWebViewGtkHTMLPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = web_view_gtkhtml_set_property;
- object_class->get_property = web_view_gtkhtml_get_property;
- object_class->dispose = web_view_gtkhtml_dispose;
- object_class->finalize = web_view_gtkhtml_finalize;
- object_class->constructed = web_view_gtkhtml_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->button_press_event = web_view_gtkhtml_button_press_event;
- widget_class->scroll_event = web_view_gtkhtml_scroll_event;
-
- html_class = GTK_HTML_CLASS (class);
- html_class->url_requested = web_view_gtkhtml_url_requested;
- html_class->link_clicked = web_view_gtkhtml_gtkhtml_link_clicked;
- html_class->on_url = web_view_gtkhtml_on_url;
- html_class->iframe_created = web_view_gtkhtml_iframe_created;
-
- class->extract_uri = web_view_gtkhtml_extract_uri;
- class->hovering_over_link = web_view_gtkhtml_hovering_over_link;
- class->link_clicked = web_view_gtkhtml_link_clicked;
- class->load_string = web_view_gtkhtml_load_string;
- class->copy_clipboard = web_view_gtkhtml_copy_clipboard;
- class->cut_clipboard = web_view_gtkhtml_cut_clipboard;
- class->paste_clipboard = web_view_gtkhtml_paste_clipboard;
- class->popup_event = web_view_gtkhtml_popup_event;
- class->stop_loading = web_view_gtkhtml_stop_loading;
- class->update_actions = web_view_gtkhtml_update_actions;
-
- g_object_class_install_property (
- object_class,
- PROP_ANIMATE,
- g_param_spec_boolean (
- "animate",
- "Animate Images",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CARET_MODE,
- g_param_spec_boolean (
- "caret-mode",
- "Caret Mode",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- /* Inherited from ESelectableInterface */
- g_object_class_override_property (
- object_class,
- PROP_COPY_TARGET_LIST,
- "copy-target-list");
-
- g_object_class_install_property (
- object_class,
- PROP_DISABLE_PRINTING,
- g_param_spec_boolean (
- "disable-printing",
- "Disable Printing",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_DISABLE_SAVE_TO_DISK,
- g_param_spec_boolean (
- "disable-save-to-disk",
- "Disable Save-to-Disk",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_EDITABLE,
- g_param_spec_boolean (
- "editable",
- "Editable",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_INLINE_SPELLING,
- g_param_spec_boolean (
- "inline-spelling",
- "Inline Spelling",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_LINKS,
- g_param_spec_boolean (
- "magic-links",
- "Magic Links",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_SMILEYS,
- g_param_spec_boolean (
- "magic-smileys",
- "Magic Smileys",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_OPEN_PROXY,
- g_param_spec_object (
- "open-proxy",
- "Open Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- /* Inherited from ESelectableInterface */
- g_object_class_override_property (
- object_class,
- PROP_PASTE_TARGET_LIST,
- "paste-target-list");
-
- g_object_class_install_property (
- object_class,
- PROP_PRINT_PROXY,
- g_param_spec_object (
- "print-proxy",
- "Print Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SAVE_AS_PROXY,
- g_param_spec_object (
- "save-as-proxy",
- "Save As Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SELECTED_URI,
- g_param_spec_string (
- "selected-uri",
- "Selected URI",
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_IMAGE,
- g_param_spec_object (
- "cursor-image",
- "Image animation at the mouse cursor",
- NULL,
- GDK_TYPE_PIXBUF_ANIMATION,
- G_PARAM_READWRITE));
-
- signals[COPY_CLIPBOARD] = g_signal_new (
- "copy-clipboard",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, copy_clipboard),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[CUT_CLIPBOARD] = g_signal_new (
- "cut-clipboard",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, cut_clipboard),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PASTE_CLIPBOARD] = g_signal_new (
- "paste-clipboard",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, paste_clipboard),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[POPUP_EVENT] = g_signal_new (
- "popup-event",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, popup_event),
- g_signal_accumulator_true_handled, NULL,
- e_marshal_BOOLEAN__BOXED_STRING,
- G_TYPE_BOOLEAN, 2,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
- G_TYPE_STRING);
-
- signals[STATUS_MESSAGE] = g_signal_new (
- "status-message",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, status_message),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- signals[STOP_LOADING] = g_signal_new (
- "stop-loading",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, stop_loading),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[UPDATE_ACTIONS] = g_signal_new (
- "update-actions",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, update_actions),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /* return TRUE when a signal handler processed the mailto URI */
- signals[PROCESS_MAILTO] = g_signal_new (
- "process-mailto",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewGtkHTMLClass, process_mailto),
- NULL, NULL,
- e_marshal_BOOLEAN__STRING,
- G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
-}
-
-static void
-e_web_view_gtkhtml_alert_sink_init (EAlertSinkInterface *interface)
-{
- interface->submit_alert = web_view_gtkhtml_submit_alert;
-}
-
-static void
-e_web_view_gtkhtml_selectable_init (ESelectableInterface *interface)
-{
- interface->update_actions = web_view_gtkhtml_selectable_update_actions;
- interface->cut_clipboard = web_view_gtkhtml_selectable_cut_clipboard;
- interface->copy_clipboard = web_view_gtkhtml_selectable_copy_clipboard;
- interface->paste_clipboard = web_view_gtkhtml_selectable_paste_clipboard;
- interface->select_all = web_view_gtkhtml_selectable_select_all;
-}
-
-static void
-e_web_view_gtkhtml_init (EWebViewGtkHTML *web_view)
-{
- GtkUIManager *ui_manager;
- GtkActionGroup *action_group;
- GtkTargetList *target_list;
- EPopupAction *popup_action;
- const gchar *domain = GETTEXT_PACKAGE;
- const gchar *id;
- GError *error = NULL;
-
- web_view->priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (web_view);
-
- ui_manager = gtk_ui_manager_new ();
- web_view->priv->ui_manager = ui_manager;
-
- g_signal_connect_swapped (
- ui_manager, "connect-proxy",
- G_CALLBACK (web_view_gtkhtml_connect_proxy_cb), web_view);
-
- target_list = gtk_target_list_new (NULL, 0);
- web_view->priv->copy_target_list = target_list;
-
- target_list = gtk_target_list_new (NULL, 0);
- web_view->priv->paste_target_list = target_list;
-
- action_group = gtk_action_group_new ("uri");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, uri_entries,
- G_N_ELEMENTS (uri_entries), web_view);
-
- action_group = gtk_action_group_new ("http");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, http_entries,
- G_N_ELEMENTS (http_entries), web_view);
-
- action_group = gtk_action_group_new ("mailto");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, mailto_entries,
- G_N_ELEMENTS (mailto_entries), web_view);
-
- action_group = gtk_action_group_new ("image");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, image_entries,
- G_N_ELEMENTS (image_entries), web_view);
-
- action_group = gtk_action_group_new ("selection");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, selection_entries,
- G_N_ELEMENTS (selection_entries), web_view);
-
- action_group = gtk_action_group_new ("standard");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), web_view);
-
- popup_action = e_popup_action_new ("open");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "open-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Support lockdown. */
-
- action_group = gtk_action_group_new ("lockdown-printing");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- popup_action = e_popup_action_new ("print");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "print-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- action_group = gtk_action_group_new ("lockdown-save-to-disk");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- popup_action = e_popup_action_new ("save-as");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "save-as-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Because we are loading from a hard-coded string, there is
- * no chance of I/O errors. Failure here implies a malformed
- * UI definition. Full stop. */
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- if (error != NULL)
- g_error ("%s", error->message);
-
- id = "org.gnome.evolution.webview";
- e_plugin_ui_register_manager (ui_manager, id, web_view);
- e_plugin_ui_enable_manager (ui_manager, id);
-
- e_extensible_load_extensions (E_EXTENSIBLE (web_view));
-}
-
-GtkWidget *
-e_web_view_gtkhtml_new (void)
-{
- return g_object_new (E_TYPE_WEB_VIEW_GTKHTML, NULL);
-}
-
-void
-e_web_view_gtkhtml_clear (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_load_empty (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_load_string (EWebViewGtkHTML *web_view,
- const gchar *string)
-{
- EWebViewGtkHTMLClass *class;
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
- g_return_if_fail (class->load_string != NULL);
-
- class->load_string (web_view, string);
-}
-
-gboolean
-e_web_view_gtkhtml_get_animate (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_animate(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_animate (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_animate (EWebViewGtkHTML *web_view,
- gboolean animate)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_animate()
- * so we can get a "notify::animate" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_animate (GTK_HTML (web_view), animate);
-
- g_object_notify (G_OBJECT (web_view), "animate");
-}
-
-gboolean
-e_web_view_gtkhtml_get_caret_mode (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_caret_mode(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_caret_mode (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_caret_mode (EWebViewGtkHTML *web_view,
- gboolean caret_mode)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_caret_mode()
- * so we can get a "notify::caret-mode" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_caret_mode (GTK_HTML (web_view), caret_mode);
-
- g_object_notify (G_OBJECT (web_view), "caret-mode");
-}
-
-GtkTargetList *
-e_web_view_gtkhtml_get_copy_target_list (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- return web_view->priv->copy_target_list;
-}
-
-gboolean
-e_web_view_gtkhtml_get_disable_printing (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return web_view->priv->disable_printing;
-}
-
-void
-e_web_view_gtkhtml_set_disable_printing (EWebViewGtkHTML *web_view,
- gboolean disable_printing)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- web_view->priv->disable_printing = disable_printing;
-
- g_object_notify (G_OBJECT (web_view), "disable-printing");
-}
-
-gboolean
-e_web_view_gtkhtml_get_disable_save_to_disk (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return web_view->priv->disable_save_to_disk;
-}
-
-void
-e_web_view_gtkhtml_set_disable_save_to_disk (EWebViewGtkHTML *web_view,
- gboolean disable_save_to_disk)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- web_view->priv->disable_save_to_disk = disable_save_to_disk;
-
- g_object_notify (G_OBJECT (web_view), "disable-save-to-disk");
-}
-
-gboolean
-e_web_view_gtkhtml_get_editable (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_editable(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_editable (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_editable (EWebViewGtkHTML *web_view,
- gboolean editable)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_editable()
- * so we can get a "notify::editable" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_editable (GTK_HTML (web_view), editable);
-
- g_object_notify (G_OBJECT (web_view), "editable");
-}
-
-gboolean
-e_web_view_gtkhtml_get_inline_spelling (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_inline_spelling(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_inline_spelling (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_inline_spelling (EWebViewGtkHTML *web_view,
- gboolean inline_spelling)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_inline_spelling()
- * so we get a "notify::inline-spelling" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_inline_spelling (GTK_HTML (web_view), inline_spelling);
-
- g_object_notify (G_OBJECT (web_view), "inline-spelling");
-}
-
-gboolean
-e_web_view_gtkhtml_get_magic_links (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_magic_links(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_magic_links (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_magic_links (EWebViewGtkHTML *web_view,
- gboolean magic_links)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_magic_links()
- * so we can get a "notify::magic-links" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_magic_links (GTK_HTML (web_view), magic_links);
-
- g_object_notify (G_OBJECT (web_view), "magic-links");
-}
-
-gboolean
-e_web_view_gtkhtml_get_magic_smileys (EWebViewGtkHTML *web_view)
-{
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_magic_smileys(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_get_magic_smileys (GTK_HTML (web_view));
-}
-
-void
-e_web_view_gtkhtml_set_magic_smileys (EWebViewGtkHTML *web_view,
- gboolean magic_smileys)
-{
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_magic_smileys()
- * so we can get a "notify::magic-smileys" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_set_magic_smileys (GTK_HTML (web_view), magic_smileys);
-
- g_object_notify (G_OBJECT (web_view), "magic-smileys");
-}
-
-const gchar *
-e_web_view_gtkhtml_get_selected_uri (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- return web_view->priv->selected_uri;
-}
-
-void
-e_web_view_gtkhtml_set_selected_uri (EWebViewGtkHTML *web_view,
- const gchar *selected_uri)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_free (web_view->priv->selected_uri);
- web_view->priv->selected_uri = g_strdup (selected_uri);
-
- g_object_notify (G_OBJECT (web_view), "selected-uri");
-}
-
-GdkPixbufAnimation *
-e_web_view_gtkhtml_get_cursor_image (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- return web_view->priv->cursor_image;
-}
-
-void
-e_web_view_gtkhtml_set_cursor_image (EWebViewGtkHTML *web_view,
- GdkPixbufAnimation *image)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- if (image != NULL)
- g_object_ref (image);
-
- if (web_view->priv->cursor_image != NULL)
- g_object_unref (web_view->priv->cursor_image);
-
- web_view->priv->cursor_image = image;
-
- g_object_notify (G_OBJECT (web_view), "cursor-image");
-}
-
-GtkAction *
-e_web_view_gtkhtml_get_open_proxy (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return web_view->priv->open_proxy;
-}
-
-void
-e_web_view_gtkhtml_set_open_proxy (EWebViewGtkHTML *web_view,
- GtkAction *open_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- if (open_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (open_proxy));
- g_object_ref (open_proxy);
- }
-
- if (web_view->priv->open_proxy != NULL)
- g_object_unref (web_view->priv->open_proxy);
-
- web_view->priv->open_proxy = open_proxy;
-
- g_object_notify (G_OBJECT (web_view), "open-proxy");
-}
-
-GtkTargetList *
-e_web_view_gtkhtml_get_paste_target_list (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- return web_view->priv->paste_target_list;
-}
-
-GtkAction *
-e_web_view_gtkhtml_get_print_proxy (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return web_view->priv->print_proxy;
-}
-
-void
-e_web_view_gtkhtml_set_print_proxy (EWebViewGtkHTML *web_view,
- GtkAction *print_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- if (print_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (print_proxy));
- g_object_ref (print_proxy);
- }
-
- if (web_view->priv->print_proxy != NULL)
- g_object_unref (web_view->priv->print_proxy);
-
- web_view->priv->print_proxy = print_proxy;
-
- g_object_notify (G_OBJECT (web_view), "print-proxy");
-}
-
-GtkAction *
-e_web_view_gtkhtml_get_save_as_proxy (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return web_view->priv->save_as_proxy;
-}
-
-void
-e_web_view_gtkhtml_set_save_as_proxy (EWebViewGtkHTML *web_view,
- GtkAction *save_as_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- if (save_as_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (save_as_proxy));
- g_object_ref (save_as_proxy);
- }
-
- if (web_view->priv->save_as_proxy != NULL)
- g_object_unref (web_view->priv->save_as_proxy);
-
- web_view->priv->save_as_proxy = save_as_proxy;
-
- g_object_notify (G_OBJECT (web_view), "save-as-proxy");
-}
-
-GtkAction *
-e_web_view_gtkhtml_get_action (EWebViewGtkHTML *web_view,
- const gchar *action_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
- g_return_val_if_fail (action_name != NULL, NULL);
-
- ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
-
- return e_lookup_action (ui_manager, action_name);
-}
-
-GtkActionGroup *
-e_web_view_gtkhtml_get_action_group (EWebViewGtkHTML *web_view,
- const gchar *group_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
- g_return_val_if_fail (group_name != NULL, NULL);
-
- ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
-
- return e_lookup_action_group (ui_manager, group_name);
-}
-
-gchar *
-e_web_view_gtkhtml_extract_uri (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkHTML *frame)
-{
- EWebViewGtkHTMLClass *class;
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- if (frame == NULL)
- frame = GTK_HTML (web_view);
-
- class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
- g_return_val_if_fail (class->extract_uri != NULL, NULL);
-
- return class->extract_uri (web_view, event, frame);
-}
-
-void
-e_web_view_gtkhtml_copy_clipboard (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[COPY_CLIPBOARD], 0);
-}
-
-void
-e_web_view_gtkhtml_cut_clipboard (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[CUT_CLIPBOARD], 0);
-}
-
-gboolean
-e_web_view_gtkhtml_is_selection_active (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_command (GTK_HTML (web_view), "is-selection-active");
-}
-
-void
-e_web_view_gtkhtml_paste_clipboard (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[PASTE_CLIPBOARD], 0);
-}
-
-gboolean
-e_web_view_gtkhtml_scroll_forward (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_command (GTK_HTML (web_view), "scroll-forward");
-}
-
-gboolean
-e_web_view_gtkhtml_scroll_backward (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
-
- return gtk_html_command (GTK_HTML (web_view), "scroll-backward");
-}
-
-void
-e_web_view_gtkhtml_select_all (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "select-all");
-}
-
-void
-e_web_view_gtkhtml_unselect_all (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "unselect-all");
-}
-
-void
-e_web_view_gtkhtml_zoom_100 (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "zoom-reset");
-}
-
-void
-e_web_view_gtkhtml_zoom_in (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "zoom-in");
-}
-
-void
-e_web_view_gtkhtml_zoom_out (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "zoom-out");
-}
-
-GtkUIManager *
-e_web_view_gtkhtml_get_ui_manager (EWebViewGtkHTML *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- return web_view->priv->ui_manager;
-}
-
-GtkWidget *
-e_web_view_gtkhtml_get_popup_menu (EWebViewGtkHTML *web_view)
-{
- GtkUIManager *ui_manager;
- GtkWidget *menu;
-
- g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
-
- ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
- menu = gtk_ui_manager_get_widget (ui_manager, "/context");
- g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
-
- return menu;
-}
-
-void
-e_web_view_gtkhtml_show_popup_menu (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data)
-{
- GtkWidget *menu;
-
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- e_web_view_gtkhtml_update_actions (web_view);
-
- menu = e_web_view_gtkhtml_get_popup_menu (web_view);
-
- if (event != NULL)
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, event->button, event->time);
- else
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, 0, gtk_get_current_event_time ());
-}
-
-void
-e_web_view_gtkhtml_status_message (EWebViewGtkHTML *web_view,
- const gchar *status_message)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[STATUS_MESSAGE], 0, status_message);
-}
-
-void
-e_web_view_gtkhtml_stop_loading (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[STOP_LOADING], 0);
-}
-
-void
-e_web_view_gtkhtml_update_actions (EWebViewGtkHTML *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
-
- g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
-}
diff --git a/widgets/misc/e-web-view-gtkhtml.h b/widgets/misc/e-web-view-gtkhtml.h
deleted file mode 100644
index aab06e8b54..0000000000
--- a/widgets/misc/e-web-view-gtkhtml.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * e-web-view-gtkhtml.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/* This is intended to serve as a common base class for all HTML viewing
- * needs in Evolution. Currently based on GtkHTML, the idea is to wrap
- * the GtkHTML API enough that we no longer have to make direct calls to
- * it. This should help smooth the transition to WebKit/GTK+.
- *
- * This class handles basic tasks like mouse hovers over links, clicked
- * links, and servicing URI requests asynchronously via GIO. */
-
-#ifndef E_WEB_VIEW_GTKHTML_H
-#define E_WEB_VIEW_GTKHTML_H
-
-#include <gtkhtml/gtkhtml.h>
-
-/* Standard GObject macros */
-#define E_TYPE_WEB_VIEW_GTKHTML \
- (e_web_view_gtkhtml_get_type ())
-#define E_WEB_VIEW_GTKHTML(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTML))
-#define E_WEB_VIEW_GTKHTML_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLClass))
-#define E_IS_WEB_VIEW_GTKHTML(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_WEB_VIEW_GTKHTML))
-#define E_IS_WEB_VIEW_GTKHTML_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_WEB_VIEW_GTKHTML))
-#define E_WEB_VIEW_GTKHTML_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EWebViewGtkHTML EWebViewGtkHTML;
-typedef struct _EWebViewGtkHTMLClass EWebViewGtkHTMLClass;
-typedef struct _EWebViewGtkHTMLPrivate EWebViewGtkHTMLPrivate;
-
-struct _EWebViewGtkHTML {
- GtkHTML parent;
- EWebViewGtkHTMLPrivate *priv;
-};
-
-struct _EWebViewGtkHTMLClass {
- GtkHTMLClass parent_class;
-
- /* Methods */
- gchar * (*extract_uri) (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkHTML *frame);
- void (*hovering_over_link) (EWebViewGtkHTML *web_view,
- const gchar *title,
- const gchar *uri);
- void (*link_clicked) (EWebViewGtkHTML *web_view,
- const gchar *uri);
- void (*load_string) (EWebViewGtkHTML *web_view,
- const gchar *load_string);
-
- /* Signals */
- void (*copy_clipboard) (EWebViewGtkHTML *web_view);
- void (*cut_clipboard) (EWebViewGtkHTML *web_view);
- void (*paste_clipboard) (EWebViewGtkHTML *web_view);
- gboolean (*popup_event) (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- const gchar *uri);
- void (*status_message) (EWebViewGtkHTML *web_view,
- const gchar *status_message);
- void (*stop_loading) (EWebViewGtkHTML *web_view);
- void (*update_actions) (EWebViewGtkHTML *web_view);
- gboolean (*process_mailto) (EWebViewGtkHTML *web_view,
- const gchar *mailto_uri);
-};
-
-GType e_web_view_gtkhtml_get_type (void);
-GtkWidget * e_web_view_gtkhtml_new (void);
-void e_web_view_gtkhtml_clear (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_load_string (EWebViewGtkHTML *web_view,
- const gchar *string);
-gboolean e_web_view_gtkhtml_get_animate (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_animate (EWebViewGtkHTML *web_view,
- gboolean animate);
-gboolean e_web_view_gtkhtml_get_caret_mode (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_caret_mode (EWebViewGtkHTML *web_view,
- gboolean caret_mode);
-GtkTargetList * e_web_view_gtkhtml_get_copy_target_list (EWebViewGtkHTML *web_view);
-gboolean e_web_view_gtkhtml_get_disable_printing (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_disable_printing (EWebViewGtkHTML *web_view,
- gboolean disable_printing);
-gboolean e_web_view_gtkhtml_get_disable_save_to_disk
- (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_disable_save_to_disk
- (EWebViewGtkHTML *web_view,
- gboolean disable_save_to_disk);
-gboolean e_web_view_gtkhtml_get_editable (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_editable (EWebViewGtkHTML *web_view,
- gboolean editable);
-gboolean e_web_view_gtkhtml_get_inline_spelling (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_inline_spelling (EWebViewGtkHTML *web_view,
- gboolean inline_spelling);
-gboolean e_web_view_gtkhtml_get_magic_links (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_magic_links (EWebViewGtkHTML *web_view,
- gboolean magic_links);
-gboolean e_web_view_gtkhtml_get_magic_smileys (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_magic_smileys (EWebViewGtkHTML *web_view,
- gboolean magic_smileys);
-const gchar * e_web_view_gtkhtml_get_selected_uri (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_selected_uri (EWebViewGtkHTML *web_view,
- const gchar *selected_uri);
-GdkPixbufAnimation *
- e_web_view_gtkhtml_get_cursor_image (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_cursor_image (EWebViewGtkHTML *web_view,
- GdkPixbufAnimation *animation);
-GtkAction * e_web_view_gtkhtml_get_open_proxy (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_open_proxy (EWebViewGtkHTML *web_view,
- GtkAction *open_proxy);
-GtkTargetList * e_web_view_gtkhtml_get_paste_target_list
- (EWebViewGtkHTML *web_view);
-GtkAction * e_web_view_gtkhtml_get_print_proxy (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_print_proxy (EWebViewGtkHTML *web_view,
- GtkAction *print_proxy);
-GtkAction * e_web_view_gtkhtml_get_save_as_proxy (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_set_save_as_proxy (EWebViewGtkHTML *web_view,
- GtkAction *save_as_proxy);
-GtkAction * e_web_view_gtkhtml_get_action (EWebViewGtkHTML *web_view,
- const gchar *action_name);
-GtkActionGroup *e_web_view_gtkhtml_get_action_group (EWebViewGtkHTML *web_view,
- const gchar *group_name);
-gchar * e_web_view_gtkhtml_extract_uri (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkHTML *frame);
-void e_web_view_gtkhtml_copy_clipboard (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_cut_clipboard (EWebViewGtkHTML *web_view);
-gboolean e_web_view_gtkhtml_is_selection_active (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_paste_clipboard (EWebViewGtkHTML *web_view);
-gboolean e_web_view_gtkhtml_scroll_forward (EWebViewGtkHTML *web_view);
-gboolean e_web_view_gtkhtml_scroll_backward (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_select_all (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_unselect_all (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_zoom_100 (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_zoom_in (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_zoom_out (EWebViewGtkHTML *web_view);
-GtkUIManager * e_web_view_gtkhtml_get_ui_manager (EWebViewGtkHTML *web_view);
-GtkWidget * e_web_view_gtkhtml_get_popup_menu (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_show_popup_menu (EWebViewGtkHTML *web_view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data);
-void e_web_view_gtkhtml_status_message (EWebViewGtkHTML *web_view,
- const gchar *status_message);
-void e_web_view_gtkhtml_stop_loading (EWebViewGtkHTML *web_view);
-void e_web_view_gtkhtml_update_actions (EWebViewGtkHTML *web_view);
-
-G_END_DECLS
-
-#endif /* E_WEB_VIEW_GTKHTML_H */
diff --git a/widgets/misc/e-web-view-preview.c b/widgets/misc/e-web-view-preview.c
deleted file mode 100644
index b75814fa83..0000000000
--- a/widgets/misc/e-web-view-preview.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * e-web-view-preview.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-web-view-preview.h"
-
-#include <string.h>
-#include <glib/gi18n-lib.h>
-
-#define E_WEB_VIEW_PREVIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_WEB_VIEW_PREVIEW, EWebViewPreviewPrivate))
-
-struct _EWebViewPreviewPrivate {
- gboolean escape_values;
- GString *updating_content; /* is NULL when not between begin_update/end_update */
-};
-
-enum {
- PROP_0,
- PROP_TREE_VIEW,
- PROP_PREVIEW_WIDGET,
- PROP_ESCAPE_VALUES
-};
-
-G_DEFINE_TYPE (
- EWebViewPreview,
- e_web_view_preview,
- GTK_TYPE_VPANED);
-
-static void
-web_view_preview_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ESCAPE_VALUES:
- e_web_view_preview_set_escape_values (
- E_WEB_VIEW_PREVIEW (object),
- g_value_get_boolean (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_preview_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_TREE_VIEW:
- g_value_set_object (
- value, e_web_view_preview_get_tree_view (
- E_WEB_VIEW_PREVIEW (object)));
- return;
-
- case PROP_PREVIEW_WIDGET:
- g_value_set_object (
- value, e_web_view_preview_get_preview (
- E_WEB_VIEW_PREVIEW (object)));
- return;
-
- case PROP_ESCAPE_VALUES:
- g_value_set_boolean (
- value, e_web_view_preview_get_escape_values (
- E_WEB_VIEW_PREVIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_preview_dispose (GObject *object)
-{
- EWebViewPreviewPrivate *priv;
-
- priv = E_WEB_VIEW_PREVIEW_GET_PRIVATE (object);
-
- if (priv->updating_content != NULL) {
- g_string_free (priv->updating_content, TRUE);
- priv->updating_content = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_web_view_preview_parent_class)->dispose (object);
-}
-
-static void
-e_web_view_preview_class_init (EWebViewPreviewClass *class)
-{
- GObjectClass *object_class;
-
- g_type_class_add_private (class, sizeof (EWebViewPreviewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = web_view_preview_set_property;
- object_class->get_property = web_view_preview_get_property;
- object_class->dispose = web_view_preview_dispose;
-
- g_object_class_install_property (
- object_class,
- PROP_TREE_VIEW,
- g_param_spec_object (
- "tree-view",
- "Tree View",
- NULL,
- GTK_TYPE_TREE_VIEW,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_PREVIEW_WIDGET,
- g_param_spec_object (
- "preview-widget",
- "Preview Widget",
- NULL,
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_ESCAPE_VALUES,
- g_param_spec_boolean (
- "escape-values",
- "Whether escaping values automatically, when inserting",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-}
-
-static GtkWidget *
-in_scrolled_window (GtkWidget *widget)
-{
- GtkWidget *sw;
-
- g_return_val_if_fail (widget != NULL, NULL);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (sw), widget);
-
- gtk_widget_show (widget);
- gtk_widget_show (sw);
-
- return sw;
-}
-
-static void
-e_web_view_preview_init (EWebViewPreview *preview)
-{
- GtkWidget *tree_view_sw, *web_view_sw;
-
- preview->priv = E_WEB_VIEW_PREVIEW_GET_PRIVATE (preview);
- preview->priv->escape_values = TRUE;
-
- tree_view_sw = in_scrolled_window (gtk_tree_view_new ());
- web_view_sw = in_scrolled_window (e_web_view_new ());
-
- gtk_widget_hide (tree_view_sw);
- gtk_widget_show (web_view_sw);
-
- gtk_paned_pack1 (GTK_PANED (preview), tree_view_sw, FALSE, TRUE);
- gtk_paned_pack2 (GTK_PANED (preview), web_view_sw, TRUE, TRUE);
-
- /* rawly 3 lines of a text plus a little bit more */
- if (gtk_paned_get_position (GTK_PANED (preview)) < 85)
- gtk_paned_set_position (GTK_PANED (preview), 85);
-}
-
-GtkWidget *
-e_web_view_preview_new (void)
-{
- return g_object_new (E_TYPE_WEB_VIEW_PREVIEW, NULL);
-}
-
-GtkTreeView *
-e_web_view_preview_get_tree_view (EWebViewPreview *preview)
-{
- g_return_val_if_fail (preview != NULL, NULL);
- g_return_val_if_fail (E_IS_WEB_VIEW_PREVIEW (preview), NULL);
-
- return GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (gtk_paned_get_child1 (GTK_PANED (preview)))));
-}
-
-GtkWidget *
-e_web_view_preview_get_preview (EWebViewPreview *preview)
-{
- g_return_val_if_fail (preview != NULL, NULL);
- g_return_val_if_fail (E_IS_WEB_VIEW_PREVIEW (preview), NULL);
-
- return gtk_bin_get_child (GTK_BIN (gtk_paned_get_child2 (GTK_PANED (preview))));
-}
-
-void
-e_web_view_preview_set_preview (EWebViewPreview *preview,
- GtkWidget *preview_widget)
-{
- GtkWidget *old_child;
-
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (GTK_IS_WIDGET (preview_widget));
-
- old_child = gtk_bin_get_child (GTK_BIN (gtk_paned_get_child2 (GTK_PANED (preview))));
- if (old_child) {
- g_return_if_fail (old_child != preview_widget);
- gtk_widget_destroy (old_child);
- }
-
- gtk_container_add (GTK_CONTAINER (gtk_paned_get_child2 (GTK_PANED (preview))), preview_widget);
-}
-
-void
-e_web_view_preview_show_tree_view (EWebViewPreview *preview)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
-
- gtk_widget_show (gtk_paned_get_child1 (GTK_PANED (preview)));
-}
-
-void
-e_web_view_preview_hide_tree_view (EWebViewPreview *preview)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
-
- gtk_widget_hide (gtk_paned_get_child1 (GTK_PANED (preview)));
-}
-
-void
-e_web_view_preview_set_escape_values (EWebViewPreview *preview,
- gboolean escape)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
-
- preview->priv->escape_values = escape;
-}
-
-gboolean
-e_web_view_preview_get_escape_values (EWebViewPreview *preview)
-{
- g_return_val_if_fail (preview != NULL, FALSE);
- g_return_val_if_fail (E_IS_WEB_VIEW_PREVIEW (preview), FALSE);
- g_return_val_if_fail (preview->priv != NULL, FALSE);
-
- return preview->priv->escape_values;
-}
-
-void
-e_web_view_preview_begin_update (EWebViewPreview *preview)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
-
- if (preview->priv->updating_content) {
- g_warning ("%s: Previous content update isn't finished with e_web_view_preview_end_update()", G_STRFUNC);
- g_string_free (preview->priv->updating_content, TRUE);
- }
-
- preview->priv->updating_content = g_string_new ("<TABLE width=\"100%\" border=\"0\" cols=\"2\">");
-}
-
-void
-e_web_view_preview_end_update (EWebViewPreview *preview)
-{
- GtkWidget *web_view;
-
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
-
- g_string_append (preview->priv->updating_content, "</TABLE>");
-
- web_view = e_web_view_preview_get_preview (preview);
- if (E_IS_WEB_VIEW (web_view))
- e_web_view_load_string (E_WEB_VIEW (web_view), preview->priv->updating_content->str);
-
- g_string_free (preview->priv->updating_content, TRUE);
- preview->priv->updating_content = NULL;
-}
-
-static gchar *
-replace_string (const gchar *text,
- const gchar *find,
- const gchar *replace)
-{
- const gchar *p, *next;
- GString *str;
- gint find_len;
-
- g_return_val_if_fail (text != NULL, NULL);
- g_return_val_if_fail (find != NULL, NULL);
- g_return_val_if_fail (*find, NULL);
-
- find_len = strlen (find);
- str = g_string_new ("");
-
- p = text;
- while (next = strstr (p, find), next) {
- if (p + 1 < next)
- g_string_append_len (str, p, next - p);
-
- if (replace && *replace)
- g_string_append (str, replace);
-
- p = next + find_len;
- }
-
- g_string_append (str, p);
-
- return g_string_free (str, FALSE);
-}
-
-static gchar *
-web_view_preview_escape_text (EWebViewPreview *preview,
- const gchar *text)
-{
- gchar *utf8_valid, *res, *end;
-
- if (!e_web_view_preview_get_escape_values (preview))
- return NULL;
-
- g_return_val_if_fail (text != NULL, NULL);
-
- if (g_utf8_validate (text, -1, NULL)) {
- res = g_markup_escape_text (text, -1);
- } else {
- utf8_valid = g_strdup (text);
- while (end = NULL, !g_utf8_validate (utf8_valid, -1, (const gchar **) &end) && end && *end)
- *end = '?';
-
- res = g_markup_escape_text (utf8_valid, -1);
-
- g_free (utf8_valid);
- }
-
- if (res && strchr (res, '\n')) {
- /* replace line breaks with <BR> */
- if (strchr (res, '\r')) {
- end = replace_string (res, "\r", "");
- g_free (res);
- res = end;
- }
-
- end = replace_string (res, "\n", "<BR>");
- g_free (res);
- res = end;
- }
-
- return res;
-}
-
-void
-e_web_view_preview_add_header (EWebViewPreview *preview,
- gint index,
- const gchar *header)
-{
- gchar *escaped;
-
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
- g_return_if_fail (header != NULL);
-
- if (index < 1)
- index = 1;
- else if (index > 6)
- index = 6;
-
- escaped = web_view_preview_escape_text (preview, header);
- if (escaped)
- header = escaped;
-
- g_string_append_printf (preview->priv->updating_content, "<TR><TD colspan=2><H%d>%s</H%d></TD></TR>", index, header, index);
-
- g_free (escaped);
-}
-
-void
-e_web_view_preview_add_text (EWebViewPreview *preview,
- const gchar *text)
-{
- gchar *escaped;
-
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
- g_return_if_fail (text != NULL);
-
- escaped = web_view_preview_escape_text (preview, text);
- if (escaped)
- text = escaped;
-
- g_string_append_printf (preview->priv->updating_content, "<TR><TD colspan=2><FONT size=\"3\">%s</FONT></TD></TR>", text);
-
- g_free (escaped);
-}
-
-void
-e_web_view_preview_add_raw_html (EWebViewPreview *preview,
- const gchar *raw_html)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
- g_return_if_fail (raw_html != NULL);
-
- g_string_append_printf (preview->priv->updating_content, "<TR><TD colspan=2>%s</TD></TR>", raw_html);
-}
-
-void
-e_web_view_preview_add_separator (EWebViewPreview *preview)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
-
- g_string_append (preview->priv->updating_content, "<TR><TD colspan=2><HR></TD></TR>");
-}
-
-void
-e_web_view_preview_add_empty_line (EWebViewPreview *preview)
-{
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
-
- g_string_append (preview->priv->updating_content, "<TR><TD colspan=2>&nbsp;</TD></TR>");
-}
-
-/* section can be NULL, but value cannot */
-void
-e_web_view_preview_add_section (EWebViewPreview *preview,
- const gchar *section,
- const gchar *value)
-{
- gchar *escaped_section = NULL, *escaped_value;
-
- g_return_if_fail (E_IS_WEB_VIEW_PREVIEW (preview));
- g_return_if_fail (preview->priv->updating_content != NULL);
- g_return_if_fail (value != NULL);
-
- if (section) {
- escaped_section = web_view_preview_escape_text (preview, section);
- if (escaped_section)
- section = escaped_section;
- }
-
- escaped_value = web_view_preview_escape_text (preview, value);
- if (escaped_value)
- value = escaped_value;
-
- g_string_append_printf (preview->priv->updating_content, "<TR><TD width=\"10%%\" valign=\"top\" nowrap><FONT size=\"3\"><B>%s</B></FONT></TD><TD width=\"90%%\"><FONT size=\"3\">%s</FONT></TD></TR>", section ? section : "", value);
-
- g_free (escaped_section);
- g_free (escaped_value);
-}
diff --git a/widgets/misc/e-web-view-preview.h b/widgets/misc/e-web-view-preview.h
deleted file mode 100644
index 07c78ff182..0000000000
--- a/widgets/misc/e-web-view-preview.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * e-web-view-preview.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* This is intended to serve as a common widget for previews before import.
- * It contains a GtkTreeView at the top and an EWebView at the bottom.
- * The tree view is not shown initially, it should be forced with
- * e_web_view_preview_show_tree_view().
- *
- * The internal default EWebView can be accessed by e_web_view_preview_get_preview()
- * and it should be updated for each change of the selected item in the tree
- * view, when it's shown.
- *
- * Updating an EWebView content through helper functions of an EWebViewPreview
- * begins with call of e_web_view_preview_begin_update(), which starts an empty
- * page construction, which is finished by e_web_view_preview_end_update(),
- * and the content of the EWebView is updated.
- */
-
-#ifndef E_WEB_VIEW_PREVIEW_H
-#define E_WEB_VIEW_PREVIEW_H
-
-#include <misc/e-web-view.h>
-
-/* Standard GObject macros */
-#define E_TYPE_WEB_VIEW_PREVIEW \
- (e_web_view_preview_get_type ())
-#define E_WEB_VIEW_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_WEB_VIEW_PREVIEW, EWebViewPreview))
-#define E_WEB_VIEW_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_WEB_VIEW_PREVIEW, EWebViewPreviewClass))
-#define E_IS_WEB_VIEW_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_WEB_VIEW_PREVIEW))
-#define E_IS_WEB_VIEW_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_WEB_VIEW_PREVIEW))
-#define E_WEB_VIEW_PREVIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_WEB_VIEW_PREVIEW, EWebViewPreviewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EWebViewPreview EWebViewPreview;
-typedef struct _EWebViewPreviewClass EWebViewPreviewClass;
-typedef struct _EWebViewPreviewPrivate EWebViewPreviewPrivate;
-
-struct _EWebViewPreview {
- GtkVPaned parent;
- EWebViewPreviewPrivate *priv;
-};
-
-struct _EWebViewPreviewClass {
- GtkVPanedClass parent_class;
-};
-
-GType e_web_view_preview_get_type (void);
-GtkWidget * e_web_view_preview_new (void);
-GtkTreeView * e_web_view_preview_get_tree_view
- (EWebViewPreview *preview);
-GtkWidget * e_web_view_preview_get_preview (EWebViewPreview *preview);
-void e_web_view_preview_set_preview (EWebViewPreview *preview,
- GtkWidget *preview_widget);
-void e_web_view_preview_show_tree_view
- (EWebViewPreview *preview);
-void e_web_view_preview_hide_tree_view
- (EWebViewPreview *preview);
-void e_web_view_preview_set_escape_values
- (EWebViewPreview *preview,
- gboolean escape);
-gboolean e_web_view_preview_get_escape_values
- (EWebViewPreview *preview);
-void e_web_view_preview_begin_update (EWebViewPreview *preview);
-void e_web_view_preview_end_update (EWebViewPreview *preview);
-void e_web_view_preview_add_header (EWebViewPreview *preview,
- gint index,
- const gchar *header);
-void e_web_view_preview_add_text (EWebViewPreview *preview,
- const gchar *text);
-void e_web_view_preview_add_raw_html (EWebViewPreview *preview,
- const gchar *raw_html);
-void e_web_view_preview_add_separator
- (EWebViewPreview *preview);
-void e_web_view_preview_add_empty_line
- (EWebViewPreview *preview);
-void e_web_view_preview_add_section (EWebViewPreview *preview,
- const gchar *section,
- const gchar *value);
-
-G_END_DECLS
-
-#endif /* E_WEB_VIEW_PREVIEW_H */
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
deleted file mode 100644
index 0d0903c7bd..0000000000
--- a/widgets/misc/e-web-view.c
+++ /dev/null
@@ -1,2946 +0,0 @@
-/*
- * e-web-view.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-web-view.h"
-
-#include <math.h>
-
-#include <string.h>
-#include <glib/gi18n-lib.h>
-#include <pango/pango.h>
-
-#include <camel/camel.h>
-#include <libebackend/libebackend.h>
-
-#include <e-util/e-util.h>
-#include <libevolution-utils/e-alert-dialog.h>
-#include <libevolution-utils/e-alert-sink.h>
-#include <e-util/e-plugin-ui.h>
-#include <e-util/e-file-request.h>
-#include <e-util/e-stock-request.h>
-
-#define LIBSOUP_USE_UNSTABLE_REQUEST_API
-#include <libsoup/soup.h>
-#include <libsoup/soup-requester.h>
-
-#include "e-popup-action.h"
-#include "e-selectable.h"
-#include <stdlib.h>
-
-#define E_WEB_VIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_WEB_VIEW, EWebViewPrivate))
-
-typedef struct _EWebViewRequest EWebViewRequest;
-
-struct _EWebViewPrivate {
- GList *requests;
- GtkUIManager *ui_manager;
- gchar *selected_uri;
- GdkPixbufAnimation *cursor_image;
- gchar *cursor_image_src;
-
- GSList *highlights;
-
- GtkAction *open_proxy;
- GtkAction *print_proxy;
- GtkAction *save_as_proxy;
-
- /* Lockdown Options */
- guint disable_printing : 1;
- guint disable_save_to_disk : 1;
-
- guint caret_mode : 1;
-
- GSettings *font_settings;
- GSettings *aliasing_settings;
-};
-
-enum {
- PROP_0,
- PROP_CARET_MODE,
- PROP_COPY_TARGET_LIST,
- PROP_CURSOR_IMAGE,
- PROP_CURSOR_IMAGE_SRC,
- PROP_DISABLE_PRINTING,
- PROP_DISABLE_SAVE_TO_DISK,
- PROP_INLINE_SPELLING,
- PROP_MAGIC_LINKS,
- PROP_MAGIC_SMILEYS,
- PROP_OPEN_PROXY,
- PROP_PRINT_PROXY,
- PROP_SAVE_AS_PROXY,
- PROP_SELECTED_URI
-};
-
-enum {
- POPUP_EVENT,
- STATUS_MESSAGE,
- STOP_LOADING,
- UPDATE_ACTIONS,
- PROCESS_MAILTO,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <menuitem action='copy-clipboard'/>"
-" <separator/>"
-" <placeholder name='custom-actions-1'>"
-" <menuitem action='open'/>"
-" <menuitem action='save-as'/>"
-" <menuitem action='http-open'/>"
-" <menuitem action='send-message'/>"
-" <menuitem action='print'/>"
-" </placeholder>"
-" <placeholder name='custom-actions-2'>"
-" <menuitem action='uri-copy'/>"
-" <menuitem action='mailto-copy'/>"
-" <menuitem action='image-copy'/>"
-" </placeholder>"
-" <placeholder name='custom-actions-3'/>"
-" <separator/>"
-" <menuitem action='select-all'/>"
-" <placeholder name='inspect-menu' />"
-" </popup>"
-"</ui>";
-
-/* Forward Declarations */
-static void e_web_view_alert_sink_init (EAlertSinkInterface *interface);
-static void e_web_view_selectable_init (ESelectableInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EWebView,
- e_web_view,
- WEBKIT_TYPE_WEB_VIEW,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_ALERT_SINK,
- e_web_view_alert_sink_init)
- G_IMPLEMENT_INTERFACE (
- E_TYPE_SELECTABLE,
- e_web_view_selectable_init))
-
-static void
-action_copy_clipboard_cb (GtkAction *action,
- EWebView *web_view)
-{
- e_web_view_copy_clipboard (web_view);
-}
-
-static void
-action_http_open_cb (GtkAction *action,
- EWebView *web_view)
-{
- const gchar *uri;
- gpointer parent;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- uri = e_web_view_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- e_show_uri (parent, uri);
-}
-
-static void
-action_mailto_copy_cb (GtkAction *action,
- EWebView *web_view)
-{
- CamelURL *curl;
- CamelInternetAddress *inet_addr;
- GtkClipboard *clipboard;
- const gchar *uri;
- gchar *text;
-
- uri = e_web_view_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- /* This should work because we checked it in update_actions(). */
- curl = camel_url_new (uri, NULL);
- g_return_if_fail (curl != NULL);
-
- inet_addr = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
- text = camel_address_format (CAMEL_ADDRESS (inet_addr));
- if (text == NULL || *text == '\0')
- text = g_strdup (uri + strlen ("mailto:"));
-
- g_object_unref (inet_addr);
- camel_url_free (curl);
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
- gtk_clipboard_set_text (clipboard, text, -1);
- gtk_clipboard_store (clipboard);
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_set_text (clipboard, text, -1);
- gtk_clipboard_store (clipboard);
-
- g_free (text);
-}
-
-static void
-action_select_all_cb (GtkAction *action,
- EWebView *web_view)
-{
- e_web_view_select_all (web_view);
-}
-
-static void
-action_send_message_cb (GtkAction *action,
- EWebView *web_view)
-{
- const gchar *uri;
- gpointer parent;
- gboolean handled;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- uri = e_web_view_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- handled = FALSE;
- g_signal_emit (web_view, signals[PROCESS_MAILTO], 0, uri, &handled);
-
- if (!handled)
- e_show_uri (parent, uri);
-}
-
-static void
-action_uri_copy_cb (GtkAction *action,
- EWebView *web_view)
-{
- GtkClipboard *clipboard;
- const gchar *uri;
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- uri = e_web_view_get_selected_uri (web_view);
- g_return_if_fail (uri != NULL);
-
- gtk_clipboard_set_text (clipboard, uri, -1);
- gtk_clipboard_store (clipboard);
-}
-
-static void
-action_image_copy_cb (GtkAction *action,
- EWebView *web_view)
-{
- GtkClipboard *clipboard;
- GdkPixbufAnimation *animation;
- GdkPixbuf *pixbuf;
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- animation = e_web_view_get_cursor_image (web_view);
- g_return_if_fail (animation != NULL);
-
- pixbuf = gdk_pixbuf_animation_get_static_image (animation);
- if (pixbuf == NULL)
- return;
-
- gtk_clipboard_set_image (clipboard, pixbuf);
- gtk_clipboard_store (clipboard);
-}
-
-static GtkActionEntry uri_entries[] = {
-
- { "uri-copy",
- GTK_STOCK_COPY,
- N_("_Copy Link Location"),
- NULL,
- N_("Copy the link to the clipboard"),
- G_CALLBACK (action_uri_copy_cb) }
-};
-
-static GtkActionEntry http_entries[] = {
-
- { "http-open",
- "emblem-web",
- N_("_Open Link in Browser"),
- NULL,
- N_("Open the link in a web browser"),
- G_CALLBACK (action_http_open_cb) }
-};
-
-static GtkActionEntry mailto_entries[] = {
-
- { "mailto-copy",
- GTK_STOCK_COPY,
- N_("_Copy Email Address"),
- NULL,
- N_("Copy the email address to the clipboard"),
- G_CALLBACK (action_mailto_copy_cb) },
-
- { "send-message",
- "mail-message-new",
- N_("_Send New Message To..."),
- NULL,
- N_("Send a mail message to this address"),
- G_CALLBACK (action_send_message_cb) }
-};
-
-static GtkActionEntry image_entries[] = {
-
- { "image-copy",
- GTK_STOCK_COPY,
- N_("_Copy Image"),
- NULL,
- N_("Copy the image to the clipboard"),
- G_CALLBACK (action_image_copy_cb) }
-};
-
-static GtkActionEntry selection_entries[] = {
-
- { "copy-clipboard",
- GTK_STOCK_COPY,
- NULL,
- NULL,
- N_("Copy the selection"),
- G_CALLBACK (action_copy_clipboard_cb) },
-};
-
-static GtkActionEntry standard_entries[] = {
-
- { "select-all",
- GTK_STOCK_SELECT_ALL,
- NULL,
- NULL,
- N_("Select all text and images"),
- G_CALLBACK (action_select_all_cb) }
-};
-
-static void
-web_view_menu_item_select_cb (EWebView *web_view,
- GtkWidget *widget)
-{
- GtkAction *action;
- GtkActivatable *activatable;
- const gchar *tooltip;
-
- activatable = GTK_ACTIVATABLE (widget);
- action = gtk_activatable_get_related_action (activatable);
- tooltip = gtk_action_get_tooltip (action);
-
- if (tooltip == NULL)
- return;
-
- e_web_view_status_message (web_view, tooltip);
-}
-
-static void
-replace_text (WebKitDOMNode *node,
- const gchar *text,
- WebKitDOMNode *replacement)
-{
- /* NodeType 3 = TEXT_NODE */
- if (webkit_dom_node_get_node_type (node) == 3) {
- gint text_length = strlen (text);
-
- while (node) {
-
- WebKitDOMNode *current_node, *replacement_node;
- const gchar *node_data, *offset;
- goffset split_offset;
- gint data_length;
-
- current_node = node;
-
- /* Don't use the WEBKIT_DOM_CHARACTER_DATA macro for
- * casting. WebKit lies about type of the object and
- * GLib will throw runtime warning about node not being
- * WebKitDOMCharacterData, but the function will return
- * correct and valid data.
- * IMO it's bug in the Gtk bindings and WebKit internally
- * handles it by the nodeType so therefor it works
- * event for "invalid" objects. But really, who knows..?
- */
- node_data = webkit_dom_character_data_get_data (
- (WebKitDOMCharacterData *) node);
-
- offset = strstr (node_data, text);
- if (offset == NULL) {
- node = NULL;
- continue;
- }
-
- split_offset = offset - node_data + text_length;
- replacement_node =
- webkit_dom_node_clone_node (replacement, TRUE);
-
- data_length = webkit_dom_character_data_get_length (
- (WebKitDOMCharacterData *) node);
- if (split_offset < data_length) {
-
- WebKitDOMNode *parent_node;
-
- node = WEBKIT_DOM_NODE (
- webkit_dom_text_split_text (
- (WebKitDOMText *) node,
- offset - node_data + text_length,
- NULL));
- parent_node = webkit_dom_node_get_parent_node (node);
- webkit_dom_node_insert_before (
- parent_node, replacement_node,
- node, NULL);
-
- } else {
- WebKitDOMNode *parent_node;
-
- parent_node = webkit_dom_node_get_parent_node (node);
- webkit_dom_node_append_child (
- parent_node,
- replacement_node, NULL);
- }
-
- webkit_dom_character_data_delete_data (
- (WebKitDOMCharacterData *) (current_node),
- offset - node_data, text_length, NULL);
- }
-
- } else {
- WebKitDOMNode *child, *next_child;
-
- /* Iframe? Let's traverse inside! */
- if (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (node)) {
-
- WebKitDOMDocument *frame_document;
-
- frame_document =
- webkit_dom_html_iframe_element_get_content_document (
- WEBKIT_DOM_HTML_IFRAME_ELEMENT (node));
- replace_text (
- WEBKIT_DOM_NODE (frame_document),
- text, replacement);
-
- } else {
- child = webkit_dom_node_get_first_child (node);
- while (child != NULL) {
- next_child = webkit_dom_node_get_next_sibling (child);
- replace_text (child, text, replacement);
- child = next_child;
- }
- }
- }
-}
-
-static void
-web_view_update_document_highlights (EWebView *web_view)
-{
- WebKitDOMDocument *document;
- GSList *iter;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
-
- for (iter = web_view->priv->highlights; iter; iter = iter->next) {
-
- WebKitDOMDocumentFragment *frag;
- WebKitDOMElement *span;
-
- span = webkit_dom_document_create_element (document, "span", NULL);
-
- /* See https://bugzilla.gnome.org/show_bug.cgi?id=681400
- * FIXME: This can be removed once we require WebKitGtk 1.10+ */
- #if WEBKIT_CHECK_VERSION (1, 9, 6)
- webkit_dom_element_set_class_name (
- span, "__evo-highlight");
- #else
- webkit_dom_html_element_set_class_name (
- WEBKIT_DOM_HTML_ELEMENT (span), "__evo-highlight");
- #endif
-
- webkit_dom_html_element_set_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (span), iter->data, NULL);
-
- frag = webkit_dom_document_create_document_fragment (document);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (frag), WEBKIT_DOM_NODE (span), NULL);
-
- replace_text (
- WEBKIT_DOM_NODE (document),
- iter->data, WEBKIT_DOM_NODE (frag));
- }
-}
-
-static void
-web_view_menu_item_deselect_cb (EWebView *web_view)
-{
- e_web_view_status_message (web_view, NULL);
-}
-
-static void
-web_view_connect_proxy_cb (EWebView *web_view,
- GtkAction *action,
- GtkWidget *proxy)
-{
- if (!GTK_IS_MENU_ITEM (proxy))
- return;
-
- g_signal_connect_swapped (
- proxy, "select",
- G_CALLBACK (web_view_menu_item_select_cb), web_view);
-
- g_signal_connect_swapped (
- proxy, "deselect",
- G_CALLBACK (web_view_menu_item_deselect_cb), web_view);
-}
-
-static GtkWidget *
-web_view_create_plugin_widget_cb (EWebView *web_view,
- const gchar *mime_type,
- const gchar *uri,
- GHashTable *param)
-{
- EWebViewClass *class;
-
- /* XXX WebKitWebView does not provide a class method for
- * this signal, so we do so we can override the default
- * behavior from subclasses for special URI types. */
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_val_if_fail (class->create_plugin_widget != NULL, NULL);
-
- return class->create_plugin_widget (web_view, mime_type, uri, param);
-}
-
-static void
-web_view_hovering_over_link_cb (EWebView *web_view,
- const gchar *title,
- const gchar *uri)
-{
- EWebViewClass *class;
-
- /* XXX WebKitWebView does not provide a class method for
- * this signal, so we do so we can override the default
- * behavior from subclasses for special URI types. */
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_if_fail (class->hovering_over_link != NULL);
-
- class->hovering_over_link (web_view, title, uri);
-}
-
-static gboolean
-web_view_navigation_policy_decision_requested_cb (EWebView *web_view,
- WebKitWebFrame *frame,
- WebKitNetworkRequest *request,
- WebKitWebNavigationAction *navigation_action,
- WebKitWebPolicyDecision *policy_decision)
-{
- EWebViewClass *class;
- WebKitWebNavigationReason reason;
- const gchar *uri;
-
- reason = webkit_web_navigation_action_get_reason (navigation_action);
- if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
- return FALSE;
-
- /* XXX WebKitWebView does not provide a class method for
- * this signal, so we do so we can override the default
- * behavior from subclasses for special URI types. */
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_val_if_fail (class->link_clicked != NULL, FALSE);
-
- webkit_web_policy_decision_ignore (policy_decision);
-
- uri = webkit_network_request_get_uri (request);
-
- class->link_clicked (web_view, uri);
-
- return TRUE;
-}
-
-static void
-web_view_load_status_changed_cb (WebKitWebView *webkit_web_view,
- GParamSpec *pspec,
- gpointer user_data)
-{
- WebKitLoadStatus status;
- EWebView *web_view;
-
- status = webkit_web_view_get_load_status (webkit_web_view);
- if (status != WEBKIT_LOAD_FINISHED)
- return;
-
- web_view = E_WEB_VIEW (webkit_web_view);
- web_view_update_document_highlights (web_view);
-
- /* Workaround webkit bug https://bugs.webkit.org/show_bug.cgi?id=89553 */
- e_web_view_zoom_in (web_view);
- e_web_view_zoom_out (web_view);
-}
-
-static void
-web_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CARET_MODE:
- e_web_view_set_caret_mode (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_CURSOR_IMAGE:
- e_web_view_set_cursor_image (
- E_WEB_VIEW (object),
- g_value_get_object (value));
- return;
-
- case PROP_CURSOR_IMAGE_SRC:
- e_web_view_set_cursor_image_src (
- E_WEB_VIEW (object),
- g_value_get_string (value));
- return;
-
- case PROP_DISABLE_PRINTING:
- e_web_view_set_disable_printing (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_DISABLE_SAVE_TO_DISK:
- e_web_view_set_disable_save_to_disk (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_INLINE_SPELLING:
- e_web_view_set_inline_spelling (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_MAGIC_LINKS:
- e_web_view_set_magic_links (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_MAGIC_SMILEYS:
- e_web_view_set_magic_smileys (
- E_WEB_VIEW (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_OPEN_PROXY:
- e_web_view_set_open_proxy (
- E_WEB_VIEW (object),
- g_value_get_object (value));
- return;
-
- case PROP_PRINT_PROXY:
- e_web_view_set_print_proxy (
- E_WEB_VIEW (object),
- g_value_get_object (value));
- return;
-
- case PROP_SAVE_AS_PROXY:
- e_web_view_set_save_as_proxy (
- E_WEB_VIEW (object),
- g_value_get_object (value));
- return;
-
- case PROP_SELECTED_URI:
- e_web_view_set_selected_uri (
- E_WEB_VIEW (object),
- g_value_get_string (value));
- return;
- }
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_CARET_MODE:
- g_value_set_boolean (
- value, e_web_view_get_caret_mode (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_CURSOR_IMAGE:
- g_value_set_object (
- value, e_web_view_get_cursor_image (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_CURSOR_IMAGE_SRC:
- g_value_set_string (
- value, e_web_view_get_cursor_image_src (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_DISABLE_PRINTING:
- g_value_set_boolean (
- value, e_web_view_get_disable_printing (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_DISABLE_SAVE_TO_DISK:
- g_value_set_boolean (
- value, e_web_view_get_disable_save_to_disk (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_INLINE_SPELLING:
- g_value_set_boolean (
- value, e_web_view_get_inline_spelling (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_MAGIC_LINKS:
- g_value_set_boolean (
- value, e_web_view_get_magic_links (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_MAGIC_SMILEYS:
- g_value_set_boolean (
- value, e_web_view_get_magic_smileys (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_OPEN_PROXY:
- g_value_set_object (
- value, e_web_view_get_open_proxy (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_PRINT_PROXY:
- g_value_set_object (
- value, e_web_view_get_print_proxy (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_SAVE_AS_PROXY:
- g_value_set_object (
- value, e_web_view_get_save_as_proxy (
- E_WEB_VIEW (object)));
- return;
-
- case PROP_SELECTED_URI:
- g_value_set_string (
- value, e_web_view_get_selected_uri (
- E_WEB_VIEW (object)));
- return;
-
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-web_view_dispose (GObject *object)
-{
- EWebViewPrivate *priv;
-
- priv = E_WEB_VIEW_GET_PRIVATE (object);
-
- if (priv->ui_manager != NULL) {
- g_object_unref (priv->ui_manager);
- priv->ui_manager = NULL;
- }
-
- if (priv->open_proxy != NULL) {
- g_object_unref (priv->open_proxy);
- priv->open_proxy = NULL;
- }
-
- if (priv->print_proxy != NULL) {
- g_object_unref (priv->print_proxy);
- priv->print_proxy = NULL;
- }
-
- if (priv->save_as_proxy != NULL) {
- g_object_unref (priv->save_as_proxy);
- priv->save_as_proxy = NULL;
- }
-
- if (priv->cursor_image != NULL) {
- g_object_unref (priv->cursor_image);
- priv->cursor_image = NULL;
- }
-
- if (priv->cursor_image_src != NULL) {
- g_free (priv->cursor_image_src);
- priv->cursor_image_src = NULL;
- }
-
- if (priv->highlights != NULL) {
- g_slist_free_full (priv->highlights, g_free);
- priv->highlights = NULL;
- }
-
- if (priv->aliasing_settings != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->aliasing_settings, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->aliasing_settings);
- priv->aliasing_settings = NULL;
- }
-
- if (priv->font_settings != NULL) {
- g_signal_handlers_disconnect_matched (
- priv->font_settings, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->font_settings);
- priv->font_settings = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_web_view_parent_class)->dispose (object);
-}
-
-static void
-web_view_finalize (GObject *object)
-{
- EWebViewPrivate *priv;
-
- priv = E_WEB_VIEW_GET_PRIVATE (object);
-
- /* All URI requests should be complete or cancelled by now. */
- if (priv->requests != NULL)
- g_warning ("Finalizing EWebView with active URI requests");
-
- g_free (priv->selected_uri);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_web_view_parent_class)->finalize (object);
-}
-
-static void
-web_view_constructed (GObject *object)
-{
-#ifndef G_OS_WIN32
- GSettings *settings;
-
- settings = g_settings_new ("org.gnome.desktop.lockdown");
-
- g_settings_bind (
- settings, "disable-printing",
- object, "disable-printing",
- G_SETTINGS_BIND_GET);
-
- g_settings_bind (
- settings, "disable-save-to-disk",
- object, "disable-save-to-disk",
- G_SETTINGS_BIND_GET);
-
- g_object_unref (settings);
-#endif
-
- e_extensible_load_extensions (E_EXTENSIBLE (object));
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (e_web_view_parent_class)->constructed (object);
-}
-
-static gboolean
-web_view_context_menu_cb (WebKitWebView *webkit_web_view,
- GtkWidget *default_menu,
- WebKitHitTestResult *hit_test_result,
- gboolean triggered_with_keyboard)
-{
- WebKitHitTestResultContext context;
- EWebView *web_view;
- gboolean event_handled = FALSE;
- gchar *uri;
-
- web_view = E_WEB_VIEW (webkit_web_view);
-
- if (web_view->priv->cursor_image != NULL) {
- g_object_unref (web_view->priv->cursor_image);
- web_view->priv->cursor_image = NULL;
- }
-
- if (web_view->priv->cursor_image_src != NULL) {
- g_free (web_view->priv->cursor_image_src);
- web_view->priv->cursor_image_src = NULL;
- }
-
- if (hit_test_result == NULL)
- return FALSE;
-
- g_object_get (G_OBJECT (hit_test_result), "context", &context, NULL);
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) {
- WebKitWebDataSource *data_source;
- WebKitWebFrame *frame;
- GList *subresources, *res;
-
- g_object_get (
- G_OBJECT (hit_test_result), "image-uri", &uri, NULL);
-
- if (uri == NULL)
- return FALSE;
-
- g_free (web_view->priv->cursor_image_src);
- web_view->priv->cursor_image_src = uri;
-
- /* Iterate through all resources of the loaded webpage and
- * try to find resource with URI matching cursor_image_src */
- frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- data_source = webkit_web_frame_get_data_source (frame);
- subresources = webkit_web_data_source_get_subresources (data_source);
- for (res = subresources; res; res = res->next) {
- WebKitWebResource *src = res->data;
- GdkPixbufLoader *loader;
- GString *data;
-
- if (g_strcmp0 (webkit_web_resource_get_uri (src),
- web_view->priv->cursor_image_src) != 0)
- continue;
-
- data = webkit_web_resource_get_data (src);
- if (data == NULL)
- break;
-
- loader = gdk_pixbuf_loader_new ();
- if (!gdk_pixbuf_loader_write (loader,
- (guchar *) data->str, data->len, NULL)) {
- g_object_unref (loader);
- break;
- }
- gdk_pixbuf_loader_close (loader, NULL);
-
- if (web_view->priv->cursor_image != NULL)
- g_object_unref (web_view->priv->cursor_image);
-
- web_view->priv->cursor_image =
- g_object_ref (gdk_pixbuf_loader_get_animation (loader));
-
- g_object_unref (loader);
- break;
- }
- g_list_free (subresources);
- }
-
- g_object_get (hit_test_result, "link-uri", &uri, NULL);
-
- if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)) {
- g_free (uri);
- uri = NULL;
- }
-
- g_signal_emit (web_view, signals[POPUP_EVENT], 0, uri, &event_handled);
-
- g_free (uri);
-
- return event_handled;
-}
-
-static gboolean
-web_view_scroll_event (GtkWidget *widget,
- GdkEventScroll *event)
-{
- if (event->state & GDK_CONTROL_MASK) {
- GdkScrollDirection direction = event->direction;
-
- if (direction == GDK_SCROLL_SMOOTH) {
- static gdouble total_delta_y = 0.0;
-
- total_delta_y += event->delta_y;
-
- if (total_delta_y >= 1.0) {
- total_delta_y = 0.0;
- direction = GDK_SCROLL_DOWN;
- } else if (total_delta_y <= -1.0) {
- total_delta_y = 0.0;
- direction = GDK_SCROLL_UP;
- } else {
- return FALSE;
- }
- }
-
- switch (direction) {
- case GDK_SCROLL_UP:
- e_web_view_zoom_in (E_WEB_VIEW (widget));
- return TRUE;
- case GDK_SCROLL_DOWN:
- e_web_view_zoom_out (E_WEB_VIEW (widget));
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static GtkWidget *
-web_view_create_plugin_widget (EWebView *web_view,
- const gchar *mime_type,
- const gchar *uri,
- GHashTable *param)
-{
- GtkWidget *widget = NULL;
-
- if (g_strcmp0 (mime_type, "image/x-themed-icon") == 0) {
- GtkIconTheme *icon_theme;
- GdkPixbuf *pixbuf;
- gpointer data;
- glong size = 0;
- GError *error = NULL;
-
- icon_theme = gtk_icon_theme_get_default ();
-
- if (size == 0) {
- data = g_hash_table_lookup (param, "width");
- if (data != NULL)
- size = MAX (size, strtol (data, NULL, 10));
- }
-
- if (size == 0) {
- data = g_hash_table_lookup (param, "height");
- if (data != NULL)
- size = MAX (size, strtol (data, NULL, 10));
- }
-
- if (size == 0)
- size = 32; /* arbitrary default */
-
- pixbuf = gtk_icon_theme_load_icon (
- icon_theme, uri, size, 0, &error);
- if (pixbuf != NULL) {
- widget = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
- } else if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- }
-
- return widget;
-}
-
-static gchar *
-web_view_extract_uri (EWebView *web_view,
- GdkEventButton *event)
-{
- WebKitHitTestResult *result;
- WebKitHitTestResultContext context;
- gchar *uri = NULL;
-
- result = webkit_web_view_get_hit_test_result (
- WEBKIT_WEB_VIEW (web_view), event);
-
- g_object_get (result, "context", &context, "link-uri", &uri, NULL);
- g_object_unref (result);
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- return uri;
-
- g_free (uri);
-
- return NULL;
-}
-
-static void
-web_view_hovering_over_link (EWebView *web_view,
- const gchar *title,
- const gchar *uri)
-{
- CamelInternetAddress *address;
- CamelURL *curl;
- const gchar *format = NULL;
- gchar *message = NULL;
- gchar *who;
-
- if (uri == NULL || *uri == '\0')
- goto exit;
-
- if (g_str_has_prefix (uri, "mailto:"))
- format = _("Click to mail %s");
- else if (g_str_has_prefix (uri, "callto:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "h323:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "sip:"))
- format = _("Click to call %s");
- else if (g_str_has_prefix (uri, "##"))
- message = g_strdup (_("Click to hide/unhide addresses"));
- else
- message = g_strdup_printf (_("Click to open %s"), uri);
-
- if (format == NULL)
- goto exit;
-
- /* XXX Use something other than Camel here. Surely
- * there's other APIs around that can do this. */
- curl = camel_url_new (uri, NULL);
- address = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (address), curl->path);
- who = camel_address_format (CAMEL_ADDRESS (address));
- g_object_unref (address);
- camel_url_free (curl);
-
- if (who == NULL)
- who = g_strdup (strchr (uri, ':') + 1);
-
- message = g_strdup_printf (format, who);
-
- g_free (who);
-
-exit:
- e_web_view_status_message (web_view, message);
-
- g_free (message);
-}
-
-static void
-web_view_link_clicked (EWebView *web_view,
- const gchar *uri)
-{
- gpointer parent;
-
- if (uri && g_ascii_strncasecmp (uri, "mailto:", 7) == 0) {
- gboolean handled = FALSE;
-
- g_signal_emit (
- web_view, signals[PROCESS_MAILTO], 0, uri, &handled);
-
- if (handled)
- return;
- }
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- e_show_uri (parent, uri);
-}
-
-static void
-web_view_load_string (EWebView *web_view,
- const gchar *string)
-{
- if (string == NULL)
- string = "";
-
- webkit_web_view_load_string (
- WEBKIT_WEB_VIEW (web_view),
- string, "text/html", "UTF-8", "evo-file:///");
-}
-
-static void
-web_view_load_uri (EWebView *web_view,
- const gchar *uri)
-{
- if (uri == NULL)
- uri = "about:blank";
-
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
-}
-
-static void
-web_view_frame_load_string (EWebView *web_view,
- const gchar *frame_name,
- const gchar *string)
-{
- WebKitWebFrame *main_frame;
-
- if (string == NULL)
- string = "";
-
- main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- if (main_frame != NULL) {
- WebKitWebFrame *frame;
-
- frame = webkit_web_frame_find_frame (main_frame, frame_name);
-
- if (frame != NULL)
- webkit_web_frame_load_string (
- frame, string, "text/html",
- "UTF-8", "evo-file:///");
- }
-}
-
-static void
-web_view_frame_load_uri (EWebView *web_view,
- const gchar *frame_name,
- const gchar *uri)
-{
- WebKitWebFrame *main_frame;
-
- if (uri == NULL)
- uri = "about:blank";
-
- main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- if (main_frame != NULL) {
- WebKitWebFrame *frame;
-
- frame = webkit_web_frame_find_frame (main_frame, frame_name);
-
- if (frame != NULL)
- webkit_web_frame_load_uri (frame, uri);
- }
-}
-
-static gboolean
-web_view_popup_event (EWebView *web_view,
- const gchar *uri)
-{
- e_web_view_set_selected_uri (web_view, uri);
- e_web_view_show_popup_menu (web_view);
-
- return TRUE;
-}
-
-static void
-web_view_stop_loading (EWebView *web_view)
-{
- webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (web_view));
-}
-
-static void
-web_view_update_actions (EWebView *web_view)
-{
- GtkActionGroup *action_group;
- gboolean can_copy;
- gboolean scheme_is_http = FALSE;
- gboolean scheme_is_mailto = FALSE;
- gboolean uri_is_valid = FALSE;
- gboolean has_cursor_image;
- gboolean visible;
- const gchar *group_name;
- const gchar *uri;
-
- uri = e_web_view_get_selected_uri (web_view);
- can_copy = webkit_web_view_can_copy_clipboard (WEBKIT_WEB_VIEW (web_view));
- has_cursor_image = e_web_view_get_cursor_image_src (web_view) ||
- e_web_view_get_cursor_image (web_view);
-
- /* Parse the URI early so we know if the actions will work. */
- if (uri != NULL) {
- CamelURL *curl;
-
- curl = camel_url_new (uri, NULL);
- uri_is_valid = (curl != NULL);
- camel_url_free (curl);
-
- scheme_is_http =
- (g_ascii_strncasecmp (uri, "http:", 5) == 0) ||
- (g_ascii_strncasecmp (uri, "https:", 6) == 0);
-
- scheme_is_mailto =
- (g_ascii_strncasecmp (uri, "mailto:", 7) == 0);
- }
-
- /* Allow copying the URI even if it's malformed. */
- group_name = "uri";
- visible = (uri != NULL) && !scheme_is_mailto;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "http";
- visible = uri_is_valid && scheme_is_http;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "mailto";
- visible = uri_is_valid && scheme_is_mailto;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "image";
- visible = has_cursor_image;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "selection";
- visible = can_copy;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "standard";
- visible = (uri == NULL);
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "lockdown-printing";
- visible = (uri == NULL) && !web_view->priv->disable_printing;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-
- group_name = "lockdown-save-to-disk";
- visible = (uri == NULL) && !web_view->priv->disable_save_to_disk;
- action_group = e_web_view_get_action_group (web_view, group_name);
- gtk_action_group_set_visible (action_group, visible);
-}
-
-static void
-web_view_submit_alert (EAlertSink *alert_sink,
- EAlert *alert)
-{
- EWebView *web_view;
- GtkWidget *dialog;
- GString *buffer;
- const gchar *icon_name = NULL;
- gpointer parent;
-
- web_view = E_WEB_VIEW (alert_sink);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- switch (e_alert_get_message_type (alert)) {
- case GTK_MESSAGE_INFO:
- icon_name = GTK_STOCK_DIALOG_INFO;
- break;
-
- case GTK_MESSAGE_WARNING:
- icon_name = GTK_STOCK_DIALOG_WARNING;
- break;
-
- case GTK_MESSAGE_ERROR:
- icon_name = GTK_STOCK_DIALOG_ERROR;
- break;
-
- default:
- dialog = e_alert_dialog_new (parent, alert);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return;
- }
-
- buffer = g_string_sized_new (512);
-
- g_string_append (
- buffer,
- "<html>"
- "<head>"
- "<meta http-equiv=\"content-type\""
- " content=\"text/html; charset=utf-8\">"
- "</head>"
- "<body>");
-
- g_string_append (
- buffer,
- "<table bgcolor='#000000' width='100%'"
- " cellpadding='1' cellspacing='0'>"
- "<tr>"
- "<td>"
- "<table bgcolor='#dddddd' width='100%' cellpadding='6'>"
- "<tr>");
-
- g_string_append_printf (
- buffer,
- "<tr>"
- "<td valign='top'>"
- "<img src='gtk-stock://%s/?size=%d'/>"
- "</td>"
- "<td align='left' width='100%%'>"
- "<h3>%s</h3>"
- "%s"
- "</td>"
- "</tr>",
- icon_name,
- GTK_ICON_SIZE_DIALOG,
- e_alert_get_primary_text (alert),
- e_alert_get_secondary_text (alert));
-
- g_string_append (
- buffer,
- "</table>"
- "</td>"
- "</tr>"
- "</table>"
- "</body>"
- "</html>");
-
- e_web_view_load_string (web_view, buffer->str);
-
- g_string_free (buffer, TRUE);
-}
-
-static void
-web_view_selectable_update_actions (ESelectable *selectable,
- EFocusTracker *focus_tracker,
- GdkAtom *clipboard_targets,
- gint n_clipboard_targets)
-{
- WebKitWebView *web_view;
- GtkAction *action;
- gboolean sensitive;
- const gchar *tooltip;
-
- web_view = WEBKIT_WEB_VIEW (selectable);
-
- action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
- sensitive = webkit_web_view_can_cut_clipboard (web_view);
- tooltip = _("Cut the selection");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
- sensitive = webkit_web_view_can_copy_clipboard (web_view);
- tooltip = _("Copy the selection");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
- sensitive = webkit_web_view_can_paste_clipboard (web_view);
- tooltip = _("Paste the clipboard");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-
- action = e_focus_tracker_get_select_all_action (focus_tracker);
- sensitive = TRUE;
- tooltip = _("Select all text and images");
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_tooltip (action, tooltip);
-}
-
-static void
-web_view_selectable_cut_clipboard (ESelectable *selectable)
-{
- e_web_view_cut_clipboard (E_WEB_VIEW (selectable));
-}
-
-static void
-web_view_selectable_copy_clipboard (ESelectable *selectable)
-{
- e_web_view_copy_clipboard (E_WEB_VIEW (selectable));
-}
-
-static void
-web_view_selectable_paste_clipboard (ESelectable *selectable)
-{
- e_web_view_paste_clipboard (E_WEB_VIEW (selectable));
-}
-
-static void
-web_view_selectable_select_all (ESelectable *selectable)
-{
- e_web_view_select_all (E_WEB_VIEW (selectable));
-}
-
-static gboolean
-web_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time_)
-{
- return FALSE;
-}
-
-static void
-e_web_view_class_init (EWebViewClass *class)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- g_type_class_add_private (class, sizeof (EWebViewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = web_view_set_property;
- object_class->get_property = web_view_get_property;
- object_class->dispose = web_view_dispose;
- object_class->finalize = web_view_finalize;
- object_class->constructed = web_view_constructed;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->scroll_event = web_view_scroll_event;
- widget_class->drag_motion = web_view_drag_motion;
-
-#if 0 /* WEBKIT */
- html_class = GTK_HTML_CLASS (class);
- html_class->url_requested = web_view_url_requested;
-#endif
-
- class->create_plugin_widget = web_view_create_plugin_widget;
- class->extract_uri = web_view_extract_uri;
- class->hovering_over_link = web_view_hovering_over_link;
- class->link_clicked = web_view_link_clicked;
- class->load_string = web_view_load_string;
- class->load_uri = web_view_load_uri;
- class->frame_load_string = web_view_frame_load_string;
- class->frame_load_uri = web_view_frame_load_uri;
- class->popup_event = web_view_popup_event;
- class->stop_loading = web_view_stop_loading;
- class->update_actions = web_view_update_actions;
-
- g_object_class_install_property (
- object_class,
- PROP_CARET_MODE,
- g_param_spec_boolean (
- "caret-mode",
- "Caret Mode",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_IMAGE,
- g_param_spec_object (
- "cursor-image",
- "Image animation at the mouse cursor",
- NULL,
- GDK_TYPE_PIXBUF_ANIMATION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_CURSOR_IMAGE_SRC,
- g_param_spec_string (
- "cursor-image-src",
- "Image source uri at the mouse cursor",
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_DISABLE_PRINTING,
- g_param_spec_boolean (
- "disable-printing",
- "Disable Printing",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_DISABLE_SAVE_TO_DISK,
- g_param_spec_boolean (
- "disable-save-to-disk",
- "Disable Save-to-Disk",
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_INLINE_SPELLING,
- g_param_spec_boolean (
- "inline-spelling",
- "Inline Spelling",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_LINKS,
- g_param_spec_boolean (
- "magic-links",
- "Magic Links",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_SMILEYS,
- g_param_spec_boolean (
- "magic-smileys",
- "Magic Smileys",
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_OPEN_PROXY,
- g_param_spec_object (
- "open-proxy",
- "Open Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_PRINT_PROXY,
- g_param_spec_object (
- "print-proxy",
- "Print Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SAVE_AS_PROXY,
- g_param_spec_object (
- "save-as-proxy",
- "Save As Proxy",
- NULL,
- GTK_TYPE_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SELECTED_URI,
- g_param_spec_string (
- "selected-uri",
- "Selected URI",
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- signals[POPUP_EVENT] = g_signal_new (
- "popup-event",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewClass, popup_event),
- g_signal_accumulator_true_handled, NULL,
- e_marshal_BOOLEAN__STRING,
- G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
-
- signals[STATUS_MESSAGE] = g_signal_new (
- "status-message",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewClass, status_message),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- signals[STOP_LOADING] = g_signal_new (
- "stop-loading",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewClass, stop_loading),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[UPDATE_ACTIONS] = g_signal_new (
- "update-actions",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewClass, update_actions),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /* return TRUE when a signal handler processed the mailto URI */
- signals[PROCESS_MAILTO] = g_signal_new (
- "process-mailto",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EWebViewClass, process_mailto),
- NULL, NULL,
- e_marshal_BOOLEAN__STRING,
- G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
-}
-
-static void
-e_web_view_alert_sink_init (EAlertSinkInterface *interface)
-{
- interface->submit_alert = web_view_submit_alert;
-}
-
-static void
-e_web_view_selectable_init (ESelectableInterface *interface)
-{
- interface->update_actions = web_view_selectable_update_actions;
- interface->cut_clipboard = web_view_selectable_cut_clipboard;
- interface->copy_clipboard = web_view_selectable_copy_clipboard;
- interface->paste_clipboard = web_view_selectable_paste_clipboard;
- interface->select_all = web_view_selectable_select_all;
-}
-
-static void
-e_web_view_init (EWebView *web_view)
-{
- GtkUIManager *ui_manager;
- GtkActionGroup *action_group;
- EPopupAction *popup_action;
- WebKitWebSettings *web_settings;
- GSettingsSchema *settings_schema;
- GSettings *settings;
- const gchar *domain = GETTEXT_PACKAGE;
- const gchar *id;
- GError *error = NULL;
-
- web_view->priv = E_WEB_VIEW_GET_PRIVATE (web_view);
-
- web_view->priv->highlights = NULL;
-
- g_signal_connect (
- web_view, "create-plugin-widget",
- G_CALLBACK (web_view_create_plugin_widget_cb), NULL);
-
- g_signal_connect (
- web_view, "hovering-over-link",
- G_CALLBACK (web_view_hovering_over_link_cb), NULL);
-
- g_signal_connect (
- web_view, "navigation-policy-decision-requested",
- G_CALLBACK (web_view_navigation_policy_decision_requested_cb),
- NULL);
-
- g_signal_connect (
- web_view, "new-window-policy-decision-requested",
- G_CALLBACK (web_view_navigation_policy_decision_requested_cb),
- NULL);
-
- g_signal_connect (
- web_view, "context-menu",
- G_CALLBACK (web_view_context_menu_cb), NULL);
-
- g_signal_connect (
- web_view, "notify::load-status",
- G_CALLBACK (web_view_load_status_changed_cb), NULL);
-
- ui_manager = gtk_ui_manager_new ();
- web_view->priv->ui_manager = ui_manager;
-
- g_signal_connect_swapped (
- ui_manager, "connect-proxy",
- G_CALLBACK (web_view_connect_proxy_cb), web_view);
-
- web_settings = e_web_view_get_default_settings ();
- e_web_view_set_settings (web_view, web_settings);
- g_object_unref (web_settings);
-
- e_web_view_install_request_handler (web_view, E_TYPE_FILE_REQUEST);
- e_web_view_install_request_handler (web_view, E_TYPE_STOCK_REQUEST);
-
- settings = g_settings_new ("org.gnome.desktop.interface");
- g_signal_connect_swapped (
- settings, "changed::font-name",
- G_CALLBACK (e_web_view_update_fonts), web_view);
- g_signal_connect_swapped (
- settings, "changed::monospace-font-name",
- G_CALLBACK (e_web_view_update_fonts), web_view);
- web_view->priv->font_settings = settings;
-
- /* This schema is optional. Use if available. */
- id = "org.gnome.settings-daemon.plugins.xsettings";
- settings_schema = g_settings_schema_source_lookup (
- g_settings_schema_source_get_default (), id, FALSE);
- if (settings_schema != NULL) {
- settings = g_settings_new (id);
- g_signal_connect_swapped (
- settings, "changed::antialiasing",
- G_CALLBACK (e_web_view_update_fonts), web_view);
- web_view->priv->aliasing_settings = settings;
- }
-
- e_web_view_update_fonts (web_view);
-
- action_group = gtk_action_group_new ("uri");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, uri_entries,
- G_N_ELEMENTS (uri_entries), web_view);
-
- action_group = gtk_action_group_new ("http");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, http_entries,
- G_N_ELEMENTS (http_entries), web_view);
-
- action_group = gtk_action_group_new ("mailto");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, mailto_entries,
- G_N_ELEMENTS (mailto_entries), web_view);
-
- action_group = gtk_action_group_new ("image");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, image_entries,
- G_N_ELEMENTS (image_entries), web_view);
-
- action_group = gtk_action_group_new ("selection");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, selection_entries,
- G_N_ELEMENTS (selection_entries), web_view);
-
- action_group = gtk_action_group_new ("standard");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), web_view);
-
- popup_action = e_popup_action_new ("open");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "open-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Support lockdown. */
-
- action_group = gtk_action_group_new ("lockdown-printing");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- popup_action = e_popup_action_new ("print");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "print-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- action_group = gtk_action_group_new ("lockdown-save-to-disk");
- gtk_action_group_set_translation_domain (action_group, domain);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- popup_action = e_popup_action_new ("save-as");
- gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
- g_object_unref (popup_action);
-
- g_object_bind_property (
- web_view, "save-as-proxy",
- popup_action, "related-action",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- /* Because we are loading from a hard-coded string, there is
- * no chance of I/O errors. Failure here implies a malformed
- * UI definition. Full stop. */
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- if (error != NULL)
- g_error ("%s", error->message);
-
- id = "org.gnome.evolution.webview";
- e_plugin_ui_register_manager (ui_manager, id, web_view);
- e_plugin_ui_enable_manager (ui_manager, id);
-}
-
-GtkWidget *
-e_web_view_new (void)
-{
- return g_object_new (E_TYPE_WEB_VIEW, NULL);
-}
-
-void
-e_web_view_clear (EWebView *web_view)
-{
- GtkStyle *style;
- gchar *html;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- style = gtk_widget_get_style (GTK_WIDGET (web_view));
-
- html = g_strdup_printf (
- "<html><head></head><body bgcolor=\"#%06x\"></body></html>",
- e_color_to_value (&style->base[GTK_STATE_NORMAL]));
-
- webkit_web_view_load_html_string (
- WEBKIT_WEB_VIEW (web_view), html, NULL);
-
- g_free (html);
-}
-
-void
-e_web_view_load_string (EWebView *web_view,
- const gchar *string)
-{
- EWebViewClass *class;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_if_fail (class->load_string != NULL);
-
- class->load_string (web_view, string);
-}
-
-void
-e_web_view_load_uri (EWebView *web_view,
- const gchar *uri)
-{
- EWebViewClass *class;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_if_fail (class->load_uri != NULL);
-
- class->load_uri (web_view, uri);
-}
-
-void
-e_web_view_reload (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_reload (WEBKIT_WEB_VIEW (web_view));
-}
-
-const gchar *
-e_web_view_get_uri (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_frame_load_string (EWebView *web_view,
- const gchar *frame_name,
- const gchar *string)
-{
- EWebViewClass *class;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_return_if_fail (frame_name != NULL);
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_if_fail (class->frame_load_string != NULL);
-
- class->frame_load_string (web_view, frame_name, string);
-}
-
-void
-e_web_view_frame_load_uri (EWebView *web_view,
- const gchar *frame_name,
- const gchar *uri)
-{
- EWebViewClass *class;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_return_if_fail (frame_name != NULL);
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_if_fail (class->frame_load_uri != NULL);
-
- class->frame_load_uri (web_view, frame_name, uri);
-}
-
-const gchar *
-e_web_view_frame_get_uri (EWebView *web_view,
- const gchar *frame_name)
-{
- WebKitWebFrame *main_frame;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
- g_return_val_if_fail (frame_name != NULL, NULL);
-
- main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- if (main_frame != NULL) {
- WebKitWebFrame *frame;
-
- frame = webkit_web_frame_find_frame (main_frame, frame_name);
-
- if (frame != NULL)
- return webkit_web_frame_get_uri (frame);
- }
-
- return NULL;
-}
-
-gchar *
-e_web_view_get_html (EWebView *web_view)
-{
- WebKitDOMDocument *document;
- WebKitDOMElement *element;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
- element = webkit_dom_document_get_document_element (document);
-
- return webkit_dom_html_element_get_outer_html (
- WEBKIT_DOM_HTML_ELEMENT (element));
-}
-
-gboolean
-e_web_view_get_caret_mode (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->caret_mode;
-}
-
-void
-e_web_view_set_caret_mode (EWebView *web_view,
- gboolean caret_mode)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->caret_mode == caret_mode)
- return;
-
- web_view->priv->caret_mode = caret_mode;
-
- g_object_notify (G_OBJECT (web_view), "caret-mode");
-}
-
-GtkTargetList *
-e_web_view_get_copy_target_list (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return webkit_web_view_get_copy_target_list (
- WEBKIT_WEB_VIEW (web_view));
-}
-
-gboolean
-e_web_view_get_disable_printing (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->disable_printing;
-}
-
-void
-e_web_view_set_disable_printing (EWebView *web_view,
- gboolean disable_printing)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->disable_printing == disable_printing)
- return;
-
- web_view->priv->disable_printing = disable_printing;
-
- g_object_notify (G_OBJECT (web_view), "disable-printing");
-}
-
-gboolean
-e_web_view_get_disable_save_to_disk (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->disable_save_to_disk;
-}
-
-void
-e_web_view_set_disable_save_to_disk (EWebView *web_view,
- gboolean disable_save_to_disk)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->disable_save_to_disk == disable_save_to_disk)
- return;
-
- web_view->priv->disable_save_to_disk = disable_save_to_disk;
-
- g_object_notify (G_OBJECT (web_view), "disable-save-to-disk");
-}
-
-gboolean
-e_web_view_get_enable_frame_flattening (EWebView *web_view)
-{
- WebKitWebSettings *settings;
- gboolean flattening;
-
- /* Return TRUE with fail since it's default value we set in _init(). */
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), TRUE);
-
- settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
- g_return_val_if_fail (settings != NULL, TRUE);
-
- g_object_get (
- G_OBJECT (settings),
- "enable-frame-flattening", &flattening, NULL);
-
- return flattening;
-}
-
-void
-e_web_view_set_enable_frame_flattening (EWebView *web_view,
- gboolean enable_frame_flattening)
-{
- WebKitWebSettings *settings;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
- g_return_if_fail (settings != NULL);
-
- g_object_set (
- G_OBJECT (settings), "enable-frame-flattening",
- enable_frame_flattening, NULL);
-}
-
-gboolean
-e_web_view_get_editable (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return webkit_web_view_get_editable (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_set_editable (EWebView *web_view,
- gboolean editable)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_set_editable (WEBKIT_WEB_VIEW (web_view), editable);
-}
-
-gboolean
-e_web_view_get_inline_spelling (EWebView *web_view)
-{
-#if 0 /* WEBKIT - XXX No equivalent property? */
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_inline_spelling(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return gtk_html_get_inline_spelling (GTK_HTML (web_view));
-#endif
-
- return FALSE;
-}
-
-void
-e_web_view_set_inline_spelling (EWebView *web_view,
- gboolean inline_spelling)
-{
-#if 0 /* WEBKIT - XXX No equivalent property? */
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_inline_spelling()
- * so we get a "notify::inline-spelling" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- gtk_html_set_inline_spelling (GTK_HTML (web_view), inline_spelling);
-
- g_object_notify (G_OBJECT (web_view), "inline-spelling");
-#endif
-}
-
-gboolean
-e_web_view_get_magic_links (EWebView *web_view)
-{
-#if 0 /* WEBKIT - XXX No equivalent property? */
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_magic_links(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return gtk_html_get_magic_links (GTK_HTML (web_view));
-#endif
-
- return FALSE;
-}
-
-void
-e_web_view_set_magic_links (EWebView *web_view,
- gboolean magic_links)
-{
-#if 0 /* WEBKIT - XXX No equivalent property? */
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_magic_links()
- * so we can get a "notify::magic-links" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- gtk_html_set_magic_links (GTK_HTML (web_view), magic_links);
-
- g_object_notify (G_OBJECT (web_view), "magic-links");
-#endif
-}
-
-gboolean
-e_web_view_get_magic_smileys (EWebView *web_view)
-{
-#if 0 /* WEBKIT - No equivalent property? */
- /* XXX This is just here to maintain symmetry
- * with e_web_view_set_magic_smileys(). */
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return gtk_html_get_magic_smileys (GTK_HTML (web_view));
-#endif
-
- return FALSE;
-}
-
-void
-e_web_view_set_magic_smileys (EWebView *web_view,
- gboolean magic_smileys)
-{
-#if 0 /* WEBKIT - No equivalent property? */
- /* XXX GtkHTML does not utilize GObject properties as well
- * as it could. This just wraps gtk_html_set_magic_smileys()
- * so we can get a "notify::magic-smileys" signal. */
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- gtk_html_set_magic_smileys (GTK_HTML (web_view), magic_smileys);
-
- g_object_notify (G_OBJECT (web_view), "magic-smileys");
-#endif
-}
-
-const gchar *
-e_web_view_get_selected_uri (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return web_view->priv->selected_uri;
-}
-
-void
-e_web_view_set_selected_uri (EWebView *web_view,
- const gchar *selected_uri)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (g_strcmp0 (web_view->priv->selected_uri, selected_uri) == 0)
- return;
-
- g_free (web_view->priv->selected_uri);
- web_view->priv->selected_uri = g_strdup (selected_uri);
-
- g_object_notify (G_OBJECT (web_view), "selected-uri");
-}
-
-GdkPixbufAnimation *
-e_web_view_get_cursor_image (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return web_view->priv->cursor_image;
-}
-
-void
-e_web_view_set_cursor_image (EWebView *web_view,
- GdkPixbufAnimation *image)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->cursor_image == image)
- return;
-
- if (image != NULL)
- g_object_ref (image);
-
- if (web_view->priv->cursor_image != NULL)
- g_object_unref (web_view->priv->cursor_image);
-
- web_view->priv->cursor_image = image;
-
- g_object_notify (G_OBJECT (web_view), "cursor-image");
-}
-
-const gchar *
-e_web_view_get_cursor_image_src (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return web_view->priv->cursor_image_src;
-}
-
-void
-e_web_view_set_cursor_image_src (EWebView *web_view,
- const gchar *src_uri)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (g_strcmp0 (web_view->priv->cursor_image_src, src_uri) == 0)
- return;
-
- g_free (web_view->priv->cursor_image_src);
- web_view->priv->cursor_image_src = g_strdup (src_uri);
-
- g_object_notify (G_OBJECT (web_view), "cursor-image-src");
-}
-
-GtkAction *
-e_web_view_get_open_proxy (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->open_proxy;
-}
-
-void
-e_web_view_set_open_proxy (EWebView *web_view,
- GtkAction *open_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->open_proxy == open_proxy)
- return;
-
- if (open_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (open_proxy));
- g_object_ref (open_proxy);
- }
-
- if (web_view->priv->open_proxy != NULL)
- g_object_unref (web_view->priv->open_proxy);
-
- web_view->priv->open_proxy = open_proxy;
-
- g_object_notify (G_OBJECT (web_view), "open-proxy");
-}
-
-GtkTargetList *
-e_web_view_get_paste_target_list (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return webkit_web_view_get_paste_target_list (
- WEBKIT_WEB_VIEW (web_view));
-}
-
-GtkAction *
-e_web_view_get_print_proxy (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->print_proxy;
-}
-
-void
-e_web_view_set_print_proxy (EWebView *web_view,
- GtkAction *print_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->print_proxy == print_proxy)
- return;
-
- if (print_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (print_proxy));
- g_object_ref (print_proxy);
- }
-
- if (web_view->priv->print_proxy != NULL)
- g_object_unref (web_view->priv->print_proxy);
-
- web_view->priv->print_proxy = print_proxy;
-
- g_object_notify (G_OBJECT (web_view), "print-proxy");
-}
-
-GtkAction *
-e_web_view_get_save_as_proxy (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return web_view->priv->save_as_proxy;
-}
-
-void
-e_web_view_set_save_as_proxy (EWebView *web_view,
- GtkAction *save_as_proxy)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (web_view->priv->save_as_proxy == save_as_proxy)
- return;
-
- if (save_as_proxy != NULL) {
- g_return_if_fail (GTK_IS_ACTION (save_as_proxy));
- g_object_ref (save_as_proxy);
- }
-
- if (web_view->priv->save_as_proxy != NULL)
- g_object_unref (web_view->priv->save_as_proxy);
-
- web_view->priv->save_as_proxy = save_as_proxy;
-
- g_object_notify (G_OBJECT (web_view), "save-as-proxy");
-}
-
-GSList *
-e_web_view_get_highlights (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return web_view->priv->highlights;
-}
-
-void
-e_web_view_add_highlight (EWebView *web_view,
- const gchar *highlight)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_return_if_fail (highlight && *highlight);
-
- web_view->priv->highlights = g_slist_append (
- web_view->priv->highlights, g_strdup (highlight));
-
- web_view_update_document_highlights (web_view);
-}
-
-void e_web_view_clear_highlights (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (!web_view->priv->highlights)
- return;
-
- g_slist_free_full (web_view->priv->highlights, g_free);
- web_view->priv->highlights = NULL;
-
- web_view_update_document_highlights (web_view);
-}
-
-GtkAction *
-e_web_view_get_action (EWebView *web_view,
- const gchar *action_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
- g_return_val_if_fail (action_name != NULL, NULL);
-
- ui_manager = e_web_view_get_ui_manager (web_view);
-
- return e_lookup_action (ui_manager, action_name);
-}
-
-GtkActionGroup *
-e_web_view_get_action_group (EWebView *web_view,
- const gchar *group_name)
-{
- GtkUIManager *ui_manager;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
- g_return_val_if_fail (group_name != NULL, NULL);
-
- ui_manager = e_web_view_get_ui_manager (web_view);
-
- return e_lookup_action_group (ui_manager, group_name);
-}
-
-gchar *
-e_web_view_extract_uri (EWebView *web_view,
- GdkEventButton *event)
-{
- EWebViewClass *class;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- g_return_val_if_fail (class->extract_uri != NULL, NULL);
-
- return class->extract_uri (web_view, event);
-}
-
-void
-e_web_view_copy_clipboard (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_cut_clipboard (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_cut_clipboard (WEBKIT_WEB_VIEW (web_view));
-}
-
-gboolean
-e_web_view_is_selection_active (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- return webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_paste_clipboard (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_paste_clipboard (WEBKIT_WEB_VIEW (web_view));
-}
-
-gboolean
-e_web_view_scroll_forward (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- webkit_web_view_move_cursor (
- WEBKIT_WEB_VIEW (web_view), GTK_MOVEMENT_PAGES, 1);
-
- return TRUE; /* XXX This means nothing. */
-}
-
-gboolean
-e_web_view_scroll_backward (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
-
- webkit_web_view_move_cursor (
- WEBKIT_WEB_VIEW (web_view), GTK_MOVEMENT_PAGES, -1);
-
- return TRUE; /* XXX This means nothing. */
-}
-
-void
-e_web_view_select_all (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_select_all (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_unselect_all (EWebView *web_view)
-{
-#if 0 /* WEBKIT */
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- gtk_html_command (GTK_HTML (web_view), "unselect-all");
-#endif
-}
-
-void
-e_web_view_zoom_100 (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (web_view), 1.0);
-}
-
-void
-e_web_view_zoom_in (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_zoom_in (WEBKIT_WEB_VIEW (web_view));
-}
-
-void
-e_web_view_zoom_out (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- webkit_web_view_zoom_out (WEBKIT_WEB_VIEW (web_view));
-}
-
-GtkUIManager *
-e_web_view_get_ui_manager (EWebView *web_view)
-{
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- return web_view->priv->ui_manager;
-}
-
-GtkWidget *
-e_web_view_get_popup_menu (EWebView *web_view)
-{
- GtkUIManager *ui_manager;
- GtkWidget *menu;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- ui_manager = e_web_view_get_ui_manager (web_view);
- menu = gtk_ui_manager_get_widget (ui_manager, "/context");
- g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
-
- return menu;
-}
-
-void
-e_web_view_show_popup_menu (EWebView *web_view)
-{
- GtkWidget *menu;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- e_web_view_update_actions (web_view);
-
- menu = e_web_view_get_popup_menu (web_view);
-
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, NULL, NULL,
- 0, gtk_get_current_event_time ());
-}
-
-void
-e_web_view_status_message (EWebView *web_view,
- const gchar *status_message)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- g_signal_emit (web_view, signals[STATUS_MESSAGE], 0, status_message);
-}
-
-void
-e_web_view_stop_loading (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- g_signal_emit (web_view, signals[STOP_LOADING], 0);
-}
-
-void
-e_web_view_update_actions (EWebView *web_view)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
-}
-
-static gchar *
-web_view_get_frame_selection_html (WebKitDOMElement *iframe)
-{
- WebKitDOMDocument *document;
- WebKitDOMDOMWindow *window;
- WebKitDOMDOMSelection *selection;
- WebKitDOMNodeList *frames;
- gulong ii, length;
-
- document = webkit_dom_html_iframe_element_get_content_document (
- WEBKIT_DOM_HTML_IFRAME_ELEMENT (iframe));
- window = webkit_dom_document_get_default_view (document);
- selection = webkit_dom_dom_window_get_selection (window);
- if (selection && (webkit_dom_dom_selection_get_range_count (selection) > 0)) {
- WebKitDOMRange *range;
- WebKitDOMElement *element;
- WebKitDOMDocumentFragment *fragment;
-
- range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
- if (range != NULL) {
- fragment = webkit_dom_range_clone_contents (
- range, NULL);
-
- element = webkit_dom_document_create_element (
- document, "DIV", NULL);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (element),
- WEBKIT_DOM_NODE (fragment), NULL);
-
- return webkit_dom_html_element_get_inner_html (
- WEBKIT_DOM_HTML_ELEMENT (element));
- }
- }
-
- frames = webkit_dom_document_get_elements_by_tag_name (
- document, "IFRAME");
- length = webkit_dom_node_list_get_length (frames);
- for (ii = 0; ii < length; ii++) {
- WebKitDOMNode *node;
- gchar *text;
-
- node = webkit_dom_node_list_item (frames, ii);
-
- text = web_view_get_frame_selection_html (
- WEBKIT_DOM_ELEMENT (node));
-
- if (text != NULL)
- return text;
- }
-
- return NULL;
-}
-
-gchar *
-e_web_view_get_selection_html (EWebView *web_view)
-{
- WebKitDOMDocument *document;
- WebKitDOMNodeList *frames;
- gulong ii, length;
-
- g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
-
- if (!webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
- return NULL;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
- frames = webkit_dom_document_get_elements_by_tag_name (document, "IFRAME");
- length = webkit_dom_node_list_get_length (frames);
-
- for (ii = 0; ii < length; ii++) {
- gchar *text;
- WebKitDOMNode *node;
-
- node = webkit_dom_node_list_item (frames, ii);
-
- text = web_view_get_frame_selection_html (
- WEBKIT_DOM_ELEMENT (node));
-
- if (text != NULL)
- return text;
- }
-
- return NULL;
-}
-
-void
-e_web_view_set_settings (EWebView *web_view,
- WebKitWebSettings *settings)
-{
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- if (settings == webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view)))
- return;
-
- g_object_bind_property (
- settings, "enable-caret-browsing",
- web_view, "caret-mode",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- webkit_web_view_set_settings (WEBKIT_WEB_VIEW (web_view), settings);
-}
-
-WebKitWebSettings *
-e_web_view_get_default_settings (void)
-{
- WebKitWebSettings *settings;
-
- settings = webkit_web_settings_new ();
-
- g_object_set (
- G_OBJECT (settings),
- "enable-frame-flattening", TRUE,
- "enable-java-applet", FALSE,
- "enable-html5-database", FALSE,
- "enable-html5-local-storage", FALSE,
- "enable-offline-web-application-cache", FALSE,
- "enable-site-specific-quirks", TRUE,
- "enable-scripts", FALSE,
- NULL);
-
- return settings;
-}
-
-void
-e_web_view_update_fonts (EWebView *web_view)
-{
- EWebViewClass *class;
- GString *stylesheet;
- gchar *base64;
- gchar *aa = NULL;
- WebKitWebSettings *settings;
- PangoFontDescription *min_size, *ms, *vw;
- const gchar *styles[] = { "normal", "oblique", "italic" };
- const gchar *smoothing = NULL;
- GtkStyleContext *context;
- GdkColor *link = NULL;
- GdkColor *visited = NULL;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- ms = NULL;
- vw = NULL;
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- if (class->set_fonts != NULL)
- class->set_fonts (web_view, &ms, &vw);
-
- if (ms == NULL) {
- gchar *font;
-
- font = g_settings_get_string (
- web_view->priv->font_settings,
- "monospace-font-name");
-
- ms = pango_font_description_from_string (
- (font != NULL) ? font : "monospace 10");
-
- g_free (font);
- }
-
- if (vw == NULL) {
- gchar *font;
-
- font = g_settings_get_string (
- web_view->priv->font_settings,
- "font-name");
-
- vw = pango_font_description_from_string (
- (font != NULL) ? font : "serif 10");
-
- g_free (font);
- }
-
- if (pango_font_description_get_size (ms) < pango_font_description_get_size (vw)) {
- min_size = ms;
- } else {
- min_size = vw;
- }
-
- stylesheet = g_string_new ("");
- g_string_append_printf (
- stylesheet,
- "body {\n"
- " font-family: '%s';\n"
- " font-size: %dpt;\n"
- " font-weight: %d;\n"
- " font-style: %s;\n",
- pango_font_description_get_family (vw),
- pango_font_description_get_size (vw) / PANGO_SCALE,
- pango_font_description_get_weight (vw),
- styles[pango_font_description_get_style (vw)]);
-
- if (web_view->priv->aliasing_settings != NULL)
- aa = g_settings_get_string (
- web_view->priv->aliasing_settings, "antialiasing");
-
- if (g_strcmp0 (aa, "none") == 0)
- smoothing = "none";
- else if (g_strcmp0 (aa, "grayscale") == 0)
- smoothing = "antialiased";
- else if (g_strcmp0 (aa, "rgba") == 0)
- smoothing = "subpixel-antialiased";
-
- if (smoothing != NULL)
- g_string_append_printf (
- stylesheet,
- " -webkit-font-smoothing: %s;\n",
- smoothing);
-
- g_free (aa);
-
- g_string_append (stylesheet, "}\n");
-
- g_string_append_printf (
- stylesheet,
- "pre,code,.pre {\n"
- " font-family: '%s';\n"
- " font-size: %dpt;\n"
- " font-weight: %d;\n"
- " font-style: %s;\n"
- "}",
- pango_font_description_get_family (ms),
- pango_font_description_get_size (ms) / PANGO_SCALE,
- pango_font_description_get_weight (ms),
- styles[pango_font_description_get_style (ms)]);
-
- context = gtk_widget_get_style_context (GTK_WIDGET (web_view));
- gtk_style_context_get_style (
- context,
- "link-color", &link,
- "visited-link-color", &visited,
- NULL);
-
- if (link == NULL) {
- link = g_slice_new0 (GdkColor);
- link->blue = G_MAXINT16;
- }
-
- if (visited == NULL) {
- visited = g_slice_new0 (GdkColor);
- visited->red = G_MAXINT16;
- }
-
- g_string_append_printf (
- stylesheet,
- "a {\n"
- " color: #%06x;\n"
- "}\n"
- "a:visited {\n"
- " color: #%06x;\n"
- "}\n",
- e_color_to_value (link),
- e_color_to_value (visited));
-
- gdk_color_free (link);
- gdk_color_free (visited);
-
- base64 = g_base64_encode ((guchar *) stylesheet->str, stylesheet->len);
- g_string_free (stylesheet, TRUE);
-
- stylesheet = g_string_new ("data:text/css;charset=utf-8;base64,");
- g_string_append (stylesheet, base64);
- g_free (base64);
-
- settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
- g_object_set (
- G_OBJECT (settings),
- "default-font-size", pango_font_description_get_size (vw) / PANGO_SCALE,
- "default-font-family", pango_font_description_get_family (vw),
- "monospace-font-family", pango_font_description_get_family (ms),
- "default-monospace-font-size", (pango_font_description_get_size (ms) / PANGO_SCALE),
- "minimum-font-size", (pango_font_description_get_size (min_size) / PANGO_SCALE),
- "user-stylesheet-uri", stylesheet->str,
- NULL);
-
- g_string_free (stylesheet, TRUE);
-
- pango_font_description_free (ms);
- pango_font_description_free (vw);
-}
-
-void
-e_web_view_install_request_handler (EWebView *web_view,
- GType handler_type)
-{
- SoupSession *session;
- SoupSessionFeature *feature;
- gboolean new;
-
- session = webkit_get_default_session ();
-
- feature = soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
- new = FALSE;
- if (feature == NULL) {
- feature = SOUP_SESSION_FEATURE (soup_requester_new ());
- soup_session_add_feature (session, feature);
- new = TRUE;
- }
-
- soup_session_feature_add_feature (feature, handler_type);
-
- if (new) {
- g_object_unref (feature);
- }
-}
-
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
deleted file mode 100644
index fe17d621c0..0000000000
--- a/widgets/misc/e-web-view.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * e-web-view.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/* This is intended to serve as a common base class for all HTML viewing
- * needs in Evolution. Currently based on GtkHTML, the idea is to wrap
- * the GtkHTML API enough that we no longer have to make direct calls to
- * it. This should help smooth the transition to WebKit/GTK+.
- *
- * This class handles basic tasks like mouse hovers over links, clicked
- * links, and servicing URI requests asynchronously via GIO. */
-
-#ifndef E_WEB_VIEW_H
-#define E_WEB_VIEW_H
-
-#include <webkit/webkit.h>
-
-/* Standard GObject macros */
-#define E_TYPE_WEB_VIEW \
- (e_web_view_get_type ())
-#define E_WEB_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_WEB_VIEW, EWebView))
-#define E_WEB_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_WEB_VIEW, EWebViewClass))
-#define E_IS_WEB_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_WEB_VIEW))
-#define E_IS_WEB_VIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_WEB_VIEW))
-#define E_WEB_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_WEB_VIEW, EWebViewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EWebView EWebView;
-typedef struct _EWebViewClass EWebViewClass;
-typedef struct _EWebViewPrivate EWebViewPrivate;
-struct PangoFontDescription;
-
-struct _EWebView {
- WebKitWebView parent;
- EWebViewPrivate *priv;
-};
-
-typedef void (*EWebViewJSFunctionCallback) (EWebView *web_view,
- size_t arg_count,
- const JSValueRef args[],
- gpointer user_data);
-
-struct _EWebViewClass {
- WebKitWebViewClass parent_class;
-
- /* Methods */
- GtkWidget * (*create_plugin_widget) (EWebView *web_view,
- const gchar *mime_type,
- const gchar *uri,
- GHashTable *param);
- gchar * (*extract_uri) (EWebView *web_view,
- GdkEventButton *event);
- void (*hovering_over_link) (EWebView *web_view,
- const gchar *title,
- const gchar *uri);
- void (*link_clicked) (EWebView *web_view,
- const gchar *uri);
- void (*load_string) (EWebView *web_view,
- const gchar *load_string);
- void (*load_uri) (EWebView *web_view,
- const gchar *load_uri);
- void (*frame_load_string) (EWebView *web_view,
- const gchar *frame_name,
- const gchar *string);
- void (*frame_load_uri) (EWebView *web_view,
- const gchar *frame_name,
- const gchar *uri);
- void (*set_fonts) (EWebView *web_view,
- PangoFontDescription **monospace,
- PangoFontDescription **variable_width);
-
- /* Signals */
- gboolean (*popup_event) (EWebView *web_view,
- const gchar *uri);
- void (*status_message) (EWebView *web_view,
- const gchar *status_message);
- void (*stop_loading) (EWebView *web_view);
- void (*update_actions) (EWebView *web_view);
- gboolean (*process_mailto) (EWebView *web_view,
- const gchar *mailto_uri);
-};
-
-GType e_web_view_get_type (void);
-GtkWidget * e_web_view_new (void);
-void e_web_view_clear (EWebView *web_view);
-void e_web_view_load_string (EWebView *web_view,
- const gchar *string);
-void e_web_view_load_uri (EWebView *web_view,
- const gchar *uri);
-const gchar * e_web_view_get_uri (EWebView *web_view);
-void e_web_view_reload (EWebView *web_view);
-void e_web_view_frame_load_string (EWebView *web_view,
- const gchar *frame_name,
- const gchar *string);
-void e_web_view_frame_load_uri (EWebView *web_view,
- const gchar *frame_name,
- const gchar *uri);
-const gchar * e_web_view_frame_get_uri (EWebView *web_view,
- const gchar *frame_name);
-gchar * e_web_view_get_html (EWebView *web_view);
-gboolean e_web_view_get_caret_mode (EWebView *web_view);
-void e_web_view_set_caret_mode (EWebView *web_view,
- gboolean caret_mode);
-GtkTargetList * e_web_view_get_copy_target_list (EWebView *web_view);
-gboolean e_web_view_get_disable_printing (EWebView *web_view);
-void e_web_view_set_disable_printing (EWebView *web_view,
- gboolean disable_printing);
-gboolean e_web_view_get_disable_save_to_disk
- (EWebView *web_view);
-void e_web_view_set_disable_save_to_disk
- (EWebView *web_view,
- gboolean disable_save_to_disk);
-gboolean e_web_view_get_enable_frame_flattening
- (EWebView *web_view);
-void e_web_view_set_enable_frame_flattening
- (EWebView *web_view,
- gboolean enable_frame_flattening);
-gboolean e_web_view_get_editable (EWebView *web_view);
-void e_web_view_set_editable (EWebView *web_view,
- gboolean editable);
-gboolean e_web_view_get_inline_spelling (EWebView *web_view);
-void e_web_view_set_inline_spelling (EWebView *web_view,
- gboolean inline_spelling);
-gboolean e_web_view_get_magic_links (EWebView *web_view);
-void e_web_view_set_magic_links (EWebView *web_view,
- gboolean magic_links);
-gboolean e_web_view_get_magic_smileys (EWebView *web_view);
-void e_web_view_set_magic_smileys (EWebView *web_view,
- gboolean magic_smileys);
-const gchar * e_web_view_get_selected_uri (EWebView *web_view);
-void e_web_view_set_selected_uri (EWebView *web_view,
- const gchar *selected_uri);
-GdkPixbufAnimation *
- e_web_view_get_cursor_image (EWebView *web_view);
-void e_web_view_set_cursor_image (EWebView *web_view,
- GdkPixbufAnimation *animation);
-const gchar * e_web_view_get_cursor_image_src (EWebView *web_view);
-void e_web_view_set_cursor_image_src (EWebView *web_view,
- const gchar *src_uri);
-GtkAction * e_web_view_get_open_proxy (EWebView *web_view);
-void e_web_view_set_open_proxy (EWebView *web_view,
- GtkAction *open_proxy);
-GtkTargetList * e_web_view_get_paste_target_list
- (EWebView *web_view);
-GtkAction * e_web_view_get_print_proxy (EWebView *web_view);
-void e_web_view_set_print_proxy (EWebView *web_view,
- GtkAction *print_proxy);
-GtkAction * e_web_view_get_save_as_proxy (EWebView *web_view);
-void e_web_view_set_save_as_proxy (EWebView *web_view,
- GtkAction *save_as_proxy);
-GSList * e_web_view_get_highlights (EWebView *web_view);
-void e_web_view_add_highlight (EWebView *web_view,
- const gchar *highlight);
-void e_web_view_clear_highlights (EWebView *web_view);
-GtkAction * e_web_view_get_action (EWebView *web_view,
- const gchar *action_name);
-GtkActionGroup *e_web_view_get_action_group (EWebView *web_view,
- const gchar *group_name);
-gchar * e_web_view_extract_uri (EWebView *web_view,
- GdkEventButton *event);
-void e_web_view_copy_clipboard (EWebView *web_view);
-void e_web_view_cut_clipboard (EWebView *web_view);
-gboolean e_web_view_is_selection_active (EWebView *web_view);
-void e_web_view_paste_clipboard (EWebView *web_view);
-gboolean e_web_view_scroll_forward (EWebView *web_view);
-gboolean e_web_view_scroll_backward (EWebView *web_view);
-void e_web_view_select_all (EWebView *web_view);
-void e_web_view_unselect_all (EWebView *web_view);
-void e_web_view_zoom_100 (EWebView *web_view);
-void e_web_view_zoom_in (EWebView *web_view);
-void e_web_view_zoom_out (EWebView *web_view);
-GtkUIManager * e_web_view_get_ui_manager (EWebView *web_view);
-GtkWidget * e_web_view_get_popup_menu (EWebView *web_view);
-void e_web_view_show_popup_menu (EWebView *web_view);
-void e_web_view_status_message (EWebView *web_view,
- const gchar *status_message);
-void e_web_view_stop_loading (EWebView *web_view);
-void e_web_view_update_actions (EWebView *web_view);
-gchar * e_web_view_get_selection_html (EWebView *web_view);
-
-void e_web_view_set_settings (EWebView *web_view,
- WebKitWebSettings *settings);
-
-void e_web_view_update_fonts (EWebView *web_view);
-
-WebKitWebSettings *
- e_web_view_get_default_settings (void);
-
-void e_web_view_install_request_handler
- (EWebView *web_view,
- GType handler_type);
-
-G_END_DECLS
-
-#endif /* E_WEB_VIEW_H */
diff --git a/widgets/misc/ea-calendar-cell.c b/widgets/misc/ea-calendar-cell.c
deleted file mode 100644
index 90a889ef18..0000000000
--- a/widgets/misc/ea-calendar-cell.c
+++ /dev/null
@@ -1,405 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <e-util/e-util.h>
-#include "ea-calendar-cell.h"
-#include "ea-calendar-item.h"
-#include "a11y/ea-factory.h"
-
-/* ECalendarCell */
-
-static void e_calendar_cell_class_init (ECalendarCellClass *class);
-
-EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_CELL, ea_calendar_cell, ea_calendar_cell_new)
-
-GType
-e_calendar_cell_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo tinfo = {
- sizeof (ECalendarCellClass),
- (GBaseInitFunc) NULL, /* base init */
- (GBaseFinalizeFunc) NULL, /* base finalize */
- (GClassInitFunc) e_calendar_cell_class_init, /* class init */
- (GClassFinalizeFunc) NULL, /* class finalize */
- NULL, /* class data */
- sizeof (ECalendarCell), /* instance size */
- 0, /* nb preallocs */
- (GInstanceInitFunc) NULL, /* instance init */
- NULL /* value table */
- };
-
- type = g_type_register_static (
- G_TYPE_OBJECT,
- "ECalendarCell", &tinfo, 0);
- }
-
- return type;
-}
-
-static void
-e_calendar_cell_class_init (ECalendarCellClass *class)
-{
- EA_SET_FACTORY (e_calendar_cell_get_type (), ea_calendar_cell);
-}
-
-ECalendarCell *
-e_calendar_cell_new (ECalendarItem *calitem,
- gint row,
- gint column)
-{
- GObject *object;
- ECalendarCell *cell;
-
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), NULL);
-
- object = g_object_new (E_TYPE_CALENDAR_CELL, NULL);
- cell = E_CALENDAR_CELL (object);
- cell->calitem = calitem;
- cell->row = row;
- cell->column = column;
-
-#ifdef ACC_DEBUG
- g_print ("EvoAcc: e_calendar_cell created %p\n", (gpointer) cell);
-#endif
-
- return cell;
-}
-
-/* EaCalendarCell */
-
-static void ea_calendar_cell_class_init (EaCalendarCellClass *klass);
-static void ea_calendar_cell_init (EaCalendarCell *a11y);
-
-static const gchar * ea_calendar_cell_get_name (AtkObject *accessible);
-static const gchar * ea_calendar_cell_get_description (AtkObject *accessible);
-static AtkObject * ea_calendar_cell_get_parent (AtkObject *accessible);
-static gint ea_calendar_cell_get_index_in_parent (AtkObject *accessible);
-static AtkStateSet *ea_calendar_cell_ref_state_set (AtkObject *accessible);
-
-/* component interface */
-static void atk_component_interface_init (AtkComponentIface *iface);
-static void component_interface_get_extents (AtkComponent *component,
- gint *x, gint *y,
- gint *width, gint *height,
- AtkCoordType coord_type);
-static gboolean component_interface_grab_focus (AtkComponent *component);
-
-static gpointer parent_class = NULL;
-
-#ifdef ACC_DEBUG
-static gint n_ea_calendar_cell_created = 0, n_ea_calendar_cell_destroyed = 0;
-static void ea_calendar_cell_finalize (GObject *object);
-#endif
-
-GType
-ea_calendar_cell_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo tinfo = {
- sizeof (EaCalendarCellClass),
- (GBaseInitFunc) NULL, /* base init */
- (GBaseFinalizeFunc) NULL, /* base finalize */
- (GClassInitFunc) ea_calendar_cell_class_init, /* class init */
- (GClassFinalizeFunc) NULL, /* class finalize */
- NULL, /* class data */
- sizeof (EaCalendarCell), /* instance size */
- 0, /* nb preallocs */
- (GInstanceInitFunc) ea_calendar_cell_init, /* instance init */
- NULL /* value table */
- };
-
- static const GInterfaceInfo atk_component_info = {
- (GInterfaceInitFunc) atk_component_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
-
- type = g_type_register_static (
- ATK_TYPE_GOBJECT_ACCESSIBLE,
- "EaCalendarCell", &tinfo, 0);
- g_type_add_interface_static (
- type, ATK_TYPE_COMPONENT,
- &atk_component_info);
- }
-
- return type;
-}
-
-static void
-ea_calendar_cell_class_init (EaCalendarCellClass *klass)
-{
- AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
-#ifdef ACC_DEBUG
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = ea_calendar_cell_finalize;
-#endif
-
- parent_class = g_type_class_peek_parent (klass);
-
- class->get_name = ea_calendar_cell_get_name;
- class->get_description = ea_calendar_cell_get_description;
-
- class->get_parent = ea_calendar_cell_get_parent;
- class->get_index_in_parent = ea_calendar_cell_get_index_in_parent;
- class->ref_state_set = ea_calendar_cell_ref_state_set;
-}
-
-static void
-ea_calendar_cell_init (EaCalendarCell *a11y)
-{
- a11y->state_set = atk_state_set_new ();
- atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT);
- atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED);
- atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE);
- atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE);
- atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING);
- atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE);
-}
-
-AtkObject *
-ea_calendar_cell_new (GObject *obj)
-{
- gpointer object;
- AtkObject *atk_object;
-
- g_return_val_if_fail (E_IS_CALENDAR_CELL (obj), NULL);
- object = g_object_new (EA_TYPE_CALENDAR_CELL, NULL);
- atk_object = ATK_OBJECT (object);
- atk_object_initialize (atk_object, obj);
- atk_object->role = ATK_ROLE_TABLE_CELL;
-
-#ifdef ACC_DEBUG
- ++n_ea_calendar_cell_created;
- g_print (
- "ACC_DEBUG: n_ea_calendar_cell_created = %d\n",
- n_ea_calendar_cell_created);
-#endif
- return atk_object;
-}
-
-#ifdef ACC_DEBUG
-static void ea_calendar_cell_finalize (GObject *object)
-{
- G_OBJECT_CLASS (parent_class)->finalize (object);
-
- ++n_ea_calendar_cell_destroyed;
- g_print (
- "ACC_DEBUG: n_ea_calendar_cell_destroyed = %d\n",
- n_ea_calendar_cell_destroyed);
-}
-#endif
-
-static const gchar *
-ea_calendar_cell_get_name (AtkObject *accessible)
-{
- GObject *g_obj;
-
- g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), NULL);
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
- if (!g_obj)
- /* defunct object*/
- return NULL;
-
- if (!accessible->name) {
- AtkObject *atk_obj;
- EaCalendarItem *ea_calitem;
- ECalendarCell *cell;
- gint day_index;
- gint year, month, day;
- gchar buffer[128];
-
- cell = E_CALENDAR_CELL (g_obj);
- atk_obj = ea_calendar_cell_get_parent (accessible);
- ea_calitem = EA_CALENDAR_ITEM (atk_obj);
- day_index = atk_table_get_index_at (
- ATK_TABLE (ea_calitem),
- cell->row, cell->column);
- e_calendar_item_get_date_for_offset (cell->calitem, day_index,
- &year, &month, &day);
-
- g_snprintf (buffer, 128, "%d-%d-%d", year, month + 1, day);
- ATK_OBJECT_CLASS (parent_class)->set_name (accessible, buffer);
- }
- return accessible->name;
-}
-
-static const gchar *
-ea_calendar_cell_get_description (AtkObject *accessible)
-{
- return ea_calendar_cell_get_name (accessible);
-}
-
-static AtkObject *
-ea_calendar_cell_get_parent (AtkObject *accessible)
-{
- GObject *g_obj;
- ECalendarCell *cell;
- ECalendarItem *calitem;
-
- g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), NULL);
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
- if (!g_obj)
- /* defunct object*/
- return NULL;
-
- cell = E_CALENDAR_CELL (g_obj);
- calitem = cell->calitem;
- return atk_gobject_accessible_for_object (G_OBJECT (calitem));
-}
-
-static gint
-ea_calendar_cell_get_index_in_parent (AtkObject *accessible)
-{
- GObject *g_obj;
- ECalendarCell *cell;
- AtkObject *parent;
-
- g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), -1);
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
- if (!g_obj)
- return -1;
- cell = E_CALENDAR_CELL (g_obj);
- parent = atk_object_get_parent (accessible);
- return atk_table_get_index_at (
- ATK_TABLE (parent),
- cell->row, cell->column);
-}
-
-static AtkStateSet *
-ea_calendar_cell_ref_state_set (AtkObject *accessible)
-{
- EaCalendarCell *atk_cell = EA_CALENDAR_CELL (accessible);
-
- g_return_val_if_fail (atk_cell->state_set, NULL);
-
- g_object_ref (atk_cell->state_set);
-
- return atk_cell->state_set;
-
-}
-
-/* Atk Component Interface */
-
-static void
-atk_component_interface_init (AtkComponentIface *iface)
-{
- g_return_if_fail (iface != NULL);
-
- iface->get_extents = component_interface_get_extents;
- iface->grab_focus = component_interface_grab_focus;
-}
-
-static void
-component_interface_get_extents (AtkComponent *component,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coord_type)
-{
- GObject *g_obj;
- AtkObject *atk_obj, *atk_canvas;
- ECalendarCell *cell;
- ECalendarItem *calitem;
- EaCalendarItem *ea_calitem;
- gint day_index;
- gint year, month, day;
- gint canvas_x, canvas_y, canvas_width, canvas_height;
-
- *x = *y = *width = *height = 0;
-
- g_return_if_fail (EA_IS_CALENDAR_CELL (component));
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component));
- if (!g_obj)
- /* defunct object*/
- return;
-
- cell = E_CALENDAR_CELL (g_obj);
- calitem = cell->calitem;
- atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
- ea_calitem = EA_CALENDAR_ITEM (atk_obj);
- day_index = atk_table_get_index_at (
- ATK_TABLE (ea_calitem),
- cell->row, cell->column);
- e_calendar_item_get_date_for_offset (calitem, day_index,
- &year, &month, &day);
-
- if (!e_calendar_item_get_day_extents (calitem,
- year, month, day,
- x, y, width, height))
- return;
- atk_canvas = atk_object_get_parent (ATK_OBJECT (ea_calitem));
- atk_component_get_extents (
- ATK_COMPONENT (atk_canvas),
- &canvas_x, &canvas_y,
- &canvas_width, &canvas_height,
- coord_type);
- *x += canvas_x;
- *y += canvas_y;
-}
-
-static gboolean
-component_interface_grab_focus (AtkComponent *component)
-{
- GObject *g_obj;
- GtkWidget *toplevel;
- AtkObject *ea_calitem;
- ECalendarItem *calitem;
- EaCalendarCell *a11y;
- gint index;
-
- a11y = EA_CALENDAR_CELL (component);
- ea_calitem = ea_calendar_cell_get_parent (ATK_OBJECT (a11y));
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_calitem));
- calitem = E_CALENDAR_ITEM (g_obj);
-
- index = atk_object_get_index_in_parent (ATK_OBJECT (a11y));
-
- atk_selection_clear_selection (ATK_SELECTION (ea_calitem));
- atk_selection_add_selection (ATK_SELECTION (ea_calitem), index);
-
- gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas));
- toplevel = gtk_widget_get_toplevel (
- GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas));
- if (toplevel && gtk_widget_is_toplevel (toplevel))
- gtk_window_present (GTK_WINDOW (toplevel));
-
- return TRUE;
-
-}
diff --git a/widgets/misc/ea-calendar-cell.h b/widgets/misc/ea-calendar-cell.h
deleted file mode 100644
index 2fd2051538..0000000000
--- a/widgets/misc/ea-calendar-cell.h
+++ /dev/null
@@ -1,86 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __EA_CALENDAR_CELL_H__
-#define __EA_CALENDAR_CELL_H__
-
-#include <atk/atkgobjectaccessible.h>
-#include "misc/e-calendar-item.h"
-
-G_BEGIN_DECLS
-
-#define E_TYPE_CALENDAR_CELL (e_calendar_cell_get_type ())
-#define E_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CALENDAR_CELL, ECalendarCell))
-#define E_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CALENDAR_CELL, ECalendarCellClass))
-#define E_IS_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CALENDAR_CELL))
-#define E_IS_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CALENDAR_CELL))
-#define E_CALENDAR_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_CALENDAR_CELL, ECalendarCellClass))
-
-typedef struct _ECalendarCell ECalendarCell;
-typedef struct _ECalendarCellClass ECalendarCellClass;
-
-struct _ECalendarCell
-{
- GObject parent;
- ECalendarItem *calitem;
- gint row;
- gint column;
-};
-
-GType e_calendar_cell_get_type (void);
-
-struct _ECalendarCellClass
-{
- GObjectClass parent_class;
-};
-
-ECalendarCell * e_calendar_cell_new (ECalendarItem *calitem,
- gint row, gint column);
-
-#define EA_TYPE_CALENDAR_CELL (ea_calendar_cell_get_type ())
-#define EA_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CALENDAR_CELL, EaCalendarCell))
-#define EA_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CALENDAR_CELL, EaCalendarCellClass))
-#define EA_IS_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CALENDAR_CELL))
-#define EA_IS_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CALENDAR_CELL))
-#define EA_CALENDAR_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CALENDAR_CELL, EaCalendarCellClass))
-
-typedef struct _EaCalendarCell EaCalendarCell;
-typedef struct _EaCalendarCellClass EaCalendarCellClass;
-
-struct _EaCalendarCell
-{
- AtkGObjectAccessible parent;
- AtkStateSet *state_set;
-};
-
-GType ea_calendar_cell_get_type (void);
-
-struct _EaCalendarCellClass
-{
- AtkGObjectAccessibleClass parent_class;
-};
-
-AtkObject * ea_calendar_cell_new (GObject *gobj);
-
-G_END_DECLS
-
-#endif /* __EA_CALENDAR_CELL_H__ */
diff --git a/widgets/misc/ea-calendar-item.c b/widgets/misc/ea-calendar-item.c
deleted file mode 100644
index dc878c4e1d..0000000000
--- a/widgets/misc/ea-calendar-item.c
+++ /dev/null
@@ -1,1372 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-#include <libgnomecanvas/gnome-canvas.h>
-#include <e-util/e-util.h>
-#include <glib/gi18n.h>
-
-#include <libedataserver/libedataserver.h>
-
-#include "ea-calendar-item.h"
-#include "ea-calendar-cell.h"
-#include "ea-cell-table.h"
-
-#define EA_CALENDAR_COLUMN_NUM E_CALENDAR_COLS_PER_MONTH
-
-/* EaCalendarItem */
-static void ea_calendar_item_class_init (EaCalendarItemClass *class);
-static void ea_calendar_item_finalize (GObject *object);
-
-static const gchar * ea_calendar_item_get_name (AtkObject *accessible);
-static const gchar * ea_calendar_item_get_description (AtkObject *accessible);
-static gint ea_calendar_item_get_n_children (AtkObject *accessible);
-static AtkObject *ea_calendar_item_ref_child (AtkObject *accessible, gint index);
-static AtkStateSet * ea_calendar_item_ref_state_set (AtkObject *accessible);
-
-/* atk table interface */
-static void atk_table_interface_init (AtkTableIface *iface);
-static gint table_interface_get_index_at (AtkTable *table,
- gint row,
- gint column);
-static gint table_interface_get_column_at_index (AtkTable *table,
- gint index);
-static gint table_interface_get_row_at_index (AtkTable *table,
- gint index);
-static AtkObject * table_interface_ref_at (AtkTable *table,
- gint row,
- gint column);
-static gint table_interface_get_n_rows (AtkTable *table);
-static gint table_interface_get_n_columns (AtkTable *table);
-static gint table_interface_get_column_extent_at (AtkTable *table,
- gint row,
- gint column);
-static gint table_interface_get_row_extent_at (AtkTable *table,
- gint row,
- gint column);
-
-static gboolean table_interface_is_row_selected (AtkTable *table,
- gint row);
-static gboolean table_interface_is_column_selected (AtkTable *table,
- gint row);
-static gboolean table_interface_is_selected (AtkTable *table,
- gint row,
- gint column);
-static gint table_interface_get_selected_rows (AtkTable *table,
- gint **rows_selected);
-static gint table_interface_get_selected_columns (AtkTable *table,
- gint **columns_selected);
-static gboolean table_interface_add_row_selection (AtkTable *table, gint row);
-static gboolean table_interface_remove_row_selection (AtkTable *table,
- gint row);
-static gboolean table_interface_add_column_selection (AtkTable *table,
- gint column);
-static gboolean table_interface_remove_column_selection (AtkTable *table,
- gint column);
-static AtkObject * table_interface_get_row_header (AtkTable *table, gint row);
-static AtkObject * table_interface_get_column_header (AtkTable *table,
- gint in_col);
-static AtkObject * table_interface_get_caption (AtkTable *table);
-
-static const gchar *
-table_interface_get_column_description (AtkTable *table,
- gint in_col);
-
-static const gchar *
-table_interface_get_row_description (AtkTable *table,
- gint row);
-
-static AtkObject *table_interface_get_summary (AtkTable *table);
-
-/* atk selection interface */
-static void atk_selection_interface_init (AtkSelectionIface *iface);
-static gboolean selection_interface_add_selection (AtkSelection *selection,
- gint i);
-static gboolean selection_interface_clear_selection (AtkSelection *selection);
-static AtkObject *selection_interface_ref_selection (AtkSelection *selection,
- gint i);
-static gint selection_interface_get_selection_count (AtkSelection *selection);
-static gboolean selection_interface_is_child_selected (AtkSelection *selection,
- gint i);
-
-/* callbacks */
-static void selection_preview_change_cb (ECalendarItem *calitem);
-static void date_range_changed_cb (ECalendarItem *calitem);
-
-/* helpers */
-static EaCellTable *ea_calendar_item_get_cell_data (EaCalendarItem *ea_calitem);
-static void ea_calendar_item_destory_cell_data (EaCalendarItem *ea_calitem);
-static gboolean ea_calendar_item_get_column_label (EaCalendarItem *ea_calitem,
- gint column,
- gchar *buffer,
- gint buffer_size);
-static gboolean ea_calendar_item_get_row_label (EaCalendarItem *ea_calitem,
- gint row,
- gchar *buffer,
- gint buffer_size);
-static gboolean e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- gint *offset);
-static void ea_calendar_set_focus_object (EaCalendarItem *ea_calitem,
- AtkObject *item_cell);
-
-#ifdef ACC_DEBUG
-static gint n_ea_calendar_item_created = 0;
-static gint n_ea_calendar_item_destroyed = 0;
-#endif
-
-static gpointer parent_class = NULL;
-
-GType
-ea_calendar_item_get_type (void)
-{
- static GType type = 0;
- AtkObjectFactory *factory;
- GTypeQuery query;
- GType derived_atk_type;
-
- if (!type) {
- static GTypeInfo tinfo = {
- sizeof (EaCalendarItemClass),
- (GBaseInitFunc) NULL, /* base init */
- (GBaseFinalizeFunc) NULL, /* base finalize */
- (GClassInitFunc) ea_calendar_item_class_init, /* class init */
- (GClassFinalizeFunc) NULL, /* class finalize */
- NULL, /* class data */
- sizeof (EaCalendarItem), /* instance size */
- 0, /* nb preallocs */
- (GInstanceInitFunc) NULL, /* instance init */
- NULL /* value table */
- };
-
- static const GInterfaceInfo atk_table_info = {
- (GInterfaceInitFunc) atk_table_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
- static const GInterfaceInfo atk_selection_info = {
- (GInterfaceInitFunc) atk_selection_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
-
- /*
- * Figure out the size of the class and instance
- * we are run-time deriving from (GailCanvasItem, in this case)
- */
-
- factory = atk_registry_get_factory (
- atk_get_default_registry (),
- GNOME_TYPE_CANVAS_ITEM);
- derived_atk_type = atk_object_factory_get_accessible_type (factory);
- g_type_query (derived_atk_type, &query);
-
- tinfo.class_size = query.class_size;
- tinfo.instance_size = query.instance_size;
-
- type = g_type_register_static (
- derived_atk_type,
- "EaCalendarItem", &tinfo, 0);
- g_type_add_interface_static (
- type, ATK_TYPE_TABLE,
- &atk_table_info);
- g_type_add_interface_static (
- type, ATK_TYPE_SELECTION,
- &atk_selection_info);
- }
-
- return type;
-}
-
-static void
-ea_calendar_item_class_init (EaCalendarItemClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
- gobject_class->finalize = ea_calendar_item_finalize;
- parent_class = g_type_class_peek_parent (klass);
-
- class->get_name = ea_calendar_item_get_name;
- class->get_description = ea_calendar_item_get_description;
- class->ref_state_set = ea_calendar_item_ref_state_set;
-
- class->get_n_children = ea_calendar_item_get_n_children;
- class->ref_child = ea_calendar_item_ref_child;
-}
-
-AtkObject *
-ea_calendar_item_new (GObject *obj)
-{
- gpointer object;
- AtkObject *atk_object;
- AtkObject *item_cell;
-
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (obj), NULL);
- object = g_object_new (EA_TYPE_CALENDAR_ITEM, NULL);
- atk_object = ATK_OBJECT (object);
- atk_object_initialize (atk_object, obj);
- atk_object->role = ATK_ROLE_CALENDAR;
-
- item_cell = atk_selection_ref_selection (
- ATK_SELECTION (atk_object), 0);
- if (item_cell)
- ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_object), item_cell);
-
-#ifdef ACC_DEBUG
- ++n_ea_calendar_item_created;
- g_print (
- "ACC_DEBUG: n_ea_calendar_item_created = %d\n",
- n_ea_calendar_item_created);
-#endif
- /* connect signal handlers */
- g_signal_connect (
- obj, "selection_preview_changed",
- G_CALLBACK (selection_preview_change_cb), atk_object);
- g_signal_connect (
- obj, "date_range_changed",
- G_CALLBACK (date_range_changed_cb), atk_object);
-
- return atk_object;
-}
-
-static void
-ea_calendar_item_finalize (GObject *object)
-{
- EaCalendarItem *ea_calitem;
-
- g_return_if_fail (EA_IS_CALENDAR_ITEM (object));
-
- ea_calitem = EA_CALENDAR_ITEM (object);
-
- /* Free the allocated cell data */
- ea_calendar_item_destory_cell_data (ea_calitem);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-#ifdef ACC_DEBUG
- ++n_ea_calendar_item_destroyed;
- printf (
- "ACC_DEBUG: n_ea_calendar_item_destroyed = %d\n",
- n_ea_calendar_item_destroyed);
-#endif
-}
-
-static const gchar *
-ea_calendar_item_get_name (AtkObject *accessible)
-{
- GObject *g_obj;
- ECalendarItem *calitem;
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- gchar *name_str = NULL;
- gchar buffer_start[128] = "";
- gchar buffer_end[128] = "";
- struct tm day_start = { 0 };
- struct tm day_end = { 0 };
-
- g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), NULL);
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
- if (!g_obj)
- return NULL;
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (g_obj), NULL);
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (e_calendar_item_get_date_range (
- calitem,
- &start_year, &start_month, &start_day,
- &end_year, &end_month, &end_day)) {
-
- day_start.tm_year = start_year - 1900;
- day_start.tm_mon = start_month;
- day_start.tm_mday = start_day;
- day_start.tm_isdst = -1;
-
- e_utf8_strftime (
- buffer_start, sizeof (buffer_start),
- _("%d %B %Y"), &day_start);
-
- day_end.tm_year = end_year - 1900;
- day_end.tm_mon = end_month;
- day_end.tm_mday = end_day;
- day_end.tm_isdst = -1;
-
- e_utf8_strftime (
- buffer_end, sizeof (buffer_end),
- _("%d %B %Y"), &day_end);
-
- name_str = g_strdup_printf (
- _("Calendar: from %s to %s"),
- buffer_start, buffer_end);
- }
-
-#if 0
- if (e_calendar_item_get_selection (calitem, &select_start, &select_end)) {
- GDate select_start, select_end;
- gint year1, year2, month1, month2, day1, day2;
-
- year1 = g_date_get_year (&select_start);
- month1 = g_date_get_month (&select_start);
- day1 = g_date_get_day (&select_start);
-
- year2 = g_date_get_year (&select_end);
- month2 = g_date_get_month (&select_end);
- day2 = g_date_get_day (&select_end);
-
- sprintf (
- new_name + strlen (new_name),
- " : current selection: from %d-%d-%d to %d-%d-%d.",
- year1, month1, day1,
- year2, month2, day2);
- }
-#endif
-
- ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str);
- g_free (name_str);
-
- return accessible->name;
-}
-
-static const gchar *
-ea_calendar_item_get_description (AtkObject *accessible)
-{
- if (accessible->description)
- return accessible->description;
-
- return _("evolution calendar item");
-}
-
-static AtkStateSet *
-ea_calendar_item_ref_state_set (AtkObject *accessible)
-{
- AtkStateSet *state_set;
- GObject *g_obj;
-
- state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
- g_obj = atk_gobject_accessible_get_object (
- ATK_GOBJECT_ACCESSIBLE (accessible));
- if (!g_obj)
- return state_set;
-
- atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
- atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
-
- return state_set;
-}
-
-static gint
-ea_calendar_item_get_n_children (AtkObject *accessible)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- gint n_children = 0;
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- GDate *start_date, *end_date;
-
- g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), -1);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (!e_calendar_item_get_date_range (calitem, &start_year,
- &start_month, &start_day,
- &end_year, &end_month,
- &end_day))
- return 0;
-
- start_date = g_date_new_dmy (start_day, start_month + 1, start_year);
- end_date = g_date_new_dmy (end_day, end_month + 1, end_year);
-
- n_children = g_date_days_between (start_date, end_date) + 1;
- g_free (start_date);
- g_free (end_date);
- return n_children;
-}
-
-static AtkObject *
-ea_calendar_item_ref_child (AtkObject *accessible,
- gint index)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- gint n_children;
- ECalendarCell *cell;
- EaCellTable *cell_data;
- EaCalendarItem *ea_calitem;
-
- g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), NULL);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return NULL;
-
- calitem = E_CALENDAR_ITEM (g_obj);
-
- n_children = ea_calendar_item_get_n_children (accessible);
- if (index < 0 || index >= n_children)
- return NULL;
-
- ea_calitem = EA_CALENDAR_ITEM (accessible);
- cell_data = ea_calendar_item_get_cell_data (ea_calitem);
- if (!cell_data)
- return NULL;
-
- cell = ea_cell_table_get_cell_at_index (cell_data, index);
- if (!cell) {
- cell = e_calendar_cell_new (
- calitem,
- index / EA_CALENDAR_COLUMN_NUM,
- index % EA_CALENDAR_COLUMN_NUM);
- ea_cell_table_set_cell_at_index (cell_data, index, cell);
- g_object_unref (cell);
- }
-
-#ifdef ACC_DEBUG
- g_print (
- "AccDebug: ea_calendar_item children[%d]=%p\n", index,
- (gpointer) cell);
-#endif
- return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT (cell)));
-}
-
-/* atk table interface */
-
-static void
-atk_table_interface_init (AtkTableIface *iface)
-{
- g_return_if_fail (iface != NULL);
-
- iface->ref_at = table_interface_ref_at;
-
- iface->get_n_rows = table_interface_get_n_rows;
- iface->get_n_columns = table_interface_get_n_columns;
- iface->get_index_at = table_interface_get_index_at;
- iface->get_column_at_index = table_interface_get_column_at_index;
- iface->get_row_at_index = table_interface_get_row_at_index;
- iface->get_column_extent_at = table_interface_get_column_extent_at;
- iface->get_row_extent_at = table_interface_get_row_extent_at;
-
- iface->is_selected = table_interface_is_selected;
- iface->get_selected_rows = table_interface_get_selected_rows;
- iface->get_selected_columns = table_interface_get_selected_columns;
- iface->is_row_selected = table_interface_is_row_selected;
- iface->is_column_selected = table_interface_is_column_selected;
- iface->add_row_selection = table_interface_add_row_selection;
- iface->remove_row_selection = table_interface_remove_row_selection;
- iface->add_column_selection = table_interface_add_column_selection;
- iface->remove_column_selection = table_interface_remove_column_selection;
-
- iface->get_row_header = table_interface_get_row_header;
- iface->get_column_header = table_interface_get_column_header;
- iface->get_caption = table_interface_get_caption;
- iface->get_summary = table_interface_get_summary;
- iface->get_row_description = table_interface_get_row_description;
- iface->get_column_description = table_interface_get_column_description;
-}
-
-static AtkObject *
-table_interface_ref_at (AtkTable *table,
- gint row,
- gint column)
-{
- gint index;
-
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- index = EA_CALENDAR_COLUMN_NUM * row + column;
- return ea_calendar_item_ref_child (ATK_OBJECT (ea_calitem), index);
-}
-
-static gint
-table_interface_get_n_rows (AtkTable *table)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- gint n_children;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem));
- return (n_children - 1) / EA_CALENDAR_COLUMN_NUM + 1;
-}
-
-static gint
-table_interface_get_n_columns (AtkTable *table)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- return EA_CALENDAR_COLUMN_NUM;
-}
-
-static gint
-table_interface_get_index_at (AtkTable *table,
- gint row,
- gint column)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- return row * EA_CALENDAR_COLUMN_NUM + column;
-}
-
-static gint
-table_interface_get_column_at_index (AtkTable *table,
- gint index)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- gint n_children;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem));
- if (index >= 0 && index < n_children)
- return index % EA_CALENDAR_COLUMN_NUM;
- return -1;
-}
-
-static gint
-table_interface_get_row_at_index (AtkTable *table,
- gint index)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- gint n_children;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return -1;
-
- n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem));
- if (index >= 0 && index < n_children)
- return index / EA_CALENDAR_COLUMN_NUM;
- return -1;
-}
-
-static gint
-table_interface_get_column_extent_at (AtkTable *table,
- gint row,
- gint column)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- return calitem->cell_width;
-}
-
-static gint
-table_interface_get_row_extent_at (AtkTable *table,
- gint row,
- gint column)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- return calitem->cell_height;
-}
-
-/* any day in the row is selected, the row is selected */
-static gboolean
-table_interface_is_row_selected (AtkTable *table,
- gint row)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- gint n_rows;
- ECalendarItem *calitem;
- gint row_index_start, row_index_end;
- gint sel_index_start, sel_index_end;
-
- GDate start_date, end_date;
-
- g_return_val_if_fail (EA_IS_CALENDAR_ITEM (table), FALSE);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (table);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- n_rows = table_interface_get_n_rows (table);
- if (row < 0 || row >= n_rows)
- return FALSE;
-
- row_index_start = row * EA_CALENDAR_COLUMN_NUM;
- row_index_end = row_index_start + EA_CALENDAR_COLUMN_NUM - 1;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (!e_calendar_item_get_selection (calitem, &start_date, &end_date))
- return FALSE;
-
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date),
- &sel_index_start);
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&end_date),
- g_date_get_month (&end_date),
- g_date_get_day (&end_date),
- &sel_index_end);
-
- if ((sel_index_start < row_index_start &&
- sel_index_end >= row_index_start) ||
- (sel_index_start >= row_index_start &&
- sel_index_start <= row_index_end))
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-table_interface_is_selected (AtkTable *table,
- gint row,
- gint column)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- gint n_rows, n_columns;
- ECalendarItem *calitem;
- gint index;
- gint sel_index_start, sel_index_end;
-
- GDate start_date, end_date;
-
- g_return_val_if_fail (EA_IS_CALENDAR_ITEM (table), FALSE);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (table);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- n_rows = table_interface_get_n_rows (table);
- if (row < 0 || row >= n_rows)
- return FALSE;
- n_columns = table_interface_get_n_columns (table);
- if (column < 0 || column >= n_columns)
- return FALSE;
-
- index = table_interface_get_index_at (table, row, column);
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (!e_calendar_item_get_selection (calitem, &start_date, &end_date))
- return FALSE;
-
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date),
- g_date_get_day (&start_date),
- &sel_index_start);
- e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&end_date),
- g_date_get_month (&end_date),
- g_date_get_day (&end_date), &sel_index_end);
-
- if (sel_index_start <= index && sel_index_end >= index)
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-table_interface_is_column_selected (AtkTable *table,
- gint column)
-{
- return FALSE;
-}
-
-static gint
-table_interface_get_selected_rows (AtkTable *table,
- gint **rows_selected)
-{
- *rows_selected = NULL;
- return -1;
-}
-
-static gint
-table_interface_get_selected_columns (AtkTable *table,
- gint **columns_selected)
-{
- *columns_selected = NULL;
- return -1;
-}
-
-static gboolean
-table_interface_add_row_selection (AtkTable *table,
- gint row)
-{
- return FALSE;
-}
-
-static gboolean
-table_interface_remove_row_selection (AtkTable *table,
- gint row)
-{
- return FALSE;
-}
-
-static gboolean
-table_interface_add_column_selection (AtkTable *table,
- gint column)
-{
- return FALSE;
-}
-
-static gboolean
-table_interface_remove_column_selection (AtkTable *table,
- gint column)
-{
- /* FIXME: NOT IMPLEMENTED */
- return FALSE;
-}
-
-static AtkObject *
-table_interface_get_row_header (AtkTable *table,
- gint row)
-{
- /* FIXME: NOT IMPLEMENTED */
- return NULL;
-}
-
-static AtkObject *
-table_interface_get_column_header (AtkTable *table,
- gint in_col)
-{
- /* FIXME: NOT IMPLEMENTED */
- return NULL;
-}
-
-static AtkObject *
-table_interface_get_caption (AtkTable *table)
-{
- /* FIXME: NOT IMPLEMENTED */
- return NULL;
-}
-
-static const gchar *
-table_interface_get_column_description (AtkTable *table,
- gint in_col)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- const gchar *description = NULL;
- EaCellTable *cell_data;
- gint n_columns;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return NULL;
-
- n_columns = table_interface_get_n_columns (table);
- if (in_col < 0 || in_col >= n_columns)
- return NULL;
- cell_data = ea_calendar_item_get_cell_data (ea_calitem);
- if (!cell_data)
- return NULL;
-
- description = ea_cell_table_get_column_label (cell_data, in_col);
- if (!description) {
- gchar buffer[128] = "column description";
- ea_calendar_item_get_column_label (
- ea_calitem, in_col,
- buffer, sizeof (buffer));
- ea_cell_table_set_column_label (cell_data, in_col, buffer);
- description = ea_cell_table_get_column_label (
- cell_data, in_col);
- }
- return description;
-}
-
-static const gchar *
-table_interface_get_row_description (AtkTable *table,
- gint row)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (table);
- const gchar *description = NULL;
- EaCellTable *cell_data;
- gint n_rows;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return NULL;
-
- n_rows = table_interface_get_n_rows (table);
- if (row < 0 || row >= n_rows)
- return NULL;
- cell_data = ea_calendar_item_get_cell_data (ea_calitem);
- if (!cell_data)
- return NULL;
-
- description = ea_cell_table_get_row_label (cell_data, row);
- if (!description) {
- gchar buffer[128] = "row description";
- ea_calendar_item_get_row_label (
- ea_calitem, row,
- buffer, sizeof (buffer));
- ea_cell_table_set_row_label (cell_data, row, buffer);
- description = ea_cell_table_get_row_label (
- cell_data,
- row);
- }
- return description;
-}
-
-static AtkObject *
-table_interface_get_summary (AtkTable *table)
-{
- /* FIXME: NOT IMPLEMENTED */
- return NULL;
-}
-
-/* atkselection interface */
-
-static void
-atk_selection_interface_init (AtkSelectionIface *iface)
-{
- g_return_if_fail (iface != NULL);
-
- iface->add_selection = selection_interface_add_selection;
- iface->clear_selection = selection_interface_clear_selection;
- iface->ref_selection = selection_interface_ref_selection;
- iface->get_selection_count = selection_interface_get_selection_count;
- iface->is_child_selected = selection_interface_is_child_selected;
-}
-
-static gboolean
-selection_interface_add_selection (AtkSelection *selection,
- gint index)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (selection);
- gint year, month, day;
- GDate start_date, end_date;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (!e_calendar_item_get_date_for_offset (calitem, index,
- &year, &month, &day))
- return FALSE;
-
- /* FIXME: not support mulit-selection */
- g_date_set_dmy (&start_date, day, month + 1, year);
- end_date = start_date;
- e_calendar_item_set_selection (calitem, &start_date, &end_date);
- return TRUE;
-}
-
-static gboolean
-selection_interface_clear_selection (AtkSelection *selection)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (selection);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- e_calendar_item_set_selection (calitem, NULL, NULL);
-
- return TRUE;
-}
-
-static AtkObject *
-selection_interface_ref_selection (AtkSelection *selection,
- gint i)
-{
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (selection);
- gint count, sel_offset;
- GDate start_date, end_date;
-
- count = selection_interface_get_selection_count (selection);
- if (i < 0 || i >= count)
- return NULL;
-
- g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_calitem));
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (!e_calendar_item_get_selection (calitem, &start_date, &end_date))
- return NULL;
- if (!e_calendar_item_get_offset_for_date (calitem,
- g_date_get_year (&start_date),
- g_date_get_month (&start_date) - 1,
- g_date_get_day (&start_date),
- &sel_offset))
- return NULL;
-
- return ea_calendar_item_ref_child (ATK_OBJECT (selection), sel_offset + i);
-}
-
-static gint
-selection_interface_get_selection_count (AtkSelection *selection)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (selection);
- GDate start_date, end_date;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return 0;
-
- calitem = E_CALENDAR_ITEM (g_obj);
- if (e_calendar_item_get_selection (calitem, &start_date, &end_date))
- return g_date_days_between (&start_date, &end_date) + 1;
- else
- return 0;
-}
-
-static gboolean
-selection_interface_is_child_selected (AtkSelection *selection,
- gint index)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCalendarItem * ea_calitem = EA_CALENDAR_ITEM (selection);
- gint row, column, n_children;
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- n_children = atk_object_get_n_accessible_children (ATK_OBJECT (selection));
- if (index < 0 || index >= n_children)
- return FALSE;
-
- row = index / EA_CALENDAR_COLUMN_NUM;
- column = index % EA_CALENDAR_COLUMN_NUM;
-
- return table_interface_is_selected (ATK_TABLE (selection), row, column);
-}
-
-/* callbacks */
-
-static void
-selection_preview_change_cb (ECalendarItem *calitem)
-{
- AtkObject *atk_obj;
- AtkObject *item_cell;
-
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
- atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
- ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj));
-
- /* only deal with the first selected child, for now */
- item_cell = atk_selection_ref_selection (
- ATK_SELECTION (atk_obj), 0);
-
- if (item_cell)
- ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell);
-
- g_signal_emit_by_name (
- atk_obj,
- "active-descendant-changed",
- item_cell);
- g_signal_emit_by_name (atk_obj, "selection_changed");
-}
-
-static void
-date_range_changed_cb (ECalendarItem *calitem)
-{
- AtkObject *atk_obj;
- AtkObject *item_cell;
-
- g_return_if_fail (E_IS_CALENDAR_ITEM (calitem));
- atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
- ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj));
-
- item_cell = atk_selection_ref_selection (
- ATK_SELECTION (atk_obj), 0);
- if (item_cell)
- ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell);
-
- g_signal_emit_by_name (atk_obj, "model_changed");
-}
-
-/* helpers */
-
-static EaCellTable *
-ea_calendar_item_get_cell_data (EaCalendarItem *ea_calitem)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- EaCellTable *cell_data;
-
- g_return_val_if_fail (ea_calitem, NULL);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return NULL;
-
- cell_data = g_object_get_data (
- G_OBJECT (ea_calitem),
- "ea-calendar-cell-table");
-
- if (!cell_data) {
- gint n_cells = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem));
- cell_data = ea_cell_table_create (
- n_cells / EA_CALENDAR_COLUMN_NUM,
- EA_CALENDAR_COLUMN_NUM,
- FALSE);
- g_object_set_data (
- G_OBJECT (ea_calitem),
- "ea-calendar-cell-table", cell_data);
- }
- return cell_data;
-}
-
-static void
-ea_calendar_item_destory_cell_data (EaCalendarItem *ea_calitem)
-{
- EaCellTable *cell_data;
-
- g_return_if_fail (ea_calitem);
-
- cell_data = g_object_get_data (
- G_OBJECT (ea_calitem),
- "ea-calendar-cell-table");
- if (cell_data) {
- g_object_set_data (
- G_OBJECT (ea_calitem),
- "ea-calendar-cell-table", NULL);
- ea_cell_table_destroy (cell_data);
- }
-}
-
-static gboolean
-ea_calendar_item_get_row_label (EaCalendarItem *ea_calitem,
- gint row,
- gchar *buffer,
- gint buffer_size)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- ECalendarItem *calitem;
- gint index, week_num;
- gint year, month, day;
-
- g_return_val_if_fail (ea_calitem, FALSE);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- calitem = E_CALENDAR_ITEM (g_obj);
-
- index = atk_table_get_index_at (ATK_TABLE (ea_calitem), row, 0);
- if (!e_calendar_item_get_date_for_offset (calitem, index,
- &year, &month, &day))
- return FALSE;
-
- week_num = e_calendar_item_get_week_number (
- calitem, day, month, year);
-
- g_snprintf (buffer, buffer_size, "week number : %d", week_num);
- return TRUE;
-}
-
-static gboolean
-ea_calendar_item_get_column_label (EaCalendarItem *ea_calitem,
- gint column,
- gchar *buffer,
- gint buffer_size)
-{
- AtkGObjectAccessible *atk_gobj;
- GObject *g_obj;
- const gchar *abbr_name;
-
- g_return_val_if_fail (ea_calitem, FALSE);
-
- atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem);
- g_obj = atk_gobject_accessible_get_object (atk_gobj);
- if (!g_obj)
- return FALSE;
-
- /* Columns are 0 = Monday ... 6 = Sunday */
- abbr_name = e_get_weekday_name (column + 1, TRUE);
- g_strlcpy (buffer, abbr_name, buffer_size);
-
- return TRUE;
-}
-
-/* the coordinate the e-calendar canvas coord */
-gboolean
-e_calendar_item_get_day_extents (ECalendarItem *calitem,
- gint year,
- gint month,
- gint date,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
-{
- GnomeCanvasItem *item;
- GtkWidget *widget;
- GtkStyle *style;
- PangoFontDescription *font_desc;
- PangoContext *pango_context;
- PangoFontMetrics *font_metrics;
- gint char_height, xthickness, ythickness, text_y;
- gint new_year, new_month, num_months, months_offset;
- gint month_x, month_y, month_cell_x, month_cell_y;
- gint month_row, month_col;
- gint day_row, day_col;
- gint days_from_week_start;
-
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE);
-
- item = GNOME_CANVAS_ITEM (calitem);
- widget = GTK_WIDGET (item->canvas);
- style = gtk_widget_get_style (widget);
-
- /* Set up Pango prerequisites */
- font_desc = calitem->font_desc;
- if (!font_desc)
- font_desc = style->font_desc;
- pango_context = gtk_widget_get_pango_context (widget);
- font_metrics = pango_context_get_metrics (
- pango_context, font_desc,
- pango_context_get_language (pango_context));
-
- char_height =
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-
- new_year = year;
- new_month = month;
- e_calendar_item_normalize_date (calitem, &new_year, &new_month);
- num_months = calitem->rows * calitem->cols;
- months_offset = (new_year - calitem->year) * 12
- + new_month - calitem->month;
-
- if (months_offset > num_months || months_offset < 0)
- return FALSE;
-
- month_row = months_offset / calitem->cols;
- month_col = months_offset % calitem->cols;
-
- month_x = item->x1 + xthickness + calitem->x_offset
- + month_col * calitem->month_width;
- month_y = item->y1 + ythickness + month_row * calitem->month_height;
-
- month_cell_x = month_x + E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS
- + calitem->month_lpad + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS;
- text_y = month_y + ythickness * 2
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME
- + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME
- + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad;
-
- month_cell_y = text_y + char_height
- + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1
- + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS;
-
- days_from_week_start = e_calendar_item_get_n_days_from_week_start (
- calitem, new_year, new_month);
- day_row = (date + days_from_week_start - 1) / EA_CALENDAR_COLUMN_NUM;
- day_col = (date + days_from_week_start - 1) % EA_CALENDAR_COLUMN_NUM;
-
- *x = month_cell_x + day_col * calitem->cell_width;
- *y = month_cell_y + day_row * calitem->cell_height;
- *width = calitem->cell_width;
- *height = calitem->cell_height;
-
- return TRUE;
-}
-
-/* month is from 0 to 11 */
-gboolean
-e_calendar_item_get_date_for_offset (ECalendarItem *calitem,
- gint day_offset,
- gint *year,
- gint *month,
- gint *day)
-{
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- GDate *start_date;
-
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE);
-
- if (!e_calendar_item_get_date_range (calitem, &start_year,
- &start_month, &start_day,
- &end_year, &end_month,
- &end_day))
- return FALSE;
-
- start_date = g_date_new_dmy (start_day, start_month + 1, start_year);
-
- g_date_add_days (start_date, day_offset);
-
- *year = g_date_get_year (start_date);
- *month = g_date_get_month (start_date) - 1;
- *day = g_date_get_day (start_date);
-
- return TRUE;
-}
-
-/* the arg month is from 0 to 11 */
-static gboolean
-e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
- gint year,
- gint month,
- gint day,
- gint *offset)
-{
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- GDate *start_date, *end_date;
-
- *offset = 0;
- g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE);
-
- if (!e_calendar_item_get_date_range (calitem, &start_year,
- &start_month, &start_day,
- &end_year, &end_month,
- &end_day))
- return FALSE;
-
- start_date = g_date_new_dmy (start_day, start_month + 1, start_year);
- end_date = g_date_new_dmy (day, month + 1, year);
-
- *offset = g_date_days_between (start_date, end_date);
- g_free (start_date);
- g_free (end_date);
-
- return TRUE;
-}
-
-gint
-e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem,
- gint year,
- gint month)
-{
- struct tm tmp_tm;
- gint start_weekday, days_from_week_start;
-
- memset (&tmp_tm, 0, sizeof (tmp_tm));
- tmp_tm.tm_year = year - 1900;
- tmp_tm.tm_mon = month;
- tmp_tm.tm_mday = 1;
- tmp_tm.tm_isdst = -1;
- mktime (&tmp_tm);
- start_weekday = (tmp_tm.tm_wday + 6) % 7; /* 0 to 6 */
- days_from_week_start = (start_weekday + 7 - calitem->week_start_day)
- % 7;
- return days_from_week_start;
-}
-
-static void
-ea_calendar_set_focus_object (EaCalendarItem *ea_calitem,
- AtkObject *item_cell)
-{
- AtkStateSet *state_set, *old_state_set;
- AtkObject *old_cell;
-
- old_cell = (AtkObject *) g_object_get_data (
- G_OBJECT (ea_calitem), "gail-focus-object");
- if (old_cell && EA_IS_CALENDAR_CELL (old_cell)) {
- old_state_set = atk_object_ref_state_set (old_cell);
- atk_state_set_remove_state (old_state_set, ATK_STATE_FOCUSED);
- g_object_unref (old_state_set);
- }
- if (old_cell)
- g_object_unref (old_cell);
-
- state_set = atk_object_ref_state_set (item_cell);
- atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
- g_object_set_data (G_OBJECT (ea_calitem), "gail-focus-object", item_cell);
- g_object_unref (state_set);
-}
diff --git a/widgets/misc/ea-calendar-item.h b/widgets/misc/ea-calendar-item.h
deleted file mode 100644
index b5271a9f8b..0000000000
--- a/widgets/misc/ea-calendar-item.h
+++ /dev/null
@@ -1,67 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __EA_CALENDAR_ITEM_H__
-#define __EA_CALENDAR_ITEM_H__
-
-#include <atk/atkgobjectaccessible.h>
-#include <misc/e-calendar-item.h>
-
-G_BEGIN_DECLS
-
-#define EA_TYPE_CALENDAR_ITEM (ea_calendar_item_get_type ())
-#define EA_CALENDAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItem))
-#define EA_CALENDAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass))
-#define EA_IS_CALENDAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CALENDAR_ITEM))
-#define EA_IS_CALENDAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CALENDAR_ITEM))
-#define EA_CALENDAR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass))
-
-typedef struct _EaCalendarItem EaCalendarItem;
-typedef struct _EaCalendarItemClass EaCalendarItemClass;
-
-struct _EaCalendarItem
-{
- AtkGObjectAccessible parent;
-};
-
-GType ea_calendar_item_get_type (void);
-
-struct _EaCalendarItemClass
-{
- AtkGObjectAccessibleClass parent_class;
-};
-
-AtkObject *ea_calendar_item_new (GObject *obj);
-gboolean e_calendar_item_get_day_extents (ECalendarItem *calitem,
- gint year, gint month, gint date,
- gint *x, gint *y,
- gint *width, gint *height);
-gboolean e_calendar_item_get_date_for_offset (ECalendarItem *calitem,
- gint day_offset,
- gint *year, gint *month,
- gint *day);
-gint e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem,
- gint year, gint month);
-
-G_END_DECLS
-
-#endif /* __EA_CALENDAR_ITEM_H__ */
diff --git a/widgets/misc/ea-cell-table.c b/widgets/misc/ea-cell-table.c
deleted file mode 100644
index bbdef0aea1..0000000000
--- a/widgets/misc/ea-cell-table.c
+++ /dev/null
@@ -1,215 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ea-cell-table.h"
-
-EaCellTable *
-ea_cell_table_create (gint rows,
- gint columns,
- gboolean column_first)
-{
- EaCellTable *cell_data;
- gint index;
-
- g_return_val_if_fail (((columns > 0) && (rows > 0)), NULL);
-
- cell_data = g_new0 (EaCellTable, 1);
-
- cell_data->column_first = column_first;
- cell_data->columns = columns;
- cell_data->rows = rows;
-
- cell_data->column_labels = g_new0 (gchar *, columns);
- for (index = columns -1; index >= 0; --index)
- cell_data->column_labels[index] = NULL;
-
- cell_data->row_labels = g_new0 (gchar *, rows);
- for (index = rows -1; index >= 0; --index)
- cell_data->row_labels[index] = NULL;
-
- cell_data->cells = g_new0 (gpointer, (columns * rows));
- for (index = (columns * rows) -1; index >= 0; --index)
- cell_data->cells[index] = NULL;
- return cell_data;
-}
-
-void
-ea_cell_table_destroy (EaCellTable *cell_data)
-{
- gint index;
- g_return_if_fail (cell_data);
-
- for (index = 0; index < cell_data->columns; ++index)
- if (cell_data->column_labels[index])
- g_free (cell_data->column_labels[index]);
- g_free (cell_data->column_labels);
-
- for (index = 0; index < cell_data->rows; ++index)
- if (cell_data->row_labels[index])
- g_free (cell_data->row_labels[index]);
- g_free (cell_data->row_labels);
-
- for (index = (cell_data->columns * cell_data->rows) -1;
- index >= 0; --index)
- if (cell_data->cells[index] &&
- G_IS_OBJECT (cell_data->cells[index]))
- g_object_unref (cell_data->cells[index]);
-
- g_free (cell_data->cells);
-}
-
-gpointer
-ea_cell_table_get_cell (EaCellTable *cell_data,
- gint row,
- gint column)
-{
- gint index;
-
- g_return_val_if_fail (cell_data, NULL);
-
- index = ea_cell_table_get_index (cell_data, column, row);
- if (index == -1)
- return NULL;
-
- return cell_data->cells[index];
-}
-
-gboolean
-ea_cell_table_set_cell (EaCellTable *cell_data,
- gint row,
- gint column,
- gpointer cell)
-{
- gint index;
-
- g_return_val_if_fail (cell_data, FALSE);
-
- index = ea_cell_table_get_index (cell_data, column, row);
- if (index == -1)
- return FALSE;
-
- if (cell && G_IS_OBJECT (cell))
- g_object_ref (cell);
- if (cell_data->cells[index] &&
- G_IS_OBJECT (cell_data->cells[index]))
- g_object_unref (cell_data->cells[index]);
- cell_data->cells[index] = cell;
-
- return TRUE;
-}
-
-gpointer
-ea_cell_table_get_cell_at_index (EaCellTable *cell_data,
- gint index)
-{
- g_return_val_if_fail (cell_data, NULL);
-
- if (index >=0 && index < (cell_data->columns * cell_data->rows))
- return cell_data->cells[index];
- return NULL;
-}
-
-gboolean
-ea_cell_table_set_cell_at_index (EaCellTable *cell_data,
- gint index,
- gpointer cell)
-{
- g_return_val_if_fail (cell_data, FALSE);
-
- if (index < 0 || index >=cell_data->columns * cell_data->rows)
- return FALSE;
-
- if (cell && G_IS_OBJECT (cell))
- g_object_ref (cell);
- if (cell_data->cells[index] &&
- G_IS_OBJECT (cell_data->cells[index]))
- g_object_unref (cell_data->cells[index]);
- cell_data->cells[index] = cell;
-
- return TRUE;
-}
-
-const gchar *
-ea_cell_table_get_column_label (EaCellTable *cell_data,
- gint column)
-{
- g_return_val_if_fail (cell_data, NULL);
- g_return_val_if_fail ((column >= 0 && column < cell_data->columns), NULL);
-
- return cell_data->column_labels[column];
-}
-
-void
-ea_cell_table_set_column_label (EaCellTable *cell_data,
- gint column,
- const gchar *label)
-{
- g_return_if_fail (cell_data);
- g_return_if_fail ((column >= 0 && column < cell_data->columns));
-
- if (cell_data->column_labels[column])
- g_free (cell_data->column_labels[column]);
- cell_data->column_labels[column] = g_strdup (label);
-}
-
-const gchar *
-ea_cell_table_get_row_label (EaCellTable *cell_data,
- gint row)
-{
- g_return_val_if_fail (cell_data, NULL);
- g_return_val_if_fail ((row >= 0 && row < cell_data->rows), NULL);
-
- return cell_data->row_labels[row];
-}
-
-void
-ea_cell_table_set_row_label (EaCellTable *cell_data,
- gint row,
- const gchar *label)
-{
- g_return_if_fail (cell_data);
- g_return_if_fail ((row >= 0 && row < cell_data->rows));
-
- if (cell_data->row_labels[row])
- g_free (cell_data->row_labels[row]);
- cell_data->row_labels[row] = g_strdup (label);
-}
-
-gint
-ea_cell_table_get_index (EaCellTable *cell_data,
- gint row,
- gint column)
-{
- g_return_val_if_fail (cell_data, -1);
- if (row < 0 || row >= cell_data->rows ||
- column < 0 || column >= cell_data->columns)
- return -1;
-
- if (cell_data->column_first)
- return column * cell_data->rows + row;
- else
- return row * cell_data->columns + column;
-}
diff --git a/widgets/misc/ea-cell-table.h b/widgets/misc/ea-cell-table.h
deleted file mode 100644
index a13d7a52c7..0000000000
--- a/widgets/misc/ea-cell-table.h
+++ /dev/null
@@ -1,59 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* EaCellTable */
-
-#include <glib-object.h>
-
-struct _EaCellTable {
- gint columns;
- gint rows;
- gboolean column_first; /* index order */
- gchar **column_labels;
- gchar **row_labels;
- gpointer *cells;
-};
-
-typedef struct _EaCellTable EaCellTable;
-
-EaCellTable * ea_cell_table_create (gint rows, gint columns,
- gboolean column_first);
-void ea_cell_table_destroy (EaCellTable * cell_data);
-gpointer ea_cell_table_get_cell (EaCellTable * cell_data,
- gint row, gint column);
-gboolean ea_cell_table_set_cell (EaCellTable * cell_data,
- gint row, gint column, gpointer cell);
-gpointer ea_cell_table_get_cell_at_index (EaCellTable * cell_data,
- gint index);
-gboolean ea_cell_table_set_cell_at_index (EaCellTable * cell_data,
- gint index, gpointer cell);
-
-const gchar *
-ea_cell_table_get_column_label (EaCellTable * cell_data, gint column);
-void ea_cell_table_set_column_label (EaCellTable * cell_data,
- gint column, const gchar *label);
-const gchar *
-ea_cell_table_get_row_label (EaCellTable * cell_data, gint row);
-void ea_cell_table_set_row_label (EaCellTable * cell_data,
- gint row, const gchar *label);
-gint ea_cell_table_get_index (EaCellTable *cell_data,
- gint row, gint column);
diff --git a/widgets/misc/ea-widgets.c b/widgets/misc/ea-widgets.c
deleted file mode 100644
index 1b74d44fd2..0000000000
--- a/widgets/misc/ea-widgets.c
+++ /dev/null
@@ -1,36 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "a11y/ea-factory.h"
-#include "ea-calendar-item.h"
-#include "ea-widgets.h"
-
-EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new)
-
-void e_calendar_item_a11y_init (void)
-{
- EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item);
-}
diff --git a/widgets/misc/ea-widgets.h b/widgets/misc/ea-widgets.h
deleted file mode 100644
index 495222ae05..0000000000
--- a/widgets/misc/ea-widgets.h
+++ /dev/null
@@ -1,32 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Bolian Yin <bolian.yin@sun.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* Evolution Accessibility
-*/
-
-#ifndef _EA_WIDGETS_H__
-#define _EA_WIDGETS_H__
-
-void e_calendar_item_a11y_init (void);
-
-#endif /* _EA_WIDGETS_H__ */
diff --git a/widgets/misc/test-calendar.c b/widgets/misc/test-calendar.c
deleted file mode 100644
index 7d3584a424..0000000000
--- a/widgets/misc/test-calendar.c
+++ /dev/null
@@ -1,146 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/*
- * test-calendar - tests the ECalendar widget.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include "e-calendar.h"
-
-/* Drag and Drop stuff. */
-enum {
- TARGET_SHORTCUT
-};
-
-static GtkTargetEntry target_table[] = {
- { (gchar *) "E-SHORTCUT", 0, TARGET_SHORTCUT }
-};
-
-static void on_date_range_changed (ECalendarItem *calitem);
-static void on_selection_changed (ECalendarItem *calitem);
-
-static void
-delete_event_cb (GtkWidget *widget,
- GdkEventAny *event,
- gpointer data)
-{
- gtk_main_quit ();
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- GtkWidget *window;
- GtkWidget *cal;
- GtkWidget *vbox;
- ECalendarItem *calitem;
-
- gtk_init (&argc, &argv);
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), "ECalendar Test");
- gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
- gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-
- g_signal_connect (
- window, "delete_event",
- G_CALLBACK (delete_event_cb), NULL);
-
- cal = e_calendar_new ();
- e_calendar_set_minimum_size (E_CALENDAR (cal), 1, 1);
- calitem = E_CALENDAR (cal)->calitem;
- gtk_widget_show (cal);
-
- g_signal_connect (
- calitem, "date_range_changed",
- G_CALLBACK (on_date_range_changed), NULL);
- g_signal_connect (
- calitem, "selection_changed",
- G_CALLBACK (on_selection_changed), NULL);
-
- gtk_drag_dest_set (
- cal,
- GTK_DEST_DEFAULT_ALL,
- target_table, G_N_ELEMENTS (target_table),
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), cal, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_widget_show (window);
-
- gtk_main ();
-
- return 0;
-}
-
-static void
-on_date_range_changed (ECalendarItem *calitem)
-{
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
-
- e_calendar_item_get_date_range (
- calitem,
- &start_year, &start_month, &start_day,
- &end_year, &end_month, &end_day);
-
- g_print (
- "Date range changed (D/M/Y): %i/%i/%i - %i/%i/%i\n",
- start_day, start_month + 1, start_year,
- end_day, end_month + 1, end_year);
-
- /* These days should windowear bold. Remember month is 0 to 11. */
- e_calendar_item_mark_day (
- calitem, 2000, 7, 26, /* 26th Aug 2000. */
- E_CALENDAR_ITEM_MARK_BOLD, FALSE);
- e_calendar_item_mark_day (
- calitem, 2000, 8, 13, /* 13th Sep 2000. */
- E_CALENDAR_ITEM_MARK_BOLD, FALSE);
-}
-
-static void
-on_selection_changed (ECalendarItem *calitem)
-{
- GDate start_date, end_date;
-
- e_calendar_item_get_selection (calitem, &start_date, &end_date);
-
- g_print (
- "Selection changed (D/M/Y): %i/%i/%i - %i/%i/%i\n",
- g_date_get_day (&start_date),
- g_date_get_month (&start_date),
- g_date_get_year (&start_date),
- g_date_get_day (&end_date),
- g_date_get_month (&end_date),
- g_date_get_year (&end_date));
-}
diff --git a/widgets/misc/test-dateedit.c b/widgets/misc/test-dateedit.c
deleted file mode 100644
index 5592afbc70..0000000000
--- a/widgets/misc/test-dateedit.c
+++ /dev/null
@@ -1,299 +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 <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/*
- * test-dateedit - tests the EDateEdit widget.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include "e-dateedit.h"
-
-static void delete_event_cb (GtkWidget *widget,
- GdkEventAny *event,
- GtkWidget *window);
-static void on_get_date_clicked (GtkWidget *button,
- EDateEdit *dedit);
-static void on_toggle_24_hour_clicked (GtkWidget *button,
- EDateEdit *dedit);
-static void on_changed (EDateEdit *dedit,
- gchar *name);
-#if 0
-static void on_date_changed (EDateEdit *dedit,
- gchar *name);
-static void on_time_changed (EDateEdit *dedit,
- gchar *name);
-#endif
-
-gint
-main (gint argc,
- gchar **argv)
-{
- GtkWidget *window;
- EDateEdit *dedit;
- GtkWidget *table, *button;
-
- gtk_init (&argc, &argv);
-
- puts ("here");
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), "EDateEdit Test");
- gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
- gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-
- g_signal_connect (
- window, "delete_event",
- G_CALLBACK (delete_event_cb), window);
-
- table = gtk_table_new (3, 3, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_widget_show (table);
-
- gtk_container_add (GTK_CONTAINER (window), table);
-
- /* EDateEdit 1. */
- dedit = E_DATE_EDIT (e_date_edit_new ());
- gtk_table_attach (
- GTK_TABLE (table), GTK_WIDGET (dedit),
- 0, 1, 0, 1, GTK_FILL, GTK_EXPAND, 0, 0);
- gtk_widget_show (GTK_WIDGET (dedit));
-
-#if 0
- g_signal_connect (
- dedit, "date_changed",
- G_CALLBACK (on_date_changed), (gpointer) "1");
- g_signal_connect (
- dedit, "time_changed",
- G_CALLBACK (on_time_changed), (gpointer) "1");
-#else
- g_signal_connect (
- dedit, "changed",
- G_CALLBACK (on_changed), (gpointer) "1");
-#endif
-
- button = gtk_button_new_with_label ("Print Date");
- gtk_table_attach (
- GTK_TABLE (table), button,
- 1, 2, 0, 1, 0, 0, 0, 0);
- gtk_widget_show (button);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (on_get_date_clicked), dedit);
-
- /* EDateEdit 2. */
- dedit = E_DATE_EDIT (e_date_edit_new ());
- gtk_table_attach (
- GTK_TABLE (table), (GtkWidget *) dedit,
- 0, 1, 1, 2, GTK_FILL, GTK_EXPAND, 0, 0);
- gtk_widget_show ((GtkWidget *) (dedit));
- e_date_edit_set_week_start_day (dedit, 1);
- e_date_edit_set_show_week_numbers (dedit, TRUE);
- e_date_edit_set_use_24_hour_format (dedit, FALSE);
- e_date_edit_set_time_popup_range (dedit, 8, 18);
- e_date_edit_set_show_time (dedit, FALSE);
-
-#if 0
- g_signal_connect (
- dedit, "date_changed",
- G_CALLBACK (on_date_changed), (gpointer) "2");
- g_signal_connect (
- dedit, "time_changed",
- G_CALLBACK (on_time_changed), (gpointer) "2");
-#else
- g_signal_connect (
- dedit, "changed",
- G_CALLBACK (on_changed), (gpointer) "2");
-#endif
-
- button = gtk_button_new_with_label ("Print Date");
- gtk_table_attach (
- GTK_TABLE (table), button,
- 1, 2, 1, 2, 0, 0, 0, 0);
- gtk_widget_show (button);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (on_get_date_clicked), dedit);
-
- /* EDateEdit 3. */
- dedit = E_DATE_EDIT (e_date_edit_new ());
- gtk_table_attach (
- GTK_TABLE (table), (GtkWidget *) dedit,
- 0, 1, 2, 3, GTK_FILL, GTK_EXPAND, 0, 0);
- gtk_widget_show ((GtkWidget *) (dedit));
- e_date_edit_set_week_start_day (dedit, 1);
- e_date_edit_set_show_week_numbers (dedit, TRUE);
- e_date_edit_set_use_24_hour_format (dedit, FALSE);
- e_date_edit_set_time_popup_range (dedit, 8, 18);
- e_date_edit_set_allow_no_date_set (dedit, TRUE);
-
-#if 0
- g_signal_connect (
- dedit, "date_changed",
- G_CALLBACK (on_date_changed), (gpointer) "3");
- g_signal_connect (
- dedit, "time_changed",
- G_CALLBACK (on_time_changed), (gpointer) "3");
-#else
- g_signal_connect (
- dedit, "changed",
- G_CALLBACK (on_changed), (gpointer) "3");
-#endif
-
- button = gtk_button_new_with_label ("Print Date");
- gtk_table_attach (
- GTK_TABLE (table), button,
- 1, 2, 2, 3, 0, 0, 0, 0);
- gtk_widget_show (button);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (on_get_date_clicked), dedit);
-
- button = gtk_button_new_with_label ("Toggle 24-hour");
- gtk_table_attach (
- GTK_TABLE (table), button,
- 2, 3, 2, 3, 0, 0, 0, 0);
- gtk_widget_show (button);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (on_toggle_24_hour_clicked), dedit);
-
- gtk_widget_show (window);
-
- gtk_main ();
-
- return 0;
-}
-
-static void
-delete_event_cb (GtkWidget *widget,
- GdkEventAny *event,
- GtkWidget *window)
-{
- gtk_widget_destroy (window);
-
- gtk_main_quit ();
-}
-
-static void
-on_get_date_clicked (GtkWidget *button,
- EDateEdit *dedit)
-{
- time_t t;
-
- t = e_date_edit_get_time (dedit);
- if (t == -1)
- g_print ("Time: None\n");
- else
- g_print ("Time: %s", ctime (&t));
-
- if (!e_date_edit_date_is_valid (dedit))
- g_print (" Date invalid\n");
-
- if (!e_date_edit_time_is_valid (dedit))
- g_print (" Time invalid\n");
-}
-
-static void
-on_toggle_24_hour_clicked (GtkWidget *button,
- EDateEdit *dedit)
-{
- gboolean use_24_hour_format;
-
- use_24_hour_format = e_date_edit_get_use_24_hour_format (dedit);
- e_date_edit_set_use_24_hour_format (dedit, !use_24_hour_format);
-}
-
-#if 0
-static void
-on_date_changed (EDateEdit *dedit,
- gchar *name)
-{
- gint year, month, day;
-
- if (e_date_edit_date_is_valid (dedit)) {
- if (e_date_edit_get_date (dedit, &year, &month, &day)) {
- g_print (
- "Date %s changed to: %i/%i/%i (M/D/Y)\n",
- name, month, day, year);
- } else {
- g_print ("Date %s changed to: None\n", name);
- }
- } else {
- g_print ("Date %s changed to: Not Valid\n", name);
- }
-}
-
-static void
-on_time_changed (EDateEdit *dedit,
- gchar *name)
-{
- gint hour, minute;
-
- if (e_date_edit_time_is_valid (dedit)) {
- if (e_date_edit_get_time_of_day (dedit, &hour, &minute)) {
- g_print (
- "Time %s changed to: %02i:%02i\n", name,
- hour, minute);
- } else {
- g_print ("Time %s changed to: None\n", name);
- }
- } else {
- g_print ("Time %s changed to: Not Valid\n", name);
- }
-}
-#endif
-
-static void
-on_changed (EDateEdit *dedit,
- gchar *name)
-{
- gint year, month, day, hour, minute;
-
- g_print ("Date %s changed ", name);
-
- if (e_date_edit_date_is_valid (dedit)) {
- if (e_date_edit_get_date (dedit, &year, &month, &day)) {
- g_print ("M/D/Y: %i/%i/%i", month, day, year);
- } else {
- g_print ("None");
- }
- } else {
- g_print ("Date Invalid");
- }
-
- if (e_date_edit_time_is_valid (dedit)) {
- if (e_date_edit_get_time_of_day (dedit, &hour, &minute)) {
- g_print (" %02i:%02i\n", hour, minute);
- } else {
- g_print (" None\n");
- }
- } else {
- g_print (" Time Invalid\n");
- }
-}
-
diff --git a/widgets/misc/test-mail-signatures.c b/widgets/misc/test-mail-signatures.c
deleted file mode 100644
index 597e77effb..0000000000
--- a/widgets/misc/test-mail-signatures.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * test-mail-signatures.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include <stdlib.h>
-
-#include <libedataserver/libedataserver.h>
-
-#include <libevolution-utils/e-alert-sink.h>
-#include <misc/e-mail-identity-combo-box.h>
-#include <misc/e-mail-signature-combo-box.h>
-#include <misc/e-mail-signature-manager.h>
-#include <misc/e-mail-signature-preview.h>
-
-static GCancellable *cancellable = NULL;
-
-static void
-signature_loaded_cb (EMailSignatureComboBox *combo_box,
- GAsyncResult *result,
- EWebView *web_view)
-{
- gchar *contents = NULL;
- gboolean is_html;
- GError *error = NULL;
-
- e_mail_signature_combo_box_load_selected_finish (
- combo_box, result, &contents, NULL, &is_html, &error);
-
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (contents == NULL);
- g_object_unref (web_view);
- g_error_free (error);
- return;
-
- } else if (error != NULL) {
- g_warn_if_fail (contents == NULL);
- e_alert_submit (
- E_ALERT_SINK (web_view),
- "widgets:no-load-signature",
- error->message, NULL);
- g_object_unref (web_view);
- g_error_free (error);
- return;
- }
-
- if (contents == NULL)
- e_web_view_clear (web_view);
- else if (is_html)
- e_web_view_load_string (web_view, contents);
- else {
- gchar *string;
-
- string = g_markup_printf_escaped ("<pre>%s</pre>", contents);
- e_web_view_load_string (web_view, string);
- g_free (string);
- }
-
- g_free (contents);
-
- g_object_unref (web_view);
-}
-
-static void
-signature_combo_changed_cb (EMailSignatureComboBox *combo_box,
- EWebView *web_view)
-{
- if (cancellable != NULL) {
- g_cancellable_cancel (cancellable);
- g_object_unref (cancellable);
- }
-
- cancellable = g_cancellable_new ();
-
- e_mail_signature_combo_box_load_selected (
- combo_box, G_PRIORITY_DEFAULT, cancellable,
- (GAsyncReadyCallback) signature_loaded_cb,
- g_object_ref (web_view));
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- ESourceRegistry *registry;
- GtkWidget *container;
- GtkWidget *widget;
- GtkWidget *vbox;
- GtkWidget *identity_combo;
- GtkWidget *signature_combo;
- GError *error = NULL;
-
- gtk_init (&argc, &argv);
-
- registry = e_source_registry_new_sync (NULL, &error);
-
- if (error != NULL) {
- g_printerr ("%s\n", error->message);
- exit (EXIT_FAILURE);
- }
-
- /* Construct the widgets. */
-
- widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (widget), "Mail Signatures");
- gtk_window_set_default_size (GTK_WINDOW (widget), 400, 400);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
- gtk_widget_show (widget);
-
- g_signal_connect (
- widget, "delete-event",
- G_CALLBACK (gtk_main_quit), NULL);
-
- container = widget;
-
- widget = gtk_vbox_new (FALSE, 12);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- container = vbox = widget;
-
- widget = gtk_label_new ("<b>EMailSignatureComboBox</b>");
- gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = gtk_vbox_new (FALSE, 6);
- gtk_widget_set_margin_left (widget, 12);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_mail_signature_combo_box_new (registry);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- signature_combo = widget;
- gtk_widget_show (widget);
-
- widget = e_mail_identity_combo_box_new (registry);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- identity_combo = 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_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_web_view_new ();
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- g_signal_connect (
- signature_combo, "changed",
- G_CALLBACK (signature_combo_changed_cb), widget);
-
- container = vbox;
-
- widget = gtk_label_new ("<b>EMailSignatureManager</b>");
- gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- widget = e_mail_signature_manager_new (registry);
- gtk_widget_set_margin_left (widget, 12);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- g_object_bind_property (
- identity_combo, "active-id",
- signature_combo, "identity-uid",
- G_BINDING_SYNC_CREATE);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/widgets/misc/test-preferences-window.c b/widgets/misc/test-preferences-window.c
deleted file mode 100644
index 4ad30e2245..0000000000
--- a/widgets/misc/test-preferences-window.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * test-preferences-window.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "e-preferences-window.c"
-
-#include <gtk/gtk.h>
-
-static GtkWidget *
-create_page_number (gint i)
-{
- gchar *caption;
- GtkWidget *widget;
-
- caption = g_strdup_printf ("Title of page %d", i);
-
- widget = gtk_label_new (caption);
- gtk_widget_show (widget);
-
- g_free (caption);
-
- return widget;
-}
-
-static GtkWidget *
-create_page_zero (EPreferencesWindow *preferences_window)
-{
- return create_page_number (0);
-}
-static GtkWidget *
-create_page_one (EPreferencesWindow *preferences_window)
-{
- return create_page_number (1);
-}
-static GtkWidget *
-create_page_two (EPreferencesWindow *preferences_window)
-{
- return create_page_number (2);
-}
-
-static void
-add_pages (EPreferencesWindow *preferences_window)
-{
- e_preferences_window_add_page (
- preferences_window, "page-0",
- "gtk-properties", "title 0", NULL,
- create_page_zero, 0);
- e_preferences_window_add_page (
- preferences_window, "page-1",
- "gtk-properties", "title 1", NULL,
- create_page_one, 1);
- e_preferences_window_add_page (
- preferences_window, "page-2",
- "gtk-properties", "title 2", NULL,
- create_page_two, 2);
-}
-
-static gint
-delete_event_callback (GtkWidget *widget,
- GdkEventAny *event,
- gpointer data)
-{
- gtk_main_quit ();
-
- return TRUE;
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- GtkWidget *window;
-
- gtk_init (&argc, &argv);
-
- window = e_preferences_window_new (NULL);
- gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
-
- g_signal_connect (
- window, "delete-event",
- G_CALLBACK (delete_event_callback), NULL);
-
- add_pages (E_PREFERENCES_WINDOW (window));
- e_preferences_window_setup (E_PREFERENCES_WINDOW (window));
-
- gtk_widget_show (window);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/widgets/misc/test-source-config.c b/widgets/misc/test-source-config.c
deleted file mode 100644
index 4a5ce30d91..0000000000
--- a/widgets/misc/test-source-config.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <stdlib.h>
-#include <gtk/gtk.h>
-
-#include <libedataserver/libedataserver.h>
-
-#include "e-source-config-dialog.h"
-
-static void
-dialog_response (GtkDialog *dialog,
- gint response_id)
-{
- gtk_main_quit ();
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- ESourceRegistry *registry;
- ESource *source = NULL;
- GtkWidget *config;
- GtkWidget *dialog;
- GError *error = NULL;
-
- gtk_init (&argc, &argv);
-
- registry = e_source_registry_new_sync (NULL, &error);
-
- if (error != NULL) {
- g_printerr ("%s\n", error->message);
- exit (EXIT_FAILURE);
- }
-
- if (argc > 1) {
- source = e_source_registry_ref_source (registry, argv[1]);
- if (source == NULL) {
- g_printerr ("No such UID: %s\n", argv[1]);
- exit (EXIT_FAILURE);
- }
- }
-
- config = e_source_config_new (registry, source);
- dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
-
- g_signal_connect (
- dialog, "response",
- G_CALLBACK (dialog_response), NULL);
-
- gtk_widget_show (config);
- gtk_widget_show (dialog);
-
- g_object_unref (source);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/widgets/misc/widgets.error.xml b/widgets/misc/widgets.error.xml
deleted file mode 100644
index efaa41c42e..0000000000
--- a/widgets/misc/widgets.error.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<error-list domain="widgets">
-
- <error id="ask-signature-changed" type="question" default="GTK_RESPONSE_YES">
- <_primary>Do you wish to save your changes?</_primary>
- <_secondary xml:space="preserve">This signature has been changed, but has not been saved.</_secondary>
- <button _label="_Discard changes" response="GTK_RESPONSE_NO"/>
- <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
- <button stock="gtk-save" response="GTK_RESPONSE_YES"/>
- </error>
-
- <error id="blank-signature" type="error">
- <_primary>Blank Signature</_primary>
- <_secondary>Please provide an unique name to identify this signature.</_secondary>
- </error>
-
- <error id="no-load-signature" type="error">
- <_primary>Could not load signature.</_primary>
- <secondary xml:space="preserve">{0}</secondary>
- </error>
-
- <error id="no-save-signature" type="error">
- <_primary>Could not save signature.</_primary>
- <secondary xml:space="preserve">{0}</secondary>
- </error>
-
-</error-list>
-