]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkseparatortoolitem.c
filechooserbutton: Duh, remove all the timeouts after tests
[~andy/gtk] / gtk / gtkseparatortoolitem.c
index 139cd25c1bfe1d8e3371e6412de3699ca9009233..33a003a8ef878ec11b98689969b6d4911747e1c9 100644 (file)
@@ -14,9 +14,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/>.
  */
 
 #include "config.h"
@@ -33,7 +31,7 @@
  * @Title: GtkSeparatorToolItem
  * @See_also: #GtkToolbar, #GtkRadioToolButton
  *
- * A #GtkSeparatorItem is a #GtkToolItem that separates groups of other
+ * A #GtkSeparatorToolItem is a #GtkToolItem that separates groups of other
  * #GtkToolItems. Depending on the theme, a #GtkSeparatorToolItem will
  * often look like a vertical line on horizontally docked toolbars.
  *
@@ -66,12 +64,16 @@ static void     gtk_separator_tool_item_get_property      (GObject
                                                            guint                      prop_id,
                                                            GValue                    *value,
                                                            GParamSpec                *pspec);
-static void     gtk_separator_tool_item_size_request      (GtkWidget                 *widget,
-                                                           GtkRequisition            *requisition);
+static void     gtk_separator_tool_item_get_preferred_width (GtkWidget               *widget,
+                                                           gint                      *minimum,
+                                                           gint                      *natural);
+static void     gtk_separator_tool_item_get_preferred_height (GtkWidget              *widget,
+                                                           gint                      *minimum,
+                                                           gint                      *natural);
 static void     gtk_separator_tool_item_size_allocate     (GtkWidget                 *widget,
                                                            GtkAllocation             *allocation);
-static gboolean gtk_separator_tool_item_expose            (GtkWidget                 *widget,
-                                                           GdkEventExpose            *event);
+static gboolean gtk_separator_tool_item_draw              (GtkWidget                 *widget,
+                                                           cairo_t                   *cr);
 static void     gtk_separator_tool_item_add               (GtkContainer              *container,
                                                            GtkWidget                 *child);
 static gint     get_space_size                            (GtkToolItem               *tool_item);
@@ -118,9 +120,10 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
 
   object_class->set_property = gtk_separator_tool_item_set_property;
   object_class->get_property = gtk_separator_tool_item_get_property;
-  widget_class->size_request = gtk_separator_tool_item_size_request;
+  widget_class->get_preferred_width = gtk_separator_tool_item_get_preferred_width;
+  widget_class->get_preferred_height = gtk_separator_tool_item_get_preferred_height;
   widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
-  widget_class->expose_event = gtk_separator_tool_item_expose;
+  widget_class->draw = gtk_separator_tool_item_draw;
   widget_class->realize = gtk_separator_tool_item_realize;
   widget_class->unrealize = gtk_separator_tool_item_unrealize;
   widget_class->map = gtk_separator_tool_item_map;
@@ -147,12 +150,17 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
 static void
 gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
 {
+  GtkStyleContext *context;
+
   separator_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (separator_item,
                                                       GTK_TYPE_SEPARATOR_TOOL_ITEM,
                                                       GtkSeparatorToolItemPrivate);
   separator_item->priv->draw = TRUE;
 
   gtk_widget_set_has_window (GTK_WIDGET (separator_item), FALSE);
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (separator_item));
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
 }
 
 static void
@@ -213,22 +221,37 @@ gtk_separator_tool_item_get_property (GObject      *object,
 }
 
 static void
-gtk_separator_tool_item_size_request (GtkWidget      *widget,
-                                      GtkRequisition *requisition)
+gtk_separator_tool_item_get_preferred_size (GtkWidget      *widget,
+                                            GtkOrientation  orientation,
+                                            gint           *minimum,
+                                            gint           *natural)
 {
-  GtkToolItem *item = GTK_TOOL_ITEM (widget);
-  GtkOrientation orientation = gtk_tool_item_get_orientation (item);
-  
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-      requisition->width = get_space_size (item);
-      requisition->height = 1;
-    }
+  if (gtk_tool_item_get_orientation (GTK_TOOL_ITEM (widget)) == orientation)
+    *minimum = *natural = get_space_size (GTK_TOOL_ITEM (widget));
   else
-    {
-      requisition->height = get_space_size (item);
-      requisition->width = 1;
-    }
+    *minimum = *natural = 1;
+}
+
+static void
+gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
+                                             gint      *minimum,
+                                             gint      *natural)
+{
+  gtk_separator_tool_item_get_preferred_size (widget,
+                                              GTK_ORIENTATION_HORIZONTAL,
+                                              minimum,
+                                              natural);
+}
+
+static void
+gtk_separator_tool_item_get_preferred_height (GtkWidget *widget,
+                                              gint      *minimum,
+                                              gint      *natural)
+{
+  gtk_separator_tool_item_get_preferred_size (widget,
+                                              GTK_ORIENTATION_VERTICAL,
+                                              minimum,
+                                              natural);
 }
 
 static void
@@ -281,9 +304,7 @@ gtk_separator_tool_item_realize (GtkWidget *widget)
 
   priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
                                        &attributes, attributes_mask);
-  gdk_window_set_user_data (priv->event_window, widget);
-
-  gtk_widget_style_attach (widget);
+  gtk_widget_register_window (widget, priv->event_window);
 }
 
 static void
@@ -294,7 +315,7 @@ gtk_separator_tool_item_unrealize (GtkWidget *widget)
 
   if (priv->event_window)
     {
-      gdk_window_set_user_data (priv->event_window, NULL);
+      gtk_widget_unregister_window (widget, priv->event_window);
       gdk_window_destroy (priv->event_window);
       priv->event_window = NULL;
     }
@@ -340,8 +361,8 @@ gtk_separator_tool_item_button_event (GtkWidget      *widget,
 }
 
 static gboolean
-gtk_separator_tool_item_expose (GtkWidget      *widget,
-                                GdkEventExpose *event)
+gtk_separator_tool_item_draw (GtkWidget *widget,
+                              cairo_t   *cr)
 {
   GtkAllocation allocation;
   GtkToolbar *toolbar = NULL;
@@ -356,8 +377,7 @@ gtk_separator_tool_item_expose (GtkWidget      *widget,
         toolbar = GTK_TOOLBAR (parent);
 
       gtk_widget_get_allocation (widget, &allocation);
-      _gtk_toolbar_paint_space_line (widget, toolbar,
-                                     &(event->area), &allocation);
+      _gtk_toolbar_paint_space_line (widget, toolbar, cr);
     }
 
   return FALSE;