D'n'd onto Go to Current Doc Dir button

master
Yevgen Muntyan 2006-12-05 23:21:20 -06:00
parent 37420fcf54
commit 47a70352a7
3 changed files with 72 additions and 50 deletions

View File

@ -99,6 +99,9 @@ static void moo_file_selector_activate (MooFileView *fileview,
static void moo_file_selector_populate_popup(MooFileView *fileview, static void moo_file_selector_populate_popup(MooFileView *fileview,
GList *selected, GList *selected,
GtkMenu *menu); GtkMenu *menu);
static void goto_current_doc_dir (MooFileSelector *filesel);
static gboolean moo_file_selector_drop (MooFileView *fileview, static gboolean moo_file_selector_drop (MooFileView *fileview,
const char *path, const char *path,
GtkWidget *widget, GtkWidget *widget,
@ -163,6 +166,14 @@ _moo_file_selector_class_init (MooFileSelectorClass *klass)
"window", "window",
MOO_TYPE_EDIT_WINDOW, MOO_TYPE_EDIT_WINDOW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
_moo_signal_new_cb ("goto-current-doc-dir",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (goto_current_doc_dir),
NULL, NULL,
_moo_marshal_VOID__VOID,
G_TYPE_NONE, 0);
} }
@ -555,12 +566,22 @@ moo_file_selector_constructor (GType type,
g_idle_add ((GSourceFunc) file_selector_go_home, g_object_ref (filesel)); g_idle_add ((GSourceFunc) file_selector_go_home, g_object_ref (filesel));
group = moo_action_collection_get_group (moo_file_view_get_actions (MOO_FILE_VIEW (fileview)), NULL); group = moo_action_collection_get_group (moo_file_view_get_actions (MOO_FILE_VIEW (fileview)), NULL);
xml = moo_file_view_get_ui_xml (MOO_FILE_VIEW (fileview));
merge_id = moo_ui_xml_new_merge_id (xml);
moo_action_group_add_action (group, "GoToCurrentDocDir", moo_action_group_add_action (group, "GoToCurrentDocDir",
"stock-id", GTK_STOCK_JUMP_TO, "stock-id", GTK_STOCK_JUMP_TO,
"tooltip", _("Go to current document directory"), "tooltip", _("Go to current document directory"),
"closure-object", filesel, "closure-object", fileview,
"closure-callback", goto_current_doc_dir, "closure-signal", "goto-current-doc-dir",
NULL); NULL);
moo_ui_xml_insert_markup (xml, merge_id,
"MooFileView/Toolbar", -1,
"<item action=\"GoToCurrentDocDir\"/>");
_moo_file_view_setup_button_drag_dest (MOO_FILE_VIEW (filesel),
"MooFileView/Toolbar/GoToCurrentDocDir",
"goto-current-doc-dir");
moo_action_group_add_action (group, "NewFile", moo_action_group_add_action (group, "NewFile",
"label", _("New File..."), "label", _("New File..."),
"tooltip", _("New File..."), "tooltip", _("New File..."),
@ -575,12 +596,6 @@ moo_file_selector_constructor (GType type,
"closure-object", filesel, "closure-object", filesel,
"closure-callback", file_selector_open_files, "closure-callback", file_selector_open_files,
NULL); NULL);
xml = moo_file_view_get_ui_xml (MOO_FILE_VIEW (fileview));
merge_id = moo_ui_xml_new_merge_id (xml);
moo_ui_xml_insert_markup (xml, merge_id,
"MooFileView/Toolbar", -1,
"<item action=\"GoToCurrentDocDir\"/>");
moo_ui_xml_insert_markup_before (xml, merge_id, moo_ui_xml_insert_markup_before (xml, merge_id,
"MooFileView/Menu", "MooFileView/Menu",
"NewFolder", "NewFolder",

View File

@ -63,6 +63,9 @@ struct _MooFileViewClass
void _moo_file_view_select_name (MooFileView *fileview, void _moo_file_view_select_name (MooFileView *fileview,
const char *name); const char *name);
void _moo_file_view_setup_button_drag_dest (MooFileView *fileview,
const char *xml_path,
const char *sig_name);
void _moo_file_view_add_target (MooFileView *fileview, void _moo_file_view_add_target (MooFileView *fileview,
GdkAtom target, GdkAtom target,
guint flags, guint flags,

View File

@ -1066,8 +1066,8 @@ init_actions (MooFileView *fileview)
group = moo_action_collection_get_group (fileview->priv->actions, NULL); group = moo_action_collection_get_group (fileview->priv->actions, NULL);
moo_action_group_add_action (group, "GoUp", moo_action_group_add_action (group, "GoUp",
"label", "Parent Folder", "label", _("Parent Folder"),
"tooltip", "Parent Folder", "tooltip", _("Parent Folder"),
"stock-id", GTK_STOCK_GO_UP, "stock-id", GTK_STOCK_GO_UP,
"accel", "<alt>Up", "accel", "<alt>Up",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1076,8 +1076,8 @@ init_actions (MooFileView *fileview)
NULL); NULL);
action = moo_action_group_add_action (group, "GoBack", action = moo_action_group_add_action (group, "GoBack",
"label", "Go Back", "label", _("Go Back"),
"tooltip", "Go Back", "tooltip", _("Go Back"),
"stock-id", GTK_STOCK_GO_BACK, "stock-id", GTK_STOCK_GO_BACK,
"accel", "<alt>Left", "accel", "<alt>Left",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1087,8 +1087,8 @@ init_actions (MooFileView *fileview)
moo_bind_bool_property (action, "sensitive", fileview, "can-go-back", FALSE); moo_bind_bool_property (action, "sensitive", fileview, "can-go-back", FALSE);
action = moo_action_group_add_action (group, "GoForward", action = moo_action_group_add_action (group, "GoForward",
"label", "Go Forward", "label", _("Go Forward"),
"tooltip", "Go Forward", "tooltip", _("Go Forward"),
"stock-id", GTK_STOCK_GO_FORWARD, "stock-id", GTK_STOCK_GO_FORWARD,
"accel", "<alt>Right", "accel", "<alt>Right",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1098,8 +1098,8 @@ init_actions (MooFileView *fileview)
moo_bind_bool_property (action, "sensitive", fileview, "can-go-forward", FALSE); moo_bind_bool_property (action, "sensitive", fileview, "can-go-forward", FALSE);
moo_action_group_add_action (group, "GoHome", moo_action_group_add_action (group, "GoHome",
"label", "Home Folder", "label", _("Home Folder"),
"tooltip", "Home Folder", "tooltip", _("Home Folder"),
"stock-id", GTK_STOCK_HOME, "stock-id", GTK_STOCK_HOME,
"accel", "<alt>Home", "accel", "<alt>Home",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1108,16 +1108,16 @@ init_actions (MooFileView *fileview)
NULL); NULL);
moo_action_group_add_action (group, "NewFolder", moo_action_group_add_action (group, "NewFolder",
"label", "New Folder...", "label", _("New Folder..."),
"tooltip", "New Folder...", "tooltip", _("New Folder..."),
"stock-id", GTK_STOCK_DIRECTORY, "stock-id", GTK_STOCK_DIRECTORY,
"closure-object", fileview, "closure-object", fileview,
"closure-callback", file_view_create_folder, "closure-callback", file_view_create_folder,
NULL); NULL);
action = moo_action_group_add_action (group, "Delete", action = moo_action_group_add_action (group, "Delete",
"label", "Delete...", "label", _("Delete..."),
"tooltip", "Delete...", "tooltip", _("Delete..."),
"stock-id", GTK_STOCK_DELETE, "stock-id", GTK_STOCK_DELETE,
"accel", "<alt>Delete", "accel", "<alt>Delete",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1128,8 +1128,8 @@ init_actions (MooFileView *fileview)
action = moo_action_group_add_action (group, "ShowHiddenFiles", action = moo_action_group_add_action (group, "ShowHiddenFiles",
"action-type::", MOO_TYPE_TOGGLE_ACTION, "action-type::", MOO_TYPE_TOGGLE_ACTION,
"label", "Show Hidden Files", "label", _("Show Hidden Files"),
"tooltip", "Show Hidden Files", "tooltip", _("Show Hidden Files"),
"accel", "<alt><shift>H", "accel", "<alt><shift>H",
"force-accel-label", TRUE, "force-accel-label", TRUE,
NULL); NULL);
@ -1137,21 +1137,21 @@ init_actions (MooFileView *fileview)
action = moo_action_group_add_action (group, "ShowParentFolder", action = moo_action_group_add_action (group, "ShowParentFolder",
"action-type::", MOO_TYPE_TOGGLE_ACTION, "action-type::", MOO_TYPE_TOGGLE_ACTION,
"label", "Show Parent Folder", "label", _("Show Parent Folder"),
"tooltip", "Show Parent Folder", "tooltip", _("Show Parent Folder"),
NULL); NULL);
_moo_sync_toggle_action (action, fileview, "show-parent-folder", FALSE); _moo_sync_toggle_action (action, fileview, "show-parent-folder", FALSE);
action = moo_action_group_add_action (group, "CaseSensitiveSort", action = moo_action_group_add_action (group, "CaseSensitiveSort",
"action-type::", MOO_TYPE_TOGGLE_ACTION, "action-type::", MOO_TYPE_TOGGLE_ACTION,
"label", "Case Sensitive Sort", "label", _("Case Sensitive Sort"),
"tooltip", "Case Sensitive Sort", "tooltip", _("Case Sensitive Sort"),
NULL); NULL);
_moo_sync_toggle_action (action, fileview, "sort-case-sensitive", FALSE); _moo_sync_toggle_action (action, fileview, "sort-case-sensitive", FALSE);
action = moo_action_group_add_action (group, "Properties", action = moo_action_group_add_action (group, "Properties",
"label", "Properties", "label", _("Properties"),
"tooltip", "Properties", "tooltip", _("Properties"),
"stock-id", GTK_STOCK_PROPERTIES, "stock-id", GTK_STOCK_PROPERTIES,
"accel", "<alt>Return", "accel", "<alt>Return",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1161,8 +1161,8 @@ init_actions (MooFileView *fileview)
moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE); moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE);
moo_action_group_add_action (group, "BookmarksMenu", moo_action_group_add_action (group, "BookmarksMenu",
"label", "Bookmarks", "label", _("Bookmarks"),
"tooltip", "Bookmarks", "tooltip", _("Bookmarks"),
"stock-id", GTK_STOCK_ABOUT, "stock-id", GTK_STOCK_ABOUT,
"closure-object", fileview, "closure-object", fileview,
"closure-callback", view_bookmarks, "closure-callback", view_bookmarks,
@ -1170,24 +1170,24 @@ init_actions (MooFileView *fileview)
NULL); NULL);
moo_action_group_add_action (group, "AddBookmark", moo_action_group_add_action (group, "AddBookmark",
"label", "Add Bookmark", "label", _("Add Bookmark"),
"tooltip", "Add Bookmark", "tooltip", _("Add Bookmark"),
"stock-id", GTK_STOCK_ADD, "stock-id", GTK_STOCK_ADD,
"closure-object", fileview, "closure-object", fileview,
"closure-callback", add_bookmark, "closure-callback", add_bookmark,
NULL); NULL);
moo_action_group_add_action (group, "EditBookmarks", moo_action_group_add_action (group, "EditBookmarks",
"label", "Edit Bookmarks...", "label", _("Edit Bookmarks..."),
"tooltip", "Edit Bookmarks...", "tooltip", _("Edit Bookmarks..."),
"stock-id", GTK_STOCK_EDIT, "stock-id", GTK_STOCK_EDIT,
"closure-object", fileview, "closure-object", fileview,
"closure-callback", edit_bookmarks, "closure-callback", edit_bookmarks,
NULL); NULL);
action = moo_action_group_add_action (group, "Cut", action = moo_action_group_add_action (group, "Cut",
"label", "Cut", "label", _("Cut"),
"tooltip", "Cut", "tooltip", _("Cut"),
"stock-id", GTK_STOCK_CUT, "stock-id", GTK_STOCK_CUT,
"accel", "<control>X", "accel", "<control>X",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1197,8 +1197,8 @@ init_actions (MooFileView *fileview)
moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE); moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE);
action = moo_action_group_add_action (group, "Copy", action = moo_action_group_add_action (group, "Copy",
"label", "Copy", "label", _("Copy"),
"tooltip", "Copy", "tooltip", _("Copy"),
"stock-id", GTK_STOCK_COPY, "stock-id", GTK_STOCK_COPY,
"force-accel-label", TRUE, "force-accel-label", TRUE,
"accel", "<control>C", "accel", "<control>C",
@ -1208,8 +1208,8 @@ init_actions (MooFileView *fileview)
moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE); moo_bind_bool_property (action, "sensitive", fileview, "has-selection", FALSE);
action = moo_action_group_add_action (group, "Paste", action = moo_action_group_add_action (group, "Paste",
"label", "Paste", "label", _("Paste"),
"tooltip", "Paste", "tooltip", _("Paste"),
"stock-id", GTK_STOCK_PASTE, "stock-id", GTK_STOCK_PASTE,
"accel", "<control>V", "accel", "<control>V",
"force-accel-label", TRUE, "force-accel-label", TRUE,
@ -1219,8 +1219,8 @@ init_actions (MooFileView *fileview)
#ifdef __WIN32__ #ifdef __WIN32__
moo_action_group_add_action (group, "Reload", moo_action_group_add_action (group, "Reload",
"label", "Reload", "label", _("Reload"),
"tooltip", "Reload", "tooltip", _("Reload"),
"stock-id", GTK_STOCK_REFRESH, "stock-id", GTK_STOCK_REFRESH,
"closure-object", fileview, "closure-object", fileview,
"closure-signal", "reload", "closure-signal", "reload",
@ -1360,13 +1360,17 @@ _moo_file_view_set_view_type (MooFileView *fileview,
} }
static void void
setup_button_drag_dest (MooFileView *fileview, _moo_file_view_setup_button_drag_dest (MooFileView *fileview,
const char *xml_path, const char *xml_path,
const char *sig_name) const char *sig_name)
{ {
GtkWidget *button; GtkWidget *button;
g_return_if_fail (MOO_IS_FILE_VIEW (fileview));
g_return_if_fail (xml_path != NULL);
g_return_if_fail (sig_name != NULL);
button = moo_ui_xml_get_widget (fileview->priv->ui_xml, button = moo_ui_xml_get_widget (fileview->priv->ui_xml,
fileview->toolbar, xml_path); fileview->toolbar, xml_path);
@ -1404,10 +1408,10 @@ create_toolbar (MooFileView *fileview)
gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_ICONS); gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_ICONS);
gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_MENU); gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_MENU);
setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoUp", "go-up"); _moo_file_view_setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoUp", "go-up");
setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoBack", "go-back"); _moo_file_view_setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoBack", "go-back");
setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoForward", "go-forward"); _moo_file_view_setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoForward", "go-forward");
setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoHome", "go-home"); _moo_file_view_setup_button_drag_dest (fileview, "MooFileView/Toolbar/GoHome", "go-home");
return fileview->toolbar; return fileview->toolbar;
} }