[easytag/wip/application-window: 52/64] Use GAction for some view menu items
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 52/64] Use GAction for some view menu items
- Date: Thu, 17 Jul 2014 07:41:35 +0000 (UTC)
commit a1b2a972fcfe5b1c96cf59c0cdbfa3e6b74f02f2
Author: David King <amigadave amigadave com>
Date: Sun Jul 13 18:25:14 2014 +0100
Use GAction for some view menu items
The sorting items remain.
data/menus.ui | 20 +++-
data/toolbar.ui | 34 +++++-
src/application_window.c | 317 +++++++++++++++++++++++++++++-----------------
src/application_window.h | 4 -
src/bar.c | 113 ----------------
src/bar.h | 20 ---
src/browser.c | 95 +++++++-------
src/browser.h | 8 +-
src/easytag.c | 18 +--
src/easytag.h | 1 -
src/scan_dialog.c | 22 ---
src/ui_manager.h | 31 -----
12 files changed, 311 insertions(+), 372 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index a83ba61..7911299 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -114,27 +114,38 @@
<attribute name="label" translatable="yes">_View</attribute>
<section>
<item>
+ <attribute name="action">win.scanner</attribute>
<attribute name="label" translatable="yes">Show Scanner</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Scanner Mode</attribute>
<item>
+ <attribute name="action">win.scan-mode</attribute>
<attribute name="label" translatable="yes">Fill Tags</attribute>
+ <attribute name="target">fill-tag</attribute>
</item>
<item>
+ <attribute name="action">win.scan-mode</attribute>
<attribute name="label" translatable="yes">Rename Files and Directories</attribute>
+ <attribute name="target">rename-file</attribute>
</item>
<item>
+ <attribute name="action">win.scan-mode</attribute>
<attribute name="label" translatable="yes">Process Fields</attribute>
+ <attribute name="target">process-fields</attribute>
</item>
</submenu>
</section>
<section>
<item>
+ <attribute name="action">win.file-artist-view</attribute>
<attribute name="label" translatable="yes">Tree Browser</attribute>
+ <attribute name="target">file</attribute>
</item>
<item>
+ <attribute name="action">win.file-artist-view</attribute>
<attribute name="label" translatable="yes">Artists and Albums</attribute>
+ <attribute name="target">artist</attribute>
</item>
</section>
<submenu>
@@ -305,20 +316,27 @@
</submenu>
<section>
<item>
+ <attribute name="accel"><Primary><Shift>c</attribute>
+ <attribute name="action">win.collapse-tree</attribute>
<attribute name="label" translatable="yes">Collapse Tree</attribute>
</item>
<item>
+ <attribute name="accel"><Primary><Shift>r</attribute>
+ <attribute name="action">win.reload-tree</attribute>
<attribute name="label" translatable="yes">Reload Tree</attribute>
</item>
</section>
<section>
<item>
+ <attribute name="accel"><Primary>r</attribute>
+ <attribute name="action">win.reload-directory</attribute>
<attribute name="label" translatable="yes">Reload Directory</attribute>
</item>
</section>
<section>
<item>
- <attribute name="label" translatable="yes">Show Hidden Directoires</attribute>
+ <attribute name="action">win.browse-show-hidden</attribute>
+ <attribute name="label" translatable="yes">Show Hidden Directories</attribute>
</item>
</section>
</submenu>
diff --git a/data/toolbar.ui b/data/toolbar.ui
index b991749..1a310a7 100644
--- a/data/toolbar.ui
+++ b/data/toolbar.ui
@@ -41,6 +41,15 @@
<object class="GtkSeparatorToolItem" id="separator1"/>
</child>
<child>
+ <object class="GtkToggleToolButton" id="scanner_button">
+ <property name="action-name">win.scanner</property>
+ <property name="icon-name">document-properties</property>
+ <property name="label" translatable="yes">_Show Scanner</property>
+ <property name="tooltip-text" translatable="yes">Show scanner</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkToolButton" id="remove_tags_button">
<property name="action-name">win.remove-tags</property>
<property name="icon-name">edit-clear</property>
@@ -80,6 +89,29 @@
<object class="GtkSeparatorToolItem" id="separator2"/>
</child>
<child>
+ <object class="GtkToggleToolButton" id="file_view_button">
+ <property name="action-name">win.file-artist-view</property>
+ <property name="action-target">'file'</property>
+ <property name="icon-name">audio-x-generic</property>
+ <property name="label" translatable="yes">Tree Browser</property>
+ <property name="tooltip-text" translatable="yes">View by directory tree</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleToolButton" id="artist_view_button">
+ <property name="action-name">win.file-artist-view</property>
+ <property name="action-target">'artist'</property>
+ <property name="label" translatable="yes">Artist and Album</property>
+ <property name="stock-id">easytag-artist-album</property>
+ <property name="tooltip-text" translatable="yes">View by artist and album</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorToolItem" id="separator3"/>
+ </child>
+ <child>
<object class="GtkToolButton" id="invert_selection_button">
<property name="action-name">win.invert-selection</property>
<property name="label" translatable="yes">Invert File Selection</property>
@@ -89,7 +121,7 @@
</object>
</child>
<child>
- <object class="GtkSeparatorToolItem" id="separator3"/>
+ <object class="GtkSeparatorToolItem" id="separator4"/>
</child>
<child>
<object class="GtkToolButton" id="find_button">
diff --git a/src/application_window.c b/src/application_window.c
index d098fcd..501e957 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -1959,7 +1959,7 @@ on_delete (GSimpleAction *action,
et_browser_load_file_list (ET_BROWSER (priv->browser),
ETCore->ETFileDisplayedList, NULL);
/* Rebuild the list... */
- et_browser_toggle_display_mode (ET_BROWSER (priv->browser));
+ /*et_browser_toggle_display_mode (ET_BROWSER (priv->browser));*/
/* To update state of command buttons */
et_application_window_update_actions (self);
@@ -2311,6 +2311,144 @@ on_preferences (GSimpleAction *action,
}
static void
+on_action_toggle (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GVariant *state;
+
+ /* Toggle the current state. */
+ state = g_action_get_state (G_ACTION (action));
+ g_action_change_state (G_ACTION (action),
+ g_variant_new_boolean (!g_variant_get_boolean (state)));
+}
+
+static void
+on_action_radio (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ /* Set the action state to the just-activated state. */
+ g_action_change_state (G_ACTION (action), variant);
+}
+
+static void
+on_scanner_change (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindow *self;
+ EtApplicationWindowPrivate *priv;
+ gboolean active;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+ active = g_variant_get_boolean (variant);
+
+ if (!active)
+ {
+ if (priv->scan_dialog)
+ {
+ gtk_widget_hide (priv->scan_dialog);
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ if (priv->scan_dialog)
+ {
+ gtk_widget_show (priv->scan_dialog);
+ }
+ else
+ {
+ priv->scan_dialog = GTK_WIDGET (et_scan_dialog_new ());
+ }
+ }
+
+ g_simple_action_set_state (action, variant);
+}
+
+static void
+on_file_artist_view_change (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindow *self;
+ EtApplicationWindowPrivate *priv;
+ const gchar *state;
+
+ self = ET_APPLICATION_WINDOW (user_data);
+ priv = et_application_window_get_instance_private (self);
+ state = g_variant_get_string (variant, NULL);
+
+ g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
+
+ /* Save the current displayed data. */
+ ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
+
+ if (strcmp (state, "file") == 0)
+ {
+ et_browser_set_display_mode (ET_BROWSER (priv->browser),
+ ET_BROWSER_MODE_FILE);
+ }
+ else if (strcmp (state, "artist") == 0)
+ {
+ et_browser_set_display_mode (ET_BROWSER (priv->browser),
+ ET_BROWSER_MODE_ARTIST);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ g_simple_action_set_state (action, variant);
+
+ et_application_window_update_actions (ET_APPLICATION_WINDOW (user_data));
+}
+
+static void
+on_collapse_tree (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_collapse (ET_BROWSER (priv->browser));
+}
+
+static void
+on_reload_tree (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_reload (ET_BROWSER (priv->browser));
+}
+
+static void
+on_reload_directory (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_reload_directory (ET_BROWSER (priv->browser));
+}
+
+static void
on_set_default_path (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
@@ -2680,6 +2818,18 @@ static const GActionEntry actions[] =
{ "redo-last-changes", on_redo_last_changes },
{ "remove-tags", on_remove_tags },
{ "preferences", on_preferences },
+ /* View menu. */
+ { "scanner", on_action_toggle, NULL, "false", on_scanner_change },
+ /* { "scan-mode", on_action_radio, NULL, "false", on_scan_mode_change },
+ * Created from GSetting. */
+ /* FIXME: Sorting submenus. */
+ { "file-artist-view", on_action_radio, "s", "'file'",
+ on_file_artist_view_change },
+ { "collapse-tree", on_collapse_tree },
+ { "reload-tree", on_reload_tree },
+ { "reload-directory", on_reload_directory },
+ /* { "browse-show-hidden", on_action_toggle, NULL, "true",
+ on_browse_show_hidden_change }, Created from GSetting. */
/* Browser menu. */
{ "set-default-path", on_set_default_path },
{ "rename-directory", on_rename_directory },
@@ -2744,8 +2894,12 @@ et_application_window_init (EtApplicationWindow *self)
g_action_map_add_action_entries (G_ACTION_MAP (self), actions,
G_N_ELEMENTS (actions), self);
+ action = g_settings_create_action (MainSettings, "browse-show-hidden");
+ g_action_map_add_action (G_ACTION_MAP (self), action);
action = g_settings_create_action (MainSettings, "browse-subdir");
g_action_map_add_action (G_ACTION_MAP (self), action);
+ action = g_settings_create_action (MainSettings, "scan-mode");
+ g_action_map_add_action (G_ACTION_MAP (self), action);
window = GTK_WINDOW (self);
@@ -2977,37 +3131,30 @@ et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action
}
void
-et_application_window_browser_collapse (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_collapse (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_browser_reload (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_reload (ET_BROWSER (priv->browser));
-}
-
-void
et_application_window_browser_toggle_display_mode (EtApplicationWindow *self)
{
EtApplicationWindowPrivate *priv;
+ GVariant *variant;
priv = et_application_window_get_instance_private (self);
- et_browser_toggle_display_mode (ET_BROWSER (priv->browser));
+ variant = g_action_group_get_action_state (G_ACTION_GROUP (self),
+ "file-artist-view");
+
+ if (strcmp (g_variant_get_string (variant, NULL), "file") == 0)
+ {
+ et_browser_set_display_mode (ET_BROWSER (priv->browser),
+ ET_BROWSER_MODE_FILE);
+ }
+ else if (strcmp (g_variant_get_string (variant, NULL), "artist") == 0)
+ {
+ et_browser_set_display_mode (ET_BROWSER (priv->browser),
+ ET_BROWSER_MODE_ARTIST);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
}
void
@@ -3092,18 +3239,6 @@ et_application_window_run_player_for_artist_list (G_GNUC_UNUSED GtkAction *actio
}
void
-et_application_window_reload_directory (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_reload_directory (ET_BROWSER (priv->browser));
-}
-
-void
et_application_window_select_dir (EtApplicationWindow *self, const gchar *path)
{
EtApplicationWindowPrivate *priv;
@@ -3137,40 +3272,6 @@ et_application_window_get_scan_dialog (EtApplicationWindow *self)
return priv->scan_dialog;
}
-void
-et_application_window_show_scan_dialog (GtkAction *action, gpointer user_data)
-{
- EtApplicationWindowPrivate *priv;
- gboolean active;
- EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
- priv = et_application_window_get_instance_private (self);
- active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-
- if (!active)
- {
- if (priv->scan_dialog)
- {
- gtk_widget_hide (priv->scan_dialog);
- }
- else
- {
- return;
- }
- }
- else
- {
- if (priv->scan_dialog)
- {
- gtk_widget_show (priv->scan_dialog);
- }
- else
- {
- priv->scan_dialog = GTK_WIDGET (et_scan_dialog_new ());
- }
- }
-}
-
/*
* Action when Scan button is pressed
*/
@@ -3210,14 +3311,6 @@ et_on_action_select_browser_mode (G_GNUC_UNUSED GtkRadioAction *action,
G_GNUC_UNUSED GtkRadioAction *current,
gpointer user_data)
{
- g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
-
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- et_application_window_browser_toggle_display_mode (ET_APPLICATION_WINDOW (user_data));
-
- et_application_window_update_actions (ET_APPLICATION_WINDOW (user_data));
}
/*
@@ -3335,14 +3428,8 @@ et_application_window_disable_command_actions (EtApplicationWindow *self)
set_action_state (self, "undo-last-changes", FALSE);
set_action_state (self, "redo-last-changes", FALSE);
- /* "Scanner" menu commands */
- ui_widget_set_sensitive (MENU_SCANNER_PATH, AM_SCANNER_FILL_TAG,
- FALSE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_RENAME_FILE, FALSE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_PROCESS_FIELDS, FALSE);
-
+ /* FIXME: "Scanner" menu commands */
+ /*set_action_state (self, "scan-mode", FALSE);*/
}
@@ -3424,18 +3511,12 @@ et_application_window_update_actions (EtApplicationWindow *self)
set_action_state (self, "show-load-filenames", FALSE);
set_action_state (self, "show-playlist", FALSE);
set_action_state (self, "run-player", FALSE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_FILL_TAG, FALSE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_RENAME_FILE, FALSE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_PROCESS_FIELDS, FALSE);
- ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, FALSE);
+ /* FIXME set_action_state (self, "scan-mode", FALSE);*/
+ set_action_state (self, "file-artist-view", FALSE);
return;
}else
{
- GtkWidget *artist_radio = NULL;
GList *selfilelist = NULL;
ET_File *etfile;
gboolean has_undo = FALSE;
@@ -3495,13 +3576,8 @@ et_application_window_update_actions (EtApplicationWindow *self)
set_action_state (self, "show-load-filenames", TRUE);
set_action_state (self, "show-playlist", TRUE);
set_action_state (self, "run-player", TRUE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_FILL_TAG,TRUE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_RENAME_FILE, TRUE);
- ui_widget_set_sensitive (MENU_SCANNER_PATH,
- AM_SCANNER_PROCESS_FIELDS, TRUE);
- ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, TRUE);
+ /* FIXME set_action_state (self, "scan-mode", TRUE); */
+ set_action_state (self, "file-artist-view", TRUE);
/* Check if one of the selected files has undo or redo data */
{
@@ -3573,18 +3649,31 @@ et_application_window_update_actions (EtApplicationWindow *self)
set_action_state (self, "redo-last-changes", FALSE);
}
- artist_radio = gtk_ui_manager_get_widget (UIManager,
- "/ToolBar/ArtistViewMode");
-
- if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
{
- ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, FALSE);
- ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, FALSE);
- }
- else
- {
- ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, TRUE);
- ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, TRUE);
+ GVariant *variant;
+ const gchar *state;
+
+ variant = g_action_group_get_action_state (G_ACTION_GROUP (self),
+ "file-artist-view");
+
+ state = g_variant_get_string (variant, NULL);
+
+ if (strcmp (state, "artist") == 0)
+ {
+ set_action_state (self, "collapse-tree", FALSE);
+ set_action_state (self, "reload-tree", FALSE);
+ }
+ else if (strcmp (state, "file") == 0)
+ {
+ set_action_state (self, "collapse-tree", TRUE);
+ set_action_state (self, "reload-tree", TRUE);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ g_variant_unref (variant);
}
}
diff --git a/src/application_window.h b/src/application_window.h
index 6cf7a6d..8cf1929 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -59,8 +59,6 @@ GtkWidget * et_application_window_get_preferences_dialog (EtApplicationWindow *s
void et_application_window_show_preferences_dialog_scanner (GtkAction *action, gpointer user_data);
GtkWidget * et_application_window_get_cddb_dialog (EtApplicationWindow *self);
void et_application_window_search_cddb_for_selection (GtkAction *action, gpointer user_data);
-void et_application_window_browser_collapse (GtkAction *action, gpointer user_data);
-void et_application_window_browser_reload (GtkAction *action, gpointer user_data);
void et_application_window_browser_toggle_display_mode (EtApplicationWindow *self);
void et_application_window_browser_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
void et_application_window_browser_clear (EtApplicationWindow *self);
@@ -68,11 +66,9 @@ void et_application_window_browser_clear_album_model (EtApplicationWindow *self)
void et_application_window_browser_clear_artist_model (EtApplicationWindow *self);
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_reload_directory (GtkAction *action, gpointer user_data);
void et_application_window_select_dir (EtApplicationWindow *self, const gchar *path);
const gchar * et_application_window_get_current_path (EtApplicationWindow *self);
GtkWidget * et_application_window_get_scan_dialog (EtApplicationWindow *self);
-void et_application_window_show_scan_dialog (GtkAction *action, gpointer user_data);
void et_application_window_scan_selected_files (GtkAction *action, gpointer user_data);
void et_on_action_select_scan_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
void et_on_action_select_browser_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index 64e2365..04d6b66 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -50,7 +50,6 @@ static GList *ActionPairsList = NULL;
* Prototypes *
**************/
-static void Init_Menu_Bar (void);
static void Statusbar_Remove_Timer (void);
static void et_statusbar_push_tooltip (const gchar *message);
@@ -76,16 +75,6 @@ static void on_menu_item_deselect (GtkMenuItem *item, gpointer user_data);
#define QCASE(string,callback) if (quark == g_quark_from_string((string))) { (callback)(); }
#define QCASE_DATA(string,callback,data) if (quark == g_quark_from_string((string))) { (callback)((data)); }
-static void
-reload_browser (gpointer data)
-{
- EtApplicationWindow *window;
-
- window = ET_APPLICATION_WINDOW (data);
-
- et_application_window_browser_reload (NULL, window);
-}
-
/*
* Menu bar
*/
@@ -135,7 +124,6 @@ Menu_Sort_Action (GtkAction *item, gpointer data)
QCASE_DATA(AM_SORT_DESCENDING_FILE_BITRATE, ET_Sort_Displayed_File_List_And_Update_UI,
ET_SORT_MODE_DESCENDING_FILE_BITRATE);
QCASE_DATA(AM_SORT_ASCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI,
ET_SORT_MODE_ASCENDING_FILE_SAMPLERATE);
QCASE_DATA(AM_SORT_DESCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI,
ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE);
- QCASE_DATA(AM_INITIALIZE_TREE, reload_browser, data);
et_application_window_browser_refresh_sort (ET_APPLICATION_WINDOW (data));
}
@@ -213,21 +201,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
_("Scan selected files"),
G_CALLBACK (et_application_window_scan_selected_files) },
- { AM_RELOAD_DIRECTORY, GTK_STOCK_REFRESH, _("Reload Directory"),
- "<Primary>R", _("Reload directory"),
- G_CALLBACK (et_application_window_reload_directory) },
- { AM_COLLAPSE_TREE, NULL, _("_Collapse Tree"), "<Primary><Shift>C",
- _("Collapse directory tree"),
- G_CALLBACK (et_application_window_browser_collapse) },
- { AM_INITIALIZE_TREE, GTK_STOCK_REFRESH, _("_Reload Tree"),
- "<Primary><Shift>R", _("Reload directory tree"),
- G_CALLBACK (et_application_window_browser_reload) },
-
- { MENU_SCANNER, NULL, _("S_canner Mode"), NULL, NULL, NULL },
-
- { MENU_VIEW, NULL, _("_View"), NULL, NULL, NULL },
-
-
/*
* Following items are on toolbar but not on menu
*/
@@ -257,55 +230,12 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
};
- GtkToggleActionEntry ToggleActionEntries[] =
- {
-#ifndef G_OS_WIN32 /* No sense here for Win32, "hidden" means : starts with a
- * '.'
- */
- { AM_BROWSER_HIDDEN_DIR, NULL, _("Show Hidden Directories"), NULL,
- _("Show hidden directories"),
- G_CALLBACK (et_application_window_browser_reload),
- g_settings_get_boolean (MainSettings, "browse-show-hidden") },
-#endif /* !G_OS_WIN32 */
- { AM_SCANNER_SHOW, "document-properties", _("_Show Scanner"), NULL,
- _("Show scanner"),
- G_CALLBACK (et_application_window_show_scan_dialog),
- g_settings_get_boolean (MainSettings, "scan-startup") },
- };
-
- GtkRadioActionEntry view_mode_entries[] =
- {
- { AM_TREE_VIEW_MODE, "audio-x-generic", _("Tree Browser"), NULL,
- _("View by directory tree"), 0 },
- { AM_ARTIST_VIEW_MODE, "easytag-artist-album",
- _("Artist and Album"), NULL,
- _("View by artist and album"), 1 }
- };
-
- GtkRadioActionEntry scanner_mode_entries[] =
- {
- { AM_SCANNER_FILL_TAG, "document-properties", _("_Fill Tags…"), NULL,
- _("Fill tags"), ET_SCAN_MODE_FILL_TAG },
- { AM_SCANNER_RENAME_FILE, "document-properties",
- _("_Rename Files and Directories…"), NULL,
- _("Rename files and directories"), ET_SCAN_MODE_RENAME_FILE },
- { AM_SCANNER_PROCESS_FIELDS, "document-properties",
- _("_Process Fields…"), NULL, _("Process Fields"),
- ET_SCAN_MODE_PROCESS_FIELDS }
- };
-
GError *error = NULL;
guint num_menu_entries;
- guint num_toggle_entries;
- guint n_view_mode_entries;
- guint n_scanner_mode_entries;
guint i;
/* Calculate number of items into the menu */
num_menu_entries = G_N_ELEMENTS(ActionEntries);
- num_toggle_entries = G_N_ELEMENTS(ToggleActionEntries);
- n_view_mode_entries = G_N_ELEMENTS (view_mode_entries);
- n_scanner_mode_entries = G_N_ELEMENTS (scanner_mode_entries);
/* Populate quarks list with the entries */
for(i = 0; i < num_menu_entries; i++)
@@ -316,29 +246,12 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
ActionPairsList = g_list_prepend (ActionPairsList, ActionPair);
}
- for(i = 0; i < num_toggle_entries; i++)
- {
- Action_Pair* ActionPair = g_malloc0(sizeof(Action_Pair));
- ActionPair->action = ToggleActionEntries[i].name;
- ActionPair->quark = g_quark_from_string(ActionPair->action);
- ActionPairsList = g_list_prepend (ActionPairsList, ActionPair);
- }
-
ActionPairsList = g_list_reverse (ActionPairsList);
/* UI Management */
ActionGroup = gtk_action_group_new("actions");
gtk_action_group_set_translation_domain (ActionGroup, GETTEXT_PACKAGE);
gtk_action_group_add_actions(ActionGroup, ActionEntries, num_menu_entries, window);
- gtk_action_group_add_toggle_actions(ActionGroup, ToggleActionEntries, num_toggle_entries, window);
- gtk_action_group_add_radio_actions (ActionGroup, view_mode_entries,
- n_view_mode_entries, 0,
- G_CALLBACK (et_on_action_select_browser_mode),
- window);
- gtk_action_group_add_radio_actions (ActionGroup, scanner_mode_entries,
- n_scanner_mode_entries, 0,
- G_CALLBACK (et_on_action_select_scan_mode),
- window);
UIManager = gtk_ui_manager_new();
@@ -357,7 +270,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
gtk_ui_manager_get_accel_group (UIManager));
menubar = gtk_ui_manager_get_widget(UIManager, "/MenuBar");
- Init_Menu_Bar();
gtk_widget_show_all(menubar);
toolbar = gtk_ui_manager_get_widget (UIManager, "/ToolBar");
@@ -371,31 +283,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
/*
- * Initialize some items of the main menu
- */
-static void
-Init_Menu_Bar (void)
-{
-
- CheckMenuItemBrowseSubdirMainMenu = gtk_ui_manager_get_widget(UIManager,
"/MenuBar/BrowserMenu/BrowseSubdir");
- if (CheckMenuItemBrowseSubdirMainMenu)
- {
- g_settings_bind (MainSettings, "browse-subdir",
- CheckMenuItemBrowseSubdirMainMenu, "active",
- G_SETTINGS_BIND_GET);
- }
-
- CheckMenuItemBrowseHiddenDirMainMenu = gtk_ui_manager_get_widget (UIManager,
- "/MenuBar/ViewMenu/BrowseHiddenDir");
- if (CheckMenuItemBrowseHiddenDirMainMenu)
- {
- g_settings_bind (MainSettings, "browse-show-hidden",
- CheckMenuItemBrowseHiddenDirMainMenu, "active",
- G_SETTINGS_BIND_GET);
- }
-}
-
-/*
* Status bar functions
*/
GtkWidget *Create_Status_Bar (void)
diff --git a/src/bar.h b/src/bar.h
index b89f60f..d1218fc 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -30,18 +30,11 @@ GtkWidget *ProgressBar;
GtkUIManager *UIManager;
GtkActionGroup *ActionGroup;
-GtkWidget *CheckMenuItemBrowseSubdirMainMenu;
-GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
-
-#define MENU_VIEW "ViewMenu"
-#define MENU_SCANNER "ScannerMenu"
-
#define MENU_FILE_SORT_TAG "SortTagMenu"
#define MENU_FILE_SORT_PROP "SortPropMenu"
#define MENU_SORT_TAG_PATH "ViewMenu/SortTagMenu"
#define MENU_SORT_PROP_PATH "ViewMenu/SortPropMenu"
-#define MENU_SCANNER_PATH MENU_VIEW "/" MENU_SCANNER
#define POPUP_FILE "FilePopup"
#define POPUP_DIR "DirPopup"
#define POPUP_SUBMENU_SCANNER "ScannerSubpopup"
@@ -49,17 +42,7 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
#define POPUP_LOG "LogPopup"
#define AM_SCAN_FILES "ScanFiles"
-#define AM_BROWSER_HIDDEN_DIR "BrowseHiddenDir"
-#define AM_COLLAPSE_TREE "CollapseTree"
-#define AM_INITIALIZE_TREE "RefreshTree"
-#define AM_RELOAD_DIRECTORY "ReloadDir"
-#define AM_TREE_VIEW_MODE "TreeViewMode"
-#define AM_ARTIST_VIEW_MODE "ArtistViewMode"
#define AM_OPEN_OPTIONS_WINDOW "Preferences"
-#define AM_SCANNER_FILL_TAG "FillTag"
-#define AM_SCANNER_RENAME_FILE "RenameFile"
-#define AM_SCANNER_PROCESS_FIELDS "ProcessFields"
-#define AM_SCANNER_SHOW "ShowScanner"
#define AM_CDDB_SEARCH_FILE "CDDBSearchFile"
#define AM_ARTIST_RUN_AUDIO_PLAYER "ArtistRunAudio"
@@ -127,7 +110,4 @@ GtkWidget *Create_Status_Bar (void);
void Statusbar_Message (const gchar *message, gboolean with_timer);
GtkWidget *Create_Progress_Bar (void);
-void Check_Menu_Item_Update_Browse_Subdir (void);
-void Check_Menu_Item_Update_Browse_Hidden_Dir (void);
-
#endif /* __BAR_H__ */
diff --git a/src/browser.c b/src/browser.c
index 6eca6a5..2753b8b 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1374,7 +1374,7 @@ et_browser_refresh_list (EtBrowser *self)
gchar *track;
gchar *disc;
gboolean valid;
- GtkWidget *artist_radio;
+ GVariant *variant;
g_return_if_fail (ET_BROWSER (self));
@@ -1386,9 +1386,6 @@ et_browser_refresh_list (EtBrowser *self)
return;
}
- artist_radio = gtk_ui_manager_get_widget (UIManager,
- "/ToolBar/ArtistViewMode");
-
// Browse the full list for changes
//gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->file_model), &iter);
// g_print("above worked %d rows\n", gtk_tree_model_iter_n_children(GTK_TREE_MODEL(priv->file_model),
NULL));
@@ -1438,8 +1435,11 @@ et_browser_refresh_list (EtBrowser *self)
}
gtk_tree_path_free(currentPath);
+ variant = g_action_group_get_action_state (G_ACTION_GROUP (MainWindow),
+ "file-artist-view");
+
// When displaying Artist + Album lists => refresh also rows color
- if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
+ if (strcmp (g_variant_get_string (variant, NULL), "artist") == 0)
{
for (row = 0; row < gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->artist_model), NULL);
row++)
@@ -1467,6 +1467,8 @@ et_browser_refresh_list (EtBrowser *self)
}
gtk_tree_path_free(currentPath);
}
+
+ g_variant_unref (variant);
}
@@ -1480,7 +1482,7 @@ et_browser_refresh_file_in_list (EtBrowser *self, ET_File *ETFile)
{
EtBrowserPrivate *priv;
GList *selectedRow = NULL;
- GtkWidget *artist_radio;
+ GVariant *variant;
GtkTreeSelection *selection;
GtkTreeIter selectedIter;
ET_File *etfile;
@@ -1503,9 +1505,6 @@ et_browser_refresh_file_in_list (EtBrowser *self, ET_File *ETFile)
return;
}
- artist_radio = gtk_ui_manager_get_widget (UIManager,
- "/ToolBar/ArtistViewMode");
-
// Search the row of the modified file to update it (when found: row_found=TRUE)
// 1/3. Get position of ETFile in ETFileList
if (row_found == FALSE)
@@ -1602,8 +1601,11 @@ et_browser_refresh_file_in_list (EtBrowser *self, ET_File *ETFile)
/* Change appearance (line to red) if filename changed. */
Browser_List_Set_Row_Appearance (self, &selectedIter);
- // When displaying Artist + Album lists => refresh also rows color
- if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
+ variant = g_action_group_get_action_state (G_ACTION_GROUP (MainWindow),
+ "file-artist-view");
+
+ /* When displaying Artist + Album lists => refresh also rows color. */
+ if (strcmp (g_variant_get_string (variant, NULL), "artist") == 0)
{
gchar *current_artist = ((File_Tag *)ETFile->FileTag->data)->artist;
gchar *current_album = ((File_Tag *)ETFile->FileTag->data)->album;
@@ -1664,6 +1666,8 @@ et_browser_refresh_file_in_list (EtBrowser *self, ET_File *ETFile)
// FIX ME : see also if we must add a new line / or change list of the ETFile
//
}
+
+ g_variant_unref (variant);
}
@@ -2714,58 +2718,51 @@ Browser_Album_List_Set_Row_Appearance (EtBrowser *self, GtkTreeIter *iter)
}
void
-et_browser_toggle_display_mode (EtBrowser *self)
+et_browser_set_display_mode (EtBrowser *self,
+ EtBrowserMode mode)
{
EtBrowserPrivate *priv;
ET_File *etfile = ETCore->ETFileDisplayed; // ETFile to display again after changing browser view
- GtkWidget *artist_radio;
g_return_if_fail (ET_BROWSER (self));
priv = et_browser_get_instance_private (self);
- // Save the current displayed data
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- // Toggle button to switch view
- artist_radio = gtk_ui_manager_get_widget (UIManager,
- "/ToolBar/ArtistViewMode");
+ /* Save the current displayed data. */
+ ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
- // Button pressed in the toolbar
- if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
+ switch (mode)
{
- /*
- * Artist + Album view
- */
+ case ET_BROWSER_MODE_FILE:
+ /* Set the whole list as "Displayed list". */
+ ET_Set_Displayed_File_List (ETCore->ETFileList);
- /* Display Artist + Album lists. */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
- ET_Create_Artist_Album_File_List();
- Browser_Artist_List_Load_Files (self, etfile);
-
- }else
- {
+ /* Display Tree Browser. */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
+ et_browser_load_file_list (self, ETCore->ETFileDisplayedList,
+ etfile);
- /*
- * Browser (classic) view
- */
- // Set the whole list as "Displayed list"
- ET_Set_Displayed_File_List(ETCore->ETFileList);
-
- /* Display Tree Browser. */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
- et_browser_load_file_list (self, ETCore->ETFileDisplayedList, etfile);
+ /* Displays the first file if nothing specified. */
+ if (!etfile)
+ {
+ GList *etfilelist = ET_Displayed_File_List_First ();
+ if (etfilelist)
+ {
+ etfile = (ET_File *)etfilelist->data;
+ }
- // Displays the first file if nothing specified
- if (!etfile)
- {
- GList *etfilelist = ET_Displayed_File_List_First();
- if (etfilelist)
- etfile = (ET_File *)etfilelist->data;
- Action_Select_Nth_File_By_Etfile(etfile);
- }
+ Action_Select_Nth_File_By_Etfile (etfile);
+ }
+ break;
+ case ET_BROWSER_MODE_ARTIST:
+ /* Display Artist + Album lists. */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
+ ET_Create_Artist_Album_File_List ();
+ Browser_Artist_List_Load_Files (self, etfile);
+ break;
+ default:
+ g_assert_not_reached ();
}
-
//ET_Display_File_Data_To_UI(etfile); // Causes a crash
}
diff --git a/src/browser.h b/src/browser.h
index 83e75b7..201fdfb 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -53,6 +53,12 @@ void et_browser_show_open_directory_with_dialog (EtBrowser *self);
void et_browser_show_open_files_with_dialog (EtBrowser *self);
void et_browser_show_rename_directory_dialog (EtBrowser *self);
+typedef enum
+{
+ ET_BROWSER_MODE_FILE,
+ ET_BROWSER_MODE_ARTIST
+} EtBrowserMode;
+
/*
* To number columns of ComboBox
*/
@@ -89,7 +95,7 @@ ET_File * et_browser_get_et_file_from_iter (EtBrowser *self, GtkTreeIter *iter);
void et_browser_entry_set_text (EtBrowser *self, const gchar *text);
void et_browser_label_set_text (EtBrowser *self, const gchar *text);
-void et_browser_toggle_display_mode (EtBrowser *self);
+void et_browser_set_display_mode (EtBrowser *self, EtBrowserMode mode);
void et_browser_go_home (EtBrowser *self);
void et_browser_go_desktop (EtBrowser *self);
diff --git a/src/easytag.c b/src/easytag.c
index b3db9de..926c2a6 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -529,7 +529,6 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
File_Name *FileNameNew;
double fraction;
GtkAction *uiaction;
- GtkWidget *toggle_radio;
GtkWidget *widget_focused;
GtkTreePath *currentPath = NULL;
@@ -718,11 +717,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
etfile_save_position,
TRUE);
- /* Browser is on mode : Artist + Album list */
- toggle_radio = gtk_ui_manager_get_widget (UIManager,
- "/ToolBar/ArtistViewMode");
- if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (toggle_radio)))
- et_application_window_browser_toggle_display_mode (window);
+ et_application_window_browser_toggle_display_mode (window);
/* To update state of command buttons */
et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
@@ -1206,7 +1201,6 @@ gboolean Read_Directory (gchar *path_real)
GList *l;
gint progress_bar_index = 0;
GtkAction *uiaction;
- GtkWidget *artist_radio;
EtApplicationWindow *window;
g_return_val_if_fail (path_real != NULL, FALSE);
@@ -1229,10 +1223,6 @@ gboolean Read_Directory (gchar *path_real)
Clear_Tag_Entry_Fields();
gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
- artist_radio = gtk_ui_manager_get_widget (UIManager, "/ToolBar/ArtistViewMode");
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio),
- FALSE);
-
// Set to unsensitive the Browser Area, to avoid to select another file while loading the first one
et_application_window_browser_set_sensitive (window, FALSE);
@@ -1574,13 +1564,11 @@ Init_Load_Default_Dir (void)
ET_Core_Free();
ET_Core_Initialize();
- /* FIXME: Open the scanner window. */
- /*
if (g_settings_get_boolean (MainSettings, "scan-startup"))
{
- et_application_window_show_scan_dialog (ET_APPLICATION_WINDOW (MainWindow));
+ g_action_group_activate_action (G_ACTION_GROUP (MainWindow), "scanner",
+ NULL);
}
- */
if (INIT_DIRECTORY)
{
diff --git a/src/easytag.h b/src/easytag.h
index 6f90ce0..8fba880 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -113,7 +113,6 @@ gint et_delete_file (ET_File *ETFile, gboolean multiple_files, GError **error);
gint Save_All_Files_With_Answer (gboolean force_saving_files);
void Action_Main_Stop_Button_Pressed (void);
-void Action_Select_Browser_Style (void);
void et_on_action_select_scan_mode (GtkRadioAction *action,
GtkRadioAction *current,
gpointer user_data);
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 56540e5..8c58314 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1751,16 +1751,11 @@ static void
on_scan_mode_changed (EtScanDialog *self, gchar *key, GSettings *settings)
{
EtScanDialogPrivate *priv;
- GtkRadioAction *radio_action;
EtScanMode mode;
priv = et_scan_dialog_get_instance_private (self);
- /* TODO: Bind to a single GAction. */
- radio_action = GTK_RADIO_ACTION (gtk_ui_manager_get_action (UIManager,
- "/MenuBar/ViewMenu/ScannerMenu/FillTag"));
mode = g_settings_get_enum (MainSettings, key);
- gtk_radio_action_set_current_value (radio_action, mode);
switch (mode)
{
@@ -1957,21 +1952,6 @@ Mask_Editor_List_Save_Button (EtScanDialog *self)
}
static void
-on_hide (EtScanDialog *self)
-{
- GtkToggleAction *toggle_action;
-
- toggle_action = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (UIManager,
- "/ToolBar/ShowScanner"));
-
- if (gtk_toggle_action_get_active (toggle_action))
- {
- gtk_toggle_action_set_active (toggle_action, FALSE);
- }
-
-}
-
-static void
Select_Fields_Select_Unselect_All (EtScanDialog *self)
{
GFlagsClass *flags_class;
@@ -2508,7 +2488,6 @@ create_scan_dialog (EtScanDialog *self)
/* 'Scan selected files' button */
scan_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- /* TODO: Set related action to match AM_SCAN_FILES. */
gtk_button_set_label (GTK_BUTTON (scan_button), _("Scan Files"));
gtk_widget_set_can_default (scan_button, TRUE);
gtk_dialog_add_action_widget (GTK_DIALOG (self), scan_button,
@@ -2520,7 +2499,6 @@ create_scan_dialog (EtScanDialog *self)
/* The response signal handles close, scan and the delete event. */
g_signal_connect (self, "response", G_CALLBACK (et_scan_on_response),
NULL);
- g_signal_connect (self, "hide", G_CALLBACK (on_hide), NULL);
g_signal_connect (self, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
diff --git a/src/ui_manager.h b/src/ui_manager.h
index 3ae1c0a..b5a6c26 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -11,18 +11,6 @@ static const gchar *ui_xml =
*/
" <menubar name='MenuBar'>"
" <menu action='ViewMenu'>"
-" <menuitem action='ShowScanner' />"
-" <menu action='ScannerMenu'>"
-" <menuitem action='FillTag' />"
-" <menuitem action='RenameFile' />"
-" <menuitem action='ProcessFields' />"
-" </menu>"
-" <separator />"
-
-" <menuitem action='TreeViewMode'/>"
-" <menuitem action='ArtistViewMode'/>"
-" <separator />"
-
" <menu action='SortTagMenu'>"
" <menuitem action='SortTrackNumAsc' />"
" <menuitem action='SortTrackNumDesc' />"
@@ -89,18 +77,6 @@ static const gchar *ui_xml =
" <menuitem action='SortSamplerateAsc' />"
" <menuitem action='SortSamplerateDesc' />"
" </menu>"
-" <separator />"
-
-" <menuitem action='CollapseTree' />"
-" <menuitem action='RefreshTree' />"
-" <separator />"
-
-" <menuitem action='ReloadDir' />"
-" <separator />"
-
-#ifndef G_OS_WIN32
-" <menuitem action='BrowseHiddenDir' />"
-#endif /* !G_OS_WIN32 */
" </menu>"
" </menubar>"
@@ -110,13 +86,6 @@ static const gchar *ui_xml =
* Tool bar
*/
" <toolbar name='ToolBar'>"
-" <toolitem action='ShowScanner'/>"
-" <separator />"
-
-" <toolitem action='TreeViewMode'/>"
-" <toolitem action='ArtistViewMode'/>"
-" <separator />"
-
" <toolitem action='Stop'/>"
" </toolbar>"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]