[gnome-builder] terminal: move size allocate helper to IdeTerminal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] terminal: move size allocate helper to IdeTerminal
- Date: Thu, 23 Nov 2017 10:24:29 +0000 (UTC)
commit f9e727947034b66efd34709ca7d8f97ded981da9
Author: Christian Hergert <chergert redhat com>
Date: Thu Nov 23 01:58:45 2017 -0800
terminal: move size allocate helper to IdeTerminal
src/libide/terminal/ide-terminal.c | 31 +++++++++++++++++++++++++
src/plugins/terminal/gb-terminal-view.c | 38 -------------------------------
2 files changed, 31 insertions(+), 38 deletions(-)
---
diff --git a/src/libide/terminal/ide-terminal.c b/src/libide/terminal/ide-terminal.c
index 90a2b28..b5432b1 100644
--- a/src/libide/terminal/ide-terminal.c
+++ b/src/libide/terminal/ide-terminal.c
@@ -339,6 +339,36 @@ ide_terminal_font_changed (IdeTerminal *self,
}
static void
+ide_terminal_size_allocate (GtkWidget *widget,
+ GtkAllocation *alloc)
+{
+ IdeTerminal *self = (IdeTerminal *)widget;
+ glong width;
+ glong height;
+ glong columns;
+ glong rows;
+
+ GTK_WIDGET_CLASS (ide_terminal_parent_class)->size_allocate (widget, alloc);
+
+ if ((alloc->width == 0) || (alloc->height == 0))
+ return;
+
+ width = vte_terminal_get_char_width (VTE_TERMINAL (self));
+ height = vte_terminal_get_char_height (VTE_TERMINAL (self));
+
+ if ((width == 0) || (height == 0))
+ return;
+
+ columns = alloc->width / width;
+ rows = alloc->height / height;
+
+ if ((columns < 2) || (rows < 2))
+ return;
+
+ vte_terminal_set_size (VTE_TERMINAL (self), columns, rows);
+}
+
+static void
ide_terminal_destroy (GtkWidget *widget)
{
IdeTerminal *self = (IdeTerminal *)widget;
@@ -361,6 +391,7 @@ ide_terminal_class_init (IdeTerminalClass *klass)
widget_class->destroy = ide_terminal_destroy;
widget_class->button_press_event = ide_terminal_button_press_event;
widget_class->popup_menu = ide_terminal_popup_menu;
+ widget_class->size_allocate = ide_terminal_size_allocate;
klass->copy_link_address = ide_terminal_copy_link_address;
klass->open_link = ide_terminal_open_link;
diff --git a/src/plugins/terminal/gb-terminal-view.c b/src/plugins/terminal/gb-terminal-view.c
index c49da74..2d9fba3 100644
--- a/src/plugins/terminal/gb-terminal-view.c
+++ b/src/plugins/terminal/gb-terminal-view.c
@@ -318,38 +318,6 @@ gb_terminal_realize (GtkWidget *widget)
}
static void
-size_allocate_cb (VteTerminal *terminal,
- GtkAllocation *alloc,
- GbTerminalView *self)
-{
- glong width;
- glong height;
- glong columns;
- glong rows;
-
- g_assert (VTE_IS_TERMINAL (terminal));
- g_assert (alloc != NULL);
- g_assert (GB_IS_TERMINAL_VIEW (self));
-
- if ((alloc->width == 0) || (alloc->height == 0))
- return;
-
- width = vte_terminal_get_char_width (terminal);
- height = vte_terminal_get_char_height (terminal);
-
- if ((width == 0) || (height == 0))
- return;
-
- columns = alloc->width / width;
- rows = alloc->height / height;
-
- if ((columns < 2) || (rows < 2))
- return;
-
- vte_terminal_set_size (terminal, columns, rows);
-}
-
-static void
gb_terminal_get_preferred_width (GtkWidget *widget,
gint *min_width,
gint *nat_width)
@@ -503,12 +471,6 @@ gb_terminal_view_connect_terminal (GbTerminalView *self,
gtk_range_set_adjustment (GTK_RANGE (self->top_scrollbar), vadj);
g_signal_connect_object (terminal,
- "size-allocate",
- G_CALLBACK (size_allocate_cb),
- self,
- 0);
-
- g_signal_connect_object (terminal,
"focus-in-event",
G_CALLBACK (focus_in_event_cb),
self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]