~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to shell/rb-shell.c

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#include <gdk/gdk.h>
48
48
#include <gdk/gdkx.h>
49
49
#include <gtk/gtk.h>
 
50
#include <girepository.h>
 
51
 
 
52
#include <libpeas/peas.h>
 
53
#include <libpeas-gtk/peas-gtk.h>
50
54
 
51
55
#ifdef HAVE_MMKEYS
52
56
#include <X11/XF86keysym.h>
68
72
#include "rb-playlist-manager.h"
69
73
#include "rb-removable-media-manager.h"
70
74
#include "rb-track-transfer-queue.h"
71
 
#include "rb-preferences.h"
72
75
#include "rb-shell-clipboard.h"
73
76
#include "rb-shell-player.h"
74
77
#include "rb-source-header.h"
81
84
#include "rb-playlist-source.h"
82
85
#include "rb-static-playlist-source.h"
83
86
#include "rb-play-queue-source.h"
84
 
#include "eel-gconf-extensions.h"
85
87
#include "rb-missing-files-source.h"
86
88
#include "rb-import-errors-source.h"
87
 
#include "rb-plugins-engine.h"
88
 
#include "rb-plugin-manager.h"
89
89
#include "rb-util.h"
90
90
#include "rb-display-page-model.h"
91
91
#include "rb-song-info.h"
97
97
 
98
98
#include "eggsmclient.h"
99
99
 
 
100
#define UNINSTALLED_PLUGINS_LOCATION "plugins"
 
101
 
100
102
#define PLAYING_ENTRY_NOTIFY_TIME 4
101
103
 
102
104
static void rb_shell_class_init (RBShellClass *klass);
172
174
static void rb_shell_play_entry (RBShell *shell, RhythmDBEntry *entry);
173
175
static void rb_shell_cmd_view_all (GtkAction *action,
174
176
                                   RBShell *shell);
175
 
static void rb_shell_view_sidepane_changed_cb (GtkAction *action,
176
 
                                                 RBShell *shell);
177
 
static void rb_shell_view_toolbar_changed_cb (GtkAction *action,
178
 
                                              RBShell *shell);
179
177
static void rb_shell_view_party_mode_changed_cb (GtkAction *action,
180
178
                                                 RBShell *shell);
181
179
static void rb_shell_view_smalldisplay_changed_cb (GtkAction *action,
185
183
static void rb_shell_view_queue_as_sidebar_changed_cb (GtkAction *action,
186
184
                                                       RBShell *shell);
187
185
static void rb_shell_load_complete_cb (RhythmDB *db, RBShell *shell);
188
 
static void rb_shell_sync_sidepane_visibility (RBShell *shell);
189
186
static void rb_shell_sync_toolbar_state (RBShell *shell);
190
187
static void rb_shell_sync_smalldisplay (RBShell *shell);
191
188
static void rb_shell_sync_pane_visibility (RBShell *shell);
193
190
static void rb_shell_set_visibility (RBShell *shell,
194
191
                                     gboolean initial,
195
192
                                     gboolean visible);
196
 
static void sidepane_visibility_changed_cb (GConfClient *client,
197
 
                                            guint cnxn_id,
198
 
                                            GConfEntry *entry,
199
 
                                            RBShell *shell);
200
 
static void toolbar_state_changed_cb (GConfClient *client,
201
 
                                      guint cnxn_id,
202
 
                                      GConfEntry *entry,
203
 
                                      RBShell *shell);
204
 
static void smalldisplay_changed_cb (GConfClient *client,
205
 
                                     guint cnxn_id,
206
 
                                     GConfEntry *entry,
207
 
                                     RBShell *shell);
208
193
static void display_page_tree_drag_received_cb (RBDisplayPageTree *display_page_tree,
209
194
                                                RBDisplayPage *page,
210
195
                                                GtkSelectionData *data,
213
198
static void paned_size_allocate_cb (GtkWidget *widget,
214
199
                                    GtkAllocation *allocation,
215
200
                                    RBShell *shell);
216
 
static void sidebar_paned_size_allocate_cb (GtkWidget *widget,
217
 
                                            GtkAllocation *allocation,
218
 
                                            RBShell *shell);
219
201
static void rb_shell_volume_widget_changed_cb (GtkScaleButton *vol,
220
202
                                               gdouble volume,
221
203
                                               RBShell *shell);
222
204
static void rb_shell_player_volume_changed_cb (RBShellPlayer *player,
223
205
                                               GParamSpec *arg,
224
206
                                               RBShell *shell);
 
207
static void settings_changed_cb (GSettings *settings, const char *key, RBShell *shell);
225
208
 
226
209
static void rb_shell_session_init (RBShell *shell);
227
210
 
256
239
        PROP_DISABLE_PLUGINS
257
240
};
258
241
 
259
 
/* prefs */
260
 
#define CONF_STATE_WINDOW_WIDTH     CONF_PREFIX "/state/window_width"
261
 
#define CONF_STATE_WINDOW_HEIGHT    CONF_PREFIX "/state/window_height"
262
 
#define CONF_STATE_SMALL_WIDTH      CONF_PREFIX "/state/small_width"
263
 
#define CONF_STATE_WINDOW_MAXIMIZED CONF_PREFIX "/state/window_maximized"
264
 
#define CONF_STATE_ADD_DIR          CONF_PREFIX "/state/add_dir"
265
 
#define CONF_STATE_PANED_POSITION   CONF_PREFIX "/state/paned_position"
266
 
#define CONF_STATE_RIGHT_PANED_POSITION   CONF_PREFIX "/state/right_paned_position"
267
 
#define CONF_STATE_WINDOW_X_POSITION CONF_PREFIX "/state/window_x_position"
268
 
#define CONF_STATE_WINDOW_Y_POSITION CONF_PREFIX "/state/window_y_position"
269
 
#define CONF_STATE_SOURCELIST_HEIGHT CONF_PREFIX "/state/sourcelist_height"
270
 
 
271
242
enum
272
243
{
273
244
        VISIBILITY_CHANGED,
360
331
        guint smalldisplay_notify_id;
361
332
 
362
333
        glong last_small_time; /* when we last changed small mode */
363
 
 
364
 
        /* Cached copies of the gconf keys.
365
 
         *
366
 
         * To avoid race conditions, the only time the keys are actually read is at startup
367
 
         */
368
 
        guint window_width;
369
 
        guint window_height;
370
 
        guint small_width;
371
 
        gboolean window_maximised;
372
 
        gboolean window_small;
373
 
        gboolean queue_as_sidebar;
374
 
        gboolean statusbar_hidden;
375
334
        gboolean party_mode;
376
 
        gint window_x;
377
 
        gint window_y;
378
 
        gint paned_position;
379
 
        gint right_paned_position;
380
 
        gint display_page_tree_height;
 
335
 
 
336
        GSettings *settings;
 
337
 
 
338
        GSettings *plugin_settings;
 
339
        PeasEngine *plugin_engine;
 
340
        PeasExtensionSet *activatable;
381
341
};
382
342
 
383
 
#define RB_SHELL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_SHELL, RBShellPrivate))
384
343
 
385
344
static GtkActionEntry rb_shell_actions [] =
386
345
{
425
384
{
426
385
        { "ViewSidePane", NULL, N_("Side _Pane"), "F9",
427
386
          N_("Change the visibility of the side pane"),
428
 
          G_CALLBACK (rb_shell_view_sidepane_changed_cb), TRUE },
 
387
          NULL, TRUE },
429
388
        { "ViewToolbar", NULL, N_("T_oolbar"), NULL,
430
389
          N_("Change the visibility of the toolbar"),
431
 
          G_CALLBACK (rb_shell_view_toolbar_changed_cb), TRUE },
 
390
          NULL, TRUE },
432
391
        { "ViewSmallDisplay", NULL, N_("_Small Display"), "<control>D",
433
392
          N_("Make the main window smaller"),
434
393
          G_CALLBACK (rb_shell_view_smalldisplay_changed_cb), },
886
845
static void
887
846
rb_shell_init (RBShell *shell)
888
847
{
889
 
        shell->priv = RB_SHELL_GET_PRIVATE (shell);
 
848
        shell->priv = G_TYPE_INSTANCE_GET_PRIVATE (shell, RB_TYPE_SHELL, RBShellPrivate);
890
849
 
891
850
        rb_user_data_dir ();
892
851
 
893
852
        rb_shell_session_init (shell);
894
 
 
895
 
        eel_gconf_monitor_add (CONF_PREFIX);
896
853
}
897
854
 
898
855
static void
1091
1048
        display = gtk_widget_get_display (shell->priv->window);
1092
1049
        gtk_widget_hide (shell->priv->window);
1093
1050
        gdk_display_sync (display);
 
1051
 
 
1052
        if (shell->priv->plugin_engine != NULL) {
 
1053
                g_object_unref (shell->priv->plugin_engine);
 
1054
                shell->priv->plugin_engine = NULL;
 
1055
        }
 
1056
        if (shell->priv->activatable != NULL) {
 
1057
                g_object_unref (shell->priv->activatable);
 
1058
                shell->priv->activatable = NULL;
 
1059
        }
 
1060
        if (shell->priv->plugin_settings != NULL) {
 
1061
                g_object_unref (shell->priv->plugin_settings);
 
1062
                shell->priv->plugin_settings = NULL;
 
1063
        }
1094
1064
}
1095
1065
 
