[vte] widget: Move some public API to its own file



commit 8cd11ab2fe6bc47bd1b9e838f74f17330581b183
Author: Christian Persch <chpe gnome org>
Date:   Wed Nov 18 21:15:42 2015 +0100

    widget: Move some public API to its own file

 src/vte.cc    |  185 ---------------------------------------------------------
 src/vtegtk.cc |  184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+), 185 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 90ba280..6d43c58 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -18,13 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-/**
- * SECTION: vte-terminal
- * @short_description: A terminal widget implementation
- *
- * A VteTerminal is a terminal emulator implemented as a GTK3 widget.
- */
-
 #include <config.h>
 
 #include <math.h>
@@ -4165,54 +4158,6 @@ vte_terminal_watch_child (VteTerminal *terminal,
 }
 
 /**
- * vte_get_user_shell:
- *
- * Gets the user's shell, or %NULL. In the latter case, the
- * system default (usually "/bin/sh") should be used.
- *
- * Returns: (transfer full) (type filename): a newly allocated string with the
- *   user's shell, or %NULL
- */
-char *
-vte_get_user_shell (void)
-{
-       struct passwd *pwd;
-
-       pwd = getpwuid(getuid());
-        if (pwd && pwd->pw_shell)
-                return g_strdup (pwd->pw_shell);
-
-        return NULL;
-}
-
-/**
- * vte_get_features:
- *
- * Gets a list of features vte was compiled with.
- *
- * Returns: (transfer none): a string with features
- *
- * Since: 0.40
- */
-const char *
-vte_get_features (void)
-{
-        return
-#ifdef WITH_GNUTLS
-                "+GNUTLS"
-#else
-                "-GNUTLS"
-#endif
-                " "
-#ifdef WITH_PCRE2
-                "+PCRE2"
-#else
-                "-PCRE2"
-#endif
-                ;
-}
-
-/**
  * vte_terminal_spawn_sync:
  * @terminal: a #VteTerminal
  * @pty_flags: flags from #VtePtyFlags
@@ -13056,82 +13001,6 @@ vte_terminal_search_find_next (VteTerminal *terminal)
        return vte_terminal_search_find (terminal, FALSE);
 }
 
-/* Just some arbitrary minimum values */
-#define MIN_COLUMNS (16)
-#define MIN_ROWS    (2)
-
-/**
- * vte_terminal_get_geometry_hints:
- * @terminal: a #VteTerminal
- * @hints: (out caller-allocates): a #GdkGeometry to fill in
- * @min_rows: the minimum number of rows to request
- * @min_columns: the minimum number of columns to request
- *
- * Fills in some @hints from @terminal's geometry. The hints
- * filled are those covered by the %GDK_HINT_RESIZE_INC,
- * %GDK_HINT_MIN_SIZE and %GDK_HINT_BASE_SIZE flags.
- *
- * See gtk_window_set_geometry_hints() for more information.
- *
- * @terminal must be realized (see gtk_widget_get_realized()).
- */
-void
-vte_terminal_get_geometry_hints(VteTerminal *terminal,
-                                GdkGeometry *hints,
-                                int min_rows,
-                                int min_columns)
-{
-        VteTerminalPrivate *pvt;
-        GtkWidget *widget;
-        GtkBorder padding;
-
-        g_return_if_fail(VTE_IS_TERMINAL(terminal));
-        g_return_if_fail(hints != NULL);
-        widget = &terminal->widget;
-        g_return_if_fail(gtk_widget_get_realized(widget));
-
-        pvt = terminal->pvt;
-
-        gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
-                                      gtk_widget_get_state_flags(widget),
-                                      &padding);
-
-        hints->base_width  = padding.left + padding.right;
-        hints->base_height = padding.top  + padding.bottom;
-        hints->width_inc   = pvt->char_width;
-        hints->height_inc  = pvt->char_height;
-        hints->min_width   = hints->base_width  + hints->width_inc  * min_columns;
-        hints->min_height  = hints->base_height + hints->height_inc * min_rows;
-}
-
-/**
- * vte_terminal_set_geometry_hints_for_window:
- * @terminal: a #VteTerminal
- * @window: a #GtkWindow
- *
- * Sets @terminal as @window's geometry widget. See
- * gtk_window_set_geometry_hints() for more information.
- *
- * @terminal must be realized (see gtk_widget_get_realized()).
- */
-void
-vte_terminal_set_geometry_hints_for_window(VteTerminal *terminal,
-                                           GtkWindow *window)
-{
-        GdkGeometry hints;
-
-        g_return_if_fail(VTE_IS_TERMINAL(terminal));
-        g_return_if_fail(gtk_widget_get_realized(&terminal->widget));
-
-        vte_terminal_get_geometry_hints(terminal, &hints, MIN_ROWS, MIN_COLUMNS);
-        gtk_window_set_geometry_hints(window,
-                                      &terminal->widget,
-                                      &hints,
-                                      (GdkWindowHints)(GDK_HINT_RESIZE_INC |
-                                                       GDK_HINT_MIN_SIZE |
-                                                       GDK_HINT_BASE_SIZE));
-}
-
 /**
  * vte_terminal_set_input_enabled:
  * @terminal: a #VteTerminal
@@ -13327,57 +13196,3 @@ vte_terminal_get_word_char_exceptions(VteTerminal *terminal)
 
         return terminal->pvt->word_char_exceptions_string;
 }
-
-/**
- * vte_get_major_version:
- *
- * Returns the major version of the VTE library at runtime.
- * Contrast this with %VTE_MAJOR_VERSION which represents
- * the version of the VTE library that the code was compiled
- * with.
- *
- * Returns: the major version
- *
- * Since: 0.40
- */
-guint
-vte_get_major_version (void)
-{
-        return VTE_MAJOR_VERSION;
-}
-
-/**
- * vte_get_minor_version:
- *
- * Returns the minor version of the VTE library at runtime.
- * Contrast this with %VTE_MINOR_VERSION which represents
- * the version of the VTE library that the code was compiled
- * with.
- *
- * Returns: the minor version
- *
- * Since: 0.40
- */
-guint
-vte_get_minor_version (void)
-{
-        return VTE_MINOR_VERSION;
-}
-
-/**
- * vte_get_micro_version:
- *
- * Returns the micro version of the VTE library at runtime.
- * Contrast this with %VTE_MICRO_VERSION which represents
- * the version of the VTE library that the code was compiled
- * with.
- *
- * Returns: the micro version
- *
- * Since: 0.40
- */
-guint
-vte_get_micro_version (void)
-{
-        return VTE_MICRO_VERSION;
-}
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 375ae25..0453aeb 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -27,6 +27,8 @@
 
 #include <new> /* placement new */
 
+#include <pwd.h>
+
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
@@ -1403,3 +1405,185 @@ vte_terminal_class_init(VteTerminalClass *klass)
         /* a11y */
         gtk_widget_class_set_accessible_type(widget_class, VTE_TYPE_TERMINAL_ACCESSIBLE);
 }
+
+/* public API */
+
+/**
+ * vte_get_features:
+ *
+ * Gets a list of features vte was compiled with.
+ *
+ * Returns: (transfer none): a string with features
+ *
+ * Since: 0.40
+ */
+const char *
+vte_get_features (void)
+{
+        return
+#ifdef WITH_GNUTLS
+                "+GNUTLS"
+#else
+                "-GNUTLS"
+#endif
+                " "
+#ifdef WITH_PCRE2
+                "+PCRE2"
+#else
+                "-PCRE2"
+#endif
+                ;
+}
+
+/**
+ * vte_get_major_version:
+ *
+ * Returns the major version of the VTE library at runtime.
+ * Contrast this with %VTE_MAJOR_VERSION which represents
+ * the version of the VTE library that the code was compiled
+ * with.
+ *
+ * Returns: the major version
+ *
+ * Since: 0.40
+ */
+guint
+vte_get_major_version (void)
+{
+        return VTE_MAJOR_VERSION;
+}
+
+/**
+ * vte_get_minor_version:
+ *
+ * Returns the minor version of the VTE library at runtime.
+ * Contrast this with %VTE_MINOR_VERSION which represents
+ * the version of the VTE library that the code was compiled
+ * with.
+ *
+ * Returns: the minor version
+ *
+ * Since: 0.40
+ */
+guint
+vte_get_minor_version (void)
+{
+        return VTE_MINOR_VERSION;
+}
+
+/**
+ * vte_get_micro_version:
+ *
+ * Returns the micro version of the VTE library at runtime.
+ * Contrast this with %VTE_MICRO_VERSION which represents
+ * the version of the VTE library that the code was compiled
+ * with.
+ *
+ * Returns: the micro version
+ *
+ * Since: 0.40
+ */
+guint
+vte_get_micro_version (void)
+{
+        return VTE_MICRO_VERSION;
+}
+
+/**
+ * vte_get_user_shell:
+ *
+ * Gets the user's shell, or %NULL. In the latter case, the
+ * system default (usually "/bin/sh") should be used.
+ *
+ * Returns: (transfer full) (type filename): a newly allocated string with the
+ *   user's shell, or %NULL
+ */
+char *
+vte_get_user_shell (void)
+{
+       struct passwd *pwd;
+
+       pwd = getpwuid(getuid());
+        if (pwd && pwd->pw_shell)
+                return g_strdup (pwd->pw_shell);
+
+        return NULL;
+}
+
+/* VteTerminal public API */
+
+/* Just some arbitrary minimum values */
+#define MIN_COLUMNS (16)
+#define MIN_ROWS    (2)
+
+/**
+ * vte_terminal_get_geometry_hints:
+ * @terminal: a #VteTerminal
+ * @hints: (out caller-allocates): a #GdkGeometry to fill in
+ * @min_rows: the minimum number of rows to request
+ * @min_columns: the minimum number of columns to request
+ *
+ * Fills in some @hints from @terminal's geometry. The hints
+ * filled are those covered by the %GDK_HINT_RESIZE_INC,
+ * %GDK_HINT_MIN_SIZE and %GDK_HINT_BASE_SIZE flags.
+ *
+ * See gtk_window_set_geometry_hints() for more information.
+ *
+ * @terminal must be realized (see gtk_widget_get_realized()).
+ */
+void
+vte_terminal_get_geometry_hints(VteTerminal *terminal,
+                                GdkGeometry *hints,
+                                int min_rows,
+                                int min_columns)
+{
+        VteTerminalPrivate *pvt;
+        GtkWidget *widget;
+        GtkBorder padding;
+
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        g_return_if_fail(hints != NULL);
+        widget = &terminal->widget;
+        g_return_if_fail(gtk_widget_get_realized(widget));
+
+        pvt = terminal->pvt;
+
+        gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
+                                      gtk_widget_get_state_flags(widget),
+                                      &padding);
+
+        hints->base_width  = padding.left + padding.right;
+        hints->base_height = padding.top  + padding.bottom;
+        hints->width_inc   = pvt->char_width;
+        hints->height_inc  = pvt->char_height;
+        hints->min_width   = hints->base_width  + hints->width_inc  * min_columns;
+        hints->min_height  = hints->base_height + hints->height_inc * min_rows;
+}
+
+/**
+ * vte_terminal_set_geometry_hints_for_window:
+ * @terminal: a #VteTerminal
+ * @window: a #GtkWindow
+ *
+ * Sets @terminal as @window's geometry widget. See
+ * gtk_window_set_geometry_hints() for more information.
+ *
+ * @terminal must be realized (see gtk_widget_get_realized()).
+ */
+void
+vte_terminal_set_geometry_hints_for_window(VteTerminal *terminal,
+                                           GtkWindow *window)
+{
+        GdkGeometry hints;
+
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        g_return_if_fail(gtk_widget_get_realized(&terminal->widget));
+
+        vte_terminal_get_geometry_hints(terminal, &hints, MIN_ROWS, MIN_COLUMNS);
+        gtk_window_set_geometry_hints(window,
+                                      &terminal->widget,
+                                      &hints,
+                                      (GdkWindowHints)(GDK_HINT_RESIZE_INC |
+                                                       GDK_HINT_MIN_SIZE |
+                                                       GDK_HINT_BASE_SIZE));
+}


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