[gtk+/wip/baedert/box] window: Remove deprecated geometry API



commit b985e9fb9a9e8eec3221cc59853066d9cd698b85
Author: Timm Bäder <mail baedert org>
Date:   Tue Oct 4 10:59:37 2016 +0200

    window: Remove deprecated geometry API

 docs/reference/gtk/gtk3-sections.txt |    3 -
 gtk/gtkwindow.c                      |  407 ----------------------------------
 gtk/gtkwindow.h                      |   12 -
 tests/testgeometry.c                 |   34 ---
 tests/testgtk.c                      |   23 --
 5 files changed, 0 insertions(+), 479 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 884afbd..0ad6991 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5663,7 +5663,6 @@ gtk_window_activate_focus
 gtk_window_activate_default
 gtk_window_set_modal
 gtk_window_set_default_size
-gtk_window_set_default_geometry
 gtk_window_set_geometry_hints
 gtk_window_set_gravity
 gtk_window_get_gravity
@@ -5743,10 +5742,8 @@ gtk_window_get_group
 gtk_window_has_group
 gtk_window_get_window_type
 gtk_window_move
-gtk_window_parse_geometry
 gtk_window_reshow_with_initial_size
 gtk_window_resize
-gtk_window_resize_to_geometry
 gtk_window_set_default_icon_list
 gtk_window_set_default_icon
 gtk_window_set_default_icon_from_file
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f86a448..f49ebe8 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5169,33 +5169,6 @@ gtk_window_set_default_size (GtkWindow   *window,
 }
 
 /**
- * gtk_window_set_default_geometry:
- * @window: a #GtkWindow
- * @width: width in resize increments, or -1 to unset the default width
- * @height: height in resize increments, or -1 to unset the default height
- *
- * Like gtk_window_set_default_size(), but @width and @height are interpreted
- * in terms of the base size and increment set with
- * gtk_window_set_geometry_hints.
- *
- * Since: 3.0
- *
- * Deprecated: 3.20: This function does nothing. If you want to set a default
- *     size, use gtk_window_set_default_size() instead.
- */
-void
-gtk_window_set_default_geometry (GtkWindow *window,
-                                gint       width,
-                                gint       height)
-{
-  g_return_if_fail (GTK_IS_WINDOW (window));
-  g_return_if_fail (width >= -1);
-  g_return_if_fail (height >= -1);
-
-  gtk_window_set_default_size_internal (window, TRUE, width, TRUE, height, TRUE);
-}
-
-/**
  * gtk_window_get_default_size:
  * @window: a #GtkWindow
  * @width: (out) (allow-none): location to store the default width, or %NULL
@@ -5280,31 +5253,6 @@ gtk_window_resize (GtkWindow *window,
 }
 
 /**
- * gtk_window_resize_to_geometry:
- * @window: a #GtkWindow
- * @width: width in resize increments to resize the window to
- * @height: height in resize increments to resize the window to
- *
- * Like gtk_window_resize(), but @width and @height are interpreted
- * in terms of the base size and increment set with
- * gtk_window_set_geometry_hints.
- *
- * Since: 3.0
- *
- * Deprecated: 3.20: This function does nothing. Use 
- *    gtk_window_resize() and compute the geometry yourself.
- */
-void
-gtk_window_resize_to_geometry (GtkWindow *window,
-                              gint       width,
-                              gint       height)
-{
-  g_return_if_fail (GTK_IS_WINDOW (window));
-  g_return_if_fail (width > 0);
-  g_return_if_fail (height > 0);
-}
-
-/**
  * gtk_window_get_size:
  * @window: a #GtkWindow
  * @width: (out) (nullable): return location for width, or %NULL
@@ -10966,361 +10914,6 @@ _gtk_window_set_window_group (GtkWindow      *window,
   window->priv->group = group;
 }
 
-/*
-  Derived from XParseGeometry() in XFree86  
-
-  Copyright 1985, 1986, 1987,1998  The Open Group
-
-  All Rights Reserved.
-
-  The above copyright notice and this permission notice shall be included
-  in all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-  IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-  OTHER DEALINGS IN THE SOFTWARE.
-
-  Except as contained in this notice, the name of The Open Group shall
-  not be used in advertising or otherwise to promote the sale, use or
-  other dealings in this Software without prior written authorization
-  from The Open Group.
-*/
-
-
-/*
- *    XParseGeometry parses strings of the form
- *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
- *   width, height, xoffset, and yoffset are unsigned integers.
- *   Example:  “=80x24+300-49”
- *   The equal sign is optional.
- *   It returns a bitmask that indicates which of the four values
- *   were actually found in the string.  For each value found,
- *   the corresponding argument is updated;  for each value
- *   not found, the corresponding argument is left unchanged. 
- */
-
-/* The following code is from Xlib, and is minimally modified, so we
- * can track any upstream changes if required.  Don’t change this
- * code. Or if you do, put in a huge comment marking which thing
- * changed.
- */
-
-static int
-read_int (gchar   *string,
-          gchar  **next)
-{
-  int result = 0;
-  int sign = 1;
-  
-  if (*string == '+')
-    string++;
-  else if (*string == '-')
-    {
-      string++;
-      sign = -1;
-    }
-
-  for (; (*string >= '0') && (*string <= '9'); string++)
-    {
-      result = (result * 10) + (*string - '0');
-    }
-
-  *next = string;
-
-  if (sign >= 0)
-    return (result);
-  else
-    return (-result);
-}
-
-/* 
- * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
- * value (x, y, width, height) was found in the parsed string.
- */
-#define NoValue         0x0000
-#define XValue          0x0001
-#define YValue          0x0002
-#define WidthValue      0x0004
-#define HeightValue     0x0008
-#define AllValues       0x000F
-#define XNegative       0x0010
-#define YNegative       0x0020
-
-/* Try not to reformat/modify, so we can compare/sync with X sources */
-static int
-gtk_XParseGeometry (const char   *string,
-                    int          *x,
-                    int          *y,
-                    unsigned int *width,   
-                    unsigned int *height)  
-{
-  int mask = NoValue;
-  char *strind;
-  unsigned int tempWidth, tempHeight;
-  int tempX, tempY;
-  char *nextCharacter;
-
-  /* These initializations are just to silence gcc */
-  tempWidth = 0;
-  tempHeight = 0;
-  tempX = 0;
-  tempY = 0;
-  
-  if ( (string == NULL) || (*string == '\0')) return(mask);
-  if (*string == '=')
-    string++;  /* ignore possible '=' at beg of geometry spec */
-
-  strind = (char *)string;
-  if (*strind != '+' && *strind != '-' && *strind != 'x') {
-    tempWidth = read_int(strind, &nextCharacter);
-    if (strind == nextCharacter) 
-      return (0);
-    strind = nextCharacter;
-    mask |= WidthValue;
-  }
-
-  if (*strind == 'x' || *strind == 'X') {      
-    strind++;
-    tempHeight = read_int(strind, &nextCharacter);
-    if (strind == nextCharacter)
-      return (0);
-    strind = nextCharacter;
-    mask |= HeightValue;
-  }
-
-  if ((*strind == '+') || (*strind == '-')) {
-    if (*strind == '-') {
-      strind++;
-      tempX = -read_int(strind, &nextCharacter);
-      if (strind == nextCharacter)
-        return (0);
-      strind = nextCharacter;
-      mask |= XNegative;
-
-    }
-    else
-      {        strind++;
-      tempX = read_int(strind, &nextCharacter);
-      if (strind == nextCharacter)
-        return(0);
-      strind = nextCharacter;
-      }
-    mask |= XValue;
-    if ((*strind == '+') || (*strind == '-')) {
-      if (*strind == '-') {
-        strind++;
-        tempY = -read_int(strind, &nextCharacter);
-        if (strind == nextCharacter)
-          return(0);
-        strind = nextCharacter;
-        mask |= YNegative;
-
-      }
-      else
-        {
-          strind++;
-          tempY = read_int(strind, &nextCharacter);
-          if (strind == nextCharacter)
-            return(0);
-          strind = nextCharacter;
-        }
-      mask |= YValue;
-    }
-  }
-       
-  /* If strind isn't at the end of the string the it's an invalid
-               geometry specification. */
-
-  if (*strind != '\0') return (0);
-
-  if (mask & XValue)
-    *x = tempX;
-  if (mask & YValue)
-    *y = tempY;
-  if (mask & WidthValue)
-    *width = tempWidth;
-  if (mask & HeightValue)
-    *height = tempHeight;
-  return (mask);
-}
-
-/**
- * gtk_window_parse_geometry:
- * @window: a #GtkWindow
- * @geometry: geometry string
- *
- * Parses a standard X Window System geometry string - see the
- * manual page for X (type “man X”) for details on this.
- * gtk_window_parse_geometry() does work on all GTK+ ports
- * including Win32 but is primarily intended for an X environment.
- *
- * If either a size or a position can be extracted from the
- * geometry string, gtk_window_parse_geometry() returns %TRUE
- * and calls gtk_window_set_default_size() and/or gtk_window_move()
- * to resize/move the window.
- *
- * If gtk_window_parse_geometry() returns %TRUE, it will also
- * set the #GDK_HINT_USER_POS and/or #GDK_HINT_USER_SIZE hints
- * indicating to the window manager that the size/position of
- * the window was user-specified. This causes most window
- * managers to honor the geometry.
- *
- * Note that for gtk_window_parse_geometry() to work as expected, it has
- * to be called when the window has its “final” size, i.e. after calling
- * gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints()
- * on the window.
- * |[<!-- language="C" -->
- * #include <gtk/gtk.h>
- *
- * static void
- * fill_with_content (GtkWidget *vbox)
- * {
- *   // fill with content...
- * }
- *
- * int
- * main (int argc, char *argv[])
- * {
- *   GtkWidget *window, *vbox;
- *   GdkGeometry size_hints = {
- *     100, 50, 0, 0, 100, 50, 10,
- *     10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
- *   };
- *
- *   gtk_init (&argc, &argv);
- *
- *   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- *   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- *
- *   gtk_container_add (GTK_CONTAINER (window), vbox);
- *   fill_with_content (vbox);
- *   gtk_widget_show_all (vbox);
- *
- *   gtk_window_set_geometry_hints (GTK_WINDOW (window),
- *                                 NULL,
- *                                 &size_hints,
- *                                 GDK_HINT_MIN_SIZE |
- *                                 GDK_HINT_BASE_SIZE |
- *                                 GDK_HINT_RESIZE_INC);
- *
- *   if (argc > 1)
- *     {
- *       gboolean res;
- *       res = gtk_window_parse_geometry (GTK_WINDOW (window),
- *                                        argv[1]);
- *       if (! res)
- *         fprintf (stderr,
- *                  "Failed to parse “%s”\n",
- *                  argv[1]);
- *     }
- *
- *   gtk_widget_show_all (window);
- *   gtk_main ();
- *
- *   return 0;
- * }
- * ]|
- *
- * Returns: %TRUE if string was parsed successfully
- *
- * Deprecated: 3.20: Geometry handling in GTK is deprecated.
- **/
-gboolean
-gtk_window_parse_geometry (GtkWindow   *window,
-                           const gchar *geometry)
-{
-  gint result, x = 0, y = 0;
-  guint w, h;
-  GtkWidget *child;
-  GdkGravity grav;
-  gboolean size_set, pos_set;
-  GdkScreen *screen;
-  
-  g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
-  g_return_val_if_fail (geometry != NULL, FALSE);
-
-  child = gtk_bin_get_child (GTK_BIN (window));
-  if (!child || !gtk_widget_get_visible (child))
-    g_warning ("gtk_window_parse_geometry() called on a window with no "
-              "visible children; the window should be set up before "
-              "gtk_window_parse_geometry() is called.");
-
-  screen = gtk_window_check_screen (window);
-  
-  result = gtk_XParseGeometry (geometry, &x, &y, &w, &h);
-
-  size_set = FALSE;
-  if ((result & WidthValue) || (result & HeightValue))
-    {
-      gtk_window_set_default_size_internal (window, 
-                                           TRUE, result & WidthValue ? w : -1,
-                                           TRUE, result & HeightValue ? h : -1, 
-                                           TRUE);
-      size_set = TRUE;
-    }
-
-  gtk_window_get_size (window, (gint *)&w, (gint *)&h);
-  
-  grav = GDK_GRAVITY_NORTH_WEST;
-
-  if ((result & XNegative) && (result & YNegative))
-    grav = GDK_GRAVITY_SOUTH_EAST;
-  else if (result & XNegative)
-    grav = GDK_GRAVITY_NORTH_EAST;
-  else if (result & YNegative)
-    grav = GDK_GRAVITY_SOUTH_WEST;
-
-  if ((result & XValue) == 0)
-    x = 0;
-
-  if ((result & YValue) == 0)
-    y = 0;
-
-  if (grav == GDK_GRAVITY_SOUTH_WEST ||
-      grav == GDK_GRAVITY_SOUTH_EAST)
-    y = gdk_screen_get_height (screen) - h + y;
-
-  if (grav == GDK_GRAVITY_SOUTH_EAST ||
-      grav == GDK_GRAVITY_NORTH_EAST)
-    x = gdk_screen_get_width (screen) - w + x;
-
-  /* we don't let you put a window offscreen; maybe some people would
-   * prefer to be able to, but it's kind of a bogus thing to do.
-   */
-  if (y < 0)
-    y = 0;
-
-  if (x < 0)
-    x = 0;
-
-  pos_set = FALSE;
-  if ((result & XValue) || (result & YValue))
-    {
-      gtk_window_set_gravity (window, grav);
-      gtk_window_move (window, x, y);
-      pos_set = TRUE;
-    }
-
-  if (size_set || pos_set)
-    {
-      /* Set USSize, USPosition hints */
-      GtkWindowGeometryInfo *info;
-
-      info = gtk_window_get_geometry_info (window, TRUE);
-
-      if (pos_set)
-        info->mask |= GDK_HINT_USER_POS;
-      if (size_set)
-        info->mask |= GDK_HINT_USER_SIZE;
-    }
-  
-  return result != 0;
-}
-
 static gboolean
 gtk_window_activate_menubar (GtkWindow   *window,
                              GdkEventKey *event)
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 8d94b15..dcec963 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -434,18 +434,6 @@ GDK_AVAILABLE_IN_ALL
 void     gtk_window_get_position     (GtkWindow   *window,
                                       gint        *root_x,
                                       gint        *root_y);
