Changeset View
Changeset View
Standalone View
Standalone View
gtk+-2/pinentry-gtk-2.c
Context not available. | |||||
return button; | return button; | ||||
} | } | ||||
static void | |||||
move_window_to_active_monitor (GtkWindow *wnd) | |||||
{ | |||||
GdkScreen *scr; | |||||
GdkWindow *active_wnd; | |||||
GdkRectangle rect; | |||||
int monitor, width, height; | |||||
scr = gdk_screen_get_default (); | |||||
/* No need to bother if there's is only one monitor. */ | |||||
if (gdk_screen_get_n_monitors (scr) == 1) | |||||
return; | |||||
active_wnd = gdk_screen_get_active_window (scr); | |||||
if (active_wnd) | |||||
{ | |||||
monitor = gdk_screen_get_monitor_at_window (scr, active_wnd); | |||||
gdk_screen_get_monitor_geometry (scr, monitor, &rect); | |||||
/* We should use GDK_GRAVITY_CENTER so that we do not have | |||||
* to care about the window's size, but I could not make it | |||||
* to work... */ | |||||
gtk_window_get_size (wnd, &width, &height); | |||||
gtk_window_move (wnd, | |||||
rect.x + rect.width / 2 - width / 2, | |||||
rect.y + rect.height / 2 - height / 2); | |||||
g_object_unref (active_wnd); | |||||
} | |||||
} | |||||
static GtkWidget * | static GtkWidget * | ||||
create_window (pinentry_t ctx) | create_window (pinentry_t ctx) | ||||
Context not available. | |||||
gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER); | gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER); | ||||
gtk_window_set_keep_above (GTK_WINDOW (win), TRUE); | gtk_window_set_keep_above (GTK_WINDOW (win), TRUE); | ||||
gtk_widget_show_all (win); | gtk_widget_show_all (win); | ||||
move_window_to_active_monitor (GTK_WINDOW (win)); | |||||
gtk_window_present (GTK_WINDOW (win)); /* Make sure it has the focus. */ | gtk_window_present (GTK_WINDOW (win)); /* Make sure it has the focus. */ | ||||
if (pinentry->timeout > 0) | if (pinentry->timeout > 0) | ||||
Context not available. |