]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkoffscreenwindow.c
Drop the Motif DND protocol
[~andy/gtk] / gtk / gtkoffscreenwindow.c
index ee37a9ae1dbea272ec7feb1f59e6c23f77581dc4..8e9f23f02ce997649891ec1aa933c16e88b80851 100644 (file)
@@ -10,9 +10,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors: Cody Russell <crussell@canonical.com>
  *          Alexander Larsson <alexl@redhat.com>
@@ -21,7 +19,8 @@
 #include "config.h"
 
 #include "gtkoffscreenwindow.h"
-
+#include "gtkwidgetprivate.h"
+#include "gtkcontainerprivate.h"
 #include "gtkprivate.h"
 
 /**
 G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW);
 
 static void
-gtk_offscreen_window_size_request (GtkWidget *widget,
-                                   GtkRequisition *requisition)
+gtk_offscreen_window_get_preferred_width (GtkWidget *widget,
+                                         gint      *minimum,
+                                         gint      *natural)
 {
   GtkBin *bin = GTK_BIN (widget);
   GtkWidget *child;
   gint border_width;
-  gint default_width, default_height;
+  gint default_width;
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-  requisition->width = border_width * 2;
-  requisition->height = border_width * 2;
+  *minimum = border_width * 2;
+  *natural = border_width * 2;
 
   child = gtk_bin_get_child (bin);
 
   if (child != NULL && gtk_widget_get_visible (child))
     {
-      GtkRequisition child_req;
+      gint child_min, child_nat;
 
-      gtk_widget_get_preferred_size (child, &child_req, NULL);
+      gtk_widget_get_preferred_width (child, &child_min, &child_nat);
 
-      requisition->width += child_req.width;
-      requisition->height += child_req.height;
+      *minimum += child_min;
+      *natural += child_nat;
     }
 
   gtk_window_get_default_size (GTK_WINDOW (widget),
-                               &default_width, &default_height);
-  if (default_width > 0)
-    requisition->width = default_width;
+                               &default_width, NULL);
 
-  if (default_height > 0)
-    requisition->height = default_height;
+  *minimum = MAX (*minimum, default_width);
+  *natural = MAX (*natural, default_width);
+}
+
+static void
+gtk_offscreen_window_get_preferred_height (GtkWidget *widget,
+                                          gint      *minimum,
+                                          gint      *natural)
+{
+  GtkBin *bin = GTK_BIN (widget);
+  GtkWidget *child;
+  gint border_width;
+  gint default_height;
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  *minimum = border_width * 2;
+  *natural = border_width * 2;
+
+  child = gtk_bin_get_child (bin);
+
+  if (child != NULL && gtk_widget_get_visible (child))
+    {
+      gint child_min, child_nat;
+
+      gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+      *minimum += child_min;
+      *natural += child_nat;
+    }
+
+  gtk_window_get_default_size (GTK_WINDOW (widget),
+                               NULL, &default_height);
+
+  *minimum = MAX (*minimum, default_height);
+  *natural = MAX (*natural, default_height);
 }
 
 static void
@@ -130,14 +162,11 @@ gtk_offscreen_window_realize (GtkWidget *widget)
   GdkWindow *window;
   GdkWindowAttr attributes;
   gint attributes_mask;
-  gint border_width;
 
   bin = GTK_BIN (widget);
 
   gtk_widget_set_realized (widget, TRUE);
 
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
   gtk_widget_get_allocation (widget, &allocation);
 
   attributes.x = allocation.x;
@@ -154,15 +183,14 @@ gtk_offscreen_window_realize (GtkWidget *widget)
   window = gdk_window_new (gtk_widget_get_parent_window (widget),
                            &attributes, attributes_mask);
   gtk_widget_set_window (widget, window);
-  gdk_window_set_user_data (window, widget);
+  gtk_widget_register_window (widget, window);
 
   child = gtk_bin_get_child (bin);
   if (child)
     gtk_widget_set_parent_window (child, window);
 
-  gtk_widget_style_attach (widget);
-  gtk_style_set_background (gtk_widget_get_style (widget),
-                            window, GTK_STATE_NORMAL);
+  gtk_style_context_set_background (gtk_widget_get_style_context (widget),
+                                    window);
 }
 
 static void
@@ -192,13 +220,10 @@ static void
 gtk_offscreen_window_show (GtkWidget *widget)
 {
   gboolean need_resize;
-  GtkContainer *container;
 
   _gtk_widget_set_visible_flag (widget, TRUE);
 
-  container = GTK_CONTAINER (widget);
-  need_resize = _gtk_container_get_need_resize (container) || !gtk_widget_get_realized (widget);
-  _gtk_container_set_need_resize (container, FALSE);
+  need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
 
   if (need_resize)
     gtk_offscreen_window_resize (widget);
@@ -238,7 +263,8 @@ gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class)
   widget_class->realize = gtk_offscreen_window_realize;
   widget_class->show = gtk_offscreen_window_show;
   widget_class->hide = gtk_offscreen_window_hide;
-  widget_class->size_request = gtk_offscreen_window_size_request;
+  widget_class->get_preferred_width = gtk_offscreen_window_get_preferred_width;
+  widget_class->get_preferred_height = gtk_offscreen_window_get_preferred_height;
   widget_class->size_allocate = gtk_offscreen_window_size_allocate;
 
   container_class->check_resize = gtk_offscreen_window_check_resize;