Commit 9004c8bf authored by William Jon McCann's avatar William Jon McCann Committed by Ray Strode
parent db8de4d6
......@@ -41,7 +41,7 @@ dnl ---------------------------------------------------------------------------
DBUS_GLIB_REQUIRED_VERSION=0.74
GLIB_REQUIRED_VERSION=2.27.4
GTK_REQUIRED_VERSION=2.20.0
GTK_REQUIRED_VERSION=2.91.1
PANGO_REQUIRED_VERSION=1.3.0
SCROLLKEEPER_REQUIRED_VERSION=0.1.4
GCONF_REQUIRED_VERSION=2.31.3
......@@ -86,13 +86,13 @@ AC_SUBST(XLIB_CFLAGS)
AC_SUBST(XLIB_LIBS)
PKG_CHECK_MODULES(GTK,
gtk+-2.0 >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
PKG_CHECK_MODULES(CANBERRA_GTK,
libcanberra-gtk >= $LIBCANBERRA_GTK_REQUIRED_VERSION
libcanberra-gtk3 >= $LIBCANBERRA_GTK_REQUIRED_VERSION
)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)
......@@ -120,7 +120,7 @@ AC_SUBST(UPOWER_LIBS)
PKG_CHECK_MODULES(SIMPLE_GREETER,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
gconf-2.0 >= $GCONF_REQUIRED_VERSION
fontconfig >= $FONTCONFIG_REQUIRED_VERSION
x11
......@@ -143,7 +143,7 @@ AC_SUBST(LIBXKLAVIER_LIBS)
PKG_CHECK_MODULES(SIMPLE_CHOOSER,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
gconf-2.0 >= $GCONF_REQUIRED_VERSION
)
AC_SUBST(SIMPLE_CHOOSER_CFLAGS)
......@@ -151,7 +151,7 @@ AC_SUBST(SIMPLE_CHOOSER_LIBS)
PKG_CHECK_MODULES(APPLET,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
libpanelapplet-2.0 >= $GNOME_PANEL_REQUIRED_VERSION)
AC_SUBST(APPLET_CFLAGS)
AC_SUBST(APPLET_LIBS)
......
......@@ -125,7 +125,7 @@ assistive_registry_start (void)
root = gdk_get_default_root_window ();
if ( ! AT_SPI_IOR) {
AT_SPI_IOR = XInternAtom (GDK_DISPLAY (), "AT_SPI_IOR", False);
AT_SPI_IOR = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "AT_SPI_IOR", False);
}
gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
......
......@@ -144,7 +144,6 @@ gdm_host_chooser_dialog_constructor (GType type,
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_title (GTK_WINDOW (dialog), _("Select System"));
gtk_window_set_icon_name (GTK_WINDOW (dialog), "computer");
......
......@@ -126,7 +126,7 @@ assistive_registry_start (void)
root = gdk_get_default_root_window ();
if ( ! AT_SPI_IOR) {
AT_SPI_IOR = XInternAtom (GDK_DISPLAY (), "AT_SPI_IOR", False);
AT_SPI_IOR = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "AT_SPI_IOR", False);
}
gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
......
......@@ -84,13 +84,13 @@ gdm_cell_renderer_timer_set_property (GObject *object,
}
static void
gdm_cell_renderer_timer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
gdm_cell_renderer_timer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
const GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
GdmCellRendererTimer *renderer;
......@@ -180,16 +180,15 @@ draw_timer (GdmCellRendererTimer *renderer,
static void
gdm_cell_renderer_timer_render (GtkCellRenderer *cell,
GdkWindow *window,
cairo_t *context,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState renderer_state)
{
GdmCellRendererTimer *renderer;
cairo_t *context;
GtkStateType widget_state;
gfloat xpad, ypad;
renderer = GDM_CELL_RENDERER_TIMER (cell);
......@@ -197,15 +196,7 @@ gdm_cell_renderer_timer_render (GtkCellRenderer *cell,
return;
}
context = gdk_cairo_create (GDK_DRAWABLE (window));
if (expose_area != NULL) {
gdk_cairo_rectangle (context, expose_area);
cairo_clip (context);
}
gfloat xpad, ypad;
gtk_cell_renderer_get_alignment (cell, &xpad, &ypad);
gtk_cell_renderer_get_alignment (cell, &xpad, &ypad);
cairo_translate (context,
cell_area->x + xpad,
......@@ -228,8 +219,6 @@ gdm_cell_renderer_timer_render (GtkCellRenderer *cell,
&gtk_widget_get_style (widget)->text_aa[widget_state],
&gtk_widget_get_style (widget)->base[widget_state],
cell_area->width, cell_area->height);
cairo_destroy (context);
}
static void
......
......@@ -196,18 +196,31 @@ remove_timeout (GdmClockWidget *clock)
}
static void
gdm_clock_widget_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gdm_clock_widget_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
if (GTK_WIDGET_CLASS (gdm_clock_widget_parent_class)->get_preferred_width) {
GTK_WIDGET_CLASS (gdm_clock_widget_parent_class)->get_preferred_width (widget, minimum_size, natural_size);
}
}
static void
gdm_clock_widget_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
PangoFontMetrics *metrics;
PangoContext *context;
int ascent;
int descent;
int padding;
int min_size;
int nat_size;
if (GTK_WIDGET_CLASS (gdm_clock_widget_parent_class)->size_request) {
GTK_WIDGET_CLASS (gdm_clock_widget_parent_class)->size_request (widget, requisition);
}
min_size = 0;
nat_size = 0;
gtk_widget_ensure_style (widget);
context = gtk_widget_get_pango_context (widget);
......@@ -218,7 +231,13 @@ gdm_clock_widget_size_request (GtkWidget *widget,
ascent = pango_font_metrics_get_ascent (metrics);
descent = pango_font_metrics_get_descent (metrics);
padding = PANGO_PIXELS (ascent + descent) / 2.0;
requisition->height += padding;
min_size += padding;
nat_size += padding;
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
*natural_size = nat_size;
pango_font_metrics_unref (metrics);
}
......@@ -233,7 +252,8 @@ gdm_clock_widget_class_init (GdmClockWidgetClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gdm_clock_widget_finalize;
widget_class->size_request = gdm_clock_widget_size_request;
widget_class->get_preferred_width = gdm_clock_widget_get_preferred_width;
widget_class->get_preferred_height = gdm_clock_widget_get_preferred_height;
g_type_class_add_private (klass, sizeof (GdmClockWidgetPrivate));
}
......
......@@ -624,7 +624,6 @@ reset_dialog (GdmGreeterLoginWindow *login_window,
{
GtkWidget *entry;
GtkWidget *label;
guint mode;
g_debug ("GdmGreeterLoginWindow: Resetting dialog to mode %u", dialog_mode);
set_busy (login_window);
......@@ -1031,7 +1030,6 @@ on_user_chosen (GdmUserChooserWidget *user_chooser,
GdmGreeterLoginWindow *login_window)
{
char *user_name;
guint mode;
user_name = gdm_user_chooser_widget_get_chosen_user_name (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser));
g_debug ("GdmGreeterLoginWindow: user chosen '%s'", user_name);
......@@ -1330,7 +1328,7 @@ gdm_greeter_login_window_key_press_event (GtkWidget *widget,
login_window = GDM_GREETER_LOGIN_WINDOW (widget);
if (event->keyval == GDK_Escape) {
if (event->keyval == GDK_KEY_Escape) {
if (login_window->priv->dialog_mode == MODE_AUTHENTICATION
|| login_window->priv->dialog_mode == MODE_TIMED_LOGIN) {
do_cancel (GDM_GREETER_LOGIN_WINDOW (widget));
......@@ -1341,45 +1339,92 @@ gdm_greeter_login_window_key_press_event (GtkWidget *widget,
}
static void
gdm_greeter_login_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gdm_greeter_login_window_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
int monitor;
GdkScreen *screen;
GtkRequisition child_requisition;
GdkRectangle area;
GtkAllocation widget_allocation;
int min_size;
int nat_size;
guint border_width;
if (GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_request) {
GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_request (widget, requisition);
}
min_size = 0;
nat_size = 0;
if (!gtk_widget_get_realized (widget)) {
return;
goto out;
}
gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)),
&min_size,
&nat_size);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_size += 2 * border_width;
nat_size += 2 * border_width;
/* Make width be at least 33% screen width */
screen = gtk_widget_get_screen (widget);
monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
gdk_screen_get_monitor_geometry (screen, monitor, &area);
min_size = MAX (min_size, .33 * area.width);
nat_size = MAX (nat_size, .33 * area.width);
gtk_widget_get_child_requisition (gtk_bin_get_child (GTK_BIN (widget)), &child_requisition);
*requisition = child_requisition;
/* Don't ever shrink window width */
gtk_widget_get_allocation (widget, &widget_allocation);
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->width += 2 * border_width;
requisition->height += 2 * border_width;
min_size = MAX (min_size, widget_allocation.width);
nat_size = MAX (nat_size, widget_allocation.width);
/* Make width be at least 33% screen width
* and height be at most 80% of screen height
*/
requisition->width = MAX (requisition->width, .33 * area.width);
requisition->height = MIN (requisition->height, .80 * area.height);
out:
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
*natural_size = nat_size;
}
/* Don't ever shrink window width
*/
GtkAllocation widget_allocation;
gtk_widget_get_allocation (widget, &widget_allocation);
static void
gdm_greeter_login_window_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
int monitor;
GdkScreen *screen;
GdkRectangle area;
int min_size;
int nat_size;
guint border_width;
min_size = 0;
nat_size = 0;
if (!gtk_widget_get_realized (widget)) {
goto out;
}
requisition->width = MAX (requisition->width, widget_allocation.width);
gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)),
&min_size,
&nat_size);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_size += 2 * border_width;
nat_size += 2 * border_width;
/* Make height be at most 80% of screen height */
screen = gtk_widget_get_screen (widget);
monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
gdk_screen_get_monitor_geometry (screen, monitor, &area);
min_size = MIN (min_size, .8 * area.height);
nat_size = MIN (nat_size, .8 * area.height);
out:
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
*natural_size = nat_size;
}
static void
......@@ -1471,7 +1516,8 @@ gdm_greeter_login_window_class_init (GdmGreeterLoginWindowClass *klass)
object_class->finalize = gdm_greeter_login_window_finalize;
widget_class->key_press_event = gdm_greeter_login_window_key_press_event;
widget_class->size_request = gdm_greeter_login_window_size_request;
widget_class->get_preferred_width = gdm_greeter_login_window_get_preferred_width;
widget_class->get_preferred_height = gdm_greeter_login_window_get_preferred_height;
signals [BEGIN_AUTO_LOGIN] =
g_signal_new ("begin-auto-login",
......
......@@ -79,6 +79,7 @@ struct GdmGreeterPanelPrivate
GtkWidget *option_hbox;
GtkWidget *hostname_label;
GtkWidget *clock;
NaTray *tray;
GtkWidget *shutdown_button;
GtkWidget *shutdown_menu;
GtkWidget *language_option_widget;
......@@ -238,7 +239,7 @@ gdm_greeter_panel_real_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gdm_greeter_panel_parent_class)->realize (widget);
}
gdk_window_set_geometry_hints (widget->window, NULL, GDK_HINT_POS);
gdk_window_set_geometry_hints (gtk_widget_get_window (widget), NULL, GDK_HINT_POS);
gdm_greeter_panel_move_resize_window (GDM_GREETER_PANEL (widget), TRUE, TRUE);
......@@ -295,35 +296,30 @@ set_struts (GdmGreeterPanel *panel,
#endif
gdk_error_trap_push ();
if (gtk_widget_get_window (GTK_WIDGET (panel)) != NULL) {
gdk_property_change (gtk_widget_get_window (GTK_WIDGET (panel)),
gdk_atom_intern ("_NET_WM_STRUT_PARTIAL", FALSE),
gdk_atom_intern ("CARDINAL", FALSE),
32,
GDK_PROP_MODE_REPLACE,
(guchar *) &data,
12);
gdk_property_change (gtk_widget_get_window (GTK_WIDGET (panel)),
gdk_atom_intern ("_NET_WM_STRUT", FALSE),
gdk_atom_intern ("CARDINAL", FALSE),
32,
GDK_PROP_MODE_REPLACE,
(guchar *) &data,
4);
}
gdk_property_change (gtk_widget_get_window (GTK_WIDGET (panel)),
gdk_atom_intern ("_NET_WM_STRUT_PARTIAL", FALSE),
gdk_atom_intern ("CARDINAL", FALSE),
32,
GDK_PROP_MODE_REPLACE,
(guchar *) &data,
12);
gdk_property_change (gtk_widget_get_window (GTK_WIDGET (panel)),
gdk_atom_intern ("_NET_WM_STRUT", FALSE),
gdk_atom_intern ("CARDINAL", FALSE),
32,
GDK_PROP_MODE_REPLACE,
(guchar *) &data,
4);
gdk_error_trap_pop ();
gdk_error_trap_pop_ignored ();
}
static void
update_struts (GdmGreeterPanel *panel)
{
GdkRectangle geometry;
gdk_screen_get_monitor_geometry (gtk_window_get_screen (GTK_WINDOW (panel)),
panel->priv->monitor,
&geometry);
/* FIXME: assumes only one panel */
set_struts (panel,
panel->priv->geometry.x,
......@@ -360,32 +356,50 @@ update_geometry (GdmGreeterPanel *panel,
}
static void
gdm_greeter_panel_real_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gdm_greeter_panel_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
gint *minimum_size,
gint *natural_size)
{
GdmGreeterPanel *panel;
GtkBin *bin;
GtkWidget *child;
GdkRectangle old_geometry;
int position_changed = FALSE;
int size_changed = FALSE;
GtkRequisition minimum_req, natural_req;
panel = GDM_GREETER_PANEL (widget);
bin = GTK_BIN (widget);
child = gtk_bin_get_child (bin);
minimum_req.width = 0;
minimum_req.height = 0;
natural_req.width = minimum_req.width;
natural_req.height = minimum_req.height;
if (child != NULL && gtk_widget_get_visible (child)) {
int min_child_width, nat_child_width;
int min_child_height, nat_child_height;
gtk_widget_get_preferred_width (gtk_bin_get_child (bin),
&min_child_width,
&nat_child_width);
gtk_widget_get_preferred_height (gtk_bin_get_child (bin),
&min_child_height,
&nat_child_height);
minimum_req.width += min_child_width;
natural_req.width += nat_child_width;
minimum_req.height += min_child_height;
natural_req.height += nat_child_height;
}
old_geometry = panel->priv->geometry;
update_geometry (panel, &natural_req);
update_geometry (panel, requisition);
requisition->width = panel->priv->geometry.width;
requisition->height = panel->priv->geometry.height;
if (gtk_bin_get_child (bin) && gtk_widget_get_visible (gtk_bin_get_child (bin))) {
gtk_widget_size_request (gtk_bin_get_child (bin), requisition);
}
if (! gtk_widget_get_realized (widget)) {
return;
}
if (!gtk_widget_get_realized (widget))
goto out;
if (old_geometry.width != panel->priv->geometry.width ||
old_geometry.height != panel->priv->geometry.height) {
......@@ -398,6 +412,36 @@ gdm_greeter_panel_real_size_request (GtkWidget *widget,
}
gdm_greeter_panel_move_resize_window (panel, position_changed, size_changed);
out:
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
if (minimum_size)
*minimum_size = panel->priv->geometry.width;
if (natural_size)
*natural_size = panel->priv->geometry.width;
} else {
if (minimum_size)
*minimum_size = panel->priv->geometry.height;
if (natural_size)
*natural_size = panel->priv->geometry.height;
}
}
static void
gdm_greeter_panel_real_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gdm_greeter_panel_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
gdm_greeter_panel_real_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gdm_greeter_panel_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
......@@ -722,7 +766,6 @@ on_shutdown_menu_deactivate (GdmGreeterPanel *panel)
static void
setup_panel (GdmGreeterPanel *panel)
{
NaTray *tray;
GtkWidget *spacer;
int padding;
......@@ -846,13 +889,13 @@ setup_panel (GdmGreeterPanel *panel)
GTK_WIDGET (panel->priv->clock), FALSE, FALSE, 6);
gtk_widget_show (panel->priv->clock);
tray = na_tray_new_for_screen (gtk_window_get_screen (GTK_WINDOW (panel)),
GTK_ORIENTATION_HORIZONTAL);
panel->priv->tray = na_tray_new_for_screen (gtk_window_get_screen (GTK_WINDOW (panel)),
GTK_ORIENTATION_HORIZONTAL);
padding = gconf_client_get_int (panel->priv->client, KEY_NOTIFICATION_AREA_PADDING, NULL);
na_tray_set_padding (tray, padding);
gtk_box_pack_end (GTK_BOX (panel->priv->hbox), GTK_WIDGET (tray), FALSE, FALSE, 6);
gtk_widget_show (GTK_WIDGET (tray));
na_tray_set_padding (panel->priv->tray, padding);
gtk_box_pack_end (GTK_BOX (panel->priv->hbox), GTK_WIDGET (panel->priv->tray), FALSE, FALSE, 6);
gtk_widget_show (GTK_WIDGET (panel->priv->tray));
gdm_greeter_panel_hide_user_options (panel);
panel->priv->progress = 0.0;
......@@ -928,7 +971,8 @@ gdm_greeter_panel_class_init (GdmGreeterPanelClass *klass)
widget_class->realize = gdm_greeter_panel_real_realize;
widget_class->unrealize = gdm_greeter_panel_real_unrealize;
widget_class->size_request = gdm_greeter_panel_real_size_request;
widget_class->get_preferred_width = gdm_greeter_panel_real_get_preferred_width;
widget_class->get_preferred_height = gdm_greeter_panel_real_get_preferred_height;
widget_class->show = gdm_greeter_panel_real_show;
widget_class->hide = gdm_greeter_panel_real_hide;
......
......@@ -314,8 +314,8 @@ get_tallest_monitor_at_point (GdkScreen *screen,
int x,
int y)
{
GdkRectangle area;
GdkRegion *region;
cairo_rectangle_int_t area;
cairo_region_t *region;
int i;
int monitor;
int n_monitors;
......@@ -326,15 +326,15 @@ get_tallest_monitor_at_point (GdkScreen *screen,
monitor = -1;
for (i = 0; i < n_monitors; i++) {
gdk_screen_get_monitor_geometry (screen, i, &area);
region = gdk_region_rectangle (&area);
region = cairo_region_create_rectangle (&area);
if (gdk_region_point_in (region, x, y)) {
if (cairo_region_contains_point (region, x, y)) {
if (area.height > tallest_height) {
monitor = i;
tallest_height = area.height;
}
}
gdk_region_destroy (region);
cairo_region_destroy (region);
}
if (monitor == -1) {
......
......@@ -72,28 +72,79 @@ gdm_language_chooser_dialog_set_current_language_name (GdmLanguageChooserDialog
}
static void
gdm_language_chooser_dialog_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gdm_language_chooser_dialog_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
int screen_w;
int screen_h;
GtkRequisition child_requisition;
GtkWidget *child;
int min_size, nat_size;
int screen_w;
if (GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->size_request) {
GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->size_request (widget, requisition);
/* FIXME: this should use monitor size */
screen_w = gdk_screen_get_width (gtk_widget_get_screen (widget));
child = gtk_bin_get_child (GTK_BIN (widget));
min_size = 0;
nat_size = 0;
if (GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->get_preferred_width) {
GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->get_preferred_width (widget, &min_size, &nat_size);
}
screen_w = gdk_screen_get_width (gtk_widget_get_screen (widget));
screen_h = gdk_screen_get_height (gtk_widget_get_screen (widget));
if (child && gtk_widget_get_visible (child)) {
gtk_widget_get_preferred_width (child,
&min_size,
&nat_size);
}
min_size += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
min_size = MIN (min_size, .50 * screen_w);
nat_size += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
nat_size = MIN (nat_size, .50 * screen_w);
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
*natural_size = nat_size;
}
gtk_widget_get_child_requisition (gtk_bin_get_child (GTK_BIN (widget)), &child_requisition);
*requisition = child_requisition;
static void
gdm_language_chooser_dialog_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
GtkWidget *child;
int min_size, nat_size;
int screen_w;
/* FIXME: this should use monitor size */
screen_w = gdk_screen_get_height (gtk_widget_get_screen (widget));
child = gtk_bin_get_child (GTK_BIN (widget));
min_size = 0;
nat_size = 0;
if (GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->get_preferred_height) {
GTK_WIDGET_CLASS (gdm_language_chooser_dialog_parent_class)->get_preferred_height (widget, &min_size, &nat_size);
}
if (child && gtk_widget_get_visible (child)) {
gtk_widget_get_preferred_height (child,
&min_size,
&nat_size);
}
requisition->width += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->height += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
min_size += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
min_size = MIN (min_size, .50 * screen_w);
nat_size += 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
nat_size = MIN (nat_size, .50 * screen_w);
requisition->width = MIN (requisition->width, .50 * screen_w);
requisition->height = MIN (requisition->height, .80 * screen_h);
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
*natural_size = nat_size;
}
static void
......@@ -126,7 +177,8 @@ gdm_language_chooser_dialog_class_init (GdmLanguageChooserDialogClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gdm_language_chooser_dialog_finalize;
widget_class->size_request = gdm_language_chooser_dialog_size_request;
widget_class->get_preferred_width = gdm_language_chooser_dialog_get_preferred_width;
widget_class->get_preferred_height = gdm_language_chooser_dialog_get_preferred_height;
widget_class->realize = gdm_language_chooser_dialog_realize;
g_type_class_add_private (klass, sizeof (GdmLanguageChooserDialogPrivate));
......@@ -168,7 +220,6 @@ gdm_language_chooser_dialog_init (GdmLanguageChooserDialog *dialog)
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
gtk_container_set_border_width (GTK_CONTAINER (dialog->priv->chooser_widget), 5);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
......
......@@ -72,28 +72,79 @@ gdm_layout_chooser_dialog_set_current_layout_name (GdmLayoutChooserDialog *dialo
}
static void
gdm_layout_chooser_dialog_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gdm_layout_chooser_dialog_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size