-GDK_DEPRECATED_IN_3_20
-gboolean gtk_window_parse_geometry   (GtkWindow   *window,
-                                      const gchar *geometry);
-
-GDK_DEPRECATED_IN_3_20_FOR(gtk_window_set_default_size)
-void gtk_window_set_default_geometry (GtkWindow *window,
-                                      gint       width,
-                                      gint       height);
-GDK_DEPRECATED_IN_3_20_FOR(gtk_window_resize)
-void gtk_window_resize_to_geometry   (GtkWindow *window,
-                                      gint       width,
-                                      gint       height);
 
 GDK_AVAILABLE_IN_ALL
 GtkWindowGroup *gtk_window_get_group (GtkWindow   *window);
diff --git a/tests/testgeometry.c b/tests/testgeometry.c
index 0a0af12..81ee29e 100644
--- a/tests/testgeometry.c
+++ b/tests/testgeometry.c
@@ -74,26 +74,12 @@ on_drawing_area_draw (GtkWidget *drawing_area,
 }
 
 static void
-on_resize_clicked (GtkWidget *button,
-                  gpointer   data)
-{
-  GtkWidget *window = gtk_widget_get_toplevel (button);
-  GdkWindowHints mask = GPOINTER_TO_UINT(data);
-
-  if ((mask & GDK_HINT_RESIZE_INC) != 0)
-    gtk_window_resize_to_geometry (GTK_WINDOW (window), 8, 8);
-  else
-    gtk_window_resize_to_geometry (GTK_WINDOW (window), 8 * GRID_SIZE, 8 * GRID_SIZE);
-}
-
-static void
 create_window (GdkWindowHints  mask)
 {
   GtkWidget *window;
   GtkWidget *drawing_area;
   GtkWidget *grid;
   GtkWidget *label;
-  GtkWidget *button;
   GdkGeometry geometry;
   GString *label_text = g_string_new (NULL);
   int border = 0;
@@ -138,13 +124,6 @@ create_window (GdkWindowHints  mask)
   gtk_widget_set_vexpand (drawing_area, TRUE);
   gtk_grid_attach (GTK_GRID (grid), drawing_area, 0, 1, 1, 1);
 
-  button = gtk_button_new_with_label ("Resize");
-  g_signal_connect (button, "clicked",
-                   G_CALLBACK (on_resize_clicked),
-                   GUINT_TO_POINTER (mask));
-  gtk_widget_set_hexpand (button, TRUE);
-  gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 1, 1);
-
   gtk_container_add (GTK_CONTAINER (window), grid);
 
   if ((mask & GDK_HINT_BASE_SIZE) != 0)
