mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
calendar: Remove day-selected-double-click signal
It doesn't really make sense to treat double clicks here different than single clicks (and is bad UX), and it also breaks switching months by quickly trying to single-click the last/first days in the calendar.
This commit is contained in:
parent
3249756648
commit
b9b5cae6d2
@ -150,7 +150,6 @@ enum {
|
||||
|
||||
enum {
|
||||
DAY_SELECTED_SIGNAL,
|
||||
DAY_SELECTED_DOUBLE_CLICK_SIGNAL,
|
||||
PREV_MONTH_SIGNAL,
|
||||
NEXT_MONTH_SIGNAL,
|
||||
PREV_YEAR_SIGNAL,
|
||||
@ -184,7 +183,6 @@ struct _GtkCalendarClass
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* day_selected) (GtkCalendar *calendar);
|
||||
void (* day_selected_double_click) (GtkCalendar *calendar);
|
||||
void (* prev_month) (GtkCalendar *calendar);
|
||||
void (* next_month) (GtkCalendar *calendar);
|
||||
void (* prev_year) (GtkCalendar *calendar);
|
||||
@ -423,21 +421,6 @@ gtk_calendar_class_init (GtkCalendarClass *class)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkCalendar::day-selected-double-click:
|
||||
* @calendar: the object which received the signal.
|
||||
*
|
||||
* Emitted when the user double-clicks a day.
|
||||
*/
|
||||
gtk_calendar_signals[DAY_SELECTED_DOUBLE_CLICK_SIGNAL] =
|
||||
g_signal_new (I_("day-selected-double-click"),
|
||||
G_OBJECT_CLASS_TYPE (gobject_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GtkCalendarClass, day_selected_double_click),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkCalendar::prev-month:
|
||||
* @calendar: the object which received the signal.
|
||||
@ -1061,36 +1044,24 @@ gtk_calendar_button_press (GtkGestureClick *gesture,
|
||||
return;
|
||||
|
||||
day_month = priv->day_month[row][col];
|
||||
day = priv->day[row][col];
|
||||
|
||||
if (n_press == 1)
|
||||
if (day_month == MONTH_PREV)
|
||||
calendar_set_month_prev (calendar);
|
||||
else if (day_month == MONTH_NEXT)
|
||||
calendar_set_month_next (calendar);
|
||||
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
|
||||
if (button == GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
day = priv->day[row][col];
|
||||
|
||||
if (day_month == MONTH_PREV)
|
||||
calendar_set_month_prev (calendar);
|
||||
else if (day_month == MONTH_NEXT)
|
||||
calendar_set_month_next (calendar);
|
||||
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
|
||||
if (button == GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
priv->in_drag = 1;
|
||||
priv->drag_start_x = x;
|
||||
priv->drag_start_y = y;
|
||||
}
|
||||
|
||||
calendar_select_and_focus_day (calendar, day);
|
||||
}
|
||||
else if (n_press == 2)
|
||||
{
|
||||
priv->in_drag = 0;
|
||||
if (day_month == MONTH_CURRENT)
|
||||
g_signal_emit (calendar,
|
||||
gtk_calendar_signals[DAY_SELECTED_DOUBLE_CLICK_SIGNAL],
|
||||
0);
|
||||
priv->in_drag = 1;
|
||||
priv->drag_start_x = x;
|
||||
priv->drag_start_y = y;
|
||||
}
|
||||
|
||||
calendar_select_and_focus_day (calendar, day);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -86,27 +86,6 @@ calendar_day_selected (GtkWidget *widget,
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
calendar_day_selected_double_click (GtkWidget *widget,
|
||||
CalendarData *data)
|
||||
{
|
||||
char *str;
|
||||
guint day;
|
||||
GDateTime *date;
|
||||
|
||||
str = calendar_date_to_string (data, "day-selected-double-click: %c");
|
||||
calendar_set_signal_strings (str, data);
|
||||
date = gtk_calendar_get_date (GTK_CALENDAR (data->calendar_widget));
|
||||
day = g_date_time_get_day_of_month (date);
|
||||
|
||||
if (gtk_calendar_get_day_is_marked (GTK_CALENDAR (data->calendar_widget), day))
|
||||
gtk_calendar_unmark_day (GTK_CALENDAR (data->calendar_widget), day);
|
||||
else
|
||||
gtk_calendar_mark_day (GTK_CALENDAR (data->calendar_widget), day);
|
||||
|
||||
g_date_time_unref (date);
|
||||
}
|
||||
|
||||
static void
|
||||
calendar_prev_month (GtkWidget *widget,
|
||||
CalendarData *data)
|
||||
@ -222,9 +201,6 @@ create_calendar(void)
|
||||
g_signal_connect (calendar, "day-selected",
|
||||
G_CALLBACK (calendar_day_selected),
|
||||
&calendar_data);
|
||||
g_signal_connect (calendar, "day-selected-double-click",
|
||||
G_CALLBACK (calendar_day_selected_double_click),
|
||||
&calendar_data);
|
||||
g_signal_connect (calendar, "prev-month",
|
||||
G_CALLBACK (calendar_prev_month),
|
||||
&calendar_data);
|
||||
|
Loading…
Reference in New Issue
Block a user