/* Color usage */
#define HEADER_FG_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
#define HEADER_BG_COLOR(widget) (& (widget)->style->bg[GTK_WIDGET_STATE (widget)])
-#define SELECTED_BG_COLOR(widget) (& (widget)->style->base[GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
-#define SELECTED_FG_COLOR(widget) (& (widget)->style->text[GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
+#define SELECTED_BG_COLOR(widget) (& (widget)->style->base[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
+#define SELECTED_FG_COLOR(widget) (& (widget)->style->text[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
#define NORMAL_DAY_COLOR(widget) (& (widget)->style->text[GTK_WIDGET_STATE (widget)])
#define PREV_MONTH_COLOR(widget) (& (widget)->style->mid[GTK_WIDGET_STATE (widget)])
#define NEXT_MONTH_COLOR(widget) (& (widget)->style->mid[GTK_WIDGET_STATE (widget)])
g_param_spec_int ("year",
P_("Year"),
P_("The selected year"),
- 0, G_MAXINT >> 8, 0,
+ 0, G_MAXINT >> 9, 0,
GTK_PARAM_READWRITE));
/**
* Do *not* translate it to anything else, if it
* it isn't calendar:YM or calendar:MY it will not work.
*
- * Note that this flipping is in top of the text direction flipping,
- * so if you have a default text direction of RTL and YM, then
- * the year will appear on the right.
+ * Note that the ordering described here is logical order, which is
+ * further influenced by BIDI ordering. Thus, if you have a default
+ * text direction of RTL and specify "calendar:YM", then the year
+ * will appear to the right of the month.
*/
year_before = _("calendar:MY");
if (strcmp (year_before, "calendar:YM") == 0)
priv->arrow_win[i] = gdk_window_new (priv->header_win,
&attributes,
attributes_mask);
- if (GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_sensitive (widget))
priv->arrow_state[i] = GTK_STATE_NORMAL;
else
priv->arrow_state[i] = GTK_STATE_INSENSITIVE;
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = widget->style->xthickness + INNER_BORDER;
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ attributes.x = widget->style->xthickness + INNER_BORDER;
+ else
+ attributes.x = widget->allocation.width - priv->week_width - (widget->style->xthickness + INNER_BORDER);
attributes.y = (priv->header_h + priv->day_name_h
+ (widget->style->ythickness + INNER_BORDER));
attributes.width = priv->week_width;
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
- attributes.x = priv->week_width + (widget->style->ythickness + INNER_BORDER);
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ attributes.x = priv->week_width + (widget->style->ythickness + INNER_BORDER);
+ else
+ attributes.x = widget->style->ythickness + INNER_BORDER;
+
attributes.y = (priv->header_h + priv->day_name_h
+ (widget->style->ythickness + INNER_BORDER));
attributes.width = (widget->allocation.width - attributes.x
- (widget->style->xthickness + INNER_BORDER));
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ attributes.width -= priv->week_width;
+
attributes.height = priv->main_h;
priv->main_win = gdk_window_new (widget->window,
&attributes, attributes_mask);
priv->day_name_win = NULL;
}
- if (GTK_WIDGET_CLASS (gtk_calendar_parent_class)->unrealize)
- GTK_WIDGET_CLASS (gtk_calendar_parent_class)->unrealize (widget);
+ GTK_WIDGET_CLASS (gtk_calendar_parent_class)->unrealize (widget);
}
static gchar*
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
gint year, month;
+ if (priv->detail_func == NULL)
+ return NULL;
+
year = calendar->year;
month = calendar->month + calendar->day_month[row][column] - MONTH_CURRENT;
priv->max_year_width = 0;
/* Translators: This is a text measurement template.
- * Translate it to the widest year text.
- *
- * Don't include the prefix "year measurement template|"
- * in the translation.
+ * Translate it to the widest year text
*
* If you don't understand this, leave it as "2000"
*/
- pango_layout_set_text (layout, Q_("year measurement template|2000"), -1);
+ pango_layout_set_text (layout, C_("year measurement template", "2000"), -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
priv->max_year_width = MAX (priv->max_year_width,
logical_rect.width + 8);
for (i = 0; i < 9; i++)
{
gchar buffer[32];
- g_snprintf (buffer, sizeof (buffer), Q_("calendar:day:digits|%d"), i * 11);
+ g_snprintf (buffer, sizeof (buffer), C_("calendar:day:digits", "%d"), i * 11);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
priv->min_day_width = MAX (priv->min_day_width,
for (i = 0; i < 9; i++)
{
gchar buffer[32];
- g_snprintf (buffer, sizeof (buffer), Q_("calendar:week:digits|%d"), i * 11);
+ g_snprintf (buffer, sizeof (buffer), C_("calendar:week:digits", "%d"), i * 11);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
priv->max_week_char_width = MAX (priv->max_week_char_width,
* gtkcalendar widget. See strftime() manual for the format.
* Use only ASCII in the translation.
*
- * Also look for the msgid "year measurement template|2000".
+ * Also look for the msgid "2000".
* Translate that entry to a year with the widest output of this
- * msgid.
- *
- * Don't include the prefix "calendar year format|" in the
- * translation. "%Y" is appropriate for most locales.
+ * msgid.
+ *
+ * "%Y" is appropriate for most locales.
*/
- strftime (buffer, sizeof (buffer), Q_("calendar year format|%Y"), tm);
+ strftime (buffer, sizeof (buffer), C_("calendar year format", "%Y"), tm);
str = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
layout = gtk_widget_create_pango_layout (widget, str);
g_free (str);
* localized digits or the ones used in English (0123...).
*
* Translate to "%Id" if you want to use localized digits, or
- * translate to "%d" otherwise. Don't include the
- * "calendar:week:digits|" part in the translation.
+ * translate to "%d" otherwise.
*
* Note that translating this doesn't guarantee that you get localized
- * digits. That needs support from your system and locale definition
+ * digits. That needs support from your system and locale definition
* too.
*/
- g_snprintf (buffer, sizeof (buffer), Q_("calendar:week:digits|%d"), week);
+ g_snprintf (buffer, sizeof (buffer), C_("calendar:week:digits", "%d"), week);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
* localized digits or the ones used in English (0123...).
*
* Translate to "%Id" if you want to use localized digits, or
- * translate to "%d" otherwise. Don't include the "calendar:day:digits|"
- * part in the translation.
+ * translate to "%d" otherwise.
*
* Note that translating this doesn't guarantee that you get localized
- * digits. That needs support from your system and locale definition
+ * digits. That needs support from your system and locale definition
* too.
*/
- g_snprintf (buffer, sizeof (buffer), Q_("calendar:day:digits|%d"), day);
+ g_snprintf (buffer, sizeof (buffer), C_("calendar:day:digits", "%d"), day);
/* Get extra information to show, if any: */
- if (priv->detail_func)
- detail = gtk_calendar_get_detail (calendar, row, col);
- else
- detail = NULL;
+ detail = gtk_calendar_get_detail (calendar, row, col);
layout = gtk_widget_create_pango_layout (widget, buffer);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_cairo_show_layout (cr, layout);
}
- if (GTK_WIDGET_HAS_FOCUS (calendar)
+ if (gtk_widget_has_focus (widget)
&& calendar->focus_row == row && calendar->focus_col == col)
{
GtkStateType state;
if (calendar->selected_day == day)
- state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
+ state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
else
state = GTK_STATE_NORMAL;
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
int i;
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
{
if (event->window == priv->main_win)
calendar_paint_main (calendar);
else if (day_month == MONTH_NEXT)
calendar_set_month_next (calendar);
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
if (event->button == 1)
if (event->window == priv->main_win)
calendar_main_button_press (calendar, event);
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
for (arrow = ARROW_YEAR_LEFT; arrow <= ARROW_MONTH_RIGHT; arrow++)
if (event->direction == GDK_SCROLL_UP)
{
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
calendar_set_month_prev (calendar);
}
else if (event->direction == GDK_SCROLL_DOWN)
{
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
calendar_set_month_next (calendar);
}
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
int i;
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
{
priv->in_drag = 0;
calendar_stop_spinning (calendar);
}
for (i = 0; i < 4; i++)
- if (GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_sensitive (widget))
priv->arrow_state[i] = GTK_STATE_NORMAL;
else
priv->arrow_state[i] = GTK_STATE_INSENSITIVE;
selected_day = calendar->selected_day;
calendar->selected_day = 0;
- if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
+ if (gtk_widget_is_drawable (GTK_WIDGET (calendar)))
calendar_invalidate_day_num (calendar, selected_day);
}
/* Select the new day */
if (day != 0)
{
- if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
+ if (gtk_widget_is_drawable (GTK_WIDGET (calendar)))
calendar_invalidate_day_num (calendar, day);
}
/**
* gtk_calendar_get_date:
* @calendar: a #GtkCalendar
- * @year: location to store the year number, or %NULL
- * @month: location to store the month number (between 0 and 11), or %NULL
- * @day: location to store the day number (between 1 and 31), or %NULL
+ * @year: (allow-none): location to store the year number, or %NULL
+ * @month: (allow-none): location to store the month number (between 0 and 11), or %NULL
+ * @day: (allow-none): location to store the day number (between 1 and 31), or %NULL
*
* Obtains the selected date from a #GtkCalendar.
**/