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
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),
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;
{
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));
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));
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;
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);
* 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;
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);
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);
y_loc += priv->max_day_char_descent;
- if (priv->detail_func)
+ if (priv->detail_func && show_details)
{
cairo_save (cr);
y_loc += 2;
}
- if (detail)
+ if (detail && show_details)
{
gint i, n_lines;
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));
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;
/**
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;
{ FALSE, "No Month _Change" },
{ TRUE, "Show _Week Numbers" },
{ FALSE, "Week Start _Monday" },
+ { TRUE, "Show De_tails" },
};
calendar_data.window = NULL;
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);
/* 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);
gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);