[devhelp] Add DhNotebook basic class



commit 538d14b8fe97a6d6a3ae76fbeb6501f800a3dce1
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri May 25 13:39:25 2018 +0200

    Add DhNotebook basic class
    
    More code will be moved from DhWindow to DhNotebook by later commits.

 po/POTFILES.in    |  1 +
 src/dh-notebook.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/dh-notebook.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/meson.build   |  1 +
 4 files changed, 130 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8d21a82f..934a9f7b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -31,6 +31,7 @@ src/dh-app.c
 src/dh-assistant.c
 src/dh-assistant.ui
 src/dh-main.c
+src/dh-notebook.c
 src/dh-preferences.c
 src/dh-preferences.ui
 src/dh-settings-app.c
diff --git a/src/dh-notebook.c b/src/dh-notebook.c
new file mode 100644
index 00000000..0935fe25
--- /dev/null
+++ b/src/dh-notebook.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * This file is part of Devhelp.
+ *
+ * Copyright (C) 2018 Sébastien Wilmet <swilmet gnome org>
+ *
+ * Devhelp is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Devhelp is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Devhelp.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "dh-notebook.h"
+
+G_DEFINE_TYPE (DhNotebook, dh_notebook, GTK_TYPE_NOTEBOOK)
+
+static void
+dh_notebook_class_init (DhNotebookClass *klass)
+{
+}
+
+static void
+dh_notebook_init (DhNotebook *notebook)
+{
+        gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
+}
+
+DhNotebook *
+dh_notebook_new (void)
+{
+        return g_object_new (DH_TYPE_NOTEBOOK, NULL);
+}
+
+/* Returns: (transfer none) (nullable): */
+DhTab *
+dh_notebook_get_active_tab (DhNotebook *notebook)
+{
+        gint page_num;
+
+        g_return_val_if_fail (DH_IS_NOTEBOOK (notebook), NULL);
+
+        page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+        if (page_num == -1)
+                return NULL;
+
+        return DH_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num));
+}
+
+/* Returns: (transfer none) (nullable): */
+DhWebView *
+dh_notebook_get_active_web_view (DhNotebook *notebook)
+{
+        DhTab *tab;
+
+        g_return_val_if_fail (DH_IS_NOTEBOOK (notebook), NULL);
+
+        tab = dh_notebook_get_active_tab (notebook);
+        return tab != NULL ? dh_tab_get_web_view (tab) : NULL;
+}
diff --git a/src/dh-notebook.h b/src/dh-notebook.h
new file mode 100644
index 00000000..c48d4618
--- /dev/null
+++ b/src/dh-notebook.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * This file is part of Devhelp.
+ *
+ * Copyright (C) 2018 Sébastien Wilmet <swilmet gnome org>
+ *
+ * Devhelp is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Devhelp is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Devhelp.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DH_NOTEBOOK_H
+#define DH_NOTEBOOK_H
+
+#include <gtk/gtk.h>
+#include "dh-tab.h"
+#include "dh-web-view.h"
+
+G_BEGIN_DECLS
+
+#define DH_TYPE_NOTEBOOK             (dh_notebook_get_type ())
+#define DH_NOTEBOOK(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_NOTEBOOK, DhNotebook))
+#define DH_NOTEBOOK_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_NOTEBOOK, DhNotebookClass))
+#define DH_IS_NOTEBOOK(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_NOTEBOOK))
+#define DH_IS_NOTEBOOK_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_NOTEBOOK))
+#define DH_NOTEBOOK_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_NOTEBOOK, DhNotebookClass))
+
+typedef struct _DhNotebook         DhNotebook;
+typedef struct _DhNotebookClass    DhNotebookClass;
+
+struct _DhNotebook {
+        GtkNotebook parent;
+};
+
+struct _DhNotebookClass {
+        GtkNotebookClass parent_class;
+
+        /* Padding for future expansion */
+        gpointer padding[12];
+};
+
+GType           dh_notebook_get_type                    (void);
+
+DhNotebook *    dh_notebook_new                         (void);
+
+DhTab *         dh_notebook_get_active_tab              (DhNotebook *notebook);
+
+DhWebView *     dh_notebook_get_active_web_view         (DhNotebook *notebook);
+
+G_END_DECLS
+
+#endif /* DH_NOTEBOOK_H */
diff --git a/src/meson.build b/src/meson.build
index 67e53ef8..3122f3da 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -2,6 +2,7 @@ devhelp_app_sources = [
         'dh-app.c',
         'dh-assistant.c',
         'dh-main.c',
+        'dh-notebook.c',
         'dh-preferences.c',
         'dh-settings-app.c',
         'dh-tab.c',


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