diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-08-27 07:32:36 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-08-27 07:32:36 +0800 |
commit | 8223eaf57016792a4fcbe90b8923eadb2cd87a45 (patch) | |
tree | 5123bfa28050b5efec2b5c9e75681d37a24d08d0 /widgets/misc/e-attachment-view.c | |
parent | 87a3fac95cfdcb3dde4e0b75718239de20d8812f (diff) | |
download | gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar.gz gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar.bz2 gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar.lz gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar.xz gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.tar.zst gsoc2013-evolution-8223eaf57016792a4fcbe90b8923eadb2cd87a45.zip |
Convert EAttachmentHandler to an EExtension.
EAttachmentHandler predates EExtension, so this is really just a code
cleanup to use the extension framework. But this also demonstrates that
extensions can target interfaces as well as instantiable types, since
EAttachmentView is an interface.
What's also nice is EAttachmentView no longer has to directly interact
with attachment handlers. Instead of EAttachmentView having to query
each attachment handler for drag-and-drop info, each handler now pushes
its own drag-and-drop info to its EAttachmentView during initialization.
Diffstat (limited to 'widgets/misc/e-attachment-view.c')
-rw-r--r-- | widgets/misc/e-attachment-view.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c index 06ec2e5d2c..a80fe32ec0 100644 --- a/widgets/misc/e-attachment-view.c +++ b/widgets/misc/e-attachment-view.c @@ -778,27 +778,7 @@ attachment_view_update_actions (EAttachmentView *view) } static void -attachment_view_add_handler (GType type, - EAttachmentView *view) -{ - EAttachmentViewPrivate *priv; - EAttachmentHandler *handler; - const GtkTargetEntry *targets; - guint n_targets; - - priv = e_attachment_view_get_private (view); - - handler = g_object_new (type, "view", view, NULL); - - targets = e_attachment_handler_get_target_table (handler, &n_targets); - gtk_target_list_add_table (priv->target_list, targets, n_targets); - priv->drag_actions |= e_attachment_handler_get_drag_actions (handler); - - g_ptr_array_add (priv->handlers, handler); -} - -static void -attachment_view_init_handlers (EAttachmentView *view) +attachment_view_init_drag_dest (EAttachmentView *view) { EAttachmentViewPrivate *priv; GtkTargetList *target_list; @@ -812,13 +792,8 @@ attachment_view_init_handlers (EAttachmentView *view) e_target_list_add_calendar_targets (target_list, 0); e_target_list_add_directory_targets (target_list, 0); - priv->handlers = g_ptr_array_new (); priv->target_list = target_list; priv->drag_actions = GDK_ACTION_COPY; - - e_type_traverse ( - E_TYPE_ATTACHMENT_HANDLER, (ETypeFunc) - attachment_view_add_handler, view); } static void @@ -904,7 +879,7 @@ e_attachment_view_init (EAttachmentView *view) if (error != NULL) g_error ("%s", error->message); - attachment_view_init_handlers (view); + attachment_view_init_drag_dest (view); e_attachment_view_drag_source_set (view); @@ -934,9 +909,6 @@ e_attachment_view_dispose (EAttachmentView *view) priv = e_attachment_view_get_private (view); - g_ptr_array_foreach (priv->handlers, (GFunc) g_object_unref, NULL); - g_ptr_array_set_size (priv->handlers, 0); - if (priv->target_list != NULL) { gtk_target_list_unref (priv->target_list); priv->target_list = NULL; @@ -955,8 +927,6 @@ e_attachment_view_finalize (EAttachmentView *view) priv = e_attachment_view_get_private (view); - g_ptr_array_free (priv->handlers, TRUE); - g_list_foreach (priv->event_list, (GFunc) gdk_event_free, NULL); g_list_free (priv->event_list); @@ -1073,6 +1043,19 @@ e_attachment_view_get_drag_actions (EAttachmentView *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) { |