← Back to team overview

lightdm-gtk-greeter-team team mailing list archive

Patch submission

 

Dear team,

I've written a (small) patch for my needs, it may be a good idea to push it
This patch just allow users to define where will be put the
authentication banner, by reading x and y positions from config

I hope you will accept it

Thanks



--- commit/data/lightdm-gtk-greeter.conf        2013-05-30
20:16:47.892174000 +0200
+++ new/data/lightdm-gtk-greeter.conf   2013-05-30 20:24:55.052403274 +0200
@@ -12,6 +12,8 @@
 # show-clock (true or false)
 # clock-format = strftime-format string, e.g. %H:%M
 # keyboard = command to launch on-screen keyboard
+# banner-x = position where to put the authentication banner position (x)
+# banner-y = position where to put the authentication banner position (y)
 #
 [greeter]
 background=/lib/plymouth/themes/xubuntu-logo/xubuntu-greybird.png
@@ -28,3 +30,5 @@ show-language-selector=true
 show-clock=true
 clock-format=%a, %I:%M %p
 keyboard=onboard
+#banner-x=250
+#banner-y=250
diff -rupN commit/src/lightdm-gtk-greeter.c new/src/lightdm-gtk-greeter.c
--- commit/src/lightdm-gtk-greeter.c    2013-05-30 20:16:47.892174000 +0200
+++ new/src/lightdm-gtk-greeter.c       2013-05-30 20:23:55.148399038 +0200
@@ -78,6 +78,9 @@ static cairo_region_t *window_region = N
 static GdkRegion *window_region = NULL;
 #endif

+/* Banner positions */
+static gint banner_x = -1;
+static gint banner_y = -1;

 #ifdef HAVE_LIBINDICATOR
 static gboolean
@@ -917,8 +920,10 @@ authentication_complete_cb (LightDMGreet
 }

 static void
-center_window (GtkWindow *window)
+position_window (GtkWindow *window)
 {
+    gint x = banner_x;
+    gint y = banner_y;
     GdkScreen *screen;
     GtkAllocation allocation;
     GdkRectangle monitor_geometry;
@@ -926,9 +931,14 @@ center_window (GtkWindow *window)
     screen = gtk_window_get_screen (window);
     gdk_screen_get_monitor_geometry (screen,
gdk_screen_get_primary_monitor (screen), &monitor_geometry);
     gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
-    gtk_window_move (window,
+
+    /* Default: if values are not suitable, put the window at the center */
+    if (x == -1 || y == -1 || (x + allocation.width >
monitor_geometry.width) || (y + allocation.height >
monitor_geometry.height))
+        gtk_window_move (window,
                      monitor_geometry.x + (monitor_geometry.width -
allocation.width) / 2,
                      monitor_geometry.y + (monitor_geometry.height -
allocation.height) / 2);
+    else
+        gtk_window_move (window, x, y);
 }

 void suspend_cb (GtkWidget *widget, LightDMGreeter *greeter);
@@ -984,7 +994,7 @@ restart_cb (GtkWidget *widget, LightDMGr
     /* Hide the login window and show the dialog */
     gtk_widget_hide (GTK_WIDGET (login_window));
     gtk_widget_show_all (dialog);
-    center_window (GTK_WINDOW (dialog));
+    position_window (GTK_WINDOW (dialog));

     if (gtk_dialog_run (GTK_DIALOG (dialog)))
         lightdm_restart (NULL);
@@ -1030,7 +1040,7 @@ shutdown_cb (GtkWidget *widget, LightDMG
     /* Hide the login window and show the dialog */
     gtk_widget_hide (GTK_WIDGET (login_window));
     gtk_widget_show_all (dialog);
-    center_window (GTK_WINDOW (dialog));
+    position_window (GTK_WINDOW (dialog));

     if (gtk_dialog_run (GTK_DIALOG (dialog)))
         lightdm_shutdown (NULL);
@@ -1525,6 +1535,18 @@ main (int argc, char **argv)
     /* Set the background */
     set_background (NULL);

+
+    /* Get banner position */
+    banner_x = g_key_file_get_integer (config, "greeter", "banner-x", &error);
+    if (error)
+        banner_x = -1;
+    g_clear_error (&error);
+
+    banner_y = g_key_file_get_integer (config, "greeter", "banner-y", &error);
+    if (error)
+        banner_y = -1;
+    g_clear_error (&error);
+
     /* Set GTK+ settings */
     value = g_key_file_get_value (config, "greeter", "theme-name", NULL);
     if (value)
@@ -1803,8 +1825,8 @@ main (int argc, char **argv)
     gtk_builder_connect_signals(builder, greeter);

     gtk_widget_show (GTK_WIDGET (login_window));
-    center_window (login_window);
-    g_signal_connect (GTK_WIDGET (login_window), "size-allocate",
G_CALLBACK (center_window), login_window);
+    position_window (login_window);
+    g_signal_connect (GTK_WIDGET (login_window), "size-allocate",
G_CALLBACK (position_window), login_window);

     gtk_widget_show (GTK_WIDGET (panel_window));
     GtkAllocation allocation;