diff options
author | Milan Crha <mcrha@redhat.com> | 2009-04-08 01:21:08 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2009-04-08 01:21:08 +0800 |
commit | 4d40aee55684753f23410cf6219f6c20aa3b6cf8 (patch) | |
tree | a8e057919363066ae6b8c734bdc94fd05df66a2f /calendar | |
parent | 7b76c88e4d1a4a510ac88c2e1f177fd8c9c3f830 (diff) | |
download | gsoc2013-evolution-4d40aee55684753f23410cf6219f6c20aa3b6cf8.tar.gz gsoc2013-evolution-4d40aee55684753f23410cf6219f6c20aa3b6cf8.tar.zst gsoc2013-evolution-4d40aee55684753f23410cf6219f6c20aa3b6cf8.zip |
** Fix for bug #523802
2009-04-07 Milan Crha <mcrha@redhat.com>
** 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
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 21 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-memo-preview.c | 8 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-memo-preview.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-preview.c | 8 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-preview.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-memos.c | 15 | ||||
-rw-r--r-- | calendar/gui/e-memos.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-tasks.c | 15 | ||||
-rw-r--r-- | calendar/gui/e-tasks.h | 1 | ||||
-rw-r--r-- | calendar/gui/memos-control.c | 51 | ||||
-rw-r--r-- | calendar/gui/tasks-control.c | 56 |
11 files changed, 167 insertions, 11 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 1048dde990..176c6fcca7 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,24 @@ +2009-04-07 Milan Crha <mcrha@redhat.com> + + ** 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. + 2009-04-02 Milan Crha <mcrha@redhat.com> ** Fix for bug #577717 diff --git a/calendar/gui/e-cal-component-memo-preview.c b/calendar/gui/e-cal-component-memo-preview.c index 3f2e68aba0..f564538a59 100644 --- a/calendar/gui/e-cal-component-memo-preview.c +++ b/calendar/gui/e-cal-component-memo-preview.c @@ -358,3 +358,11 @@ e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview) gtk_html_load_empty (GTK_HTML (priv->html)); } +GtkWidget * +e_cal_component_memo_preview_get_html (ECalComponentMemoPreview *preview) +{ + g_return_val_if_fail (preview != NULL, NULL); + g_return_val_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview), NULL); + + return preview->priv->html; +} diff --git a/calendar/gui/e-cal-component-memo-preview.h b/calendar/gui/e-cal-component-memo-preview.h index 144e54fe5c..7d77a0aa32 100644 --- a/calendar/gui/e-cal-component-memo-preview.h +++ b/calendar/gui/e-cal-component-memo-preview.h @@ -62,5 +62,6 @@ void e_cal_component_memo_preview_set_default_timezone (ECalComponentMemoPreview void e_cal_component_memo_preview_display (ECalComponentMemoPreview *preview, ECal *ecal, ECalComponent *comp); void e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview); +GtkWidget *e_cal_component_memo_preview_get_html (ECalComponentMemoPreview *preview); #endif /* _E_CAL_COMPONENT_MEMO_PREVIEW_H_ */ diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index dcc5504311..221ae36753 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -449,3 +449,11 @@ e_cal_component_preview_clear (ECalComponentPreview *preview) gtk_html_load_empty (GTK_HTML (priv->html)); } +GtkWidget * +e_cal_component_preview_get_html (ECalComponentPreview *preview) +{ + g_return_val_if_fail (preview != NULL, NULL); + g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL); + + return preview->priv->html; +} diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h index e5cc98109c..73e8126a36 100644 --- a/calendar/gui/e-cal-component-preview.h +++ b/calendar/gui/e-cal-component-preview.h @@ -68,5 +68,6 @@ void e_cal_component_preview_clear (ECalComponentPreview *preview); /* Callback used when GtkHTML widget requests URL */ void e_cal_comp_preview_url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *html_stream, gpointer data); +GtkWidget *e_cal_component_preview_get_html (ECalComponentPreview *preview); #endif /* _E_CAL_COMPONENT_PREVIEW_H_ */ diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c index fa92195121..71cfb4e4c1 100644 --- a/calendar/gui/e-memos.c +++ b/calendar/gui/e-memos.c @@ -1222,3 +1222,18 @@ e_memos_get_calendar_table (EMemos *memos) priv = memos->priv; return E_MEMO_TABLE (priv->memos_view); } + +/** + * e_memos_get_preview: + * @memos: A memos widget. + * + * Queries the #ECalComponentMemoPreview contained in a memos widget. + **/ +GtkWidget * +e_memos_get_preview (EMemos *memos) +{ + g_return_val_if_fail (memos != NULL, NULL); + g_return_val_if_fail (E_IS_MEMOS (memos), NULL); + + return memos->priv->preview; +} diff --git a/calendar/gui/e-memos.h b/calendar/gui/e-memos.h index c4a4e96154..1b3f0b8c72 100644 --- a/calendar/gui/e-memos.h +++ b/calendar/gui/e-memos.h @@ -82,5 +82,6 @@ void e_memos_setup_view_menus (EMemos *memos, BonoboUIComponent *uic); void e_memos_discard_view_menus (EMemos *memos); EMemoTable *e_memos_get_calendar_table (EMemos *memos); +GtkWidget *e_memos_get_preview (EMemos *memos); #endif /* _E_MEMOS_H_ */ diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index 1483a06203..f617a1bbd3 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -1563,3 +1563,18 @@ e_tasks_get_calendar_table (ETasks *tasks) priv = tasks->priv; return E_CALENDAR_TABLE (priv->tasks_view); } + +/** + * e_tasks_get_preview: + * @tasks: A tasks widget. + * + * Queries the #ECalComponentPreview contained in a tasks widget. + **/ +GtkWidget * +e_tasks_get_preview (ETasks *tasks) +{ + g_return_val_if_fail (tasks != NULL, NULL); + g_return_val_if_fail (E_IS_TASKS (tasks), NULL); + + return tasks->priv->preview; +} diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index f94ee27ad9..41fcd2d78a 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -87,5 +87,6 @@ void e_tasks_discard_view_menus (ETasks *tasks); struct _ECalMenu *e_tasks_get_tasks_menu (ETasks *tasks); ECalendarTable *e_tasks_get_calendar_table (ETasks *tasks); +GtkWidget *e_tasks_get_preview (ETasks *tasks); #endif /* _E_TASKS_H_ */ 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 <e-util/e-icon-factory.h> #include <e-util/e-print.h> #include <e-util/e-util-private.h> +#include <gtkhtml/gtkhtml.h> #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 diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index 5788b010b9..a0633aa636 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -43,6 +43,7 @@ #include "evolution-shell-component-utils.h" #include "e-util/e-menu.h" #include "e-cal-menu.h" +#include "e-cal-component-preview.h" #include "e-util/e-menu.h" #include "itip-utils.h" @@ -96,11 +97,19 @@ static void tasks_control_view_preview (BonoboUIComponent *uic, const char *state, void *data); +struct focus_changed_data { + BonoboControl *control; + ETasks *tasks; +}; + +static gboolean tasks_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data); + BonoboControl * tasks_control_new (void) { BonoboControl *control; - GtkWidget *tasks; + GtkWidget *tasks, *preview; + struct focus_changed_data *fc_data; tasks = e_tasks_new (); if (!tasks) @@ -116,6 +125,15 @@ tasks_control_new (void) g_signal_connect (control, "activate", G_CALLBACK (tasks_control_activate_cb), tasks); + fc_data = g_new0 (struct focus_changed_data, 1); + fc_data->control = control; + fc_data->tasks = E_TASKS (tasks); + + preview = e_cal_component_preview_get_html (E_CAL_COMPONENT_PREVIEW (e_tasks_get_preview (fc_data->tasks))); + g_object_set_data_full (G_OBJECT (preview), "tasks-ctrl-fc-data", fc_data, g_free); + g_signal_connect (preview, "focus-in-event", G_CALLBACK (tasks_control_focus_changed), fc_data); + g_signal_connect (preview, "focus-out-event", G_CALLBACK (tasks_control_focus_changed), fc_data); + return control; } @@ -160,11 +178,13 @@ sensitize_items(BonoboUIComponent *uic, struct _tasks_sensitize_item *items, gui } } +#define E_CAL_TASKS_PREVIEW_ACTIVE (1<<31) + static struct _tasks_sensitize_item tasks_sensitize_table[] = { { "TasksOpenTask", E_CAL_MENU_SELECT_ONE }, - { "TasksCut", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE }, + { "TasksCut", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE | E_CAL_TASKS_PREVIEW_ACTIVE }, { "TasksCopy", E_CAL_MENU_SELECT_ANY }, - { "TasksPaste", E_CAL_MENU_SELECT_EDITABLE }, + { "TasksPaste", E_CAL_MENU_SELECT_EDITABLE | E_CAL_TASKS_PREVIEW_ACTIVE }, { "TasksDelete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE }, { "TasksMarkComplete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE | E_CAL_MENU_SELECT_NOTCOMPLETE}, { "TasksPurge", E_CAL_MENU_SELECT_EDITABLE }, @@ -188,6 +208,7 @@ tasks_control_sensitize_commands (BonoboControl *control, ETasks *tasks, int n_s GPtrArray *events; GSList *selected = NULL, *l = NULL; ECalendarTable *cal_table; + GtkWidget *preview; uic = bonobo_control_get_ui_component (control); g_return_if_fail (uic != NULL); @@ -214,6 +235,12 @@ tasks_control_sensitize_commands (BonoboControl *control, ETasks *tasks, int n_s if (ecal) e_cal_is_read_only (ecal, &read_only, NULL); + preview = e_cal_component_preview_get_html (E_CAL_COMPONENT_PREVIEW (e_tasks_get_preview (tasks))); + if (preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview)) + t->target.mask = t->target.mask | E_CAL_TASKS_PREVIEW_ACTIVE; + else + t->target.mask = t->target.mask & (~E_CAL_TASKS_PREVIEW_ACTIVE); + sensitize_items (uic, tasks_sensitize_table, t->target.mask); e_menu_update_target ((EMenu *)menu, (EMenuTarget *)t); } @@ -229,6 +256,16 @@ selection_changed_cb (ETasks *tasks, int n_selected, gpointer data) tasks_control_sensitize_commands (control, tasks, n_selected); } +static gboolean +tasks_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data) +{ + g_return_val_if_fail (fc_data != NULL, FALSE); + + tasks_control_sensitize_commands (fc_data->control, fc_data->tasks, -1); + + return FALSE; +} + static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("TasksOpenTask", tasks_control_open_task_cmd), BONOBO_UI_VERB ("TasksNewTask", tasks_control_new_task_cmd), @@ -379,10 +416,19 @@ tasks_control_copy_cmd (BonoboUIComponent *uic, { ETasks *tasks; ECalendarTable *cal_table; + GtkWidget *preview; tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - e_calendar_table_copy_clipboard (cal_table); + + + preview = e_cal_component_preview_get_html (E_CAL_COMPONENT_PREVIEW (e_tasks_get_preview (tasks))); + 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_tasks_get_calendar_table (tasks); + e_calendar_table_copy_clipboard (cal_table); + } } static void |