Commit 2d5c28a2 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

reorganized vfs menu items

parent 867fc3d9
......@@ -37,7 +37,6 @@ static const char *fixed_ui_info =
" <popup name='FileListPopup'>"
" <placeholder name='Folder_Actions2'>"
" <menuitem action='Edit_AddToCatalog'/>"
" <menuitem action='Edit_RemoveFromCatalog'/>"
" </placeholder>"
" </popup>"
"</ui>";
......@@ -45,17 +44,15 @@ static const char *fixed_ui_info =
static const char *vfs_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='File' action='FileMenu'>"
" <placeholder name='Folder_Actions'>"
" <menuitem action='Catalog_New'/>"
" <menuitem action='Catalog_New_Library'/>"
" </placeholder>"
" </menu>"
" </menubar>"
" <popup name='FileListPopup'>"
" <placeholder name='Folder_Actions2'>"
" <menuitem action='Edit_RemoveFromCatalog'/>"
" </placeholder>"
" </popup>"
"</ui>";
static const gchar *folder_popup_ui_info =
"<ui>"
" <popup name='FolderListPopup'>"
......
......@@ -28,8 +28,15 @@
void
gth_browser_activate_action_file_new_folder (GtkAction *action,
GthBrowser *browser)
gth_browser_action_new_folder (GtkAction *action,
GthBrowser *browser)
{
}
void
gth_browser_action_rename_folder (GtkAction *action,
GthBrowser *browser)
{
}
......
......@@ -27,7 +27,8 @@
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
DEFINE_ACTION(gth_browser_activate_action_file_new_folder)
DEFINE_ACTION(gth_browser_action_new_folder)
DEFINE_ACTION(gth_browser_action_rename_folder)
DEFINE_ACTION(gth_browser_activate_action_edit_cut_files)
DEFINE_ACTION(gth_browser_activate_action_edit_copy_files)
DEFINE_ACTION(gth_browser_activate_action_edit_paste_in_folder)
......
......@@ -31,15 +31,6 @@
#define BROWSER_DATA_KEY "file-manager-browser-data"
static const char *fixed_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Edit' action='EditMenu'>"
" </menu>"
" </menubar>"
"</ui>";
static const char *vfs_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
......@@ -58,6 +49,15 @@ static const char *vfs_ui_info =
static const char *browser_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Edit' action='EditMenu'>"
" <placeholder name='File_Actions_1'>"
" <menuitem action='Edit_CutFiles'/>"
" <menuitem action='Edit_CopyFiles'/>"
" <menuitem action='Edit_PasteInFolder'/>"
" </placeholder>"
" </menu>"
" </menubar>"
" <popup name='FileListPopup'>"
" <placeholder name='File_Actions'>"
" <menuitem action='Edit_CutFiles'/>"
......@@ -70,25 +70,8 @@ static const char *browser_ui_info =
static const char *browser_vfs_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='File' action='FileMenu'>"
" <placeholder name='Folder_Actions'>"
" <menuitem action='File_NewFolder'/>"
" </placeholder>"
" </menu>"
" <menu name='Edit' action='EditMenu'>"
" <placeholder name='File_Actions'>"
" <menuitem action='Edit_CutFiles'/>"
" <menuitem action='Edit_CopyFiles'/>"
" <menuitem action='Edit_PasteInFolder'/>"
" </placeholder>"
" </menu>"
" </menubar>"
" <popup name='FileListPopup'>"
" <placeholder name='Folder_Actions'>"
" <menuitem action='Edit_Duplicate'/>"
" <menuitem action='Edit_Rename'/>"
" <separator/>"
" <menuitem action='Edit_Trash'/>"
" <menuitem action='Edit_Delete'/>"
" </placeholder>"
......@@ -96,12 +79,27 @@ static const char *browser_vfs_ui_info =
"</ui>";
static const char *folder_popup_ui_info =
"<ui>"
" <popup name='FolderListPopup'>"
" <placeholder name='SourceCommands'>"
" <menuitem action='File_NewFolder'/>"
" <menuitem action='File_RenameFolder'/>"
" </placeholder>"
" </popup>"
"</ui>";
static GtkActionEntry action_entries[] = {
{ "File_NewFolder", "folder-new",
N_("Create _Folder"), "<control><shift>N",
N_("Create a new empty folder inside this folder"),
G_CALLBACK (gth_browser_activate_action_file_new_folder) },
{ "Edit_CutFiles", GTK_STOCK_CUT,
G_CALLBACK (gth_browser_action_new_folder) },
{ "File_RenameFolder", NULL,
N_("_Rename"), NULL,
N_("Rename this folder"),
G_CALLBACK (gth_browser_action_rename_folder) },
{ "Edit_CutFiles", GTK_STOCK_CUT,
NULL, NULL,
NULL,
G_CALLBACK (gth_browser_activate_action_edit_cut_files) },
......@@ -134,10 +132,10 @@ static GtkActionEntry action_entries[] = {
typedef struct {
GtkActionGroup *action_group;
guint fixed_merge_id;
guint vfs_merge_id;
guint browser_merge_id;
guint browser_vfs_merge_id;
guint folder_popup_merge_id;
} BrowserData;
......@@ -152,7 +150,6 @@ void
fm__gth_browser_construct_cb (GthBrowser *browser)
{
BrowserData *data;
GError *error = NULL;
g_return_if_fail (GTH_IS_BROWSER (browser));
......@@ -166,12 +163,6 @@ fm__gth_browser_construct_cb (GthBrowser *browser)
browser);
gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0);
data->fixed_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error);
if (data->fixed_merge_id == 0) {
g_warning ("ui building failed: %s", error->message);
g_clear_error (&error);
}
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
}
......@@ -255,3 +246,69 @@ fm__gth_browser_load_location_after_cb (GthBrowser *browser,
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
file_manager_update_ui (data, browser);
}
void
fm__gth_browser_folder_tree_popup_before_cb (GthBrowser *browser,
GthFileSource *file_source,
GFile *folder)
{
BrowserData *data;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
if (GTH_IS_FILE_SOURCE_VFS (file_source)) {
GtkAction *action;
gboolean sensitive;
if (data->folder_popup_merge_id == 0) {
GError *error = NULL;
data->folder_popup_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), folder_popup_ui_info, -1, &error);
if (data->folder_popup_merge_id == 0) {
g_message ("building menus failed: %s", error->message);
g_error_free (error);
}
}
action = gtk_action_group_get_action (data->action_group, "File_RenameFolder");
sensitive = folder != NULL;
g_object_set (action, "sensitive", sensitive, NULL);
}
else {
if (data->folder_popup_merge_id != 0) {
gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->folder_popup_merge_id);
data->folder_popup_merge_id = 0;
}
}
}
void
fm__gth_browser_update_sensitivity_cb (GthBrowser *browser)
{
BrowserData *data;
GtkAction *action;
int n_selected;
gboolean sensitive;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
sensitive = n_selected > 0;
action = gtk_action_group_get_action (data->action_group, "Edit_CutFiles");
g_object_set (action, "sensitive", sensitive, NULL);
action = gtk_action_group_get_action (data->action_group, "Edit_CopyFiles");
g_object_set (action, "sensitive", sensitive, NULL);
action = gtk_action_group_get_action (data->action_group, "Edit_Trash");
g_object_set (action, "sensitive", sensitive, NULL);
action = gtk_action_group_get_action (data->action_group, "Edit_Delete");
g_object_set (action, "sensitive", sensitive, NULL);
action = gtk_action_group_get_action (data->action_group, "Edit_Duplicate");
g_object_set (action, "sensitive", sensitive, NULL);
action = gtk_action_group_get_action (data->action_group, "Edit_Rename");
g_object_set (action, "sensitive", sensitive, NULL);
}
......@@ -25,11 +25,15 @@
#include <gthumb.h>
void fm__gth_browser_construct_cb (GthBrowser *browser);
void fm__gth_browser_update_sensitivity_cb (GthBrowser *browser);
void fm__gth_browser_set_current_page_cb (GthBrowser *browser);
void fm__gth_browser_load_location_after_cb (GthBrowser *browser,
GFile *location,
GError *error);
void fm__gth_browser_construct_cb (GthBrowser *browser);
void fm__gth_browser_update_sensitivity_cb (GthBrowser *browser);
void fm__gth_browser_set_current_page_cb (GthBrowser *browser);
void fm__gth_browser_load_location_after_cb (GthBrowser *browser,
GFile *location,
GError *error);
void fm__gth_browser_folder_tree_popup_before_cb (GthBrowser *browser,
GthFileSource *file_source,
GFile *folder);
void fm__gth_browser_update_sensitivity_cb (GthBrowser *browser);
#endif /* CALLBACKS_H */
......@@ -33,6 +33,8 @@ gthumb_extension_activate (void)
gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (fm__gth_browser_construct_cb), NULL);
gth_hook_add_callback ("gth-browser-load-location-after", 10, G_CALLBACK (fm__gth_browser_load_location_after_cb), NULL);
gth_hook_add_callback ("gth-browser-set-current-page", 10, G_CALLBACK (fm__gth_browser_set_current_page_cb), NULL);
gth_hook_add_callback ("gth-browser-folder-tree-popup-before", 10, G_CALLBACK (fm__gth_browser_folder_tree_popup_before_cb), NULL);
gth_hook_add_callback ("gth-browser-update-sensitivity", 10, G_CALLBACK (fm__gth_browser_update_sensitivity_cb), NULL);
}
......
......@@ -31,6 +31,7 @@
#include "glib-utils.h"
#include "gth-browser.h"
#include "gth-file-selection.h"
#include "gth-folder-tree.h"
#include "gth-main.h"
#include "gth-preferences.h"
#include "gth-viewer-page.h"
......@@ -270,6 +271,17 @@ void
gth_browser_activate_action_folder_open (GtkAction *action,
GthBrowser *browser)
{
GtkWidget *folder_tree;
GFile *file;
folder_tree = gth_browser_get_folder_tree (browser);
file = gth_folder_tree_get_selected (GTH_FOLDER_TREE (folder_tree));
if (file == NULL)
return;
gth_browser_load_location (browser, file);
g_object_unref (file);
}
......@@ -277,6 +289,20 @@ void
gth_browser_activate_action_folder_open_in_new_window (GtkAction *action,
GthBrowser *browser)
{
GtkWidget *folder_tree;
GFile *file;
GtkWidget *new_browser;
folder_tree = gth_browser_get_folder_tree (browser);
file = gth_folder_tree_get_selected (GTH_FOLDER_TREE (folder_tree));
if (file == NULL)
return;
new_browser = gth_browser_new (NULL);
gtk_window_present (GTK_WINDOW (new_browser));
gth_browser_load_location (GTH_BROWSER (new_browser), file);
g_object_unref (file);
}
......
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