-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathDesktopManager.vala
169 lines (148 loc) · 5.47 KB
/
DesktopManager.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Copyright (c) 2017-2019 José Amuedo (https://github.com/spheras)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @class
* Desktop Manager
*/
public class DesktopFolder.DesktopManager : DesktopFolder.FolderManager {
/**
* @constructor
* @param DesktopFolderApp application the application owner of this window
* @param string folder_name the name of the folder
*/
public DesktopManager (DesktopFolderApp application) {
// first, let's check the folder
var directory = File.new_for_path (DesktopFolderApp.get_app_folder ()); // + "/" + DesktopFolder.DesktopWindow.DESKTOP_FAKE_FOLDER_NAME);
if (!directory.query_exists ()) {
DirUtils.create (directory.get_path (), 0755);
}
base (application, "");
// we cannot be moved
this.is_moveable = false;
this.get_view ().set_type_hint (Gdk.WindowTypeHint.DOCK);
this.get_view ().change_body_color (0);
Gdk.Screen screen = Gdk.Screen.get_default ();
this.on_screen_size_changed (screen);
this.view.show ();
}
/**
* @overrided
*/
public override int get_parent_default_arrangement_orientation_setting () {
return FolderSettings.ARRANGEMENT_ORIENTATION_VERTICAL;
}
/**
* @name create_view
* @description create the view associated with this manager
* @overrided
*/
protected override void create_view () {
this.view = new DesktopFolder.DesktopWindow (this);
}
/**
* @name show_items
* @description shows the items
*/
public override void show_items () {
debug (@"show_items $(this.get_application ().get_desktop_visibility ())");
if (this.get_application ().get_desktop_visibility ()) {
debug ("showing items");
base.show_items ();
base.view.refresh ();
}
}
/**
* @name hide_items
* @description hides the items
*/
public override void hide_items () {
debug (@"hide_items $(this.get_application ().get_desktop_visibility ())");
debug ("hiding items");
base.hide_items ();
}
/**
* @name show_view
* @description show the items on the desktop
* @override
*/
public override void show_view () {
this.show_items ();
}
/**
* @name hide_view
* @description hide the items on the desktop
* @override
*/
public override void hide_view () {
this.hide_items ();
}
/**
* @name on_screen_size_changed
* @description detecting screen size changes
*/
public override void on_screen_size_changed (Gdk.Screen screen) {
if (screen == null) {
screen = Gdk.Screen.get_default ();
}
Gdk.Rectangle boundingbox = DesktopFolder.Util.get_desktop_bounding_box ();
debug ("bounding box result: %d,%d -- %d,%d", boundingbox.x, boundingbox.y, boundingbox.width, boundingbox.height);
this.get_view ().move (0, 0); // (-12, -10);
int w = boundingbox.width; // deprecated -> screen.get_width (); // + 25;
int h = boundingbox.height; // deprecated -> screen.get_height (); // + 25;
this.get_view ().resize (w, h);
this.get_view ().set_default_size (w, h);
this.get_view ().height_request = h;
this.get_view ().width_request = w;
debug ("DESKTOP SIZE CHANGED! (%d,%d) (%d,%d)", -12, -10, w, h);
}
/**
* @name skip_file
* @description we must skip the widget setting files
* @override
*/
protected override bool skip_file (File file) {
string basename = file.get_basename ();
if (FileUtils.test (file.get_path (), FileTest.IS_DIR)) {
// is a panel?
string flagfilepath = file.get_path () + "/.desktopfolder";
// debug("is a panel? %s",flagfilepath);
File flagfile = File.new_for_commandline_arg (flagfilepath);
return flagfile.query_exists ();
} else {
if (basename.has_suffix (DesktopFolder.OLD_NOTE_EXTENSION) || basename.has_suffix (DesktopFolder.OLD_PHOTO_EXTENSION)
|| basename.has_suffix (DesktopFolder.NEW_NOTE_EXTENSION) || basename.has_suffix (DesktopFolder.NEW_PHOTO_EXTENSION)) {
return true;
}
}
return base.skip_file (file);
}
/**
* @overrided
* we must create a .nopanel inside to avoid creating a panel from this folder
*/
protected override void create_new_folder_inside (string folder_path) {
File nopanel = File.new_for_path (folder_path + "/.nopanel");
try {
if (!nopanel.query_exists ()) {
nopanel.create (FileCreateFlags.NONE);
}
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
Util.show_error_dialog ("Error", e.message);
}
}
}