Merge lp:~noskcaj/ubuntu/trusty/xfdesktop4/4.11.5 into lp:ubuntu/trusty/xfdesktop4
- Trusty (14.04)
- 4.11.5
- Merge into trusty
Proposed by
Jackson Doak
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | Sebastien Bacher | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~noskcaj/ubuntu/trusty/xfdesktop4/4.11.5 | ||||
Merge into: | lp:ubuntu/trusty/xfdesktop4 | ||||
Diff against target: |
9410 lines (+795/-6646) 34 files modified
.pc/applied-patches (+0/-3) .pc/git-desktop-icons-have-background.patch/src/xfce-desktop.c (+0/-1821) .pc/git-fix-default-icon-size.patch/src/xfce-desktop.c (+0/-1847) .pc/git-missing-images-in-settings-app.patch/settings/main.c (+0/-2101) .pc/xubuntu_improve-nautilus-interactions.patch/src/xfce-desktop.c (+33/-7) .pc/xubuntu_set-accountsservice-user-bg.patch/src/xfce-desktop.c (+33/-7) ChangeLog (+132/-0) NEWS (+19/-0) aclocal.m4 (+7/-7) configure (+13/-13) configure.ac (+2/-2) debian/changelog (+7/-0) debian/patches/git-desktop-icons-have-background.patch (+0/-104) debian/patches/git-fix-default-icon-size.patch (+0/-22) debian/patches/git-missing-images-in-settings-app.patch (+0/-125) debian/patches/series (+0/-3) debian/patches/xubuntu_improve-nautilus-interactions.patch (+3/-3) debian/patches/xubuntu_set-accountsservice-user-bg.patch (+2/-2) po/cs.po (+148/-150) po/hr.po (+11/-11) po/pl.po (+6/-6) po/pt_BR.po (+148/-151) po/sv.po (+149/-150) settings/main.c (+1/-1) src/xfce-backdrop.c (+26/-2) src/xfce-backdrop.h (+1/-1) src/xfdesktop-file-utils.c (+28/-84) src/xfdesktop-icon-view.c (+0/-3) src/xfdesktop-icon.c (+2/-2) src/xfdesktop-icon.h (+4/-4) src/xfdesktop-regular-file-icon.c (+4/-4) src/xfdesktop-special-file-icon.c (+10/-4) src/xfdesktop-volume-icon.c (+4/-4) src/xfdesktop-window-icon.c (+2/-2) |
||||
To merge this branch: | bzr merge lp:~noskcaj/ubuntu/trusty/xfdesktop4/4.11.5 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Approve | ||
Review via email: mp+213710@code.launchpad.net |
Commit message
Description of the change
New upstream bugfix release. needed for Xubuntu 14.04
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.pc/applied-patches' |
2 | --- .pc/applied-patches 2014-03-28 07:16:04 +0000 |
3 | +++ .pc/applied-patches 2014-04-01 20:08:43 +0000 |
4 | @@ -1,5 +1,2 @@ |
5 | xubuntu_set-accountsservice-user-bg.patch |
6 | xubuntu_improve-nautilus-interactions.patch |
7 | -git-desktop-icons-have-background.patch |
8 | -git-missing-images-in-settings-app.patch |
9 | -git-fix-default-icon-size.patch |
10 | |
11 | === removed directory '.pc/git-desktop-icons-have-background.patch' |
12 | === removed directory '.pc/git-desktop-icons-have-background.patch/src' |
13 | === removed file '.pc/git-desktop-icons-have-background.patch/src/xfce-desktop.c' |
14 | --- .pc/git-desktop-icons-have-background.patch/src/xfce-desktop.c 2014-03-28 07:16:04 +0000 |
15 | +++ .pc/git-desktop-icons-have-background.patch/src/xfce-desktop.c 1970-01-01 00:00:00 +0000 |
16 | @@ -1,1821 +0,0 @@ |
17 | -/* |
18 | - * xfdesktop - xfce4's desktop manager |
19 | - * |
20 | - * Copyright (c) 2004-2007 Brian Tarricone, <bjt23@cornell.edu> |
21 | - * |
22 | - * This program is free software; you can redistribute it and/or modify |
23 | - * it under the terms of the GNU General Public License as published by |
24 | - * the Free Software Foundation; either version 2 of the License, or |
25 | - * (at your option) any later version. |
26 | - * |
27 | - * This program is distributed in the hope that it will be useful, |
28 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
29 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
30 | - * GNU Library General Public License for more details. |
31 | - * |
32 | - * You should have received a copy of the GNU General Public License |
33 | - * along with this program; if not, write to the Free Software Foundation, |
34 | - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
35 | - * |
36 | - * Random portions taken from or inspired by the original xfdesktop for xfce4: |
37 | - * Copyright (C) 2002-2003 Jasper Huijsmans (huysmans@users.sourceforge.net) |
38 | - * Copyright (C) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> |
39 | - */ |
40 | - |
41 | -#ifdef HAVE_CONFIG_H |
42 | -#include <config.h> |
43 | -#endif |
44 | - |
45 | -#include <stdio.h> |
46 | - |
47 | -#ifdef HAVE_STDLIB_H |
48 | -#include <stdlib.h> |
49 | -#endif |
50 | - |
51 | -#ifdef HAVE_STRING_H |
52 | -#include <string.h> |
53 | -#endif |
54 | - |
55 | -#ifdef HAVE_SYS_TYPES_H |
56 | -#include <sys/types.h> |
57 | -#endif |
58 | -#ifdef HAVE_SYS_STAT_H |
59 | -#include <sys/stat.h> |
60 | -#endif |
61 | -#ifdef HAVE_UNISTD_H |
62 | -#include <unistd.h> |
63 | -#endif |
64 | - |
65 | -#ifdef HAVE_FCNTL_H |
66 | -#include <fcntl.h> |
67 | -#endif |
68 | - |
69 | -#include <ctype.h> |
70 | -#include <errno.h> |
71 | - |
72 | -#ifdef HAVE_TIME_H |
73 | -#include <time.h> |
74 | -#endif |
75 | - |
76 | -#include <X11/Xlib.h> |
77 | -#include <X11/Xatom.h> |
78 | - |
79 | -#include <glib.h> |
80 | -#include <gdk/gdkx.h> |
81 | -#include <gtk/gtk.h> |
82 | -#include <gio/gio.h> |
83 | - |
84 | -#ifdef ENABLE_DESKTOP_ICONS |
85 | -#include "xfdesktop-icon-view.h" |
86 | -#include "xfdesktop-window-icon-manager.h" |
87 | -# ifdef ENABLE_FILE_ICONS |
88 | -# include "xfdesktop-file-icon-manager.h" |
89 | -# include "xfdesktop-special-file-icon.h" |
90 | -# endif |
91 | -#endif |
92 | - |
93 | -#include <libxfce4util/libxfce4util.h> |
94 | -#include <libxfce4ui/libxfce4ui.h> |
95 | - |
96 | -#include <xfconf/xfconf.h> |
97 | -#include <libwnck/libwnck.h> |
98 | - |
99 | -#include "xfdesktop-common.h" |
100 | -#include "xfce-desktop.h" |
101 | -#include "xfce-desktop-enum-types.h" |
102 | -#include "xfce-workspace.h" |
103 | - |
104 | -/* disable setting the x background for bug 7442 */ |
105 | -//#define DISABLE_FOR_BUG7442 |
106 | - |
107 | -struct _XfceDesktopPriv |
108 | -{ |
109 | - GdkScreen *gscreen; |
110 | - WnckScreen *wnck_screen; |
111 | - gboolean updates_frozen; |
112 | - |
113 | - XfconfChannel *channel; |
114 | - gchar *property_prefix; |
115 | - |
116 | - GdkPixmap *bg_pixmap; |
117 | - |
118 | - gint nworkspaces; |
119 | - XfceWorkspace **workspaces; |
120 | - gint current_workspace; |
121 | - |
122 | - gboolean single_workspace_mode; |
123 | - gint single_workspace_num; |
124 | - |
125 | - SessionLogoutFunc session_logout_func; |
126 | - |
127 | - guint32 grab_time; |
128 | - |
129 | -#ifdef ENABLE_DESKTOP_ICONS |
130 | - XfceDesktopIconStyle icons_style; |
131 | - gboolean icons_font_size_set; |
132 | - guint icons_font_size; |
133 | - guint icons_size; |
134 | - GtkWidget *icon_view; |
135 | - gdouble system_font_size; |
136 | -#endif |
137 | -}; |
138 | - |
139 | -enum |
140 | -{ |
141 | - SIG_POPULATE_ROOT_MENU = 0, |
142 | - SIG_POPULATE_SECONDARY_ROOT_MENU, |
143 | - N_SIGNALS |
144 | -}; |
145 | - |
146 | -enum |
147 | -{ |
148 | - PROP_0 = 0, |
149 | -#ifdef ENABLE_DESKTOP_ICONS |
150 | - PROP_ICON_STYLE, |
151 | - PROP_ICON_SIZE, |
152 | - PROP_ICON_FONT_SIZE, |
153 | - PROP_ICON_FONT_SIZE_SET, |
154 | -#endif |
155 | - PROP_SINGLE_WORKSPACE_MODE, |
156 | - PROP_SINGLE_WORKSPACE_NUMBER, |
157 | -}; |
158 | - |
159 | - |
160 | -static void xfce_desktop_finalize(GObject *object); |
161 | -static void xfce_desktop_set_property(GObject *object, |
162 | - guint property_id, |
163 | - const GValue *value, |
164 | - GParamSpec *pspec); |
165 | -static void xfce_desktop_get_property(GObject *object, |
166 | - guint property_id, |
167 | - GValue *value, |
168 | - GParamSpec *pspec); |
169 | - |
170 | -static void xfce_desktop_realize(GtkWidget *widget); |
171 | -static void xfce_desktop_unrealize(GtkWidget *widget); |
172 | -static gboolean xfce_desktop_button_press_event(GtkWidget *widget, |
173 | - GdkEventButton *evt); |
174 | -static gboolean xfce_desktop_button_release_event(GtkWidget *widget, |
175 | - GdkEventButton *evt); |
176 | -static gboolean xfce_desktop_popup_menu(GtkWidget *widget); |
177 | - |
178 | -static gboolean xfce_desktop_expose(GtkWidget *w, |
179 | - GdkEventExpose *evt); |
180 | -static gboolean xfce_desktop_delete_event(GtkWidget *w, |
181 | - GdkEventAny *evt); |
182 | -static void xfce_desktop_style_set(GtkWidget *w, |
183 | - GtkStyle *old_style); |
184 | - |
185 | -static void xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, |
186 | - gboolean single_workspace); |
187 | -static void xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, |
188 | - gint workspace_num); |
189 | - |
190 | -static gboolean xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop); |
191 | -static gint xfce_desktop_get_current_workspace(XfceDesktop *desktop); |
192 | - |
193 | -static guint signals[N_SIGNALS] = { 0, }; |
194 | - |
195 | -/* private functions */ |
196 | - |
197 | -#ifdef ENABLE_DESKTOP_ICONS |
198 | -static gdouble |
199 | -xfce_desktop_ensure_system_font_size(XfceDesktop *desktop) |
200 | -{ |
201 | - GdkScreen *gscreen; |
202 | - GtkSettings *settings; |
203 | - gchar *font_name = NULL; |
204 | - PangoFontDescription *pfd; |
205 | - |
206 | - gscreen = gtk_widget_get_screen(GTK_WIDGET(desktop)); |
207 | - |
208 | - settings = gtk_settings_get_for_screen(gscreen); |
209 | - g_object_get(G_OBJECT(settings), "gtk-font-name", &font_name, NULL); |
210 | - |
211 | - pfd = pango_font_description_from_string(font_name); |
212 | - desktop->priv->system_font_size = pango_font_description_get_size(pfd); |
213 | - /* FIXME: this seems backwards from the documentation */ |
214 | - if(!pango_font_description_get_size_is_absolute(pfd)) { |
215 | - DBG("dividing by PANGO_SCALE"); |
216 | - desktop->priv->system_font_size /= PANGO_SCALE; |
217 | - } |
218 | - DBG("system font size is %.05f", desktop->priv->system_font_size); |
219 | - |
220 | - g_free(font_name); |
221 | - pango_font_description_free(pfd); |
222 | - |
223 | - return desktop->priv->system_font_size; |
224 | -} |
225 | - |
226 | -static void |
227 | -xfce_desktop_setup_icon_view(XfceDesktop *desktop) |
228 | -{ |
229 | - XfdesktopIconViewManager *manager = NULL; |
230 | - |
231 | - switch(desktop->priv->icons_style) { |
232 | - case XFCE_DESKTOP_ICON_STYLE_NONE: |
233 | - /* nada */ |
234 | - break; |
235 | - |
236 | - case XFCE_DESKTOP_ICON_STYLE_WINDOWS: |
237 | - manager = xfdesktop_window_icon_manager_new(desktop->priv->gscreen); |
238 | - break; |
239 | - |
240 | -#ifdef ENABLE_FILE_ICONS |
241 | - case XFCE_DESKTOP_ICON_STYLE_FILES: |
242 | - { |
243 | - GFile *file; |
244 | - const gchar *desktop_path; |
245 | - |
246 | - desktop_path = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); |
247 | - file = g_file_new_for_path(desktop_path); |
248 | - manager = xfdesktop_file_icon_manager_new(file, desktop->priv->channel); |
249 | - g_object_unref(file); |
250 | - } |
251 | - break; |
252 | -#endif |
253 | - |
254 | - default: |
255 | - g_critical("Unusable XfceDesktopIconStyle: %d. Unable to " \ |
256 | - "display desktop icons.", |
257 | - desktop->priv->icons_style); |
258 | - break; |
259 | - } |
260 | - |
261 | - if(manager) { |
262 | - xfce_desktop_ensure_system_font_size(desktop); |
263 | - |
264 | - desktop->priv->icon_view = xfdesktop_icon_view_new(manager); |
265 | - /* If the user set a custom font size, use it. Otherwise use the system |
266 | - * font size */ |
267 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
268 | - (!desktop->priv->icons_font_size_set) |
269 | - ? desktop->priv->system_font_size |
270 | - : desktop->priv->icons_font_size); |
271 | - if(desktop->priv->icons_size > 0) { |
272 | - xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
273 | - desktop->priv->icons_size); |
274 | - } |
275 | - gtk_widget_show(desktop->priv->icon_view); |
276 | - gtk_container_add(GTK_CONTAINER(desktop), desktop->priv->icon_view); |
277 | - } |
278 | - |
279 | - gtk_widget_queue_draw(GTK_WIDGET(desktop)); |
280 | -} |
281 | -#endif |
282 | - |
283 | -static void |
284 | -set_imgfile_root_property(XfceDesktop *desktop, const gchar *filename, |
285 | - gint monitor) |
286 | -{ |
287 | - gchar property_name[128]; |
288 | - |
289 | - gdk_error_trap_push(); |
290 | - |
291 | - g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, monitor); |
292 | - if(filename) { |
293 | - gdk_property_change(gdk_screen_get_root_window(desktop->priv->gscreen), |
294 | - gdk_atom_intern(property_name, FALSE), |
295 | - gdk_x11_xatom_to_atom(XA_STRING), 8, |
296 | - GDK_PROP_MODE_REPLACE, |
297 | - (guchar *)filename, strlen(filename)+1); |
298 | - } else { |
299 | - gdk_property_delete(gdk_screen_get_root_window(desktop->priv->gscreen), |
300 | - gdk_atom_intern(property_name, FALSE)); |
301 | - } |
302 | - |
303 | - gdk_error_trap_pop(); |
304 | -} |
305 | - |
306 | -static void |
307 | -set_real_root_window_pixmap(GdkScreen *gscreen, |
308 | - GdkPixmap *pmap) |
309 | -{ |
310 | -#ifndef DISABLE_FOR_BUG7442 |
311 | - Window xid; |
312 | - GdkWindow *groot; |
313 | - |
314 | - xid = GDK_DRAWABLE_XID(pmap); |
315 | - groot = gdk_screen_get_root_window(gscreen); |
316 | - |
317 | - gdk_error_trap_push(); |
318 | - |
319 | - /* set root property for transparent Eterms */ |
320 | - gdk_property_change(groot, |
321 | - gdk_atom_intern("_XROOTPMAP_ID", FALSE), |
322 | - gdk_atom_intern("PIXMAP", FALSE), 32, |
323 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
324 | - /* and set the root window's BG pixmap, because aterm is somewhat lame. */ |
325 | - gdk_window_set_back_pixmap(groot, pmap, FALSE); |
326 | - /* there really should be a standard for this crap... */ |
327 | - |
328 | - gdk_error_trap_pop(); |
329 | -#endif |
330 | -} |
331 | - |
332 | -static GdkPixmap * |
333 | -create_bg_pixmap(GdkScreen *gscreen, gpointer user_data) |
334 | -{ |
335 | - XfceDesktop *desktop = user_data; |
336 | - gint w, h; |
337 | - |
338 | - TRACE("entering"); |
339 | - |
340 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), NULL); |
341 | - |
342 | - /* If the workspaces haven't been created yet there's no need to do the |
343 | - * background pixmap */ |
344 | - if(desktop->priv->workspaces == NULL) { |
345 | - DBG("exiting, desktop->priv->workspaces == NULL"); |
346 | - return NULL; |
347 | - } |
348 | - |
349 | - TRACE("really entering"); |
350 | - |
351 | - w = gdk_screen_get_width(gscreen); |
352 | - h = gdk_screen_get_height(gscreen); |
353 | - gtk_widget_set_size_request(GTK_WIDGET(desktop), w, h); |
354 | - gtk_window_resize(GTK_WINDOW(desktop), w, h); |
355 | - |
356 | - if(desktop->priv->bg_pixmap) |
357 | - g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); |
358 | - desktop->priv->bg_pixmap = gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(GTK_WIDGET(desktop))), |
359 | - w, h, -1); |
360 | - |
361 | - if(!GDK_IS_PIXMAP(desktop->priv->bg_pixmap)) |
362 | - return NULL; |
363 | - |
364 | - gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), |
365 | - desktop->priv->bg_pixmap, FALSE); |
366 | - |
367 | - return desktop->priv->bg_pixmap; |
368 | -} |
369 | - |
370 | -static void |
371 | -set_accountsservice_user_bg(const gchar *filename) |
372 | -{ |
373 | - GDBusProxy *proxy = NULL; |
374 | - GDBusProxy *user = NULL; |
375 | - GVariant *variant = NULL; |
376 | - GError *error = NULL; |
377 | - gchar *object_path = NULL; |
378 | - const gchar *user_name = g_get_user_name(); |
379 | - |
380 | - proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, |
381 | - G_DBUS_PROXY_FLAGS_NONE, |
382 | - NULL, |
383 | - "org.freedesktop.Accounts", |
384 | - "/org/freedesktop/Accounts", |
385 | - "org.freedesktop.Accounts", |
386 | - NULL, |
387 | - &error); |
388 | - |
389 | - if(!proxy) { |
390 | - DBG("Failed to contact accounts service: %s", error->message); |
391 | - g_error_free(error); |
392 | - return; |
393 | - } |
394 | - |
395 | - variant = g_dbus_proxy_call_sync(proxy, |
396 | - "FindUserByName", |
397 | - g_variant_new("(s)", user_name), |
398 | - G_DBUS_CALL_FLAGS_NONE, |
399 | - -1, |
400 | - NULL, |
401 | - &error); |
402 | - |
403 | - if(!variant) { |
404 | - DBG("Could not contact accounts service to look up '%s': %s", |
405 | - user_name, error->message); |
406 | - g_error_free(error); |
407 | - goto bail; |
408 | - } |
409 | - |
410 | - g_variant_get(variant, "(o)", &object_path); |
411 | - user = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, |
412 | - G_DBUS_PROXY_FLAGS_NONE, |
413 | - NULL, |
414 | - "org.freedesktop.Accounts", |
415 | - object_path, |
416 | - "org.freedesktop.Accounts.User", |
417 | - NULL, |
418 | - &error); |
419 | - g_free(object_path); |
420 | - |
421 | - if(!user) { |
422 | - DBG("Could not create proxy for user '%s': %s", |
423 | - g_variant_get_string(variant, NULL), error->message); |
424 | - g_error_free(error); |
425 | - goto bail; |
426 | - } |
427 | - g_variant_unref(variant); |
428 | - |
429 | - variant = g_dbus_proxy_call_sync(user, |
430 | - "SetBackgroundFile", |
431 | - g_variant_new("(s)", filename), |
432 | - G_DBUS_CALL_FLAGS_NONE, |
433 | - -1, |
434 | - NULL, |
435 | - &error); |
436 | - |
437 | - if(!variant) { |
438 | - DBG("Failed to set the background '%s': %s", filename, error->message); |
439 | - g_error_free(error); |
440 | - goto bail; |
441 | - } |
442 | - |
443 | -bail: |
444 | - if(user) |
445 | - g_object_unref(user); |
446 | - if(proxy) |
447 | - g_object_unref(proxy); |
448 | - if(variant) |
449 | - g_variant_unref(variant); |
450 | -} |
451 | - |
452 | -static void |
453 | -backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data) |
454 | -{ |
455 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
456 | - GdkPixmap *pmap = desktop->priv->bg_pixmap; |
457 | - GdkScreen *gscreen = desktop->priv->gscreen; |
458 | - GdkRectangle rect; |
459 | - GdkRegion *clip_region = NULL; |
460 | - gint i, monitor = -1, current_workspace; |
461 | -#ifdef G_ENABLE_DEBUG |
462 | - gchar *monitor_name = NULL; |
463 | -#endif |
464 | - |
465 | - TRACE("entering"); |
466 | - |
467 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
468 | - |
469 | - if(!XFCE_IS_BACKDROP(backdrop)) |
470 | - return; |
471 | - |
472 | - if(desktop->priv->updates_frozen || !gtk_widget_get_realized(GTK_WIDGET(desktop))) |
473 | - return; |
474 | - |
475 | - TRACE("really entering"); |
476 | - |
477 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
478 | - |
479 | - /* Find out which monitor the backdrop is on */ |
480 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
481 | - if(backdrop == xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i)) { |
482 | - monitor = i; |
483 | - break; |
484 | - } |
485 | - } |
486 | - if(monitor == -1) |
487 | - return; |
488 | - /* notify Accountsservice of the new bg (only for monitor0) */ |
489 | - if(monitor == 0) |
490 | - if (xfce_desktop_get_current_workspace(desktop) == 0) |
491 | - set_accountsservice_user_bg(xfce_backdrop_get_image_filename(backdrop)); |
492 | - |
493 | -#ifdef G_ENABLE_DEBUG |
494 | - monitor_name = gdk_screen_get_monitor_plug_name(gscreen, monitor); |
495 | - |
496 | - DBG("backdrop changed for workspace %d, monitor %d (%s)", current_workspace, monitor, monitor_name); |
497 | - |
498 | - g_free(monitor_name); |
499 | -#endif |
500 | - |
501 | - if(xfce_desktop_get_n_monitors(desktop) > 1 |
502 | - && xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
503 | - /* Spanning screens */ |
504 | - GdkRectangle monitor_rect; |
505 | - |
506 | - gdk_screen_get_monitor_geometry(gscreen, 0, &rect); |
507 | - /* Get the lowest x and y value for all the monitors in |
508 | - * case none of them start at 0,0 for whatever reason. |
509 | - */ |
510 | - for(i = 1; i < xfce_desktop_get_n_monitors(desktop); i++) { |
511 | - gdk_screen_get_monitor_geometry(gscreen, i, &monitor_rect); |
512 | - |
513 | - if(monitor_rect.x < rect.x) |
514 | - rect.x = monitor_rect.x; |
515 | - if(monitor_rect.y < rect.y) |
516 | - rect.y = monitor_rect.y; |
517 | - } |
518 | - |
519 | - rect.width = gdk_screen_get_width(gscreen); |
520 | - rect.height = gdk_screen_get_height(gscreen); |
521 | - DBG("xinerama_stretch x %d, y %d, width %d, height %d", |
522 | - rect.x, rect.y, rect.width, rect.height); |
523 | - } else { |
524 | - gdk_screen_get_monitor_geometry(gscreen, monitor, &rect); |
525 | - DBG("monitor x %d, y %d, width %d, height %d", |
526 | - rect.x, rect.y, rect.width, rect.height); |
527 | - } |
528 | - |
529 | - xfce_backdrop_set_size(backdrop, rect.width, rect.height); |
530 | - |
531 | - if(monitor > 0 |
532 | - && !xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
533 | - clip_region = gdk_region_rectangle(&rect); |
534 | - |
535 | - DBG("clip_region: x: %d, y: %d, w: %d, h: %d", |
536 | - rect.x, rect.y, rect.width, rect.height); |
537 | - |
538 | - /* If we are not monitor 0 on a multi-monitor setup we need to subtract |
539 | - * all the previous monitor regions so we don't draw over them. This |
540 | - * should prevent the overlap and double backdrop drawing bugs. |
541 | - */ |
542 | - for(i = 0; i < monitor; i++) { |
543 | - GdkRectangle previous_monitor; |
544 | - GdkRegion *previous_region; |
545 | - gdk_screen_get_monitor_geometry(gscreen, i, &previous_monitor); |
546 | - |
547 | - DBG("previous_monitor: x: %d, y: %d, w: %d, h: %d", |
548 | - previous_monitor.x, previous_monitor.y, |
549 | - previous_monitor.width, previous_monitor.height); |
550 | - |
551 | - previous_region = gdk_region_rectangle(&previous_monitor); |
552 | - |
553 | - gdk_region_subtract(clip_region, previous_region); |
554 | - |
555 | - gdk_region_destroy(previous_region); |
556 | - } |
557 | - } |
558 | - |
559 | - if(clip_region != NULL) { |
560 | - /* Update the area to redraw to limit the icons/area painted */ |
561 | - gdk_region_get_clipbox(clip_region, &rect); |
562 | - DBG("area to update: x: %d, y: %d, w: %d, h: %d", |
563 | - rect.x, rect.y, rect.width, rect.height); |
564 | - } |
565 | - |
566 | - if(rect.width != 0 && rect.height != 0) { |
567 | - /* get the composited backdrop pixmap */ |
568 | - GdkPixbuf *pix = xfce_backdrop_get_pixbuf(backdrop); |
569 | - cairo_t *cr; |
570 | - |
571 | - /* create the backdrop if needed */ |
572 | - if(!pix) { |
573 | - xfce_backdrop_generate_async(backdrop); |
574 | - |
575 | - if(clip_region != NULL) |
576 | - gdk_region_destroy(clip_region); |
577 | - |
578 | - return; |
579 | - } |
580 | - |
581 | - /* Create the background pixmap if it isn't already */ |
582 | - if(!GDK_IS_PIXMAP(pmap)) { |
583 | - pmap = create_bg_pixmap(gscreen, desktop); |
584 | - |
585 | - if(!GDK_IS_PIXMAP(pmap)) { |
586 | - g_object_unref(pix); |
587 | - |
588 | - if(clip_region != NULL) |
589 | - gdk_region_destroy(clip_region); |
590 | - |
591 | - return; |
592 | - } |
593 | - } |
594 | - |
595 | - cr = gdk_cairo_create(GDK_DRAWABLE(pmap)); |
596 | - gdk_cairo_set_source_pixbuf(cr, pix, rect.x, rect.y); |
597 | - |
598 | - /* clip the area so we don't draw over a previous wallpaper */ |
599 | - if(clip_region != NULL) { |
600 | - gdk_cairo_region(cr, clip_region); |
601 | - cairo_clip(cr); |
602 | - } |
603 | - |
604 | - cairo_paint(cr); |
605 | - |
606 | - /* tell gtk to redraw the repainted area */ |
607 | - gtk_widget_queue_draw_area(GTK_WIDGET(desktop), rect.x, rect.y, |
608 | - rect.width, rect.height); |
609 | - |
610 | - set_imgfile_root_property(desktop, |
611 | - xfce_backdrop_get_image_filename(backdrop), |
612 | - monitor); |
613 | - |
614 | - /* do this again so apps watching the root win notice the update */ |
615 | - set_real_root_window_pixmap(gscreen, pmap); |
616 | - |
617 | - g_object_unref(G_OBJECT(pix)); |
618 | - cairo_destroy(cr); |
619 | - gtk_widget_show(GTK_WIDGET(desktop)); |
620 | - } |
621 | - |
622 | - if(clip_region != NULL) |
623 | - gdk_region_destroy(clip_region); |
624 | -} |
625 | - |
626 | -static void |
627 | -screen_size_changed_cb(GdkScreen *gscreen, gpointer user_data) |
628 | -{ |
629 | - XfceDesktop *desktop = user_data; |
630 | - gint current_workspace; |
631 | - |
632 | - TRACE("entering"); |
633 | - |
634 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
635 | - |
636 | - if(desktop->priv->nworkspaces <= current_workspace) |
637 | - return; |
638 | - |
639 | - if(current_workspace < 0) |
640 | - return; |
641 | - |
642 | - /* release the bg_pixmap since the dimensions may have changed */ |
643 | - if(desktop->priv->bg_pixmap) { |
644 | - g_object_unref(desktop->priv->bg_pixmap); |
645 | - desktop->priv->bg_pixmap = NULL; |
646 | - } |
647 | - |
648 | - /* special case for 1 backdrop to handle xinerama stretching */ |
649 | - if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
650 | - backdrop_changed_cb(xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], 0), desktop); |
651 | - } else { |
652 | - gint i; |
653 | - |
654 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
655 | - XfceBackdrop *current_backdrop; |
656 | - current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
657 | - backdrop_changed_cb(current_backdrop, desktop); |
658 | - } |
659 | - } |
660 | -} |
661 | - |
662 | -static void |
663 | -screen_composited_changed_cb(GdkScreen *gscreen, |
664 | - gpointer user_data) |
665 | -{ |
666 | - TRACE("entering"); |
667 | - /* fake a screen size changed, so the background is properly set */ |
668 | - screen_size_changed_cb(gscreen, user_data); |
669 | -} |
670 | - |
671 | -static void |
672 | -xfce_desktop_monitors_changed(GdkScreen *gscreen, |
673 | - gpointer user_data) |
674 | -{ |
675 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
676 | - gint i; |
677 | - |
678 | - TRACE("entering"); |
679 | - |
680 | - /* Update the workspaces */ |
681 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
682 | - xfce_workspace_monitors_changed(desktop->priv->workspaces[i], |
683 | - gscreen); |
684 | - } |
685 | - |
686 | - /* fake a screen size changed, so the background is properly set */ |
687 | - screen_size_changed_cb(gscreen, user_data); |
688 | -} |
689 | - |
690 | -static void |
691 | -workspace_backdrop_changed_cb(XfceWorkspace *workspace, |
692 | - XfceBackdrop *backdrop, |
693 | - gpointer user_data) |
694 | -{ |
695 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
696 | - |
697 | - TRACE("entering"); |
698 | - |
699 | - g_return_if_fail(XFCE_IS_WORKSPACE(workspace) && XFCE_IS_BACKDROP(backdrop)); |
700 | - |
701 | - if(xfce_desktop_get_current_workspace(desktop) == xfce_workspace_get_workspace_num(workspace)) |
702 | - backdrop_changed_cb(backdrop, user_data); |
703 | -} |
704 | - |
705 | -static void |
706 | -workspace_changed_cb(WnckScreen *wnck_screen, |
707 | - WnckWorkspace *previously_active_space, |
708 | - gpointer user_data) |
709 | -{ |
710 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
711 | - gint current_workspace, new_workspace, i; |
712 | - XfceBackdrop *current_backdrop, *new_backdrop; |
713 | - |
714 | - TRACE("entering"); |
715 | - |
716 | - /* Ignore workspace changes in single workspace mode so long as we |
717 | - * already have the bg_pixmap loaded */ |
718 | - if(xfce_desktop_get_single_workspace_mode(desktop) && desktop->priv->bg_pixmap) |
719 | - return; |
720 | - |
721 | - current_workspace = desktop->priv->current_workspace; |
722 | - new_workspace = xfce_desktop_get_current_workspace(desktop); |
723 | - |
724 | - if(new_workspace < 0 || new_workspace >= desktop->priv->nworkspaces) |
725 | - return; |
726 | - |
727 | - desktop->priv->current_workspace = new_workspace; |
728 | - |
729 | - DBG("current_workspace %d, new_workspace %d", |
730 | - current_workspace, new_workspace); |
731 | - |
732 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
733 | - /* We want to compare the current workspace backdrop with the new one |
734 | - * and see if we can avoid changing them if they are the same image/style */ |
735 | - if(current_workspace < desktop->priv->nworkspaces && current_workspace >= 0) { |
736 | - current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
737 | - new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); |
738 | - |
739 | - if(!xfce_backdrop_compare_backdrops(current_backdrop, new_backdrop) || !desktop->priv->bg_pixmap) { |
740 | - /* only update monitors that require it */ |
741 | - backdrop_changed_cb(new_backdrop, user_data); |
742 | - } |
743 | - } else { |
744 | - /* If current_workspace was removed or never existed, get the new |
745 | - * backdrop and apply it */ |
746 | - new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); |
747 | - backdrop_changed_cb(new_backdrop, user_data); |
748 | - } |
749 | - |
750 | - /* When we're spanning screens we only care about the first monitor */ |
751 | - if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[new_workspace])) |
752 | - break; |
753 | - } |
754 | -} |
755 | - |
756 | -static void |
757 | -workspace_created_cb(WnckScreen *wnck_screen, |
758 | - WnckWorkspace *new_workspace, |
759 | - gpointer user_data) |
760 | -{ |
761 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
762 | - gint nlast_workspace; |
763 | - TRACE("entering"); |
764 | - |
765 | - nlast_workspace = desktop->priv->nworkspaces; |
766 | - |
767 | - /* add one more workspace */ |
768 | - desktop->priv->nworkspaces = nlast_workspace + 1; |
769 | - |
770 | - /* allocate size for it */ |
771 | - desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, |
772 | - desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); |
773 | - |
774 | - /* create the new workspace and set it up */ |
775 | - desktop->priv->workspaces[nlast_workspace] = xfce_workspace_new(desktop->priv->gscreen, |
776 | - desktop->priv->channel, |
777 | - desktop->priv->property_prefix, |
778 | - nlast_workspace); |
779 | - |
780 | - /* Tell workspace whether to cache pixbufs */ |
781 | - xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[nlast_workspace], |
782 | - !desktop->priv->single_workspace_mode); |
783 | - |
784 | - xfce_workspace_monitors_changed(desktop->priv->workspaces[nlast_workspace], |
785 | - desktop->priv->gscreen); |
786 | - |
787 | - g_signal_connect(desktop->priv->workspaces[nlast_workspace], |
788 | - "workspace-backdrop-changed", |
789 | - G_CALLBACK(workspace_backdrop_changed_cb), desktop); |
790 | -} |
791 | - |
792 | -static void |
793 | -workspace_destroyed_cb(WnckScreen *wnck_screen, |
794 | - WnckWorkspace *old_workspace, |
795 | - gpointer user_data) |
796 | -{ |
797 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
798 | - gint nlast_workspace; |
799 | - TRACE("entering"); |
800 | - |
801 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
802 | - g_return_if_fail(desktop->priv->nworkspaces - 1 >= 0); |
803 | - g_return_if_fail(XFCE_IS_WORKSPACE(desktop->priv->workspaces[desktop->priv->nworkspaces-1])); |
804 | - |
805 | - nlast_workspace = desktop->priv->nworkspaces - 1; |
806 | - |
807 | - g_signal_handlers_disconnect_by_func(desktop->priv->workspaces[nlast_workspace], |
808 | - G_CALLBACK(workspace_backdrop_changed_cb), |
809 | - desktop); |
810 | - |
811 | - g_object_unref(desktop->priv->workspaces[nlast_workspace]); |
812 | - |
813 | - /* Remove one workspace */ |
814 | - desktop->priv->nworkspaces = nlast_workspace; |
815 | - |
816 | - /* deallocate it */ |
817 | - desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, |
818 | - desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); |
819 | - |
820 | - /* Make sure we stay within bounds now that we removed a workspace */ |
821 | - if(desktop->priv->current_workspace > desktop->priv->nworkspaces) |
822 | - desktop->priv->current_workspace = desktop->priv->nworkspaces; |
823 | -} |
824 | - |
825 | -static void |
826 | -screen_set_selection(XfceDesktop *desktop) |
827 | -{ |
828 | - Window xwin; |
829 | - gint xscreen; |
830 | - gchar selection_name[100], common_selection_name[32]; |
831 | - Atom selection_atom, common_selection_atom, manager_atom; |
832 | - |
833 | - xwin = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); |
834 | - xscreen = gdk_screen_get_number(desktop->priv->gscreen); |
835 | - |
836 | - g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen); |
837 | - selection_atom = XInternAtom(gdk_x11_get_default_xdisplay(), selection_name, False); |
838 | - manager_atom = XInternAtom(gdk_x11_get_default_xdisplay(), "MANAGER", False); |
839 | - |
840 | - g_snprintf(common_selection_name, 32, "_NET_DESKTOP_MANAGER_S%d", xscreen); |
841 | - common_selection_atom = XInternAtom(gdk_x11_get_default_xdisplay(), common_selection_name, False); |
842 | - |
843 | - /* the previous check in src/main.c occurs too early, so workaround by |
844 | - * adding this one. */ |
845 | - if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) != None) { |
846 | - g_warning("%s: already running, quitting.", PACKAGE); |
847 | - exit(0); |
848 | - } |
849 | - |
850 | - /* Check that _NET_DESKTOP_MANAGER_S%d isn't set, as it means another |
851 | - * desktop manager is running, e.g. nautilus */ |
852 | - if(XGetSelectionOwner (gdk_x11_get_default_xdisplay(), common_selection_atom) != None) { |
853 | - g_warning("%s: another desktop manager is running.", PACKAGE); |
854 | - exit(1); |
855 | - } |
856 | - |
857 | - XSelectInput(gdk_x11_get_default_xdisplay(), xwin, PropertyChangeMask | ButtonPressMask); |
858 | - XSetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom, xwin, GDK_CURRENT_TIME); |
859 | - XSetSelectionOwner(gdk_x11_get_default_xdisplay(), common_selection_atom, xwin, GDK_CURRENT_TIME); |
860 | - |
861 | - /* Check to see if we managed to claim the selection. If not, |
862 | - * we treat it as if we got it then immediately lost it */ |
863 | - if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) == xwin) { |
864 | - XClientMessageEvent xev; |
865 | - Window xroot = GDK_WINDOW_XID(gdk_screen_get_root_window(desktop->priv->gscreen)); |
866 | - |
867 | - xev.type = ClientMessage; |
868 | - xev.window = xroot; |
869 | - xev.message_type = manager_atom; |
870 | - xev.format = 32; |
871 | - xev.data.l[0] = GDK_CURRENT_TIME; |
872 | - xev.data.l[1] = selection_atom; |
873 | - xev.data.l[2] = xwin; |
874 | - xev.data.l[3] = 0; /* manager specific data */ |
875 | - xev.data.l[4] = 0; /* manager specific data */ |
876 | - |
877 | - XSendEvent(gdk_x11_get_default_xdisplay(), xroot, False, StructureNotifyMask, (XEvent *)&xev); |
878 | - } else { |
879 | - g_error("%s: could not set selection ownership", PACKAGE); |
880 | - exit(1); |
881 | - } |
882 | -} |
883 | - |
884 | - |
885 | - |
886 | -/* gobject-related functions */ |
887 | - |
888 | - |
889 | -G_DEFINE_TYPE(XfceDesktop, xfce_desktop, GTK_TYPE_WINDOW) |
890 | - |
891 | - |
892 | -static void |
893 | -xfce_desktop_class_init(XfceDesktopClass *klass) |
894 | -{ |
895 | - GObjectClass *gobject_class = (GObjectClass *)klass; |
896 | - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; |
897 | - |
898 | - g_type_class_add_private(klass, sizeof(XfceDesktopPriv)); |
899 | - |
900 | - gobject_class->finalize = xfce_desktop_finalize; |
901 | - gobject_class->set_property = xfce_desktop_set_property; |
902 | - gobject_class->get_property = xfce_desktop_get_property; |
903 | - |
904 | - widget_class->realize = xfce_desktop_realize; |
905 | - widget_class->unrealize = xfce_desktop_unrealize; |
906 | - widget_class->button_press_event = xfce_desktop_button_press_event; |
907 | - widget_class->button_release_event = xfce_desktop_button_release_event; |
908 | - widget_class->expose_event = xfce_desktop_expose; |
909 | - widget_class->delete_event = xfce_desktop_delete_event; |
910 | - widget_class->popup_menu = xfce_desktop_popup_menu; |
911 | - widget_class->style_set = xfce_desktop_style_set; |
912 | - |
913 | - signals[SIG_POPULATE_ROOT_MENU] = g_signal_new("populate-root-menu", |
914 | - XFCE_TYPE_DESKTOP, |
915 | - G_SIGNAL_RUN_LAST, |
916 | - G_STRUCT_OFFSET(XfceDesktopClass, |
917 | - populate_root_menu), |
918 | - NULL, NULL, |
919 | - g_cclosure_marshal_VOID__OBJECT, |
920 | - G_TYPE_NONE, 1, |
921 | - GTK_TYPE_MENU_SHELL); |
922 | - |
923 | - signals[SIG_POPULATE_SECONDARY_ROOT_MENU] = g_signal_new("populate-secondary-root-menu", |
924 | - XFCE_TYPE_DESKTOP, |
925 | - G_SIGNAL_RUN_LAST, |
926 | - G_STRUCT_OFFSET(XfceDesktopClass, |
927 | - populate_secondary_root_menu), |
928 | - NULL, NULL, |
929 | - g_cclosure_marshal_VOID__OBJECT, |
930 | - G_TYPE_NONE, 1, |
931 | - GTK_TYPE_MENU_SHELL); |
932 | - |
933 | -#define XFDESKTOP_PARAM_FLAGS (G_PARAM_READWRITE \ |
934 | - | G_PARAM_CONSTRUCT \ |
935 | - | G_PARAM_STATIC_NAME \ |
936 | - | G_PARAM_STATIC_NICK \ |
937 | - | G_PARAM_STATIC_BLURB) |
938 | - |
939 | -#ifdef ENABLE_DESKTOP_ICONS |
940 | - g_object_class_install_property(gobject_class, PROP_ICON_STYLE, |
941 | - g_param_spec_enum("icon-style", |
942 | - "icon style", |
943 | - "icon style", |
944 | - XFCE_TYPE_DESKTOP_ICON_STYLE, |
945 | -#ifdef ENABLE_FILE_ICONS |
946 | - XFCE_DESKTOP_ICON_STYLE_FILES, |
947 | -#else |
948 | - XFCE_DESKTOP_ICON_STYLE_WINDOWS, |
949 | -#endif /* ENABLE_FILE_ICONS */ |
950 | - XFDESKTOP_PARAM_FLAGS)); |
951 | - |
952 | - g_object_class_install_property(gobject_class, PROP_ICON_SIZE, |
953 | - g_param_spec_uint("icon-size", |
954 | - "icon size", |
955 | - "icon size", |
956 | - 8, 192, 36, |
957 | - XFDESKTOP_PARAM_FLAGS)); |
958 | - |
959 | - g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE, |
960 | - g_param_spec_uint("icon-font-size", |
961 | - "icon font size", |
962 | - "icon font size", |
963 | - 0, 144, 12, |
964 | - XFDESKTOP_PARAM_FLAGS)); |
965 | - |
966 | - g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE_SET, |
967 | - g_param_spec_boolean("icon-font-size-set", |
968 | - "icon font size set", |
969 | - "icon font size set", |
970 | - FALSE, |
971 | - XFDESKTOP_PARAM_FLAGS)); |
972 | - |
973 | -#endif /* ENABLE_DESKTOP_ICONS */ |
974 | - |
975 | - g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_MODE, |
976 | - g_param_spec_boolean("single-workspace-mode", |
977 | - "single-workspace-mode", |
978 | - "single-workspace-mode", |
979 | - TRUE, |
980 | - XFDESKTOP_PARAM_FLAGS)); |
981 | - |
982 | - g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_NUMBER, |
983 | - g_param_spec_int("single-workspace-number", |
984 | - "single-workspace-number", |
985 | - "single-workspace-number", |
986 | - 0, G_MAXINT16, 0, |
987 | - XFDESKTOP_PARAM_FLAGS)); |
988 | - |
989 | -#undef XFDESKTOP_PARAM_FLAGS |
990 | -} |
991 | - |
992 | -static void |
993 | -xfce_desktop_init(XfceDesktop *desktop) |
994 | -{ |
995 | - desktop->priv = G_TYPE_INSTANCE_GET_PRIVATE(desktop, XFCE_TYPE_DESKTOP, |
996 | - XfceDesktopPriv); |
997 | - |
998 | - gtk_window_set_type_hint(GTK_WINDOW(desktop), GDK_WINDOW_TYPE_HINT_DESKTOP); |
999 | - /* Accept focus is needed for the menu pop up either by the menu key on |
1000 | - * the keyboard or Shift+F10. */ |
1001 | - gtk_window_set_accept_focus(GTK_WINDOW(desktop), TRUE); |
1002 | - /* Can focus is needed for the gtk_grab_add/remove commands */ |
1003 | - gtk_widget_set_can_focus(GTK_WIDGET(desktop), TRUE); |
1004 | - gtk_window_set_resizable(GTK_WINDOW(desktop), FALSE); |
1005 | -} |
1006 | - |
1007 | -static void |
1008 | -xfce_desktop_finalize(GObject *object) |
1009 | -{ |
1010 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
1011 | - |
1012 | - g_object_unref(G_OBJECT(desktop->priv->channel)); |
1013 | - g_free(desktop->priv->property_prefix); |
1014 | - |
1015 | - G_OBJECT_CLASS(xfce_desktop_parent_class)->finalize(object); |
1016 | -} |
1017 | - |
1018 | -static void |
1019 | -xfce_desktop_set_property(GObject *object, |
1020 | - guint property_id, |
1021 | - const GValue *value, |
1022 | - GParamSpec *pspec) |
1023 | -{ |
1024 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
1025 | - |
1026 | - switch(property_id) { |
1027 | -#ifdef ENABLE_DESKTOP_ICONS |
1028 | - case PROP_ICON_STYLE: |
1029 | - xfce_desktop_set_icon_style(desktop, |
1030 | - g_value_get_enum(value)); |
1031 | - break; |
1032 | - |
1033 | - case PROP_ICON_SIZE: |
1034 | - xfce_desktop_set_icon_size(desktop, |
1035 | - g_value_get_uint(value)); |
1036 | - break; |
1037 | - |
1038 | - case PROP_ICON_FONT_SIZE: |
1039 | - xfce_desktop_set_icon_font_size(desktop, |
1040 | - g_value_get_uint(value)); |
1041 | - break; |
1042 | - |
1043 | - case PROP_ICON_FONT_SIZE_SET: |
1044 | - xfce_desktop_set_use_icon_font_size(desktop, |
1045 | - g_value_get_boolean(value)); |
1046 | - break; |
1047 | - |
1048 | -#endif |
1049 | - case PROP_SINGLE_WORKSPACE_MODE: |
1050 | - xfce_desktop_set_single_workspace_mode(desktop, |
1051 | - g_value_get_boolean(value)); |
1052 | - break; |
1053 | - |
1054 | - case PROP_SINGLE_WORKSPACE_NUMBER: |
1055 | - xfce_desktop_set_single_workspace_number(desktop, |
1056 | - g_value_get_int(value)); |
1057 | - break; |
1058 | - |
1059 | - default: |
1060 | - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
1061 | - break; |
1062 | - } |
1063 | -} |
1064 | - |
1065 | -static void |
1066 | -xfce_desktop_get_property(GObject *object, |
1067 | - guint property_id, |
1068 | - GValue *value, |
1069 | - GParamSpec *pspec) |
1070 | -{ |
1071 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
1072 | - |
1073 | - switch(property_id) { |
1074 | -#ifdef ENABLE_DESKTOP_ICONS |
1075 | - case PROP_ICON_STYLE: |
1076 | - g_value_set_enum(value, desktop->priv->icons_style); |
1077 | - break; |
1078 | - |
1079 | - case PROP_ICON_SIZE: |
1080 | - g_value_set_uint(value, desktop->priv->icons_size); |
1081 | - break; |
1082 | - |
1083 | - case PROP_ICON_FONT_SIZE: |
1084 | - g_value_set_uint(value, desktop->priv->icons_font_size); |
1085 | - break; |
1086 | - |
1087 | - case PROP_ICON_FONT_SIZE_SET: |
1088 | - g_value_set_boolean(value, desktop->priv->icons_font_size_set); |
1089 | - break; |
1090 | - |
1091 | -#endif |
1092 | - case PROP_SINGLE_WORKSPACE_MODE: |
1093 | - g_value_set_boolean(value, desktop->priv->single_workspace_mode); |
1094 | - break; |
1095 | - |
1096 | - case PROP_SINGLE_WORKSPACE_NUMBER: |
1097 | - g_value_set_int(value, desktop->priv->single_workspace_num); |
1098 | - break; |
1099 | - |
1100 | - default: |
1101 | - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
1102 | - break; |
1103 | - } |
1104 | -} |
1105 | - |
1106 | -static void |
1107 | -xfce_desktop_realize(GtkWidget *widget) |
1108 | -{ |
1109 | - XfceDesktop *desktop = XFCE_DESKTOP(widget); |
1110 | - GdkAtom atom; |
1111 | - gint sw, sh; |
1112 | - Window xid; |
1113 | - GdkWindow *groot; |
1114 | - WnckScreen *wnck_screen; |
1115 | - |
1116 | - TRACE("entering"); |
1117 | - |
1118 | - gtk_window_set_screen(GTK_WINDOW(desktop), desktop->priv->gscreen); |
1119 | - sw = gdk_screen_get_width(desktop->priv->gscreen); |
1120 | - sh = gdk_screen_get_height(desktop->priv->gscreen); |
1121 | - |
1122 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), |
1123 | - "monitors-changed", |
1124 | - G_CALLBACK(xfce_desktop_monitors_changed), |
1125 | - desktop); |
1126 | - |
1127 | - /* chain up */ |
1128 | - GTK_WIDGET_CLASS(xfce_desktop_parent_class)->realize(widget); |
1129 | - |
1130 | - gtk_window_set_title(GTK_WINDOW(desktop), _("Desktop")); |
1131 | - |
1132 | - gtk_widget_set_size_request(GTK_WIDGET(desktop), sw, sh); |
1133 | - gtk_window_move(GTK_WINDOW(desktop), 0, 0); |
1134 | - |
1135 | - atom = gdk_atom_intern("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE); |
1136 | - gdk_property_change(gtk_widget_get_window(GTK_WIDGET(desktop)), |
1137 | - gdk_atom_intern("_NET_WM_WINDOW_TYPE", FALSE), |
1138 | - gdk_atom_intern("ATOM", FALSE), 32, |
1139 | - GDK_PROP_MODE_REPLACE, (guchar *)&atom, 1); |
1140 | - |
1141 | - xid = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); |
1142 | - groot = gdk_screen_get_root_window(desktop->priv->gscreen); |
1143 | - |
1144 | - gdk_property_change(groot, |
1145 | - gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE), |
1146 | - gdk_atom_intern("WINDOW", FALSE), 32, |
1147 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
1148 | - |
1149 | - gdk_property_change(groot, |
1150 | - gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE), |
1151 | - gdk_atom_intern("WINDOW", FALSE), 32, |
1152 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
1153 | - |
1154 | - screen_set_selection(desktop); |
1155 | - |
1156 | - wnck_screen = wnck_screen_get(gdk_screen_get_number(desktop->priv->gscreen)); |
1157 | - desktop->priv->wnck_screen = wnck_screen; |
1158 | - |
1159 | - /* Watch for single workspace setting changes */ |
1160 | - xfconf_g_property_bind(desktop->priv->channel, |
1161 | - SINGLE_WORKSPACE_MODE, G_TYPE_BOOLEAN, |
1162 | - G_OBJECT(desktop), "single-workspace-mode"); |
1163 | - xfconf_g_property_bind(desktop->priv->channel, |
1164 | - SINGLE_WORKSPACE_NUMBER, G_TYPE_INT, |
1165 | - G_OBJECT(desktop), "single-workspace-number"); |
1166 | - |
1167 | - /* watch for workspace changes */ |
1168 | - g_signal_connect(desktop->priv->wnck_screen, "active-workspace-changed", |
1169 | - G_CALLBACK(workspace_changed_cb), desktop); |
1170 | - g_signal_connect(desktop->priv->wnck_screen, "workspace-created", |
1171 | - G_CALLBACK(workspace_created_cb), desktop); |
1172 | - g_signal_connect(desktop->priv->wnck_screen, "workspace-destroyed", |
1173 | - G_CALLBACK(workspace_destroyed_cb), desktop); |
1174 | - |
1175 | - /* watch for screen changes */ |
1176 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), "size-changed", |
1177 | - G_CALLBACK(screen_size_changed_cb), desktop); |
1178 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), "composited-changed", |
1179 | - G_CALLBACK(screen_composited_changed_cb), desktop); |
1180 | - |
1181 | - gtk_widget_add_events(GTK_WIDGET(desktop), GDK_EXPOSURE_MASK); |
1182 | - |
1183 | -#ifdef ENABLE_DESKTOP_ICONS |
1184 | - xfce_desktop_setup_icon_view(desktop); |
1185 | -#endif |
1186 | - |
1187 | - TRACE("exiting"); |
1188 | -} |
1189 | - |
1190 | -static void |
1191 | -xfce_desktop_unrealize(GtkWidget *widget) |
1192 | -{ |
1193 | - XfceDesktop *desktop = XFCE_DESKTOP(widget); |
1194 | - gint i; |
1195 | - GdkWindow *groot; |
1196 | - gchar property_name[128]; |
1197 | - |
1198 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1199 | - |
1200 | - /* disconnect all the xfconf settings to this desktop */ |
1201 | - xfconf_g_property_unbind_all(G_OBJECT(desktop)); |
1202 | - |
1203 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
1204 | - G_CALLBACK(xfce_desktop_monitors_changed), |
1205 | - desktop); |
1206 | - |
1207 | - if(gtk_widget_get_mapped(widget)) |
1208 | - gtk_widget_unmap(widget); |
1209 | - gtk_widget_set_mapped(widget, FALSE); |
1210 | - |
1211 | - gtk_container_forall(GTK_CONTAINER(widget), |
1212 | - (GtkCallback)gtk_widget_unrealize, |
1213 | - NULL); |
1214 | - |
1215 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
1216 | - G_CALLBACK(screen_size_changed_cb), desktop); |
1217 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
1218 | - G_CALLBACK(screen_composited_changed_cb), desktop); |
1219 | - |
1220 | - gdk_error_trap_push(); |
1221 | - |
1222 | - groot = gdk_screen_get_root_window(desktop->priv->gscreen); |
1223 | - gdk_property_delete(groot, gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE)); |
1224 | - gdk_property_delete(groot, gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE)); |
1225 | - |
1226 | -#ifndef DISABLE_FOR_BUG7442 |
1227 | - gdk_property_delete(groot, gdk_atom_intern("_XROOTPMAP_ID", FALSE)); |
1228 | - gdk_property_delete(groot, gdk_atom_intern("ESETROOT_PMAP_ID", FALSE)); |
1229 | - gdk_window_set_back_pixmap(groot, NULL, FALSE); |
1230 | -#endif |
1231 | - |
1232 | - if(desktop->priv->workspaces) { |
1233 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
1234 | - g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, i); |
1235 | - gdk_property_delete(groot, gdk_atom_intern(property_name, FALSE)); |
1236 | - g_object_unref(G_OBJECT(desktop->priv->workspaces[i])); |
1237 | - } |
1238 | - g_free(desktop->priv->workspaces); |
1239 | - desktop->priv->workspaces = NULL; |
1240 | - } |
1241 | - |
1242 | - gdk_flush(); |
1243 | - gdk_error_trap_pop(); |
1244 | - |
1245 | - if(desktop->priv->bg_pixmap) { |
1246 | - g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); |
1247 | - desktop->priv->bg_pixmap = NULL; |
1248 | - } |
1249 | - |
1250 | - gtk_window_set_icon(GTK_WINDOW(widget), NULL); |
1251 | - |
1252 | - gtk_style_detach(gtk_widget_get_style(widget)); |
1253 | - g_object_unref(G_OBJECT(gtk_widget_get_window(widget))); |
1254 | - gtk_widget_set_window(widget, NULL); |
1255 | - |
1256 | - gtk_selection_remove_all(widget); |
1257 | - |
1258 | - gtk_widget_set_realized(widget, FALSE); |
1259 | -} |
1260 | - |
1261 | -static gboolean |
1262 | -xfce_desktop_button_press_event(GtkWidget *w, |
1263 | - GdkEventButton *evt) |
1264 | -{ |
1265 | - guint button = evt->button; |
1266 | - guint state = evt->state; |
1267 | - XfceDesktop *desktop = XFCE_DESKTOP(w); |
1268 | - |
1269 | - TRACE("entering"); |
1270 | - |
1271 | - g_return_val_if_fail(XFCE_IS_DESKTOP(w), FALSE); |
1272 | - |
1273 | - if(evt->type == GDK_BUTTON_PRESS) { |
1274 | - if(button == 3 || (button == 1 && (state & GDK_SHIFT_MASK))) { |
1275 | -#ifdef ENABLE_DESKTOP_ICONS |
1276 | - /* Let the icon view handle these menu pop ups */ |
1277 | - if(desktop->priv->icons_style != XFCE_DESKTOP_ICON_STYLE_NONE) |
1278 | - return FALSE; |
1279 | -#endif |
1280 | - /* no icons on the desktop, grab the focus and pop up the menu */ |
1281 | - if(!gtk_widget_has_grab(w)) |
1282 | - gtk_grab_add(w); |
1283 | - |
1284 | - xfce_desktop_popup_root_menu(desktop, button, evt->time); |
1285 | - return TRUE; |
1286 | - } else if(button == 2 || (button == 1 && (state & GDK_SHIFT_MASK) |
1287 | - && (state & GDK_CONTROL_MASK))) |
1288 | - { |
1289 | - /* always grab the focus and pop up the menu */ |
1290 | - if(!gtk_widget_has_grab(w)) |
1291 | - gtk_grab_add(w); |
1292 | - |
1293 | - xfce_desktop_popup_secondary_root_menu(desktop, button, evt->time); |
1294 | - return TRUE; |
1295 | - } |
1296 | - } |
1297 | - |
1298 | - return FALSE; |
1299 | -} |
1300 | - |
1301 | -static gboolean |
1302 | -xfce_desktop_button_release_event(GtkWidget *w, |
1303 | - GdkEventButton *evt) |
1304 | -{ |
1305 | - TRACE("entering"); |
1306 | - |
1307 | - gtk_grab_remove(w); |
1308 | - |
1309 | - return FALSE; |
1310 | -} |
1311 | - |
1312 | -/* This function gets called when the user presses the menu key on the keyboard. |
1313 | - * Or Shift+F10 or whatever key binding the user has chosen. */ |
1314 | -static gboolean |
1315 | -xfce_desktop_popup_menu(GtkWidget *w) |
1316 | -{ |
1317 | - GdkEventButton *evt; |
1318 | - guint button, etime; |
1319 | - |
1320 | - TRACE("entering"); |
1321 | - |
1322 | - evt = (GdkEventButton *)gtk_get_current_event(); |
1323 | - if(evt && GDK_BUTTON_PRESS == evt->type) { |
1324 | - button = evt->button; |
1325 | - etime = evt->time; |
1326 | - } else { |
1327 | - button = 0; |
1328 | - etime = gtk_get_current_event_time(); |
1329 | - } |
1330 | - |
1331 | - xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), button, etime); |
1332 | - |
1333 | - gdk_event_free((GdkEvent*)evt); |
1334 | - return TRUE; |
1335 | -} |
1336 | - |
1337 | -static gboolean |
1338 | -xfce_desktop_expose(GtkWidget *w, |
1339 | - GdkEventExpose *evt) |
1340 | -{ |
1341 | - GList *children, *l; |
1342 | - |
1343 | - /*TRACE("entering");*/ |
1344 | - |
1345 | - if(evt->count != 0) |
1346 | - return FALSE; |
1347 | - |
1348 | - gdk_window_clear_area(gtk_widget_get_window(w), evt->area.x, evt->area.y, |
1349 | - evt->area.width, evt->area.height); |
1350 | - |
1351 | - children = gtk_container_get_children(GTK_CONTAINER(w)); |
1352 | - for(l = children; l; l = l->next) { |
1353 | - gtk_container_propagate_expose(GTK_CONTAINER(w), |
1354 | - GTK_WIDGET(l->data), |
1355 | - evt); |
1356 | - } |
1357 | - g_list_free(children); |
1358 | - |
1359 | - return FALSE; |
1360 | -} |
1361 | - |
1362 | -static gboolean |
1363 | -xfce_desktop_delete_event(GtkWidget *w, |
1364 | - GdkEventAny *evt) |
1365 | -{ |
1366 | - if(XFCE_DESKTOP(w)->priv->session_logout_func) |
1367 | - XFCE_DESKTOP(w)->priv->session_logout_func(); |
1368 | - |
1369 | - return TRUE; |
1370 | -} |
1371 | - |
1372 | -static void |
1373 | -xfce_desktop_style_set(GtkWidget *w, GtkStyle *old_style) |
1374 | -{ |
1375 | - XfceDesktop *desktop = XFCE_DESKTOP(w); |
1376 | -#ifdef ENABLE_DESKTOP_ICONS |
1377 | - gdouble old_font_size; |
1378 | -#endif |
1379 | - |
1380 | - TRACE("entering"); |
1381 | - |
1382 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1383 | - |
1384 | - if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1385 | - return; |
1386 | - |
1387 | - if(desktop->priv->workspaces == NULL) |
1388 | - return; |
1389 | - |
1390 | - if(GDK_IS_WINDOW(desktop->priv->bg_pixmap)) |
1391 | - gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), desktop->priv->bg_pixmap, FALSE); |
1392 | - |
1393 | - gtk_widget_queue_draw(GTK_WIDGET(desktop)); |
1394 | - |
1395 | -#ifdef ENABLE_DESKTOP_ICONS |
1396 | - if(!desktop->priv->icon_view || !XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view)) |
1397 | - return; |
1398 | - |
1399 | - /* reset the icon view style */ |
1400 | - gtk_widget_set_style(desktop->priv->icon_view, NULL); |
1401 | - gtk_widget_reset_rc_styles(desktop->priv->icon_view); |
1402 | - |
1403 | - old_font_size = desktop->priv->system_font_size; |
1404 | - if(xfce_desktop_ensure_system_font_size(desktop) != old_font_size |
1405 | - && desktop->priv->icon_view && !desktop->priv->icons_font_size_set) |
1406 | - { |
1407 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
1408 | - desktop->priv->system_font_size); |
1409 | - } |
1410 | -#endif |
1411 | -} |
1412 | - |
1413 | -static void |
1414 | -xfce_desktop_connect_settings(XfceDesktop *desktop) |
1415 | -{ |
1416 | -#ifdef ENABLE_DESKTOP_ICONS |
1417 | -#define ICONS_PREFIX "/desktop-icons/" |
1418 | - XfconfChannel *channel = desktop->priv->channel; |
1419 | - |
1420 | - xfce_desktop_freeze_updates(desktop); |
1421 | - |
1422 | - xfconf_g_property_bind(channel, ICONS_PREFIX "style", |
1423 | - XFCE_TYPE_DESKTOP_ICON_STYLE, |
1424 | - G_OBJECT(desktop), "icon-style"); |
1425 | - xfconf_g_property_bind(channel, ICONS_PREFIX "icon-size", G_TYPE_UINT, |
1426 | - G_OBJECT(desktop), "icon-size"); |
1427 | - xfconf_g_property_bind(channel, ICONS_PREFIX "font-size", G_TYPE_UINT, |
1428 | - G_OBJECT(desktop), "icon-font-size"); |
1429 | - xfconf_g_property_bind(channel, ICONS_PREFIX "use-custom-font-size", |
1430 | - G_TYPE_BOOLEAN, |
1431 | - G_OBJECT(desktop), "icon-font-size-set"); |
1432 | - |
1433 | - xfce_desktop_thaw_updates(desktop); |
1434 | -#undef ICONS_PREFIX |
1435 | -#endif |
1436 | -} |
1437 | - |
1438 | -static gboolean |
1439 | -xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop) |
1440 | -{ |
1441 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), TRUE); |
1442 | - |
1443 | - return desktop->priv->single_workspace_mode; |
1444 | -} |
1445 | - |
1446 | -static gint |
1447 | -xfce_desktop_get_current_workspace(XfceDesktop *desktop) |
1448 | -{ |
1449 | - WnckWorkspace *wnck_workspace; |
1450 | - gint workspace_num, current_workspace; |
1451 | - |
1452 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
1453 | - |
1454 | - wnck_workspace = wnck_screen_get_active_workspace(desktop->priv->wnck_screen); |
1455 | - |
1456 | - if(wnck_workspace != NULL) { |
1457 | - workspace_num = wnck_workspace_get_number(wnck_workspace); |
1458 | - } else { |
1459 | - workspace_num = desktop->priv->nworkspaces; |
1460 | - } |
1461 | - |
1462 | - /* If we're in single_workspace mode we need to return the workspace that |
1463 | - * it was set to, if possible, otherwise return the current workspace */ |
1464 | - if(xfce_desktop_get_single_workspace_mode(desktop) && |
1465 | - desktop->priv->single_workspace_num < desktop->priv->nworkspaces) { |
1466 | - current_workspace = desktop->priv->single_workspace_num; |
1467 | - } else { |
1468 | - current_workspace = workspace_num; |
1469 | - } |
1470 | - |
1471 | - DBG("workspace_num %d, single_workspace_num %d, current_workspace %d, max workspaces %d", |
1472 | - workspace_num, desktop->priv->single_workspace_num, current_workspace, |
1473 | - desktop->priv->nworkspaces); |
1474 | - |
1475 | - return current_workspace; |
1476 | -} |
1477 | - |
1478 | -/* public api */ |
1479 | - |
1480 | -/** |
1481 | - * xfce_desktop_new: |
1482 | - * @gscreen: The current #GdkScreen. |
1483 | - * @channel: An #XfconfChannel to use for settings. |
1484 | - * @property_prefix: String prefix for per-screen properties. |
1485 | - * |
1486 | - * Creates a new #XfceDesktop for the specified #GdkScreen. If @gscreen is |
1487 | - * %NULL, the default screen will be used. |
1488 | - * |
1489 | - * Return value: A new #XfceDesktop. |
1490 | - **/ |
1491 | -GtkWidget * |
1492 | -xfce_desktop_new(GdkScreen *gscreen, |
1493 | - XfconfChannel *channel, |
1494 | - const gchar *property_prefix) |
1495 | -{ |
1496 | - XfceDesktop *desktop; |
1497 | - |
1498 | - g_return_val_if_fail(channel && property_prefix, NULL); |
1499 | - |
1500 | - desktop = g_object_new(XFCE_TYPE_DESKTOP, NULL); |
1501 | - |
1502 | - if(!gscreen) |
1503 | - gscreen = gdk_display_get_default_screen(gdk_display_get_default()); |
1504 | - gtk_window_set_screen(GTK_WINDOW(desktop), gscreen); |
1505 | - desktop->priv->gscreen = gscreen; |
1506 | - |
1507 | - desktop->priv->channel = g_object_ref(G_OBJECT(channel)); |
1508 | - desktop->priv->property_prefix = g_strdup(property_prefix); |
1509 | - |
1510 | - xfce_desktop_connect_settings(desktop); |
1511 | - |
1512 | - return GTK_WIDGET(desktop); |
1513 | -} |
1514 | - |
1515 | -gint |
1516 | -xfce_desktop_get_n_monitors(XfceDesktop *desktop) |
1517 | -{ |
1518 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), 0); |
1519 | - |
1520 | - return gdk_screen_get_n_monitors(desktop->priv->gscreen); |
1521 | -} |
1522 | - |
1523 | -gint |
1524 | -xfce_desktop_get_width(XfceDesktop *desktop) |
1525 | -{ |
1526 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
1527 | - |
1528 | - return gdk_screen_get_width(desktop->priv->gscreen); |
1529 | -} |
1530 | - |
1531 | -gint |
1532 | -xfce_desktop_get_height(XfceDesktop *desktop) |
1533 | -{ |
1534 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
1535 | - |
1536 | - return gdk_screen_get_height(desktop->priv->gscreen); |
1537 | -} |
1538 | - |
1539 | -void |
1540 | -xfce_desktop_set_icon_style(XfceDesktop *desktop, |
1541 | - XfceDesktopIconStyle style) |
1542 | -{ |
1543 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop) |
1544 | - && style <= XFCE_DESKTOP_ICON_STYLE_FILES); |
1545 | - |
1546 | -#ifdef ENABLE_DESKTOP_ICONS |
1547 | - if(style == desktop->priv->icons_style) |
1548 | - return; |
1549 | - |
1550 | - if(desktop->priv->icon_view) { |
1551 | - gtk_widget_destroy(desktop->priv->icon_view); |
1552 | - desktop->priv->icon_view = NULL; |
1553 | - } |
1554 | - |
1555 | - desktop->priv->icons_style = style; |
1556 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1557 | - xfce_desktop_setup_icon_view(desktop); |
1558 | -#endif |
1559 | -} |
1560 | - |
1561 | -XfceDesktopIconStyle |
1562 | -xfce_desktop_get_icon_style(XfceDesktop *desktop) |
1563 | -{ |
1564 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), XFCE_DESKTOP_ICON_STYLE_NONE); |
1565 | - |
1566 | -#ifdef ENABLE_DESKTOP_ICONS |
1567 | - return desktop->priv->icons_style; |
1568 | -#else |
1569 | - return XFCE_DESKTOP_ICON_STYLE_NONE; |
1570 | -#endif |
1571 | -} |
1572 | - |
1573 | -void |
1574 | -xfce_desktop_set_icon_size(XfceDesktop *desktop, |
1575 | - guint icon_size) |
1576 | -{ |
1577 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1578 | - |
1579 | -#ifdef ENABLE_DESKTOP_ICONS |
1580 | - if(icon_size == desktop->priv->icons_size) |
1581 | - return; |
1582 | - |
1583 | - desktop->priv->icons_size = icon_size; |
1584 | - |
1585 | - if(desktop->priv->icon_view) { |
1586 | - xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
1587 | - icon_size); |
1588 | - } |
1589 | -#endif |
1590 | -} |
1591 | - |
1592 | -void |
1593 | -xfce_desktop_set_icon_font_size(XfceDesktop *desktop, |
1594 | - guint font_size_points) |
1595 | -{ |
1596 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1597 | - |
1598 | -#ifdef ENABLE_DESKTOP_ICONS |
1599 | - if(font_size_points == desktop->priv->icons_font_size) |
1600 | - return; |
1601 | - |
1602 | - desktop->priv->icons_font_size = font_size_points; |
1603 | - |
1604 | - if(desktop->priv->icons_font_size_set && desktop->priv->icon_view) { |
1605 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
1606 | - font_size_points); |
1607 | - } |
1608 | -#endif |
1609 | -} |
1610 | - |
1611 | -void |
1612 | -xfce_desktop_set_use_icon_font_size(XfceDesktop *desktop, |
1613 | - gboolean use_icon_font_size) |
1614 | -{ |
1615 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1616 | - |
1617 | -#ifdef ENABLE_DESKTOP_ICONS |
1618 | - if(use_icon_font_size == desktop->priv->icons_font_size_set) |
1619 | - return; |
1620 | - |
1621 | - desktop->priv->icons_font_size_set = use_icon_font_size; |
1622 | - |
1623 | - if(desktop->priv->icon_view) { |
1624 | - if(!use_icon_font_size) { |
1625 | - xfce_desktop_ensure_system_font_size(desktop); |
1626 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
1627 | - desktop->priv->system_font_size); |
1628 | - } else { |
1629 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
1630 | - desktop->priv->icons_font_size); |
1631 | - } |
1632 | - } |
1633 | -#endif |
1634 | -} |
1635 | - |
1636 | -static void |
1637 | -xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, |
1638 | - gboolean single_workspace) |
1639 | -{ |
1640 | - gint i; |
1641 | - |
1642 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1643 | - |
1644 | - if(single_workspace == desktop->priv->single_workspace_mode) |
1645 | - return; |
1646 | - |
1647 | - desktop->priv->single_workspace_mode = single_workspace; |
1648 | - |
1649 | - DBG("single_workspace_mode now %s", single_workspace ? "TRUE" : "FALSE"); |
1650 | - |
1651 | - /* update the workspaces & backdrops if they should cache their pixbuf */ |
1652 | - if(desktop->priv->workspaces) { |
1653 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
1654 | - /* set cache to TRUE when single_workspace is FALSE */ |
1655 | - xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[i], !single_workspace); |
1656 | - } |
1657 | - } |
1658 | - |
1659 | - /* If the desktop has been realized then fake a screen size change to |
1660 | - * update the backdrop. There's no reason to if there's no desktop yet */ |
1661 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1662 | - screen_size_changed_cb(desktop->priv->gscreen, desktop); |
1663 | -} |
1664 | - |
1665 | -static void |
1666 | -xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, |
1667 | - gint workspace_num) |
1668 | -{ |
1669 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1670 | - |
1671 | - if(workspace_num == desktop->priv->single_workspace_num) |
1672 | - return; |
1673 | - |
1674 | - DBG("single_workspace_num now %d", workspace_num); |
1675 | - |
1676 | - desktop->priv->single_workspace_num = workspace_num; |
1677 | - |
1678 | - if(xfce_desktop_get_single_workspace_mode(desktop)) { |
1679 | - /* Fake a screen size changed to update the backdrop */ |
1680 | - screen_size_changed_cb(desktop->priv->gscreen, desktop); |
1681 | - } |
1682 | -} |
1683 | - |
1684 | -void |
1685 | -xfce_desktop_set_session_logout_func(XfceDesktop *desktop, |
1686 | - SessionLogoutFunc logout_func) |
1687 | -{ |
1688 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1689 | - desktop->priv->session_logout_func = logout_func; |
1690 | -} |
1691 | - |
1692 | -void |
1693 | -xfce_desktop_freeze_updates(XfceDesktop *desktop) |
1694 | -{ |
1695 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1696 | - desktop->priv->updates_frozen = TRUE; |
1697 | -} |
1698 | - |
1699 | -void |
1700 | -xfce_desktop_thaw_updates(XfceDesktop *desktop) |
1701 | -{ |
1702 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1703 | - |
1704 | - desktop->priv->updates_frozen = FALSE; |
1705 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1706 | - xfce_desktop_monitors_changed(desktop->priv->gscreen, desktop); |
1707 | -} |
1708 | - |
1709 | -static gboolean |
1710 | -xfce_desktop_menu_destroy_idled(gpointer data) |
1711 | -{ |
1712 | - gtk_widget_destroy(GTK_WIDGET(data)); |
1713 | - return FALSE; |
1714 | -} |
1715 | - |
1716 | -static void |
1717 | -xfce_desktop_do_menu_popup(XfceDesktop *desktop, |
1718 | - guint button, |
1719 | - guint activate_time, |
1720 | - guint populate_signal) |
1721 | -{ |
1722 | - GdkScreen *screen; |
1723 | - GtkWidget *menu; |
1724 | - GList *menu_children; |
1725 | - |
1726 | - TRACE("entering"); |
1727 | - |
1728 | - if(gtk_widget_has_screen(GTK_WIDGET(desktop))) |
1729 | - screen = gtk_widget_get_screen(GTK_WIDGET(desktop)); |
1730 | - else |
1731 | - screen = gdk_display_get_default_screen(gdk_display_get_default()); |
1732 | - |
1733 | - menu = gtk_menu_new(); |
1734 | - gtk_menu_set_screen(GTK_MENU(menu), screen); |
1735 | - g_signal_connect_swapped(G_OBJECT(menu), "deactivate", |
1736 | - G_CALLBACK(g_idle_add), |
1737 | - (gpointer)xfce_desktop_menu_destroy_idled); |
1738 | - |
1739 | - g_signal_emit(G_OBJECT(desktop), populate_signal, 0, menu); |
1740 | - |
1741 | - /* if nobody populated the menu, don't do anything */ |
1742 | - menu_children = gtk_container_get_children(GTK_CONTAINER(menu)); |
1743 | - if(!menu_children) { |
1744 | - gtk_widget_destroy(menu); |
1745 | - return; |
1746 | - } |
1747 | - |
1748 | - g_list_free(menu_children); |
1749 | - |
1750 | - gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL); |
1751 | - |
1752 | - /* Per gtk_menu_popup's documentation "for conflict-resolve initiation of |
1753 | - * concurrent requests for mouse/keyboard grab requests." */ |
1754 | - if(activate_time == 0) |
1755 | - activate_time = gtk_get_current_event_time(); |
1756 | - |
1757 | - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, activate_time); |
1758 | -} |
1759 | - |
1760 | -void |
1761 | -xfce_desktop_popup_root_menu(XfceDesktop *desktop, |
1762 | - guint button, |
1763 | - guint activate_time) |
1764 | -{ |
1765 | - TRACE("entering"); |
1766 | - |
1767 | - /* If it's launched by xfdesktop --menu we won't have an event time. |
1768 | - * Grab the keyboard focus */ |
1769 | - if(activate_time == 0) |
1770 | - activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); |
1771 | - |
1772 | - xfce_desktop_do_menu_popup(desktop, button, activate_time, |
1773 | - signals[SIG_POPULATE_ROOT_MENU]); |
1774 | - |
1775 | -} |
1776 | - |
1777 | -void |
1778 | -xfce_desktop_popup_secondary_root_menu(XfceDesktop *desktop, |
1779 | - guint button, |
1780 | - guint activate_time) |
1781 | -{ |
1782 | - /* If it's launched by xfdesktop --windowlist we won't have an event time. |
1783 | - * Grab the keyboard focus */ |
1784 | - if(activate_time == 0) |
1785 | - activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); |
1786 | - |
1787 | - xfce_desktop_do_menu_popup(desktop, button, activate_time, |
1788 | - signals[SIG_POPULATE_SECONDARY_ROOT_MENU]); |
1789 | -} |
1790 | -void |
1791 | -xfce_desktop_refresh(XfceDesktop *desktop) |
1792 | -{ |
1793 | - gint i, current_workspace; |
1794 | - |
1795 | - TRACE("entering"); |
1796 | - |
1797 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1798 | - |
1799 | - if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1800 | - return; |
1801 | - |
1802 | - if(desktop->priv->workspaces == NULL) { |
1803 | - return; |
1804 | - } |
1805 | - |
1806 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
1807 | - |
1808 | - /* reload backgrounds */ |
1809 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
1810 | - XfceBackdrop *backdrop; |
1811 | - |
1812 | - backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
1813 | - |
1814 | - backdrop_changed_cb(backdrop, desktop); |
1815 | - } |
1816 | - |
1817 | -#ifdef ENABLE_DESKTOP_ICONS |
1818 | - /* reload icon view */ |
1819 | - if(desktop->priv->icon_view) { |
1820 | - gtk_widget_destroy(desktop->priv->icon_view); |
1821 | - desktop->priv->icon_view = NULL; |
1822 | - } |
1823 | - xfce_desktop_setup_icon_view(desktop); |
1824 | -#endif |
1825 | - |
1826 | -} |
1827 | - |
1828 | -void xfce_desktop_arrange_icons(XfceDesktop *desktop) |
1829 | -{ |
1830 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
1831 | - |
1832 | -#ifdef ENABLE_DESKTOP_ICONS |
1833 | - g_return_if_fail(XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view)); |
1834 | - |
1835 | - xfdesktop_icon_view_sort_icons(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view)); |
1836 | -#endif |
1837 | -} |
1838 | |
1839 | === removed directory '.pc/git-fix-default-icon-size.patch' |
1840 | === removed directory '.pc/git-fix-default-icon-size.patch/src' |
1841 | === removed file '.pc/git-fix-default-icon-size.patch/src/xfce-desktop.c' |
1842 | --- .pc/git-fix-default-icon-size.patch/src/xfce-desktop.c 2014-03-28 07:16:04 +0000 |
1843 | +++ .pc/git-fix-default-icon-size.patch/src/xfce-desktop.c 1970-01-01 00:00:00 +0000 |
1844 | @@ -1,1847 +0,0 @@ |
1845 | -/* |
1846 | - * xfdesktop - xfce4's desktop manager |
1847 | - * |
1848 | - * Copyright (c) 2004-2007 Brian Tarricone, <bjt23@cornell.edu> |
1849 | - * |
1850 | - * This program is free software; you can redistribute it and/or modify |
1851 | - * it under the terms of the GNU General Public License as published by |
1852 | - * the Free Software Foundation; either version 2 of the License, or |
1853 | - * (at your option) any later version. |
1854 | - * |
1855 | - * This program is distributed in the hope that it will be useful, |
1856 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1857 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1858 | - * GNU Library General Public License for more details. |
1859 | - * |
1860 | - * You should have received a copy of the GNU General Public License |
1861 | - * along with this program; if not, write to the Free Software Foundation, |
1862 | - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
1863 | - * |
1864 | - * Random portions taken from or inspired by the original xfdesktop for xfce4: |
1865 | - * Copyright (C) 2002-2003 Jasper Huijsmans (huysmans@users.sourceforge.net) |
1866 | - * Copyright (C) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> |
1867 | - */ |
1868 | - |
1869 | -#ifdef HAVE_CONFIG_H |
1870 | -#include <config.h> |
1871 | -#endif |
1872 | - |
1873 | -#include <stdio.h> |
1874 | - |
1875 | -#ifdef HAVE_STDLIB_H |
1876 | -#include <stdlib.h> |
1877 | -#endif |
1878 | - |
1879 | -#ifdef HAVE_STRING_H |
1880 | -#include <string.h> |
1881 | -#endif |
1882 | - |
1883 | -#ifdef HAVE_SYS_TYPES_H |
1884 | -#include <sys/types.h> |
1885 | -#endif |
1886 | -#ifdef HAVE_SYS_STAT_H |
1887 | -#include <sys/stat.h> |
1888 | -#endif |
1889 | -#ifdef HAVE_UNISTD_H |
1890 | -#include <unistd.h> |
1891 | -#endif |
1892 | - |
1893 | -#ifdef HAVE_FCNTL_H |
1894 | -#include <fcntl.h> |
1895 | -#endif |
1896 | - |
1897 | -#include <ctype.h> |
1898 | -#include <errno.h> |
1899 | - |
1900 | -#ifdef HAVE_TIME_H |
1901 | -#include <time.h> |
1902 | -#endif |
1903 | - |
1904 | -#include <X11/Xlib.h> |
1905 | -#include <X11/Xatom.h> |
1906 | - |
1907 | -#include <glib.h> |
1908 | -#include <gdk/gdkx.h> |
1909 | -#include <gtk/gtk.h> |
1910 | -#include <gio/gio.h> |
1911 | - |
1912 | -#ifdef ENABLE_DESKTOP_ICONS |
1913 | -#include "xfdesktop-icon-view.h" |
1914 | -#include "xfdesktop-window-icon-manager.h" |
1915 | -# ifdef ENABLE_FILE_ICONS |
1916 | -# include "xfdesktop-file-icon-manager.h" |
1917 | -# include "xfdesktop-special-file-icon.h" |
1918 | -# endif |
1919 | -#endif |
1920 | - |
1921 | -#include <libxfce4util/libxfce4util.h> |
1922 | -#include <libxfce4ui/libxfce4ui.h> |
1923 | - |
1924 | -#include <xfconf/xfconf.h> |
1925 | -#include <libwnck/libwnck.h> |
1926 | - |
1927 | -#include "xfdesktop-common.h" |
1928 | -#include "xfce-desktop.h" |
1929 | -#include "xfce-desktop-enum-types.h" |
1930 | -#include "xfce-workspace.h" |
1931 | - |
1932 | -/* disable setting the x background for bug 7442 */ |
1933 | -//#define DISABLE_FOR_BUG7442 |
1934 | - |
1935 | -struct _XfceDesktopPriv |
1936 | -{ |
1937 | - GdkScreen *gscreen; |
1938 | - WnckScreen *wnck_screen; |
1939 | - gboolean updates_frozen; |
1940 | - |
1941 | - XfconfChannel *channel; |
1942 | - gchar *property_prefix; |
1943 | - |
1944 | - GdkPixmap *bg_pixmap; |
1945 | - |
1946 | - gint nworkspaces; |
1947 | - XfceWorkspace **workspaces; |
1948 | - gint current_workspace; |
1949 | - |
1950 | - gboolean single_workspace_mode; |
1951 | - gint single_workspace_num; |
1952 | - |
1953 | - SessionLogoutFunc session_logout_func; |
1954 | - |
1955 | - guint32 grab_time; |
1956 | - |
1957 | -#ifdef ENABLE_DESKTOP_ICONS |
1958 | - XfceDesktopIconStyle icons_style; |
1959 | - gboolean icons_font_size_set; |
1960 | - guint icons_font_size; |
1961 | - guint icons_size; |
1962 | - gint style_refresh_timer; |
1963 | - GtkWidget *icon_view; |
1964 | - gdouble system_font_size; |
1965 | -#endif |
1966 | -}; |
1967 | - |
1968 | -enum |
1969 | -{ |
1970 | - SIG_POPULATE_ROOT_MENU = 0, |
1971 | - SIG_POPULATE_SECONDARY_ROOT_MENU, |
1972 | - N_SIGNALS |
1973 | -}; |
1974 | - |
1975 | -enum |
1976 | -{ |
1977 | - PROP_0 = 0, |
1978 | -#ifdef ENABLE_DESKTOP_ICONS |
1979 | - PROP_ICON_STYLE, |
1980 | - PROP_ICON_SIZE, |
1981 | - PROP_ICON_FONT_SIZE, |
1982 | - PROP_ICON_FONT_SIZE_SET, |
1983 | -#endif |
1984 | - PROP_SINGLE_WORKSPACE_MODE, |
1985 | - PROP_SINGLE_WORKSPACE_NUMBER, |
1986 | -}; |
1987 | - |
1988 | - |
1989 | -static void xfce_desktop_finalize(GObject *object); |
1990 | -static void xfce_desktop_set_property(GObject *object, |
1991 | - guint property_id, |
1992 | - const GValue *value, |
1993 | - GParamSpec *pspec); |
1994 | -static void xfce_desktop_get_property(GObject *object, |
1995 | - guint property_id, |
1996 | - GValue *value, |
1997 | - GParamSpec *pspec); |
1998 | - |
1999 | -static void xfce_desktop_realize(GtkWidget *widget); |
2000 | -static void xfce_desktop_unrealize(GtkWidget *widget); |
2001 | -static gboolean xfce_desktop_button_press_event(GtkWidget *widget, |
2002 | - GdkEventButton *evt); |
2003 | -static gboolean xfce_desktop_button_release_event(GtkWidget *widget, |
2004 | - GdkEventButton *evt); |
2005 | -static gboolean xfce_desktop_popup_menu(GtkWidget *widget); |
2006 | - |
2007 | -static gboolean xfce_desktop_expose(GtkWidget *w, |
2008 | - GdkEventExpose *evt); |
2009 | -static gboolean xfce_desktop_delete_event(GtkWidget *w, |
2010 | - GdkEventAny *evt); |
2011 | -static void xfce_desktop_style_set(GtkWidget *w, |
2012 | - GtkStyle *old_style); |
2013 | - |
2014 | -static void xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, |
2015 | - gboolean single_workspace); |
2016 | -static void xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, |
2017 | - gint workspace_num); |
2018 | - |
2019 | -static gboolean xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop); |
2020 | -static gint xfce_desktop_get_current_workspace(XfceDesktop *desktop); |
2021 | - |
2022 | -static guint signals[N_SIGNALS] = { 0, }; |
2023 | - |
2024 | -/* private functions */ |
2025 | - |
2026 | -#ifdef ENABLE_DESKTOP_ICONS |
2027 | -static gdouble |
2028 | -xfce_desktop_ensure_system_font_size(XfceDesktop *desktop) |
2029 | -{ |
2030 | - GdkScreen *gscreen; |
2031 | - GtkSettings *settings; |
2032 | - gchar *font_name = NULL; |
2033 | - PangoFontDescription *pfd; |
2034 | - |
2035 | - gscreen = gtk_widget_get_screen(GTK_WIDGET(desktop)); |
2036 | - |
2037 | - settings = gtk_settings_get_for_screen(gscreen); |
2038 | - g_object_get(G_OBJECT(settings), "gtk-font-name", &font_name, NULL); |
2039 | - |
2040 | - pfd = pango_font_description_from_string(font_name); |
2041 | - desktop->priv->system_font_size = pango_font_description_get_size(pfd); |
2042 | - /* FIXME: this seems backwards from the documentation */ |
2043 | - if(!pango_font_description_get_size_is_absolute(pfd)) { |
2044 | - DBG("dividing by PANGO_SCALE"); |
2045 | - desktop->priv->system_font_size /= PANGO_SCALE; |
2046 | - } |
2047 | - DBG("system font size is %.05f", desktop->priv->system_font_size); |
2048 | - |
2049 | - g_free(font_name); |
2050 | - pango_font_description_free(pfd); |
2051 | - |
2052 | - return desktop->priv->system_font_size; |
2053 | -} |
2054 | - |
2055 | -static void |
2056 | -xfce_desktop_setup_icon_view(XfceDesktop *desktop) |
2057 | -{ |
2058 | - XfdesktopIconViewManager *manager = NULL; |
2059 | - |
2060 | - switch(desktop->priv->icons_style) { |
2061 | - case XFCE_DESKTOP_ICON_STYLE_NONE: |
2062 | - /* nada */ |
2063 | - break; |
2064 | - |
2065 | - case XFCE_DESKTOP_ICON_STYLE_WINDOWS: |
2066 | - manager = xfdesktop_window_icon_manager_new(desktop->priv->gscreen); |
2067 | - break; |
2068 | - |
2069 | -#ifdef ENABLE_FILE_ICONS |
2070 | - case XFCE_DESKTOP_ICON_STYLE_FILES: |
2071 | - { |
2072 | - GFile *file; |
2073 | - const gchar *desktop_path; |
2074 | - |
2075 | - desktop_path = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); |
2076 | - file = g_file_new_for_path(desktop_path); |
2077 | - manager = xfdesktop_file_icon_manager_new(file, desktop->priv->channel); |
2078 | - g_object_unref(file); |
2079 | - } |
2080 | - break; |
2081 | -#endif |
2082 | - |
2083 | - default: |
2084 | - g_critical("Unusable XfceDesktopIconStyle: %d. Unable to " \ |
2085 | - "display desktop icons.", |
2086 | - desktop->priv->icons_style); |
2087 | - break; |
2088 | - } |
2089 | - |
2090 | - if(manager) { |
2091 | - xfce_desktop_ensure_system_font_size(desktop); |
2092 | - |
2093 | - desktop->priv->icon_view = xfdesktop_icon_view_new(manager); |
2094 | - /* If the user set a custom font size, use it. Otherwise use the system |
2095 | - * font size */ |
2096 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
2097 | - (!desktop->priv->icons_font_size_set) |
2098 | - ? desktop->priv->system_font_size |
2099 | - : desktop->priv->icons_font_size); |
2100 | - if(desktop->priv->icons_size > 0) { |
2101 | - xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
2102 | - desktop->priv->icons_size); |
2103 | - } |
2104 | - gtk_widget_show(desktop->priv->icon_view); |
2105 | - gtk_container_add(GTK_CONTAINER(desktop), desktop->priv->icon_view); |
2106 | - } |
2107 | - |
2108 | - gtk_widget_queue_draw(GTK_WIDGET(desktop)); |
2109 | -} |
2110 | -#endif |
2111 | - |
2112 | -static void |
2113 | -set_imgfile_root_property(XfceDesktop *desktop, const gchar *filename, |
2114 | - gint monitor) |
2115 | -{ |
2116 | - gchar property_name[128]; |
2117 | - |
2118 | - gdk_error_trap_push(); |
2119 | - |
2120 | - g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, monitor); |
2121 | - if(filename) { |
2122 | - gdk_property_change(gdk_screen_get_root_window(desktop->priv->gscreen), |
2123 | - gdk_atom_intern(property_name, FALSE), |
2124 | - gdk_x11_xatom_to_atom(XA_STRING), 8, |
2125 | - GDK_PROP_MODE_REPLACE, |
2126 | - (guchar *)filename, strlen(filename)+1); |
2127 | - } else { |
2128 | - gdk_property_delete(gdk_screen_get_root_window(desktop->priv->gscreen), |
2129 | - gdk_atom_intern(property_name, FALSE)); |
2130 | - } |
2131 | - |
2132 | - gdk_error_trap_pop(); |
2133 | -} |
2134 | - |
2135 | -static void |
2136 | -set_real_root_window_pixmap(GdkScreen *gscreen, |
2137 | - GdkPixmap *pmap) |
2138 | -{ |
2139 | -#ifndef DISABLE_FOR_BUG7442 |
2140 | - Window xid; |
2141 | - GdkWindow *groot; |
2142 | - |
2143 | - xid = GDK_DRAWABLE_XID(pmap); |
2144 | - groot = gdk_screen_get_root_window(gscreen); |
2145 | - |
2146 | - gdk_error_trap_push(); |
2147 | - |
2148 | - /* set root property for transparent Eterms */ |
2149 | - gdk_property_change(groot, |
2150 | - gdk_atom_intern("_XROOTPMAP_ID", FALSE), |
2151 | - gdk_atom_intern("PIXMAP", FALSE), 32, |
2152 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
2153 | - /* and set the root window's BG pixmap, because aterm is somewhat lame. */ |
2154 | - gdk_window_set_back_pixmap(groot, pmap, FALSE); |
2155 | - /* there really should be a standard for this crap... */ |
2156 | - |
2157 | - gdk_error_trap_pop(); |
2158 | -#endif |
2159 | -} |
2160 | - |
2161 | -static GdkPixmap * |
2162 | -create_bg_pixmap(GdkScreen *gscreen, gpointer user_data) |
2163 | -{ |
2164 | - XfceDesktop *desktop = user_data; |
2165 | - gint w, h; |
2166 | - |
2167 | - TRACE("entering"); |
2168 | - |
2169 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), NULL); |
2170 | - |
2171 | - /* If the workspaces haven't been created yet there's no need to do the |
2172 | - * background pixmap */ |
2173 | - if(desktop->priv->workspaces == NULL) { |
2174 | - DBG("exiting, desktop->priv->workspaces == NULL"); |
2175 | - return NULL; |
2176 | - } |
2177 | - |
2178 | - TRACE("really entering"); |
2179 | - |
2180 | - w = gdk_screen_get_width(gscreen); |
2181 | - h = gdk_screen_get_height(gscreen); |
2182 | - gtk_widget_set_size_request(GTK_WIDGET(desktop), w, h); |
2183 | - gtk_window_resize(GTK_WINDOW(desktop), w, h); |
2184 | - |
2185 | - if(desktop->priv->bg_pixmap) |
2186 | - g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); |
2187 | - desktop->priv->bg_pixmap = gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(GTK_WIDGET(desktop))), |
2188 | - w, h, -1); |
2189 | - |
2190 | - if(!GDK_IS_PIXMAP(desktop->priv->bg_pixmap)) |
2191 | - return NULL; |
2192 | - |
2193 | - gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), |
2194 | - desktop->priv->bg_pixmap, FALSE); |
2195 | - |
2196 | - return desktop->priv->bg_pixmap; |
2197 | -} |
2198 | - |
2199 | -static void |
2200 | -set_accountsservice_user_bg(const gchar *filename) |
2201 | -{ |
2202 | - GDBusProxy *proxy = NULL; |
2203 | - GDBusProxy *user = NULL; |
2204 | - GVariant *variant = NULL; |
2205 | - GError *error = NULL; |
2206 | - gchar *object_path = NULL; |
2207 | - const gchar *user_name = g_get_user_name(); |
2208 | - |
2209 | - proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, |
2210 | - G_DBUS_PROXY_FLAGS_NONE, |
2211 | - NULL, |
2212 | - "org.freedesktop.Accounts", |
2213 | - "/org/freedesktop/Accounts", |
2214 | - "org.freedesktop.Accounts", |
2215 | - NULL, |
2216 | - &error); |
2217 | - |
2218 | - if(!proxy) { |
2219 | - DBG("Failed to contact accounts service: %s", error->message); |
2220 | - g_error_free(error); |
2221 | - return; |
2222 | - } |
2223 | - |
2224 | - variant = g_dbus_proxy_call_sync(proxy, |
2225 | - "FindUserByName", |
2226 | - g_variant_new("(s)", user_name), |
2227 | - G_DBUS_CALL_FLAGS_NONE, |
2228 | - -1, |
2229 | - NULL, |
2230 | - &error); |
2231 | - |
2232 | - if(!variant) { |
2233 | - DBG("Could not contact accounts service to look up '%s': %s", |
2234 | - user_name, error->message); |
2235 | - g_error_free(error); |
2236 | - goto bail; |
2237 | - } |
2238 | - |
2239 | - g_variant_get(variant, "(o)", &object_path); |
2240 | - user = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, |
2241 | - G_DBUS_PROXY_FLAGS_NONE, |
2242 | - NULL, |
2243 | - "org.freedesktop.Accounts", |
2244 | - object_path, |
2245 | - "org.freedesktop.Accounts.User", |
2246 | - NULL, |
2247 | - &error); |
2248 | - g_free(object_path); |
2249 | - |
2250 | - if(!user) { |
2251 | - DBG("Could not create proxy for user '%s': %s", |
2252 | - g_variant_get_string(variant, NULL), error->message); |
2253 | - g_error_free(error); |
2254 | - goto bail; |
2255 | - } |
2256 | - g_variant_unref(variant); |
2257 | - |
2258 | - variant = g_dbus_proxy_call_sync(user, |
2259 | - "SetBackgroundFile", |
2260 | - g_variant_new("(s)", filename), |
2261 | - G_DBUS_CALL_FLAGS_NONE, |
2262 | - -1, |
2263 | - NULL, |
2264 | - &error); |
2265 | - |
2266 | - if(!variant) { |
2267 | - DBG("Failed to set the background '%s': %s", filename, error->message); |
2268 | - g_error_free(error); |
2269 | - goto bail; |
2270 | - } |
2271 | - |
2272 | -bail: |
2273 | - if(user) |
2274 | - g_object_unref(user); |
2275 | - if(proxy) |
2276 | - g_object_unref(proxy); |
2277 | - if(variant) |
2278 | - g_variant_unref(variant); |
2279 | -} |
2280 | - |
2281 | -static void |
2282 | -backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data) |
2283 | -{ |
2284 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2285 | - GdkPixmap *pmap = desktop->priv->bg_pixmap; |
2286 | - GdkScreen *gscreen = desktop->priv->gscreen; |
2287 | - GdkRectangle rect; |
2288 | - GdkRegion *clip_region = NULL; |
2289 | - gint i, monitor = -1, current_workspace; |
2290 | -#ifdef G_ENABLE_DEBUG |
2291 | - gchar *monitor_name = NULL; |
2292 | -#endif |
2293 | - |
2294 | - TRACE("entering"); |
2295 | - |
2296 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
2297 | - |
2298 | - if(!XFCE_IS_BACKDROP(backdrop)) |
2299 | - return; |
2300 | - |
2301 | - if(desktop->priv->updates_frozen || !gtk_widget_get_realized(GTK_WIDGET(desktop))) |
2302 | - return; |
2303 | - |
2304 | - TRACE("really entering"); |
2305 | - |
2306 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
2307 | - |
2308 | - /* Find out which monitor the backdrop is on */ |
2309 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
2310 | - if(backdrop == xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i)) { |
2311 | - monitor = i; |
2312 | - break; |
2313 | - } |
2314 | - } |
2315 | - if(monitor == -1) |
2316 | - return; |
2317 | - /* notify Accountsservice of the new bg (only for monitor0) */ |
2318 | - if(monitor == 0) |
2319 | - if (xfce_desktop_get_current_workspace(desktop) == 0) |
2320 | - set_accountsservice_user_bg(xfce_backdrop_get_image_filename(backdrop)); |
2321 | - |
2322 | -#ifdef G_ENABLE_DEBUG |
2323 | - monitor_name = gdk_screen_get_monitor_plug_name(gscreen, monitor); |
2324 | - |
2325 | - DBG("backdrop changed for workspace %d, monitor %d (%s)", current_workspace, monitor, monitor_name); |
2326 | - |
2327 | - g_free(monitor_name); |
2328 | -#endif |
2329 | - |
2330 | - if(xfce_desktop_get_n_monitors(desktop) > 1 |
2331 | - && xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
2332 | - /* Spanning screens */ |
2333 | - GdkRectangle monitor_rect; |
2334 | - |
2335 | - gdk_screen_get_monitor_geometry(gscreen, 0, &rect); |
2336 | - /* Get the lowest x and y value for all the monitors in |
2337 | - * case none of them start at 0,0 for whatever reason. |
2338 | - */ |
2339 | - for(i = 1; i < xfce_desktop_get_n_monitors(desktop); i++) { |
2340 | - gdk_screen_get_monitor_geometry(gscreen, i, &monitor_rect); |
2341 | - |
2342 | - if(monitor_rect.x < rect.x) |
2343 | - rect.x = monitor_rect.x; |
2344 | - if(monitor_rect.y < rect.y) |
2345 | - rect.y = monitor_rect.y; |
2346 | - } |
2347 | - |
2348 | - rect.width = gdk_screen_get_width(gscreen); |
2349 | - rect.height = gdk_screen_get_height(gscreen); |
2350 | - DBG("xinerama_stretch x %d, y %d, width %d, height %d", |
2351 | - rect.x, rect.y, rect.width, rect.height); |
2352 | - } else { |
2353 | - gdk_screen_get_monitor_geometry(gscreen, monitor, &rect); |
2354 | - DBG("monitor x %d, y %d, width %d, height %d", |
2355 | - rect.x, rect.y, rect.width, rect.height); |
2356 | - } |
2357 | - |
2358 | - xfce_backdrop_set_size(backdrop, rect.width, rect.height); |
2359 | - |
2360 | - if(monitor > 0 |
2361 | - && !xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
2362 | - clip_region = gdk_region_rectangle(&rect); |
2363 | - |
2364 | - DBG("clip_region: x: %d, y: %d, w: %d, h: %d", |
2365 | - rect.x, rect.y, rect.width, rect.height); |
2366 | - |
2367 | - /* If we are not monitor 0 on a multi-monitor setup we need to subtract |
2368 | - * all the previous monitor regions so we don't draw over them. This |
2369 | - * should prevent the overlap and double backdrop drawing bugs. |
2370 | - */ |
2371 | - for(i = 0; i < monitor; i++) { |
2372 | - GdkRectangle previous_monitor; |
2373 | - GdkRegion *previous_region; |
2374 | - gdk_screen_get_monitor_geometry(gscreen, i, &previous_monitor); |
2375 | - |
2376 | - DBG("previous_monitor: x: %d, y: %d, w: %d, h: %d", |
2377 | - previous_monitor.x, previous_monitor.y, |
2378 | - previous_monitor.width, previous_monitor.height); |
2379 | - |
2380 | - previous_region = gdk_region_rectangle(&previous_monitor); |
2381 | - |
2382 | - gdk_region_subtract(clip_region, previous_region); |
2383 | - |
2384 | - gdk_region_destroy(previous_region); |
2385 | - } |
2386 | - } |
2387 | - |
2388 | - if(clip_region != NULL) { |
2389 | - /* Update the area to redraw to limit the icons/area painted */ |
2390 | - gdk_region_get_clipbox(clip_region, &rect); |
2391 | - DBG("area to update: x: %d, y: %d, w: %d, h: %d", |
2392 | - rect.x, rect.y, rect.width, rect.height); |
2393 | - } |
2394 | - |
2395 | - if(rect.width != 0 && rect.height != 0) { |
2396 | - /* get the composited backdrop pixmap */ |
2397 | - GdkPixbuf *pix = xfce_backdrop_get_pixbuf(backdrop); |
2398 | - cairo_t *cr; |
2399 | - |
2400 | - /* create the backdrop if needed */ |
2401 | - if(!pix) { |
2402 | - xfce_backdrop_generate_async(backdrop); |
2403 | - |
2404 | - if(clip_region != NULL) |
2405 | - gdk_region_destroy(clip_region); |
2406 | - |
2407 | - return; |
2408 | - } |
2409 | - |
2410 | - /* Create the background pixmap if it isn't already */ |
2411 | - if(!GDK_IS_PIXMAP(pmap)) { |
2412 | - pmap = create_bg_pixmap(gscreen, desktop); |
2413 | - |
2414 | - if(!GDK_IS_PIXMAP(pmap)) { |
2415 | - g_object_unref(pix); |
2416 | - |
2417 | - if(clip_region != NULL) |
2418 | - gdk_region_destroy(clip_region); |
2419 | - |
2420 | - return; |
2421 | - } |
2422 | - } |
2423 | - |
2424 | - cr = gdk_cairo_create(GDK_DRAWABLE(pmap)); |
2425 | - gdk_cairo_set_source_pixbuf(cr, pix, rect.x, rect.y); |
2426 | - |
2427 | - /* clip the area so we don't draw over a previous wallpaper */ |
2428 | - if(clip_region != NULL) { |
2429 | - gdk_cairo_region(cr, clip_region); |
2430 | - cairo_clip(cr); |
2431 | - } |
2432 | - |
2433 | - cairo_paint(cr); |
2434 | - |
2435 | - /* tell gtk to redraw the repainted area */ |
2436 | - gtk_widget_queue_draw_area(GTK_WIDGET(desktop), rect.x, rect.y, |
2437 | - rect.width, rect.height); |
2438 | - |
2439 | - set_imgfile_root_property(desktop, |
2440 | - xfce_backdrop_get_image_filename(backdrop), |
2441 | - monitor); |
2442 | - |
2443 | - /* do this again so apps watching the root win notice the update */ |
2444 | - set_real_root_window_pixmap(gscreen, pmap); |
2445 | - |
2446 | - g_object_unref(G_OBJECT(pix)); |
2447 | - cairo_destroy(cr); |
2448 | - gtk_widget_show(GTK_WIDGET(desktop)); |
2449 | - } |
2450 | - |
2451 | - if(clip_region != NULL) |
2452 | - gdk_region_destroy(clip_region); |
2453 | -} |
2454 | - |
2455 | -static void |
2456 | -screen_size_changed_cb(GdkScreen *gscreen, gpointer user_data) |
2457 | -{ |
2458 | - XfceDesktop *desktop = user_data; |
2459 | - gint current_workspace; |
2460 | - |
2461 | - TRACE("entering"); |
2462 | - |
2463 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
2464 | - |
2465 | - if(desktop->priv->nworkspaces <= current_workspace) |
2466 | - return; |
2467 | - |
2468 | - if(current_workspace < 0) |
2469 | - return; |
2470 | - |
2471 | - /* release the bg_pixmap since the dimensions may have changed */ |
2472 | - if(desktop->priv->bg_pixmap) { |
2473 | - g_object_unref(desktop->priv->bg_pixmap); |
2474 | - desktop->priv->bg_pixmap = NULL; |
2475 | - } |
2476 | - |
2477 | - /* special case for 1 backdrop to handle xinerama stretching */ |
2478 | - if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { |
2479 | - backdrop_changed_cb(xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], 0), desktop); |
2480 | - } else { |
2481 | - gint i; |
2482 | - |
2483 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
2484 | - XfceBackdrop *current_backdrop; |
2485 | - current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
2486 | - backdrop_changed_cb(current_backdrop, desktop); |
2487 | - } |
2488 | - } |
2489 | -} |
2490 | - |
2491 | -static void |
2492 | -screen_composited_changed_cb(GdkScreen *gscreen, |
2493 | - gpointer user_data) |
2494 | -{ |
2495 | - TRACE("entering"); |
2496 | - /* fake a screen size changed, so the background is properly set */ |
2497 | - screen_size_changed_cb(gscreen, user_data); |
2498 | -} |
2499 | - |
2500 | -static void |
2501 | -xfce_desktop_monitors_changed(GdkScreen *gscreen, |
2502 | - gpointer user_data) |
2503 | -{ |
2504 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2505 | - gint i; |
2506 | - |
2507 | - TRACE("entering"); |
2508 | - |
2509 | - /* Update the workspaces */ |
2510 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
2511 | - xfce_workspace_monitors_changed(desktop->priv->workspaces[i], |
2512 | - gscreen); |
2513 | - } |
2514 | - |
2515 | - /* fake a screen size changed, so the background is properly set */ |
2516 | - screen_size_changed_cb(gscreen, user_data); |
2517 | -} |
2518 | - |
2519 | -static void |
2520 | -workspace_backdrop_changed_cb(XfceWorkspace *workspace, |
2521 | - XfceBackdrop *backdrop, |
2522 | - gpointer user_data) |
2523 | -{ |
2524 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2525 | - |
2526 | - TRACE("entering"); |
2527 | - |
2528 | - g_return_if_fail(XFCE_IS_WORKSPACE(workspace) && XFCE_IS_BACKDROP(backdrop)); |
2529 | - |
2530 | - if(xfce_desktop_get_current_workspace(desktop) == xfce_workspace_get_workspace_num(workspace)) |
2531 | - backdrop_changed_cb(backdrop, user_data); |
2532 | -} |
2533 | - |
2534 | -static void |
2535 | -workspace_changed_cb(WnckScreen *wnck_screen, |
2536 | - WnckWorkspace *previously_active_space, |
2537 | - gpointer user_data) |
2538 | -{ |
2539 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2540 | - gint current_workspace, new_workspace, i; |
2541 | - XfceBackdrop *current_backdrop, *new_backdrop; |
2542 | - |
2543 | - TRACE("entering"); |
2544 | - |
2545 | - /* Ignore workspace changes in single workspace mode so long as we |
2546 | - * already have the bg_pixmap loaded */ |
2547 | - if(xfce_desktop_get_single_workspace_mode(desktop) && desktop->priv->bg_pixmap) |
2548 | - return; |
2549 | - |
2550 | - current_workspace = desktop->priv->current_workspace; |
2551 | - new_workspace = xfce_desktop_get_current_workspace(desktop); |
2552 | - |
2553 | - if(new_workspace < 0 || new_workspace >= desktop->priv->nworkspaces) |
2554 | - return; |
2555 | - |
2556 | - desktop->priv->current_workspace = new_workspace; |
2557 | - |
2558 | - DBG("current_workspace %d, new_workspace %d", |
2559 | - current_workspace, new_workspace); |
2560 | - |
2561 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
2562 | - /* We want to compare the current workspace backdrop with the new one |
2563 | - * and see if we can avoid changing them if they are the same image/style */ |
2564 | - if(current_workspace < desktop->priv->nworkspaces && current_workspace >= 0) { |
2565 | - current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
2566 | - new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); |
2567 | - |
2568 | - if(!xfce_backdrop_compare_backdrops(current_backdrop, new_backdrop) || !desktop->priv->bg_pixmap) { |
2569 | - /* only update monitors that require it */ |
2570 | - backdrop_changed_cb(new_backdrop, user_data); |
2571 | - } |
2572 | - } else { |
2573 | - /* If current_workspace was removed or never existed, get the new |
2574 | - * backdrop and apply it */ |
2575 | - new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); |
2576 | - backdrop_changed_cb(new_backdrop, user_data); |
2577 | - } |
2578 | - |
2579 | - /* When we're spanning screens we only care about the first monitor */ |
2580 | - if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[new_workspace])) |
2581 | - break; |
2582 | - } |
2583 | -} |
2584 | - |
2585 | -static void |
2586 | -workspace_created_cb(WnckScreen *wnck_screen, |
2587 | - WnckWorkspace *new_workspace, |
2588 | - gpointer user_data) |
2589 | -{ |
2590 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2591 | - gint nlast_workspace; |
2592 | - TRACE("entering"); |
2593 | - |
2594 | - nlast_workspace = desktop->priv->nworkspaces; |
2595 | - |
2596 | - /* add one more workspace */ |
2597 | - desktop->priv->nworkspaces = nlast_workspace + 1; |
2598 | - |
2599 | - /* allocate size for it */ |
2600 | - desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, |
2601 | - desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); |
2602 | - |
2603 | - /* create the new workspace and set it up */ |
2604 | - desktop->priv->workspaces[nlast_workspace] = xfce_workspace_new(desktop->priv->gscreen, |
2605 | - desktop->priv->channel, |
2606 | - desktop->priv->property_prefix, |
2607 | - nlast_workspace); |
2608 | - |
2609 | - /* Tell workspace whether to cache pixbufs */ |
2610 | - xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[nlast_workspace], |
2611 | - !desktop->priv->single_workspace_mode); |
2612 | - |
2613 | - xfce_workspace_monitors_changed(desktop->priv->workspaces[nlast_workspace], |
2614 | - desktop->priv->gscreen); |
2615 | - |
2616 | - g_signal_connect(desktop->priv->workspaces[nlast_workspace], |
2617 | - "workspace-backdrop-changed", |
2618 | - G_CALLBACK(workspace_backdrop_changed_cb), desktop); |
2619 | -} |
2620 | - |
2621 | -static void |
2622 | -workspace_destroyed_cb(WnckScreen *wnck_screen, |
2623 | - WnckWorkspace *old_workspace, |
2624 | - gpointer user_data) |
2625 | -{ |
2626 | - XfceDesktop *desktop = XFCE_DESKTOP(user_data); |
2627 | - gint nlast_workspace; |
2628 | - TRACE("entering"); |
2629 | - |
2630 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
2631 | - g_return_if_fail(desktop->priv->nworkspaces - 1 >= 0); |
2632 | - g_return_if_fail(XFCE_IS_WORKSPACE(desktop->priv->workspaces[desktop->priv->nworkspaces-1])); |
2633 | - |
2634 | - nlast_workspace = desktop->priv->nworkspaces - 1; |
2635 | - |
2636 | - g_signal_handlers_disconnect_by_func(desktop->priv->workspaces[nlast_workspace], |
2637 | - G_CALLBACK(workspace_backdrop_changed_cb), |
2638 | - desktop); |
2639 | - |
2640 | - g_object_unref(desktop->priv->workspaces[nlast_workspace]); |
2641 | - |
2642 | - /* Remove one workspace */ |
2643 | - desktop->priv->nworkspaces = nlast_workspace; |
2644 | - |
2645 | - /* deallocate it */ |
2646 | - desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, |
2647 | - desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); |
2648 | - |
2649 | - /* Make sure we stay within bounds now that we removed a workspace */ |
2650 | - if(desktop->priv->current_workspace > desktop->priv->nworkspaces) |
2651 | - desktop->priv->current_workspace = desktop->priv->nworkspaces; |
2652 | -} |
2653 | - |
2654 | -static void |
2655 | -screen_set_selection(XfceDesktop *desktop) |
2656 | -{ |
2657 | - Window xwin; |
2658 | - gint xscreen; |
2659 | - gchar selection_name[100], common_selection_name[32]; |
2660 | - Atom selection_atom, common_selection_atom, manager_atom; |
2661 | - |
2662 | - xwin = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); |
2663 | - xscreen = gdk_screen_get_number(desktop->priv->gscreen); |
2664 | - |
2665 | - g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen); |
2666 | - selection_atom = XInternAtom(gdk_x11_get_default_xdisplay(), selection_name, False); |
2667 | - manager_atom = XInternAtom(gdk_x11_get_default_xdisplay(), "MANAGER", False); |
2668 | - |
2669 | - g_snprintf(common_selection_name, 32, "_NET_DESKTOP_MANAGER_S%d", xscreen); |
2670 | - common_selection_atom = XInternAtom(gdk_x11_get_default_xdisplay(), common_selection_name, False); |
2671 | - |
2672 | - /* the previous check in src/main.c occurs too early, so workaround by |
2673 | - * adding this one. */ |
2674 | - if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) != None) { |
2675 | - g_warning("%s: already running, quitting.", PACKAGE); |
2676 | - exit(0); |
2677 | - } |
2678 | - |
2679 | - /* Check that _NET_DESKTOP_MANAGER_S%d isn't set, as it means another |
2680 | - * desktop manager is running, e.g. nautilus */ |
2681 | - if(XGetSelectionOwner (gdk_x11_get_default_xdisplay(), common_selection_atom) != None) { |
2682 | - g_warning("%s: another desktop manager is running.", PACKAGE); |
2683 | - exit(1); |
2684 | - } |
2685 | - |
2686 | - XSelectInput(gdk_x11_get_default_xdisplay(), xwin, PropertyChangeMask | ButtonPressMask); |
2687 | - XSetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom, xwin, GDK_CURRENT_TIME); |
2688 | - XSetSelectionOwner(gdk_x11_get_default_xdisplay(), common_selection_atom, xwin, GDK_CURRENT_TIME); |
2689 | - |
2690 | - /* Check to see if we managed to claim the selection. If not, |
2691 | - * we treat it as if we got it then immediately lost it */ |
2692 | - if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) == xwin) { |
2693 | - XClientMessageEvent xev; |
2694 | - Window xroot = GDK_WINDOW_XID(gdk_screen_get_root_window(desktop->priv->gscreen)); |
2695 | - |
2696 | - xev.type = ClientMessage; |
2697 | - xev.window = xroot; |
2698 | - xev.message_type = manager_atom; |
2699 | - xev.format = 32; |
2700 | - xev.data.l[0] = GDK_CURRENT_TIME; |
2701 | - xev.data.l[1] = selection_atom; |
2702 | - xev.data.l[2] = xwin; |
2703 | - xev.data.l[3] = 0; /* manager specific data */ |
2704 | - xev.data.l[4] = 0; /* manager specific data */ |
2705 | - |
2706 | - XSendEvent(gdk_x11_get_default_xdisplay(), xroot, False, StructureNotifyMask, (XEvent *)&xev); |
2707 | - } else { |
2708 | - g_error("%s: could not set selection ownership", PACKAGE); |
2709 | - exit(1); |
2710 | - } |
2711 | -} |
2712 | - |
2713 | - |
2714 | - |
2715 | -/* gobject-related functions */ |
2716 | - |
2717 | - |
2718 | -G_DEFINE_TYPE(XfceDesktop, xfce_desktop, GTK_TYPE_WINDOW) |
2719 | - |
2720 | - |
2721 | -static void |
2722 | -xfce_desktop_class_init(XfceDesktopClass *klass) |
2723 | -{ |
2724 | - GObjectClass *gobject_class = (GObjectClass *)klass; |
2725 | - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; |
2726 | - |
2727 | - g_type_class_add_private(klass, sizeof(XfceDesktopPriv)); |
2728 | - |
2729 | - gobject_class->finalize = xfce_desktop_finalize; |
2730 | - gobject_class->set_property = xfce_desktop_set_property; |
2731 | - gobject_class->get_property = xfce_desktop_get_property; |
2732 | - |
2733 | - widget_class->realize = xfce_desktop_realize; |
2734 | - widget_class->unrealize = xfce_desktop_unrealize; |
2735 | - widget_class->button_press_event = xfce_desktop_button_press_event; |
2736 | - widget_class->button_release_event = xfce_desktop_button_release_event; |
2737 | - widget_class->expose_event = xfce_desktop_expose; |
2738 | - widget_class->delete_event = xfce_desktop_delete_event; |
2739 | - widget_class->popup_menu = xfce_desktop_popup_menu; |
2740 | - widget_class->style_set = xfce_desktop_style_set; |
2741 | - |
2742 | - signals[SIG_POPULATE_ROOT_MENU] = g_signal_new("populate-root-menu", |
2743 | - XFCE_TYPE_DESKTOP, |
2744 | - G_SIGNAL_RUN_LAST, |
2745 | - G_STRUCT_OFFSET(XfceDesktopClass, |
2746 | - populate_root_menu), |
2747 | - NULL, NULL, |
2748 | - g_cclosure_marshal_VOID__OBJECT, |
2749 | - G_TYPE_NONE, 1, |
2750 | - GTK_TYPE_MENU_SHELL); |
2751 | - |
2752 | - signals[SIG_POPULATE_SECONDARY_ROOT_MENU] = g_signal_new("populate-secondary-root-menu", |
2753 | - XFCE_TYPE_DESKTOP, |
2754 | - G_SIGNAL_RUN_LAST, |
2755 | - G_STRUCT_OFFSET(XfceDesktopClass, |
2756 | - populate_secondary_root_menu), |
2757 | - NULL, NULL, |
2758 | - g_cclosure_marshal_VOID__OBJECT, |
2759 | - G_TYPE_NONE, 1, |
2760 | - GTK_TYPE_MENU_SHELL); |
2761 | - |
2762 | -#define XFDESKTOP_PARAM_FLAGS (G_PARAM_READWRITE \ |
2763 | - | G_PARAM_CONSTRUCT \ |
2764 | - | G_PARAM_STATIC_NAME \ |
2765 | - | G_PARAM_STATIC_NICK \ |
2766 | - | G_PARAM_STATIC_BLURB) |
2767 | - |
2768 | -#ifdef ENABLE_DESKTOP_ICONS |
2769 | - g_object_class_install_property(gobject_class, PROP_ICON_STYLE, |
2770 | - g_param_spec_enum("icon-style", |
2771 | - "icon style", |
2772 | - "icon style", |
2773 | - XFCE_TYPE_DESKTOP_ICON_STYLE, |
2774 | -#ifdef ENABLE_FILE_ICONS |
2775 | - XFCE_DESKTOP_ICON_STYLE_FILES, |
2776 | -#else |
2777 | - XFCE_DESKTOP_ICON_STYLE_WINDOWS, |
2778 | -#endif /* ENABLE_FILE_ICONS */ |
2779 | - XFDESKTOP_PARAM_FLAGS)); |
2780 | - |
2781 | - g_object_class_install_property(gobject_class, PROP_ICON_SIZE, |
2782 | - g_param_spec_uint("icon-size", |
2783 | - "icon size", |
2784 | - "icon size", |
2785 | - 8, 192, 36, |
2786 | - XFDESKTOP_PARAM_FLAGS)); |
2787 | - |
2788 | - g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE, |
2789 | - g_param_spec_uint("icon-font-size", |
2790 | - "icon font size", |
2791 | - "icon font size", |
2792 | - 0, 144, 12, |
2793 | - XFDESKTOP_PARAM_FLAGS)); |
2794 | - |
2795 | - g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE_SET, |
2796 | - g_param_spec_boolean("icon-font-size-set", |
2797 | - "icon font size set", |
2798 | - "icon font size set", |
2799 | - FALSE, |
2800 | - XFDESKTOP_PARAM_FLAGS)); |
2801 | - |
2802 | -#endif /* ENABLE_DESKTOP_ICONS */ |
2803 | - |
2804 | - g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_MODE, |
2805 | - g_param_spec_boolean("single-workspace-mode", |
2806 | - "single-workspace-mode", |
2807 | - "single-workspace-mode", |
2808 | - TRUE, |
2809 | - XFDESKTOP_PARAM_FLAGS)); |
2810 | - |
2811 | - g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_NUMBER, |
2812 | - g_param_spec_int("single-workspace-number", |
2813 | - "single-workspace-number", |
2814 | - "single-workspace-number", |
2815 | - 0, G_MAXINT16, 0, |
2816 | - XFDESKTOP_PARAM_FLAGS)); |
2817 | - |
2818 | -#undef XFDESKTOP_PARAM_FLAGS |
2819 | -} |
2820 | - |
2821 | -static void |
2822 | -xfce_desktop_init(XfceDesktop *desktop) |
2823 | -{ |
2824 | - desktop->priv = G_TYPE_INSTANCE_GET_PRIVATE(desktop, XFCE_TYPE_DESKTOP, |
2825 | - XfceDesktopPriv); |
2826 | - |
2827 | - gtk_window_set_type_hint(GTK_WINDOW(desktop), GDK_WINDOW_TYPE_HINT_DESKTOP); |
2828 | - /* Accept focus is needed for the menu pop up either by the menu key on |
2829 | - * the keyboard or Shift+F10. */ |
2830 | - gtk_window_set_accept_focus(GTK_WINDOW(desktop), TRUE); |
2831 | - /* Can focus is needed for the gtk_grab_add/remove commands */ |
2832 | - gtk_widget_set_can_focus(GTK_WIDGET(desktop), TRUE); |
2833 | - gtk_window_set_resizable(GTK_WINDOW(desktop), FALSE); |
2834 | -} |
2835 | - |
2836 | -static void |
2837 | -xfce_desktop_finalize(GObject *object) |
2838 | -{ |
2839 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
2840 | - |
2841 | - g_object_unref(G_OBJECT(desktop->priv->channel)); |
2842 | - g_free(desktop->priv->property_prefix); |
2843 | - |
2844 | - if(desktop->priv->style_refresh_timer != 0) |
2845 | - g_source_remove(desktop->priv->style_refresh_timer); |
2846 | - |
2847 | - G_OBJECT_CLASS(xfce_desktop_parent_class)->finalize(object); |
2848 | -} |
2849 | - |
2850 | -static void |
2851 | -xfce_desktop_set_property(GObject *object, |
2852 | - guint property_id, |
2853 | - const GValue *value, |
2854 | - GParamSpec *pspec) |
2855 | -{ |
2856 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
2857 | - |
2858 | - switch(property_id) { |
2859 | -#ifdef ENABLE_DESKTOP_ICONS |
2860 | - case PROP_ICON_STYLE: |
2861 | - xfce_desktop_set_icon_style(desktop, |
2862 | - g_value_get_enum(value)); |
2863 | - break; |
2864 | - |
2865 | - case PROP_ICON_SIZE: |
2866 | - xfce_desktop_set_icon_size(desktop, |
2867 | - g_value_get_uint(value)); |
2868 | - break; |
2869 | - |
2870 | - case PROP_ICON_FONT_SIZE: |
2871 | - xfce_desktop_set_icon_font_size(desktop, |
2872 | - g_value_get_uint(value)); |
2873 | - break; |
2874 | - |
2875 | - case PROP_ICON_FONT_SIZE_SET: |
2876 | - xfce_desktop_set_use_icon_font_size(desktop, |
2877 | - g_value_get_boolean(value)); |
2878 | - break; |
2879 | - |
2880 | -#endif |
2881 | - case PROP_SINGLE_WORKSPACE_MODE: |
2882 | - xfce_desktop_set_single_workspace_mode(desktop, |
2883 | - g_value_get_boolean(value)); |
2884 | - break; |
2885 | - |
2886 | - case PROP_SINGLE_WORKSPACE_NUMBER: |
2887 | - xfce_desktop_set_single_workspace_number(desktop, |
2888 | - g_value_get_int(value)); |
2889 | - break; |
2890 | - |
2891 | - default: |
2892 | - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
2893 | - break; |
2894 | - } |
2895 | -} |
2896 | - |
2897 | -static void |
2898 | -xfce_desktop_get_property(GObject *object, |
2899 | - guint property_id, |
2900 | - GValue *value, |
2901 | - GParamSpec *pspec) |
2902 | -{ |
2903 | - XfceDesktop *desktop = XFCE_DESKTOP(object); |
2904 | - |
2905 | - switch(property_id) { |
2906 | -#ifdef ENABLE_DESKTOP_ICONS |
2907 | - case PROP_ICON_STYLE: |
2908 | - g_value_set_enum(value, desktop->priv->icons_style); |
2909 | - break; |
2910 | - |
2911 | - case PROP_ICON_SIZE: |
2912 | - g_value_set_uint(value, desktop->priv->icons_size); |
2913 | - break; |
2914 | - |
2915 | - case PROP_ICON_FONT_SIZE: |
2916 | - g_value_set_uint(value, desktop->priv->icons_font_size); |
2917 | - break; |
2918 | - |
2919 | - case PROP_ICON_FONT_SIZE_SET: |
2920 | - g_value_set_boolean(value, desktop->priv->icons_font_size_set); |
2921 | - break; |
2922 | - |
2923 | -#endif |
2924 | - case PROP_SINGLE_WORKSPACE_MODE: |
2925 | - g_value_set_boolean(value, desktop->priv->single_workspace_mode); |
2926 | - break; |
2927 | - |
2928 | - case PROP_SINGLE_WORKSPACE_NUMBER: |
2929 | - g_value_set_int(value, desktop->priv->single_workspace_num); |
2930 | - break; |
2931 | - |
2932 | - default: |
2933 | - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
2934 | - break; |
2935 | - } |
2936 | -} |
2937 | - |
2938 | -static void |
2939 | -xfce_desktop_realize(GtkWidget *widget) |
2940 | -{ |
2941 | - XfceDesktop *desktop = XFCE_DESKTOP(widget); |
2942 | - GdkAtom atom; |
2943 | - gint sw, sh; |
2944 | - Window xid; |
2945 | - GdkWindow *groot; |
2946 | - WnckScreen *wnck_screen; |
2947 | - |
2948 | - TRACE("entering"); |
2949 | - |
2950 | - gtk_window_set_screen(GTK_WINDOW(desktop), desktop->priv->gscreen); |
2951 | - sw = gdk_screen_get_width(desktop->priv->gscreen); |
2952 | - sh = gdk_screen_get_height(desktop->priv->gscreen); |
2953 | - |
2954 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), |
2955 | - "monitors-changed", |
2956 | - G_CALLBACK(xfce_desktop_monitors_changed), |
2957 | - desktop); |
2958 | - |
2959 | - /* chain up */ |
2960 | - GTK_WIDGET_CLASS(xfce_desktop_parent_class)->realize(widget); |
2961 | - |
2962 | - gtk_window_set_title(GTK_WINDOW(desktop), _("Desktop")); |
2963 | - |
2964 | - gtk_widget_set_size_request(GTK_WIDGET(desktop), sw, sh); |
2965 | - gtk_window_move(GTK_WINDOW(desktop), 0, 0); |
2966 | - |
2967 | - atom = gdk_atom_intern("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE); |
2968 | - gdk_property_change(gtk_widget_get_window(GTK_WIDGET(desktop)), |
2969 | - gdk_atom_intern("_NET_WM_WINDOW_TYPE", FALSE), |
2970 | - gdk_atom_intern("ATOM", FALSE), 32, |
2971 | - GDK_PROP_MODE_REPLACE, (guchar *)&atom, 1); |
2972 | - |
2973 | - xid = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); |
2974 | - groot = gdk_screen_get_root_window(desktop->priv->gscreen); |
2975 | - |
2976 | - gdk_property_change(groot, |
2977 | - gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE), |
2978 | - gdk_atom_intern("WINDOW", FALSE), 32, |
2979 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
2980 | - |
2981 | - gdk_property_change(groot, |
2982 | - gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE), |
2983 | - gdk_atom_intern("WINDOW", FALSE), 32, |
2984 | - GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); |
2985 | - |
2986 | - screen_set_selection(desktop); |
2987 | - |
2988 | - wnck_screen = wnck_screen_get(gdk_screen_get_number(desktop->priv->gscreen)); |
2989 | - desktop->priv->wnck_screen = wnck_screen; |
2990 | - |
2991 | - /* Watch for single workspace setting changes */ |
2992 | - xfconf_g_property_bind(desktop->priv->channel, |
2993 | - SINGLE_WORKSPACE_MODE, G_TYPE_BOOLEAN, |
2994 | - G_OBJECT(desktop), "single-workspace-mode"); |
2995 | - xfconf_g_property_bind(desktop->priv->channel, |
2996 | - SINGLE_WORKSPACE_NUMBER, G_TYPE_INT, |
2997 | - G_OBJECT(desktop), "single-workspace-number"); |
2998 | - |
2999 | - /* watch for workspace changes */ |
3000 | - g_signal_connect(desktop->priv->wnck_screen, "active-workspace-changed", |
3001 | - G_CALLBACK(workspace_changed_cb), desktop); |
3002 | - g_signal_connect(desktop->priv->wnck_screen, "workspace-created", |
3003 | - G_CALLBACK(workspace_created_cb), desktop); |
3004 | - g_signal_connect(desktop->priv->wnck_screen, "workspace-destroyed", |
3005 | - G_CALLBACK(workspace_destroyed_cb), desktop); |
3006 | - |
3007 | - /* watch for screen changes */ |
3008 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), "size-changed", |
3009 | - G_CALLBACK(screen_size_changed_cb), desktop); |
3010 | - g_signal_connect(G_OBJECT(desktop->priv->gscreen), "composited-changed", |
3011 | - G_CALLBACK(screen_composited_changed_cb), desktop); |
3012 | - |
3013 | - gtk_widget_add_events(GTK_WIDGET(desktop), GDK_EXPOSURE_MASK); |
3014 | - |
3015 | -#ifdef ENABLE_DESKTOP_ICONS |
3016 | - xfce_desktop_setup_icon_view(desktop); |
3017 | -#endif |
3018 | - |
3019 | - TRACE("exiting"); |
3020 | -} |
3021 | - |
3022 | -static void |
3023 | -xfce_desktop_unrealize(GtkWidget *widget) |
3024 | -{ |
3025 | - XfceDesktop *desktop = XFCE_DESKTOP(widget); |
3026 | - gint i; |
3027 | - GdkWindow *groot; |
3028 | - gchar property_name[128]; |
3029 | - |
3030 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3031 | - |
3032 | - /* disconnect all the xfconf settings to this desktop */ |
3033 | - xfconf_g_property_unbind_all(G_OBJECT(desktop)); |
3034 | - |
3035 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
3036 | - G_CALLBACK(xfce_desktop_monitors_changed), |
3037 | - desktop); |
3038 | - |
3039 | - if(gtk_widget_get_mapped(widget)) |
3040 | - gtk_widget_unmap(widget); |
3041 | - gtk_widget_set_mapped(widget, FALSE); |
3042 | - |
3043 | - gtk_container_forall(GTK_CONTAINER(widget), |
3044 | - (GtkCallback)gtk_widget_unrealize, |
3045 | - NULL); |
3046 | - |
3047 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
3048 | - G_CALLBACK(screen_size_changed_cb), desktop); |
3049 | - g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), |
3050 | - G_CALLBACK(screen_composited_changed_cb), desktop); |
3051 | - |
3052 | - gdk_error_trap_push(); |
3053 | - |
3054 | - groot = gdk_screen_get_root_window(desktop->priv->gscreen); |
3055 | - gdk_property_delete(groot, gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE)); |
3056 | - gdk_property_delete(groot, gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE)); |
3057 | - |
3058 | -#ifndef DISABLE_FOR_BUG7442 |
3059 | - gdk_property_delete(groot, gdk_atom_intern("_XROOTPMAP_ID", FALSE)); |
3060 | - gdk_property_delete(groot, gdk_atom_intern("ESETROOT_PMAP_ID", FALSE)); |
3061 | - gdk_window_set_back_pixmap(groot, NULL, FALSE); |
3062 | -#endif |
3063 | - |
3064 | - if(desktop->priv->workspaces) { |
3065 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
3066 | - g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, i); |
3067 | - gdk_property_delete(groot, gdk_atom_intern(property_name, FALSE)); |
3068 | - g_object_unref(G_OBJECT(desktop->priv->workspaces[i])); |
3069 | - } |
3070 | - g_free(desktop->priv->workspaces); |
3071 | - desktop->priv->workspaces = NULL; |
3072 | - } |
3073 | - |
3074 | - gdk_flush(); |
3075 | - gdk_error_trap_pop(); |
3076 | - |
3077 | - if(desktop->priv->bg_pixmap) { |
3078 | - g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); |
3079 | - desktop->priv->bg_pixmap = NULL; |
3080 | - } |
3081 | - |
3082 | - gtk_window_set_icon(GTK_WINDOW(widget), NULL); |
3083 | - |
3084 | - gtk_style_detach(gtk_widget_get_style(widget)); |
3085 | - g_object_unref(G_OBJECT(gtk_widget_get_window(widget))); |
3086 | - gtk_widget_set_window(widget, NULL); |
3087 | - |
3088 | - gtk_selection_remove_all(widget); |
3089 | - |
3090 | - gtk_widget_set_realized(widget, FALSE); |
3091 | -} |
3092 | - |
3093 | -static gboolean |
3094 | -xfce_desktop_button_press_event(GtkWidget *w, |
3095 | - GdkEventButton *evt) |
3096 | -{ |
3097 | - guint button = evt->button; |
3098 | - guint state = evt->state; |
3099 | - XfceDesktop *desktop = XFCE_DESKTOP(w); |
3100 | - |
3101 | - TRACE("entering"); |
3102 | - |
3103 | - g_return_val_if_fail(XFCE_IS_DESKTOP(w), FALSE); |
3104 | - |
3105 | - if(evt->type == GDK_BUTTON_PRESS) { |
3106 | - if(button == 3 || (button == 1 && (state & GDK_SHIFT_MASK))) { |
3107 | -#ifdef ENABLE_DESKTOP_ICONS |
3108 | - /* Let the icon view handle these menu pop ups */ |
3109 | - if(desktop->priv->icons_style != XFCE_DESKTOP_ICON_STYLE_NONE) |
3110 | - return FALSE; |
3111 | -#endif |
3112 | - /* no icons on the desktop, grab the focus and pop up the menu */ |
3113 | - if(!gtk_widget_has_grab(w)) |
3114 | - gtk_grab_add(w); |
3115 | - |
3116 | - xfce_desktop_popup_root_menu(desktop, button, evt->time); |
3117 | - return TRUE; |
3118 | - } else if(button == 2 || (button == 1 && (state & GDK_SHIFT_MASK) |
3119 | - && (state & GDK_CONTROL_MASK))) |
3120 | - { |
3121 | - /* always grab the focus and pop up the menu */ |
3122 | - if(!gtk_widget_has_grab(w)) |
3123 | - gtk_grab_add(w); |
3124 | - |
3125 | - xfce_desktop_popup_secondary_root_menu(desktop, button, evt->time); |
3126 | - return TRUE; |
3127 | - } |
3128 | - } |
3129 | - |
3130 | - return FALSE; |
3131 | -} |
3132 | - |
3133 | -static gboolean |
3134 | -xfce_desktop_button_release_event(GtkWidget *w, |
3135 | - GdkEventButton *evt) |
3136 | -{ |
3137 | - TRACE("entering"); |
3138 | - |
3139 | - gtk_grab_remove(w); |
3140 | - |
3141 | - return FALSE; |
3142 | -} |
3143 | - |
3144 | -/* This function gets called when the user presses the menu key on the keyboard. |
3145 | - * Or Shift+F10 or whatever key binding the user has chosen. */ |
3146 | -static gboolean |
3147 | -xfce_desktop_popup_menu(GtkWidget *w) |
3148 | -{ |
3149 | - GdkEventButton *evt; |
3150 | - guint button, etime; |
3151 | - |
3152 | - TRACE("entering"); |
3153 | - |
3154 | - evt = (GdkEventButton *)gtk_get_current_event(); |
3155 | - if(evt && GDK_BUTTON_PRESS == evt->type) { |
3156 | - button = evt->button; |
3157 | - etime = evt->time; |
3158 | - } else { |
3159 | - button = 0; |
3160 | - etime = gtk_get_current_event_time(); |
3161 | - } |
3162 | - |
3163 | - xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), button, etime); |
3164 | - |
3165 | - gdk_event_free((GdkEvent*)evt); |
3166 | - return TRUE; |
3167 | -} |
3168 | - |
3169 | -static gboolean |
3170 | -xfce_desktop_expose(GtkWidget *w, |
3171 | - GdkEventExpose *evt) |
3172 | -{ |
3173 | - GList *children, *l; |
3174 | - |
3175 | - /*TRACE("entering");*/ |
3176 | - |
3177 | - if(evt->count != 0) |
3178 | - return FALSE; |
3179 | - |
3180 | - gdk_window_clear_area(gtk_widget_get_window(w), evt->area.x, evt->area.y, |
3181 | - evt->area.width, evt->area.height); |
3182 | - |
3183 | - children = gtk_container_get_children(GTK_CONTAINER(w)); |
3184 | - for(l = children; l; l = l->next) { |
3185 | - gtk_container_propagate_expose(GTK_CONTAINER(w), |
3186 | - GTK_WIDGET(l->data), |
3187 | - evt); |
3188 | - } |
3189 | - g_list_free(children); |
3190 | - |
3191 | - return FALSE; |
3192 | -} |
3193 | - |
3194 | -static gboolean |
3195 | -xfce_desktop_delete_event(GtkWidget *w, |
3196 | - GdkEventAny *evt) |
3197 | -{ |
3198 | - if(XFCE_DESKTOP(w)->priv->session_logout_func) |
3199 | - XFCE_DESKTOP(w)->priv->session_logout_func(); |
3200 | - |
3201 | - return TRUE; |
3202 | -} |
3203 | - |
3204 | -static gboolean |
3205 | -style_refresh_cb(gpointer *w) |
3206 | -{ |
3207 | - XfceDesktop *desktop = XFCE_DESKTOP(w); |
3208 | -#ifdef ENABLE_DESKTOP_ICONS |
3209 | - gdouble old_font_size; |
3210 | -#endif |
3211 | - |
3212 | - TRACE("entering"); |
3213 | - |
3214 | - desktop->priv->style_refresh_timer = 0; |
3215 | - |
3216 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), FALSE); |
3217 | - |
3218 | - if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
3219 | - return FALSE; |
3220 | - |
3221 | - if(desktop->priv->workspaces == NULL) |
3222 | - return FALSE; |
3223 | - |
3224 | - if(GDK_IS_WINDOW(desktop->priv->bg_pixmap)) |
3225 | - gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), desktop->priv->bg_pixmap, FALSE); |
3226 | - |
3227 | - gtk_widget_queue_draw(GTK_WIDGET(desktop)); |
3228 | - |
3229 | -#ifdef ENABLE_DESKTOP_ICONS |
3230 | - if(!desktop->priv->icon_view || !XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view)) |
3231 | - return FALSE; |
3232 | - |
3233 | - /* reset the icon view style */ |
3234 | - gtk_widget_set_style(desktop->priv->icon_view, NULL); |
3235 | - gtk_widget_reset_rc_styles(desktop->priv->icon_view); |
3236 | - |
3237 | - old_font_size = desktop->priv->system_font_size; |
3238 | - if(xfce_desktop_ensure_system_font_size(desktop) != old_font_size |
3239 | - && desktop->priv->icon_view && !desktop->priv->icons_font_size_set) |
3240 | - { |
3241 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
3242 | - desktop->priv->system_font_size); |
3243 | - } |
3244 | -#endif |
3245 | - |
3246 | - return FALSE; |
3247 | -} |
3248 | - |
3249 | -static void |
3250 | -xfce_desktop_style_set(GtkWidget *w, GtkStyle *old_style) |
3251 | -{ |
3252 | - XfceDesktop *desktop = XFCE_DESKTOP(w); |
3253 | - |
3254 | - TRACE("entering"); |
3255 | - |
3256 | - if(desktop->priv->style_refresh_timer != 0) |
3257 | - g_source_remove(desktop->priv->style_refresh_timer); |
3258 | - |
3259 | - desktop->priv->style_refresh_timer = g_idle_add_full(G_PRIORITY_LOW, |
3260 | - (GSourceFunc)style_refresh_cb, |
3261 | - w, |
3262 | - NULL); |
3263 | - |
3264 | - GTK_WIDGET_CLASS(xfce_desktop_parent_class)->style_set(w, old_style); |
3265 | -} |
3266 | - |
3267 | -static void |
3268 | -xfce_desktop_connect_settings(XfceDesktop *desktop) |
3269 | -{ |
3270 | -#ifdef ENABLE_DESKTOP_ICONS |
3271 | -#define ICONS_PREFIX "/desktop-icons/" |
3272 | - XfconfChannel *channel = desktop->priv->channel; |
3273 | - |
3274 | - xfce_desktop_freeze_updates(desktop); |
3275 | - |
3276 | - xfconf_g_property_bind(channel, ICONS_PREFIX "style", |
3277 | - XFCE_TYPE_DESKTOP_ICON_STYLE, |
3278 | - G_OBJECT(desktop), "icon-style"); |
3279 | - xfconf_g_property_bind(channel, ICONS_PREFIX "icon-size", G_TYPE_UINT, |
3280 | - G_OBJECT(desktop), "icon-size"); |
3281 | - xfconf_g_property_bind(channel, ICONS_PREFIX "font-size", G_TYPE_UINT, |
3282 | - G_OBJECT(desktop), "icon-font-size"); |
3283 | - xfconf_g_property_bind(channel, ICONS_PREFIX "use-custom-font-size", |
3284 | - G_TYPE_BOOLEAN, |
3285 | - G_OBJECT(desktop), "icon-font-size-set"); |
3286 | - |
3287 | - xfce_desktop_thaw_updates(desktop); |
3288 | -#undef ICONS_PREFIX |
3289 | -#endif |
3290 | -} |
3291 | - |
3292 | -static gboolean |
3293 | -xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop) |
3294 | -{ |
3295 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), TRUE); |
3296 | - |
3297 | - return desktop->priv->single_workspace_mode; |
3298 | -} |
3299 | - |
3300 | -static gint |
3301 | -xfce_desktop_get_current_workspace(XfceDesktop *desktop) |
3302 | -{ |
3303 | - WnckWorkspace *wnck_workspace; |
3304 | - gint workspace_num, current_workspace; |
3305 | - |
3306 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
3307 | - |
3308 | - wnck_workspace = wnck_screen_get_active_workspace(desktop->priv->wnck_screen); |
3309 | - |
3310 | - if(wnck_workspace != NULL) { |
3311 | - workspace_num = wnck_workspace_get_number(wnck_workspace); |
3312 | - } else { |
3313 | - workspace_num = desktop->priv->nworkspaces; |
3314 | - } |
3315 | - |
3316 | - /* If we're in single_workspace mode we need to return the workspace that |
3317 | - * it was set to, if possible, otherwise return the current workspace */ |
3318 | - if(xfce_desktop_get_single_workspace_mode(desktop) && |
3319 | - desktop->priv->single_workspace_num < desktop->priv->nworkspaces) { |
3320 | - current_workspace = desktop->priv->single_workspace_num; |
3321 | - } else { |
3322 | - current_workspace = workspace_num; |
3323 | - } |
3324 | - |
3325 | - DBG("workspace_num %d, single_workspace_num %d, current_workspace %d, max workspaces %d", |
3326 | - workspace_num, desktop->priv->single_workspace_num, current_workspace, |
3327 | - desktop->priv->nworkspaces); |
3328 | - |
3329 | - return current_workspace; |
3330 | -} |
3331 | - |
3332 | -/* public api */ |
3333 | - |
3334 | -/** |
3335 | - * xfce_desktop_new: |
3336 | - * @gscreen: The current #GdkScreen. |
3337 | - * @channel: An #XfconfChannel to use for settings. |
3338 | - * @property_prefix: String prefix for per-screen properties. |
3339 | - * |
3340 | - * Creates a new #XfceDesktop for the specified #GdkScreen. If @gscreen is |
3341 | - * %NULL, the default screen will be used. |
3342 | - * |
3343 | - * Return value: A new #XfceDesktop. |
3344 | - **/ |
3345 | -GtkWidget * |
3346 | -xfce_desktop_new(GdkScreen *gscreen, |
3347 | - XfconfChannel *channel, |
3348 | - const gchar *property_prefix) |
3349 | -{ |
3350 | - XfceDesktop *desktop; |
3351 | - |
3352 | - g_return_val_if_fail(channel && property_prefix, NULL); |
3353 | - |
3354 | - desktop = g_object_new(XFCE_TYPE_DESKTOP, NULL); |
3355 | - |
3356 | - if(!gscreen) |
3357 | - gscreen = gdk_display_get_default_screen(gdk_display_get_default()); |
3358 | - gtk_window_set_screen(GTK_WINDOW(desktop), gscreen); |
3359 | - desktop->priv->gscreen = gscreen; |
3360 | - |
3361 | - desktop->priv->channel = g_object_ref(G_OBJECT(channel)); |
3362 | - desktop->priv->property_prefix = g_strdup(property_prefix); |
3363 | - |
3364 | - xfce_desktop_connect_settings(desktop); |
3365 | - |
3366 | - return GTK_WIDGET(desktop); |
3367 | -} |
3368 | - |
3369 | -gint |
3370 | -xfce_desktop_get_n_monitors(XfceDesktop *desktop) |
3371 | -{ |
3372 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), 0); |
3373 | - |
3374 | - return gdk_screen_get_n_monitors(desktop->priv->gscreen); |
3375 | -} |
3376 | - |
3377 | -gint |
3378 | -xfce_desktop_get_width(XfceDesktop *desktop) |
3379 | -{ |
3380 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
3381 | - |
3382 | - return gdk_screen_get_width(desktop->priv->gscreen); |
3383 | -} |
3384 | - |
3385 | -gint |
3386 | -xfce_desktop_get_height(XfceDesktop *desktop) |
3387 | -{ |
3388 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); |
3389 | - |
3390 | - return gdk_screen_get_height(desktop->priv->gscreen); |
3391 | -} |
3392 | - |
3393 | -void |
3394 | -xfce_desktop_set_icon_style(XfceDesktop *desktop, |
3395 | - XfceDesktopIconStyle style) |
3396 | -{ |
3397 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop) |
3398 | - && style <= XFCE_DESKTOP_ICON_STYLE_FILES); |
3399 | - |
3400 | -#ifdef ENABLE_DESKTOP_ICONS |
3401 | - if(style == desktop->priv->icons_style) |
3402 | - return; |
3403 | - |
3404 | - if(desktop->priv->icon_view) { |
3405 | - gtk_widget_destroy(desktop->priv->icon_view); |
3406 | - desktop->priv->icon_view = NULL; |
3407 | - } |
3408 | - |
3409 | - desktop->priv->icons_style = style; |
3410 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
3411 | - xfce_desktop_setup_icon_view(desktop); |
3412 | -#endif |
3413 | -} |
3414 | - |
3415 | -XfceDesktopIconStyle |
3416 | -xfce_desktop_get_icon_style(XfceDesktop *desktop) |
3417 | -{ |
3418 | - g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), XFCE_DESKTOP_ICON_STYLE_NONE); |
3419 | - |
3420 | -#ifdef ENABLE_DESKTOP_ICONS |
3421 | - return desktop->priv->icons_style; |
3422 | -#else |
3423 | - return XFCE_DESKTOP_ICON_STYLE_NONE; |
3424 | -#endif |
3425 | -} |
3426 | - |
3427 | -void |
3428 | -xfce_desktop_set_icon_size(XfceDesktop *desktop, |
3429 | - guint icon_size) |
3430 | -{ |
3431 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3432 | - |
3433 | -#ifdef ENABLE_DESKTOP_ICONS |
3434 | - if(icon_size == desktop->priv->icons_size) |
3435 | - return; |
3436 | - |
3437 | - desktop->priv->icons_size = icon_size; |
3438 | - |
3439 | - if(desktop->priv->icon_view) { |
3440 | - xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
3441 | - icon_size); |
3442 | - } |
3443 | -#endif |
3444 | -} |
3445 | - |
3446 | -void |
3447 | -xfce_desktop_set_icon_font_size(XfceDesktop *desktop, |
3448 | - guint font_size_points) |
3449 | -{ |
3450 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3451 | - |
3452 | -#ifdef ENABLE_DESKTOP_ICONS |
3453 | - if(font_size_points == desktop->priv->icons_font_size) |
3454 | - return; |
3455 | - |
3456 | - desktop->priv->icons_font_size = font_size_points; |
3457 | - |
3458 | - if(desktop->priv->icons_font_size_set && desktop->priv->icon_view) { |
3459 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
3460 | - font_size_points); |
3461 | - } |
3462 | -#endif |
3463 | -} |
3464 | - |
3465 | -void |
3466 | -xfce_desktop_set_use_icon_font_size(XfceDesktop *desktop, |
3467 | - gboolean use_icon_font_size) |
3468 | -{ |
3469 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3470 | - |
3471 | -#ifdef ENABLE_DESKTOP_ICONS |
3472 | - if(use_icon_font_size == desktop->priv->icons_font_size_set) |
3473 | - return; |
3474 | - |
3475 | - desktop->priv->icons_font_size_set = use_icon_font_size; |
3476 | - |
3477 | - if(desktop->priv->icon_view) { |
3478 | - if(!use_icon_font_size) { |
3479 | - xfce_desktop_ensure_system_font_size(desktop); |
3480 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
3481 | - desktop->priv->system_font_size); |
3482 | - } else { |
3483 | - xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), |
3484 | - desktop->priv->icons_font_size); |
3485 | - } |
3486 | - } |
3487 | -#endif |
3488 | -} |
3489 | - |
3490 | -static void |
3491 | -xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, |
3492 | - gboolean single_workspace) |
3493 | -{ |
3494 | - gint i; |
3495 | - |
3496 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3497 | - |
3498 | - if(single_workspace == desktop->priv->single_workspace_mode) |
3499 | - return; |
3500 | - |
3501 | - desktop->priv->single_workspace_mode = single_workspace; |
3502 | - |
3503 | - DBG("single_workspace_mode now %s", single_workspace ? "TRUE" : "FALSE"); |
3504 | - |
3505 | - /* update the workspaces & backdrops if they should cache their pixbuf */ |
3506 | - if(desktop->priv->workspaces) { |
3507 | - for(i = 0; i < desktop->priv->nworkspaces; i++) { |
3508 | - /* set cache to TRUE when single_workspace is FALSE */ |
3509 | - xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[i], !single_workspace); |
3510 | - } |
3511 | - } |
3512 | - |
3513 | - /* If the desktop has been realized then fake a screen size change to |
3514 | - * update the backdrop. There's no reason to if there's no desktop yet */ |
3515 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
3516 | - screen_size_changed_cb(desktop->priv->gscreen, desktop); |
3517 | -} |
3518 | - |
3519 | -static void |
3520 | -xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, |
3521 | - gint workspace_num) |
3522 | -{ |
3523 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3524 | - |
3525 | - if(workspace_num == desktop->priv->single_workspace_num) |
3526 | - return; |
3527 | - |
3528 | - DBG("single_workspace_num now %d", workspace_num); |
3529 | - |
3530 | - desktop->priv->single_workspace_num = workspace_num; |
3531 | - |
3532 | - if(xfce_desktop_get_single_workspace_mode(desktop)) { |
3533 | - /* Fake a screen size changed to update the backdrop */ |
3534 | - screen_size_changed_cb(desktop->priv->gscreen, desktop); |
3535 | - } |
3536 | -} |
3537 | - |
3538 | -void |
3539 | -xfce_desktop_set_session_logout_func(XfceDesktop *desktop, |
3540 | - SessionLogoutFunc logout_func) |
3541 | -{ |
3542 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3543 | - desktop->priv->session_logout_func = logout_func; |
3544 | -} |
3545 | - |
3546 | -void |
3547 | -xfce_desktop_freeze_updates(XfceDesktop *desktop) |
3548 | -{ |
3549 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3550 | - desktop->priv->updates_frozen = TRUE; |
3551 | -} |
3552 | - |
3553 | -void |
3554 | -xfce_desktop_thaw_updates(XfceDesktop *desktop) |
3555 | -{ |
3556 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3557 | - |
3558 | - desktop->priv->updates_frozen = FALSE; |
3559 | - if(gtk_widget_get_realized(GTK_WIDGET(desktop))) |
3560 | - xfce_desktop_monitors_changed(desktop->priv->gscreen, desktop); |
3561 | -} |
3562 | - |
3563 | -static gboolean |
3564 | -xfce_desktop_menu_destroy_idled(gpointer data) |
3565 | -{ |
3566 | - gtk_widget_destroy(GTK_WIDGET(data)); |
3567 | - return FALSE; |
3568 | -} |
3569 | - |
3570 | -static void |
3571 | -xfce_desktop_do_menu_popup(XfceDesktop *desktop, |
3572 | - guint button, |
3573 | - guint activate_time, |
3574 | - guint populate_signal) |
3575 | -{ |
3576 | - GdkScreen *screen; |
3577 | - GtkWidget *menu; |
3578 | - GList *menu_children; |
3579 | - |
3580 | - TRACE("entering"); |
3581 | - |
3582 | - if(gtk_widget_has_screen(GTK_WIDGET(desktop))) |
3583 | - screen = gtk_widget_get_screen(GTK_WIDGET(desktop)); |
3584 | - else |
3585 | - screen = gdk_display_get_default_screen(gdk_display_get_default()); |
3586 | - |
3587 | - menu = gtk_menu_new(); |
3588 | - gtk_menu_set_screen(GTK_MENU(menu), screen); |
3589 | - g_signal_connect_swapped(G_OBJECT(menu), "deactivate", |
3590 | - G_CALLBACK(g_idle_add), |
3591 | - (gpointer)xfce_desktop_menu_destroy_idled); |
3592 | - |
3593 | - g_signal_emit(G_OBJECT(desktop), populate_signal, 0, menu); |
3594 | - |
3595 | - /* if nobody populated the menu, don't do anything */ |
3596 | - menu_children = gtk_container_get_children(GTK_CONTAINER(menu)); |
3597 | - if(!menu_children) { |
3598 | - gtk_widget_destroy(menu); |
3599 | - return; |
3600 | - } |
3601 | - |
3602 | - g_list_free(menu_children); |
3603 | - |
3604 | - gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL); |
3605 | - |
3606 | - /* Per gtk_menu_popup's documentation "for conflict-resolve initiation of |
3607 | - * concurrent requests for mouse/keyboard grab requests." */ |
3608 | - if(activate_time == 0) |
3609 | - activate_time = gtk_get_current_event_time(); |
3610 | - |
3611 | - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, activate_time); |
3612 | -} |
3613 | - |
3614 | -void |
3615 | -xfce_desktop_popup_root_menu(XfceDesktop *desktop, |
3616 | - guint button, |
3617 | - guint activate_time) |
3618 | -{ |
3619 | - TRACE("entering"); |
3620 | - |
3621 | - /* If it's launched by xfdesktop --menu we won't have an event time. |
3622 | - * Grab the keyboard focus */ |
3623 | - if(activate_time == 0) |
3624 | - activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); |
3625 | - |
3626 | - xfce_desktop_do_menu_popup(desktop, button, activate_time, |
3627 | - signals[SIG_POPULATE_ROOT_MENU]); |
3628 | - |
3629 | -} |
3630 | - |
3631 | -void |
3632 | -xfce_desktop_popup_secondary_root_menu(XfceDesktop *desktop, |
3633 | - guint button, |
3634 | - guint activate_time) |
3635 | -{ |
3636 | - /* If it's launched by xfdesktop --windowlist we won't have an event time. |
3637 | - * Grab the keyboard focus */ |
3638 | - if(activate_time == 0) |
3639 | - activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); |
3640 | - |
3641 | - xfce_desktop_do_menu_popup(desktop, button, activate_time, |
3642 | - signals[SIG_POPULATE_SECONDARY_ROOT_MENU]); |
3643 | -} |
3644 | -void |
3645 | -xfce_desktop_refresh(XfceDesktop *desktop) |
3646 | -{ |
3647 | - gint i, current_workspace; |
3648 | - |
3649 | - TRACE("entering"); |
3650 | - |
3651 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3652 | - |
3653 | - if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
3654 | - return; |
3655 | - |
3656 | - if(desktop->priv->workspaces == NULL) { |
3657 | - return; |
3658 | - } |
3659 | - |
3660 | - current_workspace = xfce_desktop_get_current_workspace(desktop); |
3661 | - |
3662 | - /* reload backgrounds */ |
3663 | - for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { |
3664 | - XfceBackdrop *backdrop; |
3665 | - |
3666 | - backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); |
3667 | - |
3668 | - backdrop_changed_cb(backdrop, desktop); |
3669 | - } |
3670 | - |
3671 | -#ifdef ENABLE_DESKTOP_ICONS |
3672 | - /* reload icon view */ |
3673 | - if(desktop->priv->icon_view) { |
3674 | - gtk_widget_destroy(desktop->priv->icon_view); |
3675 | - desktop->priv->icon_view = NULL; |
3676 | - } |
3677 | - xfce_desktop_setup_icon_view(desktop); |
3678 | -#endif |
3679 | - |
3680 | -} |
3681 | - |
3682 | -void xfce_desktop_arrange_icons(XfceDesktop *desktop) |
3683 | -{ |
3684 | - g_return_if_fail(XFCE_IS_DESKTOP(desktop)); |
3685 | - |
3686 | -#ifdef ENABLE_DESKTOP_ICONS |
3687 | - g_return_if_fail(XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view)); |
3688 | - |
3689 | - xfdesktop_icon_view_sort_icons(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view)); |
3690 | -#endif |
3691 | -} |
3692 | |
3693 | === removed directory '.pc/git-missing-images-in-settings-app.patch' |
3694 | === removed directory '.pc/git-missing-images-in-settings-app.patch/settings' |
3695 | === removed file '.pc/git-missing-images-in-settings-app.patch/settings/main.c' |
3696 | --- .pc/git-missing-images-in-settings-app.patch/settings/main.c 2014-03-28 07:16:04 +0000 |
3697 | +++ .pc/git-missing-images-in-settings-app.patch/settings/main.c 1970-01-01 00:00:00 +0000 |
3698 | @@ -1,2101 +0,0 @@ |
3699 | -/* |
3700 | - * xfdesktop |
3701 | - * |
3702 | - * Copyright (c) 2008 Stephan Arts <stephan@xfce.org> |
3703 | - * Copyright (c) 2008 Brian Tarricone <bjt23@cornell.edu> |
3704 | - * Copyright (c) 2008 Jérôme Guelfucci <jerome.guelfucci@gmail.com> |
3705 | - * Copyright (c) 2011 Jannis Pohlmann <jannis@xfce.org> |
3706 | - * |
3707 | - * This program is free software; you can redistribute it and/or modify |
3708 | - * it under the terms of the GNU General Public License as published by |
3709 | - * the Free Software Foundation; either version 2 of the License, or |
3710 | - * (at your option) any later version. |
3711 | - * |
3712 | - * This program is distributed in the hope that it will be useful, |
3713 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3714 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3715 | - * GNU General Public License for more details. |
3716 | - * |
3717 | - * You should have received a copy of the GNU General Public License |
3718 | - * along with this program; if not, write to the Free Software Foundation, |
3719 | - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
3720 | - * |
3721 | - */ |
3722 | - |
3723 | -#ifdef HAVE_CONFIG_H |
3724 | -#include <config.h> |
3725 | -#endif |
3726 | - |
3727 | -#include <stdio.h> |
3728 | - |
3729 | -#ifdef HAVE_STDLIB_H |
3730 | -#include <stdlib.h> |
3731 | -#endif |
3732 | - |
3733 | -#ifdef HAVE_STRING_H |
3734 | -#include <string.h> |
3735 | -#endif |
3736 | - |
3737 | -#ifdef HAVE_ERRNO_H |
3738 | -#include <errno.h> |
3739 | -#endif |
3740 | - |
3741 | -#include <gdk-pixbuf/gdk-pixbuf.h> |
3742 | -#include <gtk/gtk.h> |
3743 | -#include <gdk/gdkx.h> |
3744 | - |
3745 | -#include <libxfce4util/libxfce4util.h> |
3746 | -#include <xfconf/xfconf.h> |
3747 | -#include <libxfce4ui/libxfce4ui.h> |
3748 | -#include <libwnck/libwnck.h> |
3749 | -#include <exo/exo.h> |
3750 | - |
3751 | -#include "xfdesktop-common.h" |
3752 | -#include "xfdesktop-thumbnailer.h" |
3753 | -#include "xfdesktop-settings-ui.h" |
3754 | -#include "xfdesktop-settings-appearance-frame-ui.h" |
3755 | -/* for XfceBackdropImageStyle && XfceBackdropColorStyle */ |
3756 | -#include "xfce-backdrop.h" |
3757 | - |
3758 | -#define MAX_ASPECT_RATIO 1.5f |
3759 | -#define PREVIEW_HEIGHT 96 |
3760 | -#define PREVIEW_WIDTH (PREVIEW_HEIGHT * MAX_ASPECT_RATIO) |
3761 | - |
3762 | - |
3763 | -#define SETTINGS_WINDOW_LAST_WIDTH "/last/window-width" |
3764 | -#define SETTINGS_WINDOW_LAST_HEIGHT "/last/window-height" |
3765 | - |
3766 | -#define SHOW_DESKTOP_MENU_PROP "/desktop-menu/show" |
3767 | -#define DESKTOP_MENU_SHOW_ICONS_PROP "/desktop-menu/show-icons" |
3768 | - |
3769 | -#define WINLIST_SHOW_WINDOWS_MENU_PROP "/windowlist-menu/show" |
3770 | -#define WINLIST_SHOW_APP_ICONS_PROP "/windowlist-menu/show-icons" |
3771 | -#define WINLIST_SHOW_STICKY_WIN_ONCE_PROP "/windowlist-menu/show-sticky-once" |
3772 | -#define WINLIST_SHOW_WS_NAMES_PROP "/windowlist-menu/show-workspace-names" |
3773 | -#define WINLIST_SHOW_WS_SUBMENUS_PROP "/windowlist-menu/show-submenus" |
3774 | -#define WINLIST_SHOW_ADD_REMOVE_WORKSPACES_PROP "/windowlist-menu/show-add-remove-workspaces" |
3775 | - |
3776 | -#define DESKTOP_ICONS_STYLE_PROP "/desktop-icons/style" |
3777 | -#define DESKTOP_ICONS_ICON_SIZE_PROP "/desktop-icons/icon-size" |
3778 | -#define DESKTOP_ICONS_FONT_SIZE_PROP "/desktop-icons/font-size" |
3779 | -#define DESKTOP_ICONS_CUSTOM_FONT_SIZE_PROP "/desktop-icons/use-custom-font-size" |
3780 | -#define DESKTOP_ICONS_SHOW_TOOLTIP_PROP "/desktop-icons/show-tooltips" |
3781 | -#define DESKTOP_ICONS_TOOLTIP_SIZE_PROP "/desktop-icons/tooltip-size" |
3782 | -#define DESKTOP_ICONS_SINGLE_CLICK_PROP "/desktop-icons/single-click" |
3783 | - |
3784 | -typedef struct |
3785 | -{ |
3786 | - GtkTreeModel *model; |
3787 | - GtkTreeIter *iter; |
3788 | -} PreviewData; |
3789 | - |
3790 | -typedef struct |
3791 | -{ |
3792 | - XfconfChannel *channel; |
3793 | - gint screen; |
3794 | - gint monitor; |
3795 | - gint workspace; |
3796 | - gchar *monitor_name; |
3797 | - gulong image_list_loaded:1; |
3798 | - |
3799 | - WnckWindow *wnck_window; |
3800 | - /* We keep track of the current workspace number because |
3801 | - * wnck_screen_get_active_workspace sometimes has to return NULL. */ |
3802 | - gint active_workspace; |
3803 | - |
3804 | - GtkWidget *infobar; |
3805 | - GtkWidget *infobar_label; |
3806 | - GtkWidget *label_header; |
3807 | - GtkWidget *image_iconview; |
3808 | - GtkWidget *btn_folder; |
3809 | - GtkWidget *chk_apply_to_all; |
3810 | - GtkWidget *image_style_combo; |
3811 | - GtkWidget *color_style_combo; |
3812 | - GtkWidget *color1_btn; |
3813 | - GtkWidget *color2_btn; |
3814 | - |
3815 | - gulong color1_btn_id; |
3816 | - gulong color2_btn_id; |
3817 | - |
3818 | - /* backdrop cycling options */ |
3819 | - GtkWidget *backdrop_cycle_chkbox; |
3820 | - GtkWidget *combo_backdrop_cycle_period; |
3821 | - GtkWidget *backdrop_cycle_spinbox; |
3822 | - GtkWidget *random_backdrop_order_chkbox; |
3823 | - |
3824 | - GThread *preview_thread; |
3825 | - GAsyncQueue *preview_queue; |
3826 | - |
3827 | - XfdesktopThumbnailer *thumbnailer; |
3828 | - |
3829 | - GFile *selected_folder; |
3830 | - GCancellable *cancel_enumeration; |
3831 | - guint add_dir_idle_id; |
3832 | - |
3833 | -} AppearancePanel; |
3834 | - |
3835 | -typedef struct |
3836 | -{ |
3837 | - GFileEnumerator *file_enumerator; |
3838 | - GtkListStore *ls; |
3839 | - GtkTreeIter *selected_iter; |
3840 | - gchar *last_image; |
3841 | - gchar *file_path; |
3842 | - AppearancePanel *panel; |
3843 | -} AddDirData; |
3844 | - |
3845 | -enum |
3846 | -{ |
3847 | - COL_PIX = 0, |
3848 | - COL_NAME, |
3849 | - COL_FILENAME, |
3850 | - COL_THUMBNAIL, |
3851 | - COL_COLLATE_KEY, |
3852 | - N_COLS, |
3853 | -}; |
3854 | - |
3855 | -enum |
3856 | -{ |
3857 | - COL_ICON_PIX = 0, |
3858 | - COL_ICON_NAME, |
3859 | - COL_ICON_ENABLED, |
3860 | - COL_ICON_PROPERTY, |
3861 | - N_ICON_COLS, |
3862 | -}; |
3863 | - |
3864 | -static void cb_xfdesktop_chk_apply_to_all(GtkCheckButton *button, |
3865 | - gpointer user_data); |
3866 | -static gchar *xfdesktop_settings_generate_per_workspace_binding_string(AppearancePanel *panel, |
3867 | - const gchar* property); |
3868 | -static gchar *xfdesktop_settings_get_backdrop_image(AppearancePanel *panel); |
3869 | - |
3870 | -static void |
3871 | -xfdesktop_settings_do_single_preview(GtkTreeModel *model, |
3872 | - GtkTreeIter *iter) |
3873 | -{ |
3874 | - gchar *filename = NULL, *thumbnail = NULL; |
3875 | - GdkPixbuf *pix; |
3876 | - |
3877 | - gtk_tree_model_get(model, iter, |
3878 | - COL_FILENAME, &filename, |
3879 | - COL_THUMBNAIL, &thumbnail, |
3880 | - -1); |
3881 | - |
3882 | - /* If we didn't create a thumbnail there might not be a thumbnailer service |
3883 | - * or it may not support that format */ |
3884 | - if(thumbnail == NULL) { |
3885 | - pix = gdk_pixbuf_new_from_file_at_scale(filename, |
3886 | - PREVIEW_WIDTH, PREVIEW_HEIGHT, |
3887 | - TRUE, NULL); |
3888 | - } else { |
3889 | - pix = gdk_pixbuf_new_from_file_at_scale(thumbnail, |
3890 | - PREVIEW_WIDTH, PREVIEW_HEIGHT, |
3891 | - TRUE, NULL); |
3892 | - g_free(thumbnail); |
3893 | - } |
3894 | - |
3895 | - g_free(filename); |
3896 | - |
3897 | - if(pix) { |
3898 | - gtk_list_store_set(GTK_LIST_STORE(model), iter, |
3899 | - COL_PIX, pix, |
3900 | - -1); |
3901 | - |
3902 | - g_object_unref(G_OBJECT(pix)); |
3903 | - } |
3904 | -} |
3905 | - |
3906 | -static void |
3907 | -xfdesktop_settings_free_pdata(gpointer data) |
3908 | -{ |
3909 | - PreviewData *pdata = data; |
3910 | - g_object_unref(G_OBJECT(pdata->model)); |
3911 | - gtk_tree_iter_free(pdata->iter); |
3912 | - g_free(pdata); |
3913 | -} |
3914 | - |
3915 | -static gpointer |
3916 | -xfdesktop_settings_create_previews(gpointer data) |
3917 | -{ |
3918 | - AppearancePanel *panel = data; |
3919 | - |
3920 | - while(panel->preview_queue != NULL) { |
3921 | - PreviewData *pdata = NULL; |
3922 | - |
3923 | - /* Block and wait for another preview to create */ |
3924 | - pdata = g_async_queue_pop(panel->preview_queue); |
3925 | - |
3926 | - xfdesktop_settings_do_single_preview(pdata->model, pdata->iter); |
3927 | - |
3928 | - xfdesktop_settings_free_pdata(pdata); |
3929 | - } |
3930 | - |
3931 | - return NULL; |
3932 | -} |
3933 | - |
3934 | -static void |
3935 | -xfdesktop_settings_add_file_to_queue(AppearancePanel *panel, PreviewData *pdata) |
3936 | -{ |
3937 | - TRACE("entering"); |
3938 | - |
3939 | - g_return_if_fail(panel != NULL); |
3940 | - g_return_if_fail(pdata != NULL); |
3941 | - |
3942 | - /* Create the queue if it doesn't exist */ |
3943 | - if(panel->preview_queue == NULL) { |
3944 | - panel->preview_queue = g_async_queue_new_full(xfdesktop_settings_free_pdata); |
3945 | - } |
3946 | - |
3947 | - g_async_queue_push(panel->preview_queue, pdata); |
3948 | - |
3949 | - /* Create the thread if it doesn't exist */ |
3950 | - if(panel->preview_thread == NULL) { |
3951 | -#if GLIB_CHECK_VERSION(2, 32, 0) |
3952 | - panel->preview_thread = g_thread_try_new("create_previews", |
3953 | - xfdesktop_settings_create_previews, |
3954 | - panel, NULL); |
3955 | -#else |
3956 | - panel->preview_thread = g_thread_create(xfdesktop_settings_create_previews, |
3957 | - panel, FALSE, NULL); |
3958 | -#endif |
3959 | - if(panel->preview_thread == NULL) |
3960 | - { |
3961 | - g_critical("Unable to create thread for image previews."); |
3962 | - /* Don't block but try to remove the data from the queue |
3963 | - * since we won't be creating previews */ |
3964 | - if(g_async_queue_try_pop(panel->preview_queue)) |
3965 | - xfdesktop_settings_free_pdata(pdata); |
3966 | - } |
3967 | - } |
3968 | -} |
3969 | - |
3970 | -static void |
3971 | -cb_thumbnail_ready(XfdesktopThumbnailer *thumbnailer, |
3972 | - gchar *src_file, gchar *thumb_file, |
3973 | - gpointer user_data) |
3974 | -{ |
3975 | - AppearancePanel *panel = user_data; |
3976 | - GtkTreeModel *model = gtk_icon_view_get_model(GTK_ICON_VIEW(panel->image_iconview)); |
3977 | - GtkTreeIter iter; |
3978 | - PreviewData *pdata = NULL; |
3979 | - |
3980 | - if(gtk_tree_model_get_iter_first(model, &iter)) { |
3981 | - do { |
3982 | - gchar *filename = NULL; |
3983 | - gtk_tree_model_get(model, &iter, COL_FILENAME, &filename, -1); |
3984 | - |
3985 | - /* We're looking for the src_file */ |
3986 | - if(g_strcmp0(filename, src_file) == 0) { |
3987 | - /* Add the thumb_file to it */ |
3988 | - gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
3989 | - COL_THUMBNAIL, thumb_file, -1); |
3990 | - |
3991 | - pdata = g_new0(PreviewData, 1); |
3992 | - pdata->model = g_object_ref(G_OBJECT(model)); |
3993 | - pdata->iter = gtk_tree_iter_copy(&iter); |
3994 | - |
3995 | - /* Create the preview image */ |
3996 | - xfdesktop_settings_add_file_to_queue(panel, pdata); |
3997 | - |
3998 | - g_free(filename); |
3999 | - return; |
4000 | - } |
4001 | - |
4002 | - g_free(filename); |
4003 | - } while(gtk_tree_model_iter_next(model, &iter)); |
4004 | - } |
4005 | -} |
4006 | - |
4007 | -static void |
4008 | -xfdesktop_settings_queue_preview(GtkTreeModel *model, |
4009 | - GtkTreeIter *iter, |
4010 | - AppearancePanel *panel) |
4011 | -{ |
4012 | - gchar *filename = NULL; |
4013 | - |
4014 | - gtk_tree_model_get(model, iter, COL_FILENAME, &filename, -1); |
4015 | - |
4016 | - /* Attempt to use the thumbnailer if possible */ |
4017 | - if(!xfdesktop_thumbnailer_queue_thumbnail(panel->thumbnailer, filename)) { |
4018 | - /* Thumbnailing not possible, add it to the queue to be loaded manually */ |
4019 | - PreviewData *pdata; |
4020 | - pdata = g_new0(PreviewData, 1); |
4021 | - pdata->model = g_object_ref(G_OBJECT(model)); |
4022 | - pdata->iter = gtk_tree_iter_copy(iter); |
4023 | - |
4024 | - xfdesktop_settings_add_file_to_queue(panel, pdata); |
4025 | - } |
4026 | - |
4027 | - if(filename) |
4028 | - g_free(filename); |
4029 | -} |
4030 | - |
4031 | -static void |
4032 | -cb_special_icon_toggled(GtkCellRendererToggle *render, gchar *path, gpointer user_data) |
4033 | -{ |
4034 | - XfconfChannel *channel = g_object_get_data(G_OBJECT(user_data), |
4035 | - "xfconf-channel"); |
4036 | - GtkTreePath *tree_path = gtk_tree_path_new_from_string(path); |
4037 | - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); |
4038 | - GtkTreeIter iter; |
4039 | - gboolean show_icon; |
4040 | - gchar *icon_property = NULL; |
4041 | - |
4042 | - gtk_tree_model_get_iter(model, &iter, tree_path); |
4043 | - gtk_tree_model_get(model, &iter, COL_ICON_ENABLED, &show_icon, |
4044 | - COL_ICON_PROPERTY, &icon_property, -1); |
4045 | - |
4046 | - show_icon = !show_icon; |
4047 | - |
4048 | - xfconf_channel_set_bool(channel, icon_property, show_icon); |
4049 | - |
4050 | - gtk_tree_store_set(GTK_TREE_STORE(model), &iter, |
4051 | - COL_ICON_ENABLED, show_icon, -1); |
4052 | - |
4053 | - gtk_tree_path_free(tree_path); |
4054 | - g_free(icon_property); |
4055 | -} |
4056 | - |
4057 | -static void |
4058 | -setup_special_icon_list(GtkBuilder *gxml, |
4059 | - XfconfChannel *channel) |
4060 | -{ |
4061 | - GtkWidget *treeview; |
4062 | - GtkTreeStore *ts; |
4063 | - GtkTreeViewColumn *col; |
4064 | - GtkCellRenderer *render; |
4065 | - GtkTreeIter iter, parent_iter, child_iter; |
4066 | - const struct { |
4067 | - const gchar *name; |
4068 | - const gchar *icon; |
4069 | - const gchar *icon_fallback; |
4070 | - const gchar *xfconf_property; |
4071 | - gboolean state; |
4072 | - } icons[] = { |
4073 | - { N_("Home"), "user-home", "gnome-fs-desktop", |
4074 | - DESKTOP_ICONS_SHOW_HOME, TRUE }, |
4075 | - { N_("Filesystem"), "drive-harddisk", "gnome-dev-harddisk", |
4076 | - DESKTOP_ICONS_SHOW_FILESYSTEM, TRUE }, |
4077 | - { N_("Trash"), "user-trash", "gnome-fs-trash-empty", |
4078 | - DESKTOP_ICONS_SHOW_TRASH, TRUE }, |
4079 | - { N_("Removable Devices"), "drive-removable-media", "gnome-dev-removable", |
4080 | - DESKTOP_ICONS_SHOW_REMOVABLE, TRUE }, |
4081 | - { N_("Network Shares"), "gtk-network", "gnome-dev-network", |
4082 | - DESKTOP_ICONS_SHOW_NETWORK_REMOVABLE, TRUE }, |
4083 | - { N_("Disks and Drives"), "drive-harddisk-usb", "gnome-dev-removable-usb", |
4084 | - DESKTOP_ICONS_SHOW_DEVICE_REMOVABLE, TRUE }, |
4085 | - { N_("Other Devices"), "multimedia-player", "phone", |
4086 | - DESKTOP_ICONS_SHOW_UNKNWON_REMOVABLE, TRUE }, |
4087 | - { NULL, NULL, NULL, NULL, FALSE }, |
4088 | - }; |
4089 | - const int REMOVABLE_DEVICES = 4; |
4090 | - int i, w; |
4091 | - GtkIconTheme *itheme = gtk_icon_theme_get_default(); |
4092 | - |
4093 | - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &w, NULL); |
4094 | - |
4095 | - ts = gtk_tree_store_new(N_ICON_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
4096 | - G_TYPE_BOOLEAN, G_TYPE_STRING); |
4097 | - for(i = 0; icons[i].name; ++i) { |
4098 | - GdkPixbuf *pix = NULL; |
4099 | - |
4100 | - if(gtk_icon_theme_has_icon(itheme, icons[i].icon)) |
4101 | - pix = gtk_icon_theme_load_icon(itheme, icons[i].icon, w, 0, NULL); |
4102 | - else |
4103 | - pix = gtk_icon_theme_load_icon(itheme, icons[i].icon_fallback, w, 0, NULL); |
4104 | - |
4105 | - if(i < REMOVABLE_DEVICES) { |
4106 | - gtk_tree_store_append(ts, &parent_iter, NULL); |
4107 | - iter = parent_iter; |
4108 | - } else { |
4109 | - gtk_tree_store_append(ts, &child_iter, &parent_iter); |
4110 | - iter = child_iter; |
4111 | - } |
4112 | - |
4113 | - gtk_tree_store_set(ts, &iter, |
4114 | - COL_ICON_NAME, _(icons[i].name), |
4115 | - COL_ICON_PIX, pix, |
4116 | - COL_ICON_PROPERTY, icons[i].xfconf_property, |
4117 | - COL_ICON_ENABLED, |
4118 | - xfconf_channel_get_bool(channel, |
4119 | - icons[i].xfconf_property, |
4120 | - icons[i].state), |
4121 | - -1); |
4122 | - if(pix) |
4123 | - g_object_unref(G_OBJECT(pix)); |
4124 | - } |
4125 | - |
4126 | - treeview = GTK_WIDGET(gtk_builder_get_object(gxml, "treeview_default_icons")); |
4127 | - g_object_set_data(G_OBJECT(treeview), "xfconf-channel", channel); |
4128 | - col = gtk_tree_view_column_new(); |
4129 | - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col); |
4130 | - |
4131 | - render = gtk_cell_renderer_toggle_new(); |
4132 | - gtk_tree_view_column_pack_start(col, render, FALSE); |
4133 | - gtk_tree_view_column_add_attribute(col, render, "active", COL_ICON_ENABLED); |
4134 | - |
4135 | - g_signal_connect(G_OBJECT(render), "toggled", |
4136 | - G_CALLBACK(cb_special_icon_toggled), treeview); |
4137 | - |
4138 | - render = gtk_cell_renderer_pixbuf_new(); |
4139 | - gtk_tree_view_column_pack_start(col, render, FALSE); |
4140 | - gtk_tree_view_column_add_attribute(col, render, "pixbuf", COL_ICON_PIX); |
4141 | - |
4142 | - render = gtk_cell_renderer_text_new(); |
4143 | - gtk_tree_view_column_pack_start(col, render, TRUE); |
4144 | - gtk_tree_view_column_add_attribute(col, render, "text", COL_ICON_NAME); |
4145 | - |
4146 | - gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(ts)); |
4147 | - g_object_unref(G_OBJECT(ts)); |
4148 | -} |
4149 | - |
4150 | - |
4151 | -static gint |
4152 | -image_list_compare(GtkTreeModel *model, |
4153 | - const gchar *a, |
4154 | - GtkTreeIter *b) |
4155 | -{ |
4156 | - gchar *key_b = NULL; |
4157 | - gint ret; |
4158 | - |
4159 | - gtk_tree_model_get(model, b, COL_COLLATE_KEY, &key_b, -1); |
4160 | - |
4161 | - ret = g_strcmp0(a, key_b); |
4162 | - |
4163 | - g_free(key_b); |
4164 | - |
4165 | - return ret; |
4166 | -} |
4167 | - |
4168 | -static GtkTreeIter * |
4169 | -xfdesktop_settings_image_iconview_add(GtkTreeModel *model, |
4170 | - const char *path, |
4171 | - GFileInfo *info, |
4172 | - AppearancePanel *panel) |
4173 | -{ |
4174 | - gboolean added = FALSE, found = FALSE, valid = FALSE; |
4175 | - GtkTreeIter iter, search_iter; |
4176 | - gchar *name = NULL, *name_utf8 = NULL, *name_markup = NULL, *size_string = NULL; |
4177 | - gchar *collate_key = NULL; |
4178 | - gint position = 0; |
4179 | - const gchar *content_type = g_file_info_get_content_type(info); |
4180 | - goffset file_size = g_file_info_get_size(info); |
4181 | - |
4182 | - if(!xfdesktop_image_file_is_valid(path)) |
4183 | - return NULL; |
4184 | - |
4185 | - name = g_path_get_basename(path); |
4186 | - if(name) { |
4187 | - guint name_length = strlen(name); |
4188 | - name_utf8 = g_filename_to_utf8(name, name_length, |
4189 | - NULL, NULL, NULL); |
4190 | - if(name_utf8) { |
4191 | -#if GLIB_CHECK_VERSION (2, 30, 0) |
4192 | - size_string = g_format_size(file_size); |
4193 | -#else |
4194 | - size_string = g_format_size_for_display(file_size); |
4195 | -#endif |
4196 | - |
4197 | - /* Display the file name, file type, and file size in the tooltip. */ |
4198 | - name_markup = g_markup_printf_escaped(_("<b>%s</b>\nType: %s\nSize: %s"), |
4199 | - name_utf8, content_type, size_string); |
4200 | - |
4201 | - /* create a case sensitive collation key for sorting filenames like |
4202 | - * Thunar does */ |
4203 | - collate_key = g_utf8_collate_key_for_filename(name, name_length); |
4204 | - |
4205 | - /* Insert sorted */ |
4206 | - valid = gtk_tree_model_get_iter_first(model, &search_iter); |
4207 | - while(valid && !found) { |
4208 | - if(image_list_compare(model, collate_key, &search_iter) <= 0) { |
4209 | - found = TRUE; |
4210 | - } else { |
4211 | - valid = gtk_tree_model_iter_next(model, &search_iter); |
4212 | - position++; |
4213 | - } |
4214 | - } |
4215 | - |
4216 | - gtk_list_store_insert_with_values(GTK_LIST_STORE(model), |
4217 | - &iter, |
4218 | - position, |
4219 | - COL_NAME, name_markup, |
4220 | - COL_FILENAME, path, |
4221 | - COL_COLLATE_KEY, collate_key, |
4222 | - -1); |
4223 | - xfdesktop_settings_queue_preview(model, &iter, panel); |
4224 | - |
4225 | - added = TRUE; |
4226 | - } |
4227 | - } |
4228 | - |
4229 | - g_free(name); |
4230 | - g_free(name_utf8); |
4231 | - g_free(name_markup); |
4232 | - g_free(size_string); |
4233 | - g_free(collate_key); |
4234 | - |
4235 | - if(added) |
4236 | - return gtk_tree_iter_copy(&iter); |
4237 | - else |
4238 | - return NULL; |
4239 | -} |
4240 | - |
4241 | -static void |
4242 | -cb_destroy_add_dir_enumeration(gpointer user_data) |
4243 | -{ |
4244 | - AddDirData *dir_data = user_data; |
4245 | - AppearancePanel *panel = dir_data->panel; |
4246 | - |
4247 | - TRACE("entering"); |
4248 | - |
4249 | - g_free(dir_data->file_path); |
4250 | - g_free(dir_data->last_image); |
4251 | - |
4252 | - if(G_IS_FILE_ENUMERATOR(dir_data->file_enumerator)) |
4253 | - g_object_unref(dir_data->file_enumerator); |
4254 | - |
4255 | - g_free(dir_data); |
4256 | - |
4257 | - if(panel->cancel_enumeration) { |
4258 | - g_object_unref(panel->cancel_enumeration); |
4259 | - panel->cancel_enumeration = NULL; |
4260 | - } |
4261 | - |
4262 | - panel->add_dir_idle_id = 0; |
4263 | -} |
4264 | - |
4265 | -static gboolean |
4266 | -xfdesktop_image_list_add_item(gpointer user_data) |
4267 | -{ |
4268 | - AddDirData *dir_data = user_data; |
4269 | - AppearancePanel *panel = dir_data->panel; |
4270 | - GFileInfo *info; |
4271 | - GtkTreeIter *iter; |
4272 | - |
4273 | - /* If the enumeration gets canceled/destroyed return and |
4274 | - * cb_destroy_add_dir_enumeration will get called to clean up */ |
4275 | - if(!G_IS_FILE_ENUMERATOR(dir_data->file_enumerator)) |
4276 | - return FALSE; |
4277 | - |
4278 | - /* Add one item to the icon view at a time so we don't block the UI */ |
4279 | - if((info = g_file_enumerator_next_file(dir_data->file_enumerator, NULL, NULL))) { |
4280 | - const gchar *file_name = g_file_info_get_name(info); |
4281 | - gchar *buf = g_strconcat(dir_data->file_path, "/", file_name, NULL); |
4282 | - |
4283 | - iter = xfdesktop_settings_image_iconview_add(GTK_TREE_MODEL(dir_data->ls), buf, info, panel); |
4284 | - if(iter) { |
4285 | - if(!dir_data->selected_iter && |
4286 | - !strcmp(buf, dir_data->last_image)) |
4287 | - { |
4288 | - dir_data->selected_iter = iter; |
4289 | - } else { |
4290 | - gtk_tree_iter_free(iter); |
4291 | - } |
4292 | - } |
4293 | - |
4294 | - g_free(buf); |
4295 | - g_object_unref(info); |
4296 | - |
4297 | - /* continue on the next idle callback so the user's events get priority */ |
4298 | - return TRUE; |
4299 | - } |
4300 | - |
4301 | - /* If we get here we're done enumerating files in the directory */ |
4302 | - |
4303 | - gtk_icon_view_set_model(GTK_ICON_VIEW(panel->image_iconview), |
4304 | - GTK_TREE_MODEL(dir_data->ls)); |
4305 | - |
4306 | - /* last_image is in the directory added then it should be selected */ |
4307 | - if(dir_data->selected_iter) { |
4308 | - GtkTreePath *path; |
4309 | - path = gtk_tree_model_get_path(GTK_TREE_MODEL(dir_data->ls), dir_data->selected_iter); |
4310 | - if(path) { |
4311 | - gtk_icon_view_select_path(GTK_ICON_VIEW(panel->image_iconview), path); |
4312 | - gtk_tree_iter_free(dir_data->selected_iter); |
4313 | - gtk_tree_path_free(path); |
4314 | - } |
4315 | - } |
4316 | - |
4317 | - /* cb_destroy_add_dir_enumeration will get called to clean up */ |
4318 | - return FALSE; |
4319 | -} |
4320 | - |
4321 | -static void |
4322 | -xfdesktop_image_list_add_dir(GObject *source_object, |
4323 | - GAsyncResult *res, |
4324 | - gpointer user_data) |
4325 | -{ |
4326 | - AppearancePanel *panel = user_data; |
4327 | - AddDirData *dir_data = g_new0(AddDirData, 1); |
4328 | - |
4329 | - TRACE("entering"); |
4330 | - |
4331 | - dir_data->panel = panel; |
4332 | - |
4333 | - dir_data->ls = gtk_list_store_new(N_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
4334 | - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
4335 | - |
4336 | - /* Get the last image/current image displayed so we can select it in the |
4337 | - * icon view */ |
4338 | - dir_data->last_image = xfdesktop_settings_get_backdrop_image(panel); |
4339 | - |
4340 | - dir_data->file_path = g_file_get_path(panel->selected_folder); |
4341 | - |
4342 | - dir_data->file_enumerator = g_file_enumerate_children_finish(panel->selected_folder, |
4343 | - res, |
4344 | - NULL); |
4345 | - |
4346 | - /* Individual items are added in an idle callback so everything is more |
4347 | - * responsive */ |
4348 | - panel->add_dir_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, |
4349 | - xfdesktop_image_list_add_item, |
4350 | - dir_data, |
4351 | - cb_destroy_add_dir_enumeration); |
4352 | -} |
4353 | - |
4354 | -static void |
4355 | -xfdesktop_settings_update_iconview_frame_name(AppearancePanel *panel, |
4356 | - WnckWorkspace *wnck_workspace) |
4357 | -{ |
4358 | - gchar buf[1024]; |
4359 | - gchar *workspace_name; |
4360 | - WnckScreen *screen; |
4361 | - WnckWorkspace *workspace; |
4362 | - |
4363 | - /* Don't update the name until we find our window */ |
4364 | - if(panel->wnck_window == NULL) |
4365 | - return; |
4366 | - |
4367 | - g_return_if_fail(panel->monitor >= 0 && panel->workspace >= 0); |
4368 | - |
4369 | - /* If it's a pinned window get the active workspace */ |
4370 | - if(wnck_workspace == NULL) { |
4371 | - screen = wnck_window_get_screen(panel->wnck_window); |
4372 | - workspace = wnck_screen_get_workspace(screen, panel->active_workspace); |
4373 | - } else { |
4374 | - workspace = wnck_workspace; |
4375 | - } |
4376 | - |
4377 | - workspace_name = g_strdup(wnck_workspace_get_name(workspace)); |
4378 | - |
4379 | - if(gdk_screen_get_n_monitors(gtk_widget_get_screen(panel->chk_apply_to_all)) > 1) { |
4380 | - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all))) { |
4381 | - /* Multi-monitor single workspace */ |
4382 | - if(panel->monitor_name) { |
4383 | - g_snprintf(buf, sizeof(buf), |
4384 | - _("Wallpaper for Monitor %d (%s)"), |
4385 | - panel->monitor, panel->monitor_name); |
4386 | - } else { |
4387 | - g_snprintf(buf, sizeof(buf), _("Wallpaper for Monitor %d"), panel->monitor); |
4388 | - } |
4389 | - |
4390 | - /* This is for the infobar letting the user know how to configure |
4391 | - * multiple monitor setups */ |
4392 | - gtk_label_set_text(GTK_LABEL(panel->infobar_label), |
4393 | - _("Move this dialog to the display you " |
4394 | - "want to edit the settings for.")); |
4395 | - gtk_widget_set_visible(panel->infobar, TRUE); |
4396 | - } else { |
4397 | - /* Multi-monitor per workspace wallpaper */ |
4398 | - if(panel->monitor_name) { |
4399 | - g_snprintf(buf, sizeof(buf), |
4400 | - _("Wallpaper for %s on Monitor %d (%s)"), |
4401 | - workspace_name, panel->monitor, panel->monitor_name); |
4402 | - } else { |
4403 | - g_snprintf(buf, sizeof(buf), |
4404 | - _("Wallpaper for %s on Monitor %d"), |
4405 | - workspace_name, panel->monitor); |
4406 | - } |
4407 | - |
4408 | - /* This is for the infobar letting the user know how to configure |
4409 | - * multiple monitor/workspace setups */ |
4410 | - gtk_label_set_text(GTK_LABEL(panel->infobar_label), |
4411 | - _("Move this dialog to the display and " |
4412 | - "workspace you want to edit the settings for.")); |
4413 | - gtk_widget_set_visible(panel->infobar, TRUE); |
4414 | - } |
4415 | - } else { |
4416 | - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all))) { |
4417 | - /* Single monitor and single workspace */ |
4418 | - g_snprintf(buf, sizeof(buf), _("Wallpaper for my desktop")); |
4419 | - |
4420 | - /* No need for the infobar */ |
4421 | - gtk_widget_set_visible(panel->infobar, FALSE); |
4422 | - } else { |
4423 | - /* Single monitor and per workspace wallpaper */ |
4424 | - g_snprintf(buf, sizeof(buf), _("Wallpaper for %s"), workspace_name); |
4425 | - |
4426 | - /* This is for the infobar letting the user know how to configure |
4427 | - * multiple workspace setups */ |
4428 | - gtk_label_set_text(GTK_LABEL(panel->infobar_label), |
4429 | - _("Move this dialog to the workspace you " |
4430 | - "want to edit the settings for.")); |
4431 | - gtk_widget_set_visible(panel->infobar, TRUE); |
4432 | - } |
4433 | - } |
4434 | - |
4435 | - /* This label is for which workspace/monitor we're on */ |
4436 | - gtk_label_set_text(GTK_LABEL(panel->label_header), buf); |
4437 | - |
4438 | - g_free(workspace_name); |
4439 | -} |
4440 | - |
4441 | -/* Free the returned string when done using it */ |
4442 | -static gchar* |
4443 | -xfdesktop_settings_generate_per_workspace_binding_string(AppearancePanel *panel, |
4444 | - const gchar* property) |
4445 | -{ |
4446 | - gchar *buf = NULL; |
4447 | - |
4448 | - if(panel->monitor_name == NULL) { |
4449 | - buf = g_strdup_printf("/backdrop/screen%d/monitor%d/workspace%d/%s", |
4450 | - panel->screen, panel->monitor, panel->workspace, |
4451 | - property); |
4452 | - } else { |
4453 | - buf = g_strdup_printf("/backdrop/screen%d/monitor%s/workspace%d/%s", |
4454 | - panel->screen, panel->monitor_name, panel->workspace, |
4455 | - property); |
4456 | - } |
4457 | - |
4458 | - DBG("name %s", buf); |
4459 | - |
4460 | - return buf; |
4461 | -} |
4462 | - |
4463 | -static gchar* |
4464 | -xfdesktop_settings_generate_old_binding_string(AppearancePanel *panel, |
4465 | - const gchar* property) |
4466 | -{ |
4467 | - gchar *buf = NULL; |
4468 | - |
4469 | - buf = g_strdup_printf("/backdrop/screen%d/monitor%d/%s", |
4470 | - panel->screen, panel->monitor, property); |
4471 | - |
4472 | - DBG("name %s", buf); |
4473 | - |
4474 | - return buf; |
4475 | -} |
4476 | - |
4477 | -/* Attempts to load the backdrop from the current location followed by using |
4478 | - * how previous versions of xfdesktop (before 4.11) did. This matches how |
4479 | - * xfdesktop searches for backdrops. |
4480 | - * Free the returned string when done using it. */ |
4481 | -static gchar * |
4482 | -xfdesktop_settings_get_backdrop_image(AppearancePanel *panel) |
4483 | -{ |
4484 | - gchar *last_image; |
4485 | - gchar *property, *old_property = NULL; |
4486 | - |
4487 | - /* Get the last image/current image displayed, if available */ |
4488 | - property = xfdesktop_settings_generate_per_workspace_binding_string(panel, "last-image"); |
4489 | - |
4490 | - last_image = xfconf_channel_get_string(panel->channel, property, NULL); |
4491 | - |
4492 | - /* Try the previous version or fall back to our provided default */ |
4493 | - if(last_image == NULL) { |
4494 | - old_property = xfdesktop_settings_generate_old_binding_string(panel, |
4495 | - "image-path"); |
4496 | - last_image = xfconf_channel_get_string(panel->channel, |
4497 | - old_property, |
4498 | - DEFAULT_BACKDROP); |
4499 | - } |
4500 | - |
4501 | - g_free(property); |
4502 | - if(old_property) |
4503 | - g_free(old_property); |
4504 | - |
4505 | - return last_image; |
4506 | -} |
4507 | - |
4508 | -static void |
4509 | -cb_image_selection_changed(GtkIconView *icon_view, |
4510 | - gpointer user_data) |
4511 | -{ |
4512 | - AppearancePanel *panel = user_data; |
4513 | - GtkTreeModel *model = gtk_icon_view_get_model(icon_view); |
4514 | - GtkTreeIter iter; |
4515 | - GList *selected_items = NULL; |
4516 | - gchar *filename = NULL, *current_filename = NULL; |
4517 | - gchar *buf = NULL; |
4518 | - |
4519 | - TRACE("entering"); |
4520 | - |
4521 | - if(panel->image_list_loaded && GTK_IS_TREE_MODEL(model)) |
4522 | - return; |
4523 | - |
4524 | - selected_items = gtk_icon_view_get_selected_items(icon_view); |
4525 | - |
4526 | - /* We only care about the first selected item because the iconview |
4527 | - * should be set to single selection mode */ |
4528 | - if(!selected_items || g_list_first(selected_items) == NULL) |
4529 | - return; |
4530 | - |
4531 | - if(!gtk_tree_model_get_iter(model, &iter, g_list_first(selected_items)->data)) |
4532 | - return; |
4533 | - |
4534 | - gtk_tree_model_get(model, &iter, COL_FILENAME, &filename, -1); |
4535 | - |
4536 | - /* Get the current/last image, handles migrating from old versions */ |
4537 | - current_filename = xfdesktop_settings_get_backdrop_image(panel); |
4538 | - |
4539 | - /* check to see if the selection actually did change */ |
4540 | - if(g_strcmp0(current_filename, filename) != 0) { |
4541 | - if(panel->monitor_name == NULL) { |
4542 | - DBG("got %s, applying to screen %d monitor %d workspace %d", filename, |
4543 | - panel->screen, panel->monitor, panel->workspace); |
4544 | - } else { |
4545 | - DBG("got %s, applying to screen %d monitor %s workspace %d", filename, |
4546 | - panel->screen, panel->monitor_name, panel->workspace); |
4547 | - } |
4548 | - |
4549 | - /* Get the property location to save our changes, always save to new |
4550 | - * location */ |
4551 | - buf = xfdesktop_settings_generate_per_workspace_binding_string(panel, |
4552 | - "last-image"); |
4553 | - DBG("Saving to %s/%s", buf, filename); |
4554 | - xfconf_channel_set_string(panel->channel, buf, filename); |
4555 | - } |
4556 | - |
4557 | - g_list_foreach (selected_items, (GFunc)gtk_tree_path_free, NULL); |
4558 | - g_list_free(selected_items); |
4559 | - g_free(current_filename); |
4560 | - if(buf) |
4561 | - g_free(buf); |
4562 | -} |
4563 | - |
4564 | -static gint |
4565 | -xfdesktop_settings_get_active_workspace(AppearancePanel *panel, |
4566 | - WnckWindow *wnck_window) |
4567 | -{ |
4568 | - WnckWorkspace *wnck_workspace; |
4569 | - gboolean single_workspace; |
4570 | - gint workspace_num, single_workspace_num; |
4571 | - WnckScreen *wnck_screen = wnck_window_get_screen(wnck_window); |
4572 | - |
4573 | - wnck_workspace = wnck_window_get_workspace(wnck_window); |
4574 | - |
4575 | - /* If wnck_workspace is NULL that means it's pinned and we just need to |
4576 | - * use the active/current workspace */ |
4577 | - if(wnck_workspace != NULL) { |
4578 | - workspace_num = wnck_workspace_get_number(wnck_workspace); |
4579 | - } else { |
4580 | - workspace_num = panel->active_workspace; |
4581 | - } |
4582 | - |
4583 | - single_workspace = xfconf_channel_get_bool(panel->channel, |
4584 | - SINGLE_WORKSPACE_MODE, |
4585 | - TRUE); |
4586 | - |
4587 | - /* If we're in single_workspace mode we need to return the workspace that |
4588 | - * it was set to, if that workspace exists, otherwise return the current |
4589 | - * workspace and turn off the single workspace mode */ |
4590 | - if(single_workspace) { |
4591 | - single_workspace_num = xfconf_channel_get_int(panel->channel, |
4592 | - SINGLE_WORKSPACE_NUMBER, |
4593 | - 0); |
4594 | - if(single_workspace_num < wnck_screen_get_workspace_count(wnck_screen)) { |
4595 | - return single_workspace_num; |
4596 | - } else { |
4597 | - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all), |
4598 | - FALSE); |
4599 | - } |
4600 | - } |
4601 | - |
4602 | - return workspace_num; |
4603 | -} |
4604 | - |
4605 | -/* This works for both the custom font size and show tooltips check buttons, |
4606 | - * it just enables the associated spin button */ |
4607 | -static void |
4608 | -cb_xfdesktop_chk_button_toggled(GtkCheckButton *button, |
4609 | - gpointer user_data) |
4610 | -{ |
4611 | - GtkWidget *spin_button = GTK_WIDGET(user_data); |
4612 | - |
4613 | - TRACE("entering"); |
4614 | - |
4615 | - gtk_widget_set_sensitive(spin_button, |
4616 | - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); |
4617 | -} |
4618 | - |
4619 | -static void |
4620 | -update_backdrop_random_order_chkbox(AppearancePanel *panel) |
4621 | -{ |
4622 | - gboolean sensitive = FALSE; |
4623 | - gint period; |
4624 | - |
4625 | - /* For the random check box to be active the combo_backdrop_cycle_period |
4626 | - * needs to be active and needs to not be set to chronological */ |
4627 | - if(gtk_widget_get_sensitive(panel->combo_backdrop_cycle_period)) { |
4628 | - period = gtk_combo_box_get_active(GTK_COMBO_BOX(panel->combo_backdrop_cycle_period)); |
4629 | - if(period != XFCE_BACKDROP_PERIOD_CHRONOLOGICAL) |
4630 | - sensitive = TRUE; |
4631 | - } |
4632 | - |
4633 | - gtk_widget_set_sensitive(panel->random_backdrop_order_chkbox, sensitive); |
4634 | -} |
4635 | - |
4636 | -static void |
4637 | -update_backdrop_cycle_spinbox(AppearancePanel *panel) |
4638 | -{ |
4639 | - gboolean sensitive = FALSE; |
4640 | - gint period; |
4641 | - |
4642 | - /* For the spinbox to be active the combo_backdrop_cycle_period needs to be |
4643 | - * active and needs to be set to something where the spinbox would apply */ |
4644 | - if(gtk_widget_get_sensitive(panel->combo_backdrop_cycle_period)) { |
4645 | - period = gtk_combo_box_get_active(GTK_COMBO_BOX(panel->combo_backdrop_cycle_period)); |
4646 | - if(period == XFCE_BACKDROP_PERIOD_SECONDS || |
4647 | - period == XFCE_BACKDROP_PERIOD_MINUES || |
4648 | - period == XFCE_BACKDROP_PERIOD_HOURS) |
4649 | - { |
4650 | - sensitive = TRUE; |
4651 | - } |
4652 | - } |
4653 | - |
4654 | - gtk_widget_set_sensitive(panel->backdrop_cycle_spinbox, sensitive); |
4655 | -} |
4656 | - |
4657 | -static void |
4658 | -cb_combo_backdrop_cycle_period_change(GtkComboBox *combo, |
4659 | - gpointer user_data) |
4660 | -{ |
4661 | - AppearancePanel *panel = user_data; |
4662 | - |
4663 | - /* determine if the spin box should be sensitive */ |
4664 | - update_backdrop_cycle_spinbox(panel); |
4665 | - /* determine if the random check box should be sensitive */ |
4666 | - update_backdrop_random_order_chkbox(panel); |
4667 | -} |
4668 | - |
4669 | -static void |
4670 | -cb_xfdesktop_chk_cycle_backdrop_toggled(GtkCheckButton *button, |
4671 | - gpointer user_data) |
4672 | -{ |
4673 | - AppearancePanel *panel = user_data; |
4674 | - gboolean sensitive = FALSE; |
4675 | - |
4676 | - TRACE("entering"); |
4677 | - |
4678 | - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->backdrop_cycle_chkbox))) { |
4679 | - sensitive = TRUE; |
4680 | - } |
4681 | - |
4682 | - /* The cycle backdrop toggles the period and random widgets */ |
4683 | - gtk_widget_set_sensitive(panel->combo_backdrop_cycle_period, sensitive); |
4684 | - /* determine if the spin box should be sensitive */ |
4685 | - update_backdrop_cycle_spinbox(panel); |
4686 | - /* determine if the random check box should be sensitive */ |
4687 | - update_backdrop_random_order_chkbox(panel); |
4688 | -} |
4689 | - |
4690 | -static gboolean |
4691 | -xfdesktop_spin_icon_size_timer(GtkSpinButton *button) |
4692 | -{ |
4693 | - XfconfChannel *channel = g_object_get_data(G_OBJECT(button), "xfconf-chanel"); |
4694 | - |
4695 | - TRACE("entering"); |
4696 | - |
4697 | - g_return_val_if_fail(XFCONF_IS_CHANNEL(channel), FALSE); |
4698 | - |
4699 | - xfconf_channel_set_uint(channel, |
4700 | - DESKTOP_ICONS_ICON_SIZE_PROP, |
4701 | - gtk_spin_button_get_value(button)); |
4702 | - |
4703 | - return FALSE; |
4704 | -} |
4705 | - |
4706 | -static void |
4707 | -cb_xfdesktop_spin_icon_size_changed(GtkSpinButton *button, |
4708 | - gpointer user_data) |
4709 | -{ |
4710 | - guint timer_id = 0; |
4711 | - |
4712 | - TRACE("entering"); |
4713 | - |
4714 | - g_object_set_data(G_OBJECT(button), "xfconf-chanel", user_data); |
4715 | - |
4716 | - timer_id = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(button), "timer-id")); |
4717 | - if(timer_id != 0) { |
4718 | - g_source_remove(timer_id); |
4719 | - timer_id = 0; |
4720 | - } |
4721 | - |
4722 | - timer_id = g_timeout_add(500, |
4723 | - (GSourceFunc)xfdesktop_spin_icon_size_timer, |
4724 | - button); |
4725 | - |
4726 | - g_object_set_data(G_OBJECT(button), "timer-id", GUINT_TO_POINTER(timer_id)); |
4727 | -} |
4728 | - |
4729 | -static void |
4730 | -xfdesktop_settings_stop_image_loading(AppearancePanel *panel) |
4731 | -{ |
4732 | - /* stop any thumbnailing in progress */ |
4733 | - xfdesktop_thumbnailer_dequeue_all_thumbnails(panel->thumbnailer); |
4734 | - |
4735 | - /* Remove the previews in the message queue */ |
4736 | - if(panel->preview_queue != NULL) { |
4737 | - while(g_async_queue_length(panel->preview_queue) > 0) { |
4738 | - gpointer data = g_async_queue_try_pop(panel->preview_queue); |
4739 | - if(data) |
4740 | - xfdesktop_settings_free_pdata(data); |
4741 | - } |
4742 | - } |
4743 | - |
4744 | - /* Cancel any file enumeration that's running */ |
4745 | - if(panel->cancel_enumeration != NULL) { |
4746 | - g_cancellable_cancel(panel->cancel_enumeration); |
4747 | - g_object_unref(panel->cancel_enumeration); |
4748 | - panel->cancel_enumeration = NULL; |
4749 | - } |
4750 | - |
4751 | - /* Cancel the file enumeration for populating the icon view */ |
4752 | - if(panel->add_dir_idle_id != 0) { |
4753 | - g_source_remove(panel->add_dir_idle_id); |
4754 | - panel->add_dir_idle_id = 0; |
4755 | - } |
4756 | -} |
4757 | - |
4758 | -static void |
4759 | -cb_xfdesktop_bnt_exit_clicked(GtkButton *button, gpointer user_data) |
4760 | -{ |
4761 | - AppearancePanel *panel = user_data; |
4762 | - |
4763 | - xfdesktop_settings_stop_image_loading(panel); |
4764 | -} |
4765 | - |
4766 | -static void |
4767 | -cb_folder_selection_changed(GtkWidget *button, |
4768 | - gpointer user_data) |
4769 | -{ |
4770 | - AppearancePanel *panel = user_data; |
4771 | - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(button)); |
4772 | - gchar *previous_filename = NULL; |
4773 | - |
4774 | - TRACE("entering"); |
4775 | - |
4776 | - if(panel->selected_folder != NULL) |
4777 | - previous_filename = g_file_get_path(panel->selected_folder); |
4778 | - |
4779 | - /* Check to see if the folder actually did change */ |
4780 | - if(g_strcmp0(filename, previous_filename) == 0) { |
4781 | - const gchar *current_folder = xfdesktop_settings_get_backdrop_image(panel); |
4782 | - gchar *dirname; |
4783 | - |
4784 | - dirname = g_path_get_dirname(current_folder); |
4785 | - |
4786 | - /* workaround another gtk bug - if the user sets the file chooser |
4787 | - * button to something then it can't be changed with a set folder |
4788 | - * call anymore. */ |
4789 | - if(g_strcmp0(filename, dirname) == 0) { |
4790 | - DBG("folder didn't change"); |
4791 | - g_free(dirname); |
4792 | - g_free(filename); |
4793 | - g_free(previous_filename); |
4794 | - return; |
4795 | - } else { |
4796 | - g_free(filename); |
4797 | - filename = dirname; |
4798 | - } |
4799 | - } |
4800 | - |
4801 | - TRACE("folder changed to: %s", filename); |
4802 | - |
4803 | - if(panel->selected_folder != NULL) |
4804 | - g_object_unref(panel->selected_folder); |
4805 | - |
4806 | - panel->selected_folder = g_file_new_for_path(filename); |
4807 | - |
4808 | - /* Stop any previous loading since something changed */ |
4809 | - xfdesktop_settings_stop_image_loading(panel); |
4810 | - |
4811 | - panel->cancel_enumeration = g_cancellable_new(); |
4812 | - |
4813 | - g_file_enumerate_children_async(panel->selected_folder, |
4814 | - XFDESKTOP_FILE_INFO_NAMESPACE, |
4815 | - G_FILE_QUERY_INFO_NONE, |
4816 | - G_PRIORITY_DEFAULT, |
4817 | - panel->cancel_enumeration, |
4818 | - xfdesktop_image_list_add_dir, |
4819 | - panel); |
4820 | - |
4821 | - g_free(filename); |
4822 | - g_free(previous_filename); |
4823 | -} |
4824 | - |
4825 | -static void |
4826 | -cb_xfdesktop_combo_image_style_changed(GtkComboBox *combo, |
4827 | - gpointer user_data) |
4828 | -{ |
4829 | - AppearancePanel *panel = user_data; |
4830 | - |
4831 | - TRACE("entering"); |
4832 | - |
4833 | - if(gtk_combo_box_get_active(combo) == XFCE_BACKDROP_IMAGE_NONE) { |
4834 | - /* No wallpaper so set the iconview to insensitive so the user doesn't |
4835 | - * pick wallpapers that have no effect. Stop popping up tooltips for |
4836 | - * the now insensitive iconview and provide a tooltip explaining why |
4837 | - * the iconview is insensitive. */ |
4838 | - gtk_widget_set_sensitive(panel->image_iconview, FALSE); |
4839 | - g_object_set(G_OBJECT(panel->image_iconview), |
4840 | - "tooltip-column", -1, |
4841 | - NULL); |
4842 | - gtk_widget_set_tooltip_text(panel->image_iconview, |
4843 | - _("Image selection is unavailable while the image style is set to None.")); |
4844 | - } else { |
4845 | - gint tooltip_column; |
4846 | - |
4847 | - /* We are expected to provide a wallpaper so make the iconview active. |
4848 | - * Additionally, if we were insensitive then we need to remove the |
4849 | - * global iconview tooltip and enable the individual tooltips again. */ |
4850 | - gtk_widget_set_sensitive(panel->image_iconview, TRUE); |
4851 | - g_object_get(G_OBJECT(panel->image_iconview), |
4852 | - "tooltip-column", &tooltip_column, |
4853 | - NULL); |
4854 | - if(tooltip_column == -1) { |
4855 | - gtk_widget_set_tooltip_text(panel->image_iconview, NULL); |
4856 | - g_object_set(G_OBJECT(panel->image_iconview), |
4857 | - "tooltip-column", COL_NAME, |
4858 | - NULL); |
4859 | - } |
4860 | - } |
4861 | -} |
4862 | - |
4863 | -static void |
4864 | -cb_xfdesktop_combo_color_changed(GtkComboBox *combo, |
4865 | - gpointer user_data) |
4866 | -{ |
4867 | - enum { |
4868 | - COLORS_SOLID = 0, |
4869 | - COLORS_HGRADIENT, |
4870 | - COLORS_VGRADIENT, |
4871 | - COLORS_NONE, |
4872 | - }; |
4873 | - AppearancePanel *panel = user_data; |
4874 | - |
4875 | - TRACE("entering"); |
4876 | - |
4877 | - if(gtk_combo_box_get_active(combo) == COLORS_SOLID) { |
4878 | - gtk_widget_set_sensitive(panel->color1_btn, TRUE); |
4879 | - gtk_widget_set_sensitive(panel->color2_btn, FALSE); |
4880 | - } else if(gtk_combo_box_get_active(combo) == COLORS_NONE) { |
4881 | - gtk_widget_set_sensitive(panel->color1_btn, FALSE); |
4882 | - gtk_widget_set_sensitive(panel->color2_btn, FALSE); |
4883 | - } else { |
4884 | - gtk_widget_set_sensitive(panel->color1_btn, TRUE); |
4885 | - gtk_widget_set_sensitive(panel->color2_btn, TRUE); |
4886 | - } |
4887 | -} |
4888 | - |
4889 | -static void |
4890 | -xfdesktop_settings_update_iconview_folder(AppearancePanel *panel) |
4891 | -{ |
4892 | - gchar *current_folder, *dirname; |
4893 | - |
4894 | - /* If we haven't found our window return now and wait for that */ |
4895 | - if(panel->wnck_window == NULL) |
4896 | - return; |
4897 | - |
4898 | - TRACE("entering"); |
4899 | - |
4900 | - current_folder = xfdesktop_settings_get_backdrop_image(panel); |
4901 | - dirname = g_path_get_dirname(current_folder); |
4902 | - |
4903 | - DBG("current_folder %s, dirname %s", current_folder, dirname); |
4904 | - |
4905 | - gtk_file_chooser_set_current_folder((GtkFileChooser*)panel->btn_folder, dirname); |
4906 | - |
4907 | - /* Workaround for a bug in GTK */ |
4908 | - cb_folder_selection_changed(panel->btn_folder, panel); |
4909 | - |
4910 | - g_free(current_folder); |
4911 | - g_free(dirname); |
4912 | -} |
4913 | - |
4914 | -/* This function is to add or remove all the bindings for the background |
4915 | - * tab. It's intended to be used when the app changes monitors or workspaces. |
4916 | - * It reverts the items back to their defaults before binding any new settings |
4917 | - * that way if the setting isn't present, the default correctly displays. */ |
4918 | -static void |
4919 | -xfdesktop_settings_background_tab_change_bindings(AppearancePanel *panel, |
4920 | - gboolean remove_binding) |
4921 | -{ |
4922 | - gchar *buf, *old_property = NULL; |
4923 | - XfconfChannel *channel = panel->channel; |
4924 | - |
4925 | - /* Image style combo box */ |
4926 | - buf = xfdesktop_settings_generate_per_workspace_binding_string(panel, "image-style"); |
4927 | - if(remove_binding) { |
4928 | - xfconf_g_property_unbind_by_property(channel, buf, |
4929 | - G_OBJECT(panel->image_style_combo), "active"); |
4930 | - } else { |
4931 | - /* If the current image style doesn't exist, try to load the old one */ |
4932 | - if(!xfconf_channel_has_property(channel, buf)) { |
4933 | - gint image_style; |
4934 | - old_property = xfdesktop_settings_generate_old_binding_string(panel, "image-style"); |
4935 | - |
4936 | - /* default to stretched when trying to migrate */ |
4937 | - image_style = xfconf_channel_get_int(channel, old_property, XFCE_BACKDROP_IMAGE_STRETCHED); |
4938 | - |
4939 | - /* xfce_translate_image_styles will do sanity checking */ |
4940 | - gtk_combo_box_set_active(GTK_COMBO_BOX(panel->image_style_combo), |
4941 | - xfce_translate_image_styles(image_style)); |
4942 | - |
4943 | - g_free(old_property); |
4944 | - } |
4945 | - |
4946 | - xfconf_g_property_bind(channel, buf, G_TYPE_INT, |
4947 | - G_OBJECT(panel->image_style_combo), "active"); |
4948 | - /* determine if the iconview is sensitive */ |
4949 | - cb_xfdesktop_combo_image_style_changed(GTK_COMBO_BOX(panel->image_style_combo), panel); |
4950 | - } |
4951 | - g_free(buf); |
4952 | - |
4953 | - /* Color style combo box */ |
4954 | - buf = xfdesktop_settings_generate_per_workspace_binding_string(panel, "color-style"); |
4955 | - if(remove_binding) { |
4956 | - xfconf_g_property_unbind_by_property(channel, buf, |
4957 | - G_OBJECT(panel->color_style_combo), "active"); |
4958 | - } else { |
4959 | - /* If the current color style doesn't exist, try to load the old one */ |
4960 | - if(!xfconf_channel_has_property(channel, buf)) { |
4961 | - gint color_style; |
4962 | - old_property = xfdesktop_settings_generate_old_binding_string(panel, "color-style"); |
4963 | - |
4964 | - /* default to solid when trying to migrate */ |
4965 | - color_style = xfconf_channel_get_int(channel, old_property, XFCE_BACKDROP_COLOR_SOLID); |
4966 | - |
4967 | - /* sanity check */ |
4968 | - if(color_style < 0 || color_style > XFCE_BACKDROP_COLOR_TRANSPARENT) { |
4969 | - g_warning("invalid color style, setting to solid"); |
4970 | - color_style = XFCE_BACKDROP_COLOR_SOLID; |
4971 | - } |
4972 | - |
4973 | - gtk_combo_box_set_active(GTK_COMBO_BOX(panel->color_style_combo), |
4974 | - color_style); |
4975 | - g_free(old_property); |
4976 | - } |
4977 | - |
4978 | - xfconf_g_property_bind(channel, buf, G_TYPE_INT, |
4979 | - G_OBJECT(panel->color_style_combo), "active"); |
4980 | - /* update the color button sensitivity */ |
4981 | - cb_xfdesktop_combo_color_changed(GTK_COMBO_BOX(panel->color_style_combo), panel); |
4982 | - } |
4983 | - g_free(buf); |
4984 | - |
4985 | - /* color 1 button */ |
4986 | - buf = xfdesktop_settings_generate_per_workspace_binding_string(panel, "color1"); |
4987 | - if(remove_binding) { |
4988 | - xfconf_g_property_unbind(panel->color1_btn_id); |
4989 | - } else { |
4990 | - /* If the first color doesn't exist, try to load the old one */ |
4991 | - if(!xfconf_channel_has_property(channel, buf)) { |
4992 | - GValue value = { 0, }; |
4993 | - old_property = xfdesktop_settings_generate_old_binding_string(panel, "color2"); |
4994 | - |
4995 | - xfconf_channel_get_property(channel, old_property, &value); |
4996 | - |
4997 | - if(G_VALUE_HOLDS_BOXED(&value)) { |
4998 | - gtk_color_button_set_color(GTK_COLOR_BUTTON(panel->color2_btn), |
4999 | - g_value_get_boxed(&value)); |
5000 | - g_value_unset(&value); |
The diff has been truncated for viewing.
thanks