1096
1066
static void
1102
1072
 
1103
1073
        rb_shell_player_stop (shell->priv->player_shell);
1104
1074
 
1105
 
        eel_gconf_monitor_remove (CONF_PREFIX);
1106
 
        eel_gconf_notification_remove (shell->priv->sidepane_visibility_notify_id);
1107
 
        eel_gconf_notification_remove (shell->priv->toolbar_visibility_notify_id);
1108
 
        eel_gconf_notification_remove (shell->priv->toolbar_style_notify_id);
1109
 
        eel_gconf_notification_remove (shell->priv->smalldisplay_notify_id);
 
1075
        if (shell->priv->settings != NULL) {
 
1076
                rb_settings_delayed_sync (shell->priv->settings, NULL, NULL, NULL);
 
1077
                g_object_unref (shell->priv->settings);
 
1078
        }
1110
1079
 
1111
1080
        g_free (shell->priv->cached_title);
1112
1081
 
1214
1183
static void
1215
1184
construct_db (RBShell *shell)
1216
1185
{
1217
 
        GError *error = NULL;
1218
1186
        char *pathname;
1219
1187
 
1220
1188
        /* Initialize the database */
1224
1192
        if (shell->priv->rhythmdb_file) {
1225
1193
                pathname = g_strdup (shell->priv->rhythmdb_file);
1226
1194
        } else {
1227
 
                pathname = rb_find_user_data_file ("rhythmdb.xml", &error);
1228
 
                if (error != NULL) {
1229
 
                        rb_error_dialog (GTK_WINDOW (shell->priv->window),
1230
 
                                         _("Unable to move user data files"),
1231
 
                                         "%s", error->message);
1232
 
                        g_error_free (error);
1233
 
                }
 
1195
                pathname = rb_find_user_data_file ("rhythmdb.xml");
1234
1196
        }
1235
1197
 
1236
1198
#ifdef WITH_RHYTHMDB_TREE
1408
1370
 
1409
1371
        g_signal_connect_object (G_OBJECT (shell->priv->queue_paned),
1410
1372
                                 "size-allocate",
1411
 
                                 G_CALLBACK (sidebar_paned_size_allocate_cb),
 
1373
                                 G_CALLBACK (paned_size_allocate_cb),
1412
1374
                                 shell, 0);
1413
1375
        gtk_widget_show (shell->priv->paned);
1414
1376
 
1431
1393
construct_sources (RBShell *shell)
1432
1394
{
1433
1395
        RBDisplayPage *page_group;
1434
 
        GError *error = NULL;
1435
1396
        char *pathname;
1436
1397
 
1437
1398
        rb_profile_start ("constructing sources");
1457
1418
        if (shell->priv->playlists_file) {
1458
1419
                pathname = g_strdup (shell->priv->playlists_file);
1459
1420
        } else {
1460
 
                pathname = rb_find_user_data_file ("playlists.xml", &error);
1461
 
                if (error != NULL) {
1462
 
                        rb_error_dialog (GTK_WINDOW (shell->priv->window),
1463
 
                                         _("Unable to move user data files"),
1464
 
                                         "%s", error->message);
1465
 
                        g_error_free (error);
1466
 
                }
 
1421
                pathname = rb_find_user_data_file ("playlists.xml");
1467
1422
        }
1468
1423
 
1469
1424
        /* Initialize playlist manager */
1522
1477
        toolbar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar");
1523
1478
        gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
1524
1479
                                     GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
 
1480
        g_settings_bind (shell->priv->settings, "toolbar-visible",
 
1481
                         toolbar, "visible",
 
1482
                         G_SETTINGS_BIND_DEFAULT);
1525
1483
        gtk_box_pack_start (GTK_BOX (shell->priv->main_vbox), toolbar, FALSE, FALSE, 0);
1526
1484
        gtk_box_reorder_child (GTK_BOX (shell->priv->main_vbox), toolbar, 1);
1527
 
        gtk_widget_show (toolbar);
1528
1485
 
1529
1486
        shell->priv->volume_button = gtk_volume_button_new ();
1530
1487
        g_signal_connect (shell->priv->volume_button, "value-changed",
1557
1514
        rb_profile_end ("loading ui");
1558
1515
}
1559
1516
 
 
1517
static void
 
1518
extension_added_cb (PeasExtensionSet *set, PeasPluginInfo *info, PeasExtension *extension, RBShell *shell)
 
1519
{
 
1520
        rb_debug ("activating extension %s", peas_plugin_info_get_name (info));
 
1521
        peas_extension_call (extension, "activate");
 
1522
}
 
1523
 
 
1524
static void
 
1525
extension_removed_cb (PeasExtensionSet *set, PeasPluginInfo *info, PeasExtension *extension, RBShell *shell)
 
1526
{
 
1527
        rb_debug ("deactivating extension %s", peas_plugin_info_get_name (info));
 
1528
        peas_extension_call (extension, "deactivate");
 
1529
}
 
1530
 
 
1531
static void
 
1532
construct_plugins (RBShell *shell)
 
1533
{
 
1534
        char *typelib_dir;
 
1535
        char *plugindir;
 
1536
        char *plugindatadir;
 
1537
        const GList *plugins;
 
1538
        const GList *l;
 
1539
        GError *error = NULL;
 
1540
 
 
1541
        if (shell->priv->disable_plugins) {
 
1542
                return;
 
1543
        }
 
1544
 
 
1545
        rb_profile_start ("loading plugins");
 
1546
        shell->priv->plugin_settings = g_settings_new ("org.gnome.rhythmbox.plugins");
 
1547
 
 
1548
        shell->priv->plugin_engine = peas_engine_new ();
 
1549
        /* need an #ifdef for this? */
 
1550
        peas_engine_enable_loader (shell->priv->plugin_engine, "python");
 
1551
 
 
1552
        typelib_dir = g_build_filename (LIBDIR,
 
1553
                                        "girepository-1.0",
 
1554
                                        NULL);
 
1555
        if (g_irepository_require_private (g_irepository_get_default (),
 
1556
                                           typelib_dir, "MPID", "3.0", 0, &error) == FALSE) {
 
1557
                g_clear_error (&error);
 
1558
                if (g_irepository_require (g_irepository_get_default (), "MPID", "3.0", 0, &error) == FALSE) {
 
1559
                        g_warning ("Could not load MPID typelib: %s", error->message);
 
1560
                        g_clear_error (&error);
 
1561
                }
 
1562
        }
 
1563
 
 
1564
        if (g_irepository_require_private (g_irepository_get_default (),
 
1565
                                           typelib_dir, "RB", "3.0", 0, &error) == FALSE) {
 
1566
                g_clear_error (&error);
 
1567
                if (g_irepository_require (g_irepository_get_default (), "RB", "3.0", 0, &error) == FALSE) {
 
1568
                        g_warning ("Could not load RB typelib: %s", error->message);
 
1569
                        g_clear_error (&error);
 
1570
                }
 
1571
        }
 
1572
        g_free (typelib_dir);
 
1573
 
 
1574
        if (g_irepository_require (g_irepository_get_default (), "Peas", "1.0", 0, &error) == FALSE) {
 
1575
                g_warning ("Could not load Peas typelib: %s", error->message);
 
1576
                g_clear_error (&error);
 
1577
        }
 
1578
 
 
1579
        if (g_irepository_require (g_irepository_get_default (), "PeasGtk", "1.0", 0, &error) == FALSE) {
 
1580
                g_warning ("Could not load PeasGtk typelib: %s", error->message);
 
1581
                g_clear_error (&error);
 
1582
        }
 
1583
 
 
1584
        plugindir = g_build_filename (rb_user_data_dir (), "plugins", NULL);
 
1585
        rb_debug ("plugin search path: %s", plugindir);
 
1586
        peas_engine_add_search_path (shell->priv->plugin_engine,
 
1587
                                     plugindir,
 
1588
                                     plugindir);
 
1589
        g_free (plugindir);
 
1590
 
 
1591
        plugindir = g_build_filename (LIBDIR, "rhythmbox", "plugins", NULL);
 
1592
        plugindatadir = g_build_filename (DATADIR, "rhythmbox", "plugins", NULL);
 
1593
        rb_debug ("plugin search path: %s / %s", plugindir, plugindatadir);
 
1594
        peas_engine_add_search_path (shell->priv->plugin_engine,
 
1595
                                     plugindir,
 
1596
                                     plugindatadir);
 
1597
        g_free (plugindir);
 
1598
        g_free (plugindatadir);
 
1599
 
 
1600
#ifdef USE_UNINSTALLED_DIRS
 
1601
        plugindir = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "..", UNINSTALLED_PLUGINS_LOCATION, NULL);
 
1602
        rb_debug ("plugin search path: %s", plugindir);
 
1603
        peas_engine_add_search_path (shell->priv->plugin_engine,
 
1604
                                     plugindir,
 
1605
                                     plugindir);
 
1606
        g_free (plugindir);
 
1607
#endif
 
1608
 
 
1609
        shell->priv->activatable = peas_extension_set_new (shell->priv->plugin_engine,
 
1610
                                                           PEAS_TYPE_ACTIVATABLE,
 
1611
                                                           "object", shell,
 
1612
                                                           NULL);
 
1613
        g_signal_connect (shell->priv->activatable, "extension-added", G_CALLBACK (extension_added_cb), shell);
 
1614
        g_signal_connect (shell->priv->activatable, "extension-removed", G_CALLBACK (extension_removed_cb), shell);
 
1615
 
 
1616
        g_settings_bind (shell->priv->plugin_settings,
 
1617
                         "active-plugins",
 
1618
                         shell->priv->plugin_engine,
 
1619
                         "loaded-plugins",
 
1620
                         G_SETTINGS_BIND_DEFAULT);
 
1621
 
 
1622
        /* load builtin plugins */
 
1623
        plugins = peas_engine_get_plugin_list (shell->priv->plugin_engine);
 
1624
        for (l = plugins; l != NULL; l = l->next) {
 
1625
                PeasPluginInfo *info = PEAS_PLUGIN_INFO (l->data);
 
1626
                if (peas_plugin_info_is_builtin (info) &&
 
1627
                    g_strcmp0 (peas_plugin_info_get_module_name (info), "rb") != 0) {
 
1628
                        peas_engine_load_plugin (shell->priv->plugin_engine, info);
 
1629
                }
 
1630
        }
 
1631
 
 
1632
        rb_profile_end ("loading plugins");
 
1633
}
 
1634
 
1560
1635
static gboolean
1561
1636
_scan_idle (RBShell *shell)
1562
1637
{
1571
1646
rb_shell_constructed (GObject *object)
1572
1647
{
1573
1648
        RBShell *shell;
 
1649
        GtkAction *action;
1574
1650
 
1575
1651
        RB_CHAIN_GOBJECT_METHOD (rb_shell_parent_class, constructed, object);
1576
1652
 
1579
1655
        rb_debug ("Constructing shell");
1580
1656
        rb_profile_start ("constructing shell");
1581
1657
 
 
1658
        shell->priv->settings = g_settings_new ("org.gnome.rhythmbox");
 
1659
 
1582
1660
        shell->priv->actiongroup = gtk_action_group_new ("MainActions");
1583
1661
        gtk_action_group_set_translation_domain (shell->priv->actiongroup,
1584
1662
                                                 GETTEXT_PACKAGE);
1595
1673
        /* initialize shell services */
1596
1674
        construct_widgets (shell);
1597
1675
 
1598
 
        rb_debug ("shell: adding gconf notification");
1599
 
        /* sync state */
1600
 
        shell->priv->sidepane_visibility_notify_id =
1601
 
                eel_gconf_notification_add (CONF_UI_SIDEPANE_HIDDEN,
1602
 
                                            (GConfClientNotifyFunc) sidepane_visibility_changed_cb,
1603
 
                                            shell);
1604
 
        shell->priv->toolbar_visibility_notify_id =
1605
 
                eel_gconf_notification_add (CONF_UI_TOOLBAR_HIDDEN,
1606
 
                                            (GConfClientNotifyFunc) toolbar_state_changed_cb,
1607
 
                                            shell);
1608
 
        shell->priv->toolbar_style_notify_id =
1609
 
                eel_gconf_notification_add (CONF_UI_TOOLBAR_STYLE,
1610
 
                                            (GConfClientNotifyFunc) toolbar_state_changed_cb,
1611
 
                                            shell);
1612
 
        shell->priv->smalldisplay_notify_id =
1613
 
                eel_gconf_notification_add (CONF_UI_SMALL_DISPLAY,
1614
 
                                            (GConfClientNotifyFunc) smalldisplay_changed_cb,
1615
 
                                            shell);
1616
 
 
1617
 
        /* read the cached copies of the gconf keys */
1618
 
        shell->priv->window_width = eel_gconf_get_integer (CONF_STATE_WINDOW_WIDTH);
1619
 
        shell->priv->window_height = eel_gconf_get_integer (CONF_STATE_WINDOW_HEIGHT);
1620
 
        shell->priv->small_width = eel_gconf_get_integer (CONF_STATE_SMALL_WIDTH);
1621
 
        shell->priv->window_maximised = eel_gconf_get_boolean (CONF_STATE_WINDOW_MAXIMIZED);
1622
 
        shell->priv->window_small = eel_gconf_get_boolean (CONF_UI_SMALL_DISPLAY);
1623
 
        shell->priv->queue_as_sidebar = eel_gconf_get_boolean (CONF_UI_QUEUE_AS_SIDEBAR);
1624
 
        shell->priv->window_x = eel_gconf_get_integer (CONF_STATE_WINDOW_X_POSITION);
1625
 
        shell->priv->window_y = eel_gconf_get_integer (CONF_STATE_WINDOW_Y_POSITION);
1626
 
        shell->priv->paned_position = eel_gconf_get_integer (CONF_STATE_PANED_POSITION);
1627
 
        shell->priv->right_paned_position = eel_gconf_get_integer (CONF_STATE_RIGHT_PANED_POSITION);
1628
 
        shell->priv->display_page_tree_height = eel_gconf_get_integer (CONF_STATE_SOURCELIST_HEIGHT);
1629
 
        shell->priv->statusbar_hidden = eel_gconf_get_boolean (CONF_UI_STATUSBAR_HIDDEN);
1630
 
 
1631
 
        rb_debug ("shell: syncing with gconf");
1632
 
        rb_shell_sync_sidepane_visibility (shell);
 
1676
        g_signal_connect_object (shell->priv->settings, "changed", G_CALLBACK (settings_changed_cb), shell, 0);
 
1677
 
 
1678
        action = gtk_action_group_get_action (shell->priv->actiongroup, "ViewSidePane");
 
1679
        g_settings_bind (shell->priv->settings, "display-page-tree-visible",
 
1680
                         action, "active",
 
1681
                         G_SETTINGS_BIND_DEFAULT);
 
1682
        g_settings_bind (shell->priv->settings, "display-page-tree-visible",
 
1683
                         shell->priv->sidebar_container, "visible",
 
1684
                         G_SETTINGS_BIND_DEFAULT);
 
1685
 
 
1686
        action = gtk_action_group_get_action (shell->priv->actiongroup, "ViewToolbar");
 
1687
        g_settings_bind (shell->priv->settings, "toolbar-visible",
 
1688
                         action, "active",
 
1689
                         G_SETTINGS_BIND_DEFAULT);
 
1690
 
 
1691
        rb_debug ("shell: syncing with settings");
1633
1692
        rb_shell_sync_pane_visibility (shell);
1634
1693
 
1635
1694
        g_signal_connect_object (G_OBJECT (shell->priv->db), "save-error",
1639
1698
 
1640
1699
        construct_load_ui (shell);
1641
1700
 
 
1701
        construct_plugins (shell);
 
1702
 
1642
1703
        rb_shell_sync_window_state (shell, FALSE);
1643
1704
        rb_shell_sync_smalldisplay (shell);
1644
1705
        rb_shell_sync_party_mode (shell);
1646
1707
 
1647
1708
        rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->library_source));
1648
1709
 
1649
 
        if (!shell->priv->disable_plugins)
1650
 
                rb_plugins_engine_init (shell);
1651
 
 
1652
1710
        /* by now we've added the built in sources and any sources from plugins,
1653
1711
         * so we can consider the fixed page groups loaded
1654
1712
         */
1666
1724
        rb_debug ("shell: syncing window state");
1667
1725
        rb_shell_sync_paned (shell);
1668
1726
 
1669
 
        /* Do as if we ran the first time druid */
1670
 
        if (!eel_gconf_get_boolean (CONF_FIRST_TIME))
1671
 
                eel_gconf_set_boolean (CONF_FIRST_TIME, TRUE);
1672
 
 
1673
1727
        /* set initial visibility */
1674
1728
        rb_shell_set_visibility (shell, TRUE, TRUE);
1675
1729
 
1676
1730
        gdk_notify_startup_complete ();
1677
1731
 
1678
1732
        /* focus play if small, the entry view if not */
1679
 
        if (shell->priv->window_small) {
 
1733
        if (g_settings_get_boolean (shell->priv->settings, "small-display")) {
1680
1734
                GtkWidget *play_button;
1681
1735
 
1682
1736
                play_button = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar/Play");
1712
1766
        if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
1713
1767
                gboolean maximised = ((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0);
1714
1768
 
1715
 
                if (!shell->priv->window_small) {
1716
 
                        shell->priv->window_maximised = maximised;
1717
 
                        eel_gconf_set_boolean (CONF_STATE_WINDOW_MAXIMIZED,
1718
 
                                               shell->priv->window_maximised);
 
1769
                if (!g_settings_get_boolean (shell->priv->settings, "small-display")) {
 
1770
                        g_settings_set_boolean (shell->priv->settings,
 
1771
                                                "maximized",
 
1772
                                                maximised);
1719
1773
                }
1720
1774
                rb_shell_sync_window_state (shell, TRUE);
1721
1775
                rb_shell_sync_paned (shell);
1788
1842
        rb_profile_end ("changing shell visibility");
1789
1843
}
1790
1844
 
 
1845
static void
 
1846
sync_window_settings (GSettings *settings, RBShell *shell)
 
1847
{
 
1848
        int width, height;
 
1849
        int oldx, oldy;
 
1850
        int x, y;
 
1851
        int pos;
 
1852
 
 
1853
        gtk_window_get_size (GTK_WINDOW (shell->priv->window), &width, &height);
 
1854
        if (g_settings_get_boolean (shell->priv->settings, "small-display")) {
 
1855
                if (width != g_settings_get_int (shell->priv->settings, "small-width")) {
 
1856
                        rb_debug ("storing small window width of %d", width);
 
1857
                        g_settings_set_int (shell->priv->settings, "small-width", width);
 
1858
                }
 
1859
        } else {
 
1860
                int oldwidth, oldheight;
 
1861
 
 
1862
                g_settings_get (shell->priv->settings, "size", "(ii)", &oldwidth, &oldheight);
 
1863
                if ((width != oldwidth) || (height != oldheight)) {
 
1864
                        rb_debug ("storing window size of %d:%d", width, height);
 
1865
                        g_settings_set (shell->priv->settings, "size", "(ii)", width, height);
 
1866
                }
 
1867
        }
 
1868
 
 
1869
        gtk_window_get_position (GTK_WINDOW(shell->priv->window), &x, &y);
 
1870
        g_settings_get (shell->priv->settings, "position", "(ii)", &oldx, &oldy);
 
1871
        if ((x != oldx) || (y != oldy)) {
 
1872
                rb_debug ("storing window position of %d:%d", x, y);
 
1873
                g_settings_set (shell->priv->settings, "position", "(ii)", x, y);
 
1874
        }
 
1875
 
 
1876
        pos = gtk_paned_get_position (GTK_PANED (shell->priv->paned));
 
1877
        rb_debug ("paned position %d", pos);
 
1878
 
 
1879
        if (pos != g_settings_get_int (shell->priv->settings, "paned-position")) {
 
1880
                g_settings_set_int (shell->priv->settings, "paned-position", pos);
 
1881
        }
 
1882
 
 
1883
        pos = gtk_paned_get_position (GTK_PANED (shell->priv->right_paned));
 
1884
        rb_debug ("right_paned position %d", pos);
 
1885
 
 
1886
        if (pos != g_settings_get_int (shell->priv->settings, "right-paned-position")) {
 
1887
                g_settings_set_int (shell->priv->settings, "right-paned-position", pos);
 
1888
        }
 
1889
 
 
1890
        pos = gtk_paned_get_position (GTK_PANED (shell->priv->queue_paned));
 
1891
        rb_debug ("sidebar paned position %d", pos);
 
1892
 
 
1893
        if (pos != g_settings_get_int (shell->priv->settings, "display-page-tree-height")) {
 
1894
                g_settings_set_int (shell->priv->settings, "display-page-tree-height", pos);
 
1895
        }
 
1896
}
 
1897
 
1791
1898
static gboolean
1792
1899
rb_shell_window_configure_cb (GtkWidget *win,
1793
1900
                              GdkEventConfigure *event,
1794
1901
                              RBShell *shell)
1795
1902
{
1796
 
        if (shell->priv->window_maximised || shell->priv->iconified)
 
1903
        if (g_settings_get_boolean (shell->priv->settings, "maximized") || shell->priv->iconified)
1797
1904
                return FALSE;
1798
1905
 
1799
 
        if (shell->priv->window_small) {
1800
 
                rb_debug ("storing small window width of %d", event->width);
1801
 
                shell->priv->small_width = event->width;
1802
 
                eel_gconf_set_integer (CONF_STATE_SMALL_WIDTH, event->width);
1803
 
        } else {
1804
 
                rb_debug ("storing window size of %d:%d", event->width, event->height);
1805
 
                shell->priv->window_width = event->width;
1806
 
                shell->priv->window_height = event->height;
1807
 
                eel_gconf_set_integer (CONF_STATE_WINDOW_WIDTH, event->width);
1808
 
                eel_gconf_set_integer (CONF_STATE_WINDOW_HEIGHT, event->height);
1809
 
        }
1810
 
 
1811
 
        gtk_window_get_position (GTK_WINDOW(shell->priv->window),
1812
 
                                 &shell->priv->window_x,
1813
 
                                 &shell->priv->window_y);
1814
 
        rb_debug ("storing window position of %d:%d",
1815
 
                  shell->priv->window_x,
1816
 
                  shell->priv->window_y);
1817
 
 
1818
 
        eel_gconf_set_integer (CONF_STATE_WINDOW_X_POSITION, shell->priv->window_x);
1819
 
        eel_gconf_set_integer (CONF_STATE_WINDOW_Y_POSITION, shell->priv->window_y);
1820
 
 
 
1906
        rb_settings_delayed_sync (shell->priv->settings,
 
1907
                                  (RBDelayedSyncFunc) sync_window_settings,
 
1908
                                  g_object_ref (shell),
 
1909
                                  g_object_unref);
1821
1910
        return FALSE;
1822
1911
}
1823
1912
 
1866
1955
                            gboolean dont_maximise)
1867
1956
{
1868
1957
        GdkGeometry hints;
 
1958
        int x, y;
1869
1959
 
1870
1960
        rb_profile_start ("syncing window state");
1871
1961
 
1872
 
        if (shell->priv->window_small) {
 
1962
        if (g_settings_get_boolean (shell->priv->settings, "small-display")) {
 
1963
                int width;
 
1964
 
 
1965
                width = g_settings_get_int (shell->priv->settings, "small-width");
1873
1966
                hints.min_height = -1;
1874
1967
                hints.min_width = -1;
1875
1968
                hints.max_height = -1;
1876
1969
                hints.max_width = 3000;
1877
 
                gtk_window_set_default_size (GTK_WINDOW (shell->priv->window),
1878
 
                                             shell->priv->small_width, 0);
1879
 
                gtk_window_resize (GTK_WINDOW (shell->priv->window),
1880
 
                                   shell->priv->small_width, 1);
 
1970
                gtk_window_set_default_size (GTK_WINDOW (shell->priv->window), width, 0);
 
1971
                gtk_window_resize (GTK_WINDOW (shell->priv->window), width, 1);
1881
1972
                gtk_window_set_geometry_hints (GTK_WINDOW (shell->priv->window),
1882
1973
                                                NULL,
1883
1974
                                                &hints,
1884
1975
                                                GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
1885
1976
                gtk_window_unmaximize (GTK_WINDOW (shell->priv->window));
1886
 
                rb_debug ("syncing small window width to %d", shell->priv->small_width);
 
1977
                rb_debug ("syncing small window width to %d", width);
1887
1978
        } else {
 
1979
                int width, height;
1888
1980
                if (!dont_maximise) {
1889
 
                        if (shell->priv->window_maximised)
 
1981
                        if (g_settings_get_boolean (shell->priv->settings, "maximized"))
1890
1982
                                gtk_window_maximize (GTK_WINDOW (shell->priv->window));
1891
1983
                        else
1892
1984
                                gtk_window_unmaximize (GTK_WINDOW (shell->priv->window));
1893
1985
                }
1894
1986
 
1895
 
                gtk_window_set_default_size (GTK_WINDOW (shell->priv->window),
1896
 
                                             shell->priv->window_width,
1897
 
                                             shell->priv->window_height);
1898
 
                gtk_window_resize (GTK_WINDOW (shell->priv->window),
1899
 
                                   shell->priv->window_width,
1900
 
                                   shell->priv->window_height);
 
1987
                g_settings_get (shell->priv->settings, "size", "(ii)", &width, &height);
 
1988
 
 
1989
                gtk_window_set_default_size (GTK_WINDOW (shell->priv->window), width, height);
 
1990
                gtk_window_resize (GTK_WINDOW (shell->priv->window), width, height);
1901
1991
                gtk_window_set_geometry_hints (GTK_WINDOW (shell->priv->window),
1902
1992
                                                NULL,
1903
1993
                                                &hints,
1904
1994
                                                0);
1905
1995
        }
1906
1996
 
1907
 
        gtk_window_move (GTK_WINDOW (shell->priv->window),
1908
 
                         shell->priv->window_x,
1909
 
                         shell->priv->window_y);
 
1997
        g_settings_get (shell->priv->settings, "position", "(ii)", &x, &y);
 
1998
        gtk_window_move (GTK_WINDOW (shell->priv->window), x, y);
1910
1999
        rb_profile_end ("syncing window state");
1911
2000
}
1912
2001
 
2045
2134
                              RBSource *source,
2046
2135
                              RBShell *shell)
2047
2136
{
2048
 
        shell->priv->window_small = FALSE;
2049
 
        eel_gconf_set_boolean (CONF_UI_SMALL_DISPLAY, shell->priv->window_small);
2050
 
        eel_gconf_set_boolean (CONF_UI_SIDEPANE_HIDDEN, shell->priv->window_small);
 
2137
        g_settings_set_boolean (shell->priv->settings, "small-display", FALSE);
 
2138
        g_settings_set_boolean (shell->priv->settings, "display-page-tree-visible", TRUE);
2051
2139
 
2052
2140
        rb_shell_sync_window_state (shell, FALSE);
2053
2141
}
2118
2206
        gboolean from_queue;
2119
2207
 
2120
2208
        g_object_get (player, "playing-from-queue", &from_queue, NULL);
2121
 
        if (!shell->priv->queue_as_sidebar) {
 
2209
        if (!g_settings_get_boolean (shell->priv->settings, "queue-as-sidebar")) {
2122
2210
                RBSource *source;
2123
2211
                source = rb_shell_player_get_playing_source (shell->priv->player_shell);
2124
2212
                rb_display_page_model_set_playing_source (shell->priv->display_page_model, RB_DISPLAY_PAGE (source));
2276
2364
}
2277
2365
 
2278
2366
static void
2279
 
rb_shell_view_sidepane_changed_cb (GtkAction *action,
2280
 
                                   RBShell *shell)
2281
 
{
2282
 
        eel_gconf_set_boolean (CONF_UI_SIDEPANE_HIDDEN,
2283
 
                               !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2284
 
}
2285
 
 
2286
 
static void
2287
 
rb_shell_view_toolbar_changed_cb (GtkAction *action,
2288
 
                                  RBShell *shell)
2289
 
{
2290
 
        eel_gconf_set_boolean (CONF_UI_TOOLBAR_HIDDEN,
2291
 
                               !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2292
 
}
2293
 
 
2294
 
static void
2295
2367
rb_shell_view_smalldisplay_changed_cb (GtkAction *action,
2296
2368
                                       RBShell *shell)
2297
2369
{
2304
2376
 
2305
2377
        shell->priv->last_small_time = time.tv_sec;
2306
2378
 
2307
 
        shell->priv->window_small = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2308
 
        eel_gconf_set_boolean (CONF_UI_SMALL_DISPLAY, shell->priv->window_small);
 
2379
        g_settings_set_boolean (shell->priv->settings,
 
2380
                                "small-display",
 
2381
                                gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2309
2382
}
2310
2383
 
2311
2384
static void
2312
2385
rb_shell_view_statusbar_changed_cb (GtkAction *action,
2313
2386
                                    RBShell *shell)
2314
2387
{
2315
 
        shell->priv->statusbar_hidden = !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2316
 
        eel_gconf_set_boolean (CONF_UI_STATUSBAR_HIDDEN, shell->priv->statusbar_hidden);
 
2388
        g_settings_set_boolean (shell->priv->settings,
 
2389
                                "statusbar-hidden",
 
2390
                                !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2317
2391
 
2318
2392
        rb_shell_sync_statusbar_visibility (shell);
2319
2393
}
2322
2396
rb_shell_view_queue_as_sidebar_changed_cb (GtkAction *action,
2323
2397
                                           RBShell *shell)
2324
2398
{
2325
 
        shell->priv->queue_as_sidebar = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2326
 
        eel_gconf_set_boolean (CONF_UI_QUEUE_AS_SIDEBAR, shell->priv->queue_as_sidebar);
 
2399
        gboolean queue_as_sidebar = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
2400
        /* maybe use a settings binding? */
 
2401
        g_settings_set_boolean (shell->priv->settings,
 
2402
                                "queue-as-sidebar",
 
2403
                                queue_as_sidebar);
2327
2404
 
2328
 
        if (shell->priv->queue_as_sidebar &&
 
2405
        if (queue_as_sidebar &&
2329
2406
            shell->priv->selected_page == RB_DISPLAY_PAGE (shell->priv->queue_source)) {
2330
2407
                /* queue no longer exists as a source, so change to the library */
2331
2408
                rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->library_source));
2514
2591
                                         G_CALLBACK (rb_shell_plugins_response_cb),
2515
2592
                                         NULL, 0);
2516
2593
 
2517
 
                manager = rb_plugin_manager_new ();
 
2594
                manager = peas_gtk_plugin_manager_new (NULL);
2518
2595
                gtk_widget_show_all (GTK_WIDGET (manager));
2519
 
                gtk_container_add (GTK_CONTAINER (content_area),
2520
 
                                   manager);
 
2596
                gtk_box_pack_start (GTK_BOX (content_area), manager, TRUE, TRUE, 0);
 
2597
                gtk_window_set_default_size (GTK_WINDOW (shell->priv->plugins), 600, 400);
2521
2598
        }
2522
2599
 
2523
2600
        gtk_window_present (GTK_WINDOW (shell->priv->plugins));
2531
2608
 
2532
2609
        char *current_dir = NULL;
2533
2610
        GSList *uri_list = NULL, *uris = NULL;
 
2611
        GSettings *library_settings;
2534
2612
 
2535
2613
        if (response_id != GTK_RESPONSE_ACCEPT) {
2536
2614
                gtk_widget_destroy (GTK_WIDGET (dialog));
2537
2615
                return;
2538
2616
        }
2539
2617
 
 
2618
        library_settings = g_settings_new ("org.gnome.rhythmbox.library");
2540
2619
        current_dir = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog));
2541
 
        eel_gconf_set_string (CONF_STATE_ADD_DIR, current_dir);
 
2620
        g_settings_set_string (library_settings, "add-dir", current_dir);
 
2621
        g_object_unref (library_settings);
2542
2622
 
2543
2623
        uri_list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
2544
2624
        if (uri_list == NULL) {
2560
2640
}
2561
2641
 
2562
2642
static void
 
2643
set_current_folder_uri (RBShell *shell, GtkWidget *dialog)
 
2644
{
 
2645
        GSettings *settings;
 
2646
        char *dir;
 
2647
 
 
2648
        settings = g_settings_new ("org.gnome.rhythmbox.library");
 
2649
        dir = g_settings_get_string (settings, "add-dir");
 
2650
        if (dir && dir[0] != '\0') {
 
2651
                gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
 
2652
                                                         dir);
 
2653
        }
 
2654
        g_free (dir);
 
2655
        g_object_unref (settings);
 
2656
}
 
2657
 
 
2658
static void
2563
2659
rb_shell_cmd_add_folder_to_library (GtkAction *action,
2564
2660
                                    RBShell *shell)
2565
2661
{
2566
 
        char * dir = eel_gconf_get_string (CONF_STATE_ADD_DIR);
2567
2662
        GtkWidget *dialog;
2568
2663
 
2569
2664
        dialog = rb_file_chooser_new (_("Import Folder into Library"),
2571
2666
                                      GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
2572
2667
                                      FALSE);
2573
2668
        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2574
 
        if (dir && dir[0] != '\0')
2575
 
                gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
2576
 
                                                         dir);
 
2669
        set_current_folder_uri (shell, dialog);
2577
2670
 
2578
2671
        g_signal_connect_object (G_OBJECT (dialog),
2579
2672
                                 "response",
2585
2678
rb_shell_cmd_add_file_to_library (GtkAction *action,
2586
2679
                                  RBShell *shell)
2587
2680
{
2588
 
        char * dir = eel_gconf_get_string (CONF_STATE_ADD_DIR);
2589
2681
        GtkWidget *dialog;
2590
2682
 
2591
2683
        dialog = rb_file_chooser_new (_("Import File into Library"),
2593
2685
                                      GTK_FILE_CHOOSER_ACTION_OPEN,
2594
2686
                                      FALSE);
2595
2687
        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
2596
 
        if (dir && dir[0] != '\0')
2597
 
                gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
2598
 
                                                         dir);
 
2688
        set_current_folder_uri (shell, dialog);
2599
2689
 
2600
2690
        g_signal_connect_object (G_OBJECT (dialog),
2601
2691
                                 "response",
2633
2723
        /* Stop the playing source, if any */
2634
2724
        rb_shell_player_stop (shell->priv->player_shell);
2635
2725
 
2636
 
        rb_plugins_engine_shutdown ();
2637
 
 
2638
2726
        rb_podcast_manager_shutdown (shell->priv->podcast_manager);
2639
2727
 
2640
2728
        rb_shell_shutdown (shell);
2674
2762
}
2675
2763
 
2676
2764
static void
2677
 
rb_shell_sync_sidepane_visibility (RBShell *shell)
2678
 
{
2679
 
        gboolean visible;
2680
 
        GtkAction *action;
2681
 
 
2682
 
        visible = !eel_gconf_get_boolean (CONF_UI_SIDEPANE_HIDDEN);
2683
 
 
2684
 
        if (visible) {
2685
 
                gtk_widget_show (GTK_WIDGET (shell->priv->sidebar_container));
2686
 
        } else {
2687
 
                gtk_widget_hide (GTK_WIDGET (shell->priv->sidebar_container));
2688
 
        }
2689
 
 
2690
 
        action = gtk_action_group_get_action (shell->priv->actiongroup,
2691
 
                                              "ViewSidePane");
2692
 
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2693
 
                                      visible);
2694
 
}
2695
 
 
2696
 
static void
2697
2765
rb_shell_sync_pane_visibility (RBShell *shell)
2698
2766
{
2699
2767
        GtkAction *action;
 
2768
        gboolean queue_as_sidebar = g_settings_get_boolean (shell->priv->settings, "queue-as-sidebar");
2700
2769
 
2701
2770
        if (shell->priv->queue_source != NULL) {
2702
 
                g_object_set (shell->priv->queue_source, "visibility", !shell->priv->queue_as_sidebar, NULL);
 
2771
                g_object_set (shell->priv->queue_source, "visibility", !queue_as_sidebar, NULL);
2703
2772
        }
2704
2773
 
2705
 
        if (shell->priv->queue_as_sidebar) {
 
2774
        if (queue_as_sidebar) {
2706
2775
                gtk_widget_show (shell->priv->queue_sidebar);
2707
2776
        } else {
2708
2777
                gtk_widget_hide (shell->priv->queue_sidebar);
2710
2779
 
2711
2780
        action = gtk_action_group_get_action (shell->priv->actiongroup,
2712
2781
                                              "ViewQueueAsSidebar");
2713
 
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2714
 
                                      shell->priv->queue_as_sidebar);
 
2782
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), queue_as_sidebar);
2715
2783
}
2716
2784
 
2717
2785
static void
2718
2786
rb_shell_sync_toolbar_state (RBShell *shell)
2719
2787
{
2720
2788
        GtkWidget *toolbar;
2721
 
        gboolean visible;
2722
 
        GtkAction *action;
2723
2789
        guint toolbar_style;
2724
2790
 
2725
 
        visible = !eel_gconf_get_boolean (CONF_UI_TOOLBAR_HIDDEN);
2726
 
 
2727
2791
        toolbar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/ToolBar");
2728
 
        if (visible)
2729
 
                gtk_widget_show (toolbar);
2730
 
        else
2731
 
                gtk_widget_hide (toolbar);
2732
 
 
2733
 
        action = gtk_action_group_get_action (shell->priv->actiongroup,
2734
 
                                              "ViewToolbar");
2735
 
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2736
 
                                      visible);
2737
2792
 
2738
2793
        /* icons-only in small mode */
2739
 
        if (shell->priv->window_small)
 
2794
        if (g_settings_get_boolean (shell->priv->settings, "small-display"))
2740
2795
                toolbar_style = 3;
2741
2796
        else
2742
 
                toolbar_style = eel_gconf_get_integer (CONF_UI_TOOLBAR_STYLE);
 
2797
                toolbar_style = g_settings_get_int (shell->priv->settings, "toolbar-style");
2743
2798
 
2744
2799
        switch (toolbar_style) {
2745
2800
        case 0:
2785
2840
{
2786
2841
        GtkAction *action;
2787
2842
 
2788
 
        /* party mode does not use gconf as a model since it
 
2843
        /* party mode does not use gsettings as a model since it
2789
2844
           should not be persistent */
2790
2845
 
2791
2846
        /* disable/enable quit action */
2836
2891
        jump_to_playing_action = gtk_action_group_get_action (shell->priv->actiongroup,
2837
2892
                                                              "ViewJumpToPlaying");
2838
2893
 
2839
 
        if (shell->priv->window_small) {
 
2894
        if (g_settings_get_boolean (shell->priv->settings, "small-display")) {
2840
2895
                g_object_set (action, "sensitive", FALSE, NULL);
2841
2896
                g_object_set (queue_action, "sensitive", FALSE, NULL);
2842
2897
                g_object_set (party_mode_action, "sensitive", FALSE, NULL);
2865
2920
        action = gtk_action_group_get_action (shell->priv->actiongroup,
2866
2921
                                              "ViewSmallDisplay");
2867
2922
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2868
 
                                      shell->priv->window_small);
 
2923
                                      g_settings_get_boolean (shell->priv->settings, "small-display"));
2869
2924
}
2870
2925
 
2871
2926
static void
2874
2929
        gboolean visible;
2875
2930
        GtkAction *action;
2876
2931
 
2877
 
        visible = !shell->priv->statusbar_hidden;
 
2932
        visible = !g_settings_get_boolean (shell->priv->settings, "statusbar-hidden");
2878
2933
 
2879
2934
        action = gtk_action_group_get_action (shell->priv->actiongroup, "ViewStatusbar");
2880
2935
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
2881
2936
 
2882
2937
        gtk_widget_set_visible (GTK_WIDGET (shell->priv->statusbar),
2883
 
                                visible && !shell->priv->window_small);
2884
 
}
2885
 
 
2886
 
static void
2887
 
sidepane_visibility_changed_cb (GConfClient *client,
2888
 
                                guint cnxn_id,
2889
 
                                GConfEntry *entry,
2890
 
                                RBShell *shell)
2891
 
{
2892
 
        rb_debug ("sidepane visibility changed");
2893
 
        rb_shell_sync_sidepane_visibility (shell);
2894
 
}
2895
 
 
2896
 
static void
2897
 
toolbar_state_changed_cb (GConfClient *client,
2898
 
                               guint cnxn_id,
2899
 
                               GConfEntry *entry,
2900
 
                               RBShell *shell)
2901
 
{
2902
 
        rb_debug ("toolbar state changed");
2903
 
        rb_shell_sync_toolbar_state (shell);
2904
 
}
2905
 
 
2906
 
static void
2907
 
smalldisplay_changed_cb (GConfClient *client,
2908
 
                         guint cnxn_id,
2909
 
                         GConfEntry *entry,
2910
 
                         RBShell *shell)
2911
 
{
2912
 
        rb_debug ("small display mode changed");
2913
 
        shell->priv->window_small = eel_gconf_get_boolean (CONF_UI_SMALL_DISPLAY);
2914
 
        rb_shell_sync_smalldisplay (shell);
 
2938
                                visible && !g_settings_get_boolean (shell->priv->settings, "small-display"));
 
2939
}
 
2940
 
 
2941
static void
 
2942
settings_changed_cb (GSettings *settings, const char *key, RBShell *shell)
 
2943
{
 
2944
        if (g_strcmp0 (key, "toolbar-style") == 0) {
 
2945
                rb_debug ("toolbar state changed");
 
2946
                rb_shell_sync_toolbar_state (shell);
 
2947
        } else if (g_strcmp0 (key, "small-display") == 0) {
 
2948
                rb_debug ("small display mode changed");
 
2949
                rb_shell_sync_smalldisplay (shell);
 
2950
        }
2915
2951
}
2916
2952
 
2917
2953
static void
2918
2954
rb_shell_sync_paned (RBShell *shell)
2919
2955
{
2920
2956
        gtk_paned_set_position (GTK_PANED (shell->priv->right_paned),
2921
 
                                shell->priv->right_paned_position);
 
2957
                                g_settings_get_int (shell->priv->settings, "right-paned-position"));
2922
2958
        gtk_paned_set_position (GTK_PANED (shell->priv->paned),
2923
 
                                shell->priv->paned_position);
 
2959
                                g_settings_get_int (shell->priv->settings, "paned-position"));
2924
2960
        gtk_paned_set_position (GTK_PANED (shell->priv->queue_paned),
2925
 
                                shell->priv->display_page_tree_height);
 
2961
                                g_settings_get_int (shell->priv->settings, "display-page-tree-height"));
2926
2962
}
2927
2963
 
2928
2964
static void
2930
2966
                        GtkAllocation *allocation,
2931
2967
                        RBShell *shell)
