From 9b02c881ef67ec81d137f6478d783e2b1f4efbf1 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Sat, 23 Dec 2000 01:06:22 +0000 Subject: translations 2000-12-22 JP Rosevear * gui/goto-dialog.glade.h: translations * gui/goto-dialog.glade: new glade file for goto dialog * gui/gnome-cal.c (setup_widgets): Set date navigator attributes * gui/calendar-commands.h: remove prototype * gui/goto.h: Add prototype * gui/Makefile.am: Add glade file stuff * gui/gnome-cal.c (setup_widgets): Use accessors to configure the calendar item properly 2000-12-22 JP Rosevear * e-calendar-item.h: add prototypes * e-calendar-item.c (e_calendar_item_init): Set max_days_selected to 1 and days_to_start_week_selection to -1 as documented in header (e_calendar_item_set_arg): use new accessor methods (e_calendar_item_get_arg): ditto (e_calendar_item_get_max_days_sel): accessor (e_calendar_item_set_max_days_sel): ditto (e_calendar_item_get_days_start_week_sel): ditto (e_calendar_item_set_days_start_week_sel): ditto (e_calendar_item_class_init): add display_popup argument (e_calendar_item_init): initialize display_popup member (e_calendar_item_get_arg): get display_popup member (e_calendar_item_set_arg): set display_popup member (e_calendar_item_button_press): only show the popup menu if the member is set (e_calendar_item_get_display_popup): acessor (e_calendar_item_set_display_popup): ditto svn path=/trunk/; revision=7132 --- calendar/ChangeLog | 17 ++ calendar/gui/Makefile.am | 10 +- calendar/gui/calendar-commands.h | 3 - calendar/gui/gnome-cal.c | 3 + calendar/gui/goto-dialog.glade | 159 ++++++++++++++++ calendar/gui/goto-dialog.glade.h | 21 +++ calendar/gui/goto.c | 393 +++++++++++++-------------------------- calendar/gui/goto.h | 29 +++ widgets/misc/ChangeLog | 21 +++ widgets/misc/e-calendar-item.c | 83 ++++++++- widgets/misc/e-calendar-item.h | 31 +++ 11 files changed, 490 insertions(+), 280 deletions(-) create mode 100644 calendar/gui/goto-dialog.glade create mode 100644 calendar/gui/goto-dialog.glade.h create mode 100644 calendar/gui/goto.h diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 74751b91ca..19dff51e65 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +2000-12-22 JP Rosevear + + * gui/goto-dialog.glade.h: translations + + * gui/goto-dialog.glade: new glade file for goto dialog + + * gui/gnome-cal.c (setup_widgets): Set date navigator attributes + + * gui/calendar-commands.h: remove prototype + + * gui/goto.h: Add prototype + + * gui/Makefile.am: Add glade file stuff + + * gui/gnome-cal.c (setup_widgets): Use accessors to configure the + calendar item properly + 2000-12-21 Federico Mena Quintero Alarm trigger queueing for the GUI part. diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 48ccd78e95..67422a9af3 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -54,9 +54,14 @@ gladedir = $(datadir)/evolution/glade glade_DATA = \ event-editor-dialog.glade \ e-meeting-dialog.glade \ - e-itip-control.glade + e-itip-control.glade \ + goto-dialog.glade -glade_messages = event-editor-dialog.glade.h +glade_messages = \ + event-editor-dialog.glade.h \ + e-meet-dialog.glade.h \ + e-itip-control.glade.h \ + goto-dialog.glade.h evolution_calendar_SOURCES = \ $(IDL_GENERATED) \ @@ -107,6 +112,7 @@ evolution_calendar_SOURCES = \ gnome-month-item.c \ gnome-month-item.h \ goto.c \ + goto.h \ itip-utils.c \ itip-utils.h \ main.c \ diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h index 0c237dad16..5189e2878f 100644 --- a/calendar/gui/calendar-commands.h +++ b/calendar/gui/calendar-commands.h @@ -58,9 +58,6 @@ extern const guint MAX_SNOOZE_SECS; /* This tells all the calendars to reload the config settings. */ void update_all_config_settings (void); -/* Creates and runs the Go-to date dialog */ -void goto_dialog (GnomeCalendar *gcal); - /* Returns a pointer to a statically-allocated string with a representation of the specified color. * Values must be in [0, 65535]. */ diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index e3dae90a4d..77dc0a71dc 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -244,7 +244,10 @@ setup_widgets (GnomeCalendar *gcal) /* The ECalendar. */ w = e_calendar_new (); priv->date_navigator = E_CALENDAR (w); + e_calendar_item_set_days_start_week_sel (priv->date_navigator->calitem, 9); + e_calendar_item_set_max_days_sel (priv->date_navigator->calitem, 42); gtk_widget_show (w); + e_paned_pack1 (E_PANED (priv->vpane), w, FALSE, TRUE); gtk_signal_connect (GTK_OBJECT (priv->date_navigator), "style_set", diff --git a/calendar/gui/goto-dialog.glade b/calendar/gui/goto-dialog.glade new file mode 100644 index 0000000000..fb8d67d2bd --- /dev/null +++ b/calendar/gui/goto-dialog.glade @@ -0,0 +1,159 @@ + + + + + preferences + preferences + + src + pixmaps + C + True + True + True + goto-dialog.glade.h + + + + GnomeDialog + goto-dialog + Go To Date + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button4 + True + True + + GNOME_STOCK_PIXMAP_JUMP_TO + + + + GtkButton + button5 + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox + False + 0 + + 0 + True + True + + + + GtkHBox + hbox12 + True + 3 + + 0 + True + True + + + + GtkOptionMenu + month + True + January +February +March +April +May +June +July +August +September +October +November +December + + 0 + + 0 + False + False + + + + + GtkSpinButton + year + True + 1 + 0 + True + GTK_UPDATE_IF_VALID + False + False + 1969 + 1969 + 2038 + 1 + 5 + 10 + + 0 + True + True + + + + + + Placeholder + + + + Placeholder + + + + + + diff --git a/calendar/gui/goto-dialog.glade.h b/calendar/gui/goto-dialog.glade.h new file mode 100644 index 0000000000..5d970035fc --- /dev/null +++ b/calendar/gui/goto-dialog.glade.h @@ -0,0 +1,21 @@ +/* + * Translatable strings file generated by Glade. + * Add this file to your project's POTFILES.in. + * DO NOT compile it as part of your application. + */ + +gchar *s = N_("Go To Date"); +gchar *s = N_("Go To Today"); +gchar *s = N_("January\n" + "February\n" + "March\n" + "April\n" + "May\n" + "June\n" + "July\n" + "August\n" + "September\n" + "October\n" + "November\n" + "December\n" + ""); diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index 07e75e5d3d..71d377f2b8 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -1,332 +1,195 @@ -/* Go to date dialog for gnomecal +/* Go to date dialog for Evolution * * Copyright (C) 1998 Red Hat Software, Inc. + * Copyright (C) 2000 Helix Code, Inc. * - * Author: Federico Mena + * Authors: Federico Mena + * JP Rosevear */ #include #include -#include -#include "gnome-cal.h" -#include "gnome-month-item.h" +#include #include "calendar-commands.h" -#include "mark.h" +#include "goto.h" - -static GtkWidget *goto_win; /* The goto dialog window */ -static GnomeMonthItem *month_item; /* The month item in the dialog */ -static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */ -static int current_index; /* The index of the day marked as current, or -1 if none */ - - -/* Updates the specified month item by marking it appropriately from the calendar the dialog refers - * to. Also marks the current day if appropriate. - */ -static void -update (void) +typedef struct { - GnomeCanvasItem *item; - time_t t; - struct tm tm; + GladeXML *xml; + GtkWidget *dialog; - unmark_month_item (month_item); - mark_month_item (month_item, gnome_calendar); - - if (current_index != -1) { - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG), - "fontset", NORMAL_DAY_FONTSET, - NULL); - current_index = -1; - } + GtkWidget *month; + GtkWidget *year; + ECalendar *ecal; + GtkWidget *vbox; - t = time (NULL); - tm = *localtime (&t); + GnomeCalendar *gcal; + gint year_val; + gint month_val; + gint day_val; + +} GoToDialog; - if (((tm.tm_year + 1900) == month_item->year) && (tm.tm_mon == month_item->month)) { - current_index = gnome_month_item_day2index (month_item, tm.tm_mday); - g_assert (current_index != -1); - - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), - "fontset", CURRENT_DAY_FONTSET, - NULL); - } -} +GoToDialog *dlg = NULL; /* Callback used when the year adjustment is changed */ static void year_changed (GtkAdjustment *adj, gpointer data) { - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "year", (int) adj->value, - NULL); - update (); -} - -/* Creates the year control with its adjustment */ -static GtkWidget * -create_year (int year) -{ - GtkWidget *hbox; - GtkAdjustment *adj; - GtkWidget *w; - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - - w = gtk_label_new (_("Year:")); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (year, 1900, 9999, 1, 10, 10)); - gtk_signal_connect (GTK_OBJECT (adj), "value_changed", - (GtkSignalFunc) year_changed, - NULL); - - w = gtk_spin_button_new (adj, 1.0, 0); - gtk_widget_set_usize (w, 60, 0); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); + GoToDialog *dlg = data; - return hbox; + 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_toggled (GtkToggleButton *toggle, gpointer data) +month_changed (GtkToggleButton *toggle, gpointer data) { - if (!toggle->active) - return; + GoToDialog *dlg = data; + GtkWidget *menu, *active; + + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dlg->month)); + active = gtk_menu_get_active (GTK_MENU (menu)); + dlg->month_val = g_list_index (GTK_MENU_SHELL (menu)->children, active); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", GPOINTER_TO_INT (data), - NULL); - update (); + e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val); } -/* Creates the months control */ -static GtkWidget * -create_months (int month) +/* 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) { - time_t start_time; - GtkWidget *table; - GtkWidget *w; - GSList *group; - int i, row, col; + GoToDialog *dlg = user_data; + GDate start_date, end_date; struct tm tm; - char buf[100]; - - gnome_calendar_get_selected_time_range (gnome_calendar, &start_time, NULL); - - tm = *localtime (&start_time); - - table = gtk_table_new (2, 6, TRUE); - - group = NULL; - - for (i = 0; i < 12; i++) { - row = i / 6; - col = i % 6; - - tm.tm_mon = i; - strftime (buf, 100, "%b", &tm); - - w = gtk_radio_button_new (group); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (w)); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE); + time_t et; + + e_calendar_item_get_selection (calitem, &start_date, &end_date); + g_date_to_struct_tm (&start_date, &tm); + et = mktime (&tm); + + gnome_calendar_goto (dlg->gcal, et); - gtk_container_add (GTK_CONTAINER (w), gtk_label_new (buf)); + gnome_dialog_close (GNOME_DIALOG (dlg->dialog)); +} - if (i == month) - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (w), TRUE); +/* Creates the canvas with the month item for selecting days */ +static ECalendar * +create_ecal (void) +{ + ECalendar *ecal; - gtk_signal_connect (GTK_OBJECT (w), "toggled", - (GtkSignalFunc) month_toggled, - GINT_TO_POINTER (i)); - gtk_table_attach (GTK_TABLE (table), w, - col, col + 1, - row, row + 1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - gtk_widget_show_all (w); - } + ecal = E_CALENDAR (e_calendar_new ()); - return table; + e_calendar_item_set_display_popup (ecal->calitem, FALSE); + + return ecal; } -/* Sets the scrolling region of the canvas to the allocation size */ static void -set_scroll_region (GtkWidget *widget, GtkAllocation *allocation) +goto_today (GoToDialog *dlg) { - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), - NULL); - - gnome_canvas_set_scroll_region (GNOME_CANVAS (widget), - 0, 0, - allocation->width, allocation->height); + gnome_calendar_goto_today (dlg->gcal); } -/* 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. +/* Gets the widgets from the XML file and returns if they are all available. */ -static gint -day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) +static gboolean +get_widgets (GoToDialog *dlg) { - int child_num, day; - - child_num = gnome_month_item_child2num (month_item, item); - day = gnome_month_item_num2day (month_item, child_num); - - switch (event->type) { - case GDK_BUTTON_PRESS: - if ((event->button.button == 1) && (day != 0)) { - gnome_calendar_goto (gnome_calendar, - time_from_day (month_item->year, month_item->month, day)); - gtk_widget_destroy (goto_win); - } - break; - - default: - break; - } +#define GW(name) glade_xml_get_widget (dlg->xml, name) - return FALSE; -} + dlg->dialog = GW ("goto-dialog"); -/* Creates the canvas with the month item for selecting days */ -static GtkWidget * -create_days (int day, int month, int year) -{ - GtkWidget *canvas; - int i; - GnomeCanvasItem *day_group; - - canvas = gnome_canvas_new (); - gtk_widget_set_usize (canvas, 150, 120); - - month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)))); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", month, - "year", year, - "start_on_monday", week_starts_on_monday, - NULL); - colorify_month_item (month_item, default_color_func, NULL); - month_item_prepare_prelight (month_item, default_color_func, NULL); - update (); - - /* Connect to size_allocate so that we can change the size of the month item and the - * scrolling region appropriately. - */ - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - (GtkSignalFunc) set_scroll_region, - NULL); - - /* Bind the day groups to our event handler */ - - for (i = 0; i < 42; i++) { - day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP); - gtk_signal_connect (GTK_OBJECT (day_group), "event", - (GtkSignalFunc) day_event, - NULL); - } + dlg->month = GW ("month"); + dlg->year = GW ("year"); + dlg->vbox = GW ("vbox"); + +#undef GW - return canvas; + return (dlg->dialog + && dlg->month + && dlg->year + && dlg->vbox); } static void -goto_today (GtkWidget *widget, gpointer data) +goto_dialog_init_widgets (GoToDialog *dlg) { - gnome_calendar_goto_today (gnome_calendar); - gtk_widget_destroy (goto_win); + GtkWidget *menu; + GtkAdjustment *adj; + GList *l; + + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dlg->month)); + for (l = GTK_MENU_SHELL (menu)->children; l != NULL; l = l->next) + gtk_signal_connect (GTK_OBJECT (menu), "selection_done", + GTK_SIGNAL_FUNC (month_changed), dlg); + + adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dlg->year)); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + (GtkSignalFunc) year_changed, dlg); + + gtk_signal_connect (GTK_OBJECT (dlg->ecal->calitem), + "selection_changed", + (GtkSignalFunc) ecal_event, + dlg); } /* Creates a "goto date" dialog and runs it */ void goto_dialog (GnomeCalendar *gcal) { + GtkWidget *menu; time_t start_time; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *w; - GtkWidget *days; struct tm tm; + int b; - gnome_calendar = gcal; - current_index = -1; + if (dlg) { + return; + } + + dlg = g_new0 (GoToDialog, 1); + + /* Load the content widgets */ + dlg->xml = glade_xml_new (EVOLUTION_GLADEDIR "/goto-dialog.glade", NULL); + if (!dlg->xml) { + g_message ("goto_dialog(): Could not load the Glade XML file!"); + return; + } - gnome_calendar_get_selected_time_range (gnome_calendar, &start_time, NULL); + if (!get_widgets (dlg)) { + g_message ("goto_dialog(): Could not find all widgets in the XML file!"); + return; + } + dlg->gcal = gcal; + gnome_calendar_get_selected_time_range (dlg->gcal, &start_time, NULL); tm = *localtime (&start_time); + dlg->year_val = tm.tm_year + 1900; + dlg->month_val = tm.tm_mon; + dlg->day_val = tm.tm_mday; - goto_win = gnome_dialog_new (_("Go to date"), - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); - + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dlg->month)); + gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->month), dlg->month_val); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val); - vbox = GNOME_DIALOG (goto_win)->vbox; - - /* Instructions */ - - w = gtk_label_new (_("Please select the date you want to go to.\n" - "When you click on a day, you will be taken\n" - "to that date.")); - gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Create month item before creating the year controls, since the - * latter ones need the month_item to be created. - */ - - days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900); - - /* Year */ - - w = create_year (tm.tm_year + 1900); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Month */ - - w = create_months (tm.tm_mon); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Days (canvas with month item) */ - - gtk_box_pack_start (GTK_BOX (vbox), days, TRUE, TRUE, 0); - gtk_widget_show (days); - - /* Today button */ + dlg->ecal = create_ecal (); + gtk_box_pack_start (GTK_BOX (dlg->vbox), GTK_WIDGET (dlg->ecal), TRUE, TRUE, 0); + gtk_widget_show (GTK_WIDGET (dlg->ecal)); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); + goto_dialog_init_widgets (dlg); - w = gtk_button_new_with_label (_("Go to today")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) goto_today, - NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); + gnome_dialog_set_parent (GNOME_DIALOG (dlg->dialog), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); - /* Run! */ + b = gnome_dialog_run_and_close (GNOME_DIALOG (dlg->dialog)); + if (b == 0) + goto_today (dlg); - gtk_window_set_modal (GTK_WINDOW (goto_win), TRUE); - gnome_dialog_set_close (GNOME_DIALOG (goto_win), TRUE); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gnome_calendar)))); - gtk_widget_show (goto_win); + gtk_object_unref (GTK_OBJECT (dlg->xml)); + g_free (dlg); + dlg = NULL; } diff --git a/calendar/gui/goto.h b/calendar/gui/goto.h new file mode 100644 index 0000000000..f0dc41feba --- /dev/null +++ b/calendar/gui/goto.h @@ -0,0 +1,29 @@ +/* Evolution calendar - Go To Date dialog + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: JP Rosevear + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#ifndef GOTO_DIALOG_H +#define GOTO_DIALOG_H + +#include "gnome-cal.h" + +void goto_dialog (GnomeCalendar *gcal); + +#endif diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 63a790ba23..afc608faa2 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,24 @@ +2000-12-22 JP Rosevear + + * e-calendar-item.h: add prototypes + + * e-calendar-item.c (e_calendar_item_init): Set max_days_selected to + 1 and days_to_start_week_selection to -1 as documented in header + (e_calendar_item_set_arg): use new accessor methods + (e_calendar_item_get_arg): ditto + (e_calendar_item_get_max_days_sel): accessor + (e_calendar_item_set_max_days_sel): ditto + (e_calendar_item_get_days_start_week_sel): ditto + (e_calendar_item_set_days_start_week_sel): ditto + (e_calendar_item_class_init): add display_popup argument + (e_calendar_item_init): initialize display_popup member + (e_calendar_item_get_arg): get display_popup member + (e_calendar_item_set_arg): set display_popup member + (e_calendar_item_button_press): only show the popup menu if the + member is set + (e_calendar_item_get_display_popup): acessor + (e_calendar_item_set_display_popup): ditto + 2000-12-14 Federico Mena Quintero * e-dateedit.h: #include diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c index 8e0ff1f604..6442d7d7a5 100644 --- a/widgets/misc/e-calendar-item.c +++ b/widgets/misc/e-calendar-item.c @@ -240,7 +240,8 @@ enum { ARG_MAXIMUM_DAYS_SELECTED, ARG_DAYS_TO_START_WEEK_SELECTION, ARG_MOVE_SELECTION_WHEN_MOVING, - ARG_ROUND_SELECTION_WHEN_MOVING + ARG_ROUND_SELECTION_WHEN_MOVING, + ARG_DISPLAY_POPUP }; enum { @@ -330,6 +331,9 @@ e_calendar_item_class_init (ECalendarItemClass *class) gtk_object_add_arg_type ("ECalendarItem::round_selection_when_moving", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ROUND_SELECTION_WHEN_MOVING); + gtk_object_add_arg_type ("ECalendarItem::display_popup", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, + ARG_DISPLAY_POPUP); e_calendar_item_signals[DATE_RANGE_CHANGED] = gtk_signal_new ("date_range_changed", @@ -393,11 +397,12 @@ e_calendar_item_init (ECalendarItem *calitem) calitem->show_week_numbers = FALSE; calitem->week_start_day = 0; calitem->expand = TRUE; - calitem->max_days_selected = 42; - calitem->days_to_start_week_selection = 9; + calitem->max_days_selected = 1; + calitem->days_to_start_week_selection = -1; calitem->move_selection_when_moving = TRUE; calitem->round_selection_when_moving = FALSE; - + calitem->display_popup = TRUE; + calitem->x1 = 0.0; calitem->y1 = 0.0; calitem->x2 = 0.0; @@ -503,10 +508,10 @@ e_calendar_item_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) GTK_VALUE_BOOL (*arg) = calitem->show_week_numbers; break; case ARG_MAXIMUM_DAYS_SELECTED: - GTK_VALUE_INT (*arg) = calitem->max_days_selected; + GTK_VALUE_INT (*arg) = e_calendar_item_get_max_days_sel (calitem); break; case ARG_DAYS_TO_START_WEEK_SELECTION: - GTK_VALUE_INT (*arg) = calitem->days_to_start_week_selection; + GTK_VALUE_INT (*arg) = e_calendar_item_get_days_start_week_sel (calitem); break; case ARG_MOVE_SELECTION_WHEN_MOVING: GTK_VALUE_BOOL (*arg) = calitem->move_selection_when_moving; @@ -514,6 +519,11 @@ e_calendar_item_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_ROUND_SELECTION_WHEN_MOVING: GTK_VALUE_BOOL (*arg) = calitem->round_selection_when_moving; break; + case ARG_DISPLAY_POPUP: + GTK_VALUE_BOOL (*arg) = e_calendar_item_get_display_popup (calitem); + break; + default: + g_warning ("Invalid arg"); } } @@ -639,12 +649,11 @@ e_calendar_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) break; case ARG_MAXIMUM_DAYS_SELECTED: ivalue = GTK_VALUE_INT (*arg); - ivalue = MAX (1, ivalue); - calitem->max_days_selected = ivalue; + e_calendar_item_set_max_days_sel (calitem, ivalue); break; case ARG_DAYS_TO_START_WEEK_SELECTION: ivalue = GTK_VALUE_INT (*arg); - calitem->days_to_start_week_selection = ivalue; + e_calendar_item_set_days_start_week_sel (calitem, ivalue); break; case ARG_MOVE_SELECTION_WHEN_MOVING: bvalue = GTK_VALUE_BOOL (*arg); @@ -654,6 +663,10 @@ e_calendar_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) bvalue = GTK_VALUE_BOOL (*arg); calitem->round_selection_when_moving = bvalue; break; + case ARG_DISPLAY_POPUP: + bvalue = GTK_VALUE_BOOL (*arg); + e_calendar_item_set_display_popup (calitem, bvalue); + break; default: g_warning ("Invalid arg"); } @@ -1620,7 +1633,8 @@ e_calendar_item_button_press (ECalendarItem *calitem, &all_week)) return FALSE; - if (event->button.button == 3 && day == -1) { + if (event->button.button == 3 && day == -1 + && e_calendar_item_get_display_popup (calitem)) { e_calendar_item_show_popup_menu (calitem, (GdkEventButton*) event, month_offset); @@ -2147,6 +2161,55 @@ e_calendar_item_set_first_month(ECalendarItem *calitem, gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); } +/* Get the maximum number of days selectable */ +gint +e_calendar_item_get_max_days_sel (ECalendarItem *calitem) +{ + return calitem->max_days_selected; +} + + +/* Set the maximum number of days selectable */ +void +e_calendar_item_set_max_days_sel (ECalendarItem *calitem, + gint days) +{ + calitem->max_days_selected = MAX (1, days); +} + + +/* Get the maximum number of days selectable */ +gint +e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem) +{ + return calitem->days_to_start_week_selection; +} + + +/* Set the maximum number of days selectable */ +void +e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, + gint days) +{ + calitem->days_to_start_week_selection = days; +} + +/* Set the maximum number of days before whole weeks are selected */ +gboolean +e_calendar_item_get_display_popup (ECalendarItem *calitem) +{ + return calitem->display_popup; +} + + +/* Get the maximum number of days before whole weeks are selected */ +void +e_calendar_item_set_display_popup (ECalendarItem *calitem, + gboolean display) +{ + calitem->display_popup = display; +} + /* This will make sure that the given year & month are valid, i.e. if month is < 0 or > 11 the year and month will be updated accordingly. */ diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h index a5a871228a..f638b16573 100644 --- a/widgets/misc/e-calendar-item.h +++ b/widgets/misc/e-calendar-item.h @@ -135,6 +135,9 @@ struct _ECalendarItem move back/forward one month. Used for the week view. */ gboolean round_selection_when_moving; + /* Whether to display the pop-up, TRUE by default */ + gboolean display_popup; + /* * Internal stuff. */ @@ -230,6 +233,34 @@ void e_calendar_item_set_first_month (ECalendarItem *calitem, gint year, gint month); +/* Get the maximum number of days selectable */ +gint e_calendar_item_get_max_days_sel (ECalendarItem *calitem); + +/* Set the maximum number of days selectable */ +void e_calendar_item_set_max_days_sel (ECalendarItem *calitem, + gint days); + +/* Get the maximum number of days selectable */ +gint e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem); + +/* Get the maximum number of days before whole weeks are selected */ +void e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, + gint days); + +/* Set the maximum number of days before whole weeks are selected */ +gboolean e_calendar_item_get_display_popup (ECalendarItem *calitem); + +/* Get the maximum number of days before whole weeks are selected */ +void e_calendar_item_set_display_popup (ECalendarItem *calitem, + gboolean display); + +/* Set the maximum number of days before whole weeks are selected */ +gint e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem); + +/* Set the maximum number of days selectable */ +void e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, + gint days); + /* Returns the range of dates actually shown. Months are 0 to 11. This also includes the last days of the previous month and the first days of the following month, which are normally shown in gray. */ -- cgit v1.2.3