[easytag/wip/application-window: 29/55] Use GAction for go-directory actions
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 29/55] Use GAction for go-directory actions
- Date: Tue, 22 Jul 2014 22:13:14 +0000 (UTC)
commit 0e3b624b9f9886df5ac3155ea8d87ebdce234651
Author: David King <amigadave amigadave com>
Date: Sun Jul 13 00:01:35 2014 +0100
Use GAction for go-directory actions
data/menus.ui | 14 ++++
src/application_window.c | 183 ++++++++++++++++++++++++++++------------------
src/application_window.h | 6 --
src/bar.c | 21 -----
src/bar.h | 7 --
src/browser.c | 2 +-
src/browser.h | 2 +-
src/ui_manager.h | 9 --
8 files changed, 127 insertions(+), 117 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index b63868a..4a5f3d4 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -334,38 +334,52 @@
<attribute name="label" translatable="yes">_Go</attribute>
<section>
<item>
+ <attribute name="accel"><Alt>Home</attribute>
+ <attribute name="action">win.go-home</attribute>
<attribute name="label" translatable="yes">_Home Directory</attribute>
</item>
<item>
+ <attribute name="action">win.go-desktop</attribute>
<attribute name="label" translatable="yes">Desktop Directory</attribute>
</item>
<item>
+ <attribute name="action">win.go-documents</attribute>
<attribute name="label" translatable="yes">Documents Directory</attribute>
</item>
<item>
+ <attribute name="action">win.go-downloads</attribute>
<attribute name="label" translatable="yes">Downloads Directory</attribute>
</item>
<item>
+ <attribute name="action">win.go-music</attribute>
<attribute name="label" translatable="yes">Music Directory</attribute>
</item>
<item>
+ <attribute name="accel"><Alt>Up</attribute>
+ <attribute name="action">win.go-parent</attribute>
<attribute name="label" translatable="yes">_Parent Directory</attribute>
</item>
<item>
+ <attribute name="accel"><Primary>d</attribute>
+ <attribute name="action">win.go-default</attribute>
<attribute name="label" translatable="yes">_Default Directory</attribute>
</item>
</section>
<section>
<item>
+ <attribute name="action">win.go-first</attribute>
<attribute name="label" translatable="yes">First File</attribute>
</item>
<item>
+ <attribute name="action">win.go-previous</attribute>
<attribute name="label" translatable="yes">Previous File</attribute>
</item>
<item>
+ <attribute name="action">win.go-next</attribute>
<attribute name="label" translatable="yes">_Next File</attribute>
</item>
<item>
+ <attribute name="action">win.go-last</attribute>
<attribute name="label" translatable="yes">_Last File</attribute>
</item>
</section>
diff --git a/src/application_window.c b/src/application_window.c
index 9d82e36..ec51ebb 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -1695,6 +1695,114 @@ create_tag_area (EtApplicationWindow *self)
return TagFrame;
}
+static void
+on_go_home (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_home (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_desktop (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_desktop (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_documents (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_documents (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_downloads (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_downloads (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_music (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_music (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_parent (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_go_parent (ET_BROWSER (priv->browser));
+}
+
+static void
+on_go_default (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_load_default_dir (ET_BROWSER (priv->browser));
+}
+
+static const GActionEntry actions[] =
+{
+ { "go-home", on_go_home },
+ { "go-desktop", on_go_desktop },
+ { "go-documents", on_go_documents },
+ { "go-downloads", on_go_downloads },
+ { "go-music", on_go_music },
+ { "go-parent", on_go_parent },
+ { "go-default", on_go_default },
+};
static void
et_application_window_finalize (GObject *object)
@@ -1733,6 +1841,9 @@ et_application_window_init (EtApplicationWindow *self)
priv->scan_dialog = NULL;
priv->search_dialog = NULL;
+ g_action_map_add_action_entries (G_ACTION_MAP (self), actions,
+ G_N_ELEMENTS (actions), self);
+
window = GTK_WINDOW (self);
gtk_window_set_default_size (window, 1024, 768);
@@ -2135,78 +2246,6 @@ et_application_window_browser_clear_artist_model (EtApplicationWindow *self)
}
void
-et_application_window_go_home (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_home (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_go_desktop (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_desktop (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_go_documents (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_documents (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_go_download (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_download (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_go_music (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_music (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_go_parent (G_GNUC_UNUSED GtkAction *action,
- gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
-
- et_browser_go_parent (ET_BROWSER (priv->browser));
-}
-
-void
et_application_window_run_player_for_album_list (G_GNUC_UNUSED GtkAction *action,
gpointer user_data)
{
diff --git a/src/application_window.h b/src/application_window.h
index 56a68b1..c484bc1 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -69,12 +69,6 @@ void et_application_window_browser_set_sensitive (EtApplicationWindow *self, gbo
void et_application_window_browser_clear (EtApplicationWindow *self);
void et_application_window_browser_clear_album_model (EtApplicationWindow *self);
void et_application_window_browser_clear_artist_model (EtApplicationWindow *self);
-void et_application_window_go_home (GtkAction *action, gpointer user_data);
-void et_application_window_go_desktop (GtkAction *action, gpointer user_data);
-void et_application_window_go_documents (GtkAction *action, gpointer user_data);
-void et_application_window_go_download (GtkAction *action, gpointer user_data);
-void et_application_window_go_music (GtkAction *action, gpointer user_data);
-void et_application_window_go_parent (GtkAction *action, gpointer user_data);
void et_application_window_run_player_for_album_list (GtkAction *action, gpointer user_data);
void et_application_window_run_player_for_artist_list (GtkAction *action, gpointer user_data);
void et_application_window_run_player_for_selection (GtkAction *action, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index adac839..dd7d82d 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -260,27 +260,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
G_CALLBACK (Quit_MainWindow) },
{ MENU_BROWSER, NULL, _("_Browser"), NULL,
NULL, NULL },
- { AM_LOAD_HOME_DIR, GTK_STOCK_HOME, _("_Home Directory"), "<Alt>Home",
- _("Go to home directory"),
- G_CALLBACK (et_application_window_go_home) },
- { AM_LOAD_DESKTOP_DIR, "user-desktop", _("Desktop Directory"), NULL,
- _("Go to desktop directory"),
- G_CALLBACK (et_application_window_go_desktop) },
- { AM_LOAD_DOCUMENTS_DIR, "folder-documents", _("Documents Directory"),
- NULL, _("Go to documents directory"),
- G_CALLBACK (et_application_window_go_documents) },
- { AM_LOAD_DOWNLOADS_DIR, "folder-download", _("Downloads Directory"),
- NULL, _("Go to downloads directory"),
- G_CALLBACK (et_application_window_go_download) },
- { AM_LOAD_MUSIC_DIR, "folder-music", _("Music Directory"), NULL,
- _("Go to music directory"),
- G_CALLBACK (et_application_window_go_music) },
- { AM_LOAD_PARENT_DIR, GTK_STOCK_GO_UP, _("_Parent Directory"),
- "<Alt>Up", _("Go to parent directory"),
- G_CALLBACK (et_application_window_go_parent) },
- { AM_LOAD_DEFAULT_DIR, GTK_STOCK_JUMP_TO, _("_Default Directory"),
- "<Primary>D", _("Go to default directory"),
- G_CALLBACK (et_application_window_load_default_dir) },
{ AM_SET_PATH_AS_DEFAULT, GTK_STOCK_DIRECTORY,
_("Set _Current Path as Default"), NULL,
_("Set current path as default"),
diff --git a/src/bar.h b/src/bar.h
index aae4fc9..d99ca61 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -69,13 +69,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
#define AM_UNSELECT_ALL "UnselAll"
#define AM_INVERT_SELECTION "SelInv"
#define AM_DELETE_FILE "DeleteFile"
-#define AM_LOAD_HOME_DIR "GoToHome"
-#define AM_LOAD_DESKTOP_DIR "GoToDesktop"
-#define AM_LOAD_DOCUMENTS_DIR "GoToDocument"
-#define AM_LOAD_DOWNLOADS_DIR "GoToDownload"
-#define AM_LOAD_MUSIC_DIR "GoToMusic"
-#define AM_LOAD_PARENT_DIR "GoToParent"
-#define AM_LOAD_DEFAULT_DIR "GoToDefaultPath"
#define AM_SET_PATH_AS_DEFAULT "SetDefaultPath"
#define AM_RENAME_DIR "RenameDir"
#define AM_BROWSE_SUBDIR "BrowseSubdir"
diff --git a/src/browser.c b/src/browser.c
index 25a6aaa..2045956 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -284,7 +284,7 @@ et_browser_go_documents (EtBrowser *self)
* Load downloads directory
*/
void
-et_browser_go_download (EtBrowser *self)
+et_browser_go_downloads (EtBrowser *self)
{
et_browser_select_dir (self,
g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD));
diff --git a/src/browser.h b/src/browser.h
index 18654eb..83e75b7 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -94,7 +94,7 @@ void et_browser_toggle_display_mode (EtBrowser *self);
void et_browser_go_home (EtBrowser *self);
void et_browser_go_desktop (EtBrowser *self);
void et_browser_go_documents (EtBrowser *self);
-void et_browser_go_download (EtBrowser *self);
+void et_browser_go_downloads (EtBrowser *self);
void et_browser_go_music (EtBrowser *self);
void et_browser_go_parent (EtBrowser *self);
diff --git a/src/ui_manager.h b/src/ui_manager.h
index 5c08665..77c023b 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -161,15 +161,6 @@ static const gchar *ui_xml =
" </menu>"
" <menu action='GoMenu'>"
-" <menuitem action='GoToHome' />"
-" <menuitem action='GoToDesktop' />"
-" <menuitem action='GoToDocument' />"
-" <menuitem action='GoToDownload' />"
-" <menuitem action='GoToMusic' />"
-" <menuitem action='GoToParent' />"
-" <menuitem action='GoToDefaultPath' />"
-" <separator />"
-
" <menuitem action='FirstFile' />"
" <menuitem action='PreviousFile' />"
" <menuitem action='NextFile' />"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]