2932
2968
{
2933
 
        shell->priv->paned_position = gtk_paned_get_position (GTK_PANED (shell->priv->paned));
2934
 
        shell->priv->right_paned_position = gtk_paned_get_position (GTK_PANED (shell->priv->right_paned));
2935
 
        rb_debug ("paned position %d", shell->priv->paned_position);
2936
 
        rb_debug ("right_paned position %d", shell->priv->right_paned_position);
2937
 
        eel_gconf_set_integer (CONF_STATE_PANED_POSITION, shell->priv->paned_position);
2938
 
        eel_gconf_set_integer (CONF_STATE_RIGHT_PANED_POSITION, shell->priv->right_paned_position);
2939
 
}
2940
 
 
2941
 
static void
2942
 
sidebar_paned_size_allocate_cb (GtkWidget *widget,
2943
 
                                GtkAllocation *allocation,
2944
 
                                RBShell *shell)
2945
 
{
2946
 
        shell->priv->display_page_tree_height = gtk_paned_get_position (GTK_PANED (shell->priv->queue_paned));
2947
 
        rb_debug ("sidebar paned position %d", shell->priv->display_page_tree_height);
2948
 
        eel_gconf_set_integer (CONF_STATE_SOURCELIST_HEIGHT, shell->priv->display_page_tree_height);
 
2969
        rb_settings_delayed_sync (shell->priv->settings,
 
2970
                                  (RBDelayedSyncFunc) sync_window_settings,
 
2971
                                  g_object_ref (shell),
 
2972
                                  g_object_unref);
2949
2973
}
2950
2974
 
2951
2975
static void
3000
3024
        g_return_if_fail (entry != NULL);
3001
3025
 
3002
3026
        if ((source == RB_SOURCE (shell->priv->queue_source) &&
3003
 
             shell->priv->queue_as_sidebar) ||
 
3027
             g_settings_get_boolean (shell->priv->settings, "queue-as-sidebar")) ||
3004
3028
             source == NULL) {
3005
3029
                RhythmDBEntryType *entry_type;
3006
3030
                entry_type = rhythmdb_entry_get_entry_type (entry);