@@ -172,7 +151,6 @@ create_window (GdkWindowHints  mask)
       geometry.max_height = 15 * GRID_SIZE + 2 * border;
     }
 
-  /* Contents must be set up before gtk_window_parse_geometry() */
   gtk_widget_show_all (grid);
 
   gtk_window_set_geometry_hints (GTK_WINDOW (window),
@@ -180,18 +158,6 @@ create_window (GdkWindowHints  mask)
                                 &geometry,
                                 mask);
 
-  if ((mask & GDK_HINT_RESIZE_INC) != 0)
-    {
-      if (geometry_string)
-       gtk_window_parse_geometry (GTK_WINDOW (window), geometry_string);
-      else
-       gtk_window_set_default_geometry (GTK_WINDOW (window), 10, 10);
-    }
-  else
-    {
-      gtk_window_set_default_geometry (GTK_WINDOW (window), 10 * GRID_SIZE, 10 * GRID_SIZE);
-    }
-
   gtk_widget_show (window);
   window_count++;
 }
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 90609f3..bc98c1f 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -7580,25 +7580,6 @@ move_to_position_callback (GtkWidget *widget,
 }
 
 static void
-set_geometry_callback (GtkWidget *entry,
-                       gpointer   data)
-{
-  gchar *text;
-  GtkWindow *target;
-
-  target = GTK_WINDOW (g_object_get_data (G_OBJECT (data), "target"));
-  
-  text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  if (!gtk_window_parse_geometry (target, text))
-    g_print ("Bad geometry string '%s'\n", text);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-  g_free (text);
-}
-
-static void
 resizable_callback (GtkWidget *widget,
                      gpointer   data)
 {
@@ -7899,10 +7880,6 @@ window_controls (GtkWidget *window)
   entry = gtk_entry_new ();
   gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE);
 
-  g_signal_connect (entry, "changed",
-                   G_CALLBACK (set_geometry_callback),
-                   control_window);
-
   button = gtk_button_new_with_label ("Show gravity test windows");
   g_signal_connect_swapped (button,
                            "clicked",


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