aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-04-28 03:36:19 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-04-28 20:22:22 +0800
commit0d3ef53bd7c1d7d96906f0f8348151a453e79078 (patch)
tree1964bc931216772980cb31afe989b62ca3d6f7fa /widgets
parentfab97ac4cfde3511832be5079d7da909bdbc632f (diff)
downloadgsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar.gz
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar.bz2
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar.lz
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar.xz
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.tar.zst
gsoc2013-evolution-0d3ef53bd7c1d7d96906f0f8348151a453e79078.zip
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.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/Makefile.am2
-rw-r--r--widgets/misc/e-attachment.c620
-rw-r--r--widgets/misc/e-expander.c1341
-rw-r--r--widgets/misc/e-expander.h82
4 files changed, 0 insertions, 2045 deletions
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 2fa7327e35..f5dbd63d82 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 537a3470d7..b2c3e1579e 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 771598739d..0000000000
--- 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 6ddb68087e..0000000000
--- 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_ */