[sound-juicer] Add an application menu
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Add an application menu
- Date: Sat, 1 Sep 2012 17:03:31 +0000 (UTC)
commit 6abce56aae866bba182d45a1408d89b9ab0db162
Author: Florian MÃllner <fmuellner gnome org>
Date: Fri May 4 16:01:50 2012 +0200
Add an application menu
https://bugzilla.gnome.org/show_bug.cgi?id=675245
data/Makefile.am | 2 +-
data/sound-juicer-menu.ui | 54 +++++++++++++
data/sound-juicer.ui | 97 -----------------------
po/POTFILES.in | 1 +
src/sj-about.c | 2 +-
src/sj-about.h | 2 +-
src/sj-extracting.c | 10 ++-
src/sj-main.c | 192 +++++++++++++++++++++++++--------------------
src/sj-main.h | 8 +--
src/sj-play.c | 4 +
src/sj-prefs.c | 2 +-
src/sj-prefs.h | 3 +-
12 files changed, 180 insertions(+), 197 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index f4e53fb..b752400 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
privatedatadir = $(pkgdatadir)
-dist_privatedata_DATA = sound-juicer.ui
+dist_privatedata_DATA = sound-juicer.ui sound-juicer-menu.ui
desktopdir = $(datadir)/applications
desktop_in_files = sound-juicer.desktop.in.in
diff --git a/data/sound-juicer-menu.ui b/data/sound-juicer-menu.ui
new file mode 100644
index 0000000..76170a0
--- /dev/null
+++ b/data/sound-juicer-menu.ui
@@ -0,0 +1,54 @@
+<interface>
+ <menu id="app-menu">
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">Disc</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Re-read</attribute>
+ <attribute name="action">app.re-read</attribute>
+ <attribute name="accel"><Primary>r</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Duplicate</attribute>
+ <attribute name="action">app.duplicate</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Eject</attribute>
+ <attribute name="action">app.eject</attribute>
+ <attribute name="accel"><Primary>j</attribute>
+ </item>
+ </section>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Submit Track Names</attribute>
+ <attribute name="action">app.submit-tracks</attribute>
+ <attribute name="accel"><Primary>s</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">About Sound Juicer</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Help</attribute>
+ <attribute name="action">app.help</attribute>
+ <attribute name="accel">F1</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/data/sound-juicer.ui b/data/sound-juicer.ui
index d944216..1e61369 100644
--- a/data/sound-juicer.ui
+++ b/data/sound-juicer.ui
@@ -54,25 +54,6 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="eject">
- <property name="visible">True</property>
- <property name="label" translatable="yes">E_ject</property>
- <property name="use_underline">True</property>
- <accelerator key="J" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_eject_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="submit">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="label" translatable="yes">_Submit Track Names...</property>
- <property name="use_underline">True</property>
- <accelerator key="S" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_submit_activate"/>
- </object>
- </child>
- <child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</object>
@@ -86,40 +67,6 @@
<signal name="activate" handler="on_extract_activate"/>
</object>
</child>
- <child>
- <object class="GtkImageMenuItem" id="re-read">
- <property name="label" translatable="yes">_Re-read Disc</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="R" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_reread_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="duplicate_menuitem">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">_Duplicate Disc</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_duplicate_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separator2">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="quit">
- <property name="label">gtk-quit</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_quit_activate"/>
- </object>
- </child>
</object>
</child>
</object>
@@ -149,50 +96,6 @@
<signal name="activate" handler="on_deselect_all_activate"/>
</object>
</child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separator1">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="edit_preferences">
- <property name="label">gtk-preferences</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_edit_preferences_cb"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Help</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menuitem4_menu">
- <child>
- <object class="GtkImageMenuItem" id="contents">
- <property name="label" translatable="yes">_Contents</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="F1" signal="activate"/>
- <signal name="activate" handler="on_contents_activate"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="about">
- <property name="label">gtk-about</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_about_activate"/>
- </object>
- </child>
</object>
</child>
</object>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 582b00d..6f59d83 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@
data/sound-juicer.desktop.in.in
data/sound-juicer.schemas.in
[type: gettext/glade]data/sound-juicer.ui
+[type: gettext/glade]data/sound-juicer-menu.ui
libjuicer/sj-error.c
libjuicer/sj-extractor.c
libjuicer/sj-metadata.c
diff --git a/src/sj-about.c b/src/sj-about.c
index af6ce17..d5ce3f4 100644
--- a/src/sj-about.c
+++ b/src/sj-about.c
@@ -30,7 +30,7 @@
#include <string.h>
#include "sj-about.h"
-G_MODULE_EXPORT void on_about_activate (void)
+void show_about_dialog (void)
{
char *license_trans;
diff --git a/src/sj-about.h b/src/sj-about.h
index 07933f2..499fdab 100644
--- a/src/sj-about.h
+++ b/src/sj-about.h
@@ -25,6 +25,6 @@
#include <gtk/gtk.h>
-G_MODULE_EXPORT void on_about_activate (void);
+void show_about_dialog (void);
#endif /* SJ_ABOUT_H */
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index e8e7d4c..4a5c94a 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -41,6 +41,7 @@
#include "sj-error.h"
#include "sj-extracting.h"
+#include "sj-main.h"
#include "sj-util.h"
#include "sj-play.h"
#include "sj-inhibit.h"
@@ -88,7 +89,7 @@ static GtkWidget *progress_bar, *status_bar;
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, *reread_menuitem, *select_all_menuitem, *deselect_all_menuitem;
+static GtkWidget *extract_menuitem, *play_menuitem, *select_all_menuitem, *deselect_all_menuitem;
static GtkTreeIter current;
@@ -251,10 +252,11 @@ cleanup (void)
/* Enabling the Menuitem */
gtk_widget_set_sensitive (play_menuitem, TRUE);
gtk_widget_set_sensitive (extract_menuitem, TRUE);
- gtk_widget_set_sensitive (reread_menuitem, TRUE);
gtk_widget_set_sensitive (select_all_menuitem, TRUE);
gtk_widget_set_sensitive (deselect_all_menuitem, TRUE);
+ set_action_enabled ("re-read", TRUE);
+
/*Enable the Extract column and Make the Title and Artist column Editable*/
g_object_set (G_OBJECT (toggle_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
g_object_set (G_OBJECT (title_renderer), "editable", TRUE, NULL);
@@ -791,7 +793,6 @@ on_extract_activate (GtkWidget *button, gpointer user_data)
play_menuitem = GET_WIDGET ("play_menuitem");
extract_menuitem = GET_WIDGET ("extract_menuitem");
- reread_menuitem = GET_WIDGET ("re-read");
select_all_menuitem = GET_WIDGET ("select_all");
deselect_all_menuitem = GET_WIDGET ("deselect_all");
@@ -819,10 +820,11 @@ on_extract_activate (GtkWidget *button, gpointer user_data)
/* 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 (reread_menuitem, FALSE);
gtk_widget_set_sensitive (select_all_menuitem, FALSE);
gtk_widget_set_sensitive (deselect_all_menuitem, FALSE);
+ set_action_enabled ("re-read", FALSE);
+
/* Disable the Extract column */
g_object_set (G_OBJECT (toggle_renderer), "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
g_object_set (G_OBJECT (title_renderer), "editable", FALSE, NULL);
diff --git a/src/sj-main.c b/src/sj-main.c
index ec69786..0f55400 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -58,7 +58,6 @@ gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data
static void reread_cd (gboolean ignore_no_media);
static void update_ui_for_album (AlbumDetails *album);
-static void set_duplication (gboolean enable);
/* Prototypes for the signal blocking/unblocking in update_ui_for_album */
G_MODULE_EXPORT void on_title_edit_changed(GtkEditable *widget, gpointer user_data);
@@ -79,9 +78,6 @@ static GtkWidget *title_entry, *artist_entry, *duration_label, *genre_entry, *ye
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;
-static GtkWidget *submit_menuitem;
-static GtkWidget *reread_menuitem;
-static GtkWidget *duplicate, *eject;
GtkListStore *track_store;
GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer;
@@ -110,6 +106,8 @@ static guint debug_flags = 0;
#define RAISE_WINDOW "raise-window"
#define SOURCE_BUILDER "../data/sound-juicer.ui"
#define INSTALLED_BUILDER DATADIR"/sound-juicer/sound-juicer.ui"
+#define SOURCE_MENU_BUILDER "../data/sound-juicer-menu.ui"
+#define INSTALLED_MENU_BUILDER DATADIR"/sound-juicer/sound-juicer-menu.ui"
void
sj_stock_init (void)
@@ -195,7 +193,7 @@ static void error_on_start (GError *error)
/**
* Clicked Quit
*/
-G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data)
+static void on_quit_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
{
if (on_delete_event (NULL, NULL, NULL) == FALSE) {
gtk_widget_destroy (GTK_WIDGET (main_window));
@@ -205,7 +203,7 @@ G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data)
/**
* Clicked Eject
*/
-G_MODULE_EXPORT void on_eject_activate (GtkMenuItem *item, gpointer user_data)
+static void on_eject_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
{
/* first make sure we're not playing */
stop_playback ();
@@ -428,13 +426,77 @@ musicbrainz_submit_info_bar_new (char *title, char *artist)
return infobar;
}
+/**
+ * Clicked the Submit menu item in the UI
+ */
+static void on_submit_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ GError *error = NULL;
+
+ if (current_submit_url) {
+ if (!gtk_show_uri (NULL, current_submit_url, GDK_CURRENT_TIME, &error)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "<b>%s</b>\n\n%s\n%s: %s",
+ _("Could not open URL"),
+ _("Sound Juicer could not open the submission URL"),
+ _("Reason"),
+ error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+ }
+ }
+}
+
+static void on_preferences_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ show_preferences_dialog ();
+}
+
+static void on_about_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ show_about_dialog ();
+}
+
+/**
+ * Clicked on duplicate in the UI (button/menu)
+ */
+static void on_duplicate_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ GError *error = NULL;
+ const gchar* device;
+
+ device = brasero_drive_get_device (drive);
+ if (!g_spawn_command_line_async (g_strconcat ("brasero -c ", device, NULL), &error)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "<b>%s</b>\n\n%s\n%s: %s",
+ _("Could not duplicate disc"),
+ _("Sound Juicer could not duplicate the disc"),
+ _("Reason"),
+ error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+ }
+}
+
static void
musicbrainz_submit_info_bar_response (GtkInfoBar *infobar,
int response_id,
gpointer user_data)
{
if (response_id == GTK_RESPONSE_OK) {
- on_submit_activate (NULL, NULL);
+ on_submit_activate (NULL, NULL, NULL);
}
set_message_area (message_area_eventbox, NULL);
@@ -474,7 +536,7 @@ static void update_ui_for_album (AlbumDetails *album)
gtk_widget_set_sensitive (deselect_all_menuitem, FALSE);
gtk_widget_set_sensitive (prev_menuitem, FALSE);
gtk_widget_set_sensitive (next_menuitem, FALSE);
- set_duplication (FALSE);
+ set_action_enabled ("duplicate", FALSE);
set_message_area (message_area_eventbox, NULL);
} else {
@@ -516,7 +578,7 @@ static void update_ui_for_album (AlbumDetails *album)
gtk_widget_set_sensitive (deselect_all_menuitem, TRUE);
gtk_widget_set_sensitive (prev_menuitem, FALSE);
gtk_widget_set_sensitive (next_menuitem, FALSE);
- set_duplication (TRUE);
+ set_action_enabled ("duplicate", TRUE);
for (l = album->tracks; l; l=g_list_next (l)) {
GtkTreeIter iter;
@@ -827,9 +889,9 @@ metadata_cb (SjMetadataGetter *m, GList *albums, GError *error)
g_free (current_submit_url);
current_submit_url = sj_metadata_getter_get_submit_url (metadata);
if (current_submit_url) {
- gtk_widget_set_sensitive (submit_menuitem, TRUE);
+ set_action_enabled ("submit-tracks", TRUE);
}
- gtk_widget_set_sensitive (reread_menuitem, TRUE);
+ set_action_enabled ("re-read", TRUE);
/* Free old album details */
if (current_album != NULL) {
@@ -895,7 +957,7 @@ static void reread_cd (gboolean ignore_no_media)
window = gtk_widget_get_window (main_window);
- gtk_widget_set_sensitive (reread_menuitem, FALSE);
+ set_action_enabled ("re-read", FALSE);
/* Make sure nothing is playing */
stop_playback ();
@@ -916,7 +978,7 @@ static void reread_cd (gboolean ignore_no_media)
g_free (current_submit_url);
current_submit_url = NULL;
- gtk_widget_set_sensitive (submit_menuitem, FALSE);
+ set_action_enabled ("submit-tracks", FALSE);
if (!is_audio_cd (drive)) {
sj_debug (DEBUG_CD, "Media is not an audio CD\n");
@@ -1061,7 +1123,7 @@ set_device (const char* device, gboolean ignore_no_media)
}
/* Enable/disable the eject options based on wether the drive supports ejection */
- gtk_widget_set_sensitive (eject, brasero_drive_can_eject (drive));
+ set_action_enabled ("eject", brasero_drive_can_eject (drive));
}
}
@@ -1166,7 +1228,7 @@ static void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_ACCEPT) {
gtk_widget_destroy (dialog);
- on_edit_preferences_cb (NULL, NULL);
+ show_preferences_dialog ();
} else {
/* Can't use gtk_main_quit here, we may be outside the main loop */
exit(0);
@@ -1230,40 +1292,12 @@ static void http_proxy_port_changed_cb (GConfClient *client, guint cnxn_id, GCon
/**
* Clicked on Reread in the UI (button/menu)
*/
-G_MODULE_EXPORT void on_reread_activate (GtkWidget *button, gpointer user_data)
+static void on_reread_activate (GSimpleAction *action, GVariant *parameter, gpointer data)
{
reread_cd (FALSE);
}
/**
- * Clicked the Submit menu item in the UI
- */
-G_MODULE_EXPORT void on_submit_activate (GtkWidget *menuitem, gpointer user_data)
-{
- GError *error = NULL;
-
- if (current_submit_url) {
- if (!gtk_show_uri (NULL, current_submit_url, GDK_CURRENT_TIME, &error)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "<b>%s</b>\n\n%s\n%s: %s",
- _("Could not open URL"),
- _("Sound Juicer could not open the submission URL"),
- _("Reason"),
- error->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_error_free (error);
- }
- }
-
-}
-
-/**
* Called in on_extract_toggled to see if there are selected tracks or not.
* extracting points to the boolean to set to if there are tracks to extract,
* and starts as false.
@@ -1490,7 +1524,7 @@ G_MODULE_EXPORT void on_disc_number_edit_changed(GtkEditable *widget, gpointer u
current_album->disc_number = disc_number;
}
-G_MODULE_EXPORT void on_contents_activate(GtkWidget *button, gpointer user_data) {
+static void on_contents_activate(GSimpleAction *action, GVariant *parameter, gpointer data) {
GError *error = NULL;
gtk_show_uri (NULL, "ghelp:sound-juicer", GDK_CURRENT_TIME, &error);
@@ -1579,6 +1613,17 @@ is_cd_duplication_available()
return FALSE;
}
+GActionEntry app_entries[] = {
+ { "re-read", on_reread_activate, NULL, NULL, NULL },
+ { "duplicate", on_duplicate_activate, NULL, NULL, NULL },
+ { "eject", on_eject_activate, NULL, NULL, NULL },
+ { "submit-tracks", on_submit_activate, NULL, NULL, NULL },
+ { "preferences", on_preferences_activate, NULL, NULL, NULL },
+ { "about", on_about_activate, NULL, NULL, NULL },
+ { "help", on_contents_activate, NULL, NULL, NULL },
+ { "quit", on_quit_activate, NULL, NULL, NULL }
+};
+
static void
startup_cb (GApplication *app, gpointer user_data)
{
@@ -1614,6 +1659,10 @@ startup_cb (GApplication *app, gpointer user_data)
gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY, http_proxy_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY_PORT, http_proxy_port_changed_cb, NULL, NULL, NULL);
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ NULL);
+
builder = gtk_builder_new ();
if (g_file_test (SOURCE_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
gtk_builder_add_from_file (builder, SOURCE_BUILDER, &error);
@@ -1621,6 +1670,15 @@ startup_cb (GApplication *app, gpointer user_data)
gtk_builder_add_from_file (builder, INSTALLED_BUILDER, &error);
}
+ if (g_file_test (SOURCE_MENU_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
+ gtk_builder_add_from_file (builder, SOURCE_MENU_BUILDER, &error);
+ } else {
+ gtk_builder_add_from_file (builder, INSTALLED_MENU_BUILDER, &error);
+ }
+
+ gtk_application_set_app_menu (GTK_APPLICATION (app),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
+
if (error != NULL) {
error_on_start (error);
g_error_free (error);
@@ -1633,8 +1691,6 @@ startup_cb (GApplication *app, gpointer user_data)
message_area_eventbox = GET_WIDGET ("message_area_eventbox");
select_all_menuitem = GET_WIDGET ("select_all");
deselect_all_menuitem = GET_WIDGET ("deselect_all");
- submit_menuitem = GET_WIDGET ("submit");
- reread_menuitem = GET_WIDGET ("re-read");
title_entry = GET_WIDGET ("title_entry");
artist_entry = GET_WIDGET ("artist_entry");
duration_label = GET_WIDGET ("duration_label");
@@ -1649,8 +1705,6 @@ startup_cb (GApplication *app, gpointer user_data)
next_menuitem = GET_WIDGET ("next_track_menuitem");
prev_menuitem = GET_WIDGET ("previous_track_menuitem");
status_bar = GET_WIDGET ("status_bar");
- duplicate = GET_WIDGET ("duplicate_menuitem");
- eject = GET_WIDGET ("eject");
{ /* ensure that the play/pause button's size is constant */
GtkWidget *fake_button1, *fake_button2;
@@ -1833,7 +1887,7 @@ startup_cb (GApplication *app, gpointer user_data)
}
/* Set whether duplication of a cd is available using the brasero tool */
- gtk_widget_set_sensitive (duplicate, FALSE);
+ set_action_enabled ("duplicate", FALSE);
duplication_enabled = is_cd_duplication_available();
gconf_bridge_bind_window_size(gconf_bridge_get(), GCONF_WINDOW, GTK_WINDOW (main_window));
@@ -1848,42 +1902,12 @@ activate_cb (GApplication *app, gpointer user_data)
gtk_window_present (GTK_WINDOW (main_window));
}
-/**
- * Clicked on duplicate in the UI (button/menu)
- */
-G_MODULE_EXPORT void on_duplicate_activate (GtkWidget *button, gpointer user_data)
+void set_action_enabled (const char *name, gboolean enabled)
{
- GError *error = NULL;
- const gchar* device;
+ GActionMap *map = G_ACTION_MAP (g_application_get_default ());
+ GAction *action = g_action_map_lookup_action (map, name);
- device = brasero_drive_get_device (drive);
- if (!g_spawn_command_line_async (g_strconcat ("brasero -c ", device, NULL), &error)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "<b>%s</b>\n\n%s\n%s: %s",
- _("Could not duplicate disc"),
- _("Sound Juicer could not duplicate the disc"),
- _("Reason"),
- error->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_error_free (error);
- }
-}
-
-/**
- * Sets the duplication buttons sensitive property if duplication is enabled.
- * This is setup in the main entry point.
- */
-static void set_duplication(gboolean enabled)
-{
- if (duplication_enabled) {
- gtk_widget_set_sensitive (duplicate, enabled);
- }
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
}
int main (int argc, char **argv)
diff --git a/src/sj-main.h b/src/sj-main.h
index 8c1a08c..3734878 100644
--- a/src/sj-main.h
+++ b/src/sj-main.h
@@ -26,9 +26,9 @@
void sj_stock_init (void);
-G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data);
+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_eject_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);
@@ -36,12 +36,8 @@ AlbumDetails* multiple_album_dialog (GList* albums);
const char* prefs_get_default_device (void);
-G_MODULE_EXPORT void on_reread_activate (GtkWidget *button, gpointer user_data);
-G_MODULE_EXPORT void on_submit_activate (GtkWidget *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_genre_edit_changed(GtkEditable *widget, gpointer user_data);
G_MODULE_EXPORT void on_year_edit_changed(GtkEditable *widget, gpointer user_data);
-G_MODULE_EXPORT void on_contents_activate(GtkWidget *button, gpointer user_data);
-G_MODULE_EXPORT void on_duplicate_activate (GtkWidget *button, gpointer user_data);
GtkWidget* sj_make_volume_button (void);
diff --git a/src/sj-play.c b/src/sj-play.c
index 5de5f2a..aadb330 100644
--- a/src/sj-play.c
+++ b/src/sj-play.c
@@ -29,6 +29,7 @@
#include "sound-juicer.h"
#include "sj-play.h"
+#include "sj-main.h"
static GstElement *pipeline = NULL;
static guint id = 0, button_change_id = 0;
@@ -111,6 +112,9 @@ _stop (void)
/* 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 ("re-read", TRUE);
+
gtk_widget_hide (seek_scale);
gtk_widget_hide (volume_button);
sj_main_set_title (NULL);
diff --git a/src/sj-prefs.c b/src/sj-prefs.c
index bdce5da..13ac22f 100644
--- a/src/sj-prefs.c
+++ b/src/sj-prefs.c
@@ -463,7 +463,7 @@ static GtkWidget *sj_audio_profile_chooser_new(void)
/**
* Clicked on Preferences in the UI
*/
-G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data)
+void show_preferences_dialog ()
{
static GtkWidget *prefs_dialog = NULL;
diff --git a/src/sj-prefs.h b/src/sj-prefs.h
index 70a4165..25a5066 100644
--- a/src/sj-prefs.h
+++ b/src/sj-prefs.h
@@ -24,7 +24,7 @@
#define SJ_PREFS_H
extern const char* prefs_get_default_device ();
-void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data);
+void show_preferences_dialog (void);
gboolean cd_drive_exists (const char *device);
void show_help (GtkWindow *parent);
@@ -32,6 +32,5 @@ void prefs_profile_changed (GtkWidget *widget, gpointer user_data);
G_MODULE_EXPORT void prefs_base_folder_changed (GtkWidget *chooser, gpointer user_data);
void prefs_path_option_changed (GtkComboBox *combo, gpointer user_data);
void prefs_file_option_changed (GtkComboBox *combo, gpointer user_data);
-G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data);
#endif /* SJ_PREFS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]