From 2e266d5ae53296ce9b647c2318b42b2d9111a7b1 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 22 Jun 2004 22:35:41 +0000 Subject: HIGify and newer design; alarm page is gone, Cancel/OK buttons for the 2004-06-22 JP Rosevear * gui/dialogs/Makefile.am, gui/dialogs/alarm-dialog.c, gui/dialogs/alarm-dialog.glade, gui/dialogs/alarm-dialog.h, gui/dialogs/alarm-list-dialog.c, gui/dialogs/alarm-list-dialog.glade, gui/dialogs/alarm-list-dialog.h, gui/dialogs/alarm-options.c, gui/dialogs/alarm-options.h, gui/dialogs/alarm-page.c, gui/dialogs/alarm-page.glade, gui/dialogs/alarm-page.h, gui/dialogs/comp-editor.c, gui/dialogs/comp-editor.h, gui/dialogs/event-editor.c, gui/dialogs/event-page.c, gui/dialogs/event-page.glade, gui/dialogs/meeting-page.c, gui/dialogs/meeting-page.glade, gui/dialogs/recurrence-page.c, gui/dialogs/recurrence-page.glade, gui/dialogs/task-details-page.c, gui/dialogs/task-details-page.glade, gui/dialogs/task-editor.c, gui/dialogs/task-page.c, gui/dialogs/task-page.glade: HIGify and newer design; alarm page is gone, Cancel/OK buttons for the dialog, no more menus; slightly improve read-only workings for entry areas svn path=/trunk/; revision=26463 --- calendar/gui/dialogs/alarm-list-dialog.c | 244 +++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 calendar/gui/dialogs/alarm-list-dialog.c (limited to 'calendar/gui/dialogs/alarm-list-dialog.c') diff --git a/calendar/gui/dialogs/alarm-list-dialog.c b/calendar/gui/dialogs/alarm-list-dialog.c new file mode 100644 index 0000000000..42b992dde7 --- /dev/null +++ b/calendar/gui/dialogs/alarm-list-dialog.c @@ -0,0 +1,244 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* Evolution calendar - Alarm page of the calendar component dialogs + * + * Copyright (C) 2001-2003 Ximian, Inc. + * + * Authors: Federico Mena-Quintero + * Miguel de Icaza + * Seth Alves + * JP Rosevear + * Hans Petter Jansson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-time-utils.h" +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-icon-factory.h" +#include "alarm-dialog.h" +#include "alarm-list-dialog.h" + + + +typedef struct { + /* Glade XML data */ + GladeXML *xml; + + /* The client */ + ECal *ecal; + + /* The list store */ + EAlarmList *list_store; + + /* Toplevel */ + GtkWidget *toplevel; + + GtkWidget *list; + GtkWidget *add; + GtkWidget *delete; +} Dialog; + +/* Gets the widgets from the XML file and returns TRUE if they are all available. */ +static gboolean +get_widgets (Dialog *dialog) +{ +#define GW(name) glade_xml_get_widget (dialog->xml, name) + + dialog->toplevel = GW ("alarm-list-dialog"); + if (!dialog->toplevel) + return FALSE; + + dialog->list = GW ("list"); + dialog->add = GW ("add"); + dialog->delete = GW ("delete"); + +#undef GW + + return (dialog->list + && dialog->add + && dialog->delete); +} + +static void +sensitize_buttons (Dialog *dialog) +{ + GtkTreeSelection *selection; + GtkTreeIter iter; + gboolean have_selected; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)); + have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter); + + if (e_cal_get_one_alarm_only (dialog->ecal) && have_selected) + gtk_widget_set_sensitive (dialog->add, FALSE); + else + gtk_widget_set_sensitive (dialog->add, TRUE); + gtk_widget_set_sensitive (dialog->delete, have_selected); +} + +/* Callback used for the "add reminder" button */ +static void +add_clicked_cb (GtkButton *button, gpointer data) +{ + Dialog *dialog = data; + ECalComponentAlarm *alarm; + GtkTreeView *view; + GtkTreeIter iter; + icalcomponent *icalcomp; + icalproperty *icalprop; + + view = GTK_TREE_VIEW (dialog->list); + + alarm = e_cal_component_alarm_new (); + + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); + icalprop = icalproperty_new_x ("1"); + icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); + icalcomponent_add_property (icalcomp, icalprop); + + if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) { + e_alarm_list_append (dialog->list_store, &iter, alarm); + gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter); + } else { + e_cal_component_alarm_free (alarm); + } + + sensitize_buttons (dialog); +} + +/* Callback used for the "delete reminder" button */ +static void +delete_clicked_cb (GtkButton *button, gpointer data) +{ + Dialog *dialog = data; + GtkTreeSelection *selection; + GtkTreeIter iter; + GtkTreePath *path; + gboolean valid_iter; + + 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; + } + + path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->list_store), &iter); + e_alarm_list_remove (dialog->list_store, &iter); + + /* Select closest item after removal */ + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list_store), &iter, path); + if (!valid_iter) { + gtk_tree_path_prev (path); + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list_store), &iter, path); + } + + if (valid_iter) + gtk_tree_selection_select_iter (selection, &iter); + + sensitize_buttons (dialog); + + gtk_tree_path_free (path); +} + +/* Hooks the widget signals */ +static void +init_widgets (Dialog *dialog) +{ + GtkTreeViewColumn *column; + GtkCellRenderer *cell_renderer; + + /* View */ + gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->list), + GTK_TREE_MODEL (dialog->list_store)); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Action/Trigger")); + cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + gtk_tree_view_column_pack_start (column, cell_renderer, TRUE); + gtk_tree_view_column_add_attribute (column, cell_renderer, "text", E_ALARM_LIST_COLUMN_DESCRIPTION); + gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->list), column); + + /* Reminder buttons */ + g_signal_connect (dialog->add, "clicked", + G_CALLBACK (add_clicked_cb), dialog); + g_signal_connect (dialog->delete, "clicked", + G_CALLBACK (delete_clicked_cb), dialog); +} + +gboolean +alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store) +{ + Dialog dialog; + int response_id; + GList *icon_list; + + dialog.ecal = ecal; + dialog.list_store = list_store; + + dialog.xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-list-dialog.glade", NULL, NULL); + if (!dialog.xml) { + g_message (G_STRLOC ": Could not load the Glade XML file!"); + return FALSE; + } + + if (!get_widgets (&dialog)) { + g_object_unref(dialog.xml); + return FALSE; + } + + init_widgets (&dialog); + + sensitize_buttons (&dialog); + + icon_list = e_icon_factory_get_icon_list ("stock_calendar"); + if (icon_list) { + gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list); + g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); + g_list_free (icon_list); + } + + gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), + GTK_WINDOW (parent)); + + response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); + gtk_widget_hide (dialog.toplevel); + +#if 0 + if (response_id == GTK_RESPONSE_OK) + dialog_to_alarm (&dialog); +#endif + + gtk_widget_destroy (dialog.toplevel); + g_object_unref (dialog.xml); + + return TRUE; +} -- cgit v1.2.3