[gnome-terminal] Use VteTerminal::inner-border style property



commit d9380aefabc1a326b46e5ebb149e773e485cc60e
Author: Christian Persch <chpe gnome org>
Date:   Tue Dec 1 00:36:14 2009 +0100

    Use VteTerminal::inner-border style property
    
    Get the right padding values from the inner-border style property.
    
    Bump vte req to 0.23.1.

 configure.ac          |    2 +-
 src/terminal-screen.c |   12 ++++++++----
 src/terminal-window.c |   34 +++++++++++++++++++---------------
 3 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6ba46a6..dcddb4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,7 @@ GLIB_REQUIRED=2.16.0
 GTK_REQUIRED=2.14.0
 GCONF_REQUIRED=2.14.0
 DBUS_GLIB_REQUIRED=0.6
-VTE_REQUIRED=0.22.0
+VTE_REQUIRED=0.23.1
 
 PKG_CHECK_MODULES([TERM],
   [vte >= $VTE_REQUIRED
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 7fb9809..664e6b4 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -1689,18 +1689,22 @@ terminal_screen_button_press (GtkWidget      *widget,
   TerminalScreenPrivate *priv = screen->priv;
   gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) =
     GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event;
-  int char_width, char_height, row, col, xpad_total, ypad_total;
+  int char_width, char_height, row, col;
   char *matched_string;
   int matched_flavor = 0;
   guint state;
+  GtkBorder *inner_border = NULL;
 
   state = event->state & gtk_accelerator_get_default_mod_mask ();
 
   terminal_screen_get_cell_size (screen, &char_width, &char_height);
-  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad_total, &ypad_total);
 
-  row = (event->x - xpad_total / 2) / char_width;
-  col = (event->y - ypad_total / 2) / char_height;
+  gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
+  row = (event->x - (inner_border ? inner_border->left : 0)) / char_width;
+  col = (event->y - (inner_border ? inner_border->top : 0)) / char_height;
+  gtk_border_free (inner_border);
+
+  /* FIXMEchpe: add vte API to do this check by widget coords instead of grid coords */
   matched_string = terminal_screen_check_match (screen, row, col, &matched_flavor);
   
   if (matched_string != NULL &&
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 284576f..8cf5b55 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -982,7 +982,8 @@ screen_resize_window_cb (TerminalScreen *screen,
   VteTerminal *terminal = VTE_TERMINAL (screen);
   GtkWidget *widget = GTK_WIDGET (screen);
   guint grid_width, grid_height;
-  int xpad_total, ypad_total, char_width, char_height;
+  int char_width, char_height;
+  GtkBorder *inner_border = NULL;
 
   /* Don't do anything if we're maximised or fullscreened */
   // FIXME: realized && ... instead? 
@@ -999,12 +1000,13 @@ screen_resize_window_cb (TerminalScreen *screen,
 
   /* The resize-window signal sucks. Re-compute grid widths */
 
-  vte_terminal_get_padding (terminal, &xpad_total, &ypad_total);
   char_width = vte_terminal_get_char_width (terminal);
   char_height = vte_terminal_get_char_height (terminal);
 
-  grid_width = (width - xpad_total) / char_width;
-  grid_height = (height - ypad_total) / char_height;
+  gtk_widget_style_get (GTK_WIDGET (terminal), "inner-border", &inner_border, NULL);
+  grid_width = (width - (inner_border ? (inner_border->left + inner_border->right) : 0)) / char_width;
+  grid_height = (height - (inner_border ? (inner_border->top + inner_border->bottom) : 0)) / char_height;
+  gtk_border_free (inner_border);
 
   vte_terminal_set_size (terminal, grid_width, grid_height);
 
@@ -2439,8 +2441,7 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
   int char_height;
   int grid_width;
   int grid_height;
-  int xpad_total;
-  int ypad_total;
+  GtkBorder *inner_border = NULL;
 
   /* be sure our geometry is up-to-date */
   terminal_window_update_geometry (window);
@@ -2471,10 +2472,10 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
   if (force_grid_height >= 0)
     grid_height = force_grid_height;
   
-  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad_total, &ypad_total);
-
-  w += xpad_total + char_width * grid_width;
-  h += ypad_total + char_height * grid_height;
+  gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
+  w += (inner_border ? (inner_border->left + inner_border->right) : 0) + char_width * grid_width;
+  h += (inner_border ? (inner_border->top + inner_border->bottom) : 0) + char_height * grid_height;
+  gtk_border_free (inner_border);
 
   _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
                          "[window %p] set size: grid %dx%d force %dx%d setting %dx%d pixels\n",
@@ -2812,15 +2813,18 @@ terminal_window_update_geometry (TerminalWindow *window)
       char_height != priv->old_char_height ||
       widget != (GtkWidget*) priv->old_geometry_widget)
     {
-      int xpad_total, ypad_total;
+      GtkBorder *inner_border = NULL;
       
       /* FIXME Since we're using xthickness/ythickness to compute
        * padding we need to change the hints when the theme changes.
        */
-      vte_terminal_get_padding (VTE_TERMINAL (priv->active_screen), &xpad_total, &ypad_total);
-      
-      hints.base_width = xpad_total;
-      hints.base_height = ypad_total;
+
+      gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
+
+      hints.base_width = (inner_border ? (inner_border->left + inner_border->right) : 0);
+      hints.base_height = (inner_border ? (inner_border->top + inner_border->bottom) : 0);
+
+      gtk_border_free (inner_border);
 
 #define MIN_WIDTH_CHARS 4
 #define MIN_HEIGHT_CHARS 2



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