/* Functions to mark calendars * * Copyright (C) 1998 Red Hat Software, Inc. * * Author: Federico Mena */ #include #include "gnome-cal.h" #include "main.h" #include "mark.h" #include "timeutil.h" /* Frees the specified data when an object is destroyed */ static void free_data (GtkObject *object, gpointer data) { g_free (data); } /* If the array of "marked" attributes for the days in a a month item has not been created yet, this * function creates the array and clears it. Otherwise, it just returns the existing array. */ static char * get_attributes (GnomeMonthItem *mitem) { char *attrs; attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes"); if (!attrs) { attrs = g_new0 (char, 42); gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs); gtk_signal_connect (GTK_OBJECT (mitem), "destroy", (GtkSignalFunc) free_data, attrs); } return attrs; } void colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) { g_return_if_fail (mitem != NULL); g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); g_return_if_fail (func != NULL); unmark_month_item (mitem); /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop() * returns a pointer to a static string -- and we need several values. */ gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data), NULL); gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data), NULL); gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data), NULL); gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), "day_color", (* func) (COLOR_PROP_DAY_FG, func_data), NULL); } /* In the month item, marks all the days that are touched by the specified time span. Assumes that * the time span is completely contained within the month. The array of day attributes is modified * accordingly. */ static void mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end) { struct tm tm; int day_index; tm = *localtime (&start); for (; start <= end; start += 60 * 60 * 24) { mktime (&tm); /* normalize the time */ /* Figure out the day index that corresponds to this time */ day_index = gnome_month_item_day2index (mitem, tm.tm_mday); g_assert (day_index >= 0); /* Mark the day box */ mark_month_item_index (mitem, day_index, default_color_func, NULL); /* Next day */ tm.tm_mday++; } } void mark_month_item (GnomeMonthItem *mitem, Calendar *cal) { time_t month_begin, month_end; GList *list, *l; CalendarObject *co; g_return_if_fail (mitem != NULL); g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); g_return_if_fail (cal != NULL); month_begin = time_month_begin (time_from_day (mitem->year, mitem->month, 1)); month_end = time_month_end (month_begin); list = calendar_get_events_in_range (cal, month_begin, month_end); for (l = list; l; l = l->next) { co = l->data; /* We clip the event's start and end times to the month's limits */ mark_event_in_month (mitem, MAX (co->ev_start, month_begin), MIN (co->ev_end, month_end)); } calendar_destroy_event_list (list); } void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data) { char *attrs; GnomeCanvasItem *item; g_return_if_fail (mitem != NULL); g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); g_return_if_fail ((index >= 0) && (index < 42)); g_return_if_fail (func != NULL); attrs = get_attributes (mitem); attrs[index] = TRUE; item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index); gnome_canvas_item_set (item, "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data), NULL); } void unmark_month_item (GnomeMonthItem *mitem) { int i; char *attrs; GnomeCanvasItem *item; g_return_if_fail (mitem != NULL); g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); attrs = get_attributes (mitem); /* Find marked days and unmark them by turning off their marked attribute flag and changing * the color. */ for (i = 0; i < 42; i++) if (attrs[i]) { attrs[i] = FALSE; item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i); gnome_canvas_item_set (item, "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG), NULL); } } /* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs * appropriate prelighting. */ static gint day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) { GnomeMonthItem *mitem; GnomeCanvasItem *box; int child_num, day; GetColorFunc func; gpointer func_data; char *color; char *attrs; /* We only accept enters and leaves */ if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY))) return FALSE; /* Get index information */ mitem = GNOME_MONTH_ITEM (data); child_num = gnome_month_item_child2num (mitem, item); day = gnome_month_item_num2day (mitem, child_num); if (day == 0) return FALSE; /* it was a day outside the month's range */ child_num -= GNOME_MONTH_ITEM_DAY_GROUP; box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num); /* Get colors */ func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func"); func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data"); /* Now actually set the proper color in the item */ switch (event->type) { case GDK_ENTER_NOTIFY: color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data); gnome_canvas_item_set (box, "fill_color", color, NULL); break; case GDK_LEAVE_NOTIFY: attrs = get_attributes (mitem); color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG, func_data); gnome_canvas_item_set (box, "fill_color", color, NULL); break; default: g_assert_not_reached (); } return TRUE; } void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) { GnomeCanvasItem *day_group; int i; g_return_if_fail (mitem != NULL); g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); g_return_if_fail (func != NULL); /* Store the function in the object data */ gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func); gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data); /* Connect the appropriate signals to perform prelighting */ for (i = 0; i < 42; i++) { day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i); gtk_signal_connect (GTK_OBJECT (day_group), "event", (GtkSignalFunc) day_event, mitem); } } char * default_color_func (ColorProp propnum, gpointer data) { return color_spec_from_prop (propnum); } ntw44/cgit/cgit.cgi/freebsd-ports-gnome/log/x11-servers/xorg-server?id=2cb19decbd334a4679f9a50321728092a6107777&showmsg=1'>Expand)AuthorAgeFilesLines * Fix xserver multiple vulnerabilities.flz2008-01-232-1/+516 * - Add local patch to fix alpha build. [1]flz2008-01-023-2/+40 * - OPTIONS'ify (HAL, AIGLX, SUID).flz2007-12-131-20/+24 * Fix plist for sparc64. Should be a no-op on other archs, but bumplinimon2007-11-202-13/+14 * Add temporary fix for LEDs. Proper fix will be available in nextflz2007-10-292-1/+21 * Restore default optimization on RELENG_7.flz2007-10-241-4/+0 * - Explicit some configure arguments.flz2007-10-101-11/+7 * Teach xorg-server that FreeBSD >= 700053 supports PCI domains andmarius2007-09-303-0/+395 * - Update X.org ports to 7.3.flz2007-09-1411-384/+40 * Band-aid over memory hungry gcc 4.2 when compiling xf86ScanPci.c.lesi2007-06-222-0/+15 * Clenup share/X11 directory upon deinstall.lesi2007-05-311-0/+1 * - Welcome X.org 7.2 \o/.flz2007-05-2039-1664/+486 * Fix loading modules on current by adding patch from devel/imake-6 sincelesi2007-02-232-1/+40 * Add vendor patch preventing overwiting of data on the stack or otherlesi2007-01-282-1/+9 * Chase the GNOME X11BASE to LOCALBASE move, and fix the build with themarcus2006-10-144-1/+259 * Fix crash by bad pcf font.lesi2006-08-263-1/+103 * - Add support to Intel 945GMmnag2006-08-212-1/+336 * Add a better workaround for LP64 bug in ProcRenderCompositeGlyphs() inlesi2006-06-052-1/+12 * Add my patch for buffer overflow in the Render extension's TriFan/TriStripanholt2006-05-033-1/+27 * Complete removal of cfb from sunffb driver as was done post release inlesi2006-04-202-1/+102 * Add patch from X.Org, fixing privilege escalation.lesi2006-03-222-0/+21 * Fix build on FreeBSD 4.Xlesi2006-02-025-0/+59 * Replace ugly "@unexec rmdir %D... 2>/dev/null || true" with @dirrmtryedwin2006-01-221-5/+5 * Upgrade to X.Org 6.9.0 release.lesi2006-01-2231-1405/+140 * Fix one of the hangs on new GeForce cards using a patch from X.Org CVS.anholt2005-11-302-1/+23 * Do not put Apple Cinema Display to sleep right after DDC probe.lesi2005-11-121-4/+14 * If port belongs to X11 distribution different than ${X_WINDOW_SYSTEM} one,lesi2005-11-122-1/+5 * Fix the fix for CAN-2005-2495.lesi2005-09-192-30/+44 * Fix integer overflow when allocating large pixmaps.lesi2005-09-122-1/+170 * Fix a use-after-free in the cursor code that's easily triggered with -AJ mallocanholt2005-08-272-1/+43 * Grab a patch for keyboard on sparc64 from Xorg CVS. This makes 'kbd' driverlesi2005-08-014-31/+36 * [1] Fix the Chipset lines written by xorgcfg for 3dfx cards.anholt2005-06-233-1/+31 * Fix up plist after modifications to mtree (BSD.x11-4.dist rev. 1.27).lesi2005-06-151-1/+3 * - Correct the ranges of the bus resource windows on sparc64.lesi2005-05-183-1/+78 * Bump max number of buttons supported by mouse driver to 16 so Logitechlesi2005-05-092-0/+12 * Speed up extract target by not extracting */CVS/*. From ahze:lesi2005-04-071-0/+1 * Sync with etc/mtree/BSD.x11-4.dist rev. 1.26:lesi2005-03-251-1/+5 * Add Peter Grehan's patches to port xorg-server to PowerPC.anholt2005-03-1910-20/+135 * Remove a duplicated imake define that adds noise to the configure stage.anholt2005-03-191-1/+0 * Upgrade X.Org ports to 6.8.2.lesi2005-03-1818-615/+695 * [1] Add i810 driver to AMD64 package.anholt2005-01-1410-52/+219 * [1] Fix a crash on startup with i830+ systems due to failure to follow an APIanholt2005-01-028-0/+512 * Re-add libXThrStub for FreeBSD that requires thread stubs. Between 6.7 and 6.8anholt2004-12-312-16/+78 * - Rewrap to fit on 80 columns consolepav2004-12-291-2/+2 * Update X.Org ports to 6.8.1, and the DRI port to use Mesa 6.2. Because Mesa 6.2anholt2004-12-2318-593/+100 * Don't refer people to nonexistant 'Monitors' file in xorgconfig.lesi2004-11-052-1/+14 * Fix behaviour of keyboard under pc98 where keycodes differ from i386.lesi2004-09-262-5/+34 * Fix behaviour of keyboard under sparc64, where keycodes were off by onelesi2004-09-133-1/+49 * Fix problem with XVideo (insufficient resources for operation). [1]lesi2004-09-034-1/+31 * Use MASTER_SITE_XORG.lesi2004-09-021-1/+3 * Fix missing symbol with SiS driver [1].lesi2004-08-315-50/+149 * - Correct typo (CLFAGS -> CFLAGS)pav2004-07-281-1/+1 * - Extend IGNORE message, point users to instructions how to switchpav2004-07-241-1/+1 * - Add the X_WINDOW_SYSTEM={xorg,xfree86-4,xfree86-3} variable to bsd.port.mk,anholt2004-07-241-0/+4 * s/WITH_XLIB/USE_XLIB/ -- fixes missing dependency.anholt2004-07-191-1/+1 * Rethink the DRI dependency. It's not actually needed for the server to work.anholt2004-07-121-4/+0 * And my hat collection grows. Actually remove the remnants of pkg-messageanholt2004-06-191-5/+0 * - Install the server setuid by default. The x11/wrapper/files/wrapper.c codeanholt2004-06-194-13/+27 * Install xorgcfg and xorgconfig.anholt2004-06-103-3/+7 * - Only set XFREE86_HTML_MAN if there are going to be manpages installedanholt2004-05-314-15/+34 * - Depend on xorg-libraries by default instead of the modular libraries.anholt2004-05-302-2/+13 * Add some more patches based on XFree86-4-libraries/files, for theanholt2004-05-293-1/+50 * [1] Fix packaging on amd64anholt2004-05-184-14/+325 * [1] Add missing dependency on freetype2.anholt2004-05-112-0/+20 * Correct a typo in one of the LIB_PC_DEPENDS.marcus2004-05-111-1/+1