~matttbe/ubuntu/raring/rhythmbox/lp1010619_RB_2.98

« back to all changes in this revision

Viewing changes to .pc/05_hide_on_quit.patch/shell/rb-shell.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-11-06 20:52:57 UTC
  • mfrom: (1.1.67) (214.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20121106205257-0btjh8jqley153el
Tags: 2.98-0ubuntu1
* New upstream release (LP: #1060601)
* debian/control.in:
  - Bump minimum glib, gtk, totem-plparser, clutter, and clutter-gst
  - Drop no longer needed musicbrainz dependency
* Refreshed 09_keywords.patch
* Updated 11_fix_cd_pausing.patch with fix from git
* Dropped patches applied in new version:
  - 00git_musicbrainz5.patch
  - 08_CVE-2012-3355.patch
  - dont_free_consumed_floating_gvariant.patch
  - git_scale_click.patch
  - git_crash_during_monitor.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
                                      RBShell *shell);
169
169
static void rb_shell_cmd_plugins (GtkAction *action,
170
170
                                  RBShell *shell);
171
 
static void rb_shell_cmd_add_folder_to_library (GtkAction *action,
172
 
                                                RBShell *shell);
173
 
static void rb_shell_cmd_add_file_to_library (GtkAction *action,
174
 
                                              RBShell *shell);
 
171
static void rb_shell_cmd_add_music (GtkAction *action, RBShell *shell);
175
172
 
176
173
static void rb_shell_cmd_current_song (GtkAction *action,
177
174
                                       RBShell *shell);
283
280
 
284
281
        guint async_state_save_id;
285
282
        guint save_playlist_id;
286
 
        guint save_db_id;
287
283
 
288
284
        gboolean shutting_down;
289
285
        gboolean load_complete;
344
340
        { "Tools", NULL, N_("_Tools") },
345
341
        { "Help", NULL, N_("_Help") },
346
342
 
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) },
555
548
                return NULL;
556
549
        }
557
550
 
558
 
        s = g_string_new_len (data, data_size);
 
551
        s = g_slice_new0 (GString);
 
552
        s->str = data;
 
553
        s->len = data_size;
 
554
        s->allocated_len = data_size;
559
555
        v = g_new0 (GValue, 1);
560
556
        g_value_init (v, G_TYPE_GSTRING);
561
 
        g_value_set_boxed (v, s);
 
557
        g_value_take_boxed (v, s);
562
558
        return v;
563
559
}
564
560
 
1075
1071
        rb_profile_end ("loading plugins");
1076
1072
}
1077
1073
 
1078
 
static void
1079
 
emit_action_state_update (RBShell *shell, const char *action)
1080
 
{
1081
 
        GDBusConnection *bus;
1082
 
        GVariant *state;
1083
 
 
1084
 
 
1085
 
        bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
1086
 
 
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);
1089
 
        if (bus != NULL) {
1090
 
                g_dbus_connection_emit_signal (bus,
1091
 
                                               NULL,
1092
 
                                               "/org/gnome/Rhythmbox3",
1093
 
                                               "org.gtk.Actions",
1094
 
                                               "StateChanged",
1095
 
                                               g_variant_new ("(sv)", action, state),
1096
 
                                               NULL);
1097
 
                g_object_unref (bus);
1098
 
        }
1099
 
        g_variant_unref (state);
1100
 
}
1101
 
 
1102
1074
static gboolean
1103
1075
_scan_idle (RBShell *shell)
1104
1076
{
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");
1115
1086
        }
1116
1087
 
1117
1088
        return FALSE;
1824
1795
}
1825
1796
 
1826
1797
static gboolean
1827
 
idle_save_rhythmdb (RBShell *shell)
1828
 
{
1829
 
        rhythmdb_save (shell->priv->db);
1830
 
 
1831
 
        shell->priv->save_db_id = 0;
1832
 
 
1833
 
        return FALSE;
1834
 
}
1835
 
 
1836
 
static gboolean
1837
1798
idle_save_playlist_manager (RBShell *shell)
1838
1799
{
1839
1800
        GDK_THREADS_ENTER ();
1893
1854
                shell->priv->save_playlist_id = 0;
1894
1855
        }
1895
1856
 
1896
 
        if (shell->priv->save_db_id > 0) {
1897
 
                g_source_remove (shell->priv->save_db_id);
1898
 
                shell->priv->save_db_id = 0;
1899
 
        }
1900
 
 
1901
1857
        if (shell->priv->queue_sidebar != NULL) {
1902
1858
                g_object_unref (shell->priv->queue_sidebar);
1903
1859
        }
