[vte/vte-next: 64/114] Remove 'inner-border' style property
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 64/114] Remove 'inner-border' style property
- Date: Mon, 30 May 2011 17:12:07 +0000 (UTC)
commit f981d0a66c86c8c4fefbb6e7c54366d5e1371d21
Author: Christian Persch <chpe gnome org>
Date: Sat May 7 20:13:04 2011 +0200
Remove 'inner-border' style property
Use the standard 'padding' style property instead.
src/vte.c | 30 +++++-------------------------
src/vteaccess.c | 17 +++++++----------
src/vteapp.c | 54 +++++++++++++++++++++++++++---------------------------
3 files changed, 39 insertions(+), 62 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index c773350..31540ed 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -4210,20 +4210,14 @@ vte_terminal_set_padding(VteTerminal *terminal)
{
VteTerminalPrivate *pvt = terminal->pvt;
GtkWidget *widget = GTK_WIDGET(terminal);
- GtkBorder *border = NULL;
GtkBorder padding;
- gtk_widget_style_get(widget, "inner-border", &border, NULL);
-
- if (border != NULL) {
- padding = *border;
- gtk_border_free(border);
- } else {
- padding = default_padding;
- }
+ gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+ gtk_widget_get_state_flags(widget),
+ &padding);
_vte_debug_print(VTE_DEBUG_MISC,
- "Setting inner-border to { %d, %d, %d, %d }\n",
+ "Setting padding to (%d,%d,%d,%d)\n",
padding.left, padding.right,
padding.top, padding.bottom);
@@ -11616,20 +11610,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
/* Style properties */
- /**
- * VteTerminal:inner-border:
- *
- * Sets the border around the terminal.
- *
- * Since: 0.24
- */
- gtk_widget_class_install_style_property
- (widget_class,
- g_param_spec_boxed ("inner-border", NULL, NULL,
- GTK_TYPE_BORDER,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
/* Keybindings */
binding_set = gtk_binding_set_by_class(klass);
@@ -11645,7 +11625,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
klass->priv->style_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (klass->priv->style_provider),
"VteTerminal {\n"
- "-VteTerminal-inner-border: 1;\n"
+ "padding: 1 1 1 1;\n"
"}\n",
-1, NULL);
}
diff --git a/src/vteaccess.c b/src/vteaccess.c
index aef9a79..bf83fb6 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -33,6 +33,7 @@
#include "vte.h"
#include "vteaccess.h"
#include "vteint.h"
+#include "vte-private.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
@@ -1774,9 +1775,8 @@ vte_terminal_accessible_set_size(AtkComponent *component,
gint width, gint height)
{
VteTerminal *terminal;
- gint columns, rows, char_width, char_height;
+ long columns, rows;
GtkWidget *widget;
- GtkBorder *padding;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE(component));
if (widget == NULL) {
@@ -1784,14 +1784,11 @@ vte_terminal_accessible_set_size(AtkComponent *component,
}
terminal = VTE_TERMINAL(widget);
- char_width = vte_terminal_get_char_width (terminal);
- char_height = vte_terminal_get_char_height (terminal);
- gtk_widget_style_get (widget, "inner-border", &padding, NULL);
- /* If the size is an exact multiple of the cell size, use that,
- * otherwise round down. */
- columns = (width - (padding ? (padding->left + padding->right) : 0)) / char_width;
- rows = (height - (padding ? (padding->top + padding->bottom) : 0)) / char_height;
- gtk_border_free (padding);
+ /* If the size is an exact multiple of the cell size, use that,
+ * otherwise round down. */
+ if (!_vte_terminal_size_to_grid_size(terminal, width, height, &columns, &rows))
+ return FALSE;
+
vte_terminal_set_size(terminal, columns, rows);
return (vte_terminal_get_row_count (terminal) == rows) &&
(vte_terminal_get_column_count (terminal) == columns);
diff --git a/src/vteapp.c b/src/vteapp.c
index c7cf557..4e4832b 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -69,7 +69,7 @@ char_size_changed(GtkWidget *widget, guint width, guint height, gpointer data)
VteTerminal *terminal;
GtkWindow *window;
GdkGeometry geometry;
- GtkBorder *padding;
+ GtkBorder padding;
g_assert(GTK_IS_WINDOW(data));
g_assert(VTE_IS_TERMINAL(widget));
@@ -79,14 +79,15 @@ char_size_changed(GtkWidget *widget, guint width, guint height, gpointer data)
if (!gtk_widget_get_realized (GTK_WIDGET (window)))
return;
- gtk_widget_style_get (widget, "inner-border", &padding, NULL);
- geometry.width_inc = width;
+ gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+ gtk_widget_get_state_flags(widget),
+ &padding);
+ geometry.width_inc = width;
geometry.height_inc = height;
- geometry.base_width = padding ? (padding->left + padding->right) : 0;
- geometry.base_height = padding ? (padding->top + padding->bottom) : 0;
+ geometry.base_width = padding.left + padding.right;
+ geometry.base_height = padding.top + padding.bottom;
geometry.min_width = geometry.base_width + width * 2;
geometry.min_height = geometry.base_height + height * 2;
- gtk_border_free (padding);
gtk_window_set_geometry_hints(window, widget, &geometry,
GDK_HINT_RESIZE_INC |
@@ -101,7 +102,7 @@ char_size_realized(GtkWidget *widget, gpointer data)
GtkWindow *window;
GdkGeometry geometry;
guint width, height;
- GtkBorder *padding;
+ GtkBorder padding;
g_assert(GTK_IS_WINDOW(data));
g_assert(VTE_IS_TERMINAL(widget));
@@ -111,16 +112,17 @@ char_size_realized(GtkWidget *widget, gpointer data)
if (!gtk_widget_get_realized (GTK_WIDGET(window)))
return;
- gtk_widget_style_get (widget, "inner-border", &padding, NULL);
- width = vte_terminal_get_char_width (terminal);
+ gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+ gtk_widget_get_state_flags(widget),
+ &padding);
+ width = vte_terminal_get_char_width (terminal);
height = vte_terminal_get_char_height (terminal);
geometry.width_inc = width;
geometry.height_inc = height;
- geometry.base_width = padding ? (padding->left + padding->right) : 0;
- geometry.base_height = padding ? (padding->top + padding->bottom) : 0;
+ geometry.base_width = padding.left + padding.right;
+ geometry.base_height = padding.top + padding.bottom;
geometry.min_width = geometry.base_width + width * 2;
geometry.min_height = geometry.base_height + height * 2;
- gtk_border_free (padding);
gtk_window_set_geometry_hints(window, widget, &geometry,
GDK_HINT_RESIZE_INC |
@@ -186,21 +188,22 @@ button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data)
VteTerminal *terminal;
char *match;
int tag;
- GtkBorder *padding;
+ GtkBorder padding;
int char_width, char_height;
switch (event->button) {
case 3:
terminal = VTE_TERMINAL(widget);
- gtk_widget_style_get (widget, "inner-border", &padding, NULL);
- char_width = vte_terminal_get_char_width (terminal);
+ gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+ gtk_widget_get_state_flags(widget),
+ &padding);
+ char_width = vte_terminal_get_char_width (terminal);
char_height = vte_terminal_get_char_height (terminal);
match = vte_terminal_match_check(terminal,
- (event->x - (padding ? padding->left : 0)) / char_width,
- (event->y - (padding ? padding->top : 0)) / char_height,
+ (event->x - padding.left) / char_width,
+ (event->y - padding.top) / char_height,
&tag);
- gtk_border_free (padding);
if (match != NULL) {
g_print("Matched `%s' (%d).\n", match, tag);
g_free(match);
@@ -307,7 +310,7 @@ resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
gint owidth, oheight, char_width, char_height, column_count, row_count;
- GtkBorder *padding;
+ GtkBorder padding;
terminal = VTE_TERMINAL(widget);
@@ -318,17 +321,14 @@ resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
char_height = vte_terminal_get_char_height (terminal);
column_count = vte_terminal_get_column_count (terminal);
row_count = vte_terminal_get_row_count (terminal);
- gtk_widget_style_get (widget, "inner-border", &padding, NULL);
+ gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+ gtk_widget_get_state_flags(widget),
+ &padding);
- owidth -= char_width * column_count;
- oheight -= char_height * row_count;
- if (padding != NULL) {
- owidth -= padding->left + padding->right;
- oheight -= padding->top + padding->bottom;
- }
+ owidth -= char_width * column_count + padding.left + padding.right;
+ oheight -= char_height * row_count + padding.top + padding.bottom;
gtk_window_resize(GTK_WINDOW(data),
width + owidth, height + oheight);
- gtk_border_free (padding);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]