search-view: hide if click is performed outside
Result drop down should disappear when any click is performed outside that drop down. https://bugzilla.gnome.org/show_bug.cgi?id=74796 https://bugzilla.gnome.org/show_bug.cgi?id=747962
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
a6e347d8f2
commit
ec3ef0d0a3
+40
-1
@@ -163,6 +163,10 @@ struct _GcalWindow
|
||||
|
||||
/* temp to keep event_creation */
|
||||
gboolean open_edit_dialog;
|
||||
|
||||
/* handler for the searh_view */
|
||||
gint click_outside_handler_id;
|
||||
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -209,6 +213,27 @@ static const GActionEntry actions[] = {
|
||||
/*
|
||||
* Auxiliary methods
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
hide_search_view_on_click_outside (GcalWindow *window,
|
||||
GdkEventButton *event,
|
||||
GtkPopover *popover)
|
||||
{
|
||||
GdkWindow *search_view_window;
|
||||
|
||||
search_view_window = gtk_widget_get_window (GTK_WIDGET (popover));
|
||||
|
||||
/* If the event is not produced in the search view widget, we hide the search_bar */
|
||||
if (event->window != search_view_window)
|
||||
{
|
||||
gtk_popover_popdown (popover);
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (window->search_bar), FALSE);
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
update_today_button_sensitive (GcalWindow *window)
|
||||
{
|
||||
@@ -1143,7 +1168,21 @@ search_toggled (GObject *object,
|
||||
|
||||
/* update header_bar widget */
|
||||
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (window->search_bar)))
|
||||
gcal_search_view_search (GCAL_SEARCH_VIEW (window->search_view), NULL, NULL);
|
||||
{
|
||||
gcal_search_view_search (GCAL_SEARCH_VIEW (window->search_view), NULL, NULL);
|
||||
|
||||
/* When the search button is toogled we connect the signal */
|
||||
window->click_outside_handler_id = g_signal_connect (window,
|
||||
"button-press-event",
|
||||
G_CALLBACK (hide_search_view_on_click_outside),
|
||||
window->search_view);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* When the search mode is false we disconnect the handler */
|
||||
g_signal_handler_disconnect (window, window->click_outside_handler_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1973,7 +1973,7 @@ gcal_month_view_button_press (GtkWidget *widget,
|
||||
if (pressed_indicator && g_hash_table_contains (ppriv->overflow_cells, GINT_TO_POINTER (clicked_cell)))
|
||||
self->pressed_overflow_indicator = clicked_cell;
|
||||
|
||||
return TRUE;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -798,7 +798,7 @@ gcal_week_grid_button_press (GtkWidget *widget,
|
||||
|
||||
gtk_widget_queue_draw (widget);
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -140,7 +140,7 @@ on_button_pressed (GcalWeekHeader *self,
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -1135,7 +1135,7 @@ navigator_button_press_cb (GcalYearView *year_view,
|
||||
gboolean is_title = FALSE;
|
||||
|
||||
if (!calculate_day_month_for_coord (year_view, event->x, event->y, &day, &month, &is_title))
|
||||
return FALSE;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (is_title)
|
||||
day = 1;
|
||||
@@ -1144,7 +1144,7 @@ navigator_button_press_cb (GcalYearView *year_view,
|
||||
year_view->selected_data->start_day = day;
|
||||
year_view->selected_data->start_month = month;
|
||||
|
||||
return TRUE;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
Reference in New Issue
Block a user