[tepl] Tab: integrate a TeplGotoLineBar



commit c206b1145d096cb064398101381dd48ce0de520b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Apr 24 18:39:57 2020 +0200

    Tab: integrate a TeplGotoLineBar

 docs/reference/tepl-sections.txt |  1 +
 tepl/tepl-tab.c                  | 40 ++++++++++++++++++++++++++++++++++++++++
 tepl/tepl-tab.h                  | 11 ++++++++++-
 3 files changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/tepl-sections.txt b/docs/reference/tepl-sections.txt
index 87d7bea..dc21387 100644
--- a/docs/reference/tepl-sections.txt
+++ b/docs/reference/tepl-sections.txt
@@ -403,6 +403,7 @@ tepl_tab_new
 tepl_tab_new_with_view
 tepl_tab_get_view
 tepl_tab_get_buffer
+tepl_tab_get_goto_line_bar
 tepl_tab_add_info_bar
 tepl_tab_load_file
 tepl_tab_save_async
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index 9cb7cd1..019a2dc 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -66,6 +66,7 @@
 struct _TeplTabPrivate
 {
        TeplView *view;
+       TeplGotoLineBar *goto_line_bar;
 };
 
 enum
@@ -171,6 +172,13 @@ tepl_tab_pack_info_bar_default (TeplTab    *tab,
        }
 }
 
+static void
+tepl_tab_pack_goto_line_bar_default (TeplTab         *tab,
+                                    TeplGotoLineBar *goto_line_bar)
+{
+       gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (goto_line_bar));
+}
+
 static void
 close_confirm_dialog_single_cb (GObject      *source_object,
                                GAsyncResult *result,
@@ -289,6 +297,7 @@ tepl_tab_dispose (GObject *object)
        TeplTab *tab = TEPL_TAB (object);
 
        g_clear_object (&tab->priv->view);
+       g_clear_object (&tab->priv->goto_line_bar);
 
        G_OBJECT_CLASS (tepl_tab_parent_class)->dispose (object);
 }
@@ -304,6 +313,7 @@ tepl_tab_class_init (TeplTabClass *klass)
 
        klass->pack_view = tepl_tab_pack_view_default;
        klass->pack_info_bar = tepl_tab_pack_info_bar_default;
+       klass->pack_goto_line_bar = tepl_tab_pack_goto_line_bar_default;
        klass->close_request = tepl_tab_close_request_default;
 
        /**
@@ -456,6 +466,36 @@ tepl_tab_get_buffer (TeplTab *tab)
        return TEPL_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->view)));
 }
 
+/**
+ * tepl_tab_get_goto_line_bar:
+ * @tab: a #TeplTab.
+ *
+ * Gets the #TeplGotoLineBar widget belonging to @tab. The #TeplGotoLineBar must
+ * not be destroyed by the application, the purpose of this function is to
+ * show/hide the widget.
+ *
+ * Returns: (transfer none): the #TeplGotoLineBar widget belonging to @tab.
+ * Since: 5.0
+ */
+TeplGotoLineBar *
+tepl_tab_get_goto_line_bar (TeplTab *tab)
+{
+       g_return_val_if_fail (TEPL_IS_TAB (tab), NULL);
+
+       if (tab->priv->goto_line_bar == NULL)
+       {
+               tab->priv->goto_line_bar = tepl_goto_line_bar_new ();
+               g_object_ref_sink (tab->priv->goto_line_bar);
+
+               tepl_goto_line_bar_set_view (tab->priv->goto_line_bar,
+                                            tab->priv->view);
+
+               TEPL_TAB_GET_CLASS (tab)->pack_goto_line_bar (tab, tab->priv->goto_line_bar);
+       }
+
+       return tab->priv->goto_line_bar;
+}
+
 /**
  * tepl_tab_add_info_bar:
  * @tab: a #TeplTab.
diff --git a/tepl/tepl-tab.h b/tepl/tepl-tab.h
index 12e069b..dfc2c2a 100644
--- a/tepl/tepl-tab.h
+++ b/tepl/tepl-tab.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of Tepl, a text editor library.
  *
- * Copyright 2016, 2017 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016-2020 - Sébastien Wilmet <swilmet gnome org>
  *
  * Tepl is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include <tepl/tepl-buffer.h>
 #include <tepl/tepl-view.h>
+#include <tepl/tepl-goto-line-bar.h>
 
 G_BEGIN_DECLS
 
@@ -61,6 +62,9 @@ struct _TeplTab
  *   non-#GtkInfoBar child widget of #TeplTab (so by default it is inserted
  *   below other #GtkInfoBar's, but above the #GtkScrolledWindow containing the
  *   #TeplView).
+ * @pack_goto_line_bar: Virtual function pointer to add a #TeplGotoLineBar in
+ *   the #TeplTab container. By default the #TeplGotoLineBar is added at the
+ *   bottom.
  * @close_request: For the #TeplTab::close-request signal.
  */
 struct _TeplTabClass
@@ -75,6 +79,9 @@ struct _TeplTabClass
        void    (* pack_info_bar)       (TeplTab    *tab,
                                         GtkInfoBar *info_bar);
 
+       void    (* pack_goto_line_bar)  (TeplTab         *tab,
+                                        TeplGotoLineBar *goto_line_bar);
+
        /* Signals */
 
        void    (* close_request)       (TeplTab *tab);
@@ -93,6 +100,8 @@ TeplView *   tepl_tab_get_view               (TeplTab *tab);
 
 TeplBuffer *   tepl_tab_get_buffer             (TeplTab *tab);
 
+TeplGotoLineBar *tepl_tab_get_goto_line_bar    (TeplTab *tab);
+
 void           tepl_tab_add_info_bar           (TeplTab    *tab,
                                                 GtkInfoBar *info_bar);
 


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