/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2018 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
if (!GTK_IS_PROGRESS_BAR(w)) {
return FALSE;
}
-
+ gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(w), 0.1);
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(w));
GTK_EVENTS_FLUSH();
return TRUE;
{
GtkWidget *btn;
GtkWidget *btn_label;
-#if !GTK_CHECK_VERSION(3, 0, 0)
GdkColormap *cmap;
gboolean success[2];
-#endif
GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
gchar *local_url = NULL;
if (!url)
btn = gtk_button_new_with_label(label?label:url);
gtk_button_set_relief(GTK_BUTTON(btn), GTK_RELIEF_NONE);
btn_label = gtk_bin_get_child(GTK_BIN((btn)));
-#if !GTK_CHECK_VERSION(3, 0, 0)
cmap = gdk_drawable_get_colormap(gtk_widget_get_window(window));
gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
if (success[0] == TRUE && success[1] == TRUE) {
-#endif
GtkStyle *style;
gtk_widget_ensure_style(btn_label);
style = gtk_style_copy
style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
gtk_widget_set_style(btn_label, style);
g_object_unref(style);
-#if !GTK_CHECK_VERSION(3, 0, 0)
} else
g_warning("color allocation failed");
-#endif
g_signal_connect(G_OBJECT(btn), "enter",
G_CALLBACK(link_btn_enter), window);
}
}
- w = gdk_pixbuf_get_width(pixbuf);
- h = gdk_pixbuf_get_height(pixbuf);
-
- if (angle == 90 || angle == 270) {
- avail_height = box_width;
- avail_width = box_height;
- } else {
- avail_width = box_width;
- avail_height = box_height;
- }
-
- /* Scale first */
- if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
- if (w > avail_width) {
- h = (avail_width * h) / w;
- w = avail_width;
- }
- if (h > avail_height) {
- w = (avail_height * w) / h;
- h = avail_height;
- }
- t_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
- w, h, GDK_INTERP_BILINEAR);
- g_object_unref(pixbuf);
- pixbuf = t_pixbuf;
- }
/* Rotate if needed */
if (angle != 0) {
pixbuf = t_pixbuf;
}
+ w = gdk_pixbuf_get_width(pixbuf);
+ h = gdk_pixbuf_get_height(pixbuf);
+
+ avail_width = box_width;
+ avail_height = box_height;
+
+ if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
+ if (w > avail_width || h > avail_height) {
+ h = (avail_width * h) / w;
+ w = avail_width;
+ }
+ t_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
+ w, h, GDK_INTERP_BILINEAR);
+ g_object_unref(pixbuf);
+ pixbuf = t_pixbuf;
+ }
+
return pixbuf;
}
return ptr;
}
+
+static GList *get_predefined_times(void)
+{
+ int h,m;
+ GList *times = NULL;
+ for (h = 0; h < 24; h++) {
+ for (m = 0; m < 60; m += 15) {
+ gchar *tmp = g_strdup_printf("%02d:%02d", h, m);
+ times = g_list_append(times, tmp);
+ }
+ }
+ return times;
+}
+
+static int get_list_item_num(int h, int m)
+{
+ if (m % 15 != 0)
+ return -1;
+
+ return (h*4 + m/15);
+}
+
+GtkWidget *gtkut_time_select_combo_new()
+{
+ GtkWidget *combo = gtk_combo_box_text_new_with_entry();
+ GList *times = get_predefined_times();
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), -1);
+ combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(combo), times);
+
+ list_free_strings_full(times);
+
+ return combo;
+}
+
+
+void gtkut_time_select_select_by_time(GtkComboBox *combo, int hour, int minute)
+{
+ gchar *time_text = g_strdup_printf("%02d:%02d", hour, minute);
+ gint num = get_list_item_num(hour, minute);
+
+ if (num > -1)
+ combobox_select_by_text(combo, time_text);
+ else
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), time_text);
+
+ g_free(time_text);
+}
+
+static void get_time_from_combo(GtkComboBox *combo, int *h, int *m)
+{
+ gchar *tmp;
+ gchar **parts;
+
+ if (!h || !m)
+ return;
+
+ tmp = gtk_editable_get_chars(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(combo))), 0, -1);
+ parts = g_strsplit(tmp, ":", 2);
+ if (parts[0] && parts[1] && *parts[0] && *parts[1]) {
+ *h = atoi(parts[0]);
+ *m = atoi(parts[1]);
+ }
+ g_strfreev(parts);
+ g_free(tmp);
+}
+
+gboolean gtkut_time_select_get_time(GtkComboBox *combo, int *hour, int *minute)
+{
+ const gchar *value = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))));
+
+ if (value == NULL || strlen(value) != 5)
+ return FALSE;
+
+ if (hour == NULL || minute == NULL)
+ return FALSE;
+
+ get_time_from_combo(combo, hour, minute);
+
+ if (*hour < 0 || *hour > 23)
+ return FALSE;
+ if (*minute < 0 || *minute > 59)
+ return FALSE;
+
+ return TRUE;
+}
+
+void gtk_calendar_select_today(GtkCalendar *calendar)
+{
+ time_t t = time (NULL);
+ struct tm buft;
+ struct tm *lt = localtime_r (&t, &buft);
+
+ mktime(lt);
+ gtk_calendar_select_day(calendar, lt->tm_mday);
+ gtk_calendar_select_month(calendar, lt->tm_mon, lt->tm_year + 1900);
+}