344
340
{ "Tools", NULL, N_("_Tools") },
345
341
{ "Help", NULL, N_("_Help") },
347
{ "MusicImportFolder", GTK_STOCK_OPEN, N_("_Import Folder..."), "<control>O",
348
N_("Choose folder to be added to the Library"),
349
G_CALLBACK (rb_shell_cmd_add_folder_to_library) },
350
{ "MusicImportFile", GTK_STOCK_FILE, N_("Import _File..."), NULL,
351
N_("Choose file to be added to the Library"),
352
G_CALLBACK (rb_shell_cmd_add_file_to_library) },
343
{ "MusicAdd", GTK_STOCK_OPEN, N_("Add Music..."), "<control>O",
344
N_("Add music to the library"),
345
G_CALLBACK (rb_shell_cmd_add_music) },
353
346
{ "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
354
347
N_("Show information about Rhythmbox"),
355
348
G_CALLBACK (rb_shell_cmd_about) },
1075
1071
rb_profile_end ("loading plugins");
1079
emit_action_state_update (RBShell *shell, const char *action)
1081
GDBusConnection *bus;
1085
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
1087
state = g_action_group_get_action_state (G_ACTION_GROUP (shell), action);
1088
g_signal_emit_by_name (shell, "action-state-changed::LoadURI", "LoadURI", state);
1090
g_dbus_connection_emit_signal (bus,
1092
"/org/gnome/Rhythmbox3",
1095
g_variant_new ("(sv)", action, state),
1097
g_object_unref (bus);
1099
g_variant_unref (state);
1102
1074
static gboolean
1103
1075
_scan_idle (RBShell *shell)
1111
1083
if (shell->priv->no_registration == FALSE) {
1112
1084
g_variant_get (g_action_group_get_action_state (G_ACTION_GROUP (shell), "LoadURI"), "(bb)", &loaded, &scanned);
1113
1085
g_action_group_change_action_state (G_ACTION_GROUP (shell), "LoadURI", g_variant_new ("(bb)", loaded, TRUE));
1114
emit_action_state_update (shell, "LoadURI");
2077
2032
shell = RB_SHELL (object);
2079
2034
/* create application actions */
2080
actions = g_simple_action_group_new ();
2081
2035
action = g_simple_action_new_stateful ("LoadURI", G_VARIANT_TYPE ("(sb)"), g_variant_new ("(bb)", FALSE, FALSE));
2082
2036
g_signal_connect_object (action, "activate", G_CALLBACK (load_uri_action_cb), shell, 0);
2083
g_simple_action_group_insert (actions, G_ACTION (action));
2037
g_action_map_add_action (G_ACTION_MAP (shell), G_ACTION (action));
2084
2038
g_object_unref (action);
2086
2040
action = g_simple_action_new ("ActivateSource", G_VARIANT_TYPE ("(su)"));
2087
2041
g_signal_connect_object (action, "activate", G_CALLBACK (activate_source_action_cb), shell, 0);
2088
g_simple_action_group_insert (actions, G_ACTION (action));
2042
g_action_map_add_action (G_ACTION_MAP (shell), G_ACTION (action));
2089
2043
g_object_unref (action);
2091
2045
action = g_simple_action_new ("Quit", NULL);
2092
2046
g_signal_connect_object (action, "activate", G_CALLBACK (quit_action_cb), shell, 0);
2093
g_simple_action_group_insert (actions, G_ACTION (action));
2047
g_action_map_add_action (G_ACTION_MAP (shell), G_ACTION (action));
2094
2048
g_object_unref (action);
2096
g_application_set_action_group (G_APPLICATION (shell), G_ACTION_GROUP (actions));
2098
2050
/* construct enough of the rest of it to display the window if required */
2100
2052
shell->priv->settings = g_settings_new ("org.gnome.rhythmbox");
2110
2062
rb_shell_n_toggle_entries,
2113
/* Translators: this is the short label for the 'import folder' action */
2114
gtk_action_set_short_label (gtk_action_group_get_action (shell->priv->actiongroup, "MusicImportFolder"), C_("Library", "Import"));
2065
/* Translators: this is the short label for the 'add music' action */
2066
gtk_action_set_short_label (gtk_action_group_get_action (shell->priv->actiongroup, "MusicAdd"), C_("Library", "Import"));
2115
2067
/* Translators: this is the short label for the 'view all tracks' action */
2116
2068
gtk_action_set_short_label (gtk_action_group_get_action (shell->priv->actiongroup, "ViewAll"), _("Show All"));
2912
add_to_library_response_cb (GtkDialog *dialog,
2917
char *current_dir = NULL;
2918
GSList *uri_list = NULL, *uris = NULL;
2919
GSettings *library_settings;
2921
if (response_id != GTK_RESPONSE_ACCEPT) {
2922
gtk_widget_destroy (GTK_WIDGET (dialog));
2926
library_settings = g_settings_new ("org.gnome.rhythmbox.library");
2927
current_dir = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog));
2928
g_settings_set_string (library_settings, "add-dir", current_dir);
2929
g_object_unref (library_settings);
2931
uri_list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
2932
if (uri_list == NULL) {
2933
uri_list = g_slist_prepend (uri_list, g_strdup (current_dir));
2936
for (uris = uri_list; uris; uris = uris->next) {
2937
rb_shell_load_uri (shell, (char *)uris->data, FALSE, NULL);
2938
g_free (uris->data);
2940
g_slist_free (uri_list);
2941
g_free (current_dir);
2942
gtk_widget_destroy (GTK_WIDGET (dialog));
2944
if (shell->priv->save_db_id > 0) {
2945
g_source_remove (shell->priv->save_db_id);
2947
shell->priv->save_db_id = g_timeout_add_seconds (10, (GSourceFunc) idle_save_rhythmdb, shell);
2951
set_current_folder_uri (RBShell *shell, GtkWidget *dialog)
2953
GSettings *settings;
2956
settings = g_settings_new ("org.gnome.rhythmbox.library");
2957
dir = g_settings_get_string (settings, "add-dir");
2958
if (dir && dir[0] != '\0') {
2959
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
2963
g_object_unref (settings);
2967
rb_shell_cmd_add_folder_to_library (GtkAction *action,
2972
dialog = rb_file_chooser_new (_("Import Folder into Library"),
2973
GTK_WINDOW (shell->priv->window),
2974
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
2976
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2977
set_current_folder_uri (shell, dialog);
2979
g_signal_connect_object (G_OBJECT (dialog),
2981
G_CALLBACK (add_to_library_response_cb),
2986
rb_shell_cmd_add_file_to_library (GtkAction *action,
2991
dialog = rb_file_chooser_new (_("Import File into Library"),
2992
GTK_WINDOW (shell->priv->window),
2993
GTK_FILE_CHOOSER_ACTION_OPEN,
2995
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2996
set_current_folder_uri (shell, dialog);
2998
g_signal_connect_object (G_OBJECT (dialog),
3000
G_CALLBACK (add_to_library_response_cb),
2864
rb_shell_cmd_add_music (GtkAction *action, RBShell *shell)
2866
rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->library_source));
2867
rb_library_source_show_import_dialog (shell->priv->library_source);
3004
2870
static gboolean
3058
2924
if (shell->priv->no_registration == FALSE) {
3059
2925
g_variant_get (g_action_group_get_action_state (G_ACTION_GROUP (shell), "LoadURI"), "(bb)", &loaded, &scanned);
3060
2926
g_action_group_change_action_state (G_ACTION_GROUP (shell), "LoadURI", g_variant_new ("(bb)", TRUE, scanned));
3061
emit_action_state_update (shell, "LoadURI");
3064
2929
rhythmdb_start_action_thread (shell->priv->db);