]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktoolbar.c
texthandle: Set a bigger input shape, covering the line height
[~andy/gtk] / gtk / gtktoolbar.c
index 6bef947309c5262019ad604d60cd54428800c126..e4dbfa45eb2aa79e5cf54a8f223a9e3161b264ef 100644 (file)
@@ -44,6 +44,7 @@
 #include "gtkmarshalers.h"
 #include "gtkmenu.h"
 #include "gtkorientable.h"
+#include "gtkorientableprivate.h"
 #include "gtkradiobutton.h"
 #include "gtkradiotoolbutton.h"
 #include "gtkseparatormenuitem.h"
@@ -83,8 +84,6 @@
 
 typedef struct _ToolbarContent ToolbarContent;
 
-#define DEFAULT_IPADDING    0
-
 #define DEFAULT_SPACE_SIZE  12
 #define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
 #define SPACE_LINE_DIVISION 10.0
@@ -253,7 +252,6 @@ static void       gtk_toolbar_reconfigured         (GtkToolbar          *toolbar
 
 static GtkReliefStyle       get_button_relief    (GtkToolbar *toolbar);
 static gint                 get_max_child_expand (GtkToolbar *toolbar);
-static GtkShadowType        get_shadow_type      (GtkToolbar *toolbar);
 
 /* methods on ToolbarContent 'class' */
 static ToolbarContent *toolbar_content_new_tool_item        (GtkToolbar          *toolbar,
@@ -577,13 +575,22 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                                                              DEFAULT_SPACE_SIZE,
                                                             GTK_PARAM_READABLE));
   
+  /**
+   * GtkToolbar:internal-padding:
+   *
+   * Amount of border space between the toolbar shadow and the buttons.
+   *
+   * Deprecated: 3.6: Use the standard padding CSS property
+   *   (through objects like #GtkStyleContext and #GtkCssProvider); the value
+   *   of this style property is ignored.
+   */
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_int ("internal-padding",
                                                             P_("Internal padding"),
                                                             P_("Amount of border space between the toolbar shadow and the buttons"),
                                                             0,
                                                             G_MAXINT,
-                                                             DEFAULT_IPADDING,
+                                                             0,
                                                              GTK_PARAM_READABLE));
 
   gtk_widget_class_install_style_property (widget_class,
@@ -610,6 +617,15 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                                                               GTK_TYPE_RELIEF_STYLE,
                                                               GTK_RELIEF_NONE,
                                                               GTK_PARAM_READABLE));
+  /**
+   * GtkToolbar:shadow-type:
+   *
+   * Style of bevel around the toolbar.
+   *
+   * Deprecated: 3.6: Use the standard border CSS property
+   *   (through objects like #GtkStyleContext and #GtkCssProvider); the value
+   *   of this style property is ignored.
+   */
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_enum ("shadow-type",
                                                               P_("Shadow type"),
@@ -831,7 +847,7 @@ gtk_toolbar_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, toolbar);
+  gtk_widget_register_window (widget, priv->event_window);
 }
 
 static void
@@ -842,7 +858,7 @@ gtk_toolbar_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;
     }
@@ -891,7 +907,6 @@ get_widget_padding_and_border (GtkWidget *widget,
   GtkStyleContext *context;
   GtkStateFlags state;
   GtkBorder tmp;
-  gint ipadding = 0;
 
   context = gtk_widget_get_style_context (widget);
   state = gtk_style_context_get_state (context);
@@ -899,12 +914,10 @@ get_widget_padding_and_border (GtkWidget *widget,
   gtk_style_context_get_padding (context, state, padding);
   gtk_style_context_get_border (context, state, &tmp);
 
-  gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
-
-  padding->top += tmp.top + ipadding;
-  padding->right += tmp.right + ipadding;
-  padding->bottom += tmp.bottom + ipadding;
-  padding->left += tmp.left + ipadding;
+  padding->top += tmp.top;
+  padding->right += tmp.right;
+  padding->bottom += tmp.bottom;
+  padding->left += tmp.left;
 }
 
 static void
@@ -1017,25 +1030,11 @@ gtk_toolbar_size_request (GtkWidget      *widget,
     }
 
   /* Extra spacing */
-  get_widget_padding_and_border (widget, &padding);
   border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar));
+  get_widget_padding_and_border (widget, &padding);
 
   requisition->width += 2 * border_width + padding.left + padding.right;
   requisition->height += 2 * border_width + padding.top + padding.bottom;
-
-  if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
-    {
-      GtkStyleContext *context;
-      GtkStateFlags state;
-      GtkBorder padding;
-
-      context = gtk_widget_get_style_context (widget);
-      state = gtk_widget_get_state_flags (widget);
-      gtk_style_context_get_padding (context, state, &padding);
-
-      requisition->width += padding.left + padding.right;
-      requisition->height += padding.top + padding.bottom;
-    }
   
   priv->button_maxw = max_homogeneous_child_width;
   priv->button_maxh = max_homogeneous_child_height;
@@ -1513,7 +1512,6 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   gboolean overflowing;
   gboolean size_changed;
   GtkAllocation item_area;
-  GtkShadowType shadow_type;
 
   gtk_widget_get_allocation (widget, &widget_allocation);
   size_changed = FALSE;
@@ -1542,9 +1540,6 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
 
   gtk_widget_get_preferred_size (priv->arrow_button,
                                  &arrow_requisition, NULL);
-
-  shadow_type = get_shadow_type (toolbar);
-
   get_widget_padding_and_border (widget, &padding);
 
   if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -1552,24 +1547,12 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       available_size = size = allocation->width - 2 * border_width - padding.left - padding.right;
       short_size = allocation->height - 2 * border_width - padding.top - padding.bottom;
       arrow_size = arrow_requisition.width;
