[gtk+/wip/baedert/box] widget: Remove cursor-aspect-ratio/window-dragging style properties



commit dd8f415f06a7772e2e4a05241588fe05b9ee7766
Author: Timm Bäder <mail baedert org>
Date:   Wed Oct 5 17:23:29 2016 +0200

    widget: Remove cursor-aspect-ratio/window-dragging style properties
    
    And replaces its usages in GtkTextView/GtkStyleContext with a hard-coded
    0.04 which was the default value for cursor-aspect-ratio.  Also remove
    the public gtk_draw_insertion_cursor which used draw_insertion_cursor
    which in turn looked up cursor-aspect-ratio

 docs/reference/gtk/gtk3-sections.txt |    1 -
 gtk/gtkstylecontext.c                |   49 +--------------------------------
 gtk/gtkstylecontext.h                |    7 -----
 gtk/gtkwidget.c                      |    7 -----
 gtk/gtkwindow.c                      |   11 +++----
 testsuite/gtk/cssprovider.c          |    8 +++---
 6 files changed, 11 insertions(+), 72 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 1cb4c5a..6a9ab22 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6137,7 +6137,6 @@ gtk_paint_vline
 gtk_paint_expander
 gtk_paint_layout
 gtk_paint_resize_grip
-gtk_draw_insertion_cursor
 
 <SUBSECTION>
 GtkRcProperty
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 03a16aa..b98a8d8 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -123,6 +123,7 @@
  * %GTK_STYLE_PROVIDER_PRIORITY_USER priority.
  */
 
+#define CURSOR_ASPECT_RATIO (0.04)
 typedef struct PropertyValue PropertyValue;
 
 struct PropertyValue
