places sidebar: Stop using ::button-press/release-event

We'll use a generic ::event signal instead.
This commit is contained in:
Matthias Clasen 2018-01-16 00:15:22 -05:00
parent 10ac015ac6
commit 15e67e27ca

View File

@ -281,11 +281,8 @@ static void check_unmount_and_eject (GMount *mount,
GDrive *drive,
gboolean *show_unmount,
gboolean *show_eject);
static gboolean on_button_press_event (GtkWidget *widget,
GdkEventButton *event,
GtkSidebarRow *sidebar);
static gboolean on_button_release_event (GtkWidget *widget,
GdkEventButton *event,
static gboolean on_row_event (GtkWidget *widget,
GdkEvent *event,
GtkSidebarRow *sidebar);
static void popup_menu_cb (GtkSidebarRow *row);
static void long_press_cb (GtkGesture *gesture,
@ -495,10 +492,8 @@ add_place (GtkPlacesSidebar *sidebar,
g_signal_connect_swapped (eject_button, "clicked",
G_CALLBACK (eject_or_unmount_bookmark), row);
g_signal_connect (GTK_SIDEBAR_ROW (row), "button-press-event",
G_CALLBACK (on_button_press_event), row);
g_signal_connect (GTK_SIDEBAR_ROW (row), "button-release-event",
G_CALLBACK (on_button_release_event), row);
g_signal_connect (GTK_SIDEBAR_ROW (row), "event",
G_CALLBACK (on_row_event), row);
gtk_container_add (GTK_CONTAINER (sidebar->list_box), GTK_WIDGET (row));
@ -3721,19 +3716,23 @@ on_row_activated (GtkListBox *list_box,
}
static gboolean
on_button_press_event (GtkWidget *widget,
GdkEventButton *event,
on_row_event (GtkWidget *widget,
GdkEvent *event,
GtkSidebarRow *row)
{
GtkPlacesSidebar *sidebar;
GtkPlacesSidebarSectionType section_type;
GtkPlacesSidebarPlaceType row_type;
gdouble x, y;
g_object_get (GTK_SIDEBAR_ROW (row),
g_object_get (row,
"sidebar", &sidebar,
"section_type", &section_type,
"place-type", &row_type,
NULL);
if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
{
if (section_type == SECTION_BOOKMARKS)
{
gdk_event_get_coords ((GdkEvent *) event, &x, &y);
@ -3746,25 +3745,16 @@ on_button_press_event (GtkWidget *widget,
}
g_object_unref (sidebar);
return FALSE;
}
static gboolean
on_button_release_event (GtkWidget *widget,
GdkEventButton *event,
GtkSidebarRow *row)
else if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
{
gboolean ret = FALSE;
GtkPlacesSidebarPlaceType row_type;
guint button, state;
if (event && row &&
gdk_event_get_button ((GdkEvent *) event, &button) &&
gdk_event_get_state ((GdkEvent *) event, &state))
if (row &&
gdk_event_get_button (event, &button) &&
gdk_event_get_state (event, &state))
{
g_object_get (row, "place-type", &row_type, NULL);
if (button == 1)
ret = FALSE;
else if (button == 2)
@ -3788,6 +3778,9 @@ on_button_release_event (GtkWidget *widget,
return ret;
}
return FALSE;
}
static void
popup_menu_cb (GtkSidebarRow *row)
{