Commit 262a0dd0 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

desktop: activate rename with F2 key

https://bugs.launchpad.net/bugs/1875703
parent a149a614
Pipeline #174668 passed with stages
in 11 minutes and 58 seconds
......@@ -96,6 +96,8 @@ enum
ACTIVATE,
RENAME,
TRASH,
DELETE,
......@@ -2086,6 +2088,17 @@ activate_cb (GfIconView *self,
gf_icon_open (GF_ICON (l->data));
}
static void
rename_cb (GfIconView *self,
gpointer user_data)
{
if (self->selected_icons == NULL ||
g_list_length (self->selected_icons) != 1)
return;
gf_icon_rename (GF_ICON (self->selected_icons->data));
}
static void
trash_cb (GfIconView *self,
gpointer user_data)
......@@ -2709,6 +2722,11 @@ install_signals (void)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
view_signals[RENAME] =
g_signal_new ("rename", GF_TYPE_ICON_VIEW,
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
view_signals[TRASH] =
g_signal_new ("trash", GF_TYPE_ICON_VIEW,
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
......@@ -2781,6 +2799,12 @@ add_bindings (GtkBindingSet *binding_set)
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, modifiers,
"activate", 0);
/* Rename */
modifiers = 0;
gtk_binding_entry_add_signal (binding_set, GDK_KEY_F2, modifiers,
"rename", 0);
/* Trash */
modifiers = 0;
......@@ -2876,6 +2900,7 @@ gf_icon_view_init (GfIconView *self)
g_signal_connect (self, "select-all", G_CALLBACK (select_all_cb), NULL);
g_signal_connect (self, "unselect-all", G_CALLBACK (unselect_all_cb), NULL);
g_signal_connect (self, "activate", G_CALLBACK (activate_cb), NULL);
g_signal_connect (self, "rename", G_CALLBACK (rename_cb), NULL);
g_signal_connect (self, "trash", G_CALLBACK (trash_cb), NULL);
g_signal_connect (self, "delete", G_CALLBACK (delete_cb), NULL);
g_signal_connect (self, "toggle", G_CALLBACK (toggle_cb), NULL);
......
......@@ -444,32 +444,7 @@ static void
rename_cb (GtkMenuItem *item,
GfIcon *self)
{
GfIconPrivate *priv;
priv = gf_icon_get_instance_private (self);
g_assert (priv->popover == NULL);
priv->popover = gf_rename_popover_new (GTK_WIDGET (self),
gf_icon_get_file_type (self),
gf_icon_get_name (self));
g_signal_connect (priv->popover, "validate",
G_CALLBACK (rename_validate_cb),
self);
g_signal_connect (priv->popover, "do-rename",
G_CALLBACK (rename_do_rename_cb),
self);
g_signal_connect (priv->popover, "closed",
G_CALLBACK (rename_closed_cb),
self);
g_signal_connect (priv->popover, "destroy",
G_CALLBACK (rename_destroy_cb),
self);
gtk_popover_popup (GTK_POPOVER (priv->popover));
gf_icon_rename (self);
}
static void
......@@ -586,6 +561,9 @@ create_popup_menu (GfIcon *self)
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
gtk_widget_show (item);
label = gtk_bin_get_child (GTK_BIN (item));
gtk_accel_label_set_accel (GTK_ACCEL_LABEL (label), GDK_KEY_F2, 0);
g_signal_connect (item, "activate",
G_CALLBACK (rename_cb),
self);
......@@ -1594,6 +1572,40 @@ gf_icon_open (GfIcon *self)
g_free (uri);
}
void
gf_icon_rename (GfIcon *self)
{
GfIconPrivate *priv;
if (!GF_ICON_GET_CLASS (self)->can_rename (self))
return;
priv = gf_icon_get_instance_private (self);
g_assert (priv->popover == NULL);
priv->popover = gf_rename_popover_new (GTK_WIDGET (self),
gf_icon_get_file_type (self),
gf_icon_get_name (self));
g_signal_connect (priv->popover, "validate",
G_CALLBACK (rename_validate_cb),
self);
g_signal_connect (priv->popover, "do-rename",
G_CALLBACK (rename_do_rename_cb),
self);
g_signal_connect (priv->popover, "closed",
G_CALLBACK (rename_closed_cb),
self);
g_signal_connect (priv->popover, "destroy",
G_CALLBACK (rename_destroy_cb),
self);
gtk_popover_popup (GTK_POPOVER (priv->popover));
}
void
gf_icon_popup_menu (GfIcon *self)
{
......
......@@ -75,6 +75,8 @@ gboolean gf_icon_get_selected (GfIcon *self);
void gf_icon_open (GfIcon *self);
void gf_icon_rename (GfIcon *self);
void gf_icon_popup_menu (GfIcon *self);
void gf_icon_update (GfIcon *self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment