~ubuntu-branches/ubuntu/lucid/totem/lucid-updates

« back to all changes in this revision

Viewing changes to src/totem-playlist.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-10-29 16:30:01 UTC
  • mfrom: (1.10.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091029163001-urrn5sglqccz34ue
Tags: 2.28.2-0ubuntu1
* New upstream release: (LP: #463102)
  - Movie Player:
    - Fix possible crash on exit when using Python plugins
    - Fix warning when displaying file tooltip in the playlist
    - Fix help links not showing up in error messages (LP: #452510)
    - Fix "disabling screensaver when audio is playing" checkbox
      never turning off (or on)
    - Fix play order when removing currently playing song
  - Web browser plugin:
    - Fix screensaver not being stopped when playing movies (LP: #358297)
      (LP: #381116)
    - Fix parsing of playlist files when using WebKit
    - Add support for midi files
  - GStreamer backend:
    - Fix possible hang on startup
    - Fix DVB channels file not being detected properly
    - Fix warning when creating a screenshot
    - Use cubic volumes when PulseAudio is used
    - Fix intermittent pixel-aspect-ratio warnings
* debian/patches/03_screensaver_preferences.patch:
* debian/patches/71_totem_python_gil.patch:
* debian/patches/91_git_change_fix_dvb_issue.patch:
  - Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
enum {
132
132
        PLAYING_COL,
133
133
        FILENAME_COL,
 
134
        FILENAME_ESCAPED_COL,
134
135
        URI_COL,
135
136
        TITLE_CUSTOM_COL,
136
137
        SUBTITLE_URI_COL,
1631
1632
 
1632
1633
        /* tooltips */
1633
1634
        gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(playlist->priv->treeview),
1634
 
                                         FILENAME_COL);
 
1635
                                         FILENAME_ESCAPED_COL);
1635
1636
 
1636
1637
        /* The configuration */
1637
1638
        init_config (playlist);
1654
1655
}
1655
1656
 
1656
1657
static gboolean
1657
 
totem_playlist_add_one_mrl (TotemPlaylist *playlist, const char *mrl,
1658
 
                const char *display_name)
 
1658
totem_playlist_add_one_mrl (TotemPlaylist *playlist,
 
1659
                            const char *mrl,
 
1660
                            const char *display_name)
1659
1661
{
1660
1662
        GtkListStore *store;
1661
1663
        GtkTreeIter iter;
1662
 
        char *filename_for_display, *uri;
 
1664
        char *filename_for_display, *uri, *escaped_filename;
1663
1665
        GtkTreeRowReference *ref;
1664
1666
        GFileMonitor *monitor;
1665
1667
        GFile *file;
1704
1706
                monitor = NULL;
1705
1707
        }
1706
1708
 
 
1709
        escaped_filename = g_markup_escape_text (filename_for_display, -1);
1707
1710
        gtk_list_store_insert_with_values (store, &iter, pos,
1708
1711
                        PLAYING_COL, TOTEM_PLAYLIST_STATUS_NONE,
1709
1712
                        FILENAME_COL, filename_for_display,
 
1713
                        FILENAME_ESCAPED_COL, escaped_filename,
1710
1714
                        URI_COL, uri ? uri : mrl,
1711
1715
                        TITLE_CUSTOM_COL, display_name ? TRUE : FALSE,
1712
1716
                        FILE_MONITOR_COL, monitor,
1713
1717
                        -1);
 
1718
        g_free (escaped_filename);
1714
1719
 
1715
1720
        g_signal_emit (playlist,
1716
1721
                       totem_playlist_table_signals[ITEM_ADDED],
1815
1820
        return TRUE;
1816
1821
}
1817
1822
 
 
1823
static int
 
1824
compare_removal (GtkTreeRowReference *ref, GtkTreePath *path)
 
1825
{
 
1826
        GtkTreePath *ref_path;
 
1827
        int ret = -1;
 
1828
 
 
1829
        ref_path = gtk_tree_row_reference_get_path (ref);
 
1830
        if (gtk_tree_path_compare (path, ref_path) == 0)
 
1831
                ret = 0;
 
1832
        gtk_tree_path_free (ref_path);
 
1833
        return ret;
 
1834
}
 
1835
 
 
1836
/* Whether the item in question will be removed */
 
1837
static gboolean
 
1838
totem_playlist_item_to_be_removed (TotemPlaylist *playlist,
 
1839
                                   GtkTreePath *path,
 
1840
                                   ClearComparisonFunc func)
 
1841
{
 
1842
        GList *ret;
 
1843
 
 
1844
        if (func == NULL) {
 
1845
                GtkTreeSelection *selection;
 
1846
 
 
1847
                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (playlist->priv->treeview));
 
1848
                return gtk_tree_selection_path_is_selected (selection, path);
 
1849
        }
 
1850
 
 
1851
        ret = g_list_find_custom (playlist->priv->list, path, (GCompareFunc) compare_removal);
 
1852
        return (ret != NULL);
 
1853
}
 
1854
 
1818
1855
static void
1819
1856
totem_playlist_clear_with_compare (TotemPlaylist *playlist,
1820
1857
                                   ClearComparisonFunc func,
1821
1858
                                   gconstpointer data)
1822
1859
{
1823
1860
        GtkTreeRowReference *ref;
1824
 
        int next_pos;
 
1861
        GtkTreeRowReference *next;
1825
1862
 
1826
1863
        ref = NULL;
1827
 
        next_pos = -1;
 
1864
        next = NULL;
1828
1865
 
1829
1866
        if (func == NULL) {
1830
1867
                GtkTreeSelection *selection;
1861
1898
 
1862
1899
                                path = gtk_tree_path_new_from_indices (i, -1);
1863
1900
                                r = gtk_tree_row_reference_new (playlist->priv->model, path);
1864
 
                                if (playlist->priv->current != NULL) {
1865
 
                                        if (gtk_tree_path_compare (path, playlist->priv->current) == 0)
 
1901
                                if (playlist->priv->current_to_be_removed == FALSE && playlist->priv->current != NULL) {
 
1902
                                        if (gtk_tree_path_compare (path, playlist->priv->current) == 0) {
1866
1903
                                                playlist->priv->current_to_be_removed = TRUE;
 
1904
                                        }
1867
1905
                                }
1868
1906
                                playlist->priv->list = g_list_prepend (playlist->priv->list, r);
1869
1907
                                gtk_tree_path_free (path);
1876
1914
 
1877
1915
        /* If the current item is to change, we need to keep an static
1878
1916
         * reference to it, TreeIter and TreePath don't allow that */
1879
 
        if (playlist->priv->current != NULL) {
1880
 
                int *indices;
1881
 
 
 
1917
        if (playlist->priv->current_to_be_removed == FALSE &&
 
1918
            playlist->priv->current != NULL) {
1882
1919
                ref = gtk_tree_row_reference_new (playlist->priv->model,
1883
 
                                playlist->priv->current);
1884
 
                indices = gtk_tree_path_get_indices (playlist->priv->current);
1885
 
                next_pos = indices[0];
 
1920
                                                  playlist->priv->current);
 
1921
        } else if (playlist->priv->current != NULL) {
 
1922
                GtkTreePath *item;
1886
1923
 
 
1924
                item = gtk_tree_path_copy (playlist->priv->current);
 
1925
                gtk_tree_path_next (item);
 
1926
                next = gtk_tree_row_reference_new (playlist->priv->model, item);
 
1927
                while (next != NULL) {
 
1928
                        if (totem_playlist_item_to_be_removed (playlist, item, func) == FALSE) {
 
1929
                                /* Found the item after the current one that
 
1930
                                 * won't be removed, thus the new current */
 
1931
                                break;
 
1932
                        }
 
1933
                        gtk_tree_row_reference_free (next);
 
1934
                        gtk_tree_path_next (item);
 
1935
                        next = gtk_tree_row_reference_new (playlist->priv->model, item);
 
1936
                }
1887
1937
        }
1888
1938
 
1889
1939
        /* We destroy the items, one-by-one from the list built above */
1890
 
        while (playlist->priv->list != NULL)
1891
 
        {
 
1940
        while (playlist->priv->list != NULL) {
1892
1941
                GtkTreePath *path;
1893
1942
                GtkTreeIter iter;
1894
1943
 
1910
1959
 
1911
1960
        if (playlist->priv->current_to_be_removed != FALSE) {
1912
1961
                /* The current item was removed from the playlist */
1913
 
                if (next_pos != -1) {
1914
 
                        char *str;
1915
 
                        GtkTreeIter iter;
1916
 
                        GtkTreePath *cur;
1917
 
 
1918
 
                        str = g_strdup_printf ("%d", next_pos);
1919
 
                        cur = gtk_tree_path_new_from_string (str);
1920
 
 
1921
 
                        if (gtk_tree_model_get_iter (playlist->priv->model, &iter, cur) == FALSE) {
1922
 
                                playlist->priv->current = NULL;
1923
 
                                gtk_tree_path_free (cur);
1924
 
                        } else {
1925
 
                                playlist->priv->current = cur;
1926
 
                        }
1927
 
                        g_free (str);
 
1962
                if (next != NULL) {
 
1963
                        playlist->priv->current = gtk_tree_row_reference_get_path (next);
 
1964
                        gtk_tree_row_reference_free (next);
1928
1965
                } else {
1929
1966
                        playlist->priv->current = NULL;
1930
1967
                }
1939
1976
        } else {
1940
1977
                if (ref != NULL) {
1941
1978
                        /* The path to the current item changed */
1942
 
                        playlist->priv->current =
1943
 
                                gtk_tree_row_reference_get_path (ref);
1944
 
                        gtk_tree_row_reference_free (ref);
 
1979
                        playlist->priv->current = gtk_tree_row_reference_get_path (ref);
1945
1980
                }
1946
1981
 
1947
1982
                if (playlist->priv->shuffle)
1951
1986
                                totem_playlist_table_signals[CHANGED], 0,
1952
1987
                                NULL);
1953
1988
        }
 
1989
        if (ref != NULL)
 
1990
                gtk_tree_row_reference_free (ref);
1954
1991
        totem_playlist_update_save_button (playlist);
1955
1992
        gtk_tree_view_columns_autosize (GTK_TREE_VIEW (playlist->priv->treeview));
1956
1993
 
2139
2176
        GtkListStore *store;
2140
2177
        GtkTreeIter iter;
2141
2178
        gboolean custom_title;
 
2179
        char *escaped_title;
2142
2180
 
2143
2181
        g_return_val_if_fail (TOTEM_IS_PLAYLIST (playlist), FALSE);
2144
2182
 
2161
2199
                        return TRUE;
2162
2200
        }
2163
2201
 
 
2202
        escaped_title = g_markup_escape_text (title, -1);
2164
2203
        gtk_list_store_set (store, &iter,
2165
2204
                        FILENAME_COL, title,
 
2205
                        FILENAME_ESCAPED_COL, escaped_title,
2166
2206
                        TITLE_CUSTOM_COL, TRUE,
2167
2207
                        -1);
 
2208
        g_free (escaped_title);
2168
2209
 
2169
2210
        g_signal_emit (playlist,
2170
2211
                       totem_playlist_table_signals[ACTIVE_NAME_CHANGED], 0);
2283
2324
 
2284
2325
        g_return_if_fail (TOTEM_IS_PLAYLIST (playlist));
2285
2326
 
2286
 
        if (totem_playlist_has_next_mrl (playlist) == FALSE)
2287
 
        {
 
2327
        if (totem_playlist_has_next_mrl (playlist) == FALSE) {
2288
2328
                totem_playlist_set_at_start (playlist);
2289
2329
                return;
2290
2330
        }
2291
2331
 
2292
2332
        totem_playlist_unset_playing (playlist);
2293
2333
 
2294
 
        if (playlist->priv->shuffle == FALSE)
2295
 
        {
 
2334
        if (playlist->priv->shuffle == FALSE) {
2296
2335
                gtk_tree_model_get_iter (playlist->priv->model,
2297
 
                                &iter,
2298
 
                                playlist->priv->current);
 
2336
                                         &iter,
 
2337
                                         playlist->priv->current);
2299
2338
 
2300
2339
                gtk_tree_model_iter_next (playlist->priv->model, &iter);
2301
2340
                gtk_tree_path_free (playlist->priv->current);
2302
 
                playlist->priv->current = gtk_tree_model_get_path
2303
 
                        (playlist->priv->model, &iter);
 
2341
                playlist->priv->current = gtk_tree_model_get_path (playlist->priv->model, &iter);
2304
2342
        } else {
2305
2343
                int indice;
2306
2344