Merge lp:~bratsche/xsplash/monitors-changed into lp:xsplash

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bratsche/xsplash/monitors-changed
Merge into: lp:xsplash
Diff against target: 283 lines
1 file modified
src/xsplash.c (+156/-69)
To merge this branch: bzr merge lp:~bratsche/xsplash/monitors-changed
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+12833@code.launchpad.net
To post a comment you must log in.
84. By Cody Russell

revert logfile change

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xsplash.c'
2--- src/xsplash.c 2009-10-01 20:56:55 +0000
3+++ src/xsplash.c 2009-10-04 00:15:21 +0000
4@@ -53,10 +53,15 @@
5
6 struct _XsplashServerPrivate
7 {
8- gchar *dbusobject;
9 GtkWidget *window;
10+ GtkWidget *logo;
11+ GtkWidget *fixed;
12 GtkWidget *throbber;
13+ GtkWidget *background;
14+ GdkPixbuf *logo_pixbuf;
15 GdkPixbuf *throbber_pixbuf;
16+
17+ gchar *dbusobject;
18 DBusGConnection *system_bus;
19 DBusGProxy *bus_proxy;
20
21@@ -505,20 +510,140 @@
22 gdk_screen_get_rgba_colormap (priv->screen));
23 }
24 }
25+
26+ gtk_window_present (GTK_WINDOW (priv->window));
27+}
28+
29+static void
30+setup_background_image (XsplashServer *server)
31+{
32+ XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
33+ GdkPixmap *pixmap;
34+ GdkPixbuf *pixbuf;
35+
36+ pixbuf = get_pixbuf (get_monitor_width (),
37+ get_monitor_height ());
38+
39+ pixmap = gdk_pixmap_new (priv->cow,
40+ gdk_pixbuf_get_width (pixbuf),
41+ gdk_pixbuf_get_height (pixbuf),
42+ -1);
43+
44+ gdk_draw_pixbuf (pixmap,
45+ NULL,
46+ pixbuf,
47+ 0, 0,
48+ 0, 0,
49+ -1, -1,
50+ GDK_RGB_DITHER_MAX,
51+ 0, 0);
52+
53+ if (!priv->background)
54+ {
55+ priv->background = gtk_image_new_from_pixmap (pixmap,
56+ NULL);
57+ }
58+ else
59+ {
60+ gtk_image_set_from_pixmap (GTK_IMAGE (priv->background),
61+ pixmap, NULL);
62+ }
63+}
64+
65+static void
66+setup_logo_image (XsplashServer *server)
67+{
68+ XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
69+
70+ if (!priv->logo)
71+ {
72+ gchar *logo_filename = NULL;
73+
74+ logo_filename = get_logo_filename (get_monitor_width ());
75+ priv->logo_pixbuf = gdk_pixbuf_new_from_file (logo_filename, NULL);
76+
77+ priv->logo = gtk_image_new_from_pixbuf (priv->logo_pixbuf);
78+
79+ gtk_fixed_put (GTK_FIXED (priv->fixed),
80+ priv->logo,
81+ get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2,
82+ get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2);
83+
84+ if (logo_filename != NULL)
85+ g_free (logo_filename);
86+ }
87+ else
88+ {
89+ gtk_fixed_move (GTK_FIXED (priv->fixed),
90+ priv->logo,
91+ get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2,
92+ get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2);;
93+ }
94+}
95+
96+static void
97+setup_throbber_image (XsplashServer *server)
98+{
99+ XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
100+
101+ if (!priv->throbber)
102+ {
103+ gchar *throbber_filename = NULL;
104+
105+ throbber_filename = get_throbber_filename ();
106+
107+ if (throbber_filename && throbber_frames)
108+ {
109+ priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_filename, NULL);
110+
111+ if (priv->throbber_pixbuf != NULL)
112+ {
113+ priv->throbber = gtk_image_new ();
114+ gtk_widget_show (priv->throbber);
115+
116+ gtk_fixed_put (GTK_FIXED (priv->fixed),
117+ priv->throbber,
118+ get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
119+ get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
120+
121+ start_throbber (server);
122+ }
123+ else
124+ {
125+ g_message ("couldn't load throbber image from file (%s); "
126+ "disabling throbber", throbber_image);
127+ }
128+ }
129+
130+ if (throbber_filename)
131+ g_free (throbber_filename);
132+ }
133+ else
134+ {
135+ gtk_fixed_move (GTK_FIXED (priv->fixed),
136+ priv->throbber,
137+ get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
138+ get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
139+ }
140+}
141+
142+static void
143+monitors_changed (GdkScreen *screen,
144+ gpointer user_data)
145+{
146+ XsplashServer *server= (XsplashServer *)user_data;
147+
148+ setup_background_image (server);
149+ setup_logo_image (server);
150+ setup_throbber_image (server);
151+
152+ g_message ("**** monitors changed");
153 }
154
155 static void
156 xsplash_server_init (XsplashServer *server)
157 {
158 XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
159- GdkPixbuf *pixbuf;
160- GdkPixbuf *logo;
161- GtkWidget *image;
162- GtkWidget *fixed;
163- gchar *logo_filename;
164- gchar *throbber_filename;
165- GdkPixmap *pixmap;
166- GdkVisual *visual;
167
168 priv->dbusobject = NULL;
169 priv->system_bus = NULL;
170@@ -532,6 +657,7 @@
171 if (have_xcomposite)
172 {
173 Window window;
174+ GdkCursor *cursor;
175
176 gdk_error_trap_push ();
177
178@@ -539,6 +665,11 @@
179 GDK_DRAWABLE_XID (gdk_get_default_root_window ()));
180 priv->cow = gdk_window_foreign_new (window);
181
182+ cursor = gdk_cursor_new (GDK_BLANK_CURSOR);
183+ gdk_window_set_cursor (priv->cow,
184+ cursor);
185+ gdk_cursor_unref (cursor);
186+
187 gdk_flush ();
188 gdk_error_trap_pop ();
189 }
190@@ -557,6 +688,10 @@
191 "composited-changed",
192 G_CALLBACK (composited_changed),
193 server);
194+ g_signal_connect (G_OBJECT (priv->screen),
195+ "monitors-changed",
196+ G_CALLBACK (monitors_changed),
197+ server);
198
199 g_signal_connect (priv->window,
200 "realize",
201@@ -571,70 +706,22 @@
202 G_CALLBACK (focus_out_event),
203 server);
204
205- logo_filename = get_logo_filename (get_monitor_width ());
206- throbber_filename = get_throbber_filename ();
207-
208- pixbuf = get_pixbuf (get_monitor_width (),
209- get_monitor_height ());
210-
211- logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
212-
213- fixed = gtk_fixed_new ();
214-
215- visual = gdk_screen_get_system_visual (priv->screen);
216- pixmap = gdk_pixmap_new (NULL,
217- gdk_pixbuf_get_width (pixbuf),
218- gdk_pixbuf_get_height (pixbuf),
219- visual->depth);
220- gdk_draw_pixbuf (pixmap,
221- NULL,
222- pixbuf,
223- 0, 0,
224- 0, 0,
225- -1, -1,
226- GDK_RGB_DITHER_MAX,
227- 0, 0);
228- image = gtk_image_new_from_pixmap (pixmap,
229- NULL);
230- gtk_container_add (GTK_CONTAINER (fixed), image);
231-
232- image = gtk_image_new_from_pixbuf (logo);
233- gtk_fixed_put (GTK_FIXED (fixed), image,
234- get_monitor_width () / 2 - gdk_pixbuf_get_width (logo) / 2,
235- get_monitor_height () / 3 - gdk_pixbuf_get_height (logo) / 2);
236-
237- if (throbber_filename && throbber_frames)
238- {
239- priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_filename, NULL);
240-
241- if (priv->throbber_pixbuf != NULL)
242- {
243- priv->throbber = gtk_image_new ();
244- gtk_widget_show (priv->throbber);
245-
246- gtk_fixed_put (GTK_FIXED (fixed), priv->throbber,
247- get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
248- get_monitor_height () / 3 + gdk_pixbuf_get_height (logo) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
249- start_throbber (server);
250- }
251- else
252- {
253- g_message ("couldn't load throbber image from file (%s); "
254- "disabling throbber", throbber_image);
255- }
256- }
257-
258- gtk_container_add (GTK_CONTAINER (priv->window), fixed);
259+ priv->fixed = gtk_fixed_new ();
260+
261+ setup_background_image (server);
262+
263+ gtk_container_add (GTK_CONTAINER (priv->fixed),
264+ priv->background);
265+
266+ setup_logo_image (server);
267+ setup_throbber_image (server);
268+
269+ gtk_container_add (GTK_CONTAINER (priv->window), priv->fixed);
270
271 start_daemon_mode ();
272
273 gtk_widget_show_all (priv->window);
274-
275- if (logo_filename)
276- g_free (logo_filename);
277-
278- if (throbber_filename)
279- g_free (throbber_filename);
280+ gtk_window_present (GTK_WINDOW (priv->window));
281 }
282
283 static void

Subscribers

People subscribed via source and target branches