[evolution] Bug #611165 - Use memo start date from a calendar view, if active
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #611165 - Use memo start date from a calendar view, if active
- Date: Wed, 23 Jun 2010 18:43:36 +0000 (UTC)
commit bcdea3f01e0b614a0e366ee19c0ff6810e43b32d
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 23 20:42:03 2010 +0200
Bug #611165 - Use memo start date from a calendar view, if active
calendar/gui/comp-util.c | 53 ++++++++++++++++++++++++++
calendar/gui/comp-util.h | 4 ++
modules/calendar/e-cal-shell-view-memopad.c | 3 +-
modules/calendar/e-memo-shell-backend.c | 6 ++-
modules/calendar/e-memo-shell-view-actions.c | 3 +-
5 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c
index e8cbc72..2254d49 100644
--- a/calendar/gui/comp-util.c
+++ b/calendar/gui/comp-util.c
@@ -35,6 +35,10 @@
#include "e-util/e-categories-config.h"
#include "common/authentication.h"
+#include "gnome-cal.h"
+#include "shell/e-shell-window.h"
+#include "shell/e-shell-view.h"
+
/**
@@ -425,6 +429,55 @@ cal_comp_memo_new_with_defaults (ECal *client)
return comp;
}
+void
+cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell)
+{
+ GtkWindow *window;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (shell != NULL);
+
+ window = e_shell_get_active_window (shell);
+ if (window && E_IS_SHELL_WINDOW (window)) {
+ EShellWindow *shell_window = E_SHELL_WINDOW (window);
+
+ if (e_shell_window_get_active_view (shell_window)
+ && g_str_equal (e_shell_window_get_active_view (shell_window), "calendar")) {
+ EShellView *view;
+ GnomeCalendar *gnome_cal;
+ time_t start = 0, end = 0;
+ icaltimezone *zone;
+ struct icaltimetype itt;
+ icalcomponent *icalcomp;
+ icalproperty *prop;
+
+ view = e_shell_window_peek_shell_view (shell_window, "calendar");
+ g_return_if_fail (view != NULL);
+
+ gnome_cal = NULL;
+ g_object_get (G_OBJECT (e_shell_view_get_shell_content (view)), "calendar", &gnome_cal, NULL);
+ g_return_if_fail (gnome_cal != NULL);
+
+ gnome_calendar_get_current_time_range (gnome_cal, &start, &end);
+ g_return_if_fail (start != 0);
+
+ zone = e_cal_model_get_timezone (gnome_calendar_get_model (gnome_cal));
+ itt = icaltime_from_timet_with_zone (start, FALSE, zone);
+
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ prop = icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY);
+ if (prop) {
+ icalproperty_set_dtstart (prop, itt);
+ } else {
+ prop = icalproperty_new_dtstart (itt);
+ icalcomponent_add_property (icalcomp, prop);
+ }
+
+ e_cal_component_rescan (comp);
+ }
+ }
+}
+
/**
* cal_comp_util_get_n_icons:
* @comp: A calendar component object.
diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h
index d328627..7b1bf28 100644
--- a/calendar/gui/comp-util.h
+++ b/calendar/gui/comp-util.h
@@ -29,6 +29,8 @@
#include <libecal/e-cal-component.h>
#include <libecal/e-cal.h>
+struct _EShell;
+
void cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone);
/* Returns TRUE if the component uses the given timezone for both DTSTART
@@ -50,6 +52,8 @@ ECalComponent *cal_comp_event_new_with_current_time (ECal *client, gboolean all_
ECalComponent *cal_comp_task_new_with_defaults (ECal *client);
ECalComponent *cal_comp_memo_new_with_defaults (ECal *client);
+void cal_comp_update_time_by_active_window (ECalComponent *comp, struct _EShell *shell);
+
void cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list);
GSList *cal_comp_selection_get_string_list (GtkSelectionData *data);
diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c
index 61ef73d..267f814 100644
--- a/modules/calendar/e-cal-shell-view-memopad.c
+++ b/modules/calendar/e-cal-shell-view-memopad.c
@@ -80,8 +80,9 @@ action_calendar_memopad_new_cb (GtkAction *action,
g_slist_free (list);
client = comp_data->client;
- editor = memo_editor_new (client, shell, COMP_EDITOR_NEW_ITEM);
comp = cal_comp_memo_new_with_defaults (client);
+ cal_comp_update_time_by_active_window (comp, shell);
+ editor = memo_editor_new (client, shell, COMP_EDITOR_NEW_ITEM);
comp_editor_edit_comp (editor, comp);
gtk_window_present (GTK_WINDOW (editor));
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index a51a5fc..2a0c277 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -210,8 +210,9 @@ memo_shell_backend_memo_new_cb (ECal *cal,
flags |= COMP_EDITOR_NEW_ITEM;
- editor = memo_editor_new (cal, shell, flags);
comp = cal_comp_memo_new_with_defaults (cal);
+ cal_comp_update_time_by_active_window (comp, shell);
+ editor = memo_editor_new (cal, shell, flags);
comp_editor_edit_comp (editor, comp);
gtk_window_present (GTK_WINDOW (editor));
@@ -237,8 +238,9 @@ memo_shell_backend_memo_shared_new_cb (ECal *cal,
flags |= COMP_EDITOR_IS_SHARED;
flags |= COMP_EDITOR_USER_ORG;
- editor = memo_editor_new (cal, shell, flags);
comp = cal_comp_memo_new_with_defaults (cal);
+ cal_comp_update_time_by_active_window (comp, shell);
+ editor = memo_editor_new (cal, shell, flags);
comp_editor_edit_comp (editor, comp);
gtk_window_present (GTK_WINDOW (editor));
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 69bf9c5..c915da2 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -362,8 +362,9 @@ action_memo_new_cb (GtkAction *action,
g_return_if_fail (client != NULL);
- editor = memo_editor_new (client, shell, COMP_EDITOR_NEW_ITEM);
comp = cal_comp_memo_new_with_defaults (client);
+ cal_comp_update_time_by_active_window (comp, shell);
+ editor = memo_editor_new (client, shell, COMP_EDITOR_NEW_ITEM);
comp_editor_edit_comp (editor, comp);
gtk_window_present (GTK_WINDOW (editor));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]