2
* main.c - desktop manager of pcmanfm
4
* Copyright 2008 PCMan <pcman.tw@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28
#ifdef DESKTOP_INTEGRATION
31
//#include "fm-desktop.h"
33
#include "vfs-file-info.h"
34
#include "vfs-mime-type.h"
35
//#include "vfs-app-desktop.h"
37
#include "vfs-file-monitor.h"
38
#include "vfs-volume.h"
39
#include "vfs-thumbnail-loader.h"
42
#include "desktop-window.h"
46
static GtkWindowGroup* group = NULL;
48
static GdkFilterReturn on_rootwin_event ( GdkXEvent *xevent, GdkEvent *event, gpointer data );
50
static GtkWidget **desktops = NULL;
51
static gint n_screens = 0;
53
static guint theme_change_notify = 0;
55
static void on_icon_theme_changed( GtkIconTheme* theme, gpointer data )
57
/* reload icons of desktop windows */
59
for ( i = 0; i < n_screens; i++ )
60
desktop_window_reload_icons( (DesktopWindow*)desktops[ i ] );
63
void fm_turn_on_desktop_icons()
70
group = gtk_window_group_new();
72
theme_change_notify = g_signal_connect( gtk_icon_theme_get_default(), "changed",
73
G_CALLBACK(on_icon_theme_changed), NULL );
75
vfs_mime_type_get_icon_size( &big, NULL );
77
gdpy = gdk_display_get_default();
79
n_screens = gdk_display_get_n_screens( gdpy );
80
desktops = g_new( GtkWidget *, n_screens );
81
for ( i = 0; i < n_screens; i++ )
83
desktops[ i ] = desktop_window_new();
84
desktop_window_set_icon_size( (DesktopWindow*)desktops[ i ], big );
85
desktop_window_set_single_click( (DesktopWindow*)desktops[ i ], app_settings.single_click );
87
gtk_widget_realize( desktops[ i ] ); /* without this, setting wallpaper won't work */
88
gtk_widget_show_all( desktops[ i ] );
89
gdk_window_lower( desktops[ i ] ->window );
91
gtk_window_group_add_window( group, desktops[i] );
93
fm_desktop_update_colors();
94
fm_desktop_update_wallpaper();
97
void fm_turn_off_desktop_icons()
101
if( theme_change_notify )
103
g_signal_handler_disconnect( gtk_icon_theme_get_default(), theme_change_notify );
104
theme_change_notify = 0;
107
for ( i = 0; i < n_screens; i++ )
109
gtk_widget_destroy( desktops[ i ] );
110
/* gtk_window_group_remove_window() */
114
// if ( busy_cursor > 0 )
115
// g_source_remove( busy_cursor );
116
g_object_unref( group );
120
void fm_desktop_update_thumbnails()
122
/* FIXME: thumbnail on desktop cannot be turned off. */
125
void fm_desktop_update_wallpaper()
131
if( app_settings.show_wallpaper && app_settings.wallpaper )
133
switch( app_settings.wallpaper_mode )
146
type = DW_BG_STRETCH;
148
pix = gdk_pixbuf_new_from_file( app_settings.wallpaper, NULL );
156
for ( i = 0; i < n_screens; i++ )
157
desktop_window_set_background( desktops[ i ], pix, type );
160
g_object_unref( pix );
163
void fm_desktop_update_colors()
166
for ( i = 0; i < n_screens; i++ )
168
desktop_window_set_bg_color( desktops[ i ], &app_settings.desktop_bg1 );
169
desktop_window_set_text_color( desktops[ i ], &app_settings.desktop_text, &app_settings.desktop_shadow );
173
void fm_desktop_update_icons()
178
vfs_mime_type_get_icon_size( &big, NULL );
180
for ( i = 0; i < n_screens; i++ )
181
desktop_window_set_icon_size( (DesktopWindow*)desktops[ i ], big );
184
void fm_desktop_set_single_click( gboolean single_click )
187
for ( i = 0; i < n_screens; i++ )
188
desktop_window_set_single_click( (DesktopWindow*)desktops[ i ], single_click );
191
#else /* ! DESKTOP_INTEGRATION */
193
/* dummy implementations */
194
void fm_turn_on_desktop_icons() { }
195
void fm_turn_off_desktop_icons() { }
196
void fm_desktop_update_thumbnails() { }
197
void fm_desktop_update_wallpaper() { }
198
void fm_desktop_update_colors() { }
199
void fm_desktop_update_icons() { }
200
void fm_desktop_set_single_click( gboolean single_click ) { }