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
This commit is contained in:
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2007-12-28 Mathias Hasselmann <mathias@openismus.com>
|
||||||
|
|
||||||
|
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 <mathias@openismus.com>
|
2007-12-28 Mathias Hasselmann <mathias@openismus.com>
|
||||||
|
|
||||||
Try more decent appearance of calendar details separator. (#339540)
|
Try more decent appearance of calendar details separator. (#339540)
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
2007-12-28 Mathias Hasselmann <mathias@openismus.com>
|
||||||
|
|
||||||
|
* gtk/tmpl/gtkcalendar.sgml: Move documentation for
|
||||||
|
GtkCalendarDisplayOptions to gtk/gtkcalendar.c.
|
||||||
|
|
||||||
2007-12-27 Mathias Hasselmann <mathias@openismus.com>
|
2007-12-27 Mathias Hasselmann <mathias@openismus.com>
|
||||||
|
|
||||||
* reference/gtk/gtk-sections.txt: Add new GtkCalendar symbols.
|
* reference/gtk/gtk-sections.txt: Add new GtkCalendar symbols.
|
||||||
|
|||||||
@ -150,17 +150,8 @@ calendar.
|
|||||||
|
|
||||||
<!-- ##### ENUM GtkCalendarDisplayOptions ##### -->
|
<!-- ##### ENUM GtkCalendarDisplayOptions ##### -->
|
||||||
<para>
|
<para>
|
||||||
These options can be used to influence the display and behaviour of a #GtkCalendar.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@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.
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION gtk_calendar_new ##### -->
|
<!-- ##### FUNCTION gtk_calendar_new ##### -->
|
||||||
<para>
|
<para>
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@ -233,6 +233,7 @@ enum
|
|||||||
PROP_SHOW_DAY_NAMES,
|
PROP_SHOW_DAY_NAMES,
|
||||||
PROP_NO_MONTH_CHANGE,
|
PROP_NO_MONTH_CHANGE,
|
||||||
PROP_SHOW_WEEK_NUMBERS,
|
PROP_SHOW_WEEK_NUMBERS,
|
||||||
|
PROP_SHOW_DETAILS,
|
||||||
PROP_DETAIL_WIDTH_CHARS,
|
PROP_DETAIL_WIDTH_CHARS,
|
||||||
PROP_DETAIL_HEIGHT_ROWS,
|
PROP_DETAIL_HEIGHT_ROWS,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
@ -544,6 +545,23 @@ gtk_calendar_class_init (GtkCalendarClass *class)
|
|||||||
0, 127, 0,
|
0, 127, 0,
|
||||||
GTK_PARAM_READWRITE));
|
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] =
|
gtk_calendar_signals[MONTH_CHANGED_SIGNAL] =
|
||||||
g_signal_new (I_("month_changed"),
|
g_signal_new (I_("month_changed"),
|
||||||
G_OBJECT_CLASS_TYPE (gobject_class),
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
||||||
@ -677,8 +695,9 @@ gtk_calendar_init (GtkCalendar *calendar)
|
|||||||
calendar->num_marked_dates = 0;
|
calendar->num_marked_dates = 0;
|
||||||
calendar->selected_day = tm->tm_mday;
|
calendar->selected_day = tm->tm_mday;
|
||||||
|
|
||||||
calendar->display_flags = ( GTK_CALENDAR_SHOW_HEADING |
|
calendar->display_flags = (GTK_CALENDAR_SHOW_HEADING |
|
||||||
GTK_CALENDAR_SHOW_DAY_NAMES );
|
GTK_CALENDAR_SHOW_DAY_NAMES |
|
||||||
|
GTK_CALENDAR_SHOW_DETAILS);
|
||||||
|
|
||||||
calendar->highlight_row = -1;
|
calendar->highlight_row = -1;
|
||||||
calendar->highlight_col = -1;
|
calendar->highlight_col = -1;
|
||||||
@ -785,9 +804,9 @@ calendar_queue_refresh (GtkCalendar *calendar)
|
|||||||
{
|
{
|
||||||
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
|
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
|
||||||
|
|
||||||
if (!priv->detail_func ||
|
if (!(priv->detail_func) ||
|
||||||
priv->detail_width_chars ||
|
!(calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS) ||
|
||||||
priv->detail_height_rows)
|
(priv->detail_width_chars && priv->detail_height_rows))
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (calendar));
|
gtk_widget_queue_draw (GTK_WIDGET (calendar));
|
||||||
else
|
else
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (calendar));
|
gtk_widget_queue_resize (GTK_WIDGET (calendar));
|
||||||
@ -1295,6 +1314,11 @@ gtk_calendar_set_property (GObject *object,
|
|||||||
GTK_CALENDAR_SHOW_WEEK_NUMBERS,
|
GTK_CALENDAR_SHOW_WEEK_NUMBERS,
|
||||||
g_value_get_boolean (value));
|
g_value_get_boolean (value));
|
||||||
break;
|
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:
|
case PROP_DETAIL_WIDTH_CHARS:
|
||||||
gtk_calendar_set_detail_width_chars (calendar,
|
gtk_calendar_set_detail_width_chars (calendar,
|
||||||
g_value_get_int (value));
|
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,
|
g_value_set_boolean (value, calendar_get_display_option (calendar,
|
||||||
GTK_CALENDAR_SHOW_WEEK_NUMBERS));
|
GTK_CALENDAR_SHOW_WEEK_NUMBERS));
|
||||||
break;
|
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:
|
case PROP_DETAIL_WIDTH_CHARS:
|
||||||
g_value_set_int (value, priv->detail_width_chars);
|
g_value_set_int (value, priv->detail_width_chars);
|
||||||
break;
|
break;
|
||||||
@ -1672,7 +1700,8 @@ gtk_calendar_query_tooltip (GtkWidget *widget,
|
|||||||
col = calendar_column_from_x (calendar, x - x0);
|
col = calendar_column_from_x (calendar, x - x0);
|
||||||
row = calendar_row_from_y (calendar, y - y0);
|
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);
|
detail = gtk_calendar_get_detail (calendar, row, col);
|
||||||
calendar_day_rectangle (calendar, row, col, &day_rect);
|
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. */
|
* pango_layout_set_markup is called which alters font settings. */
|
||||||
priv->max_detail_height = 0;
|
priv->max_detail_height = 0;
|
||||||
|
|
||||||
if (priv->detail_func)
|
if (priv->detail_func && (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS))
|
||||||
{
|
{
|
||||||
gchar *markup, *tail;
|
gchar *markup, *tail;
|
||||||
|
|
||||||
@ -2389,13 +2418,15 @@ calendar_paint_day (GtkCalendar *calendar,
|
|||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
gboolean overflow = FALSE;
|
gboolean overflow = FALSE;
|
||||||
|
gboolean show_details;
|
||||||
|
|
||||||
g_return_if_fail (row < 6);
|
g_return_if_fail (row < 6);
|
||||||
g_return_if_fail (col < 7);
|
g_return_if_fail (col < 7);
|
||||||
|
|
||||||
cr = gdk_cairo_create (priv->main_win);
|
cr = gdk_cairo_create (priv->main_win);
|
||||||
|
|
||||||
day = calendar->day[row][col];
|
day = calendar->day[row][col];
|
||||||
|
show_details = (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS);
|
||||||
|
|
||||||
calendar_day_rectangle (calendar, row, col, &day_rect);
|
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;
|
x_loc = day_rect.x + (day_rect.width - logical_rect.width) / 2;
|
||||||
y_loc = day_rect.y;
|
y_loc = day_rect.y;
|
||||||
|
|
||||||
gdk_cairo_set_source_color (cr, text_color);
|
gdk_cairo_set_source_color (cr, text_color);
|
||||||
cairo_move_to (cr, x_loc, y_loc);
|
cairo_move_to (cr, x_loc, y_loc);
|
||||||
pango_cairo_show_layout (cr, layout);
|
pango_cairo_show_layout (cr, layout);
|
||||||
|
|
||||||
if (calendar->marked_date[day-1]
|
if (calendar->day_month[row][col] == MONTH_CURRENT &&
|
||||||
&& calendar->day_month[row][col] == MONTH_CURRENT)
|
(calendar->marked_date[day-1] || (detail && !show_details)))
|
||||||
{
|
{
|
||||||
cairo_move_to (cr, x_loc - 1, y_loc);
|
cairo_move_to (cr, x_loc - 1, y_loc);
|
||||||
pango_cairo_show_layout (cr, layout);
|
pango_cairo_show_layout (cr, layout);
|
||||||
@ -2471,7 +2502,7 @@ calendar_paint_day (GtkCalendar *calendar,
|
|||||||
|
|
||||||
y_loc += priv->max_day_char_descent;
|
y_loc += priv->max_day_char_descent;
|
||||||
|
|
||||||
if (priv->detail_func)
|
if (priv->detail_func && show_details)
|
||||||
{
|
{
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
@ -2492,7 +2523,7 @@ calendar_paint_day (GtkCalendar *calendar,
|
|||||||
y_loc += 2;
|
y_loc += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detail)
|
if (detail && show_details)
|
||||||
{
|
{
|
||||||
gint i, n_lines;
|
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)
|
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");
|
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;
|
calendar->display_flags = flags;
|
||||||
if (resize)
|
if (resize)
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (calendar));
|
gtk_widget_queue_resize (GTK_WIDGET (calendar));
|
||||||
|
|||||||
@ -51,13 +51,28 @@ typedef struct _GtkCalendarClass GtkCalendarClass;
|
|||||||
|
|
||||||
typedef struct _GtkCalendarPrivate GtkCalendarPrivate;
|
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
|
typedef enum
|
||||||
{
|
{
|
||||||
GTK_CALENDAR_SHOW_HEADING = 1 << 0,
|
GTK_CALENDAR_SHOW_HEADING = 1 << 0,
|
||||||
GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1,
|
GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1,
|
||||||
GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2,
|
GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2,
|
||||||
GTK_CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3,
|
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;
|
} GtkCalendarDisplayOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
typedef struct _CalendarData
|
typedef struct _CalendarData
|
||||||
{
|
{
|
||||||
GtkWidget *calendar_widget;
|
GtkWidget *calendar_widget;
|
||||||
GtkWidget *flag_checkboxes[5];
|
GtkWidget *flag_checkboxes[6];
|
||||||
gboolean settings[5];
|
gboolean settings[6];
|
||||||
GtkWidget *font_dialog;
|
GtkWidget *font_dialog;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *prev2_sig;
|
GtkWidget *prev2_sig;
|
||||||
@ -431,6 +431,7 @@ create_calendar(void)
|
|||||||
{ FALSE, "No Month _Change" },
|
{ FALSE, "No Month _Change" },
|
||||||
{ TRUE, "Show _Week Numbers" },
|
{ TRUE, "Show _Week Numbers" },
|
||||||
{ FALSE, "Week Start _Monday" },
|
{ FALSE, "Week Start _Monday" },
|
||||||
|
{ TRUE, "Show De_tails" },
|
||||||
};
|
};
|
||||||
|
|
||||||
calendar_data.window = NULL;
|
calendar_data.window = NULL;
|
||||||
@ -602,7 +603,7 @@ create_calendar(void)
|
|||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
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_signal_connect (toggle, "toggled",
|
||||||
G_CALLBACK(calendar_toggle_details),
|
G_CALLBACK(calendar_toggle_details),
|
||||||
&calendar_data);
|
&calendar_data);
|
||||||
@ -610,7 +611,7 @@ create_calendar(void)
|
|||||||
|
|
||||||
/* Build the Right frame with the flags in */
|
/* 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 ("<b>Flags</b>", vbox, 1, 0);
|
frame = create_expander ("<b>Flags</b>", vbox, 1, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user