#undef GTK_DISABLE_DEPRECATED
#include "gtkcalendar.h"
-#define GTK_DISABLE_DEPRECATED
#include "gtkdnd.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
-#include "gtkintl.h"
#include "gdk/gdkkeysyms.h"
#include "gtkalias.h"
time_t secs;
struct tm *tm;
gint i;
- char buffer[255];
#ifdef G_OS_WIN32
wchar_t wbuffer[100];
#else
+ char buffer[255];
time_t tmp_time;
#endif
GtkCalendarPrivate *priv;
gchar *year_before;
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
- gchar *langinfo;
+ union { unsigned int word; char *string; } langinfo;
gint week_1stday = 0;
gint first_weekday = 1;
guint week_origin;
strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
#else
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SABBREVDAYNAME1 + (i+6)%7,
- wbuffer, G_N_ELEMENTS (wbuffer)))
- default_abbreviated_dayname[i] = g_strdup_printf ("(%d)", i);
- else
- default_abbreviated_dayname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
- }
+ if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SABBREVDAYNAME1 + (i+6)%7,
+ wbuffer, G_N_ELEMENTS (wbuffer)))
+ default_abbreviated_dayname[i] = g_strdup_printf ("(%d)", i);
else
- {
- if (!GetLocaleInfoA (GetThreadLocale (),
- (LOCALE_SABBREVDAYNAME1 + (i+6)%7) | LOCALE_USE_CP_ACP,
- buffer, G_N_ELEMENTS (buffer)))
- default_abbreviated_dayname[i] = g_strdup_printf ("(%d)", i);
- else
- default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
- }
+ default_abbreviated_dayname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
#endif
}
strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
#else
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SMONTHNAME1 + i,
- wbuffer, G_N_ELEMENTS (wbuffer)))
- default_monthname[i] = g_strdup_printf ("(%d)", i);
- else
- default_monthname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
- }
+ if (!GetLocaleInfoW (GetThreadLocale (), LOCALE_SMONTHNAME1 + i,
+ wbuffer, G_N_ELEMENTS (wbuffer)))
+ default_monthname[i] = g_strdup_printf ("(%d)", i);
else
- {
- if (!GetLocaleInfoA (GetThreadLocale (),
- (LOCALE_SMONTHNAME1 + i) | LOCALE_USE_CP_ACP,
- buffer, G_N_ELEMENTS (buffer)))
- default_monthname[i] = g_strdup_printf ("(%d)", i);
- else
- default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
- }
+ default_monthname[i] = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
#endif
}
else if (strcmp (year_before, "calendar:MY") != 0)
g_warning ("Whoever translated calendar:MY did so wrongly.\n");
+#ifdef G_OS_WIN32
+ priv->week_start = 0;
+ week_start = NULL;
+
+ if (GetLocaleInfoW (GetThreadLocale (), LOCALE_IFIRSTDAYOFWEEK,
+ wbuffer, G_N_ELEMENTS (wbuffer)))
+ week_start = g_utf16_to_utf8 (wbuffer, -1, NULL, NULL, NULL);
+
+ if (week_start != NULL)
+ {
+ priv->week_start = (week_start[0] - '0' + 1) % 7;
+ g_free(week_start);
+ }
+#else
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
- langinfo = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
- first_weekday = langinfo[0];
- langinfo = nl_langinfo (_NL_TIME_WEEK_1STDAY);
- week_origin = GPOINTER_TO_INT (langinfo);
+ langinfo.string = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
+ first_weekday = langinfo.string[0];
+ langinfo.string = nl_langinfo (_NL_TIME_WEEK_1STDAY);
+ week_origin = langinfo.word;
if (week_origin == 19971130) /* Sunday */
week_1stday = 0;
else if (week_origin == 19971201) /* Monday */
g_warning ("Whoever translated calendar:week_start:0 did so wrongly.\n");
priv->week_start = 0;
}
+#endif
#endif
calendar_compute_days (calendar);
for (i = 0; i < 7; i++)
{
pango_layout_set_text (layout, default_abbreviated_dayname[i], -1);
- pango_layout_line_get_pixel_extents (pango_layout_get_lines (layout)->data, NULL, &logical_rect);
+ pango_layout_line_get_pixel_extents (pango_layout_get_lines_readonly (layout)->data, NULL, &logical_rect);
priv->min_day_width = MAX (priv->min_day_width, logical_rect.width);
priv->max_label_char_ascent = MAX (priv->max_label_char_ascent,
gtk_paint_arrow (widget->style, window, state,
GTK_SHADOW_OUT, NULL, widget, "calendar",
GTK_ARROW_RIGHT, TRUE,
- width/2 - 2, height/2 - 4, 8, 8);
+ width/2 - 4, height/2 - 4, 8, 8);
}
}
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
gboolean retval = FALSE;
- GDK_THREADS_ENTER ();
-
if (priv->timer)
{
calendar_arrow_action (calendar, priv->click_child);
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
priv->need_timer = FALSE;
- priv->timer = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
+ priv->timer = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT_IDLE,
timeout * SCROLL_DELAY_FACTOR,
(GSourceFunc) calendar_timer,
(gpointer) calendar, NULL);
retval = TRUE;
}
- GDK_THREADS_LEAVE ();
-
return retval;
}
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
priv->need_timer = TRUE;
- priv->timer = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
+ priv->timer = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT_IDLE,
timeout,
(GSourceFunc) calendar_timer,
(gpointer) calendar, NULL);
gint direction)
{
GtkTextDirection text_dir = gtk_widget_get_direction (GTK_WIDGET (calendar));
-
+
if ((text_dir == GTK_TEXT_DIR_LTR && direction == -1) ||
(text_dir == GTK_TEXT_DIR_RTL && direction == 1))
{
calendar->focus_col = 6;
calendar->focus_row--;
}
+
+ if (calendar->focus_col < 0)
+ calendar->focus_col = 6;
+ if (calendar->focus_row < 0)
+ calendar->focus_row = 5;
}
else
{
calendar->focus_col = 0;
calendar->focus_row++;
}
+
+ if (calendar->focus_col < 0)
+ calendar->focus_col = 0;
+ if (calendar->focus_row < 0)
+ calendar->focus_row = 0;
}
}
{
if (calendar->focus_row > 0)
calendar->focus_row--;
+ if (calendar->focus_row < 0)
+ calendar->focus_row = 5;
+ if (calendar->focus_col < 0)
+ calendar->focus_col = 6;
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, calendar->focus_row,
calendar->focus_col);
{
if (calendar->focus_row < 5)
calendar->focus_row++;
+ if (calendar->focus_col < 0)
+ calendar->focus_col = 0;
calendar_invalidate_day (calendar, old_focus_row, old_focus_col);
calendar_invalidate_day (calendar, calendar->focus_row,
calendar->focus_col);