90817683b8cded6f00d367647a5c9a008de8cbcb
[lxde/pcmanfm.git] / src / main-win-ui.c
1 /*
2 * main-win-ui.c
3 *
4 * Copyright 2009 - 2012 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
5 * Copyright 2012-2014 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22
23 /* this file is included by main-win.c */
24
25 static const char main_menu_xml[] =
26 "<menubar>"
27 "<menu action='FileMenu'>"
28 "<menuitem action='New'/>"
29 "<menuitem action='NewTab'/>"
30 "<separator/>"
31 "<menu action='CreateNew'>"
32 "<menuitem action='NewFolder'/>"
33 "<menuitem action='NewBlank'/>"
34 "</menu>"
35 "<separator/>"
36 "<menuitem action='Prop'/>"
37 "<separator/>"
38 "<menuitem action='CloseTab'/>"
39 "<menuitem action='Close'/>"
40 "</menu>"
41 "<menu action='EditMenu'>"
42 "<menuitem action='Open'/>"
43 "<separator/>"
44 "<menuitem action='Cut'/>"
45 "<menuitem action='Copy'/>"
46 "<menuitem action='Paste'/>"
47 "<menuitem action='ToTrash'/>"
48 "<menuitem action='Del'/>"
49 "<menuitem action='CopyPath'/>"
50 "<separator/>"
51 "<menuitem action='FileProp'/>"
52 "<separator/>"
53 "<menuitem action='Rename'/>"
54 "<menuitem action='Link'/>"
55 /* TODO: implement "Create a duplicate" action
56 "<menuitem action='Duplicate'/>" */
57 "<menuitem action='MoveTo'/>"
58 "<menuitem action='CopyTo'/>"
59 "<separator/>"
60 "<menuitem action='SelAll'/>"
61 "<menuitem action='InvSel'/>"
62 "<separator/>"
63 "<menuitem action='Pref'/>"
64 "</menu>"
65 "<menu action='ViewMenu'>"
66 "<menuitem action='Reload'/>"
67 "<separator/>"
68 "<menu action='Toolbar'>"
69 "<menuitem action='ShowToolbar'/>"
70 "<separator/>"
71 "<menuitem action='ToolbarNewWin'/>"
72 "<menuitem action='ToolbarNewTab'/>"
73 "<menuitem action='ToolbarNav'/>"
74 "<menuitem action='ToolbarHome'/>"
75 "</menu>"
76 "<menu action='PathMode'>"
77 "<menuitem action='PathEntry'/>"
78 "<menuitem action='PathBar'/>"
79 "</menu>"
80 "<menu action='SidePane'>"
81 "<menuitem action='ShowSidePane' />"
82 "<separator/>"
83 #if FM_CHECK_VERSION(1, 2, 0)
84 "<placeholder name='SidePaneModes'/>"
85 #else
86 "<menuitem action='Places' />"
87 "<menuitem action='DirTree' />"
88 #endif
89 "</menu>"
90 "<menuitem action='ShowStatus'/>"
91 "<separator/>"
92 "<menuitem action='DualPane'/>"
93 "<menuitem action='Fullscreen' />"
94 "<separator/>"
95 "<menuitem action='SizeBigger'/>"
96 "<menuitem action='SizeSmaller'/>"
97 "<menuitem action='SizeDefault'/>"
98 #if FM_CHECK_VERSION(1, 0, 2)
99 "<separator/>"
100 "<menuitem action='Filter'/>"
101 #endif
102 "<separator/>"
103 "<menu action='FolderView'>"
104 #if FM_CHECK_VERSION(1, 2, 0)
105 "<placeholder name='ViewModes'/>"
106 #else
107 "<menuitem action='IconView'/>"
108 "<menuitem action='ThumbnailView'/>"
109 "<menuitem action='CompactView'/>"
110 "<menuitem action='ListView'/>"
111 #endif
112 "</menu>"
113 "<menu action='Sort'>"
114 "<menuitem action='Asc'/>"
115 "<menuitem action='Desc'/>"
116 "<separator/>"
117 "<menuitem action='ByName'/>"
118 "<menuitem action='ByMTime'/>"
119 "<menuitem action='BySize'/>"
120 "<menuitem action='ByType'/>"
121 #if FM_CHECK_VERSION(1, 2, 0)
122 "<menuitem action='ByExt'/>"
123 #endif
124 #if FM_CHECK_VERSION(1, 0, 2)
125 "<separator/>"
126 #if FM_CHECK_VERSION(1, 2, 0)
127 "<menuitem action='MingleDirs'/>"
128 #endif
129 "<menuitem action='SortIgnoreCase'/>"
130 #endif
131 "</menu>"
132 "<menuitem action='ShowHidden'/>"
133 "<menuitem action='SavePerFolder'/>"
134 "</menu>"
135 "<menu action='BookmarksMenu'>"
136 "<menuitem action='AddBookmark'/>"
137 "</menu>"
138 "<menu action='GoMenu'>"
139 "<menuitem action='Prev'/>"
140 "<menuitem action='Next'/>"
141 "<menuitem action='Up'/>"
142 "<separator/>"
143 "<menuitem action='Home'/>"
144 "<menuitem action='Desktop'/>"
145 "<menuitem action='Trash'/>"
146 "<menuitem action='Apps'/>"
147 "<menuitem action='Computer'/>"
148 "<menuitem action='Network'/>"
149 "<separator/>"
150 "<menuitem action='Location'/>"
151 "<menuitem action='Connect'/>"
152 "</menu>"
153 "<menu action='ToolMenu'>"
154 "<menuitem action='Term'/>"
155 #if FM_CHECK_VERSION(1, 0, 2)
156 "<menuitem action='Search'/>"
157 #endif
158 "<menuitem action='Launch'/>"
159 /* "<menuitem action='AsRoot'/>" */
160 "</menu>"
161 "<menu action='HelpMenu'>"
162 "<menuitem action='About'/>"
163 "<menuitem action='KeyNavList'/>"
164 "</menu>"
165 "</menubar>"
166 "<toolbar>"
167 "<toolitem action='New'/>"
168 "<toolitem action='NewTab'/>"
169 #if FM_CHECK_VERSION(1, 2, 0)
170 "<toolitem action='Prev'/>"
171 #endif
172 "<toolitem action='Next'/>"
173 "<toolitem action='Up'/>"
174 "<toolitem action='Home'/>"
175 "<toolitem action='Go'/>"
176 "</toolbar>"
177 "<accelerator action='Location2'/>"
178 "<accelerator action='Prev2'/>"
179 "<accelerator action='Next2'/>"
180 "<accelerator action='Reload2'/>";
181
182 /* For actions that are bounced to FmFolderView - check accels for accordance */
183 static GtkActionEntry main_win_actions[]=
184 {
185 {"FileMenu", NULL, N_("_File"), NULL, NULL, NULL},
186 {"New", GTK_STOCK_NEW, N_("_New Window"), "<Ctrl>N", NULL, G_CALLBACK(on_new_win)},
187 {"NewTab", "tab-new", N_("New T_ab"), "<Ctrl>T", N_("Create new tab for this folder"), G_CALLBACK(on_new_tab)},
188 {"CreateNew", GTK_STOCK_ADD, N_("C_reate New..."), "", NULL, NULL},
189 {"NewFolder", "folder", N_("Folder"), "<Ctrl><Shift>N", NULL, G_CALLBACK(bounce_action)},
190 {"NewBlank", NULL, N_("Empty File"), "<Ctrl><Alt>N", NULL, G_CALLBACK(bounce_action)},
191 {"Prop", GTK_STOCK_PROPERTIES, N_("Folder Propertie_s"), NULL, NULL, G_CALLBACK(bounce_action)},
192 {"CloseTab", GTK_STOCK_CLOSE, N_("_Close Tab"), "<Ctrl>W", NULL, G_CALLBACK(on_close_tab)},
193 {"Close", GTK_STOCK_QUIT, N_("Close _Window"), "<Ctrl>Q", NULL, G_CALLBACK(on_close_win)},
194 {"EditMenu", NULL, N_("_Edit"), NULL, NULL, NULL},
195 {"Open", GTK_STOCK_OPEN, NULL, "Return", NULL, G_CALLBACK(on_open)},
196 {"Cut", GTK_STOCK_CUT, N_("C_ut"), NULL, NULL, G_CALLBACK(bounce_action)},
197 {"Copy", GTK_STOCK_COPY, NULL, NULL, NULL, G_CALLBACK(bounce_action)},
198 {"Paste", GTK_STOCK_PASTE, NULL, NULL, NULL, G_CALLBACK(bounce_action)},
199 {"ToTrash", GTK_STOCK_DELETE, N_("Move to _Trash"), "", NULL, G_CALLBACK(on_trash)},
200 {"Del", GTK_STOCK_REMOVE, NULL, "", NULL, G_CALLBACK(on_del)},
201 {"CopyPath", NULL, N_("Copy Pat_h(s)"), NULL, NULL, G_CALLBACK(on_copy_path)},
202 {"Rename", NULL, N_("R_ename..."), "F2", NULL, G_CALLBACK(on_rename)},
203 {"Duplicate", NULL, N_("D_uplicate..."), "<Ctrl>U", NULL, NULL},
204 {"Link", NULL, N_("Create Lin_k..."), NULL, NULL, G_CALLBACK(on_link)},
205 {"MoveTo", NULL, N_("_Move to..."), NULL, NULL, G_CALLBACK(on_move_to)},
206 {"CopyTo", NULL, N_("Copy to_..."), NULL, NULL, G_CALLBACK(on_copy_to)},
207 {"FileProp", GTK_STOCK_PROPERTIES, N_("Propertie_s"), "<Alt>Return", NULL, G_CALLBACK(bounce_action)},
208 {"SelAll", GTK_STOCK_SELECT_ALL, NULL, "<Ctrl>A", NULL, G_CALLBACK(bounce_action)},
209 {"InvSel", NULL, N_("_Invert Selection"), "<Ctrl>I", NULL, G_CALLBACK(bounce_action)},
210 {"Pref", GTK_STOCK_PREFERENCES, N_("Prefere_nces"), NULL, NULL, G_CALLBACK(on_preference)},
211 {"ViewMenu", NULL, N_("_View"), NULL, NULL, NULL},
212 {"Reload", GTK_STOCK_REFRESH, N_("_Reload Folder"), "F5", N_("Reload current folder"), G_CALLBACK(on_reload)},
213 {"Toolbar", NULL, N_("Tool_bar"), NULL, NULL, NULL},
214 {"PathMode", NULL, N_("Pat_h Bar"), NULL, NULL, NULL},
215 {"SidePane", "view-sidetree", N_("Side _Pane"), NULL, NULL, NULL},
216 /* other see below: 'ShowHidden' 'ShowStatus' 'Fullscreen' 'IconView'... */
217 {"FolderView", "view-choose", N_("Fo_lder View Mode"), NULL, NULL, NULL},
218 {"Sort", NULL, N_("S_ort Files"), NULL, NULL, NULL},
219 {"SizeBigger", GTK_STOCK_ZOOM_IN, NULL, "<Ctrl>KP_Add", NULL, G_CALLBACK(on_size_increment)},
220 {"SizeSmaller", GTK_STOCK_ZOOM_OUT, N_("Zoom O_ut"), "<Ctrl>KP_Subtract", NULL, G_CALLBACK(on_size_decrement)},
221 {"SizeDefault", GTK_STOCK_ZOOM_100, NULL, "<Ctrl>0", NULL, G_CALLBACK(on_size_default)},
222 #if FM_CHECK_VERSION(1, 0, 2)
223 {"Filter", "view-filter", N_("Fil_ter..."), "<Ctrl>E", NULL, G_CALLBACK(on_filter)},
224 #endif
225 {"HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL},
226 {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(on_about)},
227 {"KeyNavList", GTK_STOCK_INFO, N_("_Keyboard Navigation"), NULL, NULL, G_CALLBACK(on_key_nav_list)},
228 {"GoMenu", NULL, N_("_Go"), NULL, NULL, NULL},
229 {"Prev", GTK_STOCK_GO_BACK, N_("_Previous Folder"), "<Alt>Left", N_("Return to previous folder in history"), G_CALLBACK(on_go_back)},
230 {"Next", GTK_STOCK_GO_FORWARD, N_("_Next Folder"), "<Alt>Right", N_("Go forward to next folder in history"), G_CALLBACK(on_go_forward)},
231 {"Up", GTK_STOCK_GO_UP, N_("Pa_rent Folder"), "<Alt>Up", N_("Go to parent Folder"), G_CALLBACK(on_go_up)},
232 {"Home", "user-home", N_("H_ome Folder"), "<Alt>Home", N_("Go to home folder"), G_CALLBACK(on_go_home)},
233 {"Desktop", "user-desktop", N_("_Desktop"), NULL, N_("Go to desktop folder"), G_CALLBACK(on_go_desktop)},
234 {"Trash", "user-trash", N_("_Trash Can"), NULL, N_("Open trash can"), G_CALLBACK(on_go_trash)},
235 {"Root", "drive-harddisk", N_("Filesyste_m Root"), NULL, N_("Go fo filesystem root"), NULL},
236 {"Apps", "system-software-install", N_("_Applications"), NULL, N_("Go to root of applications menu folder"), G_CALLBACK(on_go_apps)},
237 {"Computer", "computer", N_("Dev_ices"), NULL, N_("Go to list of devices connected to the computer"), G_CALLBACK(on_go_computer)},
238 {"Network", GTK_STOCK_NETWORK, N_("Net_work"), NULL, N_("Go to list of places on the network"), G_CALLBACK(on_go_network)},
239 {"Location", GTK_STOCK_JUMP_TO, N_("_Go to Location..."), "<Ctrl>L", NULL, G_CALLBACK(on_location)},
240 {"Connect", NULL, N_("_Connect to Server..."), NULL, N_("Open a window to choose remote folder location"), G_CALLBACK(on_go_connect)},
241 {"Go", GTK_STOCK_JUMP_TO, NULL, NULL, N_("Go to the path in the location bar"), G_CALLBACK(on_go)},
242 {"BookmarksMenu", NULL, N_("_Bookmarks"), NULL, NULL, NULL},
243 {"AddBookmark", GTK_STOCK_ADD, N_("_Add to Bookmarks..."), "<Ctrl>D", N_("Add current folder to bookmarks list"), G_CALLBACK(on_add_bookmark)},
244 {"ToolMenu", NULL, N_("Too_ls"), NULL, NULL, NULL},
245 {"Term", "utilities-terminal", N_("Open Current Folder in _Terminal"), "F4", NULL, G_CALLBACK(on_open_in_terminal)},
246 #if FM_CHECK_VERSION(1, 0, 2)
247 {"Search", GTK_STOCK_FIND, N_("Fin_d Files..."), "<Ctrl><Shift>F", N_("Open search dialog"), G_CALLBACK(on_search)},
248 #endif
249 {"Launch", GTK_STOCK_EXECUTE, N_("_Run a Command in Current Folder..."), NULL, NULL, G_CALLBACK(on_launch)},
250 /*{"AsRoot", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Open Current Folder as _Root"), NULL, NULL, G_CALLBACK(on_open_as_root)},*/
251 /* for accelerators */
252 {"Location2", NULL, NULL, "<Alt>d", NULL, G_CALLBACK(on_location)},
253 {"Prev2", NULL, NULL, "XF86Back", NULL, G_CALLBACK(on_go_back)},
254 {"Next2", NULL, NULL, "XF86Forward", NULL, G_CALLBACK(on_go_forward)},
255 {"Reload2", NULL, NULL, "<Ctrl>R", NULL, G_CALLBACK(on_reload)},
256 };
257
258 /* main_win_toggle_actions+main_win_mode_actions - see 'ViewMenu' for mnemonics */
259 static GtkToggleActionEntry main_win_toggle_actions[]=
260 {
261 #if FM_CHECK_VERSION(1, 2, 0)
262 /* Note to translators: "Mingle..." means "Do not put folders before files" but make the translation as short as possible, please! */
263 {"MingleDirs", NULL, N_("Mingle _Files and Folders"), NULL, NULL, G_CALLBACK(on_mingle_dirs), FALSE},
264 #endif
265 #if FM_CHECK_VERSION(1, 0, 2)
266 {"SortIgnoreCase", NULL, N_("_Ignore Name Case"), NULL, NULL, G_CALLBACK(on_sort_ignore_case), TRUE},
267 #endif
268 {"ShowHidden", NULL, N_("Sho_w Hidden"), "<Ctrl>H", NULL, G_CALLBACK(on_show_hidden), FALSE},
269 /* Note to translators: this save is meant for folder's settings such as sort */
270 {"SavePerFolder", NULL, N_("Preserve This Folder's Settings"), NULL,
271 N_("Check to remember view and sort as folder setting rather than global one"),
272 G_CALLBACK(on_save_per_folder), FALSE},
273 {"ShowToolbar", NULL, N_("_Show Toolbar"), NULL, NULL, G_CALLBACK(on_show_toolbar), TRUE},
274 {"ToolbarNewWin", NULL, N_("Show 'New _Window' Button"), NULL, NULL, G_CALLBACK(on_toolbar_new_win), TRUE},
275 {"ToolbarNewTab", NULL, N_("Show 'New _Tab' Button"), NULL, NULL, G_CALLBACK(on_toolbar_new_tab), TRUE},
276 {"ToolbarNav", NULL, N_("Show _Navigation Buttons"), NULL, NULL, G_CALLBACK(on_toolbar_nav), TRUE},
277 {"ToolbarHome", NULL, N_("Show '_Home' Button"), NULL, NULL, G_CALLBACK(on_toolbar_home), TRUE},
278 {"ShowSidePane", NULL, N_("Sho_w Side Pane"), "F9", NULL, G_CALLBACK(on_show_side_pane), TRUE},
279 {"ShowStatus", NULL, N_("Show Status B_ar"), "<Ctrl>B", NULL, G_CALLBACK(on_show_status), TRUE},
280 {"DualPane", NULL, N_("_Dual Pane Mode"), "F3", N_("Show two panels with folder views"), G_CALLBACK(on_dual_pane), FALSE},
281 {"Fullscreen", NULL, N_("Fullscreen _Mode"), "F11", NULL, G_CALLBACK(on_fullscreen), FALSE}
282 };
283
284 #if !FM_CHECK_VERSION(1, 2, 0)
285 static GtkRadioActionEntry main_win_mode_actions[]=
286 {
287 {"IconView", NULL, N_("_Icon View"), "<Ctrl>1", NULL, FM_FV_ICON_VIEW},
288 {"CompactView", NULL, N_("_Compact View"), "<Ctrl>2", NULL, FM_FV_COMPACT_VIEW},
289 {"ThumbnailView", NULL, N_("_Thumbnail View"), "<Ctrl>3", NULL, FM_FV_THUMBNAIL_VIEW},
290 {"ListView", NULL, N_("Detailed _List View"), "<Ctrl>4", NULL, FM_FV_LIST_VIEW},
291 };
292 #endif
293
294 static GtkRadioActionEntry main_win_sort_type_actions[]=
295 {
296 {"Asc", GTK_STOCK_SORT_ASCENDING, NULL, NULL, NULL, GTK_SORT_ASCENDING},
297 {"Desc", GTK_STOCK_SORT_DESCENDING, NULL, NULL, NULL, GTK_SORT_DESCENDING},
298 };
299
300 static GtkRadioActionEntry main_win_sort_by_actions[]=
301 {
302 #if FM_CHECK_VERSION(1, 0, 2)
303 {"ByName", NULL, N_("By _Name"), "<Alt><Ctrl>1", NULL, FM_FOLDER_MODEL_COL_NAME},
304 {"ByMTime", NULL, N_("By _Modification Time"), "<Alt><Ctrl>2", NULL, FM_FOLDER_MODEL_COL_MTIME},
305 {"BySize", NULL, N_("By _Size"), "<Alt><Ctrl>3", NULL, FM_FOLDER_MODEL_COL_SIZE},
306 {"ByType", NULL, N_("By File _Type"), "<Alt><Ctrl>4", NULL, FM_FOLDER_MODEL_COL_DESC},
307 #if FM_CHECK_VERSION(1, 2, 0)
308 {"ByExt", NULL, N_("By _Extension"), "<Alt><Ctrl>5", NULL, FM_FOLDER_MODEL_COL_EXT}
309 #endif
310 #else
311 {"ByName", NULL, N_("By _Name"), "<Alt><Ctrl>1", NULL, COL_FILE_NAME},
312 {"ByMTime", NULL, N_("By _Modification Time"), "<Alt><Ctrl>2", NULL, COL_FILE_MTIME},
313 {"BySize", NULL, N_("By _Size"), "<Alt><Ctrl>3", NULL, COL_FILE_SIZE},
314 {"ByType", NULL, N_("By File _Type"), "<Alt><Ctrl>4", NULL, COL_FILE_DESC}
315 #endif
316 };
317
318 #if !FM_CHECK_VERSION(1, 2, 0)
319 static GtkRadioActionEntry main_win_side_bar_mode_actions[]=
320 {
321 {"Places", NULL, N_("Places"), "<Ctrl>6", NULL, FM_SP_PLACES},
322 {"DirTree", NULL, N_("Directory Tree"), "<Ctrl>7", NULL, FM_SP_DIR_TREE},
323 {"Remote", NULL, N_("Remote"), "<Ctrl>8", NULL, FM_SP_REMOTE},
324 };
325 #endif
326
327 static GtkRadioActionEntry main_win_path_bar_mode_actions[]=
328 {
329 {"PathEntry", NULL, N_("_Location"), NULL, NULL, 0},
330 {"PathBar", NULL, N_("_Buttons"), NULL, NULL, 1}
331 };
332