From f09486d7376bf2008d022458ad42f450a8c77ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com> Date: Mon, 16 May 2011 16:10:00 +0200 Subject: Bug #649392 - Improve calendar's "Goto" dialog and move it to dialogs --- calendar/gui/Makefile.am | 6 - calendar/gui/dialogs/Makefile.am | 4 + calendar/gui/dialogs/goto-dialog.c | 285 ++++++++++++++++++++++++++++ calendar/gui/dialogs/goto-dialog.h | 34 ++++ calendar/gui/dialogs/goto-dialog.ui | 180 ++++++++++++++++++ calendar/gui/e-cal-list-view.c | 2 +- calendar/gui/e-calendar-view.c | 2 +- calendar/gui/e-day-view.c | 2 +- calendar/gui/e-week-view.c | 2 +- calendar/gui/ea-cal-view.c | 2 +- calendar/gui/goto-dialog.ui | 179 ----------------- calendar/gui/goto.c | 280 --------------------------- calendar/gui/goto.h | 34 ---- modules/calendar/e-cal-shell-view-private.h | 2 +- po/POTFILES.in | 4 +- 15 files changed, 511 insertions(+), 507 deletions(-) create mode 100644 calendar/gui/dialogs/goto-dialog.c create mode 100644 calendar/gui/dialogs/goto-dialog.h create mode 100644 calendar/gui/dialogs/goto-dialog.ui delete mode 100644 calendar/gui/goto-dialog.ui delete mode 100644 calendar/gui/goto.c delete mode 100644 calendar/gui/goto.h diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index a74d4a1a70..0a404d429c 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -42,7 +42,6 @@ ecalendarinclude_HEADERS = \ e-week-view.h \ e-timezone-entry.h \ gnome-cal.h \ - goto.h \ itip-utils.h \ misc.h \ tag-calendar.h \ @@ -74,9 +73,6 @@ libevolution_calendar_la_CPPFLAGS = \ $(EVOLUTION_CALENDAR_CFLAGS) \ $(CAMEL_CFLAGS) -ui_DATA = \ - goto-dialog.ui - etspec_DATA = \ e-calendar-table.etspec \ e-meeting-time-sel.etspec \ @@ -170,8 +166,6 @@ libevolution_calendar_la_SOURCES = \ e-week-view.h \ e-timezone-entry.c \ e-timezone-entry.h \ - goto.c \ - goto.h \ gnome-cal.c \ gnome-cal.h \ itip-utils.c \ diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 38e0c47e62..684550990b 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -36,6 +36,7 @@ ecalendarinclude_HEADERS = \ e-send-options-utils.h \ event-editor.h \ event-page.h \ + goto-dialog.h \ memo-editor.h \ memo-page.h \ recurrence-page.h \ @@ -85,6 +86,8 @@ libcal_dialogs_la_SOURCES = \ event-editor.h \ event-page.c \ event-page.h \ + goto-dialog.c \ + goto-dialog.h \ memo-editor.c \ memo-editor.h \ memo-page.c \ @@ -113,6 +116,7 @@ ui_DATA = \ alarm-list-dialog.ui \ e-delegate-dialog.ui \ event-page.ui \ + goto-dialog.ui \ memo-page.ui \ recurrence-page.ui \ schedule-page.ui \ diff --git a/calendar/gui/dialogs/goto-dialog.c b/calendar/gui/dialogs/goto-dialog.c new file mode 100644 index 0000000000..282d5547ff --- /dev/null +++ b/calendar/gui/dialogs/goto-dialog.c @@ -0,0 +1,285 @@ +/* + * Go to date dialog for Evolution + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Federico Mena <federico@ximian.com> + * JP Rosevear <jpr@ximian.com> + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * Copyright (C) 1998 Red Hat, Inc. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtk.h> + +#include "goto-dialog.h" + +#include "e-util/e-util.h" +#include "e-util/e-util-private.h" +#include "calendar/gui/calendar-config.h" +#include "calendar/gui/tag-calendar.h" + +typedef struct +{ + GtkBuilder *builder; + GtkWidget *dialog; + + GtkWidget *month_combobox; + GtkWidget *year; + ECalendar *ecal; + GtkWidget *vbox; + + GnomeCalendar *gcal; + gint year_val; + gint month_val; + gint day_val; + +} GoToDialog; + +static GoToDialog *dlg = NULL; + +/* Callback used when the year adjustment is changed */ +static void +year_changed (GtkAdjustment *adj, gpointer data) +{ + GoToDialog *dlg = data; + + dlg->year_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dlg->year)); + e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val); +} + +/* Callback used when a month button is toggled */ +static void +month_changed (GtkToggleButton *toggle, gpointer data) +{ + GoToDialog *dlg = data; + + dlg->month_val = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg->month_combobox)); + + e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val); +} + +static void +ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data) +{ + GoToDialog *dlg = user_data; + ECalModel *model; + ECal *client; + + model = gnome_calendar_get_model (dlg->gcal); + client = e_cal_model_get_default_client (model); + if (client) + tag_calendar_by_client (dlg->ecal, client); +} + +/* Event handler for day groups in the month item. A button press makes + * the calendar jump to the selected day and destroys the Go-to dialog box. */ +static void +ecal_event (ECalendarItem *calitem, gpointer user_data) +{ + GoToDialog *dlg = user_data; + GDate start_date, end_date; + ECalModel *model; + struct icaltimetype tt = icaltime_null_time (); + icaltimezone *timezone; + time_t et; + + model = gnome_calendar_get_model (dlg->gcal); + e_calendar_item_get_selection (calitem, &start_date, &end_date); + timezone = e_cal_model_get_timezone (model); + + tt.year = g_date_get_year (&start_date); + tt.month = g_date_get_month (&start_date); + tt.day = g_date_get_day (&start_date); + + et = icaltime_as_timet_with_zone (tt, timezone); + + gnome_calendar_goto (dlg->gcal, et); + + gtk_dialog_response (GTK_DIALOG (dlg->dialog), GTK_RESPONSE_NONE); +} + +/* Returns the current time, for the ECalendarItem. */ +static struct tm +get_current_time (ECalendarItem *calitem, gpointer data) +{ + icaltimezone *zone; + struct tm tmp_tm = { 0 }; + struct icaltimetype tt; + + /* Get the current timezone. */ + zone = calendar_config_get_icaltimezone (); + + tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone); + + /* Now copy it to the struct tm and return it. */ + tmp_tm.tm_year = tt.year - 1900; + tmp_tm.tm_mon = tt.month - 1; + tmp_tm.tm_mday = tt.day; + tmp_tm.tm_hour = tt.hour; + tmp_tm.tm_min = tt.minute; + tmp_tm.tm_sec = tt.second; + tmp_tm.tm_isdst = -1; + + return tmp_tm; +} + +/* Creates the ecalendar */ +static void +create_ecal (GoToDialog *dlg) +{ + ECalendarItem *calitem; + + dlg->ecal = E_CALENDAR (e_calendar_new ()); + calitem = dlg->ecal->calitem; + + gnome_canvas_item_set (GNOME_CANVAS_ITEM (calitem), + "move_selection_when_moving", FALSE, + NULL); + e_calendar_item_set_display_popup (calitem, FALSE); + gtk_widget_show (GTK_WIDGET (dlg->ecal)); + gtk_box_pack_start (GTK_BOX (dlg->vbox), GTK_WIDGET (dlg->ecal), TRUE, TRUE, 0); + + e_calendar_item_set_first_month (calitem, dlg->year_val, dlg->month_val); + e_calendar_item_set_get_time_callback (calitem, + get_current_time, + dlg, NULL); + + ecal_date_range_changed (calitem, dlg); +} + +static void +goto_today (GoToDialog *dlg) +{ + gnome_calendar_goto_today (dlg->gcal); +} + +/* Gets the widgets from the XML file and returns if they are all available. */ +static gboolean +get_widgets (GoToDialog *dlg) +{ + #define GW(name) e_builder_get_widget (dlg->builder, name) + + dlg->dialog = GW ("goto-dialog"); + + dlg->month_combobox = GW ("month-combobox"); + dlg->year = GW ("year"); + dlg->vbox = GW ("vbox"); + + #undef GW + + return (dlg->dialog + && dlg->month_combobox + && dlg->year + && dlg->vbox); +} + +static void +goto_dialog_init_widgets (GoToDialog *dlg) +{ + GtkAdjustment *adj; + + g_signal_connect ( + dlg->month_combobox, "changed", + G_CALLBACK (month_changed), dlg); + + adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dlg->year)); + g_signal_connect ( + adj, "value_changed", + G_CALLBACK (year_changed), dlg); + + g_signal_connect ( + dlg->ecal->calitem, "date_range_changed", + G_CALLBACK (ecal_date_range_changed), dlg); + g_signal_connect ( + dlg->ecal->calitem, "selection_changed", + G_CALLBACK (ecal_event), dlg); +} + +/* Creates a "goto date" dialog and runs it */ +void +goto_dialog (GtkWindow *parent, GnomeCalendar *gcal) +{ + ECalModel *model; + time_t start_time; + struct icaltimetype tt; + icaltimezone *timezone; + gint week_start_day; + gint b; + + if (dlg) { + return; + } + + dlg = g_new0 (GoToDialog, 1); + + /* Load the content widgets */ + dlg->builder = gtk_builder_new (); + e_load_ui_builder_definition (dlg->builder, "goto-dialog.ui"); + + if (!get_widgets (dlg)) { + g_message ("goto_dialog(): Could not find all widgets in the XML file!"); + g_free (dlg); + return; + } + dlg->gcal = gcal; + + model = gnome_calendar_get_model (gcal); + timezone = e_cal_model_get_timezone (model); + e_cal_model_get_time_range (model, &start_time, NULL); + tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); + dlg->year_val = tt.year; + dlg->month_val = tt.month - 1; + dlg->day_val = tt.day; + + gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->month_combobox), dlg->month_val); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val); + + create_ecal (dlg); + + goto_dialog_init_widgets (dlg); + + gtk_window_set_transient_for (GTK_WINDOW (dlg->dialog), parent); + + /* set initial selection to current day */ + + dlg->ecal->calitem->selection_set = TRUE; + dlg->ecal->calitem->selection_start_month_offset = 0; + dlg->ecal->calitem->selection_start_day = tt.day; + dlg->ecal->calitem->selection_end_month_offset = 0; + dlg->ecal->calitem->selection_end_day = tt.day; + + /* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ + week_start_day = e_cal_model_get_week_start_day (model); + dlg->ecal->calitem->week_start_day = (week_start_day + 6) % 7; + + gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem)); + + b = gtk_dialog_run (GTK_DIALOG (dlg->dialog)); + gtk_widget_destroy (dlg->dialog); + + if (b == 0) + goto_today (dlg); + + g_object_unref (dlg->builder); + g_free (dlg); + dlg = NULL; +} diff --git a/calendar/gui/dialogs/goto-dialog.h b/calendar/gui/dialogs/goto-dialog.h new file mode 100644 index 0000000000..9cd416be80 --- /dev/null +++ b/calendar/gui/dialogs/goto-dialog.h @@ -0,0 +1,34 @@ +/* + * Evolution calendar - Go To Date dialog + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Federico Mena <federico@ximian.com> + * JP Rosevear <jpr@ximian.com> + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * Copyright (C) 1998 Red Hat, Inc. + * + */ + +#ifndef GOTO_DIALOG_H +#define GOTO_DIALOG_H + +#include "calendar/gui/gnome-cal.h" + +void goto_dialog (GtkWindow *parent, GnomeCalendar *gcal); + +#endif diff --git a/calendar/gui/dialogs/goto-dialog.ui b/calendar/gui/dialogs/goto-dialog.ui new file mode 100644 index 0000000000..4bcb1da863 --- /dev/null +++ b/calendar/gui/dialogs/goto-dialog.ui @@ -0,0 +1,180 @@ +<?xml version="1.0"?> +<!--*- mode: xml -*--> +<interface> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">2038</property> + <property name="lower">1969</property> + <property name="page_increment">5</property> + <property name="step_increment">1</property> + <property name="page_size">0</property> + <property name="value">1969</property> + </object> + <object class="GtkListStore" id="model1"> + <columns> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">January</col> + </row> + <row> + <col id="0" translatable="yes">February</col> + </row> + <row> + <col id="0" translatable="yes">March</col> + </row> + <row> + <col id="0" translatable="yes">April</col> + </row> + <row> + <col id="0" translatable="yes">May</col> + </row> + <row> + <col id="0" translatable="yes">June</col> + </row> + <row> + <col id="0" translatable="yes">July</col> + </row> + <row> + <col id="0" translatable="yes">August</col> + </row> + <row> + <col id="0" translatable="yes">September</col> + </row> + <row> + <col id="0" translatable="yes">October</col> + </row> + <row> + <col id="0" translatable="yes">November</col> + </row> + <row> + <col id="0" translatable="yes">December</col> + </row> + </data> + </object> + <object class="GtkDialog" id="goto-dialog"> + <property name="title" translatable="yes">Select Date</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <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="urgency_hint">False</property> + <property name="border_width">12</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <child> + <object class="GtkButton" id="button4"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Select _Today</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </object> + </child> + <child> + <object class="GtkButton" id="button5"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </object> + </child> + </object> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + <child> + <object class="GtkHBox" id="hbox12"> + <property name="visible">True</property> + <property name="homogeneous">True</property> + <property name="spacing">4</property> + <child> + <object class="GtkComboBox" id="month-combobox"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + <property name="model">model1</property> + <child> + <object class="GtkCellRendererText" id="renderer1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="year"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_IF_VALID</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">adjustment1</property> + </object> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </object> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">button4</action-widget> + <action-widget response="-6">button5</action-widget> + </action-widgets> + </object> +</interface> diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 27a11787ae..b81a4412bd 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -51,13 +51,13 @@ #include "e-cell-date-edit-text.h" #include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" +#include "dialogs/goto-dialog.h" #include "dialogs/send-comp.h" #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" #include "comp-util.h" #include "itip-utils.h" #include "calendar-config.h" -#include "goto.h" #include "misc.h" static void e_cal_list_view_dispose (GObject *object); diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index d9b7e91ce4..1f4ac33cb6 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -57,8 +57,8 @@ #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" #include "dialogs/select-source-dialog.h" +#include "dialogs/goto-dialog.h" #include "print.h" -#include "goto.h" #include "misc.h" struct _ECalendarViewPrivate { diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index b5bd081839..af28e3cc12 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -48,10 +48,10 @@ #include "dialogs/send-comp.h" #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" +#include "dialogs/goto-dialog.h" #include "print.h" #include "comp-util.h" #include "itip-utils.h" -#include "goto.h" #include "e-cal-model-calendar.h" #include "e-day-view-time-item.h" #include "e-day-view-top-item.h" diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 9fd9abcfcc..d6f430f2a1 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -47,12 +47,12 @@ #include "dialogs/send-comp.h" #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" +#include "dialogs/goto-dialog.h" #include "comp-util.h" #include "itip-utils.h" #include <libecal/e-cal-time-util.h> #include "calendar-config.h" #include "print.h" -#include "goto.h" #include "e-cal-model-calendar.h" #include "e-week-view-event-item.h" #include "e-week-view-layout.h" diff --git a/calendar/gui/ea-cal-view.c b/calendar/gui/ea-cal-view.c index 1c49d2896b..15381ee772 100644 --- a/calendar/gui/ea-cal-view.c +++ b/calendar/gui/ea-cal-view.c @@ -24,7 +24,7 @@ #include "ea-calendar-helpers.h" #include "e-day-view.h" #include "e-week-view.h" -#include "goto.h" +#include "dialogs/goto-dialog.h" #include <glib.h> #include <glib/gi18n.h> diff --git a/calendar/gui/goto-dialog.ui b/calendar/gui/goto-dialog.ui deleted file mode 100644 index 8ddbfb8575..0000000000 --- a/calendar/gui/goto-dialog.ui +++ /dev/null @@ -1,179 +0,0 @@ -<?xml version="1.0"?> -<!--*- mode: xml -*--> -<interface> - <object class="GtkAdjustment" id="adjustment1"> - <property name="upper">2038</property> - <property name="lower">1969</property> - <property name="page_increment">5</property> - <property name="step_increment">1</property> - <property name="page_size">0</property> - <property name="value">1969</property> - </object> - <object class="GtkListStore" id="model1"> - <columns> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">January</col> - </row> - <row> - <col id="0" translatable="yes">February</col> - </row> - <row> - <col id="0" translatable="yes">March</col> - </row> - <row> - <col id="0" translatable="yes">April</col> - </row> - <row> - <col id="0" translatable="yes">May</col> - </row> - <row> - <col id="0" translatable="yes">June</col> - </row> - <row> - <col id="0" translatable="yes">July</col> - </row> - <row> - <col id="0" translatable="yes">August</col> - </row> - <row> - <col id="0" translatable="yes">September</col> - </row> - <row> - <col id="0" translatable="yes">October</col> - </row> - <row> - <col id="0" translatable="yes">November</col> - </row> - <row> - <col id="0" translatable="yes">December</col> - </row> - </data> - </object> - <object class="GtkDialog" id="goto-dialog"> - <property name="title" translatable="yes">Select Date</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <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="urgency_hint">False</property> - <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <object class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Select _Today</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </object> - </child> - <child> - <object class="GtkButton" id="button5"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </object> - </child> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">4</property> - <child> - <object class="GtkHBox" id="hbox12"> - <property name="visible">True</property> - <property name="homogeneous">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkComboBox" id="month-combobox"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - <property name="model">model1</property> - <child> - <object class="GtkCellRendererText" id="renderer1"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="year"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_IF_VALID</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">adjustment1</property> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </object> - </child> - <action-widgets> - <action-widget response="0">button4</action-widget> - <action-widget response="-6">button5</action-widget> - </action-widgets> - </object> -</interface> diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c deleted file mode 100644 index bf24c3c097..0000000000 --- a/calendar/gui/goto.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Go to date dialog for Evolution - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Federico Mena <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 1998 Red Hat, Inc. - * - */ - -#include <config.h> -#include <gtk/gtk.h> -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" -#include "calendar-config.h" -#include "tag-calendar.h" -#include "goto.h" - -typedef struct -{ - GtkBuilder *builder; - GtkWidget *dialog; - - GtkWidget *month_combobox; - GtkWidget *year; - ECalendar *ecal; - GtkWidget *vbox; - - GnomeCalendar *gcal; - gint year_val; - gint month_val; - gint day_val; - -} GoToDialog; - -static GoToDialog *dlg = NULL; - -/* Callback used when the year adjustment is changed */ -static void -year_changed (GtkAdjustment *adj, gpointer data) -{ - GoToDialog *dlg = data; - - dlg->year_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dlg->year)); - e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val); -} - -/* Callback used when a month button is toggled */ -static void -month_changed (GtkToggleButton *toggle, gpointer data) -{ - GoToDialog *dlg = data; - - dlg->month_val = gtk_combo_box_get_active (GTK_COMBO_BOX (dlg->month_combobox)); - - e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val); -} - -static void -ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data) -{ - GoToDialog *dlg = user_data; - ECalModel *model; - ECal *client; - - model = gnome_calendar_get_model (dlg->gcal); - client = e_cal_model_get_default_client (model); - if (client) - tag_calendar_by_client (dlg->ecal, client); -} - -/* Event handler for day groups in the month item. A button press makes - * the calendar jump to the selected day and destroys the Go-to dialog box. */ -static void -ecal_event (ECalendarItem *calitem, gpointer user_data) -{ - GoToDialog *dlg = user_data; - GDate start_date, end_date; - ECalModel *model; - struct icaltimetype tt = icaltime_null_time (); - icaltimezone *timezone; - time_t et; - - model = gnome_calendar_get_model (dlg->gcal); - e_calendar_item_get_selection (calitem, &start_date, &end_date); - timezone = e_cal_model_get_timezone (model); - - tt.year = g_date_get_year (&start_date); - tt.month = g_date_get_month (&start_date); - tt.day = g_date_get_day (&start_date); - - et = icaltime_as_timet_with_zone (tt, timezone); - - gnome_calendar_goto (dlg->gcal, et); - - gtk_dialog_response (GTK_DIALOG (dlg->dialog), GTK_RESPONSE_NONE); -} - -/* Returns the current time, for the ECalendarItem. */ -static struct tm -get_current_time (ECalendarItem *calitem, gpointer data) -{ - icaltimezone *zone; - struct tm tmp_tm = { 0 }; - struct icaltimetype tt; - - /* Get the current timezone. */ - zone = calendar_config_get_icaltimezone (); - - tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone); - - /* Now copy it to the struct tm and return it. */ - tmp_tm.tm_year = tt.year - 1900; - tmp_tm.tm_mon = tt.month - 1; - tmp_tm.tm_mday = tt.day; - tmp_tm.tm_hour = tt.hour; - tmp_tm.tm_min = tt.minute; - tmp_tm.tm_sec = tt.second; - tmp_tm.tm_isdst = -1; - - return tmp_tm; -} - -/* Creates the ecalendar */ -static void -create_ecal (GoToDialog *dlg) -{ - ECalendarItem *calitem; - - dlg->ecal = E_CALENDAR (e_calendar_new ()); - calitem = dlg->ecal->calitem; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (calitem), - "move_selection_when_moving", FALSE, - NULL); - e_calendar_item_set_display_popup (calitem, FALSE); - gtk_widget_show (GTK_WIDGET (dlg->ecal)); - gtk_box_pack_start (GTK_BOX (dlg->vbox), GTK_WIDGET (dlg->ecal), TRUE, TRUE, 0); - - e_calendar_item_set_first_month (calitem, dlg->year_val, dlg->month_val); - e_calendar_item_set_get_time_callback (calitem, - get_current_time, - dlg, NULL); - - ecal_date_range_changed (calitem, dlg); -} - -static void -goto_today (GoToDialog *dlg) -{ - gnome_calendar_goto_today (dlg->gcal); -} - -/* Gets the widgets from the XML file and returns if they are all available. */ -static gboolean -get_widgets (GoToDialog *dlg) -{ -#define GW(name) e_builder_get_widget (dlg->builder, name) - - dlg->dialog = GW ("goto-dialog"); - - dlg->month_combobox = GW ("month-combobox"); - dlg->year = GW ("year"); - dlg->vbox = GW ("vbox"); - -#undef GW - - return (dlg->dialog - && dlg->month_combobox - && dlg->year - && dlg->vbox); -} - -static void -goto_dialog_init_widgets (GoToDialog *dlg) -{ - GtkAdjustment *adj; - - g_signal_connect ( - dlg->month_combobox, "changed", - G_CALLBACK (month_changed), dlg); - - adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dlg->year)); - g_signal_connect ( - adj, "value_changed", - G_CALLBACK (year_changed), dlg); - - g_signal_connect ( - dlg->ecal->calitem, "date_range_changed", - G_CALLBACK (ecal_date_range_changed), dlg); - g_signal_connect ( - dlg->ecal->calitem, "selection_changed", - G_CALLBACK (ecal_event), dlg); -} - -/* Creates a "goto date" dialog and runs it */ -void -goto_dialog (GtkWindow *parent, GnomeCalendar *gcal) -{ - ECalModel *model; - time_t start_time; - struct icaltimetype tt; - icaltimezone *timezone; - gint week_start_day; - gint b; - - if (dlg) { - return; - } - - dlg = g_new0 (GoToDialog, 1); - - /* Load the content widgets */ - dlg->builder = gtk_builder_new (); - e_load_ui_builder_definition (dlg->builder, "goto-dialog.ui"); - - if (!get_widgets (dlg)) { - g_message ("goto_dialog(): Could not find all widgets in the XML file!"); - g_free (dlg); - return; - } - dlg->gcal = gcal; - - model = gnome_calendar_get_model (gcal); - timezone = e_cal_model_get_timezone (model); - e_cal_model_get_time_range (model, &start_time, NULL); - tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); - dlg->year_val = tt.year; - dlg->month_val = tt.month - 1; - dlg->day_val = tt.day; - - gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->month_combobox), dlg->month_val); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val); - - create_ecal (dlg); - - goto_dialog_init_widgets (dlg); - - gtk_window_set_transient_for (GTK_WINDOW (dlg->dialog), parent); - - /* set initial selection to current day */ - - dlg->ecal->calitem->selection_set = TRUE; - dlg->ecal->calitem->selection_start_month_offset = 0; - dlg->ecal->calitem->selection_start_day = tt.day; - dlg->ecal->calitem->selection_end_month_offset = 0; - dlg->ecal->calitem->selection_end_day = tt.day; - - /* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ - week_start_day = e_cal_model_get_week_start_day (model); - dlg->ecal->calitem->week_start_day = (week_start_day + 6) % 7; - - gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem)); - - b = gtk_dialog_run (GTK_DIALOG (dlg->dialog)); - gtk_widget_destroy (dlg->dialog); - - if (b == 0) - goto_today (dlg); - - g_object_unref (dlg->builder); - g_free (dlg); - dlg = NULL; -} diff --git a/calendar/gui/goto.h b/calendar/gui/goto.h deleted file mode 100644 index 2b81757127..0000000000 --- a/calendar/gui/goto.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Evolution calendar - Go To Date dialog - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Federico Mena <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 1998 Red Hat, Inc. - * - */ - -#ifndef GOTO_DIALOG_H -#define GOTO_DIALOG_H - -#include "gnome-cal.h" - -void goto_dialog (GtkWindow *parent, GnomeCalendar *gcal); - -#endif diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h index b3b4092788..52ec374295 100644 --- a/modules/calendar/e-cal-shell-view-private.h +++ b/modules/calendar/e-cal-shell-view-private.h @@ -50,11 +50,11 @@ #include "calendar/gui/e-day-view.h" #include "calendar/gui/e-week-view.h" #include "calendar/gui/gnome-cal.h" -#include "calendar/gui/goto.h" #include "calendar/gui/print.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/copy-source-dialog.h" #include "calendar/gui/dialogs/event-editor.h" +#include "calendar/gui/dialogs/goto-dialog.h" #include "calendar/gui/dialogs/memo-editor.h" #include "calendar/gui/dialogs/select-source-dialog.h" #include "calendar/gui/dialogs/task-editor.h" diff --git a/po/POTFILES.in b/po/POTFILES.in index af941b9c56..700d9a8c81 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -62,6 +62,8 @@ calendar/gui/dialogs/delete-error.c calendar/gui/dialogs/event-editor.c calendar/gui/dialogs/event-page.c [type: gettext/glade]calendar/gui/dialogs/event-page.ui +calendar/gui/dialogs/goto-dialog.c +[type: gettext/glade]calendar/gui/dialogs/goto-dialog.ui calendar/gui/dialogs/memo-editor.c calendar/gui/dialogs/memo-page.c [type: gettext/glade]calendar/gui/dialogs/memo-page.ui @@ -111,8 +113,6 @@ calendar/gui/ea-jump-button.c calendar/gui/ea-week-view-main-item.c calendar/gui/ea-week-view.c calendar/gui/gnome-cal.c -[type: gettext/glade]calendar/gui/goto-dialog.ui -calendar/gui/goto.c calendar/gui/itip-utils.c calendar/gui/memotypes.xml calendar/gui/misc.c -- cgit v1.2.3