[evolution/kill-bonobo] Commit the rest of the attachment UI rewrite
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution/kill-bonobo] Commit the rest of the attachment UI rewrite
- Date: Tue, 28 Apr 2009 14:30:23 -0400 (EDT)
commit 0d3ef53bd7c1d7d96906f0f8348151a453e79078
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Apr 27 15:36:19 2009 -0400
Commit the rest of the attachment UI rewrite
Oops, last commit only included the -new- files.
This also removes EExpander, which is no longer used.
---
a11y/widgets/Makefile.am | 2 -
a11y/widgets/ea-expander.c | 165 ---
a11y/widgets/ea-expander.h | 51 -
a11y/widgets/ea-widgets.c | 7 -
a11y/widgets/ea-widgets.h | 1 -
calendar/gui/calendar-component.c | 1 +
calendar/gui/dialogs/comp-editor.c | 53 +-
calendar/gui/dialogs/event-editor.c | 2 -
calendar/gui/e-cal-popup.h | 2 -
composer/e-msg-composer.c | 3 +-
composer/e-msg-composer.h | 5 -
e-util/e-util.c | 30 +
e-util/e-util.h | 5 +
mail/em-filter-i18n.h | 2 +
mail/em-popup.h | 2 +-
mail/mail-component.c | 2 +
plugins/attachment-reminder/attachment-reminder.c | 2 +
widgets/misc/Makefile.am | 2 -
widgets/misc/e-attachment.c | 620 ----------
widgets/misc/e-expander.c | 1341 ---------------------
widgets/misc/e-expander.h | 82 --
21 files changed, 57 insertions(+), 2323 deletions(-)
diff --git a/a11y/widgets/Makefile.am b/a11y/widgets/Makefile.am
index e7d10dc..6da3057 100644
--- a/a11y/widgets/Makefile.am
+++ b/a11y/widgets/Makefile.am
@@ -20,8 +20,6 @@ libevolution_widgets_a11y_la_SOURCES = \
ea-calendar-item.h \
ea-calendar-cell.c \
ea-calendar-cell.h \
- ea-expander.c \
- ea-expander.h \
ea-widgets.c \
ea-widgets.h
diff --git a/a11y/widgets/ea-expander.c b/a11y/widgets/ea-expander.c
deleted file mode 100644
index ae9da5f..0000000
--- a/a11y/widgets/ea-expander.c
+++ /dev/null
@@ -1,165 +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:
- * Boby Wang <boby wang sun com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-#include "ea-expander.h"
-#include <glib/gi18n.h>
-
-static AtkObjectClass *parent_class;
-static GType parent_type;
-
-/* Action IDs */
-enum {
- ACTIVATE,
- LAST_ACTION
-};
-
-static G_CONST_RETURN gchar*
-ea_expander_get_name (AtkObject *a11y)
-{
- return _("Toggle Attachment Bar");
-}
-
-/* Action interface */
-static G_CONST_RETURN gchar *
-ea_expander_action_get_name (AtkAction *action, gint i)
-{
- switch (i)
- {
- case ACTIVATE:
- return _("activate");
- default:
- return NULL;
- }
-}
-
-static gboolean
-ea_expander_do_action (AtkAction *action, gint i)
-{
- GtkWidget *widget;
- EExpander *expander;
-
- widget = GTK_ACCESSIBLE (action)->widget;
- if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
- return FALSE;
-
- expander = E_EXPANDER (widget);
-
- switch (i)
- {
- case ACTIVATE:
- g_signal_emit_by_name (expander, "activate");
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-static gint
-ea_expander_get_n_actions (AtkAction *action)
-{
- return LAST_ACTION;
-}
-
-static void
-atk_action_interface_init (AtkActionIface *iface)
-{
- g_return_if_fail (iface != NULL);
-
- iface->do_action = ea_expander_do_action;
- iface->get_n_actions = ea_expander_get_n_actions;
- iface->get_name = ea_expander_action_get_name;
-}
-
-static void
-ea_expander_class_init (EaExpanderClass *klass)
-{
- AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_ref (parent_type);
-
- atk_object_class->get_name = ea_expander_get_name;
-}
-
-static void
-ea_expander_init (EaExpander *a11y)
-{
- /* Empty */
-}
-
-GType
-ea_expander_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- AtkObjectFactory *factory;
- GTypeQuery query;
-
- GTypeInfo info = {
- sizeof (EaExpanderClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) ea_expander_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (EaExpander),
- 0,
- (GInstanceInitFunc) ea_expander_init,
- NULL /* value_tree */
- };
-
- static const GInterfaceInfo atk_action_info = {
- (GInterfaceInitFunc) atk_action_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
-
- factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_BIN);
- parent_type = atk_object_factory_get_accessible_type (factory);
- g_type_query (parent_type, &query);
-
- info.class_size = query.class_size;
- info.instance_size = query.instance_size;
-
- type = g_type_register_static (parent_type, "EaExpander", &info, 0);
- g_type_add_interface_static (type, ATK_TYPE_ACTION,
- &atk_action_info);
- }
-
- return type;
-}
-
-AtkObject *
-ea_expander_new (GtkWidget *widget)
-{
- EaExpander *a11y;
-
- a11y = g_object_new (ea_expander_get_type (), NULL);
-
- GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget);
- ATK_OBJECT (a11y)->role = ATK_ROLE_TOGGLE_BUTTON;
-
- return ATK_OBJECT (a11y);
-}
-
diff --git a/a11y/widgets/ea-expander.h b/a11y/widgets/ea-expander.h
deleted file mode 100644
index e670ad0..0000000
--- a/a11y/widgets/ea-expander.h
+++ /dev/null
@@ -1,51 +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:
- * Boby Wang <boby wang sun com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _EA_EXPANDER_H_
-#define _EA_EXPANDER_H_
-
-#include <gtk/gtk.h>
-#include <misc/e-expander.h>
-
-#define EA_TYPE_EXPANDER (ea_expander_get_type ())
-#define EA_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_EXPANDER, EaExpander))
-#define EA_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass,), EA_TYPE_EXPANDER, EaExpanderClass))
-#define EA_IS_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_EXPANDER))
-#define EA_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_EXPANDER_CLASS))
-
-typedef struct _EaExpander EaExpander;
-typedef struct _EaExpanderClass EaExpanderClass;
-
-struct _EaExpander {
- GtkAccessible object;
-};
-
-struct _EaExpanderClass {
- GtkAccessibleClass parent_class;
-};
-
-/* Standard Glib function */
-GType ea_expander_get_type (void);
-AtkObject* ea_expander_new (GtkWidget *expander);
-
-#endif /* ! _EA_EXPANDER_H_ */
diff --git a/a11y/widgets/ea-widgets.c b/a11y/widgets/ea-widgets.c
index 7ca52ae..e9e170a 100644
--- a/a11y/widgets/ea-widgets.c
+++ b/a11y/widgets/ea-widgets.c
@@ -22,18 +22,11 @@
#include "ea-factory.h"
#include "widgets/ea-calendar-item.h"
-#include "widgets/ea-expander.h"
#include "ea-widgets.h"
EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new)
-EA_FACTORY (EA_TYPE_EXPANDER, ea_expander, ea_expander_new)
void e_calendar_item_a11y_init (void)
{
EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item);
}
-
-void e_expander_a11y_init (void)
-{
- EA_SET_FACTORY (e_expander_get_type (), ea_expander);
-}
diff --git a/a11y/widgets/ea-widgets.h b/a11y/widgets/ea-widgets.h
index 75ae46e..d19c908 100644
--- a/a11y/widgets/ea-widgets.h
+++ b/a11y/widgets/ea-widgets.h
@@ -28,6 +28,5 @@
#define _EA_WIDGETS_H__
void e_calendar_item_a11y_init (void);
-void e_expander_a11y_init (void);
#endif /* _EA_WIDGETS_H__ */
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index b84268c..2aaaaf2 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -58,6 +58,7 @@
#include "e-util/e-error.h"
#include "e-cal-menu.h"
#include "e-cal-popup.h"
+#include "e-attachment-handler-calendar.h"
/* IDs for user creatable items */
#define CREATE_EVENT_ID "event"
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 5d1f7a2..ceab3d3 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -180,39 +180,6 @@ static void obj_removed_cb (ECal *client, GList *uids, CompEditor *editor);
G_DEFINE_TYPE (CompEditor, comp_editor, GTK_TYPE_WINDOW)
enum {
- DND_TYPE_MESSAGE_RFC822,
- DND_TYPE_X_UID_LIST,
- DND_TYPE_TEXT_URI_LIST,
- DND_TYPE_NETSCAPE_URL,
- DND_TYPE_TEXT_VCARD,
- DND_TYPE_TEXT_CALENDAR,
-};
-
-static GtkTargetEntry drop_types[] = {
- { "message/rfc822", 0, DND_TYPE_MESSAGE_RFC822 },
- { "x-uid-list", 0, DND_TYPE_X_UID_LIST },
- { "text/uri-list", 0, DND_TYPE_TEXT_URI_LIST },
- { "_NETSCAPE_URL", 0, DND_TYPE_NETSCAPE_URL },
- { "text/x-vcard", 0, DND_TYPE_TEXT_VCARD },
- { "text/calendar", 0, DND_TYPE_TEXT_CALENDAR },
-};
-
-#define num_drop_types (sizeof (drop_types) / sizeof (drop_types[0]))
-
-static struct {
- char *target;
- GdkAtom atom;
- guint32 actions;
-} drag_info[] = {
- { "message/rfc822", NULL, GDK_ACTION_COPY },
- { "x-uid-list", NULL, GDK_ACTION_ASK|GDK_ACTION_MOVE|GDK_ACTION_COPY },
- { "text/uri-list", NULL, GDK_ACTION_COPY },
- { "_NETSCAPE_URL", NULL, GDK_ACTION_COPY },
- { "text/x-vcard", NULL, GDK_ACTION_COPY },
- { "text/calendar", NULL, GDK_ACTION_COPY },
-};
-
-enum {
OBJECT_CREATED,
LAST_SIGNAL
};
@@ -299,12 +266,15 @@ get_attachment_list (CompEditor *editor)
if (mime_part == NULL)
continue;
- wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (p->data));
+ if (mime_part == NULL)
+ continue;
+
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
/* Extract the content from the stream and write it down
* as a mime part file into the directory denoting the
* calendar source */
- utf8_safe_fname = camel_file_util_safe_filename (camel_mime_part_get_filename ((CamelMimePart *) p->data));
+ utf8_safe_fname = camel_file_util_safe_filename (camel_mime_part_get_filename (mime_part));
/* It is absolutely fine to get a NULL from the filename of
* mime part. We assume that it is named "Attachment"
@@ -1455,7 +1425,7 @@ comp_editor_key_press_event (GtkWidget *widget,
{
CompEditor *editor;
- editor = COMP_EDITOR (editor);
+ editor = COMP_EDITOR (widget);
if (event->keyval == GDK_Escape) {
commit_all_fields (editor);
@@ -1476,10 +1446,6 @@ comp_editor_class_init (CompEditorClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (drag_info); i++)
- drag_info[i].atom = gdk_atom_intern(drag_info[i].target, FALSE);
g_type_class_add_private (class, sizeof (CompEditorPrivate));
@@ -1569,6 +1535,10 @@ static void
comp_editor_init (CompEditor *editor)
{
CompEditorPrivate *priv;
+ EAttachmentView *view;
+ GdkDragAction drag_actions;
+ GtkTargetList *target_list;
+ GtkTargetEntry *targets;
GtkActionGroup *action_group;
GtkAction *action;
GtkWidget *container;
@@ -2353,6 +2323,9 @@ fill_widgets (CompEditor *editor)
view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
+ store = e_attachment_view_get_store (view);
+
priv = editor->priv;
/*Check if attachments are available here and set them*/
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index be12f71..830bbeb 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -515,8 +515,6 @@ event_editor_init (EventEditor *ee)
g_signal_connect_swapped (
ee->priv->model, "row_deleted",
G_CALLBACK (event_editor_model_changed_cb), ee);
-
- gtk_window_set_default_size (GTK_WINDOW (ee), 300, 225);
}
static void
diff --git a/calendar/gui/e-cal-popup.h b/calendar/gui/e-cal-popup.h
index fb899c3..34874ef 100644
--- a/calendar/gui/e-cal-popup.h
+++ b/calendar/gui/e-cal-popup.h
@@ -195,8 +195,6 @@ ECalPopup *e_cal_popup_new(const char *menuid);
ECalPopupTargetSelect *e_cal_popup_target_new_select(ECalPopup *eabp, struct _ECalModel *model, GPtrArray *events);
ECalPopupTargetSource *e_cal_popup_target_new_source(ECalPopup *eabp, struct _ESourceSelector *selector);
-ECalPopupTargetAttachments * e_cal_popup_target_new_attachments (ECalPopup *ecp,
- CompEditor *editor, GSList *attachments);
/* ********************************************************************** */
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 4e1cb62..5e8943d 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -49,7 +49,6 @@
#include "e-util/e-dialog-utils.h"
#include "misc/e-charset-picker.h"
-#include "misc/e-expander.h"
#include "e-util/e-error.h"
#include "e-util/e-mktemp.h"
#include "e-util/e-plugin-ui.h"
@@ -1229,7 +1228,7 @@ attachment_store_changed_cb (EMsgComposer *composer)
GtkhtmlEditor *editor;
/* Mark the editor as changed so it prompts about unsaved
- changes on close. */
+ * changes on close. */
editor = GTKHTML_EDITOR (composer);
gtkhtml_editor_set_changed (editor, TRUE);
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index ec8a6e3..42f12bf 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -157,11 +157,6 @@ gboolean e_msg_composer_is_exiting (EMsgComposer *composer);
GList * e_load_spell_languages (void);
void e_save_spell_languages (GList *spell_languages);
-gboolean e_msg_composer_is_exiting (EMsgComposer *composer);
-
-GList * e_load_spell_languages (void);
-void e_save_spell_languages (GList *spell_languages);
-
G_END_DECLS
#endif /* E_MSG_COMPOSER_H */
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 071f5e5..04be119 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1531,3 +1531,33 @@ e_camel_object_get_type (void)
return type;
}
+
+static gpointer
+e_camel_object_copy (gpointer camel_object)
+{
+ if (CAMEL_IS_OBJECT (camel_object))
+ camel_object_ref (camel_object);
+
+ return camel_object;
+}
+
+static void
+e_camel_object_free (gpointer camel_object)
+{
+ if (CAMEL_IS_OBJECT (camel_object))
+ camel_object_unref (camel_object);
+}
+
+GType
+e_camel_object_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ type = g_boxed_type_register_static (
+ "ECamelObject",
+ (GBoxedCopyFunc) e_camel_object_copy,
+ (GBoxedFreeFunc) e_camel_object_free);
+
+ return type;
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 84ec411..34ef346 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -146,6 +146,11 @@ gboolean e_util_read_file (const gchar *filename,
#define E_TYPE_CAMEL_OBJECT (e_camel_object_get_type ())
GType e_camel_object_get_type (void);
+/* Camel uses its own object system, so we have to box
+ * CamelObjects to safely use them as GObject properties. */
+#define E_TYPE_CAMEL_OBJECT (e_camel_object_get_type ())
+GType e_camel_object_get_type (void);
+
G_END_DECLS
#endif /* _E_UTIL_H_ */
diff --git a/mail/em-filter-i18n.h b/mail/em-filter-i18n.h
index 8b8d0c3..c0b2925 100644
--- a/mail/em-filter-i18n.h
+++ b/mail/em-filter-i18n.h
@@ -26,6 +26,7 @@ char *s = N_("Exist");
char *s = N_("exists");
char *s = N_("Expression");
char *s = N_("Follow Up");
+char *s = N_("Forward to");
char *s = N_("Important");
char *s = N_("is");
char *s = N_("is after");
@@ -46,6 +47,7 @@ char *s = N_("Message Body");
char *s = N_("Message Header");
char *s = N_("Message is Junk");
char *s = N_("Message is not Junk");
+char *s = N_("Message Location");
char *s = N_("Move to Folder");
char *s = N_("Pipe to Program");
char *s = N_("Play Sound");
diff --git a/mail/em-popup.h b/mail/em-popup.h
index 4d075ec..77f80e5 100644
--- a/mail/em-popup.h
+++ b/mail/em-popup.h
@@ -50,7 +50,7 @@ enum _em_popup_target_t {
EM_POPUP_TARGET_SELECT,
EM_POPUP_TARGET_URI,
EM_POPUP_TARGET_PART,
- EM_POPUP_TARGET_FOLDER,
+ EM_POPUP_TARGET_FOLDER
};
/**
diff --git a/mail/mail-component.c b/mail/mail-component.c
index daeb166..926f571 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -92,6 +92,8 @@
#include "e-util/e-non-intrusive-error-dialog.h"
+#include "e-attachment-handler-mail.h"
+
#define MAILER_ERROR_LEVEL_KEY "/apps/evolution/mail/display/error_level"
#define MAILER_ERROR_TIME_OUT_KEY "/apps/evolution/mail/display/error_timeout"
diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c
index 2004250..8634ce4 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -46,6 +46,8 @@
#include "composer/e-msg-composer.h"
#include "composer/e-composer-actions.h"
+#include "widgets/misc/e-attachment-view.h"
+#include "widgets/misc/e-attachment-store.h"
#define GCONF_KEY_ATTACH_REMINDER_CLUES "/apps/evolution/mail/attachment_reminder_clues"
#define SIGNATURE "-- "
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 2fa7327..f5dbd63 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -64,7 +64,6 @@ widgetsinclude_HEADERS = \
e-combo-cell-editable.h \
e-cursors.h \
e-dateedit.h \
- e-expander.h \
e-file-activity.h \
e-gui-utils.h \
e-hsv-utils.h \
@@ -129,7 +128,6 @@ libemiscwidgets_la_SOURCES = \
e-combo-cell-editable.c \
e-cursors.c \
e-dateedit.c \
- e-expander.c \
e-file-activity.c \
e-gui-utils.c \
e-hsv-utils.c \
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 537a347..b2c3e15 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -1915,626 +1915,6 @@ attachment_open_context_free (OpenContext *open_context)
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;
-
- /* Steal the result. */
- simple = open_context->simple;
- open_context->simple = NULL;
-
- g_simple_async_result_set_from_error (simple, error);
- g_simple_async_result_complete (simple);
- g_error_free (error);
-
- attachment_open_context_free (open_context);
-
- return TRUE;
-}
-
-static void
-attachment_open_file (GFile *file,
- OpenContext *open_context)
-{
- GdkAppLaunchContext *context;
- GSimpleAsyncResult *simple;
- GList *file_list;
- gboolean success;
- GError *error = NULL;
-
- /* Steal the result. */
- simple = open_context->simple;
- open_context->simple = NULL;
-
- /* Find a default app based on content type. */
- if (open_context->app_info == NULL) {
- EAttachment *attachment;
- GFileInfo *file_info;
- const gchar *content_type;
-
- attachment = open_context->attachment;
- file_info = e_attachment_get_file_info (attachment);
- if (file_info == NULL)
- goto exit;
-
- content_type = g_file_info_get_content_type (file_info);
- if (content_type == NULL)
- goto exit;
-
- open_context->app_info = g_app_info_get_default_for_type (
- content_type, FALSE);
- }
-
- if (open_context->app_info == NULL)
- goto exit;
-
- context = gdk_app_launch_context_new ();
- 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_simple_async_result_set_op_res_gboolean (simple, success);
-
- g_list_free (file_list);
- g_object_unref (context);
-
-exit:
- if (error != NULL) {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (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;
- GError *error = NULL;
-
- file = e_attachment_save_finish (attachment, result, &error);
-
- if (attachment_open_check_for_error (open_context, error))
- return;
-
- attachment_open_file (file, open_context);
- g_object_unref (file);
-}
-
-static void
-attachment_open_save_temporary (OpenContext *open_context)
-{
- GFile *file;
- gchar *template;
- gchar *path;
- GError *error = NULL;
-
- errno = 0;
-
- /* XXX This could trigger a blocking temp directory cleanup. */
- template = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ());
- path = e_mktemp (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;
-
- file = g_file_new_for_path (path);
-
- g_free (path);
-
- e_attachment_save_async (
- open_context->attachment, file, (GAsyncReadyCallback)
- attachment_open_save_finished_cb, open_context);
-
- g_object_unref (file);
-}
-
-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));
- g_return_if_fail (callback != NULL);
-
- 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);
- g_object_unref (simple);
-
- 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);
-}
-
-/************************* 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)
-{
- /* Do not free the GSimpleAsyncResult. */
- g_object_unref (save_context->attachment);
-
- 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;
-
- /* Steal the result. */
- simple = save_context->simple;
- save_context->simple = NULL;
-
- g_simple_async_result_set_from_error (simple, error);
- g_simple_async_result_complete (simple);
- g_error_free (error);
-
- 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;
- 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 result. */
- simple = save_context->simple;
- save_context->simple = NULL;
-
- /* Steal the destination. */
- destination = save_context->destination;
- save_context->destination = NULL;
-
- 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_object (CAMEL_MEDIUM (mime_part));
- camel_data_wrapper_decode_to_stream (wrapper, stream);
- camel_object_unref (stream);
-
- /* Load the buffer into a GMemoryInputStream. */
- input_stream = g_memory_input_stream_new_from_data (
- 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);
diff --git a/widgets/misc/e-expander.c b/widgets/misc/e-expander.c
deleted file mode 100644
index 7715987..0000000
--- a/widgets/misc/e-expander.c
+++ /dev/null
@@ -1,1341 +0,0 @@
-/*
- * GTK - The GIMP Toolkit
- *
- * 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:
- * Mark McLoughlin <mark skynet ie>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- * Copyright (C) 2003 Sun Microsystems, Inc.
- *
- */
-
-#include <config.h>
-
-#include "e-expander.h"
-#include "ea-widgets.h"
-
-#include <gdk/gdkkeysyms.h>
-
-#define DEFAULT_EXPANDER_SIZE 10
-#define DEFAULT_EXPANDER_SPACING 2
-
-/* ESTUFF */
-#ifndef _
-#define _(x) (x)
-#endif
-#define E_EXPANDER_GET_PRIVATE(expander) ((EExpanderPrivate *)g_object_get_data (G_OBJECT (expander), "e-expander-priv"))
-
-enum {
- PROP_0,
- PROP_EXPANDED,
- PROP_LABEL,
- PROP_USE_UNDERLINE,
- PROP_PADDING,
- PROP_LABEL_WIDGET
-};
-
-typedef struct {
- GtkWidget *label_widget;
- gint spacing;
-
- GtkExpanderStyle expander_style;
- guint animation_timeout;
-
- guint expanded : 1;
- guint use_underline : 1;
- guint button_down : 1;
-} EExpanderPrivate;
-
-static void e_expander_class_init (EExpanderClass *klass);
-static void e_expander_init (EExpander *expander);
-
-static void e_expander_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void e_expander_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void e_expander_destroy (GtkObject *object);
-
-static void e_expander_realize (GtkWidget *widget);
-static void e_expander_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_expander_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void e_expander_map (GtkWidget *widget);
-static gboolean e_expander_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gboolean e_expander_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean e_expander_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean e_expander_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static gboolean e_expander_enter_notify (GtkWidget *widget,
- GdkEventCrossing *event);
-static gboolean e_expander_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event);
-static gboolean e_expander_focus (GtkWidget *widget,
- GtkDirectionType direction);
-
-static void e_expander_add (GtkContainer *container,
- GtkWidget *widget);
-static void e_expander_remove (GtkContainer *container,
- GtkWidget *widget);
-static void e_expander_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void e_expander_activate (EExpander *expander);
-
-static GtkBinClass *parent_class = NULL;
-
-GType
-e_expander_get_type (void)
-{
- static GType expander_type = 0;
-
- if (!expander_type)
- {
- static const GTypeInfo expander_info =
- {
- sizeof (EExpanderClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) e_expander_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EExpander),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_expander_init,
- };
-
- expander_type = g_type_register_static (GTK_TYPE_BIN,
- "EExpander",
- &expander_info, 0);
- }
-
- return expander_type;
-}
-
-static void
-e_expander_class_init (EExpanderClass *klass)
-{
- GObjectClass *gobject_class;
- GtkObjectClass *gtkobject_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = (GObjectClass *) klass;
- gtkobject_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
- container_class = (GtkContainerClass *) klass;
-
- gobject_class->set_property = e_expander_set_property;
- gobject_class->get_property = e_expander_get_property;
-
- gtkobject_class->destroy = e_expander_destroy;
-
- widget_class->realize = e_expander_realize;
- widget_class->size_request = e_expander_size_request;
- widget_class->size_allocate = e_expander_size_allocate;
- widget_class->map = e_expander_map;
- widget_class->expose_event = e_expander_expose;
- widget_class->button_press_event = e_expander_button_press;
- widget_class->button_release_event = e_expander_button_release;
- widget_class->motion_notify_event = e_expander_motion_notify;
- widget_class->enter_notify_event = e_expander_enter_notify;
- widget_class->leave_notify_event = e_expander_leave_notify;
- widget_class->focus = e_expander_focus;
-
- container_class->add = e_expander_add;
- container_class->remove = e_expander_remove;
- container_class->forall = e_expander_forall;
-
- klass->activate = e_expander_activate;
-
- /* ESTUFF g_type_class_add_private (klass, sizeof (EExpanderPrivate)); */
-
- g_object_class_install_property (gobject_class,
- PROP_EXPANDED,
- g_param_spec_boolean ("expanded",
- _("Expanded"),
- _("Whether or not the expander is expanded"),
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- _("Label"),
- _("Text of the expander's label"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_USE_UNDERLINE,
- g_param_spec_boolean ("use_underline",
- _("Use underline"),
- _("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_PADDING,
- g_param_spec_int ("spacing",
- _("Spacing"),
- _("Space to put between the label and the child"),
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
- PROP_LABEL_WIDGET,
- g_param_spec_object ("label_widget",
- _("Label widget"),
- _("A widget to display in place of the usual expander label"),
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("expander-size",
- _("Expander Size"),
- _("Size of the expander arrow"),
- 0,
- G_MAXINT,
- DEFAULT_EXPANDER_SIZE,
- G_PARAM_READABLE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("expander-spacing",
- _("Indicator Spacing"),
- _("Spacing around expander arrow"),
- 0,
- G_MAXINT,
- DEFAULT_EXPANDER_SPACING,
- G_PARAM_READABLE));
-
- widget_class->activate_signal =
- g_signal_new ("activate",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EExpanderClass, activate),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_expander_a11y_init();
-}
-
-static void
-e_expander_init (EExpander *expander)
-{
- EExpanderPrivate *priv;
-
- /* ESTUFF */
- priv = g_new0 (EExpanderPrivate, 1);
- g_object_set_data_full (G_OBJECT (expander), "e-expander-priv", priv, g_free);
-
- /* ESTUFF priv = E_EXPANDER_GET_PRIVATE (expander); */
-
- GTK_WIDGET_SET_FLAGS (expander, GTK_CAN_FOCUS);
- GTK_WIDGET_UNSET_FLAGS (expander, GTK_NO_WINDOW);
-
- priv->label_widget = NULL;
- priv->spacing = 0;
-
- priv->expander_style = GTK_EXPANDER_COLLAPSED;
- priv->animation_timeout = 0;
-
- priv->expanded = FALSE;
- priv->use_underline = FALSE;
- priv->button_down = FALSE;
-
-}
-
-static void
-e_expander_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EExpander *expander = E_EXPANDER (object);
-
- switch (prop_id)
- {
- case PROP_EXPANDED:
- e_expander_set_expanded (expander, g_value_get_boolean (value));
- break;
- case PROP_LABEL:
- e_expander_set_label (expander, g_value_get_string (value));
- break;
- case PROP_USE_UNDERLINE:
- e_expander_set_use_underline (expander, g_value_get_boolean (value));
- break;
- case PROP_PADDING:
- e_expander_set_spacing (expander, g_value_get_int (value));
- break;
- case PROP_LABEL_WIDGET:
- e_expander_set_label_widget (expander, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-e_expander_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EExpander *expander = E_EXPANDER (object);
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- switch (prop_id)
- {
- case PROP_EXPANDED:
- g_value_set_boolean (value, priv->expanded);
- break;
- case PROP_LABEL:
- g_value_set_string (value, e_expander_get_label (expander));
- break;
- case PROP_USE_UNDERLINE:
- g_value_set_boolean (value, priv->use_underline);
- break;
- case PROP_PADDING:
- g_value_set_int (value, priv->spacing);
- break;
- case PROP_LABEL_WIDGET:
- g_value_set_object (value,
- priv->label_widget ?
- G_OBJECT (priv->label_widget) : NULL);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-e_expander_destroy (GtkObject *object)
-{
- EExpander *expander = E_EXPANDER (object);
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (priv->animation_timeout)
- g_source_remove (priv->animation_timeout);
- priv->animation_timeout = 0;
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-e_expander_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint border_width;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget) |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_EXPOSURE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-}
-
-static void
-e_expander_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EExpander *expander;
- GtkBin *bin;
- EExpanderPrivate *priv;
- gint border_width;
- gint expander_size;
- gint expander_spacing;
- gboolean interior_focus;
- gint focus_width;
- gint focus_pad;
-
- expander = E_EXPANDER (widget);
- bin = GTK_BIN (widget);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- gtk_widget_style_get (widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- "expander-size", &expander_size,
- "expander-spacing", &expander_spacing,
- NULL);
-
- requisition->width = expander_size + 2 * expander_spacing +
- 2 * focus_width + 2 * focus_pad;
- requisition->height = interior_focus ? (2 * focus_width + 2 * focus_pad) : 0;
-
- if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
- {
- GtkRequisition label_requisition;
-
- gtk_widget_size_request (priv->label_widget, &label_requisition);
-
- requisition->width += label_requisition.width;
- requisition->height += label_requisition.height;
- }
-
- requisition->height = MAX (expander_size + 2 * expander_spacing, requisition->height);
-
- if (!interior_focus)
- requisition->height += 2 * focus_width + 2 * focus_pad;
-
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (bin->child, &child_requisition);
-
- if (!interior_focus)
- child_requisition.width += 2 * focus_width + 2 * focus_pad;
-
- requisition->width = MAX (requisition->width, child_requisition.width);
- requisition->height += child_requisition.height + priv->spacing;
- }
-
- requisition->width += 2 * border_width;
- requisition->height += 2 * border_width + 2 * priv->spacing;
-}
-
-static void
-e_expander_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EExpander *expander;
- GtkBin *bin;
- EExpanderPrivate *priv;
- GtkRequisition child_requisition;
- gboolean child_visible = FALSE;
- gint border_width;
- gint expander_size;
- gint expander_spacing;
- gboolean interior_focus;
- gint focus_width;
- gint focus_pad;
- gint label_height;
-
- expander = E_EXPANDER (widget);
- bin = GTK_BIN (widget);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- gtk_widget_style_get (widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- "expander-size", &expander_size,
- "expander-spacing", &expander_spacing,
- NULL);
-
- child_requisition.width = 0;
- child_requisition.height = 0;
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
- {
- child_visible = TRUE;
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
- }
-
- widget->allocation = *allocation;
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x + border_width,
- allocation->y + border_width,
- MAX (allocation->width - 2 * border_width, 0),
- MAX (allocation->height - 2 * border_width, 0));
-
- if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
- {
- GtkAllocation label_allocation;
- GtkRequisition label_requisition;
- gboolean ltr;
-
- gtk_widget_get_child_requisition (priv->label_widget, &label_requisition);
-
- ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
-
- label_allocation.x = focus_width + focus_pad;
- if (ltr)
- label_allocation.x += expander_size + 2 * expander_spacing;
- label_allocation.y = priv->spacing + focus_width + focus_pad;
-
- label_allocation.width = MIN (label_requisition.width,
- allocation->width - 2 * border_width -
- expander_size - 2 * expander_spacing -
- 2 * focus_width - 2 * focus_pad);
- label_allocation.width = MAX (label_allocation.width, 1);
-
- label_allocation.height = MIN (label_requisition.height,
- allocation->height - 2 * border_width -
- 2 * priv->spacing -
- 2 * focus_width - 2 * focus_pad -
- child_requisition.height -
- (child_visible ? priv->spacing : 0));
- label_allocation.height = MAX (label_allocation.height, 1);
-
- gtk_widget_size_allocate (priv->label_widget, &label_allocation);
-
- label_height = label_allocation.height;
- }
- else
- {
- label_height = 0;
- }
-
- if (child_visible)
- {
- GtkAllocation child_allocation;
- gint top_height;
-
- top_height = MAX (2 * expander_spacing + expander_size,
- label_height +
- (interior_focus ? 2 * focus_width + 2 * focus_pad : 0));
-
- child_allocation.x = 0;
- child_allocation.y = 2 * priv->spacing + top_height;
-
- if (!interior_focus)
- {
- child_allocation.x += focus_width + focus_pad;
- child_allocation.y += focus_width + focus_pad;
- }
-
- child_allocation.width = allocation->width - 2 * border_width -
- (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0);
- child_allocation.width = MAX (child_allocation.width, 1);
-
- child_allocation.height = allocation->height - top_height -
- 2 * border_width -
- 3 * priv->spacing -
- (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0);
- child_allocation.height = MAX (child_allocation.height, 1);
-
- gtk_widget_size_allocate (bin->child, &child_allocation);
- }
-}
-
-static void
-e_expander_map (GtkWidget *widget)
-{
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (widget);
-
- if (priv->label_widget)
- gtk_widget_map (priv->label_widget);
-
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-}
-
-static GdkRectangle
-get_expander_bounds (EExpander *expander)
-{
- GtkWidget *widget;
- EExpanderPrivate *priv;
- GdkRectangle bounds;
- gint border_width;
- gint expander_size;
- gint expander_spacing;
- gboolean interior_focus;
- gint focus_width;
- gint focus_pad;
- gboolean ltr;
-
- widget = GTK_WIDGET (expander);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- border_width = GTK_CONTAINER (expander)->border_width;
-
- gtk_widget_style_get (widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- "expander-size", &expander_size,
- "expander-spacing", &expander_spacing,
- NULL);
-
- ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
-
-
- if (ltr)
- bounds.x = expander_spacing;
- else
- bounds.x = widget->allocation.width - 2 * border_width -
- expander_spacing - expander_size;
-
- if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
- {
- GtkAllocation label_allocation;
-
- label_allocation = priv->label_widget->allocation;
-
- if (expander_size < label_allocation.height)
- bounds.y = label_allocation.y + (label_allocation.height - expander_size) / 2;
- else
- bounds.y = priv->spacing + expander_spacing;
- }
- else
- {
- bounds.y = priv->spacing + expander_spacing;
- }
-
- if (!interior_focus)
- {
- if (ltr)
- bounds.x += focus_width + focus_pad;
- else
- bounds.x -= focus_width + focus_pad;
- bounds.y += focus_width + focus_pad;
- }
-
- bounds.width = bounds.height = expander_size;
-
- return bounds;
-}
-
-static void
-e_expander_paint (EExpander *expander)
-{
- GtkWidget *widget;
- EExpanderPrivate *priv;
- gint x, y;
- GtkStateType state;
- GdkRectangle clip;
-
- widget = GTK_WIDGET (expander);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- clip = get_expander_bounds (expander);
-
- x = clip.x + clip.width / 2;
- y = clip.y + clip.height / 2;
-
- state = widget->state;
- if (state != GTK_STATE_PRELIGHT)
- state = GTK_STATE_NORMAL;
-
- gtk_paint_expander (widget->style,
- widget->window,
- state,
- &clip,
- widget,
- "expander",
- x,
- y,
- priv->expander_style);
-}
-
-static void
-e_expander_paint_focus (EExpander *expander,
- GdkRectangle *area)
-{
- GtkWidget *widget;
- EExpanderPrivate *priv;
- gint x, y, width, height;
- gboolean interior_focus;
- gint focus_width;
- gint focus_pad;
- gint expander_size;
- gint expander_spacing;
- gboolean ltr;
-
- widget = GTK_WIDGET (expander);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- gtk_widget_style_get (widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- "expander-size", &expander_size,
- "expander-spacing", &expander_spacing,
- NULL);
-
- ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
-
- if (interior_focus)
- {
- if (ltr)
- x = expander_spacing * 2 + expander_size;
- else
- x = 0;
- y = priv->spacing;
-
- width = height = 2 * focus_pad + 2 * focus_width;
-
- if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget))
- {
- GtkAllocation label_allocation = priv->label_widget->allocation;
-
- width += label_allocation.width;
- height += label_allocation.height;
- }
- }
- else
- {
- x = y = 0;
- width = widget->allocation.width - 2 * GTK_CONTAINER (widget)->border_width;
- height = widget->allocation.height - 2 * GTK_CONTAINER (widget)->border_width;
- }
-
- gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
- area, widget, "expander",
- x, y, width, height);
-}
-
-static gboolean
-e_expander_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- if (GTK_WIDGET_DRAWABLE (widget))
- {
- EExpander *expander = E_EXPANDER (widget);
-
- e_expander_paint (expander);
-
- if (GTK_WIDGET_HAS_FOCUS (expander))
- e_expander_paint_focus (expander, &event->area);
-
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
- }
-
- return FALSE;
-}
-
-static gboolean
-is_in_expander_panel (EExpander *expander,
- GdkWindow *window,
- gint x,
- gint y)
-{
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (expander);
-
- area = get_expander_bounds (expander);
-
- area.x = 0;
- area.width = widget->allocation.width;
-
- if (widget->window == window)
- {
- if (x >= area.x && x <= (area.x + area.width) &&
- y >= area.y && y <= (area.y + area.height))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-e_expander_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- EExpander *expander = E_EXPANDER (widget);
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (event->button == 1 && !priv->button_down)
- {
- if (is_in_expander_panel (expander, event->window, event->x, event->y))
- {
- priv->button_down = TRUE;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-e_expander_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- EExpander *expander = E_EXPANDER (widget);
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (event->button == 1 && priv->button_down)
- {
- g_signal_emit_by_name (expander, "activate");
-
- priv->button_down = FALSE;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-e_expander_maybe_prelight (EExpander *expander)
-{
- GtkWidget *widget;
- EExpanderPrivate *priv;
- GtkStateType state = GTK_STATE_NORMAL;
-
- widget = GTK_WIDGET (expander);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (!priv->button_down)
- {
- gint x, y;
-
- gdk_window_get_pointer (widget->window, &x, &y, NULL);
-
- if (is_in_expander_panel (expander, widget->window, x, y))
- state = GTK_STATE_PRELIGHT;
- }
-
- gtk_widget_set_state (widget, state);
-}
-
-static gboolean
-e_expander_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
-{
- e_expander_maybe_prelight (E_EXPANDER (widget));
-
- return FALSE;
-}
-
-static gboolean
-e_expander_enter_notify (GtkWidget *widget,
- GdkEventCrossing *event)
-{
- e_expander_maybe_prelight (E_EXPANDER (widget));
-
- return FALSE;
-}
-
-static gboolean
-e_expander_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event)
-{
- gtk_widget_set_state (widget, GTK_STATE_NORMAL);
-
- return FALSE;
-}
-
-static gboolean
-focus_child_in (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
-
- if (!child)
- return FALSE;
-
- return gtk_widget_child_focus (child, direction);
-}
-
-static gboolean
-e_expander_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- EExpanderPrivate *priv;
- GtkWidget *old_focus_child;
- gboolean widget_is_focus;
- gboolean label_can_focus;
-
- priv = E_EXPANDER_GET_PRIVATE (widget);
-
- widget_is_focus = gtk_widget_is_focus (widget);
- old_focus_child = GTK_CONTAINER (widget)->focus_child;
- label_can_focus = priv->label_widget && GTK_WIDGET_CAN_FOCUS (priv->label_widget);
-
- if (old_focus_child && old_focus_child == priv->label_widget)
- {
- switch (direction)
- {
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_LEFT:
- case GTK_DIR_UP:
- gtk_widget_grab_focus (widget);
- return TRUE;
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_RIGHT:
- return focus_child_in (widget, direction);
- }
- }
- else if (old_focus_child)
- {
- if (gtk_widget_child_focus (old_focus_child, direction))
- return TRUE;
-
- switch (direction)
- {
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_LEFT:
- case GTK_DIR_UP:
- if (label_can_focus)
- gtk_widget_grab_focus (priv->label_widget);
- else
- gtk_widget_grab_focus (widget);
- return TRUE;
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_RIGHT:
- return FALSE;
- }
- }
- else if (widget_is_focus)
- {
- switch (direction)
- {
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_LEFT:
- case GTK_DIR_UP:
- return FALSE;
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_RIGHT:
- if (label_can_focus)
- {
- gtk_widget_grab_focus (priv->label_widget);
- return TRUE;
- }
-
- return focus_child_in (widget, direction);
- }
- }
- else
- {
- switch (direction)
- {
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_TAB_BACKWARD:
- gtk_widget_grab_focus (widget);
- return TRUE;
- case GTK_DIR_UP:
- case GTK_DIR_LEFT:
- case GTK_DIR_RIGHT:
- if (!focus_child_in (widget, direction))
- {
- gtk_widget_grab_focus (widget);
- }
- return TRUE;
- }
- }
-
- g_return_val_if_reached(FALSE);
-}
-
-static void
-e_expander_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
-
- g_object_set (G_OBJECT (widget),
- "visible", E_EXPANDER_GET_PRIVATE (container)->expanded,
- NULL);
-}
-
-static void
-e_expander_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- EExpander *expander = E_EXPANDER (container);
-
- if (E_EXPANDER_GET_PRIVATE (expander)->label_widget == widget)
- e_expander_set_label_widget (expander, NULL);
- else
- GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
-}
-
-static void
-e_expander_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkBin *bin = GTK_BIN (container);
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (container);
-
- if (bin->child)
- (* callback) (bin->child, callback_data);
-
- if (priv->label_widget)
- (* callback) (priv->label_widget, callback_data);
-}
-
-static void
-e_expander_activate (EExpander *expander)
-{
- e_expander_set_expanded (expander,
- !E_EXPANDER_GET_PRIVATE (expander)->expanded);
-}
-
-GtkWidget *
-e_expander_new (const gchar *label)
-{
- return g_object_new (E_TYPE_EXPANDER, "label", label, NULL);
-}
-
-GtkWidget *
-e_expander_new_with_mnemonic (const gchar *label)
-{
- return g_object_new (E_TYPE_EXPANDER,
- "label", label,
- "use_underline", TRUE,
- NULL);
-}
-
-static gboolean
-e_expander_animation_timeout (EExpander *expander)
-{
- EExpanderPrivate *priv;
- GdkRectangle area;
- gboolean finish = FALSE;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (GTK_WIDGET_REALIZED (expander))
- {
- area = get_expander_bounds (expander);
- gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE);
- }
-
- if (priv->expanded)
- {
- if (priv->expander_style == GTK_EXPANDER_COLLAPSED)
- {
- priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED;
- }
- else
- {
- priv->expander_style = GTK_EXPANDER_EXPANDED;
- finish = TRUE;
- }
- }
- else
- {
- if (priv->expander_style == GTK_EXPANDER_EXPANDED)
- {
- priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED;
- }
- else
- {
- priv->expander_style = GTK_EXPANDER_COLLAPSED;
- finish = TRUE;
- }
- }
-
- if (finish)
- {
- priv->animation_timeout = 0;
- g_object_set (G_OBJECT (GTK_BIN (expander)->child),
- "visible", priv->expanded,
- NULL);
- }
-
- return !finish;
-}
-
-static void
-e_expander_start_animation (EExpander *expander)
-{
- EExpanderPrivate *priv;
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (priv->animation_timeout)
- g_source_remove (priv->animation_timeout);
-
- priv->animation_timeout =
- g_timeout_add (50,
- (GSourceFunc) e_expander_animation_timeout,
- expander);
-}
-
-void
-e_expander_set_expanded (EExpander *expander,
- gboolean expanded)
-{
- EExpanderPrivate *priv;
-
- g_return_if_fail (E_IS_EXPANDER (expander));
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- expanded = expanded != FALSE;
-
- if (priv->expanded != expanded)
- {
- priv->expanded = expanded;
-
- if (GTK_WIDGET_VISIBLE (expander))
- e_expander_start_animation (expander);
-
- else if (GTK_BIN (expander)->child)
- {
- priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED :
- GTK_EXPANDER_COLLAPSED;
- g_object_set (G_OBJECT (GTK_BIN (expander)->child),
- "visible", priv->expanded,
- NULL);
- }
-
- gtk_widget_queue_resize (GTK_WIDGET (expander));
-
- g_object_notify (G_OBJECT (expander), "expanded");
- }
-}
-
-gboolean
-e_expander_get_expanded (EExpander *expander)
-{
- g_return_val_if_fail (E_IS_EXPANDER (expander), FALSE);
-
- return E_EXPANDER_GET_PRIVATE (expander)->expanded;
-}
-
-void
-e_expander_set_spacing (EExpander *expander,
- gint spacing)
-{
- EExpanderPrivate *priv;
-
- g_return_if_fail (E_IS_EXPANDER (expander));
- g_return_if_fail (spacing >= 0);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (priv->spacing != spacing)
- {
- priv->spacing = spacing;
-
- gtk_widget_queue_resize (GTK_WIDGET (expander));
-
- g_object_notify (G_OBJECT (expander), "spacing");
- }
-}
-
-gint
-e_expander_get_spacing (EExpander *expander)
-{
- g_return_val_if_fail (E_IS_EXPANDER (expander), 0);
-
- return E_EXPANDER_GET_PRIVATE (expander)->spacing;
-}
-
-void
-e_expander_set_label (EExpander *expander,
- const gchar *label)
-{
- g_return_if_fail (E_IS_EXPANDER (expander));
-
- if (!label)
- {
- e_expander_set_label_widget (expander, NULL);
- }
- else
- {
- GtkWidget *child;
-
- child = gtk_label_new (label);
- gtk_label_set_use_underline (GTK_LABEL (child),
- E_EXPANDER_GET_PRIVATE (expander)->use_underline);
- gtk_widget_show (child);
-
- e_expander_set_label_widget (expander, child);
- }
-
- g_object_notify (G_OBJECT (expander), "label");
-}
-
-/**
- * e_expander_get_label:
- * @expander: a #EExpander
- *
- * If the expander's label widget is a #GtkLabel, return the
- * text in the label widget. (The frame will have a #GtkLabel
- * for the label widget if a non-%NULL argument was passed
- * to e_expander_new().)
- *
- * Return value: the text in the label, or %NULL if there
- * was no label widget or the lable widget was not
- * a #GtkLabel. This string is owned by GTK+ and
- * must not be modified or freed.
- **/
-G_CONST_RETURN char *
-e_expander_get_label (EExpander *expander)
-{
- EExpanderPrivate *priv;
-
- g_return_val_if_fail (E_IS_EXPANDER (expander), NULL);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (priv->label_widget && GTK_IS_LABEL (priv->label_widget))
- return gtk_label_get_text (GTK_LABEL (priv->label_widget));
- else
- return NULL;
-}
-
-void
-e_expander_set_use_underline (EExpander *expander,
- gboolean use_underline)
-{
- EExpanderPrivate *priv;
-
- g_return_if_fail (E_IS_EXPANDER (expander));
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- use_underline = use_underline != FALSE;
-
- if (priv->use_underline != use_underline)
- {
- priv->use_underline = use_underline;
-
- if (priv->label_widget && GTK_IS_LABEL (priv->label_widget))
- gtk_label_set_use_underline (GTK_LABEL (priv->label_widget), use_underline);
-
- g_object_notify (G_OBJECT (expander), "use_underline");
- }
-}
-
-gboolean
-e_expander_get_use_underline (EExpander *expander)
-{
- g_return_val_if_fail (E_IS_EXPANDER (expander), FALSE);
-
- return E_EXPANDER_GET_PRIVATE (expander)->use_underline;
-}
-
-/**
- * e_expander_set_label_widget:
- * @expander: a #EExpander
- * @label_widget: the new label widget
- *
- * Set the label widget for the expander. This is the widget
- * that will appear embedded alongside the expander arrow.
- **/
-void
-e_expander_set_label_widget (EExpander *expander,
- GtkWidget *label_widget)
-{
- EExpanderPrivate *priv;
- gboolean need_resize = FALSE;
-
- g_return_if_fail (E_IS_EXPANDER (expander));
- g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
- g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
-
- priv = E_EXPANDER_GET_PRIVATE (expander);
-
- if (priv->label_widget == label_widget)
- return;
-
- if (priv->label_widget)
- {
- need_resize = GTK_WIDGET_VISIBLE (priv->label_widget);
- gtk_widget_unparent (priv->label_widget);
- }
-
- priv->label_widget = label_widget;
-
- if (label_widget)
- {
- priv->label_widget = label_widget;
- gtk_widget_set_parent (label_widget, GTK_WIDGET (expander));
- need_resize |= GTK_WIDGET_VISIBLE (label_widget);
- }
-
- if (GTK_WIDGET_VISIBLE (expander) && need_resize)
- gtk_widget_queue_resize (GTK_WIDGET (expander));
-
- g_object_notify (G_OBJECT (expander), "label_widget");
-}
-
-/**
- * e_expander_get_label_widget:
- * @expander: a #EExpander
- *
- * Retrieves the label widget for the frame. See
- * e_expander_set_label_widget().
- *
- * Return value: the label widget, or %NULL if there is none.
- **/
-GtkWidget *
-e_expander_get_label_widget (EExpander *expander)
-{
- g_return_val_if_fail (E_IS_EXPANDER (expander), NULL);
-
- return E_EXPANDER_GET_PRIVATE (expander)->label_widget;
-}
diff --git a/widgets/misc/e-expander.h b/widgets/misc/e-expander.h
deleted file mode 100644
index 6ddb680..0000000
--- a/widgets/misc/e-expander.h
+++ /dev/null
@@ -1,82 +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:
- * Mark McLoughlin <mark skynet ie>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- * Copyright (C) 2003 Sun Microsystems, Inc.
- *
- */
-
-#ifndef _E_EXPANDER_H_
-#define _E_EXPANDER_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define E_TYPE_EXPANDER (e_expander_get_type ())
-#define E_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_EXPANDER, EExpander))
-#define E_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_EXPANDER, EExpanderClass))
-#define E_IS_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_EXPANDER))
-#define E_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_EXPANDER))
-#define E_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_EXPANDER, EExpanderClass))
-/* ESTUFF #define E_EXPANDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_EXPANDER, EExpanderPrivate)) */
-
-typedef struct _EExpander EExpander;
-typedef struct _EExpanderClass EExpanderClass;
-
-struct _EExpander
-{
- GtkBin bin;
-};
-
-struct _EExpanderClass
-{
- GtkBinClass parent_class;
-
- void (* activate) (EExpander *expander);
-};
-
-GType e_expander_get_type (void);
-
-GtkWidget *e_expander_new (const gchar *label);
-GtkWidget *e_expander_new_with_mnemonic (const gchar *label);
-
-void e_expander_set_expanded (EExpander *expander,
- gboolean expanded);
-gboolean e_expander_get_expanded (EExpander *expander);
-
-/* Spacing between the expander/label and the child */
-void e_expander_set_spacing (EExpander *expander,
- gint spacing);
-gint e_expander_get_spacing (EExpander *expander);
-
-void e_expander_set_label (EExpander *expander,
- const gchar *label);
-G_CONST_RETURN gchar *e_expander_get_label (EExpander *expander);
-
-void e_expander_set_use_underline (EExpander *expander,
- gboolean use_underline);
-gboolean e_expander_get_use_underline (EExpander *expander);
-
-void e_expander_set_label_widget (EExpander *expander,
- GtkWidget *label_widget);
-GtkWidget *e_expander_get_label_widget (EExpander *expander);
-
-G_END_DECLS
-
-#endif /* _E_EXPANDER_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]