Re: [PATCH] applet: position some more dialogs to the center of the screen

On Thu, 2013-03-07 at 16:17 -0600, Dan Williams wrote:
On Wed, 2013-03-06 at 12:40 -0500, Mathieu Trudel-Lapierre wrote:
 src/applet-dialogs.c | 4 ++++
 src/utils/utils.c    | 2 ++
 2 files changed, 6 insertions(+)

I agree with the goal here, but the GTK docs say:

I don't think the info dialog was getting centered though, so I've added
that to the glade XML.  Also, it does appear that some of the dialogs
were already marked center-always, probably because I (or somebody else)
didn't understand the center-always stuff originally.  So there's
precedent for your patch at least.

diff --git a/src/info.ui b/src/info.ui
index ad99750..4efdf84 100644
--- a/src/info.ui
+++ b/src/info.ui
@@ -2,6 +2,7 @@
   <object class="GtkDialog" id="info_dialog">
     <property name="border_width">5</property>
+    <property name="window_position">center</property>
     <property name="title" translatable="yes">Connection Information</property>
     <property name="resizable">False</property>
     <property name="icon_name">gtk-info</property>


"Note that using GTK_WIN_POS_CENTER_ALWAYS is almost always a bad idea.
It won't necessarily work well with all window managers or on all
windowing systems."

Comments in the GTK code indicate that CENTER_ALWAYS is really intended
for override-redirect windows, and that a simple CENTER should suffice
to center the window when it's first shown.

We already have "center" set for some windows in the glade XML; is that
not working as well as it should?


diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 53167b7..1e7359e 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -55,6 +55,7 @@ info_dialog_show_error (const char *err)
    dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
                    "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", _("Error displaying 
connection information:"), err);
+   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_present (GTK_WINDOW (dialog));
    g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
@@ -902,6 +903,7 @@ applet_info_dialog_show (NMApplet *applet)
    g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), dialog);
    g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_hide), dialog);
    gtk_widget_realize (dialog);
+   gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_present_with_time (GTK_WINDOW (dialog),
            gdk_x11_get_server_time (gtk_widget_get_window (dialog)));
@@ -981,6 +983,7 @@ applet_mobile_password_dialog_new (NMConnection *connection,
    dialog = GTK_DIALOG (gtk_dialog_new ());
    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_set_title (GTK_WINDOW (dialog), _("Mobile broadband network password"));
    w = gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
@@ -1338,6 +1341,7 @@ applet_mobile_pin_dialog_new (const char *unlock_required,
    } else
            g_assert_not_reached ();
+   gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_set_title (GTK_WINDOW (dialog), title);
    widget = GTK_WIDGET (gtk_builder_get_object (builder, "header_label"));
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 00f8596..3260c5b 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -192,6 +192,8 @@ utils_show_error_dialog (const char *title,
+   gtk_window_set_position (GTK_WINDOW (err_dialog), GTK_WIN_POS_CENTER_ALWAYS);
    if (text2)
            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog), "%s", text2);
    if (title)

networkmanager-list mailing list
networkmanager-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]