From: Mathias Hasselmann Date: Fri, 28 Dec 2007 09:39:34 +0000 (+0000) Subject: Add GTK_CALENDAR_SHOW_DETAILS display flag, which chooses if details are shown within... X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=c32421418a398e9218d4fea7afc58842245d4ca1;p=~andy%2Fgtk Add GTK_CALENDAR_SHOW_DETAILS display flag, which chooses if details are shown within the widget, or jst as tooltip. * gtk/gtkcalendar.c, gtk/gtkcalendar.h: Add "show-details" property aka. GTK_CALENDAR_SHOW_DETAILS, and use it. * tests/testcalendar.c: Test GTK_CALENDAR_SHOW_DETAILS. Reduce padding in flags vbox. svn path=/trunk/; revision=19267 --- diff --git a/ChangeLog b/ChangeLog index e41f1e34e..7ae79a061 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-12-28 Mathias Hasselmann + + Add GTK_CALENDAR_SHOW_DETAILS display flag, which chooses if details + are shown within the widget, or jst as tooltip. + + * gtk/gtkcalendar.c, gtk/gtkcalendar.h: Add "show-details" property + aka. GTK_CALENDAR_SHOW_DETAILS, and use it. + * tests/testcalendar.c: Test GTK_CALENDAR_SHOW_DETAILS. Reduce padding + in flags vbox. + 2007-12-28 Mathias Hasselmann Try more decent appearance of calendar details separator. (#339540) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index b4f0c7ad3..d6d5105b8 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2007-12-28 Mathias Hasselmann + + * gtk/tmpl/gtkcalendar.sgml: Move documentation for + GtkCalendarDisplayOptions to gtk/gtkcalendar.c. + 2007-12-27 Mathias Hasselmann * reference/gtk/gtk-sections.txt: Add new GtkCalendar symbols. diff --git a/docs/reference/gtk/tmpl/gtkcalendar.sgml b/docs/reference/gtk/tmpl/gtkcalendar.sgml index 3de3fb21d..bcac0b38a 100644 --- a/docs/reference/gtk/tmpl/gtkcalendar.sgml +++ b/docs/reference/gtk/tmpl/gtkcalendar.sgml @@ -150,17 +150,8 @@ calendar. -These options can be used to influence the display and behaviour of a #GtkCalendar. -@GTK_CALENDAR_SHOW_HEADING: Specifies that the month and year should be displayed. -@GTK_CALENDAR_SHOW_DAY_NAMES: Specifies that three letter day descriptions should be present. -@GTK_CALENDAR_NO_MONTH_CHANGE: Prevents the user from switching months with the calendar. -@GTK_CALENDAR_SHOW_WEEK_NUMBERS: Displays each week numbers of the current year, down the left side - of the calendar. -@GTK_CALENDAR_WEEK_START_MONDAY: Since GTK+ 2.4, this option is deprecated and ignored by GTK+. - The information on which day the calendar week starts is derived from the locale. - diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 29d2a7b49..45cc88088 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -233,6 +233,7 @@ enum PROP_SHOW_DAY_NAMES, PROP_NO_MONTH_CHANGE, PROP_SHOW_WEEK_NUMBERS, + PROP_SHOW_DETAILS, PROP_DETAIL_WIDTH_CHARS, PROP_DETAIL_HEIGHT_ROWS, PROP_LAST @@ -544,6 +545,23 @@ gtk_calendar_class_init (GtkCalendarClass *class) 0, 127, 0, GTK_PARAM_READWRITE)); +/** + * GtkCalendar:show-details: + * + * Determines whether details are shown directly in the widget, or if they are + * available only as tooltip. When this property is set days with details are + * marked. + * + * Since: 2.16 + */ + g_object_class_install_property (gobject_class, + PROP_SHOW_DETAILS, + g_param_spec_boolean ("show-details", + P_("Show Details"), + P_("If TRUE, details are shown"), + TRUE, + GTK_PARAM_READWRITE)); + gtk_calendar_signals[MONTH_CHANGED_SIGNAL] = g_signal_new (I_("month_changed"), G_OBJECT_CLASS_TYPE (gobject_class), @@ -677,8 +695,9 @@ gtk_calendar_init (GtkCalendar *calendar) calendar->num_marked_dates = 0; calendar->selected_day = tm->tm_mday; - calendar->display_flags = ( GTK_CALENDAR_SHOW_HEADING | - GTK_CALENDAR_SHOW_DAY_NAMES ); + calendar->display_flags = (GTK_CALENDAR_SHOW_HEADING | + GTK_CALENDAR_SHOW_DAY_NAMES | + GTK_CALENDAR_SHOW_DETAILS); calendar->highlight_row = -1; calendar->highlight_col = -1; @@ -785,9 +804,9 @@ calendar_queue_refresh (GtkCalendar *calendar) { GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); - if (!priv->detail_func || - priv->detail_width_chars || - priv->detail_height_rows) + if (!(priv->detail_func) || + !(calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS) || + (priv->detail_width_chars && priv->detail_height_rows)) gtk_widget_queue_draw (GTK_WIDGET (calendar)); else gtk_widget_queue_resize (GTK_WIDGET (calendar)); @@ -1295,6 +1314,11 @@ gtk_calendar_set_property (GObject *object, GTK_CALENDAR_SHOW_WEEK_NUMBERS, g_value_get_boolean (value)); break; + case PROP_SHOW_DETAILS: + calendar_set_display_option (calendar, + GTK_CALENDAR_SHOW_DETAILS, + g_value_get_boolean (value)); + break; case PROP_DETAIL_WIDTH_CHARS: gtk_calendar_set_detail_width_chars (calendar, g_value_get_int (value)); @@ -1345,6 +1369,10 @@ gtk_calendar_get_property (GObject *object, g_value_set_boolean (value, calendar_get_display_option (calendar, GTK_CALENDAR_SHOW_WEEK_NUMBERS)); break; + case PROP_SHOW_DETAILS: + g_value_set_boolean (value, calendar_get_display_option (calendar, + GTK_CALENDAR_SHOW_DETAILS)); + break; case PROP_DETAIL_WIDTH_CHARS: g_value_set_int (value, priv->detail_width_chars); break; @@ -1672,7 +1700,8 @@ gtk_calendar_query_tooltip (GtkWidget *widget, col = calendar_column_from_x (calendar, x - x0); row = calendar_row_from_y (calendar, y - y0); - if (priv->detail_overflow[row] & (1 << col)) + if (0 != (priv->detail_overflow[row] & (1 << col)) || + 0 == (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS)) { detail = gtk_calendar_get_detail (calendar, row, col); calendar_day_rectangle (calendar, row, col, &day_rect); @@ -1826,7 +1855,7 @@ gtk_calendar_size_request (GtkWidget *widget, * pango_layout_set_markup is called which alters font settings. */ priv->max_detail_height = 0; - if (priv->detail_func) + if (priv->detail_func && (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS)) { gchar *markup, *tail; @@ -2389,13 +2418,15 @@ calendar_paint_day (GtkCalendar *calendar, PangoLayout *layout; PangoRectangle logical_rect; gboolean overflow = FALSE; - + gboolean show_details; + g_return_if_fail (row < 6); g_return_if_fail (col < 7); cr = gdk_cairo_create (priv->main_win); day = calendar->day[row][col]; + show_details = (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS); calendar_day_rectangle (calendar, row, col, &day_rect); @@ -2457,13 +2488,13 @@ calendar_paint_day (GtkCalendar *calendar, x_loc = day_rect.x + (day_rect.width - logical_rect.width) / 2; y_loc = day_rect.y; - + gdk_cairo_set_source_color (cr, text_color); cairo_move_to (cr, x_loc, y_loc); pango_cairo_show_layout (cr, layout); - - if (calendar->marked_date[day-1] - && calendar->day_month[row][col] == MONTH_CURRENT) + + if (calendar->day_month[row][col] == MONTH_CURRENT && + (calendar->marked_date[day-1] || (detail && !show_details))) { cairo_move_to (cr, x_loc - 1, y_loc); pango_cairo_show_layout (cr, layout); @@ -2471,7 +2502,7 @@ calendar_paint_day (GtkCalendar *calendar, y_loc += priv->max_day_char_descent; - if (priv->detail_func) + if (priv->detail_func && show_details) { cairo_save (cr); @@ -2492,7 +2523,7 @@ calendar_paint_day (GtkCalendar *calendar, y_loc += 2; } - if (detail) + if (detail && show_details) { gint i, n_lines; @@ -3617,6 +3648,9 @@ gtk_calendar_set_display_options (GtkCalendar *calendar, if ((flags ^ calendar->display_flags) & GTK_CALENDAR_WEEK_START_MONDAY) g_warning ("GTK_CALENDAR_WEEK_START_MONDAY is ignored; the first day of the week is determined from the locale"); + if ((flags ^ calendar->display_flags) & GTK_CALENDAR_SHOW_DETAILS) + resize++; + calendar->display_flags = flags; if (resize) gtk_widget_queue_resize (GTK_WIDGET (calendar)); diff --git a/gtk/gtkcalendar.h b/gtk/gtkcalendar.h index c6a0afbd4..5fa887d39 100644 --- a/gtk/gtkcalendar.h +++ b/gtk/gtkcalendar.h @@ -51,13 +51,28 @@ typedef struct _GtkCalendarClass GtkCalendarClass; typedef struct _GtkCalendarPrivate GtkCalendarPrivate; +/** + * GtkCalendarDisplayOptions: + * @GTK_CALENDAR_SHOW_HEADING: Specifies that the month and year should be displayed. + * @GTK_CALENDAR_SHOW_DAY_NAMES: Specifies that three letter day descriptions should be present. + * @GTK_CALENDAR_NO_MONTH_CHANGE: Prevents the user from switching months with the calendar. + * @GTK_CALENDAR_SHOW_WEEK_NUMBERS: Displays each week numbers of the current year, down the + * left side of the calendar. + * @GTK_CALENDAR_WEEK_START_MONDAY: Since GTK+ 2.4, this option is deprecated and ignored by GTK+. + * The information on which day the calendar week starts is derived from the locale. + * @GTK_CALENDAR_SHOW_DETAILS: Just show an indicator, not the full details + * text when details are provided. See gtk_calendar_set_detail_func(). + * + * These options can be used to influence the display and behaviour of a #GtkCalendar. + */ typedef enum { GTK_CALENDAR_SHOW_HEADING = 1 << 0, GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1, GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2, GTK_CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3, - GTK_CALENDAR_WEEK_START_MONDAY = 1 << 4 + GTK_CALENDAR_WEEK_START_MONDAY = 1 << 4, + GTK_CALENDAR_SHOW_DETAILS = 1 << 5, } GtkCalendarDisplayOptions; /** diff --git a/tests/testcalendar.c b/tests/testcalendar.c index 0c751fbdd..d3cf08c83 100644 --- a/tests/testcalendar.c +++ b/tests/testcalendar.c @@ -30,9 +30,9 @@ typedef struct _CalendarData { - GtkWidget *calendar_widget; - GtkWidget *flag_checkboxes[5]; - gboolean settings[5]; + GtkWidget *calendar_widget; + GtkWidget *flag_checkboxes[6]; + gboolean settings[6]; GtkWidget *font_dialog; GtkWidget *window; GtkWidget *prev2_sig; @@ -431,6 +431,7 @@ create_calendar(void) { FALSE, "No Month _Change" }, { TRUE, "Show _Week Numbers" }, { FALSE, "Week Start _Monday" }, + { TRUE, "Show De_tails" }, }; calendar_data.window = NULL; @@ -602,7 +603,7 @@ create_calendar(void) gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); - toggle = gtk_check_button_new_with_mnemonic ("_Show Details"); + toggle = gtk_check_button_new_with_mnemonic ("_Use Details"); g_signal_connect (toggle, "toggled", G_CALLBACK(calendar_toggle_details), &calendar_data); @@ -610,7 +611,7 @@ create_calendar(void) /* Build the Right frame with the flags in */ - vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL); + vbox = gtk_vbox_new(FALSE, 0); frame = create_expander ("Flags", vbox, 1, 0); gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);