~ubuntu-branches/ubuntu/trusty/pcmanfm/trusty-proposed

« back to all changes in this revision

Viewing changes to src/desktop/desktop.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Lee
  • Date: 2008-09-26 10:19:20 UTC
  • mfrom: (4.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080926101920-cfldybkmwgwrtv9u
Tags: 0.5-3
* Correct spellings,  03_correct_spelling.dpatch (Closes:498794) 
* Code in some files are taken from other projects, added these
  informations into copyright file. (Closes:499678)
* Applied 04_defaut_terminal.dpatch to support x-terminal-emulator
  alternative. (Closes:497494) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      main.c - desktop manager of pcmanfm
 
3
 *
 
4
 *      Copyright 2008 PCMan <pcman.tw@gmail.com>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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,
 
19
 *      MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifdef HAVE_CONFIG_H
 
23
#  include <config.h>
 
24
#endif
 
25
 
 
26
#include "desktop.h"
 
27
 
 
28
#ifdef DESKTOP_INTEGRATION
 
29
 
 
30
#include <gtk/gtk.h>
 
31
//#include "fm-desktop.h"
 
32
 
 
33
#include "vfs-file-info.h"
 
34
#include "vfs-mime-type.h"
 
35
//#include "vfs-app-desktop.h"
 
36
 
 
37
#include "vfs-file-monitor.h"
 
38
#include "vfs-volume.h"
 
39
#include "vfs-thumbnail-loader.h"
 
40
#include "vfs-dir.h"
 
41
 
 
42
#include "desktop-window.h"
 
43
 
 
44
#include "settings.h"
 
45
 
 
46
static GtkWindowGroup* group = NULL;
 
47
 
 
48
static GdkFilterReturn on_rootwin_event ( GdkXEvent *xevent, GdkEvent *event, gpointer data );
 
49
 
 
50
static GtkWidget **desktops = NULL;
 
51
static gint n_screens = 0;
 
52
 
 
53
static guint theme_change_notify = 0;
 
54
 
 
55
static void on_icon_theme_changed( GtkIconTheme* theme, gpointer data )
 
56
{
 
57
        /* reload icons of desktop windows */
 
58
    int i;
 
59
    for ( i = 0; i < n_screens; i++ )
 
60
        desktop_window_reload_icons( (DesktopWindow*)desktops[ i ] );
 
61
}
 
62
 
 
63
void fm_turn_on_desktop_icons()
 
64
{
 
65
    GdkDisplay * gdpy;
 
66
    gint i;
 
67
    int big = 0;
 
68
 
 
69
    if( ! group )
 
70
        group = gtk_window_group_new();
 
71
 
 
72
    theme_change_notify = g_signal_connect( gtk_icon_theme_get_default(), "changed",
 
73
                                                                                                        G_CALLBACK(on_icon_theme_changed), NULL );
 
74
 
 
75
    vfs_mime_type_get_icon_size( &big, NULL );
 
76
 
 
77
    gdpy = gdk_display_get_default();
 
78
 
 
79
    n_screens = gdk_display_get_n_screens( gdpy );
 
80
    desktops = g_new( GtkWidget *, n_screens );
 
81
    for ( i = 0; i < n_screens; i++ )
 
82
    {
 
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 );
 
86
 
 
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 );
 
90
 
 
91
        gtk_window_group_add_window( group, desktops[i] );
 
92
    }
 
93
    fm_desktop_update_colors();
 
94
    fm_desktop_update_wallpaper();
 
95
}
 
96
 
 
97
void fm_turn_off_desktop_icons()
 
98
{
 
99
    int i;
 
100
 
 
101
    if( theme_change_notify )
 
102
    {
 
103
        g_signal_handler_disconnect( gtk_icon_theme_get_default(), theme_change_notify );
 
104
        theme_change_notify = 0;
 
105
    }
 
106
 
 
107
    for ( i = 0; i < n_screens; i++ )
 
108
    {
 
109
        gtk_widget_destroy( desktops[ i ] );
 
110
        /* gtk_window_group_remove_window() */
 
111
    }
 
112
    g_free( desktops );
 
113
 
 
114
//    if ( busy_cursor > 0 )
 
115
//        g_source_remove( busy_cursor );
 
116
    g_object_unref( group );
 
117
    group = NULL;
 
118
}
 
119
 
 
120
void fm_desktop_update_thumbnails()
 
121
{
 
122
    /* FIXME: thumbnail on desktop cannot be turned off. */
 
123
}
 
124
 
 
125
void fm_desktop_update_wallpaper()
 
126
{
 
127
    DWBgType type;
 
128
    GdkPixbuf* pix;
 
129
    int i;
 
130
 
 
131
    if( app_settings.show_wallpaper && app_settings.wallpaper )
 
132
    {
 
133
        switch( app_settings.wallpaper_mode )
 
134
        {
 
135
        case WPM_FULL:
 
136
            type = DW_BG_FULL;
 
137
            break;
 
138
        case WPM_CENTER:
 
139
            type = DW_BG_CENTER;
 
140
            break;
 
141
        case WPM_TILE:
 
142
            type = DW_BG_TILE;
 
143
            break;
 
144
        case WPM_STRETCH:
 
145
        default:
 
146
            type = DW_BG_STRETCH;
 
147
        }
 
148
        pix = gdk_pixbuf_new_from_file( app_settings.wallpaper, NULL );
 
149
    }
 
150
    else
 
151
    {
 
152
        type = DW_BG_COLOR;
 
153
        pix = NULL;
 
154
    }
 
155
 
 
156
    for ( i = 0; i < n_screens; i++ )
 
157
        desktop_window_set_background( desktops[ i ], pix, type );
 
158
 
 
159
    if( pix )
 
160
        g_object_unref( pix );
 
161
}
 
162
 
 
163
void fm_desktop_update_colors()
 
164
{
 
165
    int i;
 
166
    for ( i = 0; i < n_screens; i++ )
 
167
    {
 
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 );
 
170
    }
 
171
}
 
172
 
 
173
void fm_desktop_update_icons()
 
174
{
 
175
    int i;
 
176
    int big = 0;
 
177
 
 
178
    vfs_mime_type_get_icon_size( &big, NULL );
 
179
 
 
180
    for ( i = 0; i < n_screens; i++ )
 
181
        desktop_window_set_icon_size( (DesktopWindow*)desktops[ i ], big );
 
182
}
 
183
 
 
184
void fm_desktop_set_single_click( gboolean single_click )
 
185
{
 
186
    int i;
 
187
    for ( i = 0; i < n_screens; i++ )
 
188
        desktop_window_set_single_click( (DesktopWindow*)desktops[ i ], single_click );
 
189
}
 
190
 
 
191
#else /* ! DESKTOP_INTEGRATION */
 
192
 
 
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 ) { }
 
201
#endif
 
202