2067
2023
rb_shell_constructed (GObject *object)
2068
2024
{
2069
2025
        RBShell *shell;
2070
 
        GSimpleActionGroup *actions;
2071
2026
        GSimpleAction *action;
2072
2027
 
2073
2028
        gtk_init (NULL, NULL);
2077
2032
        shell = RB_SHELL (object);
2078
2033
 
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);
2085
2039
 
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);
2090
2044
 
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);
2095
2049
 
2096
 
        g_application_set_action_group (G_APPLICATION (shell), G_ACTION_GROUP (actions));
2097
 
 
2098
2050
        /* construct enough of the rest of it to display the window if required */
2099
2051
 
2100
2052
        shell->priv->settings = g_settings_new ("org.gnome.rhythmbox");
2110
2062
                                             rb_shell_n_toggle_entries,
2111
2063
                                             shell);
2112
2064
 
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"));
2117
2069
 
2909
2861
}
2910
2862
 
2911
2863
static void
2912
 
add_to_library_response_cb (GtkDialog *dialog,
2913
 
                            int response_id,
2914
 
                            RBShell *shell)
2915
 
{
2916
 
 
2917
 
        char *current_dir = NULL;
2918
 
        GSList *uri_list = NULL, *uris = NULL;
2919
 
        GSettings *library_settings;
2920
 
 
2921
 
        if (response_id != GTK_RESPONSE_ACCEPT) {
2922
 
                gtk_widget_destroy (GTK_WIDGET (dialog));
2923
 
                return;
2924
 
        }
2925
 
 
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);
2930
 
 
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));
2934
 
        }
2935
 
 
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);
2939
 
        }
2940
 
        g_slist_free (uri_list);
2941
 
        g_free (current_dir);
2942
 
        gtk_widget_destroy (GTK_WIDGET (dialog));
2943
 
 
2944
 
        if (shell->priv->save_db_id > 0) {
2945
 
                g_source_remove (shell->priv->save_db_id);
2946
 
        }
2947
 
        shell->priv->save_db_id = g_timeout_add_seconds (10, (GSourceFunc) idle_save_rhythmdb, shell);
2948
 
}
2949
 
 
2950
 
static void
2951
 
set_current_folder_uri (RBShell *shell, GtkWidget *dialog)
2952
 
{
2953
 
        GSettings *settings;
2954
 
        char *dir;
2955
 
 
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),
2960
 
                                                         dir);
2961
 
        }
2962
 
        g_free (dir);
2963
 
        g_object_unref (settings);
2964
 
}
2965
 
 
2966
 
static void
2967
 
rb_shell_cmd_add_folder_to_library (GtkAction *action,
2968
 
                                    RBShell *shell)
2969
 
{
2970
 
        GtkWidget *dialog;
2971
 
 
2972
 
        dialog = rb_file_chooser_new (_("Import Folder into Library"),
2973
 
                                      GTK_WINDOW (shell->priv->window),
2974
 
                                      GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
2975
 
                                      FALSE);
2976
 
        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2977
 
        set_current_folder_uri (shell, dialog);
2978
 
 
2979
 
        g_signal_connect_object (G_OBJECT (dialog),
2980
 
                                 "response",
2981
 
                                 G_CALLBACK (add_to_library_response_cb),
2982
 
                                 shell, 0);
2983
 
}
2984
 
 
2985
 
static void
2986
 
rb_shell_cmd_add_file_to_library (GtkAction *action,
2987
 
                                  RBShell *shell)
2988
 
{
2989
 
        GtkWidget *dialog;
2990
 
 
2991
 
        dialog = rb_file_chooser_new (_("Import File into Library"),
2992
 
                                      GTK_WINDOW (shell->priv->window),
2993
 
                                      GTK_FILE_CHOOSER_ACTION_OPEN,
2994
 
                                      FALSE);
2995
 
        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2996
 
        set_current_folder_uri (shell, dialog);
2997
 
 
2998
 
        g_signal_connect_object (G_OBJECT (dialog),
2999
 
                                 "response",
3000
 
                                 G_CALLBACK (add_to_library_response_cb),
3001
 
                                 shell, 0);
 
2864
rb_shell_cmd_add_music (GtkAction *action, RBShell *shell)
 
2865
{
 
2866
        rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->library_source));
 
2867
        rb_library_source_show_import_dialog (shell->priv->library_source);
3002
2868
}
3003
2869
 
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");
3062
2927
        }
3063
2928
 
3064
2929
        rhythmdb_start_action_thread (shell->priv->db);
3368
3233
                RBSource *source;
3369
3234
 
3370
3235
                source = (RBSource *)t->data;
 
3236
                if (rb_source_uri_is_source (source, uri))
 
3237
                        return source;
 
3238
 
3371
3239
                s = rb_source_want_uri (source, uri);
3372
3240
                if (s > strength) {
3373
3241
                        gchar *name;