← Back to team overview

ayatana-commits team mailing list archive

[Branch ~xsplash-team/xsplash/trunk] Rev 83: merge lp:~bratsche/xsplash/monitors-changed, bug #413348

 

Merge authors:
  Cody Russell (bratsche)
Related merge proposals:
  https://code.launchpad.net/~bratsche/xsplash/monitors-changed/+merge/12833
  proposed by: Cody Russell (bratsche)
  review: Approve - Ted Gould (ted)
------------------------------------------------------------
revno: 83 [merge]
committer: Cody Russell <crussell@xxxxxxxxxxxxx>
branch nick: xsplash
timestamp: Mon 2009-10-05 17:48:01 -0400
message:
  merge lp:~bratsche/xsplash/monitors-changed, bug #413348
modified:
  src/xsplash.c


--
lp:xsplash
https://code.launchpad.net/~xsplash-team/xsplash/trunk

Your team ayatana-commits is subscribed to branch lp:xsplash.
To unsubscribe from this branch go to https://code.launchpad.net/~xsplash-team/xsplash/trunk/+edit-subscription.
=== modified file 'src/xsplash.c'
--- src/xsplash.c	2009-10-05 21:46:49 +0000
+++ src/xsplash.c	2009-10-05 21:48:01 +0000
@@ -55,10 +55,15 @@
 
 struct _XsplashServerPrivate
 {
-  gchar           *dbusobject;
   GtkWidget       *window;
+  GtkWidget       *logo;
+  GtkWidget       *fixed;
   GtkWidget       *throbber;
+  GtkWidget       *background;
+  GdkPixbuf       *logo_pixbuf;
   GdkPixbuf       *throbber_pixbuf;
+
+  gchar           *dbusobject;
   DBusGConnection *system_bus;
   DBusGProxy      *bus_proxy;
 
@@ -507,20 +512,140 @@
                                    gdk_screen_get_rgba_colormap (priv->screen));
         }
     }
