shell: Activate items on single click
https://bugzilla.gnome.org/show_bug.cgi?id=692150
This commit is contained in:
parent
0b4c630e47
commit
a98e81e1c3
2 changed files with 5 additions and 44 deletions
|
@ -28,7 +28,7 @@ G_DEFINE_TYPE (CcShellItemView, cc_shell_item_view, GTK_TYPE_ICON_VIEW)
|
|||
|
||||
struct _CcShellItemViewPrivate
|
||||
{
|
||||
gboolean ignore_release;
|
||||
gpointer padding;
|
||||
};
|
||||
|
||||
|
||||
|
@ -79,43 +79,6 @@ cc_shell_item_view_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (cc_shell_item_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
iconview_button_press_event_cb (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
CcShellItemView *cc_view)
|
||||
{
|
||||
/* be sure to ignore double and triple clicks */
|
||||
cc_view->priv->ignore_release = (event->type != GDK_BUTTON_PRESS);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
iconview_button_release_event_cb (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
CcShellItemView *cc_view)
|
||||
{
|
||||
CcShellItemViewPrivate *priv = cc_view->priv;
|
||||
|
||||
if (event->button == 1 && !priv->ignore_release)
|
||||
{
|
||||
GList *selection;
|
||||
|
||||
selection =
|
||||
gtk_icon_view_get_selected_items (GTK_ICON_VIEW (cc_view));
|
||||
|
||||
if (!selection)
|
||||
return TRUE;
|
||||
|
||||
gtk_icon_view_item_activated (GTK_ICON_VIEW (cc_view),
|
||||
(GtkTreePath*) selection->data);
|
||||
|
||||
g_list_free (selection);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
iconview_item_activated_cb (GtkIconView *icon_view,
|
||||
GtkTreePath *path,
|
||||
|
@ -198,14 +161,12 @@ cc_shell_item_view_init (CcShellItemView *self)
|
|||
g_object_set (self, "margin", 0, NULL);
|
||||
g_signal_connect (self, "item-activated",
|
||||
G_CALLBACK (iconview_item_activated_cb), self);
|
||||
g_signal_connect (self, "button-press-event",
|
||||
G_CALLBACK (iconview_button_press_event_cb), self);
|
||||
g_signal_connect (self, "button-release-event",
|
||||
G_CALLBACK (iconview_button_release_event_cb), self);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
cc_shell_item_view_new (void)
|
||||
{
|
||||
return g_object_new (CC_TYPE_SHELL_ITEM_VIEW, NULL);
|
||||
return g_object_new (CC_TYPE_SHELL_ITEM_VIEW,
|
||||
"activate-on-single-click", TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue