Re: [evolution-patches] [Calendar] Fix for 225816
- From: Johnny Jacob <johnnyjacob gmail com>
- To: chen <pchenthill novell com>
- Cc: evolution-patches gnome org
- Subject: Re: [evolution-patches] [Calendar] Fix for 225816
- Date: Wed, 25 Jan 2006 12:13:23 +0530
Hi
Thanks for the comments. reworked the patch
Please review
Thanks
Johnny
On 1/20/06, chen <pchenthill novell com> wrote:
> Hi,
> Why do u call sensitize widgets in edit_button_cb as that button
> would be disabled if the calendar is readonly ?
>
> 252 + action = malloc ( sizeof (ECalComponentAlarmAction));
> 256 + trigger = malloc ( sizeof (ECalComponentAlarmTrigger));
> Not freed. Better to use g_new0.
>
> e_cal_component_alarm_get_attach (alarm, (&attach));
> attach should be freed
> const char *str;
> unused variable.
>
> The function populate_widgets should be called only when editing alarms.
> Could be renamed so that it indicates that the data is from
> existing alarm component.
>
> Please test the patch by changing the alarm values. Alarm should not
> popup for old values. Please resend with these changes.
>
> thanks, Chenthill.
>
> On Wed, 2006-01-18 at 20:08 +0530, Johnny Jacob wrote:
> > Hi
> >
> > Worked on Bug 225816 – Can't edit existing alarm / reminder, only add or remove.
> >
> > Please review
> >
> > Thanks
> > Johnny
> > _______________________________________________
> > Evolution-patches mailing list
> > Evolution-patches gnome org
> > http://mail.gnome.org/mailman/listinfo/evolution-patches
>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2959
diff -u -p -r1.2959 ChangeLog
--- ChangeLog 25 Jan 2006 04:18:46 -0000 1.2959
+++ ChangeLog 25 Jan 2006 06:36:21 -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-25 Chenthill Palanisamy <pchenthill novell com>
Fixes #327879
Index: 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
--- gui/dialogs/alarm-dialog.c 13 Jan 2006 11:02:32 -0000 1.13
+++ gui/dialogs/alarm-dialog.c 25 Jan 2006 06:38:00 -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_from_alarm (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)
@@ -206,6 +210,7 @@ alarm_to_dialog (Dialog *dialog)
GtkWidget *menu;
GList *l;
gboolean repeat;
+ ECalComponentAlarmAction action;
char *email;
int i;
@@ -239,6 +244,41 @@ 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);
+
+ /* if we are editing a exiting alarm */
+ e_cal_component_alarm_get_action (dialog->alarm, &action);
+
+ if (action)
+ populate_widgets_from_alarm (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 +335,40 @@ 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);
+ g_free (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 )
+{
+ ECalComponentText description;
+ GtkTextBuffer *text_buffer;
+
+ e_cal_component_alarm_get_description (alarm, &description);
+
+ if (!description.value) {
+ 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 +482,27 @@ 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);
+ g_free (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)
@@ -427,12 +522,12 @@ palarm_widgets_to_alarm (Dialog *dialog,
icalattach_unref (attach);
str = e_dialog_editable_get (dialog->palarm_args);
- if (str && *str) {
+
description.value = str;
description.altrep = NULL;
e_cal_component_alarm_set_description (alarm, &description);
- }
+
g_free (str);
/* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that
@@ -449,6 +544,86 @@ palarm_widgets_to_alarm (Dialog *dialog,
}
icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
+ }
+}
+
+static void
+populate_widgets_from_alarm (Dialog *dialog)
+{
+ ECalComponentAlarmTrigger *trigger;
+ ECalComponentAlarmAction *action;
+
+ action = g_new0 (ECalComponentAlarmAction, 1);
+ e_cal_component_alarm_get_action (dialog->alarm, action);
+ g_return_if_fail ( action != NULL );
+
+ trigger = g_new0 (ECalComponentAlarmTrigger, 1);
+ 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: 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
--- gui/dialogs/alarm-list-dialog.c 26 Nov 2005 02:31:51 -0000 1.7
+++ gui/dialogs/alarm-list-dialog.c 25 Jan 2006 06:38:09 -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,31 @@ 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);
+}
+
/* Callback used for the "delete reminder" button */
static void
delete_clicked_cb (GtkButton *button, gpointer data)
@@ -208,6 +237,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: 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
--- gui/dialogs/alarm-list-dialog.glade 2 Feb 2005 22:56:51 -0000 1.3
+++ gui/dialogs/alarm-list-dialog.glade 25 Jan 2006 06:38:23 -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]