[nautilus/wip/antoniof/make-window-slot-final: 6/7] window-slot: Use view id macros as action values
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/make-window-slot-final: 6/7] window-slot: Use view id macros as action values
- Date: Wed, 13 Jan 2021 22:11:25 +0000 (UTC)
commit e75a4a851c2397581e174c9a9d559f5818558d04
Author: António Fernandes <antoniof gnome org>
Date: Wed Jan 13 12:36:36 2021 +0000
window-slot: Use view id macros as action values
The slot.files-view-mode action takes hardcoded id values.
This may break if the ids enumeration changes.
To prevent that define the values with a macro which we can stringify.
src/nautilus-view.h | 6 ++++--
src/nautilus-window-slot.c | 10 ++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index deeb4bb3e..9d46ab6dd 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -24,10 +24,12 @@
#include "nautilus-query.h"
#include "nautilus-toolbar-menu-sections.h"
+#define NAUTILUS_VIEW_GRID_ID_VALUE 0
+#define NAUTILUS_VIEW_LIST_ID_VALUE 1
enum
{
- NAUTILUS_VIEW_GRID_ID,
- NAUTILUS_VIEW_LIST_ID,
+ NAUTILUS_VIEW_GRID_ID = NAUTILUS_VIEW_GRID_ID_VALUE,
+ NAUTILUS_VIEW_LIST_ID = NAUTILUS_VIEW_LIST_ID_VALUE,
NAUTILUS_VIEW_EMPTY_ID,
NAUTILUS_VIEW_OTHER_LOCATIONS_ID,
NAUTILUS_VIEW_INVALID_ID,
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index cd4b4f78a..fa3580130 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -1119,6 +1119,7 @@ static void
nautilus_window_slot_init (NautilusWindowSlot *self)
{
GApplication *app;
+
app = g_application_get_default ();
g_signal_connect (nautilus_trash_monitor_get (),
@@ -1141,8 +1142,13 @@ nautilus_window_slot_init (NautilusWindowSlot *self)
gtk_widget_insert_action_group (GTK_WIDGET (self),
"slot",
G_ACTION_GROUP (self->slot_action_group));
- nautilus_application_set_accelerator (app, "slot.files-view-mode(uint32 1)", "<control>1");
- nautilus_application_set_accelerator (app, "slot.files-view-mode(uint32 0)", "<control>2");
+
+ nautilus_application_set_accelerator (app,
+ "slot.files-view-mode(uint32 " G_STRINGIFY
(NAUTILUS_VIEW_LIST_ID_VALUE) ")",
+ "<control>1");
+ nautilus_application_set_accelerator (app,
+ "slot.files-view-mode(uint32 " G_STRINGIFY
(NAUTILUS_VIEW_GRID_ID_VALUE) ")",
+ "<control>2");
nautilus_application_set_accelerator (app, "slot.search-visible", "<control>f");
self->view_mode_before_search = NAUTILUS_VIEW_INVALID_ID;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]