[evolution-patches] [Calendar] Fix for 225816
- From: Johnny Jacob <johnnyjacob gmail com>
- To: evolution-patches gnome org
- Subject: [evolution-patches] [Calendar] Fix for 225816
- Date: Wed, 18 Jan 2006 20:08:05 +0530
Hi
Worked on Bug 225816 – Can't edit existing alarm / reminder, only add or remove.
Please review
Thanks
Johnny
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2945
diff -u -p -r1.2945 ChangeLog
--- calendar/ChangeLog 16 Jan 2006 16:22:33 -0000 1.2945
+++ calendar/ChangeLog 18 Jan 2006 14:33:08 -0000
@@ -1,3 +1,19 @@
+2006-01-18 Johnny Jacob <johnnyjacob gmail com>
+
+ Fixes #225816
+ * gui/dialogs/alatm-list-dialog.glade : Added edit button.
+ * gui/dialogs/alarm-list-dialog.c (init_widgets), (get_widgets) :
+ Get and connect signals for edit button.
+ (sensitize_buttons) : Handle the sesitivity of edit button.
+ (edit_clicked_cb) : Added. Handle edit button click event.
+ * gui/dialogs/alarm-dialogs.c (populate_widgets) : Added. Extract data
+ from alarm and fill in the widgets.
+ (alarm_to_repeat_widgets): Added. Alarm data to repeat widgets.
+ (alarm_to_aalarm_widgets): Added. Alarm data to audio alarm widgets.
+ (alarm_to_dalarm_widgets): Added. Alarm data to display alarm widgets.
+ (alarm_to_palarm_widgets): Added. Alarm data to procedure alarm widgets.
+ (alarm_to_dialog): call populate_widgets.
+
2006-01-16 Johnny Jacob <johnnyjacob gmail com>
* gui/dialogs/event-page.c (edit_button_cb): Added.
Index: calendar/gui/dialogs/alarm-list-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/alarm-list-dialog.c,v
retrieving revision 1.7
diff -u -p -r1.7 alarm-list-dialog.c
--- calendar/gui/dialogs/alarm-list-dialog.c 26 Nov 2005 02:31:51 -0000 1.7
+++ calendar/gui/dialogs/alarm-list-dialog.c 18 Jan 2006 14:33:19 -0000
@@ -65,6 +65,7 @@ typedef struct {
GtkWidget *list;
GtkWidget *add;
+ GtkWidget *edit;
GtkWidget *delete;
} Dialog;
@@ -80,12 +81,14 @@ get_widgets (Dialog *dialog)
dialog->list = GW ("list");
dialog->add = GW ("add");
+ dialog->edit = GW ("edit");
dialog->delete = GW ("delete");
#undef GW
return (dialog->list
&& dialog->add
+ && dialog->edit
&& dialog->delete);
}
@@ -111,6 +114,7 @@ sensitize_buttons (Dialog *dialog)
else
gtk_widget_set_sensitive (dialog->add, TRUE);
gtk_widget_set_sensitive (dialog->delete, have_selected && !read_only);
+ gtk_widget_set_sensitive (dialog->edit, have_selected && !read_only);
}
/* Callback used for the "add reminder" button */
@@ -143,6 +147,33 @@ add_clicked_cb (GtkButton *button, gpoin
sensitize_buttons (dialog);
}
+/* Callback used for the "edit reminder" button */
+static void
+edit_clicked_cb (GtkButton *button, gpointer data)
+{
+ Dialog *dialog = data;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ ECalComponentAlarm *alarm;
+ GtkTreeView *view;
+
+ view = GTK_TREE_VIEW (dialog->list);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list));
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ g_warning ("Could not get a selection to delete.");
+ return;
+ }
+
+ alarm = e_alarm_list_get_alarm (dialog->list_store, &iter);
+
+ if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm))
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter);
+
+ sensitize_buttons (dialog);
+}
+
/* Callback used for the "delete reminder" button */
static void
delete_clicked_cb (GtkButton *button, gpointer data)
@@ -208,6 +239,8 @@ init_widgets (Dialog *dialog)
G_CALLBACK (add_clicked_cb), dialog);
g_signal_connect (dialog->delete, "clicked",
G_CALLBACK (delete_clicked_cb), dialog);
+ g_signal_connect (dialog->edit, "clicked",
+ G_CALLBACK (edit_clicked_cb), dialog);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)), "changed",
G_CALLBACK (selection_changed_cb), dialog);
Index: calendar/gui/dialogs/alarm-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/alarm-dialog.c,v
retrieving revision 1.13
diff -u -p -r1.13 alarm-dialog.c
--- calendar/gui/dialogs/alarm-dialog.c 13 Jan 2006 11:02:32 -0000 1.13
+++ calendar/gui/dialogs/alarm-dialog.c 18 Jan 2006 14:33:30 -0000
@@ -54,6 +54,7 @@
#include "e-util/e-util-private.h"
#include <libebook/e-destination.h>
#include <libedataserverui/e-name-selector.h>
+#include <libical/icalattach.h>
#include "../calendar-config.h"
#include "comp-editor-util.h"
#include "alarm-dialog.h"
@@ -180,6 +181,9 @@ static const int duration_units_map[] =
-1
};
+static void populate_widgets (Dialog *dialog);
+static void action_selection_done_cb (GtkMenuShell *menu_shell, gpointer data);
+
/* Fills the widgets with default values */
static void
clear_widgets (Dialog *dialog)
@@ -239,6 +243,37 @@ alarm_to_dialog (Dialog *dialog)
/* If we can repeat */
repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
gtk_widget_set_sensitive (dialog->repeat_toggle, repeat);
+
+ populate_widgets (dialog);
+}
+
+static void
+alarm_to_repeat_widgets (Dialog *dialog, ECalComponentAlarm *alarm)
+{
+ ECalComponentAlarmRepeat repeat;
+
+ e_cal_component_alarm_get_repeat (dialog->alarm, &repeat);
+
+ if ( repeat.repetitions ) {
+ e_dialog_toggle_set (dialog->repeat_toggle, TRUE);
+ e_dialog_spin_set (dialog->repeat_quantity, repeat.repetitions);
+ } else
+ return;
+
+ if ( repeat.duration.minutes ) {
+ e_dialog_option_menu_set (dialog->repeat_unit, DUR_MINUTES, duration_units_map);
+ e_dialog_spin_set (dialog->repeat_value, repeat.duration.minutes);
+ }
+
+ if ( repeat.duration.hours ) {
+ e_dialog_option_menu_set (dialog->repeat_unit, DUR_HOURS, duration_units_map);
+ e_dialog_spin_set (dialog->repeat_value, repeat.duration.hours);
+ }
+
+ if ( repeat.duration.days ) {
+ e_dialog_option_menu_set (dialog->repeat_unit, DUR_DAYS, duration_units_map);
+ e_dialog_spin_set (dialog->repeat_value, repeat.duration.days);
+ }
}
static void
@@ -295,6 +330,39 @@ aalarm_widgets_to_alarm (Dialog *dialog,
icalattach_unref (attach);
}
+/* Fills the widgets with audio alarm data */
+static void
+alarm_to_aalarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm)
+{
+ const char *url;
+ icalattach *attach;
+
+ e_cal_component_alarm_get_attach (alarm, (&attach));
+ url = icalattach_get_url (attach);
+
+ if ( !(url && *url) )
+ return;
+
+ e_dialog_toggle_set (dialog->aalarm_sound, TRUE);
+ e_dialog_editable_set (dialog->aalarm_attach, url);
+}
+
+/* Fills the widgets with display alarm data */
+static void
+alarm_to_dalarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm )
+{
+ const char *str;
+ ECalComponentText description;
+ GtkTextBuffer *text_buffer;
+
+ e_cal_component_alarm_get_description (alarm, &description);
+ g_return_if_fail ( description.value != NULL );
+
+ e_dialog_toggle_set (dialog->dalarm_message, TRUE);
+ text_buffer = gtk_text_view_get_buffer (dialog->dalarm_description);
+ gtk_text_buffer_set_text (text_buffer, description.value, -1);
+}
+
/* Fills the display alarm data with the values from the widgets */
static void
dalarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm)
@@ -408,6 +476,26 @@ malarm_widgets_to_alarm (Dialog *dialog,
}
}
+/* Fills the widgets from procedure alarm data */
+static void
+alarm_to_palarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm)
+{
+ ECalComponentText description;
+ const char *url;
+ icalattach *attach;
+
+ e_cal_component_alarm_get_attach (alarm, (&attach));
+ url = icalattach_get_url (attach);
+
+ if ( !(url && *url) )
+ return;
+
+ e_dialog_editable_set (dialog->palarm_program, url);
+ e_cal_component_alarm_get_description (alarm, &description);
+
+ e_dialog_editable_set (dialog->palarm_args, description.value);
+}
+
/* Fills the procedure alarm data with the values from the widgets */
static void
palarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm)
@@ -449,6 +537,86 @@ palarm_widgets_to_alarm (Dialog *dialog,
}
icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
+ }
+}
+
+static void
+populate_widgets (Dialog *dialog)
+{
+ ECalComponentAlarmTrigger *trigger;
+ ECalComponentAlarmAction *action;
+
+ action = malloc ( sizeof (ECalComponentAlarmAction));
+ e_cal_component_alarm_get_action (dialog->alarm, action);
+ g_return_if_fail ( action != NULL );
+
+ trigger = malloc ( sizeof (ECalComponentAlarmTrigger));
+ e_cal_component_alarm_get_trigger (dialog->alarm, trigger);
+ g_return_if_fail ( trigger != NULL );
+
+ if ( *action == E_CAL_COMPONENT_ALARM_NONE )
+ return;
+
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel),_("Edit Alarm"));
+
+ /* Alarm Types */
+ switch ( trigger->type ) {
+ case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
+ e_dialog_option_menu_set (dialog->time, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, time_map);
+ break;
+
+ case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END:
+ e_dialog_option_menu_set (dialog->time, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END, time_map);
+ break;
+ }
+
+ switch ( trigger->u.rel_duration.is_neg ){
+ case 1:
+ e_dialog_option_menu_set (dialog->relative, BEFORE, relative_map);
+ break;
+
+ case 0:
+ e_dialog_option_menu_set (dialog->relative, AFTER, relative_map);
+ break;
+ }
+
+ if ( trigger->u.rel_duration.hours ) {
+ e_dialog_option_menu_set (dialog->value_units, HOURS, value_map);
+ e_dialog_spin_set (dialog->interval_value, trigger->u.rel_duration.hours);
+ }
+
+ if ( trigger->u.rel_duration.minutes ){
+ e_dialog_option_menu_set (dialog->value_units, MINUTES, value_map);
+ e_dialog_spin_set (dialog->interval_value, trigger->u.rel_duration.minutes);
+ }
+
+ if ( trigger->u.rel_duration.days ){
+ e_dialog_option_menu_set (dialog->value_units, DAYS, value_map);
+ e_dialog_spin_set (dialog->interval_value, trigger->u.rel_duration.days);
+ }
+
+ /* Repeat options */
+ alarm_to_repeat_widgets (dialog, dialog->alarm);
+
+ /* Alarm options */
+ e_dialog_option_menu_set (dialog->action, *action, action_map);
+ action_selection_done_cb (dialog->action, dialog);
+
+ switch (*action) {
+ case E_CAL_COMPONENT_ALARM_AUDIO:
+ alarm_to_aalarm_widgets (dialog, dialog->alarm);
+ break;
+
+ case E_CAL_COMPONENT_ALARM_DISPLAY:
+ alarm_to_dalarm_widgets (dialog, dialog->alarm);
+ break;
+
+ case E_CAL_COMPONENT_ALARM_EMAIL:
+ break;
+
+ case E_CAL_COMPONENT_ALARM_PROCEDURE:
+ alarm_to_palarm_widgets (dialog, dialog->alarm);
+ break;
}
}
Index: calendar/gui/dialogs/alarm-list-dialog.glade
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/alarm-list-dialog.glade,v
retrieving revision 1.3
diff -u -p -r1.3 alarm-list-dialog.glade
--- calendar/gui/dialogs/alarm-list-dialog.glade 2 Feb 2005 22:56:51 -0000 1.3
+++ calendar/gui/dialogs/alarm-list-dialog.glade 18 Jan 2006 14:33:37 -0000
@@ -17,6 +17,7 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -93,6 +94,9 @@
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
</widget>
</child>
</widget>
@@ -165,6 +169,10 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -185,6 +193,18 @@
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-remove</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="edit">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-edit</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]