aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-09-03 20:29:15 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-09-03 20:29:52 +0800
commitd0841e7c2490436c664cfec87099b86d54d4127d (patch)
treee9ac7fa767b6099e46c1adbd0cd004567191f60e
parent847475a598fd21dff81ccb064603bafb97bd4cd6 (diff)
downloadgsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar.gz
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar.bz2
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar.lz
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar.xz
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.tar.zst
gsoc2013-evolution-d0841e7c2490436c664cfec87099b86d54d4127d.zip
Bug 593881 - Category icons do not appear in preview pane
-rw-r--r--calendar/gui/e-cal-component-preview.c101
-rw-r--r--modules/calendar/e-memo-shell-view-private.c25
-rw-r--r--modules/calendar/e-task-shell-view-private.c27
3 files changed, 115 insertions, 38 deletions
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index de6f6fcd3d..633eb5678e 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -46,31 +46,6 @@ struct _ECalComponentPreviewPrivate {
static gpointer parent_class;
-static void
-cal_component_preview_link_clicked (GtkHTML *html,
- const gchar *uri)
-{
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, uri);
-}
-
-static void
-cal_component_preview_on_url (GtkHTML *html,
- const gchar *url)
-{
-#if 0
- gchar *msg;
- ECalComponentPreview *preview = data;
-
- if (url && *url) {
- msg = g_strdup_printf (_("Click to open %s"), url);
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg);
- g_free (msg);
- } else
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL);
-#endif
-}
-
/* Converts a time_t to a string, relative to the specified timezone */
static gchar *
timet_to_str_with_zone (ECalComponentDateTime *dt,
@@ -159,7 +134,9 @@ cal_component_preview_write_html (GtkHTMLStream *stream,
}
}
if (string->len > 0)
- gtk_html_stream_printf (stream, "%s</H3>", string->str);
+ gtk_html_stream_printf (stream, "%s", string->str);
+ if (list != NULL)
+ gtk_html_stream_printf (stream, "</H3>");
e_cal_component_free_categories_list (list);
g_string_free (string, TRUE);
@@ -294,33 +271,83 @@ cal_component_preview_write_html (GtkHTMLStream *stream,
}
static void
-cal_component_preview_finalize (GObject *object)
+cal_component_preview_url_requested (GtkHTML *html,
+ const gchar *url,
+ GtkHTMLStream *html_stream)
{
- ECalComponentPreviewPrivate *priv;
+ GFile *file;
+ GFileInputStream *input_stream;
+ gchar buffer[4096];
+ gssize bytes_read;
+ GError *error = NULL;
+
+ file = g_file_new_for_uri (url);
+
+ /* XXX We only handle native files, which I guess minimizes
+ * the damage from doing blocking reads here. Annoying
+ * that GtkHTML does not handle this itself. */
+ if (!g_file_is_native (file))
+ goto exit;
+
+ input_stream = g_file_read (file, NULL, &error);
+
+ if (error != NULL)
+ goto fail;
+
+ do {
+ bytes_read = g_input_stream_read (
+ G_INPUT_STREAM (input_stream),
+ buffer, sizeof (buffer), NULL, &error);
- priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (object);
+ if (bytes_read > 0)
+ gtk_html_stream_write (
+ html_stream, buffer, bytes_read);
- /* XXX Nothing to do? */
+ } while (bytes_read > 0);
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ if (error != NULL)
+ goto fail;
+
+ gtk_html_stream_close (html_stream, GTK_HTML_STREAM_OK);
+
+ goto exit;
+
+fail:
+ g_warning ("%s", error->message);
+ g_error_free (error);
+
+ gtk_html_stream_close (html_stream, GTK_HTML_STREAM_ERROR);
+
+exit:
+ if (input_stream != NULL)
+ g_object_unref (input_stream);
+
+ g_object_unref (file);
+}
+
+static void
+cal_component_preview_link_clicked (GtkHTML *html,
+ const gchar *uri)
+{
+ gpointer parent;
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (html));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ e_show_uri (parent, uri);
}
static void
cal_component_preview_class_init (ECalComponentPreviewClass *class)
{
- GObjectClass *object_class;
GtkHTMLClass *gtkhtml_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ECalComponentPreviewPrivate));
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = cal_component_preview_finalize;
-
gtkhtml_class = GTK_HTML_CLASS (class);
+ gtkhtml_class->url_requested = cal_component_preview_url_requested;
gtkhtml_class->link_clicked = cal_component_preview_link_clicked;
- gtkhtml_class->on_url = cal_component_preview_on_url;
}
static void
diff --git a/modules/calendar/e-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c
index f1d331fab3..0a96d29664 100644
--- a/modules/calendar/e-memo-shell-view-private.c
+++ b/modules/calendar/e-memo-shell-view-private.c
@@ -24,6 +24,24 @@
#include "widgets/menus/gal-view-factory-etable.h"
static void
+memo_shell_view_preview_on_url_cb (EShellView *shell_view,
+ const gchar *url)
+{
+ EShellTaskbar *shell_taskbar;
+ gchar *message;
+
+ shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
+
+ if (url == NULL || *url == '\0')
+ e_shell_taskbar_set_message (shell_taskbar, NULL);
+ else {
+ message = g_strdup_printf (_("Click to open %s"), url);
+ e_shell_taskbar_set_message (shell_taskbar, message);
+ g_free (message);
+ }
+}
+
+static void
memo_shell_view_table_popup_event_cb (EShellView *shell_view,
GdkEventButton *event)
{
@@ -171,6 +189,7 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
+ ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
ECalModel *model;
ETable *table;
@@ -191,6 +210,7 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
priv->memo_shell_sidebar = g_object_ref (shell_sidebar);
memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
+ memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content);
memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
model = e_memo_table_get_model (memo_table);
table = e_memo_table_get_table (memo_table);
@@ -204,6 +224,11 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
memo_shell_view);
g_signal_connect_swapped (
+ memo_preview, "on-url",
+ G_CALLBACK (memo_shell_view_preview_on_url_cb),
+ memo_shell_view);
+
+ g_signal_connect_swapped (
memo_table, "open-component",
G_CALLBACK (e_memo_shell_view_open_memo),
memo_shell_view);
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index 87bb6984dc..380d54ef3d 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -47,6 +47,24 @@ task_shell_view_process_completed_tasks (ETaskShellView *task_shell_view)
}
static void
+task_shell_view_preview_on_url_cb (EShellView *shell_view,
+ const gchar *url)
+{
+ EShellTaskbar *shell_taskbar;
+ gchar *message;
+
+ shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
+
+ if (url == NULL || *url == '\0')
+ e_shell_taskbar_set_message (shell_taskbar, NULL);
+ else {
+ message = g_strdup_printf (_("Click to open %s"), url);
+ e_shell_taskbar_set_message (shell_taskbar, message);
+ g_free (message);
+ }
+}
+
+static void
task_shell_view_table_popup_event_cb (EShellView *shell_view,
GdkEventButton *event)
{
@@ -214,12 +232,13 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
ETaskShellContent *task_shell_content;
ETaskShellSidebar *task_shell_sidebar;
EShell *shell;
+ EShellView *shell_view;
EShellBackend *shell_backend;
EShellContent *shell_content;
EShellSettings *shell_settings;
EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
- EShellView *shell_view;
+ ECalComponentPreview *task_preview;
ECalendarTable *task_table;
ECalModel *model;
ETable *table;
@@ -243,6 +262,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
priv->task_shell_sidebar = g_object_ref (shell_sidebar);
task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
+ task_preview = e_task_shell_content_get_task_preview (task_shell_content);
task_table = e_task_shell_content_get_task_table (task_shell_content);
model = e_calendar_table_get_model (task_table);
table = e_calendar_table_get_table (task_table);
@@ -256,6 +276,11 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
task_shell_view);
g_signal_connect_swapped (
+ task_preview, "on-url",
+ G_CALLBACK (task_shell_view_preview_on_url_cb),
+ task_shell_view);
+
+ g_signal_connect_swapped (
task_table, "open-component",
G_CALLBACK (e_task_shell_view_open_task),
task_shell_view);