From 4d40aee55684753f23410cf6219f6c20aa3b6cf8 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 7 Apr 2009 17:21:08 +0000 Subject: ** Fix for bug #523802 2009-04-07 Milan Crha ** Fix for bug #523802 * gui/e-tasks.h: (e_tasks_get_preview): * gui/e-tasks.c: (e_tasks_get_preview): * gui/e-cal-component-preview.h: (e_cal_component_preview_get_html): * gui/e-cal-component-preview.c: (e_cal_component_preview_get_html): * gui/tasks-control.c: (tasks_control_new), (tasks_sensitize_table[]), (tasks_control_sensitize_commands), (tasks_control_focus_changed), (tasks_control_copy_cmd): * gui/e-memos.h: (e_memos_get_preview): * gui/e-memos.c: (e_memos_get_preview): * gui/e-cal-component-memo-preview.h: * gui/e-cal-component-memo-preview.c: (e_cal_component_memo_preview_get_html): * gui/memos-control.c: (memos_control_new), (memos_control_sensitize_commands), (memos_control_focus_changed), (memos_control_copy_cmd): Use copy of the preview panel, when focused, and events' copy otherwise. svn path=/trunk/; revision=37502 --- calendar/gui/memos-control.c | 51 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'calendar/gui/memos-control.c') diff --git a/calendar/gui/memos-control.c b/calendar/gui/memos-control.c index 8e5eaf23b2..54f1dbc2ae 100644 --- a/calendar/gui/memos-control.c +++ b/calendar/gui/memos-control.c @@ -35,12 +35,14 @@ #include #include #include +#include #include "calendar-config.h" #include "e-memos.h" #include "e-memo-table.h" #include "print.h" #include "memos-control.h" +#include "e-cal-component-memo-preview.h" #include "evolution-shell-component-utils.h" #define FIXED_MARGIN .05 @@ -74,13 +76,19 @@ static void memos_control_print_preview_cmd (BonoboUIComponent *uic, gpointer data, const char *path); +struct focus_changed_data { + BonoboControl *control; + EMemos *memos; +}; +static gboolean memos_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data); BonoboControl * memos_control_new (void) { BonoboControl *control; - GtkWidget *memos; + GtkWidget *memos, *preview; + struct focus_changed_data *fc_data; memos = e_memos_new (); if (!memos) @@ -96,6 +104,15 @@ memos_control_new (void) g_signal_connect (control, "activate", G_CALLBACK (memos_control_activate_cb), memos); + fc_data = g_new0 (struct focus_changed_data, 1); + fc_data->control = control; + fc_data->memos = E_MEMOS (memos); + + preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (fc_data->memos))); + g_object_set_data_full (G_OBJECT (preview), "memos-ctrl-fc-data", fc_data, g_free); + g_signal_connect (preview, "focus-in-event", G_CALLBACK (memos_control_focus_changed), fc_data); + g_signal_connect (preview, "focus-out-event", G_CALLBACK (memos_control_focus_changed), fc_data); + return control; } @@ -122,9 +139,10 @@ void memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, int n_selected) { BonoboUIComponent *uic; - gboolean read_only = TRUE; + gboolean read_only = TRUE, preview_active; ECal *ecal; ECalModel *model; + GtkWidget *preview; uic = bonobo_control_get_ui_component (control); g_return_if_fail (uic != NULL); @@ -132,6 +150,9 @@ memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, int n_s if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL) return; + preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (memos))); + preview_active = preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview); + model = e_memo_table_get_model (e_memos_get_calendar_table (memos)); ecal = e_cal_model_get_default_client (model); if (ecal) @@ -141,13 +162,13 @@ memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, int n_s n_selected != 1 ? "0" : "1", NULL); bonobo_ui_component_set_prop (uic, "/commands/MemosCut", "sensitive", - n_selected == 0 || read_only ? "0" : "1", + n_selected == 0 || read_only || preview_active ? "0" : "1", NULL); bonobo_ui_component_set_prop (uic, "/commands/MemosCopy", "sensitive", n_selected == 0 ? "0" : "1", NULL); bonobo_ui_component_set_prop (uic, "/commands/MemosPaste", "sensitive", - read_only ? "0" : "1", + read_only || preview_active ? "0" : "1", NULL); bonobo_ui_component_set_prop (uic, "/commands/MemosDelete", "sensitive", n_selected == 0 || read_only ? "0" : "1", @@ -165,6 +186,16 @@ selection_changed_cb (EMemos *memos, int n_selected, gpointer data) memos_control_sensitize_commands (control, memos, n_selected); } +static gboolean +memos_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data) +{ + g_return_val_if_fail (fc_data != NULL, FALSE); + + memos_control_sensitize_commands (fc_data->control, fc_data->memos, e_table_selected_count (e_memo_table_get_table (e_memos_get_calendar_table (fc_data->memos)))); + + return FALSE; +} + static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("MemosOpenMemo", memos_control_open_memo_cmd), BONOBO_UI_VERB ("MemosNewMemo", memos_control_new_memo_cmd), @@ -304,10 +335,18 @@ memos_control_copy_cmd (BonoboUIComponent *uic, { EMemos *memos; EMemoTable *cal_table; + GtkWidget *preview; memos = E_MEMOS (data); - cal_table = e_memos_get_calendar_table (memos); - e_memo_table_copy_clipboard (cal_table); + + preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (memos))); + if (preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview)) { + /* copy selected text in a preview when that's shown and focused */ + gtk_html_copy (GTK_HTML (preview)); + } else { + cal_table = e_memos_get_calendar_table (memos); + e_memo_table_copy_clipboard (cal_table); + } } static void -- cgit