diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-09-03 13:33:07 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-09-03 13:33:07 +0800 |
commit | de704a7b4576df4f84ed859c7d3337cce0f89e57 (patch) | |
tree | 3a95fc12ba32383476faf9d09abe3ed3ab200aa8 /calendar/gui/gnome-month-item.c | |
parent | 0e94defc997236d4cd07fd101159d2ea063c082c (diff) | |
download | gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar.gz gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar.bz2 gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar.lz gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar.xz gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.tar.zst gsoc2013-evolution-de704a7b4576df4f84ed859c7d3337cce0f89e57.zip |
Today: we can now configure the colors for the monthly items, courtesy of
Today: we can now configure the colors for the monthly items, courtesy of
the canvas and GnomeColorPicker. Look at the preferences dialog, it is
kind of nice. There are still some bugs to be fixed, nothing major.
1998-09-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
* prop.c (create_colors_page): We can now configure the colors of
the monthly calendars! Wheeeeee! There are still some nits to be
fixed, which are listed in the TODO file.
(build_color_spec): New function to build color specifications.
(parse_color_spec): New function to parse color specifications.
* mark.c: Modified all functions to use the configured colors.
* goto.c: Likewise.
* main.c (colors_changed): New function that notifies all
calendars that colors have changed.
* gnome-cal.c (gnome_calendar_colors_changed): New function that
notifies all the views that the colors have changed.
* month-view.c (month_view_colors_changed): New function that
notifies the month view that colors have changed.
* year-view.c (year_view_colors_changed): New function that
notifies the year view that colors have changed.
* gnome-month-item.h (struct _GnomeMonthItem): Added fields for
outline and day box colors.
* gnome-month-item.c (gnome_month_item_set_arg): Added
outline_color, outline_color_gdk, day_box_color, and
day_box_color_gdk arguments to month items. These are convenient
to quickly set the colors of the month item.
(gnome_month_item_get_arg): Likewise.
* main.[ch]: Added a global array of structures for color preferences.
svn path=/trunk/; revision=360
Diffstat (limited to 'calendar/gui/gnome-month-item.c')
-rw-r--r-- | calendar/gui/gnome-month-item.c | 144 |
1 files changed, 105 insertions, 39 deletions
diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c index 289664e535..b1ef4925bf 100644 --- a/calendar/gui/gnome-month-item.c +++ b/calendar/gui/gnome-month-item.c @@ -62,6 +62,10 @@ enum { ARG_DAY_FONT_GDK, ARG_HEAD_COLOR, ARG_HEAD_COLOR_GDK, + ARG_OUTLINE_COLOR, + ARG_OUTLINE_COLOR_GDK, + ARG_DAY_BOX_COLOR, + ARG_DAY_BOX_COLOR_GDK, ARG_DAY_COLOR, ARG_DAY_COLOR_GDK }; @@ -136,6 +140,10 @@ gnome_month_item_class_init (GnomeMonthItemClass *class) gtk_object_add_arg_type ("GnomeMonthItem::day_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_DAY_FONT_GDK); gtk_object_add_arg_type ("GnomeMonthItem::heading_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_COLOR); gtk_object_add_arg_type ("GnomeMonthItem::heading_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_HEAD_COLOR_GDK); + gtk_object_add_arg_type ("GnomeMonthItem::outline_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_OUTLINE_COLOR); + gtk_object_add_arg_type ("GnomeMonthItem::outline_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_OUTLINE_COLOR_GDK); + gtk_object_add_arg_type ("GnomeMonthItem::day_box_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_BOX_COLOR); + gtk_object_add_arg_type ("GnomeMonthItem::day_box_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_BOX_COLOR_GDK); gtk_object_add_arg_type ("GnomeMonthItem::day_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_COLOR); gtk_object_add_arg_type ("GnomeMonthItem::day_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_COLOR_GDK); @@ -302,19 +310,26 @@ set_head_font (GnomeMonthItem *mitem) NULL); } -/* Sets the color for all the day headings */ +/* Sets the color for all the headings */ static void set_head_color (GnomeMonthItem *mitem) { int i; - GdkColor color; + GdkColor outline; + GdkColor head; - color.pixel = mitem->head_pixel; + outline.pixel = mitem->outline_pixel; + head.pixel = mitem->head_pixel; + + for (i = 0; i < 7; i++) { + gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i], + "fill_color_gdk", &outline, + NULL); - for (i = 0; i < 7; i++) gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "fill_color_gdk", &color, + "fill_color_gdk", &head, NULL); + } } /* Creates the items for the day name headings */ @@ -336,7 +351,6 @@ create_headings (GnomeMonthItem *mitem) mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]), gnome_canvas_rect_get_type (), - "fill_color", "black", NULL); /* Label */ @@ -491,19 +505,29 @@ set_day_font (GnomeMonthItem *mitem) NULL); } -/* Sets the color for all the day numbers */ +/* Sets the color for all the day items */ static void set_day_color (GnomeMonthItem *mitem) { int i; - GdkColor color; + GdkColor outline; + GdkColor day_box; + GdkColor day; - color.pixel = mitem->day_pixel; + outline.pixel = mitem->outline_pixel; + day_box.pixel = mitem->day_box_pixel; + day.pixel = mitem->day_pixel; + + for (i = 0; i < 42; i++) { + gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i], + "outline_color_gdk", &outline, + "fill_color_gdk", &day_box, + NULL); - for (i = 0; i < 42; i++) gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "fill_color_gdk", &color, + "fill_color_gdk", &day, NULL); + } } /* Creates the items for the days */ @@ -525,8 +549,6 @@ create_days (GnomeMonthItem *mitem) mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]), gnome_canvas_rect_get_type (), - "outline_color", "black", - "fill_color", "#d6d6d6d6d6d6", NULL); /* Label */ @@ -643,8 +665,10 @@ gnome_month_item_construct (GnomeMonthItem *mitem) gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "#d6d6d6d6d6d6", &color); mitem->head_pixel = color.pixel; + mitem->day_box_pixel = color.pixel; gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "black", &color); + mitem->outline_pixel = color.pixel; mitem->day_pixel = color.pixel; create_items (mitem); @@ -733,13 +757,36 @@ reanchor (GnomeMonthItem *mitem) NULL); } +/* Sets the color of the specified pixel value to that of the specified argument, which must be in + * GdkColor format if format is TRUE, otherwise it must be in string format. + */ +static void +set_color_arg (GnomeMonthItem *mitem, gulong *pixel, GtkArg *arg, int gdk_format, int set_head, int set_day) +{ + GdkColor color; + + if (gdk_format) + *pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel; + else { + if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color)) + *pixel = color.pixel; + else + *pixel = 0; + } + + if (set_head) + set_head_color (mitem); + + if (set_day) + set_day_color (mitem); +} + static void gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) { GnomeMonthItem *mitem; char **day_names; int i; - GdkColor color; mitem = GNOME_MONTH_ITEM (object); @@ -873,31 +920,35 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_HEAD_COLOR: - if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color)) - mitem->head_pixel = color.pixel; - else - mitem->head_pixel = 0; - - set_head_color (mitem); + set_color_arg (mitem, &mitem->head_pixel, arg, FALSE, TRUE, FALSE); break; case ARG_HEAD_COLOR_GDK: - mitem->head_pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel; - set_head_color (mitem); + set_color_arg (mitem, &mitem->head_pixel, arg, TRUE, TRUE, FALSE); break; - case ARG_DAY_COLOR: - if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color)) - mitem->day_pixel = color.pixel; - else - mitem->day_pixel = 0; + case ARG_OUTLINE_COLOR: + set_color_arg (mitem, &mitem->outline_pixel, arg, FALSE, TRUE, TRUE); + break; - set_day_color (mitem); + case ARG_OUTLINE_COLOR_GDK: + set_color_arg (mitem, &mitem->outline_pixel, arg, TRUE, TRUE, TRUE); + break; + + case ARG_DAY_BOX_COLOR: + set_color_arg (mitem, &mitem->day_box_pixel, arg, FALSE, FALSE, TRUE); + break; + + case ARG_DAY_BOX_COLOR_GDK: + set_color_arg (mitem, &mitem->day_box_pixel, arg, TRUE, FALSE, TRUE); + break; + + case ARG_DAY_COLOR: + set_color_arg (mitem, &mitem->day_pixel, arg, FALSE, FALSE, TRUE); break; case ARG_DAY_COLOR_GDK: - mitem->day_pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel; - set_day_color (mitem); + set_color_arg (mitem, &mitem->day_pixel, arg, TRUE, FALSE, TRUE); break; default: @@ -905,11 +956,24 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } } +/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified + * arg for returning it in the get_arg method. + */ +static void +get_color_arg (GnomeMonthItem *mitem, gulong pixel, GtkArg *arg) +{ + GdkColor *color; + + color = g_new (GdkColor, 1); + color->pixel = pixel; + gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color); + GTK_VALUE_BOXED (*arg) = color; +} + static void gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) { GnomeMonthItem *mitem; - GdkColor *color; mitem = GNOME_MONTH_ITEM (object); @@ -975,17 +1039,19 @@ gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_HEAD_COLOR_GDK: - color = g_new (GdkColor, 1); - color->pixel = mitem->head_pixel; - gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color); - GTK_VALUE_BOXED (*arg) = color; + get_color_arg (mitem, mitem->head_pixel, arg); + break; + + case ARG_OUTLINE_COLOR_GDK: + get_color_arg (mitem, mitem->outline_pixel, arg); + break; + + case ARG_DAY_BOX_COLOR_GDK: + get_color_arg (mitem, mitem->day_box_pixel, arg); break; case ARG_DAY_COLOR_GDK: - color = g_new (GdkColor, 1); - color->pixel = mitem->day_pixel; - gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color); - GTK_VALUE_BOXED (*arg) = color; + get_color_arg (mitem, mitem->day_pixel, arg); break; default: |