[gnome-commander] Open properties popup by keypress at the position of the file/directory in the file list, fixing #96
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Open properties popup by keypress at the position of the file/directory in the file list, fixing #96
- Date: Mon, 22 Feb 2021 21:50:29 +0000 (UTC)
commit aa40e0ee762dce8f33af945a002bab52257486ad
Author: Uwe Scholz <u scholz83 gmx de>
Date: Mon Feb 22 22:48:38 2021 +0100
Open properties popup by keypress at the position of the file/directory in the file list, fixing #96
NEWS | 1 +
doc/C/releases.xml | 3 +++
src/gnome-cmd-file-list.cc | 47 +++++++++++++++++++++++++++++++---------------
3 files changed, 36 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 120b89a5..29efcdad 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ New features:
Bug fixes:
* Fixed issue #95 (InternalViewer: Scrolling images via mouse, mouse scroll wheel or keyboard arrow keys)
+ * Fixed issue #96 (Segmentation fault when opening file/directory properties using keyboard)
* Minor memory optimizations
===================================
diff --git a/doc/C/releases.xml b/doc/C/releases.xml
index 51043cbb..1864b629 100644
--- a/doc/C/releases.xml
+++ b/doc/C/releases.xml
@@ -32,6 +32,9 @@
<listitem>
<para>Fixed issue #95 (InternalViewer: Scrolling images via mouse, mouse scroll
wheel or keyboard arrow keys)</para>
</listitem>
+ <listitem>
+ <para>Fixed issue #96 (Segmentation fault when opening file/directory properties
using keyboard)</para>
+ </listitem>
</itemizedlist>
</para>
<para>New features:</para>
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index d4f1d417..d21578e2 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -808,28 +808,45 @@ static char *build_selected_file_list (GnomeCmdFileList *fl, int *file_list_len)
}
-static void show_file_popup (GnomeCmdFileList *fl, GdkEventButton *event)
+static void get_popup_pos (GtkMenu *menu, gint *x, gint *y, gboolean push_in, GnomeCmdFileList
*gnomeCmdFileList)
{
- // create the popup menu
- GtkWidget *menu = gnome_cmd_file_popmenu_new (fl);
- if (!menu) return;
+ g_return_if_fail (GNOME_CMD_IS_FILE_LIST (gnomeCmdFileList));
- g_object_ref (menu);
- g_object_set_data_full (*fl, "file_popup_menu", menu, g_object_unref);
+ gint w, h;
- gtk_menu_popup (GTK_MENU (menu), nullptr, nullptr, nullptr, fl, event->button, event->time);
+ get_focus_row_coordinates (gnomeCmdFileList, *x, *y, w, h);
}
-inline void show_file_popup_with_warp (GnomeCmdFileList *fl)
+static void show_file_popup (GnomeCmdFileList *fl, GdkEventButton *event)
{
- gint x, y, w, h;
-
- get_focus_row_coordinates (fl, x, y, w, h);
+ // create the popup menu
+ GtkWidget *menu = gnome_cmd_file_popmenu_new (fl);
+ if (!menu) return;
- //FIXME: Warp the pointer to x, y here
+ g_object_ref (menu);
+ g_object_set_data_full (*fl, "file_popup_menu", menu, g_object_unref);
- show_file_popup (fl, nullptr);
+ if (event)
+ {
+ gtk_menu_popup (GTK_MENU (menu),
+ nullptr,
+ nullptr,
+ nullptr,
+ fl,
+ event->button,
+ event->time);
+ }
+ else
+ {
+ gtk_menu_popup (GTK_MENU (menu),
+ nullptr,
+ nullptr,
+ (GtkMenuPositionFunc) get_popup_pos,
+ fl,
+ 0,
+ gtk_get_current_event_time ());
+ }
}
@@ -2480,7 +2497,7 @@ gboolean GnomeCmdFileList::key_pressed(GdkEventKey *event)
return TRUE;
case GDK_F10:
- show_file_popup_with_warp (this);
+ show_file_popup (this, nullptr);
return TRUE;
case GDK_Left:
@@ -2662,7 +2679,7 @@ gboolean GnomeCmdFileList::key_pressed(GdkEventKey *event)
return TRUE;
case GDK_Menu:
- show_file_popup_with_warp (this);
+ show_file_popup (this, nullptr);
return TRUE;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]