[sound-juicer] Remove the remaining menubar
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Remove the remaining menubar
- Date: Sat, 1 Sep 2012 17:03:36 +0000 (UTC)
commit fbf43e5bf00c1067ea9ff7e1f5640241c9b9c3c1
Author: Florian MÃllner <fmuellner gnome org>
Date: Fri May 4 16:40:11 2012 +0200
Remove the remaining menubar
https://bugzilla.gnome.org/show_bug.cgi?id=675245
data/sound-juicer.ui | 97 ----------------------------------------------
src/sj-extracting.c | 24 +++---------
src/sj-main.c | 104 +++++++++++++++++++++++++++++++++-----------------
src/sj-main.h | 2 -
src/sj-play.c | 22 ++++-------
src/sj-play.h | 7 +--
6 files changed, 86 insertions(+), 170 deletions(-)
---
diff --git a/data/sound-juicer.ui b/data/sound-juicer.ui
index 1e61369..1ff2dff 100644
--- a/data/sound-juicer.ui
+++ b/data/sound-juicer.ui
@@ -12,102 +12,6 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkMenuBar" id="menubar1">
- <property name="visible">True</property>
- <child>
- <object class="GtkMenuItem" id="menuitem1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Disc</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menuitem1_menu">
- <child>
- <object class="GtkImageMenuItem" id="play_menuitem">
- <property name="label" translatable="yes">_Play / Pause</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="p" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_play_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="next_track_menuitem">
- <property name="label" translatable="yes">_Next Track</property>
- <property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Skip to the next track</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="N" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_next_track_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="previous_track_menuitem">
- <property name="label" translatable="yes">Pre_vious Track</property>
- <property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Skip to the previous track</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_previous_track_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="extract_menuitem">
- <property name="label">sj-stock-extract</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_extract_activate"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menuitem2_menu">
- <child>
- <object class="GtkMenuItem" id="select_all">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Select All</property>
- <property name="use_underline">True</property>
- <accelerator key="A" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_select_all_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="deselect_all">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Deselect All</property>
- <property name="use_underline">True</property>
- <accelerator key="A" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_deselect_all_activate"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<object class="GtkEventBox" id="message_area_eventbox">
<property name="visible">True</property>
<child>
@@ -395,7 +299,6 @@
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
- <signal name="clicked" handler="on_play_activate"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index 4a5c94a..3a21f0e 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -88,9 +88,6 @@ static GtkWidget *progress_bar, *status_bar;
/** The widgets in the main UI */
static GtkWidget *extract_button, *play_button, *title_entry, *artist_entry, *genre_entry, *year_entry, *disc_number_entry, *track_listview;
-/** The menuitem in the main menu */
-static GtkWidget *extract_menuitem, *play_menuitem, *select_all_menuitem, *deselect_all_menuitem;
-
static GtkTreeIter current;
/**
@@ -250,11 +247,9 @@ cleanup (void)
gtk_widget_set_sensitive (year_entry, TRUE);
gtk_widget_set_sensitive (disc_number_entry, TRUE);
/* Enabling the Menuitem */
- gtk_widget_set_sensitive (play_menuitem, TRUE);
- gtk_widget_set_sensitive (extract_menuitem, TRUE);
- gtk_widget_set_sensitive (select_all_menuitem, TRUE);
- gtk_widget_set_sensitive (deselect_all_menuitem, TRUE);
-
+ set_action_enabled ("play", TRUE);
+ set_action_enabled ("select-all", TRUE);
+ set_action_enabled ("deselect-all", TRUE);
set_action_enabled ("re-read", TRUE);
/*Enable the Extract column and Make the Title and Artist column Editable*/
@@ -791,11 +786,6 @@ on_extract_activate (GtkWidget *button, gpointer user_data)
progress_bar = GET_WIDGET ("progress_bar");
status_bar = GET_WIDGET ("status_bar");
- play_menuitem = GET_WIDGET ("play_menuitem");
- extract_menuitem = GET_WIDGET ("extract_menuitem");
- select_all_menuitem = GET_WIDGET ("select_all");
- deselect_all_menuitem = GET_WIDGET ("deselect_all");
-
initialised = TRUE;
}
@@ -818,11 +808,9 @@ on_extract_activate (GtkWidget *button, gpointer user_data)
gtk_widget_set_sensitive (disc_number_entry, FALSE);
/* Disable the menuitems in the main menu*/
- gtk_widget_set_sensitive (play_menuitem, FALSE);
- gtk_widget_set_sensitive (extract_menuitem, FALSE);
- gtk_widget_set_sensitive (select_all_menuitem, FALSE);
- gtk_widget_set_sensitive (deselect_all_menuitem, FALSE);
-
+ set_action_enabled ("play", FALSE);
+ set_action_enabled ("select-all", FALSE);
+ set_action_enabled ("deselect-all", FALSE);
set_action_enabled ("re-read", FALSE);
/* Disable the Extract column */
diff --git a/src/sj-main.c b/src/sj-main.c
index 0f55400..b4625e9 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -77,7 +77,6 @@ static GtkWidget *message_area_eventbox;
static GtkWidget *title_entry, *artist_entry, *duration_label, *genre_entry, *year_entry, *disc_number_entry;
static GtkWidget *track_listview, *extract_button, *play_button;
static GtkWidget *status_bar;
-static GtkWidget *extract_menuitem, *play_menuitem, *next_menuitem, *prev_menuitem, *select_all_menuitem, *deselect_all_menuitem;
GtkListStore *track_store;
GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer;
@@ -244,23 +243,40 @@ static gboolean select_all_foreach_cb (GtkTreeModel *model,
return FALSE;
}
-G_MODULE_EXPORT void on_select_all_activate (GtkMenuItem *item, gpointer user_data)
+static void on_play_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ toggle_play ();
+}
+
+static void on_next_track_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ play_next_track ();
+}
+
+static void on_previous_track_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ play_previous_track ();
+}
+
+static void on_select_all_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
{
gtk_tree_model_foreach (GTK_TREE_MODEL (track_store), select_all_foreach_cb, GINT_TO_POINTER (TRUE));
gtk_widget_set_sensitive (extract_button, TRUE);
- gtk_widget_set_sensitive (extract_menuitem, TRUE);
- gtk_widget_set_sensitive (select_all_menuitem, FALSE);
- gtk_widget_set_sensitive (deselect_all_menuitem, TRUE);
+
+ set_action_enabled ("select-all", FALSE);
+ set_action_enabled ("deselect-all", TRUE);
+
no_of_tracks_selected = total_no_of_tracks;
}
-G_MODULE_EXPORT void on_deselect_all_activate (GtkMenuItem *item, gpointer user_data)
+static void on_deselect_all_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
{
gtk_tree_model_foreach (GTK_TREE_MODEL (track_store), select_all_foreach_cb, GINT_TO_POINTER (FALSE));
gtk_widget_set_sensitive (extract_button, FALSE);
- gtk_widget_set_sensitive (extract_menuitem, FALSE);
- gtk_widget_set_sensitive (deselect_all_menuitem, FALSE);
- gtk_widget_set_sensitive (select_all_menuitem,TRUE);
+
+ set_action_enabled ("deselect-all", FALSE);
+ set_action_enabled ("select-all", TRUE);
+
no_of_tracks_selected = 0;
}
@@ -529,13 +545,12 @@ static void update_ui_for_album (AlbumDetails *album)
gtk_widget_set_sensitive (year_entry, FALSE);
gtk_widget_set_sensitive (disc_number_entry, FALSE);
gtk_widget_set_sensitive (play_button, FALSE);
- gtk_widget_set_sensitive (play_menuitem, FALSE);
gtk_widget_set_sensitive (extract_button, FALSE);
- gtk_widget_set_sensitive (extract_menuitem, FALSE);
- gtk_widget_set_sensitive (select_all_menuitem, FALSE);
- gtk_widget_set_sensitive (deselect_all_menuitem, FALSE);
- gtk_widget_set_sensitive (prev_menuitem, FALSE);
- gtk_widget_set_sensitive (next_menuitem, FALSE);
+ set_action_enabled ("play", FALSE);
+ set_action_enabled ("select-all", FALSE);
+ set_action_enabled ("deselect-all", FALSE);
+ set_action_enabled ("previous-track", FALSE);
+ set_action_enabled ("next-track", FALSE);
set_action_enabled ("duplicate", FALSE);
set_message_area (message_area_eventbox, NULL);
@@ -571,13 +586,12 @@ static void update_ui_for_album (AlbumDetails *album)
gtk_widget_set_sensitive (year_entry, TRUE);
gtk_widget_set_sensitive (disc_number_entry, TRUE);
gtk_widget_set_sensitive (play_button, TRUE);
- gtk_widget_set_sensitive (play_menuitem, TRUE);
gtk_widget_set_sensitive (extract_button, TRUE);
- gtk_widget_set_sensitive (extract_menuitem, TRUE);
- gtk_widget_set_sensitive (select_all_menuitem, FALSE);
- gtk_widget_set_sensitive (deselect_all_menuitem, TRUE);
- gtk_widget_set_sensitive (prev_menuitem, FALSE);
- gtk_widget_set_sensitive (next_menuitem, FALSE);
+ set_action_enabled ("play", TRUE);
+ set_action_enabled ("select-all", FALSE);
+ set_action_enabled ("deselect-all", TRUE);
+ set_action_enabled ("previous-track", FALSE);
+ set_action_enabled ("next-track", FALSE);
set_action_enabled ("duplicate", TRUE);
for (l = album->tracks; l; l=g_list_next (l)) {
@@ -1339,26 +1353,24 @@ static void on_extract_toggled (GtkCellRendererToggle *cellrenderertoggle,
if (extract) {
/* If true, then we can extract */
gtk_widget_set_sensitive (extract_button, TRUE);
- gtk_widget_set_sensitive (extract_menuitem, TRUE);
no_of_tracks_selected++;
} else {
/* Reuse the boolean extract */
extract = FALSE;
gtk_tree_model_foreach (GTK_TREE_MODEL (track_store), (GtkTreeModelForeachFunc)extract_available_foreach, &extract);
gtk_widget_set_sensitive (extract_button, extract);
- gtk_widget_set_sensitive (extract_menuitem, extract);
no_of_tracks_selected--;
}
/* Enable and disable the Select/Deselect All buttons */
if (no_of_tracks_selected == total_no_of_tracks) {
- gtk_widget_set_sensitive(deselect_all_menuitem, TRUE);
- gtk_widget_set_sensitive(select_all_menuitem, FALSE);
+ set_action_enabled ("deselect-all", TRUE);
+ set_action_enabled ("select-all", FALSE);
} else if (no_of_tracks_selected == 0) {
- gtk_widget_set_sensitive(deselect_all_menuitem, FALSE);
- gtk_widget_set_sensitive(select_all_menuitem, TRUE);
+ set_action_enabled ("deselect-all", FALSE);
+ set_action_enabled ("select-all", TRUE);
} else {
- gtk_widget_set_sensitive(select_all_menuitem, TRUE);
- gtk_widget_set_sensitive(deselect_all_menuitem, TRUE);
+ set_action_enabled ("select-all", TRUE);
+ set_action_enabled ("deselect-all", TRUE);
}
}
@@ -1624,6 +1636,14 @@ GActionEntry app_entries[] = {
{ "quit", on_quit_activate, NULL, NULL, NULL }
};
+GActionEntry win_entries[] = {
+ { "play", on_play_activate, NULL, NULL, NULL },
+ { "next-track", on_next_track_activate, NULL, NULL, NULL },
+ { "previous-track", on_previous_track_activate, NULL, NULL, NULL },
+ { "select-all", on_select_all_activate, NULL, NULL, NULL },
+ { "deselect-all", on_deselect_all_activate, NULL, NULL, NULL }
+};
+
static void
startup_cb (GApplication *app, gpointer user_data)
{
@@ -1689,8 +1709,6 @@ startup_cb (GApplication *app, gpointer user_data)
main_window = GET_WIDGET ("main_window");
message_area_eventbox = GET_WIDGET ("message_area_eventbox");
- select_all_menuitem = GET_WIDGET ("select_all");
- deselect_all_menuitem = GET_WIDGET ("deselect_all");
title_entry = GET_WIDGET ("title_entry");
artist_entry = GET_WIDGET ("artist_entry");
duration_label = GET_WIDGET ("duration_label");
@@ -1699,13 +1717,26 @@ startup_cb (GApplication *app, gpointer user_data)
disc_number_entry = GET_WIDGET ("disc_number_entry");
track_listview = GET_WIDGET ("track_listview");
extract_button = GET_WIDGET ("extract_button");
- extract_menuitem = GET_WIDGET ("extract_menuitem");
play_button = GET_WIDGET ("play_button");
- play_menuitem = GET_WIDGET ("play_menuitem");
- next_menuitem = GET_WIDGET ("next_track_menuitem");
- prev_menuitem = GET_WIDGET ("previous_track_menuitem");
status_bar = GET_WIDGET ("status_bar");
+ g_action_map_add_action_entries (G_ACTION_MAP (main_window),
+ win_entries, G_N_ELEMENTS (win_entries),
+ NULL);
+ gtk_actionable_set_action_name(GTK_ACTIONABLE(play_button), "win.play");
+
+ /* window actions are only available via shortcuts */
+ gtk_application_add_accelerator (GTK_APPLICATION (app),
+ "<Primary>p", "win.play", NULL);
+ gtk_application_add_accelerator (GTK_APPLICATION (app),
+ "<Primary>n", "win.next-track", NULL);
+ gtk_application_add_accelerator (GTK_APPLICATION (app),
+ "<Primary>b", "win.previous-track", NULL);
+ gtk_application_add_accelerator (GTK_APPLICATION (app),
+ "<Primary>a", "win.select-all", NULL);
+ gtk_application_add_accelerator (GTK_APPLICATION (app),
+ "<Primary><Shift>a", "win.deselect-all", NULL);
+
{ /* ensure that the play/pause button's size is constant */
GtkWidget *fake_button1, *fake_button2;
GtkSizeGroup *size_group;
@@ -1907,6 +1938,9 @@ void set_action_enabled (const char *name, gboolean enabled)
GActionMap *map = G_ACTION_MAP (g_application_get_default ());
GAction *action = g_action_map_lookup_action (map, name);
+ if (action == NULL)
+ action = g_action_map_lookup_action (G_ACTION_MAP (main_window), name);
+
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
}
diff --git a/src/sj-main.h b/src/sj-main.h
index 3734878..c580f98 100644
--- a/src/sj-main.h
+++ b/src/sj-main.h
@@ -29,8 +29,6 @@ void sj_stock_init (void);
void set_action_enabled (const char *name, gboolean enabled);
G_MODULE_EXPORT void on_destroy_activate (GtkMenuItem *item, gpointer user_data);
-G_MODULE_EXPORT void on_select_all_activate (GtkMenuItem *item, gpointer user_data);
-G_MODULE_EXPORT void on_deselect_all_activate (GtkMenuItem *item, gpointer user_data);
AlbumDetails* multiple_album_dialog (GList* albums);
diff --git a/src/sj-play.c b/src/sj-play.c
index aadb330..c00ebb4 100644
--- a/src/sj-play.c
+++ b/src/sj-play.c
@@ -41,7 +41,7 @@ static void set_gst_ui_and_play (void);
static GtkTreeIter current_iter;
-static GtkWidget *play_button, *next_menuitem, *prev_menuitem, *seek_scale, *volume_button, *statusbar, *track_listview;
+static GtkWidget *play_button, *seek_scale, *volume_button, *statusbar, *track_listview;
/**
* Select track number.
@@ -87,8 +87,8 @@ _play (void)
{
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- gtk_widget_set_sensitive (next_menuitem, TRUE);
- gtk_widget_set_sensitive (prev_menuitem, TRUE);
+ set_action_enabled ("next-track", TRUE);
+ set_action_enabled ("previous-track", TRUE);
}
/**
@@ -110,8 +110,8 @@ _stop (void)
gst_element_set_state (pipeline, GST_STATE_NULL);
/* TODO: this should be centralised into the state change logic really */
- gtk_widget_set_sensitive (next_menuitem, FALSE);
- gtk_widget_set_sensitive (prev_menuitem, FALSE);
+ set_action_enabled ("next-track", FALSE);
+ set_action_enabled ("previous-track", FALSE);
set_action_enabled ("re-read", TRUE);
@@ -390,9 +390,7 @@ stop_playback (void)
/*
* Interface entry point.
*/
-
-G_MODULE_EXPORT void
-on_play_activate (GtkWidget *button, gpointer user_data)
+void toggle_play ()
{
GError *err = NULL;
@@ -456,14 +454,12 @@ on_tracklist_row_activate (GtkTreeView * treeview, GtkTreePath * path,
}
}
-G_MODULE_EXPORT void
-on_next_track_activate(GtkWidget *button, gpointer data)
+void play_next_track ()
{
cb_hop_track (NULL, NULL, NULL);
}
-G_MODULE_EXPORT void
-on_previous_track_activate(GtkWidget *button, gpointer data)
+void play_previous_track ()
{
GtkTreeModel *model;
gint prev_track = current_track - 1;
@@ -608,8 +604,6 @@ void
sj_play_init (void)
{
play_button = GET_WIDGET ("play_button");
- next_menuitem = GET_WIDGET ("next_track_menuitem");
- prev_menuitem = GET_WIDGET ("previous_track_menuitem");
seek_scale = GET_WIDGET ("seek_scale");
volume_button = GET_WIDGET ("volume_button");
statusbar = GET_WIDGET ("status_bar");
diff --git a/src/sj-play.h b/src/sj-play.h
index d5b65f8..03395d3 100644
--- a/src/sj-play.h
+++ b/src/sj-play.h
@@ -35,12 +35,11 @@ G_MODULE_EXPORT void on_tracklist_row_activate (GtkTreeView *treeview, GtkTreePa
void stop_ui_hack (void);
-G_MODULE_EXPORT void on_play_activate (GtkWidget *button, gpointer user_data);
+void toggle_play (void);
-G_MODULE_EXPORT void on_next_track_activate(GtkWidget *button, gpointer data);
-
-G_MODULE_EXPORT void on_previous_track_activate(GtkWidget *button, gpointer data);
+void play_next_track (void);
+void play_previous_track (void);
G_MODULE_EXPORT void on_tracklist_row_selected (GtkTreeView *treeview,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]