+
+  gtk_window_present (GTK_WINDOW (priv->window));
+}
+
+static void
+setup_background_image (XsplashServer *server)
+{
+  XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
+  GdkPixmap *pixmap;
+  GdkPixbuf *pixbuf;
+
+  pixbuf = get_pixbuf (get_monitor_width (),
+                       get_monitor_height ());
+
+  pixmap = gdk_pixmap_new (priv->cow,
+                           gdk_pixbuf_get_width (pixbuf),
+                           gdk_pixbuf_get_height (pixbuf),
+                           -1);
+
+  gdk_draw_pixbuf (pixmap,
+                   NULL,
+                   pixbuf,
+                   0, 0,
+                   0, 0,
+                   -1, -1,
+                   GDK_RGB_DITHER_MAX,
+                   0, 0);
+
+  if (!priv->background)
+    {
+      priv->background = gtk_image_new_from_pixmap (pixmap,
+                                                    NULL);
+    }
+  else
+    {
+      gtk_image_set_from_pixmap (GTK_IMAGE (priv->background),
+                                 pixmap, NULL);
+    }
+}
+
+static void
+setup_logo_image (XsplashServer *server)
+{
+  XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
+
+  if (!priv->logo)
+    {
+      gchar *logo_filename = NULL;
+
+      logo_filename = get_logo_filename (get_monitor_width ());
+      priv->logo_pixbuf = gdk_pixbuf_new_from_file (logo_filename, NULL);
+
+      priv->logo = gtk_image_new_from_pixbuf (priv->logo_pixbuf);
+
+      gtk_fixed_put (GTK_FIXED (priv->fixed),
+                     priv->logo,
+                     get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2,
+                     get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2);
+
+      if (logo_filename != NULL)
+        g_free (logo_filename);
+    }
+  else
+    {
+      gtk_fixed_move (GTK_FIXED (priv->fixed),
+                      priv->logo,
+                      get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->logo_pixbuf) / 2,
+                      get_monitor_height () / 3 - gdk_pixbuf_get_height (priv->logo_pixbuf) / 2);;
+    }
+}
+
+static void
+setup_throbber_image (XsplashServer *server)
+{
+  XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
+
+  if (!priv->throbber)
+    {
+      gchar *throbber_filename = NULL;
+
+      throbber_filename = get_throbber_filename ();
+
+      if (throbber_filename && throbber_frames)
+        {
+          priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_filename, NULL);
+
+          if (priv->throbber_pixbuf != NULL)
+            {
+              priv->throbber = gtk_image_new ();
+              gtk_widget_show (priv->throbber);
+
+              gtk_fixed_put (GTK_FIXED (priv->fixed),
+                             priv->throbber,
+                             get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
+                             get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
+
+              start_throbber (server);
+            }
+          else
+            {
+              g_message ("couldn't load throbber image from file (%s); "
+                         "disabling throbber", throbber_image);
+            }
+        }
+
+      if (throbber_filename)
+        g_free (throbber_filename);
+    }
+  else
+    {
+      gtk_fixed_move (GTK_FIXED (priv->fixed),
+                      priv->throbber,
+                      get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
+                      get_monitor_height () / 3 + gdk_pixbuf_get_height (priv->logo_pixbuf) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
+    }
+}
+
+static void
+monitors_changed (GdkScreen *screen,
+                  gpointer   user_data)
+{
+  XsplashServer *server= (XsplashServer *)user_data;
+
+  setup_background_image (server);
+  setup_logo_image (server);
+  setup_throbber_image (server);
+
+  g_message ("**** monitors changed");
 }
 
 static void
 xsplash_server_init (XsplashServer *server)
 {
   XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
-  GdkPixbuf *pixbuf;
-  GdkPixbuf *logo;
-  GtkWidget *image;
-  GtkWidget *fixed;
-  gchar *logo_filename;
-  gchar *throbber_filename;
-  GdkPixmap *pixmap;
-  GdkVisual *visual;
 
   priv->dbusobject = NULL;
   priv->system_bus = NULL;
@@ -565,6 +690,10 @@
                     "composited-changed",
                     G_CALLBACK (composited_changed),
                     server);
+  g_signal_connect (G_OBJECT (priv->screen),
+                    "monitors-changed",
+                    G_CALLBACK (monitors_changed),
+                    server);
 
   g_signal_connect (priv->window,
                     "realize",
@@ -579,70 +708,22 @@
                     G_CALLBACK (focus_out_event),
                     server);
 
-  logo_filename = get_logo_filename (get_monitor_width ());
-  throbber_filename = get_throbber_filename ();
-
-  pixbuf = get_pixbuf (get_monitor_width (),
-                       get_monitor_height ());
-
-  logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
-
-  fixed = gtk_fixed_new ();
-  
-  visual = gdk_screen_get_system_visual (priv->screen);
-  pixmap = gdk_pixmap_new (NULL,
-                           gdk_pixbuf_get_width (pixbuf),
-                           gdk_pixbuf_get_height (pixbuf),
-                           visual->depth);
-  gdk_draw_pixbuf (pixmap,
-                   NULL,
-                   pixbuf,
-                   0, 0,
-                   0, 0,
-                   -1, -1,
-                   GDK_RGB_DITHER_MAX,
-                   0, 0);
-  image = gtk_image_new_from_pixmap (pixmap,
-                                     NULL);
-  gtk_container_add (GTK_CONTAINER (fixed), image);
-
-  image = gtk_image_new_from_pixbuf (logo);
-  gtk_fixed_put (GTK_FIXED (fixed), image,
-                 get_monitor_width () / 2 - gdk_pixbuf_get_width (logo) / 2,
-                 get_monitor_height () / 3 - gdk_pixbuf_get_height (logo) / 2);
-
-  if (throbber_filename && throbber_frames)
-    {
-      priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_filename, NULL);
-
-      if (priv->throbber_pixbuf != NULL)
-        {
-          priv->throbber = gtk_image_new ();
-          gtk_widget_show (priv->throbber);
-
-          gtk_fixed_put (GTK_FIXED (fixed), priv->throbber,
-                         get_monitor_width () / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
-                         get_monitor_height () / 3 + gdk_pixbuf_get_height (logo) / 2 + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
-          start_throbber (server);
-        }
-      else
-        {
-          g_message ("couldn't load throbber image from file (%s); "
-                   "disabling throbber", throbber_image);
-        }
-    }
-
-  gtk_container_add (GTK_CONTAINER (priv->window), fixed);
+  priv->fixed = gtk_fixed_new ();
+
+  setup_background_image (server);
+
+  gtk_container_add (GTK_CONTAINER (priv->fixed),
+                     priv->background);
+
+  setup_logo_image (server);
+  setup_throbber_image (server);
+
+  gtk_container_add (GTK_CONTAINER (priv->window), priv->fixed);
 
   start_daemon_mode ();
 
   gtk_widget_show_all (priv->window);
-
-  if (logo_filename)
-    g_free (logo_filename);
-
-  if (throbber_filename)
-    g_free (throbber_filename);
+  gtk_window_present (GTK_WINDOW (priv->window));
 }
 
 static void