shell: resize the window to the size of the panel being opened

Resize the shell window when a panel is activated so that it is at the
natural size of the panel.
This commit is contained in:
Thomas Wood 2010-07-14 16:22:06 +01:00
parent ce2f25082a
commit a1bf960a75
2 changed files with 32 additions and 4 deletions

View file

@ -72,6 +72,8 @@ struct _GnomeControlCenterPrivate
gchar *default_window_title;
gchar *default_window_icon;
gint overview_width, overview_height;
};
@ -119,7 +121,8 @@ activate_panel (GnomeControlCenter *shell,
{
GtkWidget *panel;
GtkWidget *box;
gint i;
gint i, old_page;
GtkRequisition min, nat;
/* create the panel plugin */
panel = g_object_new (panel_type, "shell", shell, NULL);
@ -129,9 +132,22 @@ activate_panel (GnomeControlCenter *shell,
gtk_container_add (GTK_CONTAINER (box), panel);
/* switch to the new panel */
old_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
/* store the old size */
if (old_page == OVERVIEW_PAGE)
{
GtkAllocation alloc;
gtk_widget_get_allocation (priv->window, &alloc);
priv->overview_width = alloc.width;
priv->overview_height = alloc.height;
}
i = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), box,
NULL);
/* switch to the new panel */
gtk_widget_show (box);
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
@ -140,6 +156,12 @@ activate_panel (GnomeControlCenter *shell,
gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name);
gtk_widget_show (panel);
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->window), &min,
&nat);
/* resize to the preferred size of the panel */
gtk_window_resize (GTK_WINDOW (priv->window), nat.width, nat.height);
return;
}
}
@ -200,6 +222,11 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
gtk_window_set_title (GTK_WINDOW (priv->window), priv->default_window_title);
gtk_window_set_icon_name (GTK_WINDOW (priv->window),
priv->default_window_icon);
/* resize back to the original overview size */
if (priv->overview_width > 0 && priv->overview_height > 0)
gtk_window_resize (GTK_WINDOW (priv->window), priv->overview_width,
priv->overview_height);
}

View file

@ -3,9 +3,10 @@
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="main-window">
<property name="width_request">750</property>
<property name="height_request">500</property>
<property name="title" translatable="yes">System Settings</property>
<property name="default_width">800</property>
<property name="default_height">500</property>
<property name="resizable">False</property>
<property name="icon_name">gnome-control-center</property>
<child>
<object class="GtkVBox" id="vbox1">