1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
From ec763f341d737c61a2eee020de53ccd5db8b8dcf Mon Sep 17 00:00:00 2001
From: Michael Webster <miketwebster@gmail.com>
Date: Fri, 23 Nov 2012 10:26:31 -0500
Subject: [PATCH] Simplify view toolbar item management
---
src/nemo-window-menus.c | 39 +++++++++++++++++++++++----------------
src/nemo-window-menus.h | 9 +++++----
src/nemo-window.c | 2 +-
3 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/src/nemo-window-menus.c b/src/nemo-window-menus.c
index 927c6b7..bd29084 100644
--- a/src/nemo-window-menus.c
+++ b/src/nemo-window-menus.c
@@ -27,8 +27,9 @@
*/
#include <config.h>
-#include <locale.h>
+#include <locale.h>
+#include "nemo-window-menus.h"
#include "nemo-actions.h"
#include "nemo-application.h"
#include "nemo-connect-server-dialog.h"
@@ -767,6 +768,13 @@ action_edit_location_callback (GtkAction *action,
nemo_window_pane_ensure_location_bar (pane);
}
+enum {
+ ICON_VIEW,
+ LIST_VIEW,
+ COMPACT_VIEW,
+ NULL_VIEW
+};
+
static void
action_icon_view_callback (GtkAction *action,
gpointer user_data)
@@ -776,7 +784,7 @@ action_icon_view_callback (GtkAction *action,
window = NEMO_WINDOW (user_data);
slot = nemo_window_get_active_slot (window);
nemo_window_slot_set_content_view (slot, NEMO_ICON_VIEW_ID);
- toolbar_set_view_button (NEMO_ACTION_ICON_VIEW, nemo_window_get_active_pane(window));
+ toolbar_set_view_button (ICON_VIEW, nemo_window_get_active_pane(window));
}
@@ -789,7 +797,7 @@ action_list_view_callback (GtkAction *action,
window = NEMO_WINDOW (user_data);
slot = nemo_window_get_active_slot (window);
nemo_window_slot_set_content_view (slot, NEMO_LIST_VIEW_ID);
- toolbar_set_view_button (NEMO_ACTION_LIST_VIEW, nemo_window_get_active_pane(window));
+ toolbar_set_view_button (LIST_VIEW, nemo_window_get_active_pane(window));
}
@@ -802,30 +810,29 @@ action_compact_view_callback (GtkAction *action,
window = NEMO_WINDOW (user_data);
slot = nemo_window_get_active_slot (window);
nemo_window_slot_set_content_view (slot, FM_COMPACT_VIEW_ID);
- toolbar_set_view_button (NEMO_ACTION_COMPACT_VIEW, nemo_window_get_active_pane(window));
+ toolbar_set_view_button (COMPACT_VIEW, nemo_window_get_active_pane(window));
}
-
-gchar *
-toolbar_action_for_view_id (gchar *view_id)
+guint
+toolbar_action_for_view_id (const char *view_id)
{
if (g_strcmp0(view_id, NEMO_ICON_VIEW_ID) == 0) {
- return NEMO_ACTION_ICON_VIEW;
+ return ICON_VIEW;
} else if (g_strcmp0(view_id, NEMO_LIST_VIEW_ID) == 0) {
- return NEMO_ACTION_LIST_VIEW;
+ return LIST_VIEW;
} else if (g_strcmp0(view_id, FM_COMPACT_VIEW_ID) == 0) {
- return NEMO_ACTION_COMPACT_VIEW;
+ return COMPACT_VIEW;
} else {
- return NULL;
+ return NULL_VIEW;
}
}
void
-toolbar_set_view_button (gchar *action_id, NemoWindowPane *pane)
+toolbar_set_view_button (guint action_id, NemoWindowPane *pane)
{
GtkAction *action, *action1, *action2;
GtkActionGroup *action_group;
- if (action_id == NULL) {
+ if (action_id == NULL_VIEW) {
return;
}
action_group = nemo_window_pane_get_toolbar_action_group (pane);
@@ -858,19 +865,19 @@ toolbar_set_view_button (gchar *action_id, NemoWindowPane *pane)
action_compact_view_callback,
NULL);
- if (g_strcmp0(action_id, NEMO_ACTION_ICON_VIEW) != 0) {
+ if (action_id != ICON_VIEW) {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
} else {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
}
- if (g_strcmp0(action_id, NEMO_ACTION_LIST_VIEW) != 0) {
+ if (action_id != LIST_VIEW) {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action1), FALSE);
} else {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action1), TRUE);
}
- if (g_strcmp0(action_id, NEMO_ACTION_COMPACT_VIEW) != 0) {
+ if (action_id != COMPACT_VIEW) {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action2), FALSE);
} else {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action2), TRUE);
diff --git a/src/nemo-window-menus.h b/src/nemo-window-menus.h
index 2ed773b..9ecf614 100644
--- a/src/nemo-window-menus.h
+++ b/src/nemo-window-menus.h
@@ -22,13 +22,14 @@
Author: Holger Berndt <berndth@gmx.de>
*/
-#ifndef NEMO_WINDOW_PANE_H
-#define NEMO_WINDOW_PANE_H
+#ifndef NEMO_WINDOW_MENUS_H
+#define NEMO_WINDOW_MENUS_H
#include "nemo-window.h"
+#include "nemo-window-pane.h"
#include <gtk/gtk.h>
-gchar * toolbar_action_for_view_id (gchar *view_id );
-void toolbar_set_view_button (gchar *action_id, NemoWindowPane *pane);
+guint toolbar_action_for_view_id (const char *view_id );
+void toolbar_set_view_button (guint action_id, NemoWindowPane *pane);
#endif /* NEMO_WINDOW_PANE_H */
diff --git a/src/nemo-window.c b/src/nemo-window.c
index 4b4e67d..592e346 100644
--- a/src/nemo-window.c
+++ b/src/nemo-window.c
@@ -1246,7 +1246,7 @@ nemo_window_sync_view_as_menus (NemoWindow *window)
char action_name[32];
GList *node;
GtkAction *action;
- gchar *view_id;
+ const char *view_id;
g_assert (NEMO_IS_WINDOW (window));
--
1.8.0.2
|