@@ -2810,7 +2811,6 @@ draw_insertion_cursor (GtkStyleContext *context,
 {
   GdkRGBA primary_color;
   GdkRGBA secondary_color;
-  gfloat cursor_aspect_ratio;
   gint stem_width;
   gint offset;
 
@@ -2824,11 +2824,7 @@ draw_insertion_cursor (GtkStyleContext *context,
    * propagate the changes to gtktextview.c:text_window_invalidate_cursors().
    */
 
-  gtk_style_context_get_style (context,
-                               "cursor-aspect-ratio", &cursor_aspect_ratio,
-                               NULL);
-
-  stem_width = height * cursor_aspect_ratio + 1;
+  stem_width = height * CURSOR_ASPECT_RATIO + 1;
 
   /* put (stem_width % 2) on the proper side of the cursor */
   if (direction == PANGO_DIRECTION_LTR)
@@ -2961,47 +2957,6 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
 }
 
 /**
- * gtk_draw_insertion_cursor:
- * @widget:  a #GtkWidget
- * @cr: cairo context to draw to
- * @location: location where to draw the cursor (@location->width is ignored)
- * @is_primary: if the cursor should be the primary cursor color.
- * @direction: whether the cursor is left-to-right or
- *             right-to-left. Should never be #GTK_TEXT_DIR_NONE
- * @draw_arrow: %TRUE to draw a directional arrow on the
- *        cursor. Should be %FALSE unless the cursor is split.
- *
- * Draws a text caret on @cr at @location. This is not a style function
- * but merely a convenience function for drawing the standard cursor shape.
- *
- * Since: 3.0
- * Deprecated: 3.4: Use gtk_render_insertion_cursor() instead.
- */
-void
-gtk_draw_insertion_cursor (GtkWidget          *widget,
-                           cairo_t            *cr,
-                           const GdkRectangle *location,
-                           gboolean            is_primary,
-                           GtkTextDirection    direction,
-                           gboolean            draw_arrow)
-{
-  GtkStyleContext *context;
-
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (cr != NULL);
-  g_return_if_fail (location != NULL);
-  g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
-
-  context = gtk_widget_get_style_context (widget);
-
-  draw_insertion_cursor (context, cr,
-                         location->x, location->y, location->height,
-                         is_primary,
-                         (direction == GTK_TEXT_DIR_RTL) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR,
-                         draw_arrow);
-}
-
-/**
  * gtk_style_context_get_change:
  * @context: the context to query
  *
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 9f8551f..37119f0 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -1241,13 +1241,6 @@ void        gtk_render_insertion_cursor
                                     PangoLayout         *layout,
                                     int                  index,
                                     PangoDirection       direction);
-GDK_DEPRECATED_IN_3_4
-void   gtk_draw_insertion_cursor    (GtkWidget          *widget,
-                                     cairo_t            *cr,
-                                     const GdkRectangle *location,
-                                     gboolean            is_primary,
-                                     GtkTextDirection    direction,
-                                     gboolean            draw_arrow);
 
 typedef enum {
   GTK_STYLE_CONTEXT_PRINT_NONE         = 0,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index eb0024c..aecfffc 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3325,13 +3325,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
                                 GTK_TYPE_WIDGET_HELP_TYPE,
                                 GTK_WIDGET_HELP_WHATS_THIS);
 
-  gtk_widget_class_install_style_property (klass,
-                                           g_param_spec_boolean ("window-dragging",
-                                                                 P_("Window dragging"),
-                                                                 P_("Whether windows can be dragged and 
maximized by clicking on empty areas"),
-                                                                 FALSE,
-                                                                 GTK_PARAM_READABLE));
-
   gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
   gtk_widget_class_set_css_name (klass, "widget");
 }
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f49ebe8..ba18ab2 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1448,7 +1448,9 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
     {
     case GTK_WINDOW_REGION_CONTENT:
       if (event_widget != widget)
-        gtk_widget_style_get (event_widget, "window-dragging", &window_drag, NULL);
+        {
+          /* TODO: Have some way of enabling/disabling window-dragging on random widgets */
+        }
 
       if (!window_drag)
         {
@@ -1497,8 +1499,7 @@ drag_gesture_begin_cb (GtkGestureDrag *gesture,
 {
   GdkEventSequence *sequence;
   GtkWindowRegion region;
-  GtkWidget *event_widget;
-  gboolean widget_drag;
+  gboolean widget_drag = FALSE;
   const GdkEvent *event;
 
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
@@ -1515,9 +1516,7 @@ drag_gesture_begin_cb (GtkGestureDrag *gesture,
         /* Claim it */
         break;
       case GTK_WINDOW_REGION_CONTENT:
-        event_widget = gtk_get_event_widget ((GdkEvent *) event);
-
-        gtk_widget_style_get (event_widget, "window-dragging", &widget_drag, NULL);
+          /* TODO: Have some way of enabling/disabling window-dragging on random widgets */
 
         if (!widget_drag)
           gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
diff --git a/testsuite/gtk/cssprovider.c b/testsuite/gtk/cssprovider.c
index 8510784..d3606bf 100644
--- a/testsuite/gtk/cssprovider.c
+++ b/testsuite/gtk/cssprovider.c
@@ -33,13 +33,13 @@ test_section_in_style_property (void)
   provider = gtk_css_provider_new ();
   g_signal_connect (provider, "parsing-error",
                     G_CALLBACK (assert_section_is_not_null), NULL);
-  gtk_css_provider_load_from_data (provider, "* { -GtkWidget-window-dragging: random garbage goes here; }", 
-1, NULL);
+  gtk_css_provider_load_from_data (provider, "* { -GtkEntry-invisible-char: random garbage goes here; }", 
-1, NULL);
 
-  widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
-  pspec = gtk_widget_class_find_style_property (widget_class, "window-dragging");
+  widget_class = g_type_class_ref (GTK_TYPE_ENTRY);
+  pspec = gtk_widget_class_find_style_property (widget_class, "invisible-char");
   g_assert (pspec);
   path = gtk_widget_path_new ();
-  gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
+  gtk_widget_path_append_type (path, GTK_TYPE_ENTRY);
 
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (provider), path, 0, pspec, &value);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]