-
-      if (shadow_type != GTK_SHADOW_NONE)
-        {
-          available_size -= padding.left + padding.right;
-          short_size -= padding.top + padding.bottom;
-        }
     }
   else
     {
       available_size = size = allocation->height - 2 * border_width - padding.top - padding.bottom;
       short_size = allocation->width - 2 * border_width - padding.left - padding.right;
       arrow_size = arrow_requisition.height;
-
-      if (shadow_type != GTK_SHADOW_NONE)
-        {
-          available_size -= padding.top + padding.bottom;
-          short_size -= padding.left + padding.right;
-        }
     }
 
   n_items = g_list_length (priv->content);
@@ -1686,7 +1669,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
     }
 
   /* position items */
-  pos = border_width + padding.left;
+  pos = border_width;
   for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
     {
       /* Both NORMAL and OVERFLOWN items get a position.
@@ -1695,7 +1678,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       if (new_states[i] == NORMAL || new_states[i] == OVERFLOWN)
         {
           allocations[i].x = pos;
-          allocations[i].y = border_width + padding.top;
+          allocations[i].y = border_width;
           allocations[i].height = short_size;
 
           pos += allocations[i].width;
@@ -1705,12 +1688,12 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   /* position arrow */
   if (need_arrow)
     {
-      arrow_allocation.x = available_size - border_width - padding.left - arrow_allocation.width;
-      arrow_allocation.y = border_width + padding.top;
+      arrow_allocation.x = available_size - border_width - arrow_allocation.width;
+      arrow_allocation.y = border_width;
     }
 
-  item_area.x = border_width + padding.left;
-  item_area.y = border_width + padding.top;
+  item_area.x = border_width;
+  item_area.y = border_width;
   item_area.width = available_size - (need_arrow? arrow_size : 0);
   item_area.height = short_size;
 
@@ -1739,35 +1722,18 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   /* translate the items by allocation->(x,y) */
   for (i = 0; i < n_items; ++i)
     {
-      allocations[i].x += allocation->x;
-      allocations[i].y += allocation->y;
-
-      if (shadow_type != GTK_SHADOW_NONE)
-        {
-          allocations[i].x += padding.left;
-          allocations[i].y += padding.top;
-        }
+      allocations[i].x += allocation->x + padding.left;
+      allocations[i].y += allocation->y + padding.top;
     }
 
   if (need_arrow)
     {
-      arrow_allocation.x += allocation->x;
-      arrow_allocation.y += allocation->y;
-
-      if (shadow_type != GTK_SHADOW_NONE)
-        {
-          arrow_allocation.x += padding.left;
-          arrow_allocation.y += padding.top;
-        }
+      arrow_allocation.x += allocation->x + padding.left;
+      arrow_allocation.y += allocation->y + padding.top;
     }
 
-  item_area.x += allocation->x;
-  item_area.y += allocation->y;
-  if (shadow_type != GTK_SHADOW_NONE)
-    {
-      item_area.x += padding.left;
-      item_area.y += padding.top;
-    }
+  item_area.x += allocation->x + padding.left;
+  item_area.y += allocation->y + padding.top;
 
   /* did anything change? */
   for (list = priv->content, i = 0; list != NULL; list = list->next, i++)
@@ -2126,7 +2092,7 @@ gtk_toolbar_screen_changed (GtkWidget *widget,
   if (old_settings)
     {
       g_signal_handler_disconnect (old_settings, priv->settings_connection);
-
+      priv->settings_connection = 0;
       g_object_unref (old_settings);
     }
 
@@ -2613,6 +2579,7 @@ gtk_toolbar_orientation_changed (GtkToolbar    *toolbar,
       
       gtk_toolbar_reconfigured (toolbar);
       
+      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (toolbar));
       gtk_widget_queue_resize (GTK_WIDGET (toolbar));
       g_object_notify (G_OBJECT (toolbar), "orientation");
     }
@@ -3157,6 +3124,14 @@ gtk_toolbar_dispose (GObject *object)
       priv->menu = NULL;
     }
 
+  if (priv->settings_connection > 0)
+    {
+      g_signal_handler_disconnect (priv->settings, priv->settings_connection);
+      priv->settings_connection = 0;
+    }
+
+  g_clear_object (&priv->settings);
+
  G_OBJECT_CLASS (gtk_toolbar_parent_class)->dispose (object);
 }
 
@@ -3361,18 +3336,12 @@ calculate_max_homogeneous_pixels (GtkWidget *widget)
 {
   PangoContext *context;
   PangoFontMetrics *metrics;
-  const PangoFontDescription *font_desc;
-  GtkStyleContext *style_context;
-  GtkStateFlags state;
   gint char_width;
   
   context = gtk_widget_get_pango_context (widget);
-  style_context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
-
-  font_desc = gtk_style_context_get_font (style_context, state);
 
-  metrics = pango_context_get_metrics (context, font_desc,
+  metrics = pango_context_get_metrics (context,
+                                       pango_context_get_font_description (context),
                                       pango_context_get_language (context));
   char_width = pango_font_metrics_get_approximate_char_width (metrics);
   pango_font_metrics_unref (metrics);
@@ -3674,18 +3643,6 @@ get_max_child_expand (GtkToolbar *toolbar)
   return mexpand;
 }
 
-static GtkShadowType
-get_shadow_type (GtkToolbar *toolbar)
-{
-  GtkShadowType shadow_type;
-  
-  gtk_widget_style_get (GTK_WIDGET (toolbar),
-                       "shadow-type", &shadow_type,
-                       NULL);
-  
-  return shadow_type;
-}
-
 /* GTK+ internal methods */
 
 gint