46
46
#include <libxfce4util/libxfce4util.h>
47
47
#include <xfconf/xfconf.h>
48
48
#include <libxfce4ui/libxfce4ui.h>
51
49
#include <exo/exo.h>
54
51
#include "xfdesktop-common.h"
55
52
#include "xfdesktop-settings-ui.h"
56
53
#include "xfdesktop-settings-appearance-frame-ui.h"
58
55
#define PREVIEW_HEIGHT 48
56
#define MAX_ASPECT_RATIO 3.0f
60
58
#define SHOW_DESKTOP_MENU_PROP "/desktop-menu/show"
61
59
#define DESKTOP_MENU_SHOW_ICONS_PROP "/desktop-menu/show-icons"
166
167
name, width, height);
168
169
aspect = (gdouble)width / height;
171
/* Keep the aspect ratio sensible otherwise the treeview looks bad */
172
if(aspect > MAX_ASPECT_RATIO) {
173
aspect = MAX_ASPECT_RATIO;
169
176
width = PREVIEW_HEIGHT * aspect;
170
177
height = PREVIEW_HEIGHT;
171
178
pix_scaled = gdk_pixbuf_scale_simple(pix, width, height,
198
203
PreviewData *pdata = data;
206
GDK_THREADS_ENTER ();
202
208
for(l = pdata->iters; l; l = l->next)
203
209
xfdesktop_settings_do_single_preview(pdata->model, l->data);
211
GDK_THREADS_LEAVE ();
206
213
g_object_unref(G_OBJECT(pdata->model));
207
214
g_slist_foreach(pdata->iters, (GFunc)gtk_tree_iter_free, NULL);
231
239
GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
233
241
if(gtk_tree_selection_get_mode(selection) != GTK_SELECTION_MULTIPLE
234
&& gtk_tree_selection_get_selected(selection, NULL, &iter))
242
&& gtk_tree_selection_get_selected(selection, NULL, &iter))
236
244
GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
237
245
gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, 0.0, 0.0);
716
724
/* remember the tree view to scroll to the selected image in the
717
725
* thread that creates all the previews */
718
g_object_set_data_full(G_OBJECT(ls), "xfdesktop-tree-view",
726
g_object_set_data_full(G_OBJECT(ls), "xfdesktop-tree-view",
719
727
g_object_ref(panel->image_treeview),
760
768
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
772
cb_xfdesktop_chk_cycle_backdrop_toggled(GtkCheckButton *button,
775
gboolean sensitive = FALSE;
776
GtkWidget *spin_button = GTK_WIDGET(user_data);
778
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) &&
779
gtk_widget_get_sensitive(GTK_WIDGET(button))) {
783
gtk_widget_set_sensitive(spin_button, sensitive);
764
787
xfdesktop_spin_icon_size_timer(GtkSpinButton *button)
878
901
(GtkFileFilterFunc)gtk_true, NULL, NULL);
879
902
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
882
904
exo_gtk_file_chooser_add_thumbnail_preview(GTK_FILE_CHOOSER(chooser));
885
906
if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
886
907
GSList *filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(chooser));
1026
1047
gtk_widget_set_sensitive(panel->btn_minus, FALSE);
1027
1048
gtk_widget_set_sensitive(panel->btn_newlist, FALSE);
1028
1049
gtk_widget_set_sensitive(panel->frame_image_list, TRUE);
1050
gtk_widget_set_sensitive(panel->backdrop_cycle_chkbox, FALSE);
1051
gtk_widget_set_sensitive(panel->backdrop_cycle_spinbox, FALSE);
1029
1052
DBG("show_image=%s", panel->show_image?"true":"false");
1030
1053
if(!panel->show_image) {
1031
1054
panel->show_image = TRUE;
1051
1074
gtk_widget_set_sensitive(panel->btn_minus, TRUE);
1052
1075
gtk_widget_set_sensitive(panel->btn_newlist, TRUE);
1053
1076
gtk_widget_set_sensitive(panel->frame_image_list, TRUE);
1077
gtk_widget_set_sensitive(panel->backdrop_cycle_chkbox, TRUE);
1078
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->backdrop_cycle_chkbox)))
1079
gtk_widget_set_sensitive(panel->backdrop_cycle_spinbox, TRUE);
1081
gtk_widget_set_sensitive(panel->backdrop_cycle_spinbox, FALSE);
1054
1082
DBG("show_image=%s", panel->show_image?"true":"false");
1055
1083
if(!panel->show_image) {
1056
1084
panel->show_image = TRUE;
1059
1087
} else if(w == panel->radio_none) {
1060
1088
DBG("widget is none");
1061
1089
gtk_widget_set_sensitive(panel->frame_image_list, FALSE);
1090
gtk_widget_set_sensitive(panel->backdrop_cycle_chkbox, FALSE);
1091
gtk_widget_set_sensitive(panel->backdrop_cycle_spinbox, FALSE);
1062
1092
DBG("show_image=%s", panel->show_image?"true":"false");
1063
1093
if(panel->show_image) {
1064
1094
panel->show_image = FALSE;
1257
1287
G_CALLBACK(image_treeview_drag_data_received), panel);
1261
xfdesktop_settings_dialog_new(GtkBuilder *main_gxml,
1262
XfconfChannel *channel)
1291
xfdesktop_settings_dialog_add_screens(GtkBuilder *main_gxml,
1292
XfconfChannel *channel)
1264
1294
gint i, j, nmonitors, nscreens;
1265
GtkWidget *dialog, *appearance_container, *chk_custom_font_size,
1295
GtkWidget *appearance_container, *chk_custom_font_size,
1266
1296
*spin_font_size, *color_style_widget, *w, *box,
1267
1297
*spin_icon_size, *chk_show_thumbnails, *chk_single_click;
1269
dialog = GTK_WIDGET(gtk_builder_get_object(main_gxml, "prefs_dialog"));
1270
1299
appearance_container = GTK_WIDGET(gtk_builder_get_object(main_gxml,
1271
1300
"notebook_screens"));
1295
1324
chk_show_thumbnails = GTK_WIDGET(gtk_builder_get_object(main_gxml,
1296
1325
"chk_show_thumbnails"));
1326
/* The default value when this property is not set, is 'TRUE'.
1327
* the bind operation defaults to 'FALSE' for unset boolean properties.
1329
* Make the checkbox correspond to the default behaviour.
1331
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(chk_show_thumbnails),
1298
1334
nscreens = gdk_display_get_n_screens(gdk_display_get_default());
1438
1475
g_signal_connect(G_OBJECT(panel->btn_newlist), "clicked",
1439
1476
G_CALLBACK(newlist_button_clicked), panel);
1478
panel->chk_xinerama_stretch = GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
1479
"chk_xinerama_stretch"));
1481
/* The first monitor has the option of doing the xinerama-stretch,
1482
* but only if there's multiple monitors attached. Make it invisible
1483
* in all other cases.
1485
if(j == 0 && nmonitors > 1) {
1486
g_snprintf(buf, sizeof(buf), "/backdrop/screen%d/xinerama-stretch",
1488
xfconf_g_property_bind(channel, buf, G_TYPE_BOOLEAN,
1489
G_OBJECT(panel->chk_xinerama_stretch), "active");
1490
gtk_widget_set_sensitive(panel->chk_xinerama_stretch, TRUE);
1492
gtk_widget_hide(panel->chk_xinerama_stretch);
1495
panel->backdrop_cycle_chkbox = GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
1496
"chk_cycle_backdrop"));
1497
panel->backdrop_cycle_spinbox = GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
1498
"spin_backdrop_time_minutes"));
1500
g_signal_connect(G_OBJECT(panel->backdrop_cycle_chkbox), "toggled",
1501
G_CALLBACK(cb_xfdesktop_chk_cycle_backdrop_toggled),
1502
panel->backdrop_cycle_spinbox);
1504
g_snprintf(buf, sizeof(buf), PER_SCREEN_PROP_FORMAT "/backdrop-cycle-enable",
1506
xfconf_g_property_bind(channel, buf, G_TYPE_BOOLEAN,
1507
G_OBJECT(panel->backdrop_cycle_chkbox), "active");
1509
g_snprintf(buf, sizeof(buf), PER_SCREEN_PROP_FORMAT "/backdrop-cycle-timer",
1511
xfconf_g_property_bind(channel, buf, G_TYPE_UINT,
1512
G_OBJECT(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(panel->backdrop_cycle_spinbox))),
1441
1515
panel->radio_singleimage = GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
1442
1516
"radio_singleimage"));
1443
1517
g_signal_connect(G_OBJECT(panel->radio_singleimage), "toggled",
1549
1623
setup_special_icon_list(main_gxml, channel);
1627
xfdesktop_settings_response(GtkWidget *dialog, gint response_id)
1629
if(response_id == GTK_RESPONSE_HELP)
1630
xfce_dialog_show_help(GTK_WINDOW(dialog), "xfdesktop", "preferences", NULL);
1554
1635
static GdkNativeWindow opt_socket_id = 0;
1619
1697
channel = xfconf_channel_new(XFDESKTOP_CHANNEL);
1621
gdk_threads_enter();
1699
xfdesktop_settings_dialog_add_screens(gxml, channel);
1623
dialog = xfdesktop_settings_dialog_new(gxml, channel);
1624
1701
if(opt_socket_id == 0) {
1625
g_object_unref(G_OBJECT(gxml));
1627
while(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_HELP)
1628
g_spawn_command_line_async("xfhelp4 xfdesktop.html", NULL);
1702
dialog = GTK_WIDGET(gtk_builder_get_object(gxml, "prefs_dialog"));
1703
g_signal_connect(dialog, "response",
1704
G_CALLBACK(xfdesktop_settings_response), NULL);
1705
gtk_window_present(GTK_WINDOW (dialog));
1707
/* To prevent the settings dialog to be saved in the session */
1708
gdk_set_sm_client_id("FAKE ID");
1630
1712
GtkWidget *plug, *plug_child;
1640
1722
gtk_widget_reparent(plug_child, plug);
1641
1723
gtk_widget_show(plug_child);
1643
g_object_unref(G_OBJECT(gxml));
1648
gdk_threads_leave();
1728
g_object_unref(G_OBJECT(gxml));
1650
1730
g_object_unref(G_OBJECT(channel));
1651
1731
xfconf_shutdown();