[Planner Dev] First calendar undo patch



Hi guys!

Here goes the fresh new patch for the calendar editor, this one for the
calendar day type editor.

Richard, now that I know in deep the calendar editor, I think it is
wonderful :) 

Cheers

-- 
Alvaro del Castillo San Félix
Lambdaux Software Services S.R.L.
Universidad Rey Juan Carlos
Centro de Apoyo Tecnológico
C/ Tulipán sn 28933 Mostoles, Madrid-Spain
www.lambdaux.com
acs lambdaux com
Index: src/planner-calendar-dialog.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-calendar-dialog.c,v
retrieving revision 1.3
diff -u -b -B -p -r1.3 planner-calendar-dialog.c
--- src/planner-calendar-dialog.c	2 May 2004 16:21:28 -0000	1.3
+++ src/planner-calendar-dialog.c	15 Jun 2004 03:09:03 -0000
@@ -127,6 +127,81 @@ static void          cal_dialog_project_
 static void          cal_dialog_new_dialog_run         (DialogData       *data);
 
 
+typedef struct {
+	PlannerCmd        base;
+
+	MrpCalendar *calendar;
+	MrpDay      *day;
+	MrpDay      *old_day;
+	mrptime      time;
+} CalCmdDayType;
+
+static gboolean
+cal_cmd_day_type_do (PlannerCmd *cmd_base)
+{
+	CalCmdDayType *cmd = (CalCmdDayType*) cmd_base;
+
+	if (g_getenv ("PLANNER_DEBUG_UNDO_CAL")) {
+		g_message ("Changing calendar for day ...");
+	}
+
+	mrp_calendar_set_days (cmd->calendar, cmd->time, cmd->day, -1);
+
+	return TRUE;
+}
+
+static void
+cal_cmd_day_type_undo (PlannerCmd *cmd_base)
+{
+	CalCmdDayType *cmd = (CalCmdDayType*) cmd_base;
+
+	if (g_getenv ("PLANNER_DEBUG_UNDO_CAL")) {
+		g_message ("Undo Changing calendar for day ...");
+	}
+
+	mrp_calendar_set_days (cmd->calendar, cmd->time, cmd->old_day, -1);
+}
+
+
+static void
+cal_cmd_day_type_free (PlannerCmd *cmd_base)
+{
+	CalCmdDayType *cmd = (CalCmdDayType*) cmd_base;
+
+	g_object_unref (cmd->calendar);
+	mrp_day_unref  (cmd->day);
+	mrp_day_unref  (cmd->old_day);
+}
+
+static PlannerCmd *
+planner_cal_cmd_day_type (PlannerWindow  *main_window,
+			  MrpCalendar    *calendar,
+			  MrpDay         *day,
+			  mrptime         time)
+{
+	PlannerCmd    *cmd_base;
+	CalCmdDayType *cmd;
+
+	cmd_base = planner_cmd_new (CalCmdDayType,
+				    _("Change day type"),
+				    cal_cmd_day_type_do,
+				    cal_cmd_day_type_undo,
+				    cal_cmd_day_type_free);
+
+	cmd = (CalCmdDayType*) cmd_base;
+
+	cmd->calendar = g_object_ref (calendar);
+	cmd->day = mrp_day_ref (day);
+	cmd->old_day = mrp_day_ref (mrp_calendar_get_day (calendar, time, FALSE));
+	cmd->time = time;
+			
+	planner_cmd_manager_insert_and_do (planner_window_get_cmd_manager 
+					   (main_window),
+					   cmd_base);
+	return cmd_base;
+}
+
+
 static void
 cal_dialog_setup_option_menu (DialogData *data)
 {
@@ -548,7 +623,8 @@ cal_dialog_apply_clicked_cb (GtkWidget  
 	
 	planner_calendar_get_date (PLANNER_CALENDAR (data->calendar), &y, &m, &d);
 	t = mrp_time_compose (y, m + 1, d, 0, 0, 0);
-	mrp_calendar_set_days (calendar, t, day, -1);
+	/* mrp_calendar_set_days (calendar, t, day, -1); */
+	planner_cal_cmd_day_type (data->main_window, calendar, day, t);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]