[devhelp] Revert "modernize the code base"
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Revert "modernize the code base"
- Date: Fri, 21 Sep 2018 13:52:45 +0000 (UTC)
commit 4bb853c39b5e8aecad1189632e6a084d56923339
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Sep 21 15:26:40 2018 +0200
Revert "modernize the code base"
And revert also "fix build error for missing private struct"
This reverts commit 9946209fb75d90526a8dba2e640e5dd43097d6d3.
This reverts commit 4f65b8c38f1e7ee3328b67caea61e5a589796ad9.
In the end I will continue to develop Devhelp. I don't like certain new
GLib features, it's documented in the HACKING file.
devhelp/dh-application-window.h | 4 +-
devhelp/dh-assistant-view.h | 32 +++++++--
devhelp/dh-book-list-builder.c | 28 ++++----
devhelp/dh-book-list-builder.h | 41 +++++++++---
devhelp/dh-book-list-directory.c | 57 ++++++++--------
devhelp/dh-book-list-directory.h | 27 ++++++--
devhelp/dh-book-list-simple.c | 43 ++++++-------
devhelp/dh-book-list-simple.h | 30 +++++++--
devhelp/dh-book-list.c | 30 ++++-----
devhelp/dh-book-list.h | 47 +++++++++++---
devhelp/dh-book-manager.c | 4 --
devhelp/dh-book-manager.h | 31 +++++++--
devhelp/dh-book-tree.c | 10 +--
devhelp/dh-book-tree.h | 38 +++++++++--
devhelp/dh-book.h | 48 ++++++++++----
devhelp/dh-completion.c | 23 +++----
devhelp/dh-completion.h | 42 +++++++++---
devhelp/dh-keyword-model.c | 4 --
devhelp/dh-keyword-model.h | 37 +++++++++--
devhelp/dh-link.h | 4 +-
devhelp/dh-notebook.c | 23 +++----
devhelp/dh-notebook.h | 43 ++++++++++---
devhelp/dh-parser.h | 4 +-
devhelp/dh-profile-builder.c | 32 ++++-----
devhelp/dh-profile-builder.h | 44 ++++++++++---
devhelp/dh-profile.c | 25 +++----
devhelp/dh-profile.h | 45 ++++++++++---
devhelp/dh-search-bar.c | 61 ++++++------------
devhelp/dh-search-bar.h | 27 ++++++--
devhelp/dh-search-context.h | 4 +-
devhelp/dh-settings-builder.c | 28 ++++----
devhelp/dh-settings-builder.h | 48 +++++++++++---
devhelp/dh-settings.c | 136 ++++++++++++++++-----------------------
devhelp/dh-settings.h | 97 +++++++++++++++++++---------
devhelp/dh-sidebar.h | 18 +++++-
devhelp/dh-tab-label.c | 50 +++++++-------
devhelp/dh-tab-label.h | 34 ++++++++--
devhelp/dh-tab.c | 20 +++---
devhelp/dh-tab.h | 35 ++++++++--
devhelp/dh-util-lib.h | 4 +-
devhelp/dh-web-view.c | 58 +++++++----------
devhelp/dh-web-view.h | 59 ++++++++++++-----
src/dh-app.c | 6 +-
src/dh-app.h | 27 ++++++--
src/dh-assistant.c | 2 +-
src/dh-main.c | 3 +-
src/dh-preferences.c | 1 -
src/dh-preferences.h | 20 +++++-
src/dh-settings-app.c | 35 ++++------
src/dh-settings-app.h | 33 ++++++++--
src/dh-window.c | 4 +-
src/dh-window.h | 29 +++++++--
52 files changed, 1034 insertions(+), 601 deletions(-)
---
diff --git a/devhelp/dh-application-window.h b/devhelp/dh-application-window.h
index 106191e8..2005b713 100644
--- a/devhelp/dh-application-window.h
+++ b/devhelp/dh-application-window.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_APPLICATION_WINDOW_H
+#define DH_APPLICATION_WINDOW_H
#include <glib.h>
#include <devhelp/dh-notebook.h>
@@ -31,3 +32,4 @@ void dh_application_window_bind_sidebar_and_notebook (DhSidebar *sid
G_END_DECLS
+#endif /* DH_APPLICATION_WINDOW_H */
diff --git a/devhelp/dh-assistant-view.h b/devhelp/dh-assistant-view.h
index 12c53922..602206f2 100644
--- a/devhelp/dh-assistant-view.h
+++ b/devhelp/dh-assistant-view.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_ASSISTANT_VIEW_H
+#define DH_ASSISTANT_VIEW_H
#include <webkit2/webkit2.h>
#include <devhelp/dh-link.h>
@@ -26,7 +27,18 @@
G_BEGIN_DECLS
#define DH_TYPE_ASSISTANT_VIEW (dh_assistant_view_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhAssistantView, dh_assistant_view, DH, ASSISTANT_VIEW, WebKitWebView)
+#define DH_ASSISTANT_VIEW(i) (G_TYPE_CHECK_INSTANCE_CAST ((i), DH_TYPE_ASSISTANT_VIEW,
DhAssistantView))
+#define DH_ASSISTANT_VIEW_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), DH_TYPE_ASSISTANT_VIEW,
DhAssistantViewClass))
+#define DH_IS_ASSISTANT_VIEW(i) (G_TYPE_CHECK_INSTANCE_TYPE ((i), DH_TYPE_ASSISTANT_VIEW))
+#define DH_IS_ASSISTANT_VIEW_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), DH_ASSISTANT_VIEW))
+#define DH_ASSISTANT_VIEW_GET_CLASS(i) (G_TYPE_INSTANCE_GET_CLASS ((i), DH_TYPE_ASSISTANT_VIEW,
DhAssistantView))
+
+typedef struct _DhAssistantView DhAssistantView;
+typedef struct _DhAssistantViewClass DhAssistantViewClass;
+
+struct _DhAssistantView {
+ WebKitWebView parent_instance;
+};
struct _DhAssistantViewClass {
WebKitWebViewClass parent_class;
@@ -35,10 +47,16 @@ struct _DhAssistantViewClass {
gpointer padding[12];
};
-GtkWidget *dh_assistant_view_new (void);
-gboolean dh_assistant_view_set_link (DhAssistantView *view,
- DhLink *link);
-gboolean dh_assistant_view_search (DhAssistantView *view,
- const gchar *str);
+GType dh_assistant_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget * dh_assistant_view_new (void);
+
+gboolean dh_assistant_view_set_link (DhAssistantView *view,
+ DhLink *link);
+
+gboolean dh_assistant_view_search (DhAssistantView *view,
+ const gchar *str);
+
G_END_DECLS
+#endif /* DH_ASSISTANT_VIEW_H */
diff --git a/devhelp/dh-book-list-builder.c b/devhelp/dh-book-list-builder.c
index 0f385e32..14dbf4e3 100644
--- a/devhelp/dh-book-list-builder.c
+++ b/devhelp/dh-book-list-builder.c
@@ -38,12 +38,12 @@
* but it is implemented in a simpler way, to have less boilerplate.
*/
-typedef struct {
+struct _DhBookListBuilderPrivate {
/* List of DhBookList*. */
GList *sub_book_lists;
DhSettings *settings;
-} DhBookListBuilderPrivate;
+};
G_DEFINE_TYPE_WITH_PRIVATE (DhBookListBuilder, dh_book_list_builder, G_TYPE_OBJECT)
@@ -51,12 +51,11 @@ static void
dh_book_list_builder_dispose (GObject *object)
{
DhBookListBuilder *builder = DH_BOOK_LIST_BUILDER (object);
- DhBookListBuilderPrivate *priv = dh_book_list_builder_get_instance_private (builder);
- g_list_free_full (priv->sub_book_lists, g_object_unref);
- priv->sub_book_lists = NULL;
+ g_list_free_full (builder->priv->sub_book_lists, g_object_unref);
+ builder->priv->sub_book_lists = NULL;
- g_clear_object (&priv->settings);
+ g_clear_object (&builder->priv->settings);
G_OBJECT_CLASS (dh_book_list_builder_parent_class)->dispose (object);
}
@@ -72,6 +71,7 @@ dh_book_list_builder_class_init (DhBookListBuilderClass *klass)
static void
dh_book_list_builder_init (DhBookListBuilder *builder)
{
+ builder->priv = dh_book_list_builder_get_instance_private (builder);
}
/**
@@ -106,13 +106,11 @@ void
dh_book_list_builder_add_sub_book_list (DhBookListBuilder *builder,
DhBookList *sub_book_list)
{
- DhBookListBuilderPrivate *priv = dh_book_list_builder_get_instance_private (builder);
-
g_return_if_fail (DH_IS_BOOK_LIST_BUILDER (builder));
g_return_if_fail (DH_IS_BOOK_LIST (sub_book_list));
- priv->sub_book_lists = g_list_append (priv->sub_book_lists,
- g_object_ref (sub_book_list));
+ builder->priv->sub_book_lists = g_list_append (builder->priv->sub_book_lists,
+ g_object_ref (sub_book_list));
}
static void
@@ -235,12 +233,10 @@ void
dh_book_list_builder_read_books_disabled_setting (DhBookListBuilder *builder,
DhSettings *settings)
{
- DhBookListBuilderPrivate *priv = dh_book_list_builder_get_instance_private (builder);
-
g_return_if_fail (DH_IS_BOOK_LIST_BUILDER (builder));
g_return_if_fail (settings == NULL || DH_IS_SETTINGS (settings));
- g_set_object (&priv->settings, settings);
+ g_set_object (&builder->priv->settings, settings);
}
/**
@@ -256,10 +252,8 @@ dh_book_list_builder_read_books_disabled_setting (DhBookListBuilder *builder,
DhBookList *
dh_book_list_builder_create_object (DhBookListBuilder *builder)
{
- DhBookListBuilderPrivate *priv = dh_book_list_builder_get_instance_private (builder);
-
g_return_val_if_fail (DH_IS_BOOK_LIST_BUILDER (builder), NULL);
- return _dh_book_list_simple_new (priv->sub_book_lists,
- priv->settings);
+ return _dh_book_list_simple_new (builder->priv->sub_book_lists,
+ builder->priv->settings);
}
diff --git a/devhelp/dh-book-list-builder.h b/devhelp/dh-book-list-builder.h
index 243b0ce8..395149e7 100644
--- a/devhelp/dh-book-list-builder.h
+++ b/devhelp/dh-book-list-builder.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_LIST_BUILDER_H
+#define DH_BOOK_LIST_BUILDER_H
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -27,7 +28,21 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST_BUILDER (dh_book_list_builder_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhBookListBuilder, dh_book_list_builder, DH, BOOK_LIST_BUILDER, GObject)
+#define DH_BOOK_LIST_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_BOOK_LIST_BUILDER,
DhBookListBuilder))
+#define DH_BOOK_LIST_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_BOOK_LIST_BUILDER,
DhBookListBuilderClass))
+#define DH_IS_BOOK_LIST_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_BOOK_LIST_BUILDER))
+#define DH_IS_BOOK_LIST_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_BOOK_LIST_BUILDER))
+#define DH_BOOK_LIST_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_BOOK_LIST_BUILDER,
DhBookListBuilderClass))
+
+typedef struct _DhBookListBuilder DhBookListBuilder;
+typedef struct _DhBookListBuilderClass DhBookListBuilderClass;
+typedef struct _DhBookListBuilderPrivate DhBookListBuilderPrivate;
+
+struct _DhBookListBuilder {
+ GObject parent;
+
+ DhBookListBuilderPrivate *priv;
+};
struct _DhBookListBuilderClass {
GObjectClass parent_class;
@@ -36,13 +51,21 @@ struct _DhBookListBuilderClass {
gpointer padding[12];
};
-DhBookListBuilder *dh_book_list_builder_new (void);
-void dh_book_list_builder_add_sub_book_list (DhBookListBuilder *builder,
- DhBookList *sub_book_list);
-void dh_book_list_builder_add_default_sub_book_lists (DhBookListBuilder *builder);
-void dh_book_list_builder_read_books_disabled_setting (DhBookListBuilder *builder,
- DhSettings *settings);
-DhBookList *dh_book_list_builder_create_object (DhBookListBuilder *builder);
+GType dh_book_list_builder_get_type (void);
+
+DhBookListBuilder *
+ dh_book_list_builder_new (void);
+
+void dh_book_list_builder_add_sub_book_list (DhBookListBuilder *builder,
+ DhBookList *sub_book_list);
+
+void dh_book_list_builder_add_default_sub_book_lists (DhBookListBuilder *builder);
+
+void dh_book_list_builder_read_books_disabled_setting (DhBookListBuilder *builder,
+ DhSettings *settings);
+
+DhBookList * dh_book_list_builder_create_object (DhBookListBuilder *builder);
G_END_DECLS
+#endif /* DH_BOOK_LIST_BUILDER_H */
diff --git a/devhelp/dh-book-list-directory.c b/devhelp/dh-book-list-directory.c
index 5e0ac0e5..a61c05c5 100644
--- a/devhelp/dh-book-list-directory.c
+++ b/devhelp/dh-book-list-directory.c
@@ -61,13 +61,13 @@ typedef struct {
guint timeout_id;
} NewPossibleBookData;
-typedef struct {
+struct _DhBookListDirectoryPrivate {
GFile *directory;
GFileMonitor *directory_monitor;
/* List of NewPossibleBookData* */
GSList *new_possible_books_data;
-} DhBookListDirectoryPrivate;
+};
enum {
PROP_0,
@@ -219,7 +219,7 @@ static gboolean
new_possible_book_timeout_cb (gpointer user_data)
{
NewPossibleBookData *data = user_data;
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private
(data->list_directory);
+ DhBookListDirectoryPrivate *priv = data->list_directory->priv;
data->timeout_id = 0;
@@ -238,7 +238,7 @@ books_directory_changed_cb (GFileMonitor *directory_monitor,
GFileMonitorEvent event_type,
DhBookListDirectory *list_directory)
{
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
+ DhBookListDirectoryPrivate *priv = list_directory->priv;
NewPossibleBookData *data;
/* With the GFileMonitor here we only handle events for new directories
@@ -266,18 +266,17 @@ static void
monitor_books_directory (DhBookListDirectory *list_directory)
{
GError *error = NULL;
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
- g_assert (priv->directory_monitor == NULL);
- priv->directory_monitor = g_file_monitor_directory (priv->directory,
- G_FILE_MONITOR_NONE,
- NULL,
- &error);
+ g_assert (list_directory->priv->directory_monitor == NULL);
+ list_directory->priv->directory_monitor = g_file_monitor_directory (list_directory->priv->directory,
+ G_FILE_MONITOR_NONE,
+ NULL,
+ &error);
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (priv->directory);
+ parse_name = g_file_get_parse_name (list_directory->priv->directory);
g_warning ("Failed to create file monitor on directory “%s”: %s",
parse_name,
@@ -287,8 +286,8 @@ monitor_books_directory (DhBookListDirectory *list_directory)
g_clear_error (&error);
}
- if (priv->directory_monitor != NULL) {
- g_signal_connect_object (priv->directory_monitor,
+ if (list_directory->priv->directory_monitor != NULL) {
+ g_signal_connect_object (list_directory->priv->directory_monitor,
"changed",
G_CALLBACK (books_directory_changed_cb),
list_directory,
@@ -301,9 +300,8 @@ find_books (DhBookListDirectory *list_directory)
{
GFileEnumerator *enumerator;
GError *error = NULL;
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
- enumerator = g_file_enumerate_children (priv->directory,
+ enumerator = g_file_enumerate_children (list_directory->priv->directory,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
NULL,
@@ -317,7 +315,7 @@ find_books (DhBookListDirectory *list_directory)
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (priv->directory);
+ parse_name = g_file_get_parse_name (list_directory->priv->directory);
g_warning ("Error when reading directory '%s': %s",
parse_name,
@@ -338,7 +336,7 @@ find_books (DhBookListDirectory *list_directory)
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (priv->directory);
+ parse_name = g_file_get_parse_name (list_directory->priv->directory);
g_warning ("Error when enumerating directory '%s': %s",
parse_name,
@@ -363,11 +361,10 @@ static void
set_directory (DhBookListDirectory *list_directory,
GFile *directory)
{
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
- g_assert (priv->directory == NULL);
+ g_assert (list_directory->priv->directory == NULL);
g_return_if_fail (G_IS_FILE (directory));
- priv->directory = g_object_ref (directory);
+ list_directory->priv->directory = g_object_ref (directory);
find_books (list_directory);
}
@@ -413,13 +410,12 @@ static void
dh_book_list_directory_dispose (GObject *object)
{
DhBookListDirectory *list_directory = DH_BOOK_LIST_DIRECTORY (object);
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
- g_clear_object (&priv->directory);
- g_clear_object (&priv->directory_monitor);
+ g_clear_object (&list_directory->priv->directory);
+ g_clear_object (&list_directory->priv->directory_monitor);
- g_slist_free_full (priv->new_possible_books_data, new_possible_book_data_free);
- priv->new_possible_books_data = NULL;
+ g_slist_free_full (list_directory->priv->new_possible_books_data, new_possible_book_data_free);
+ list_directory->priv->new_possible_books_data = NULL;
G_OBJECT_CLASS (dh_book_list_directory_parent_class)->dispose (object);
}
@@ -466,6 +462,8 @@ dh_book_list_directory_class_init (DhBookListDirectoryClass *klass)
static void
dh_book_list_directory_init (DhBookListDirectory *list_directory)
{
+ list_directory->priv = dh_book_list_directory_get_instance_private (list_directory);
+
instances = g_list_prepend (instances, list_directory);
}
@@ -495,10 +493,9 @@ dh_book_list_directory_new (GFile *directory)
for (l = instances; l != NULL; l = l->next) {
DhBookListDirectory *cur_list_directory = DH_BOOK_LIST_DIRECTORY (l->data);
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private
(cur_list_directory);
- if (priv->directory != NULL &&
- g_file_equal (priv->directory, directory))
+ if (cur_list_directory->priv->directory != NULL &&
+ g_file_equal (cur_list_directory->priv->directory, directory))
return g_object_ref (cur_list_directory);
}
@@ -517,9 +514,7 @@ dh_book_list_directory_new (GFile *directory)
GFile *
dh_book_list_directory_get_directory (DhBookListDirectory *list_directory)
{
- DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
-
g_return_val_if_fail (DH_IS_BOOK_LIST_DIRECTORY (list_directory), NULL);
- return priv->directory;
+ return list_directory->priv->directory;
}
diff --git a/devhelp/dh-book-list-directory.h b/devhelp/dh-book-list-directory.h
index bc732c29..1aade54f 100644
--- a/devhelp/dh-book-list-directory.h
+++ b/devhelp/dh-book-list-directory.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_LIST_DIRECTORY_H
+#define DH_BOOK_LIST_DIRECTORY_H
#include <gio/gio.h>
#include <devhelp/dh-book-list.h>
@@ -26,7 +27,21 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST_DIRECTORY (dh_book_list_directory_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhBookListDirectory, dh_book_list_directory, DH, BOOK_LIST_DIRECTORY, DhBookList)
+#define DH_BOOK_LIST_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
DH_TYPE_BOOK_LIST_DIRECTORY, DhBookListDirectory))
+#define DH_BOOK_LIST_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
DH_TYPE_BOOK_LIST_DIRECTORY, DhBookListDirectoryClass))
+#define DH_IS_BOOK_LIST_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
DH_TYPE_BOOK_LIST_DIRECTORY))
+#define DH_IS_BOOK_LIST_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
DH_TYPE_BOOK_LIST_DIRECTORY))
+#define DH_BOOK_LIST_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
DH_TYPE_BOOK_LIST_DIRECTORY, DhBookListDirectoryClass))
+
+typedef struct _DhBookListDirectory DhBookListDirectory;
+typedef struct _DhBookListDirectoryClass DhBookListDirectoryClass;
+typedef struct _DhBookListDirectoryPrivate DhBookListDirectoryPrivate;
+
+struct _DhBookListDirectory {
+ DhBookList parent;
+
+ DhBookListDirectoryPrivate *priv;
+};
struct _DhBookListDirectoryClass {
DhBookListClass parent_class;
@@ -35,8 +50,12 @@ struct _DhBookListDirectoryClass {
gpointer padding[12];
};
-DhBookListDirectory *dh_book_list_directory_new (GFile *directory);
-GFile *dh_book_list_directory_get_directory (DhBookListDirectory *list_directory);
+GType dh_book_list_directory_get_type (void);
+
+DhBookListDirectory * dh_book_list_directory_new (GFile *directory);
+
+GFile * dh_book_list_directory_get_directory (DhBookListDirectory *list_directory);
G_END_DECLS
+#endif /* DH_BOOK_LIST_DIRECTORY_H */
diff --git a/devhelp/dh-book-list-simple.c b/devhelp/dh-book-list-simple.c
index 4770fc38..de476ffe 100644
--- a/devhelp/dh-book-list-simple.c
+++ b/devhelp/dh-book-list-simple.c
@@ -20,15 +20,15 @@
#include "dh-book-list-simple.h"
-typedef struct {
+struct _DhBookListSimplePrivate {
/* List of DhBookList*. */
GList *sub_book_lists;
/* For reading the "books-disabled" GSettings key. */
DhSettings *settings;
-} DhBookListSimplePrivate;
+};
-G_DEFINE_TYPE_WITH_PRIVATE (DhBookListSimple, dh_book_list_simple, DH_TYPE_BOOK_LIST)
+G_DEFINE_TYPE_WITH_PRIVATE (DhBookListSimple, _dh_book_list_simple, DH_TYPE_BOOK_LIST)
static gpointer
book_copy_func (gconstpointer src,
@@ -41,18 +41,17 @@ static void
dh_book_list_simple_dispose (GObject *object)
{
DhBookListSimple *list_simple = DH_BOOK_LIST_SIMPLE (object);
- DhBookListSimplePrivate *priv = dh_book_list_simple_get_instance_private (list_simple);
- g_list_free_full (priv->sub_book_lists, g_object_unref);
- priv->sub_book_lists = NULL;
+ g_list_free_full (list_simple->priv->sub_book_lists, g_object_unref);
+ list_simple->priv->sub_book_lists = NULL;
- g_clear_object (&priv->settings);
+ g_clear_object (&list_simple->priv->settings);
- G_OBJECT_CLASS (dh_book_list_simple_parent_class)->dispose (object);
+ G_OBJECT_CLASS (_dh_book_list_simple_parent_class)->dispose (object);
}
static void
-dh_book_list_simple_class_init (DhBookListSimpleClass *klass)
+_dh_book_list_simple_class_init (DhBookListSimpleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -60,8 +59,9 @@ dh_book_list_simple_class_init (DhBookListSimpleClass *klass)
}
static void
-dh_book_list_simple_init (DhBookListSimple *list_simple)
+_dh_book_list_simple_init (DhBookListSimple *list_simple)
{
+ list_simple->priv = _dh_book_list_simple_get_instance_private (list_simple);
}
/* Returns: the new start of the list. */
@@ -69,17 +69,16 @@ static GList *
filter_by_books_disabled (DhBookListSimple *list_simple,
GList *list)
{
- DhBookListSimplePrivate *priv = dh_book_list_simple_get_instance_private (list_simple);
GList *new_list = NULL;
GList *l;
- if (priv->settings == NULL)
+ if (list_simple->priv->settings == NULL)
return list;
for (l = list; l != NULL; l = l->next) {
DhBook *book = DH_BOOK (l->data);
- if (dh_settings_is_book_enabled (priv->settings, book))
+ if (dh_settings_is_book_enabled (list_simple->priv->settings, book))
new_list = g_list_prepend (new_list, g_object_ref (book));
}
@@ -93,9 +92,8 @@ generate_list (DhBookListSimple *list_simple)
{
GList *ret = NULL;
GList *book_list_node;
- DhBookListSimplePrivate *priv = dh_book_list_simple_get_instance_private (list_simple);
- for (book_list_node = priv->sub_book_lists;
+ for (book_list_node = list_simple->priv->sub_book_lists;
book_list_node != NULL;
book_list_node = book_list_node->next) {
DhBookList *book_list = DH_BOOK_LIST (book_list_node->data);
@@ -105,7 +103,7 @@ generate_list (DhBookListSimple *list_simple)
books = dh_book_list_get_books (book_list);
/* First DhBookList, take all DhBook's. */
- if (book_list_node == priv->sub_book_lists) {
+ if (book_list_node == list_simple->priv->sub_book_lists) {
g_assert (ret == NULL);
ret = g_list_copy_deep (books, book_copy_func, NULL);
continue;
@@ -175,10 +173,9 @@ static void
set_sub_book_lists (DhBookListSimple *list_simple,
GList *sub_book_lists)
{
- DhBookListSimplePrivate *priv = dh_book_list_simple_get_instance_private (list_simple);
GList *l;
- g_assert (priv->sub_book_lists == NULL);
+ g_assert (list_simple->priv->sub_book_lists == NULL);
for (l = sub_book_lists; l != NULL; l = l->next) {
DhBookList *book_list;
@@ -189,8 +186,8 @@ set_sub_book_lists (DhBookListSimple *list_simple,
}
book_list = l->data;
- priv->sub_book_lists = g_list_prepend (priv->sub_book_lists,
- g_object_ref (book_list));
+ list_simple->priv->sub_book_lists = g_list_prepend (list_simple->priv->sub_book_lists,
+ g_object_ref (book_list));
g_signal_connect_object (book_list,
"add-book",
@@ -205,7 +202,7 @@ set_sub_book_lists (DhBookListSimple *list_simple,
G_CONNECT_AFTER);
}
- priv->sub_book_lists = g_list_reverse (priv->sub_book_lists);
+ list_simple->priv->sub_book_lists = g_list_reverse (list_simple->priv->sub_book_lists);
}
static void
@@ -221,16 +218,14 @@ _dh_book_list_simple_new (GList *sub_book_lists,
DhSettings *settings)
{
DhBookListSimple *list_simple;
- DhBookListSimplePrivate *priv;
g_return_val_if_fail (settings == NULL || DH_IS_SETTINGS (settings), NULL);
list_simple = g_object_new (DH_TYPE_BOOK_LIST_SIMPLE, NULL);
- priv = dh_book_list_simple_get_instance_private (list_simple);
set_sub_book_lists (list_simple, sub_book_lists);
if (settings != NULL) {
- priv->settings = g_object_ref (settings);
+ list_simple->priv->settings = g_object_ref (settings);
g_signal_connect_object (settings,
"books-disabled-changed",
diff --git a/devhelp/dh-book-list-simple.h b/devhelp/dh-book-list-simple.h
index 644672f7..414d518e 100644
--- a/devhelp/dh-book-list-simple.h
+++ b/devhelp/dh-book-list-simple.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_LIST_SIMPLE_H
+#define DH_BOOK_LIST_SIMPLE_H
#include <glib-object.h>
#include "dh-book-list.h"
@@ -26,8 +27,22 @@
G_BEGIN_DECLS
-#define DH_TYPE_BOOK_LIST_SIMPLE (dh_book_list_simple_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhBookListSimple, dh_book_list_simple, DH, BOOK_LIST_SIMPLE, DhBookList)
+#define DH_TYPE_BOOK_LIST_SIMPLE (_dh_book_list_simple_get_type ())
+#define DH_BOOK_LIST_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_BOOK_LIST_SIMPLE,
DhBookListSimple))
+#define DH_BOOK_LIST_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_BOOK_LIST_SIMPLE,
DhBookListSimpleClass))
+#define DH_IS_BOOK_LIST_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_BOOK_LIST_SIMPLE))
+#define DH_IS_BOOK_LIST_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_BOOK_LIST_SIMPLE))
+#define DH_BOOK_LIST_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_BOOK_LIST_SIMPLE,
DhBookListSimpleClass))
+
+typedef struct _DhBookListSimple DhBookListSimple;
+typedef struct _DhBookListSimpleClass DhBookListSimpleClass;
+typedef struct _DhBookListSimplePrivate DhBookListSimplePrivate;
+
+struct _DhBookListSimple {
+ DhBookList parent;
+
+ DhBookListSimplePrivate *priv;
+};
struct _DhBookListSimpleClass {
DhBookListClass parent_class;
@@ -37,7 +52,12 @@ struct _DhBookListSimpleClass {
};
G_GNUC_INTERNAL
-DhBookList *_dh_book_list_simple_new (GList *sub_book_lists,
- DhSettings *settings);
+GType _dh_book_list_simple_get_type (void);
+
+G_GNUC_INTERNAL
+DhBookList * _dh_book_list_simple_new (GList *sub_book_lists,
+ DhSettings *settings);
+
G_END_DECLS
+#endif /* DH_BOOK_LIST_SIMPLE_H */
diff --git a/devhelp/dh-book-list.c b/devhelp/dh-book-list.c
index d2c4b7f4..791e8fcc 100644
--- a/devhelp/dh-book-list.c
+++ b/devhelp/dh-book-list.c
@@ -37,10 +37,10 @@
* #DhBook::updated signals. It is for example handled by #DhBookListDirectory.
*/
-typedef struct {
+struct _DhBookListPrivate {
/* The list of DhBook's. */
GList *books;
-} DhBookListPrivate;
+};
enum {
SIGNAL_ADD_BOOK,
@@ -57,8 +57,7 @@ static gboolean
book_id_present_in_list (DhBookList *book_list,
DhBook *book)
{
- DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
- return g_list_find_custom (priv->books,
+ return g_list_find_custom (book_list->priv->books,
book,
(GCompareFunc) dh_book_cmp_by_id) != NULL;
}
@@ -67,10 +66,9 @@ static void
dh_book_list_dispose (GObject *object)
{
DhBookList *book_list = DH_BOOK_LIST (object);
- DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
- g_list_free_full (priv->books, g_object_unref);
- priv->books = NULL;
+ g_list_free_full (book_list->priv->books, g_object_unref);
+ book_list->priv->books = NULL;
G_OBJECT_CLASS (dh_book_list_parent_class)->dispose (object);
}
@@ -88,26 +86,24 @@ static void
dh_book_list_add_book_default (DhBookList *book_list,
DhBook *book)
{
- DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
g_return_if_fail (!book_id_present_in_list (book_list, book));
- priv->books = g_list_prepend (priv->books,
- g_object_ref (book));
+ book_list->priv->books = g_list_prepend (book_list->priv->books,
+ g_object_ref (book));
}
static void
dh_book_list_remove_book_default (DhBookList *book_list,
DhBook *book)
{
- DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
GList *node;
- node = g_list_find (priv->books, book);
+ node = g_list_find (book_list->priv->books, book);
g_return_if_fail (node != NULL);
- priv->books = g_list_delete_link (priv->books, node);
+ book_list->priv->books = g_list_delete_link (book_list->priv->books, node);
- if (g_list_find (priv->books, book) != NULL)
+ if (g_list_find (book_list->priv->books, book) != NULL)
g_warning ("The same DhBook was inserted several times.");
g_object_unref (book);
@@ -116,10 +112,7 @@ dh_book_list_remove_book_default (DhBookList *book_list,
static GList *
dh_book_list_get_books_default (DhBookList *book_list)
{
- DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
- g_return_val_if_fail (DH_IS_BOOK_LIST (book_list), NULL);
-
- return priv->books;
+ return book_list->priv->books;
}
static void
@@ -184,6 +177,7 @@ dh_book_list_class_init (DhBookListClass *klass)
static void
dh_book_list_init (DhBookList *book_list)
{
+ book_list->priv = dh_book_list_get_instance_private (book_list);
}
/**
diff --git a/devhelp/dh-book-list.h b/devhelp/dh-book-list.h
index 5ae74d72..9660715d 100644
--- a/devhelp/dh-book-list.h
+++ b/devhelp/dh-book-list.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_LIST_H
+#define DH_BOOK_LIST_H
#include <glib-object.h>
#include <devhelp/dh-book.h>
@@ -26,7 +27,21 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST (dh_book_list_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhBookList, dh_book_list, DH, BOOK_LIST, GObject)
+#define DH_BOOK_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_BOOK_LIST, DhBookList))
+#define DH_BOOK_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_BOOK_LIST, DhBookListClass))
+#define DH_IS_BOOK_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_BOOK_LIST))
+#define DH_IS_BOOK_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_BOOK_LIST))
+#define DH_BOOK_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_BOOK_LIST, DhBookListClass))
+
+typedef struct _DhBookList DhBookList;
+typedef struct _DhBookListClass DhBookListClass;
+typedef struct _DhBookListPrivate DhBookListPrivate;
+
+struct _DhBookList {
+ GObject parent;
+
+ DhBookListPrivate *priv;
+};
/**
* DhBookListClass:
@@ -44,24 +59,36 @@ struct _DhBookListClass {
/* Signals */
void (* add_book) (DhBookList *book_list,
DhBook *book);
+
void (* remove_book) (DhBookList *book_list,
DhBook *book);
+
/* Vfuncs */
GList * (* get_books) (DhBookList *book_list);
+ /*< private >*/
+
/* Padding for future expansion */
gpointer padding[12];
};
-DhBookList *dh_book_list_new (void);
-DhBookList *dh_book_list_get_default (void);
+GType dh_book_list_get_type (void);
+
+DhBookList * dh_book_list_new (void);
+
+DhBookList * dh_book_list_get_default (void);
+
G_GNUC_INTERNAL
-void _dh_book_list_unref_default (void);
-GList *dh_book_list_get_books (DhBookList *book_list);
-void dh_book_list_add_book (DhBookList *book_list,
- DhBook *book);
-void dh_book_list_remove_book (DhBookList *book_list,
- DhBook *book);
+void _dh_book_list_unref_default (void);
+
+GList * dh_book_list_get_books (DhBookList *book_list);
+
+void dh_book_list_add_book (DhBookList *book_list,
+ DhBook *book);
+
+void dh_book_list_remove_book (DhBookList *book_list,
+ DhBook *book);
G_END_DECLS
+#endif /* DH_BOOK_LIST_H */
diff --git a/devhelp/dh-book-manager.c b/devhelp/dh-book-manager.c
index 55d99e59..a499960d 100644
--- a/devhelp/dh-book-manager.c
+++ b/devhelp/dh-book-manager.c
@@ -39,10 +39,6 @@
* </warning>
*/
-struct _DhBookManager {
- GObject parent_instance;
-};
-
G_DEFINE_TYPE (DhBookManager, dh_book_manager, G_TYPE_OBJECT);
static void
diff --git a/devhelp/dh-book-manager.h b/devhelp/dh-book-manager.h
index aef79a43..8251e588 100644
--- a/devhelp/dh-book-manager.h
+++ b/devhelp/dh-book-manager.h
@@ -19,19 +19,42 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_MANAGER_H
+#define DH_BOOK_MANAGER_H
#include <glib-object.h>
G_BEGIN_DECLS
+typedef struct _DhBookManager DhBookManager;
+typedef struct _DhBookManagerClass DhBookManagerClass;
+
#define DH_TYPE_BOOK_MANAGER (dh_book_manager_get_type ())
-G_DECLARE_FINAL_TYPE (DhBookManager, dh_book_manager, DH, BOOK_MANAGER, GObject)
+#define DH_BOOK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DH_TYPE_BOOK_MANAGER, DhBookManager))
+#define DH_BOOK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DH_TYPE_BOOK_MANAGER,
DhBookManagerClass))
+#define DH_IS_BOOK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DH_TYPE_BOOK_MANAGER))
+#define DH_IS_BOOK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DH_TYPE_BOOK_MANAGER))
+#define DH_BOOK_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DH_TYPE_BOOK_MANAGER,
DhBookManagerClass))
+
+struct _DhBookManager {
+ GObject parent_instance;
+};
+
+struct _DhBookManagerClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_book_manager_get_type (void) G_GNUC_CONST;
G_DEPRECATED
-DhBookManager *dh_book_manager_new (void);
+DhBookManager * dh_book_manager_new (void);
+
G_DEPRECATED
-void dh_book_manager_populate (DhBookManager *book_manager);
+void dh_book_manager_populate (DhBookManager *book_manager);
G_END_DECLS
+#endif /* DH_BOOK_MANAGER_H */
diff --git a/devhelp/dh-book-tree.c b/devhelp/dh-book-tree.c
index 287c4054..f9bad5cf 100644
--- a/devhelp/dh-book-tree.c
+++ b/devhelp/dh-book-tree.c
@@ -46,10 +46,6 @@
* emitted. Only one element can be selected at a time.
*/
-struct _DhBookTree {
- GtkTreeView parent_instance;
-};
-
typedef struct {
DhProfile *profile;
GtkTreeStore *store;
@@ -110,7 +106,7 @@ book_tree_selection_changed_cb (GtkTreeSelection *selection,
if (link != NULL &&
link != priv->selected_link) {
- g_clear_pointer (&priv->selected_link, dh_link_unref);
+ g_clear_pointer (&priv->selected_link, (GDestroyNotify)dh_link_unref);
priv->selected_link = dh_link_ref (link);
g_signal_emit (tree, signals[LINK_SELECTED], 0, link);
}
@@ -585,7 +581,7 @@ book_tree_init_selection (DhBookTree *tree)
if (link == NULL || dh_link_get_link_type (link) != DH_LINK_TYPE_BOOK)
g_warn_if_reached ();
- g_clear_pointer (&priv->selected_link, dh_link_unref);
+ g_clear_pointer (&priv->selected_link, (GDestroyNotify)dh_link_unref);
priv->selected_link = link;
gtk_tree_selection_select_iter (selection, &iter);
}
@@ -722,7 +718,7 @@ dh_book_tree_dispose (GObject *object)
g_clear_object (&priv->profile);
g_clear_object (&priv->store);
- g_clear_pointer (&priv->selected_link, dh_link_unref);
+ g_clear_pointer (&priv->selected_link, (GDestroyNotify)dh_link_unref);
priv->context_menu = NULL;
G_OBJECT_CLASS (dh_book_tree_parent_class)->dispose (object);
diff --git a/devhelp/dh-book-tree.h b/devhelp/dh-book-tree.h
index 58a3ea7c..d6f4c16b 100644
--- a/devhelp/dh-book-tree.h
+++ b/devhelp/dh-book-tree.h
@@ -19,7 +19,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_TREE_H
+#define DH_BOOK_TREE_H
#include <gtk/gtk.h>
#include <devhelp/dh-link.h>
@@ -28,13 +29,36 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_TREE (dh_book_tree_get_type ())
-G_DECLARE_FINAL_TYPE (DhBookTree, dh_book_tree, DH, BOOK_TREE, GtkTreeView)
+#define DH_BOOK_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_BOOK_TREE, DhBookTree))
+#define DH_BOOK_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_BOOK_TREE, DhBookTreeClass))
+#define DH_IS_BOOK_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_BOOK_TREE))
+#define DH_IS_BOOK_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), DH_TYPE_BOOK_TREE))
-DhBookTree *dh_book_tree_new (DhProfile *profile);
-DhProfile *dh_book_tree_get_profile (DhBookTree *tree);
-DhLink *dh_book_tree_get_selected_link (DhBookTree *tree);
-void dh_book_tree_select_uri (DhBookTree *tree,
- const gchar *uri);
+typedef struct _DhBookTree DhBookTree;
+typedef struct _DhBookTreeClass DhBookTreeClass;
+
+struct _DhBookTree {
+ GtkTreeView parent_instance;
+};
+
+struct _DhBookTreeClass {
+ GtkTreeViewClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_book_tree_get_type (void) G_GNUC_CONST;
+
+DhBookTree * dh_book_tree_new (DhProfile *profile);
+
+DhProfile * dh_book_tree_get_profile (DhBookTree *tree);
+
+DhLink * dh_book_tree_get_selected_link (DhBookTree *tree);
+
+void dh_book_tree_select_uri (DhBookTree *tree,
+ const gchar *uri);
G_END_DECLS
+#endif /* DH_BOOK_TREE_H */
diff --git a/devhelp/dh-book.h b/devhelp/dh-book.h
index 9ea9f8b0..94143b61 100644
--- a/devhelp/dh-book.h
+++ b/devhelp/dh-book.h
@@ -22,16 +22,27 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_BOOK_H
+#define DH_BOOK_H
-#include <glib-object.h>
#include <gio/gio.h>
#include <devhelp/dh-completion.h>
G_BEGIN_DECLS
+typedef struct _DhBook DhBook;
+typedef struct _DhBookClass DhBookClass;
+
#define DH_TYPE_BOOK (dh_book_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhBook, dh_book, DH, BOOK, GObject)
+#define DH_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DH_TYPE_BOOK, DhBook))
+#define DH_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DH_TYPE_BOOK, DhBookClass))
+#define DH_IS_BOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DH_TYPE_BOOK))
+#define DH_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DH_TYPE_BOOK))
+#define DH_BOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DH_TYPE_BOOK, DhBookClass))
+
+struct _DhBook {
+ GObject parent_instance;
+};
struct _DhBookClass {
GObjectClass parent_class;
@@ -40,17 +51,30 @@ struct _DhBookClass {
gpointer padding[12];
};
-DhBook *dh_book_new (GFile *index_file);
-GFile *dh_book_get_index_file (DhBook *book);
-const gchar *dh_book_get_id (DhBook *book);
-const gchar *dh_book_get_title (DhBook *book);
-const gchar *dh_book_get_language (DhBook *book);
-GList *dh_book_get_links (DhBook *book);
-GNode *dh_book_get_tree (DhBook *book);
+GType dh_book_get_type (void) G_GNUC_CONST;
+
+DhBook * dh_book_new (GFile *index_file);
+
+GFile * dh_book_get_index_file (DhBook *book);
+
+const gchar *dh_book_get_id (DhBook *book);
+
+const gchar *dh_book_get_title (DhBook *book);
+
+const gchar *dh_book_get_language (DhBook *book);
+
+GList * dh_book_get_links (DhBook *book);
+
+GNode * dh_book_get_tree (DhBook *book);
+
DhCompletion *dh_book_get_completion (DhBook *book);
-gint dh_book_cmp_by_id (DhBook *a,
+
+gint dh_book_cmp_by_id (DhBook *a,
DhBook *b);
-gint dh_book_cmp_by_title (DhBook *a,
+
+gint dh_book_cmp_by_title (DhBook *a,
DhBook *b);
+
G_END_DECLS
+#endif /* DH_BOOK_H */
diff --git a/devhelp/dh-completion.c b/devhelp/dh-completion.c
index 2ee68ff5..21ea0c24 100644
--- a/devhelp/dh-completion.c
+++ b/devhelp/dh-completion.c
@@ -43,10 +43,10 @@
* from the #GList.
*/
-typedef struct {
+struct _DhCompletionPrivate {
/* Element types: gchar*, owned. */
GSequence *sequence;
-} DhCompletionPrivate;
+};
typedef struct {
const gchar *prefix;
@@ -86,9 +86,8 @@ static void
dh_completion_finalize (GObject *object)
{
DhCompletion *completion = DH_COMPLETION (object);
- DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
- g_sequence_free (priv->sequence);
+ g_sequence_free (completion->priv->sequence);
G_OBJECT_CLASS (dh_completion_parent_class)->finalize (object);
}
@@ -104,8 +103,9 @@ dh_completion_class_init (DhCompletionClass *klass)
static void
dh_completion_init (DhCompletion *completion)
{
- DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
- priv->sequence = g_sequence_new (g_free);
+ completion->priv = dh_completion_get_instance_private (completion);
+
+ completion->priv->sequence = g_sequence_new (g_free);
}
/**
@@ -135,12 +135,10 @@ void
dh_completion_add_string (DhCompletion *completion,
const gchar *str)
{
- DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
-
g_return_if_fail (DH_IS_COMPLETION (completion));
g_return_if_fail (str != NULL);
- g_sequence_append (priv->sequence, g_strdup (str));
+ g_sequence_append (completion->priv->sequence, g_strdup (str));
}
/**
@@ -155,11 +153,9 @@ dh_completion_add_string (DhCompletion *completion,
void
dh_completion_sort (DhCompletion *completion)
{
- DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
-
g_return_if_fail (DH_IS_COMPLETION (completion));
- g_sequence_sort (priv->sequence,
+ g_sequence_sort (completion->priv->sequence,
compare_func,
NULL);
}
@@ -260,7 +256,6 @@ do_complete (DhCompletion *completion,
const gchar *prefix,
gboolean *found_string_with_prefix)
{
- DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
GSequenceIter *iter;
CompletionData data;
@@ -270,7 +265,7 @@ do_complete (DhCompletion *completion,
g_return_val_if_fail (DH_IS_COMPLETION (completion), NULL);
g_return_val_if_fail (prefix != NULL, NULL);
- iter = g_sequence_search (priv->sequence,
+ iter = g_sequence_search (completion->priv->sequence,
(gpointer) prefix,
compare_func,
NULL);
diff --git a/devhelp/dh-completion.h b/devhelp/dh-completion.h
index cbd16a9b..7f9b0d7c 100644
--- a/devhelp/dh-completion.h
+++ b/devhelp/dh-completion.h
@@ -18,14 +18,29 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_COMPLETION_H
+#define DH_COMPLETION_H
#include <glib-object.h>
G_BEGIN_DECLS
#define DH_TYPE_COMPLETION (dh_completion_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhCompletion, dh_completion, DH, COMPLETION, GObject)
+#define DH_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_COMPLETION, DhCompletion))
+#define DH_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_COMPLETION,
DhCompletionClass))
+#define DH_IS_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_COMPLETION))
+#define DH_IS_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_COMPLETION))
+#define DH_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_COMPLETION,
DhCompletionClass))
+
+typedef struct _DhCompletion DhCompletion;
+typedef struct _DhCompletionClass DhCompletionClass;
+typedef struct _DhCompletionPrivate DhCompletionPrivate;
+
+struct _DhCompletion {
+ GObject parent;
+
+ DhCompletionPrivate *priv;
+};
struct _DhCompletionClass {
GObjectClass parent_class;
@@ -34,14 +49,21 @@ struct _DhCompletionClass {
gpointer padding[12];
};
-DhCompletion *dh_completion_new (void);
-void dh_completion_add_string (DhCompletion *completion,
- const gchar *str);
-void dh_completion_sort (DhCompletion *completion);
-gchar *dh_completion_complete (DhCompletion *completion,
- const gchar *prefix);
-gchar *dh_completion_aggregate_complete (GList *completion_objects,
- const gchar *prefix);
+GType dh_completion_get_type (void);
+
+DhCompletion * dh_completion_new (void);
+
+void dh_completion_add_string (DhCompletion *completion,
+ const gchar *str);
+
+void dh_completion_sort (DhCompletion *completion);
+
+gchar * dh_completion_complete (DhCompletion *completion,
+ const gchar *prefix);
+
+gchar * dh_completion_aggregate_complete (GList *completion_objects,
+ const gchar *prefix);
G_END_DECLS
+#endif /* DH_COMPLETION_H */
diff --git a/devhelp/dh-keyword-model.c b/devhelp/dh-keyword-model.c
index a0800ca8..bab5f977 100644
--- a/devhelp/dh-keyword-model.c
+++ b/devhelp/dh-keyword-model.c
@@ -75,10 +75,6 @@
* affect the case sensitivity for the other search terms.
*/
-struct _DhKeywordModel {
- GObject parent_instance;
-};
-
typedef struct {
gchar *current_book_id;
diff --git a/devhelp/dh-keyword-model.h b/devhelp/dh-keyword-model.h
index fd1d3b58..4dd0bfa6 100644
--- a/devhelp/dh-keyword-model.h
+++ b/devhelp/dh-keyword-model.h
@@ -20,7 +20,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_KEYWORD_MODEL_H
+#define DH_KEYWORD_MODEL_H
#include <glib-object.h>
#include <devhelp/dh-link.h>
@@ -29,7 +30,25 @@
G_BEGIN_DECLS
#define DH_TYPE_KEYWORD_MODEL (dh_keyword_model_get_type ())
-G_DECLARE_FINAL_TYPE (DhKeywordModel, dh_keyword_model, DH, KEYWORD_MODEL, GObject)
+#define DH_KEYWORD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_KEYWORD_MODEL,
DhKeywordModel))
+#define DH_KEYWORD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_KEYWORD_MODEL,
DhKeywordModelClass))
+#define DH_IS_KEYWORD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_KEYWORD_MODEL))
+#define DH_IS_KEYWORD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_KEYWORD_MODEL))
+#define DH_KEYWORD_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_KEYWORD_MODEL,
DhKeywordModelClass))
+
+typedef struct _DhKeywordModel DhKeywordModel;
+typedef struct _DhKeywordModelClass DhKeywordModelClass;
+
+struct _DhKeywordModel {
+ GObject parent_instance;
+};
+
+struct _DhKeywordModelClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
enum {
DH_KEYWORD_MODEL_COL_NAME,
@@ -38,11 +57,15 @@ enum {
DH_KEYWORD_MODEL_NUM_COLS
};
-DhKeywordModel *dh_keyword_model_new (void);
-DhLink *dh_keyword_model_filter (DhKeywordModel *model,
- const gchar *search_string,
- const gchar *current_book_id,
- DhProfile *profile);
+GType dh_keyword_model_get_type (void);
+
+DhKeywordModel *dh_keyword_model_new (void);
+
+DhLink * dh_keyword_model_filter (DhKeywordModel *model,
+ const gchar *search_string,
+ const gchar *current_book_id,
+ DhProfile *profile);
G_END_DECLS
+#endif /* DH_KEYWORD_MODEL_H */
diff --git a/devhelp/dh-link.h b/devhelp/dh-link.h
index a9532ac7..51641f51 100644
--- a/devhelp/dh-link.h
+++ b/devhelp/dh-link.h
@@ -20,7 +20,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_LINK_H
+#define DH_LINK_H
#include <glib-object.h>
@@ -112,3 +113,4 @@ const gchar *dh_link_type_to_string (DhLinkType link_type);
G_END_DECLS
+#endif /* DH_LINK_H */
diff --git a/devhelp/dh-notebook.c b/devhelp/dh-notebook.c
index 233b21ca..e31bd043 100644
--- a/devhelp/dh-notebook.c
+++ b/devhelp/dh-notebook.c
@@ -33,9 +33,9 @@
* #DhTab.
*/
-typedef struct {
+struct _DhNotebookPrivate {
DhProfile *profile;
-} DhNotebookPrivate;
+};
enum {
PROP_0,
@@ -51,14 +51,13 @@ static void
set_profile (DhNotebook *notebook,
DhProfile *profile)
{
- DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
if (profile == NULL)
return;
g_return_if_fail (DH_IS_PROFILE (profile));
- g_assert (priv->profile == NULL);
- priv->profile = g_object_ref (profile);
+ g_assert (notebook->priv->profile == NULL);
+ notebook->priv->profile = g_object_ref (profile);
}
static void
@@ -103,12 +102,11 @@ static void
dh_notebook_constructed (GObject *object)
{
DhNotebook *notebook = DH_NOTEBOOK (object);
- DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
if (G_OBJECT_CLASS (dh_notebook_parent_class)->constructed != NULL)
G_OBJECT_CLASS (dh_notebook_parent_class)->constructed (object);
- if (priv->profile == NULL)
+ if (notebook->priv->profile == NULL)
set_profile (notebook, dh_profile_get_default ());
}
@@ -116,9 +114,8 @@ static void
dh_notebook_dispose (GObject *object)
{
DhNotebook *notebook = DH_NOTEBOOK (object);
- DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
- g_clear_object (&priv->profile);
+ g_clear_object (¬ebook->priv->profile);
G_OBJECT_CLASS (dh_notebook_parent_class)->dispose (object);
}
@@ -191,6 +188,8 @@ dh_notebook_class_init (DhNotebookClass *klass)
static void
dh_notebook_init (DhNotebook *notebook)
{
+ notebook->priv = dh_notebook_get_instance_private (notebook);
+
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
}
@@ -221,10 +220,9 @@ dh_notebook_new (DhProfile *profile)
DhProfile *
dh_notebook_get_profile (DhNotebook *notebook)
{
- DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
g_return_val_if_fail (DH_IS_NOTEBOOK (notebook), NULL);
- return priv->profile;
+ return notebook->priv->profile;
}
static void
@@ -257,11 +255,10 @@ dh_notebook_open_new_tab (DhNotebook *notebook,
DhTab *tab;
GtkWidget *label;
gint page_num;
- DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
g_return_if_fail (DH_IS_NOTEBOOK (notebook));
- web_view = dh_web_view_new (priv->profile);
+ web_view = dh_web_view_new (notebook->priv->profile);
gtk_widget_show (GTK_WIDGET (web_view));
tab = dh_tab_new (web_view);
diff --git a/devhelp/dh-notebook.h b/devhelp/dh-notebook.h
index e1411fb2..68209d36 100644
--- a/devhelp/dh-notebook.h
+++ b/devhelp/dh-notebook.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_NOTEBOOK_H
+#define DH_NOTEBOOK_H
#include <gtk/gtk.h>
#include <devhelp/dh-profile.h>
@@ -28,7 +29,21 @@
G_BEGIN_DECLS
#define DH_TYPE_NOTEBOOK (dh_notebook_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhNotebook, dh_notebook, DH, NOTEBOOK, GtkNotebook)
+#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;
+typedef struct _DhNotebookPrivate DhNotebookPrivate;
+
+struct _DhNotebook {
+ GtkNotebook parent;
+
+ DhNotebookPrivate *priv;
+};
struct _DhNotebookClass {
GtkNotebookClass parent_class;
@@ -37,14 +52,22 @@ struct _DhNotebookClass {
gpointer padding[12];
};
-DhNotebook *dh_notebook_new (DhProfile *profile);
-DhProfile *dh_notebook_get_profile (DhNotebook *notebook);
-void dh_notebook_open_new_tab (DhNotebook *notebook,
- const gchar *uri,
- gboolean switch_focus);
-DhTab *dh_notebook_get_active_tab (DhNotebook *notebook);
-DhWebView *dh_notebook_get_active_web_view (DhNotebook *notebook);
-GList *dh_notebook_get_all_web_views (DhNotebook *notebook);
+GType dh_notebook_get_type (void);
+
+DhNotebook * dh_notebook_new (DhProfile *profile);
+
+DhProfile * dh_notebook_get_profile (DhNotebook *notebook);
+
+void dh_notebook_open_new_tab (DhNotebook *notebook,
+ const gchar *uri,
+ gboolean switch_focus);
+
+DhTab * dh_notebook_get_active_tab (DhNotebook *notebook);
+
+DhWebView * dh_notebook_get_active_web_view (DhNotebook *notebook);
+
+GList * dh_notebook_get_all_web_views (DhNotebook *notebook);
G_END_DECLS
+#endif /* DH_NOTEBOOK_H */
diff --git a/devhelp/dh-parser.h b/devhelp/dh-parser.h
index fdbc0656..6cfe46c1 100644
--- a/devhelp/dh-parser.h
+++ b/devhelp/dh-parser.h
@@ -20,7 +20,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_PARSER_H
+#define DH_PARSER_H
#include <gio/gio.h>
@@ -37,3 +38,4 @@ gboolean _dh_parser_read_file (GFile *index_file,
G_END_DECLS
+#endif /* DH_PARSER_H */
diff --git a/devhelp/dh-profile-builder.c b/devhelp/dh-profile-builder.c
index 5ab4be85..16ec6f3a 100644
--- a/devhelp/dh-profile-builder.c
+++ b/devhelp/dh-profile-builder.c
@@ -35,14 +35,10 @@
* but it is implemented in a simpler way, to have less boilerplate.
*/
-struct _DhProfileBuilder {
- GObject parent_instance;
-};
-
-typedef struct {
+struct _DhProfileBuilderPrivate {
DhSettings *settings;
DhBookList *book_list;
-} DhProfileBuilderPrivate;
+};
G_DEFINE_TYPE_WITH_PRIVATE (DhProfileBuilder, dh_profile_builder, G_TYPE_OBJECT)
@@ -50,10 +46,9 @@ static void
dh_profile_builder_dispose (GObject *object)
{
DhProfileBuilder *builder = DH_PROFILE_BUILDER (object);
- DhProfileBuilderPrivate *priv = dh_profile_builder_get_instance_private (builder);
- g_clear_object (&priv->settings);
- g_clear_object (&priv->book_list);
+ g_clear_object (&builder->priv->settings);
+ g_clear_object (&builder->priv->book_list);
G_OBJECT_CLASS (dh_profile_builder_parent_class)->dispose (object);
}
@@ -69,6 +64,7 @@ dh_profile_builder_class_init (DhProfileBuilderClass *klass)
static void
dh_profile_builder_init (DhProfileBuilder *builder)
{
+ builder->priv = dh_profile_builder_get_instance_private (builder);
}
/**
@@ -99,12 +95,10 @@ void
dh_profile_builder_set_settings (DhProfileBuilder *builder,
DhSettings *settings)
{
- DhProfileBuilderPrivate *priv = dh_profile_builder_get_instance_private (builder);
-
g_return_if_fail (DH_IS_PROFILE_BUILDER (builder));
g_return_if_fail (DH_IS_SETTINGS (settings));
- g_set_object (&priv->settings, settings);
+ g_set_object (&builder->priv->settings, settings);
}
/**
@@ -123,12 +117,10 @@ void
dh_profile_builder_set_book_list (DhProfileBuilder *builder,
DhBookList *book_list)
{
- DhProfileBuilderPrivate *priv = dh_profile_builder_get_instance_private (builder);
-
g_return_if_fail (DH_IS_PROFILE_BUILDER (builder));
g_return_if_fail (DH_IS_BOOK_LIST (book_list));
- g_set_object (&priv->book_list, book_list);
+ g_set_object (&builder->priv->book_list, book_list);
}
/**
@@ -141,20 +133,18 @@ dh_profile_builder_set_book_list (DhProfileBuilder *builder,
DhProfile *
dh_profile_builder_create_object (DhProfileBuilder *builder)
{
- DhProfileBuilderPrivate *priv = dh_profile_builder_get_instance_private (builder);
-
g_return_val_if_fail (DH_IS_PROFILE_BUILDER (builder), NULL);
/* Set default values if needed.
* Use all the set functions to test them, to have the same code paths
* as if the set functions were already called.
*/
- if (priv->settings == NULL)
+ if (builder->priv->settings == NULL)
dh_profile_builder_set_settings (builder, dh_settings_get_default ());
- if (priv->book_list == NULL)
+ if (builder->priv->book_list == NULL)
dh_profile_builder_set_book_list (builder, dh_book_list_get_default ());
- return _dh_profile_new (priv->settings,
- priv->book_list);
+ return _dh_profile_new (builder->priv->settings,
+ builder->priv->book_list);
}
diff --git a/devhelp/dh-profile-builder.h b/devhelp/dh-profile-builder.h
index d116b14a..25e409cc 100644
--- a/devhelp/dh-profile-builder.h
+++ b/devhelp/dh-profile-builder.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_PROFILE_BUILDER_H
+#define DH_PROFILE_BUILDER_H
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -28,14 +29,41 @@
G_BEGIN_DECLS
#define DH_TYPE_PROFILE_BUILDER (dh_profile_builder_get_type ())
-G_DECLARE_FINAL_TYPE (DhProfileBuilder, dh_profile_builder, DH, PROFILE_BUILDER, GObject)
+#define DH_PROFILE_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_PROFILE_BUILDER,
DhProfileBuilder))
+#define DH_PROFILE_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_PROFILE_BUILDER,
DhProfileBuilderClass))
+#define DH_IS_PROFILE_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_PROFILE_BUILDER))
+#define DH_IS_PROFILE_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_PROFILE_BUILDER))
+#define DH_PROFILE_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_PROFILE_BUILDER,
DhProfileBuilderClass))
-DhProfileBuilder *dh_profile_builder_new (void);
-void dh_profile_builder_set_settings (DhProfileBuilder *builder,
- DhSettings *settings);
-void dh_profile_builder_set_book_list (DhProfileBuilder *builder,
- DhBookList *book_list);
-DhProfile *dh_profile_builder_create_object (DhProfileBuilder *builder);
+typedef struct _DhProfileBuilder DhProfileBuilder;
+typedef struct _DhProfileBuilderClass DhProfileBuilderClass;
+typedef struct _DhProfileBuilderPrivate DhProfileBuilderPrivate;
+
+struct _DhProfileBuilder {
+ GObject parent;
+
+ DhProfileBuilderPrivate *priv;
+};
+
+struct _DhProfileBuilderClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_profile_builder_get_type (void);
+
+DhProfileBuilder * dh_profile_builder_new (void);
+
+void dh_profile_builder_set_settings (DhProfileBuilder *builder,
+ DhSettings *settings);
+
+void dh_profile_builder_set_book_list (DhProfileBuilder *builder,
+ DhBookList *book_list);
+
+DhProfile * dh_profile_builder_create_object (DhProfileBuilder *builder);
G_END_DECLS
+#endif /* DH_PROFILE_BUILDER_H */
diff --git a/devhelp/dh-profile.c b/devhelp/dh-profile.c
index c8be6fda..0a058734 100644
--- a/devhelp/dh-profile.c
+++ b/devhelp/dh-profile.c
@@ -47,14 +47,11 @@
* providing additional features useful for that development platform (for
* example to download the latest API documentation, have a start page, etc).
*/
-struct _DhProfile {
- GObject parent_instance;
-};
-typedef struct {
+struct _DhProfilePrivate {
DhSettings *settings;
DhBookList *book_list;
-} DhProfilePrivate;
+};
static DhProfile *default_instance = NULL;
@@ -64,10 +61,9 @@ static void
dh_profile_dispose (GObject *object)
{
DhProfile *profile = DH_PROFILE (object);
- DhProfilePrivate *priv = dh_profile_get_instance_private (profile);
- g_clear_object (&priv->settings);
- g_clear_object (&priv->book_list);
+ g_clear_object (&profile->priv->settings);
+ g_clear_object (&profile->priv->book_list);
G_OBJECT_CLASS (dh_profile_parent_class)->dispose (object);
}
@@ -93,6 +89,7 @@ dh_profile_class_init (DhProfileClass *klass)
static void
dh_profile_init (DhProfile *profile)
{
+ profile->priv = dh_profile_get_instance_private (profile);
}
DhProfile *
@@ -100,15 +97,13 @@ _dh_profile_new (DhSettings *settings,
DhBookList *book_list)
{
DhProfile *profile;
- DhProfilePrivate *priv;
g_return_val_if_fail (DH_IS_SETTINGS (settings), NULL);
g_return_val_if_fail (DH_IS_BOOK_LIST (book_list), NULL);
profile = g_object_new (DH_TYPE_PROFILE, NULL);
- priv = dh_profile_get_instance_private (profile);
- priv->settings = g_object_ref (settings);
- priv->book_list = g_object_ref (book_list);
+ profile->priv->settings = g_object_ref (settings);
+ profile->priv->book_list = g_object_ref (book_list);
return profile;
}
@@ -162,10 +157,9 @@ _dh_profile_unref_default (void)
DhSettings *
dh_profile_get_settings (DhProfile *profile)
{
- DhProfilePrivate *priv = dh_profile_get_instance_private (profile);
g_return_val_if_fail (DH_IS_PROFILE (profile), NULL);
- return priv->settings;
+ return profile->priv->settings;
}
/**
@@ -181,8 +175,7 @@ dh_profile_get_settings (DhProfile *profile)
DhBookList *
dh_profile_get_book_list (DhProfile *profile)
{
- DhProfilePrivate *priv = dh_profile_get_instance_private (profile);
g_return_val_if_fail (DH_IS_PROFILE (profile), NULL);
- return priv->book_list;
+ return profile->priv->book_list;
}
diff --git a/devhelp/dh-profile.h b/devhelp/dh-profile.h
index 4098a264..5af1bfc3 100644
--- a/devhelp/dh-profile.h
+++ b/devhelp/dh-profile.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_PROFILE_H
+#define DH_PROFILE_H
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -27,16 +28,44 @@
G_BEGIN_DECLS
#define DH_TYPE_PROFILE (dh_profile_get_type ())
-G_DECLARE_FINAL_TYPE (DhProfile, dh_profile, DH, PROFILE, GObject)
+#define DH_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_PROFILE, DhProfile))
+#define DH_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_PROFILE, DhProfileClass))
+#define DH_IS_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_PROFILE))
+#define DH_IS_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_PROFILE))
+#define DH_PROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_PROFILE, DhProfileClass))
+
+typedef struct _DhProfile DhProfile;
+typedef struct _DhProfileClass DhProfileClass;
+typedef struct _DhProfilePrivate DhProfilePrivate;
+
+struct _DhProfile {
+ GObject parent;
+
+ DhProfilePrivate *priv;
+};
+
+struct _DhProfileClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_profile_get_type (void);
G_GNUC_INTERNAL
-DhProfile *_dh_profile_new (DhSettings *settings,
- DhBookList *book_list);
-DhProfile *dh_profile_get_default (void);
+DhProfile * _dh_profile_new (DhSettings *settings,
+ DhBookList *book_list);
+
+DhProfile * dh_profile_get_default (void);
+
G_GNUC_INTERNAL
-void _dh_profile_unref_default (void);
-DhSettings *dh_profile_get_settings (DhProfile *profile);
-DhBookList *dh_profile_get_book_list (DhProfile *profile);
+void _dh_profile_unref_default (void);
+
+DhSettings * dh_profile_get_settings (DhProfile *profile);
+
+DhBookList * dh_profile_get_book_list (DhProfile *profile);
G_END_DECLS
+#endif /* DH_PROFILE_H */
diff --git a/devhelp/dh-search-bar.c b/devhelp/dh-search-bar.c
index e0b3e5c4..872dff8a 100644
--- a/devhelp/dh-search-bar.c
+++ b/devhelp/dh-search-bar.c
@@ -37,10 +37,10 @@
* you).
*/
-typedef struct {
+struct _DhSearchBarPrivate {
DhNotebook *notebook;
GtkSearchEntry *search_entry;
-} DhSearchBarPrivate;
+};
enum {
PROP_0,
@@ -56,14 +56,10 @@ static void
update_search_in_web_view (DhSearchBar *search_bar,
DhWebView *view)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
const gchar *search_text = NULL;
- g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
-
-
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (search_bar)))
- search_text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
+ search_text = gtk_entry_get_text (GTK_ENTRY (search_bar->priv->search_entry));
dh_web_view_set_search_text (view, search_text);
}
@@ -71,12 +67,9 @@ update_search_in_web_view (DhSearchBar *search_bar,
static void
update_search_in_active_web_view (DhSearchBar *search_bar)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
DhWebView *web_view;
- g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
-
- web_view = dh_notebook_get_active_web_view (priv->notebook);
+ web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
if (web_view != NULL)
update_search_in_web_view (search_bar, web_view);
}
@@ -84,13 +77,10 @@ update_search_in_active_web_view (DhSearchBar *search_bar)
static void
update_search_in_all_web_views (DhSearchBar *search_bar)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
GList *web_views;
GList *l;
- g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
-
- web_views = dh_notebook_get_all_web_views (priv->notebook);
+ web_views = dh_notebook_get_all_web_views (search_bar->priv->notebook);
for (l = web_views; l != NULL; l = l->next) {
DhWebView *web_view = DH_WEB_VIEW (l->data);
@@ -103,12 +93,9 @@ update_search_in_all_web_views (DhSearchBar *search_bar)
static void
search_previous_in_active_web_view (DhSearchBar *search_bar)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
DhWebView *web_view;
- g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
-
- web_view = dh_notebook_get_active_web_view (priv->notebook);
+ web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
if (web_view == NULL)
return;
@@ -119,12 +106,9 @@ search_previous_in_active_web_view (DhSearchBar *search_bar)
static void
search_next_in_active_web_view (DhSearchBar *search_bar)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
DhWebView *web_view;
- g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
-
- web_view = dh_notebook_get_active_web_view (priv->notebook);
+ web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
if (web_view == NULL)
return;
@@ -196,7 +180,6 @@ dh_search_bar_constructed (GObject *object)
GtkStyleContext *style_context;
GtkWidget *prev_button;
GtkWidget *next_button;
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
if (G_OBJECT_CLASS (dh_search_bar_parent_class)->constructed != NULL)
G_OBJECT_CLASS (dh_search_bar_parent_class)->constructed (object);
@@ -208,22 +191,22 @@ dh_search_bar_constructed (GObject *object)
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
/* Search entry */
- priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
- gtk_widget_set_size_request (GTK_WIDGET (priv->search_entry), 300, -1);
+ search_bar->priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
+ gtk_widget_set_size_request (GTK_WIDGET (search_bar->priv->search_entry), 300, -1);
gtk_container_add (GTK_CONTAINER (hgrid),
- GTK_WIDGET (priv->search_entry));
+ GTK_WIDGET (search_bar->priv->search_entry));
- g_signal_connect (priv->search_entry,
+ g_signal_connect (search_bar->priv->search_entry,
"search-changed",
G_CALLBACK (search_changed_cb),
search_bar);
- g_signal_connect (priv->search_entry,
+ g_signal_connect (search_bar->priv->search_entry,
"previous-match",
G_CALLBACK (previous_match_cb),
search_bar);
- g_signal_connect (priv->search_entry,
+ g_signal_connect (search_bar->priv->search_entry,
"next-match",
G_CALLBACK (next_match_cb),
search_bar);
@@ -251,7 +234,7 @@ dh_search_bar_constructed (GObject *object)
G_CALLBACK (search_mode_enabled_notify_cb),
NULL);
- g_signal_connect_object (priv->notebook,
+ g_signal_connect_object (search_bar->priv->notebook,
"switch-page",
G_CALLBACK (notebook_switch_page_after_cb),
search_bar,
@@ -261,7 +244,7 @@ dh_search_bar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (search_bar), hgrid);
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar),
- GTK_ENTRY (priv->search_entry));
+ GTK_ENTRY (search_bar->priv->search_entry));
}
static void
@@ -290,12 +273,11 @@ dh_search_bar_set_property (GObject *object,
GParamSpec *pspec)
{
DhSearchBar *search_bar = DH_SEARCH_BAR (object);
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
switch (prop_id) {
case PROP_NOTEBOOK:
- g_assert (priv->notebook == NULL);
- priv->notebook = g_object_ref_sink (g_value_get_object (value));
+ g_assert (search_bar->priv->notebook == NULL);
+ search_bar->priv->notebook = g_object_ref_sink (g_value_get_object (value));
break;
default:
@@ -308,10 +290,9 @@ static void
dh_search_bar_dispose (GObject *object)
{
DhSearchBar *search_bar = DH_SEARCH_BAR (object);
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
- g_clear_object (&priv->notebook);
- priv->search_entry = NULL;
+ g_clear_object (&search_bar->priv->notebook);
+ search_bar->priv->search_entry = NULL;
G_OBJECT_CLASS (dh_search_bar_parent_class)->dispose (object);
}
@@ -349,6 +330,7 @@ dh_search_bar_class_init (DhSearchBarClass *klass)
static void
dh_search_bar_init (DhSearchBar *search_bar)
{
+ search_bar->priv = dh_search_bar_get_instance_private (search_bar);
}
/**
@@ -378,8 +360,7 @@ dh_search_bar_new (DhNotebook *notebook)
DhNotebook *
dh_search_bar_get_notebook (DhSearchBar *search_bar)
{
- DhSearchBarPrivate *priv = dh_search_bar_get_instance_private (search_bar);
g_return_val_if_fail (DH_IS_SEARCH_BAR (search_bar), NULL);
- return priv->notebook;
+ return search_bar->priv->notebook;
}
diff --git a/devhelp/dh-search-bar.h b/devhelp/dh-search-bar.h
index 12e91bd5..72f2cd7c 100644
--- a/devhelp/dh-search-bar.h
+++ b/devhelp/dh-search-bar.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_SEARCH_BAR_H
+#define DH_SEARCH_BAR_H
#include <gtk/gtk.h>
#include <devhelp/dh-notebook.h>
@@ -26,7 +27,21 @@
G_BEGIN_DECLS
#define DH_TYPE_SEARCH_BAR (dh_search_bar_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhSearchBar, dh_search_bar, DH, SEARCH_BAR, GtkSearchBar)
+#define DH_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SEARCH_BAR, DhSearchBar))
+#define DH_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SEARCH_BAR,
DhSearchBarClass))
+#define DH_IS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SEARCH_BAR))
+#define DH_IS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SEARCH_BAR))
+#define DH_SEARCH_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_SEARCH_BAR,
DhSearchBarClass))
+
+typedef struct _DhSearchBar DhSearchBar;
+typedef struct _DhSearchBarClass DhSearchBarClass;
+typedef struct _DhSearchBarPrivate DhSearchBarPrivate;
+
+struct _DhSearchBar {
+ GtkSearchBar parent;
+
+ DhSearchBarPrivate *priv;
+};
struct _DhSearchBarClass {
GtkSearchBarClass parent_class;
@@ -35,8 +50,12 @@ struct _DhSearchBarClass {
gpointer padding[12];
};
-DhSearchBar *dh_search_bar_new (DhNotebook *notebook);
-DhNotebook *dh_search_bar_get_notebook (DhSearchBar *search_bar);
+GType dh_search_bar_get_type (void);
+
+DhSearchBar * dh_search_bar_new (DhNotebook *notebook);
+
+DhNotebook * dh_search_bar_get_notebook (DhSearchBar *search_bar);
G_END_DECLS
+#endif /* DH_SEARCH_BAR_H */
diff --git a/devhelp/dh-search-context.h b/devhelp/dh-search-context.h
index f58fe5b5..6f5ffb2c 100644
--- a/devhelp/dh-search-context.h
+++ b/devhelp/dh-search-context.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_SEARCH_CONTEXT_H
+#define DH_SEARCH_CONTEXT_H
#include <glib.h>
#include "dh-book.h"
@@ -61,3 +62,4 @@ gboolean _dh_search_context_is_exact_link (DhSearchContext
G_END_DECLS
+#endif /* DH_SEARCH_CONTEXT_H */
diff --git a/devhelp/dh-settings-builder.c b/devhelp/dh-settings-builder.c
index b76e7b91..fbf9aef5 100644
--- a/devhelp/dh-settings-builder.c
+++ b/devhelp/dh-settings-builder.c
@@ -51,22 +51,20 @@
* but it is implemented in a simpler way, to have less boilerplate.
*/
-struct _DhSettingsBuilder {
- GObject parent_instance;
-
+struct _DhSettingsBuilderPrivate {
gchar *contents_path;
gchar *fonts_path;
};
-G_DEFINE_TYPE (DhSettingsBuilder, dh_settings_builder, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (DhSettingsBuilder, dh_settings_builder, G_TYPE_OBJECT)
static void
dh_settings_builder_finalize (GObject *object)
{
DhSettingsBuilder *builder = DH_SETTINGS_BUILDER (object);
- g_free (builder->contents_path);
- g_free (builder->fonts_path);
+ g_free (builder->priv->contents_path);
+ g_free (builder->priv->fonts_path);
G_OBJECT_CLASS (dh_settings_builder_parent_class)->finalize (object);
}
@@ -82,7 +80,7 @@ dh_settings_builder_class_init (DhSettingsBuilderClass *klass)
static void
dh_settings_builder_init (DhSettingsBuilder *builder)
{
- builder = dh_settings_builder_get_instance_private (builder);
+ builder->priv = dh_settings_builder_get_instance_private (builder);
}
/**
@@ -116,8 +114,8 @@ dh_settings_builder_set_contents_path (DhSettingsBuilder *builder,
g_return_if_fail (DH_IS_SETTINGS_BUILDER (builder));
g_return_if_fail (contents_path != NULL);
- g_free (builder->contents_path);
- builder->contents_path = g_strdup (contents_path);
+ g_free (builder->priv->contents_path);
+ builder->priv->contents_path = g_strdup (contents_path);
}
/**
@@ -139,8 +137,8 @@ dh_settings_builder_set_fonts_path (DhSettingsBuilder *builder,
g_return_if_fail (DH_IS_SETTINGS_BUILDER (builder));
g_return_if_fail (fonts_path != NULL);
- g_free (builder->fonts_path);
- builder->fonts_path = g_strdup (fonts_path);
+ g_free (builder->priv->fonts_path);
+ builder->priv->fonts_path = g_strdup (fonts_path);
}
/**
@@ -159,15 +157,15 @@ dh_settings_builder_create_object (DhSettingsBuilder *builder)
* Use all the set functions to test them, to have the same code paths
* as if the set functions were already called.
*/
- if (builder->contents_path == NULL) {
+ if (builder->priv->contents_path == NULL) {
// Must be compatible with Devhelp app version 3.28:
dh_settings_builder_set_contents_path (builder, "/org/gnome/devhelp/state/main/contents/");
}
- if (builder->fonts_path == NULL) {
+ if (builder->priv->fonts_path == NULL) {
// Must be compatible with Devhelp app version 3.28:
dh_settings_builder_set_fonts_path (builder, "/org/gnome/devhelp/fonts/");
}
- return _dh_settings_new (builder->contents_path,
- builder->fonts_path);
+ return _dh_settings_new (builder->priv->contents_path,
+ builder->priv->fonts_path);
}
diff --git a/devhelp/dh-settings-builder.h b/devhelp/dh-settings-builder.h
index a7afea04..bb1f31d7 100644
--- a/devhelp/dh-settings-builder.h
+++ b/devhelp/dh-settings-builder.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_SETTINGS_BUILDER_H
+#define DH_SETTINGS_BUILDER_H
#include <glib-object.h>
#include <devhelp/dh-settings.h>
@@ -26,13 +27,42 @@
G_BEGIN_DECLS
#define DH_TYPE_SETTINGS_BUILDER (dh_settings_builder_get_type ())
-G_DECLARE_FINAL_TYPE (DhSettingsBuilder, dh_settings_builder, DH, SETTINGS_BUILDER, GObject)
-
-DhSettingsBuilder *dh_settings_builder_new (void);
-void dh_settings_builder_set_contents_path (DhSettingsBuilder *builder,
- const gchar *contents_path);
-void dh_settings_builder_set_fonts_path (DhSettingsBuilder *builder,
- const gchar *fonts_path);
-DhSettings *dh_settings_builder_create_object (DhSettingsBuilder *builder);
+#define DH_SETTINGS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SETTINGS_BUILDER,
DhSettingsBuilder))
+#define DH_SETTINGS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SETTINGS_BUILDER,
DhSettingsBuilderClass))
+#define DH_IS_SETTINGS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SETTINGS_BUILDER))
+#define DH_IS_SETTINGS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SETTINGS_BUILDER))
+#define DH_SETTINGS_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_SETTINGS_BUILDER,
DhSettingsBuilderClass))
+
+typedef struct _DhSettingsBuilder DhSettingsBuilder;
+typedef struct _DhSettingsBuilderClass DhSettingsBuilderClass;
+typedef struct _DhSettingsBuilderPrivate DhSettingsBuilderPrivate;
+
+struct _DhSettingsBuilder {
+ GObject parent;
+
+ DhSettingsBuilderPrivate *priv;
+};
+
+struct _DhSettingsBuilderClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_settings_builder_get_type (void);
+
+DhSettingsBuilder *
+ dh_settings_builder_new (void);
+
+void dh_settings_builder_set_contents_path (DhSettingsBuilder *builder,
+ const gchar *contents_path);
+
+void dh_settings_builder_set_fonts_path (DhSettingsBuilder *builder,
+ const gchar *fonts_path);
+
+DhSettings * dh_settings_builder_create_object (DhSettingsBuilder *builder);
+
G_END_DECLS
+#endif /* DH_SETTINGS_BUILDER_H */
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index 716046b0..873f55fa 100644
--- a/devhelp/dh-settings.c
+++ b/devhelp/dh-settings.c
@@ -82,7 +82,7 @@
#define SYSTEM_FIXED_FONT_KEY "monospace-font-name"
#define SYSTEM_VARIABLE_FONT_KEY "font-name"
-typedef struct {
+struct _DhSettingsPrivate {
GSettings *gsettings_contents;
GSettings *gsettings_fonts;
GSettings *gsettings_desktop_interface;
@@ -95,7 +95,7 @@ typedef struct {
guint group_books_by_language : 1;
guint use_system_fonts : 1;
-} DhSettingsPrivate;
+};
enum {
PROP_0,
@@ -121,14 +121,13 @@ G_DEFINE_TYPE_WITH_PRIVATE (DhSettings, dh_settings, G_TYPE_OBJECT);
static void
load_books_disabled (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
gchar **books_disabled_strv;
gint i;
- g_list_free_full (priv->books_disabled, g_free);
- priv->books_disabled = NULL;
+ g_list_free_full (settings->priv->books_disabled, g_free);
+ settings->priv->books_disabled = NULL;
- books_disabled_strv = g_settings_get_strv (priv->gsettings_contents,
+ books_disabled_strv = g_settings_get_strv (settings->priv->gsettings_contents,
"books-disabled");
if (books_disabled_strv == NULL)
@@ -136,10 +135,10 @@ load_books_disabled (DhSettings *settings)
for (i = 0; books_disabled_strv[i] != NULL; i++) {
gchar *book_id = books_disabled_strv[i];
- priv->books_disabled = g_list_prepend (priv->books_disabled, book_id);
+ settings->priv->books_disabled = g_list_prepend (settings->priv->books_disabled, book_id);
}
- priv->books_disabled = g_list_reverse (priv->books_disabled);
+ settings->priv->books_disabled = g_list_reverse (settings->priv->books_disabled);
g_free (books_disabled_strv);
}
@@ -147,14 +146,13 @@ load_books_disabled (DhSettings *settings)
static void
store_books_disabled (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
GVariantBuilder *builder;
GVariant *variant;
GList *l;
builder = g_variant_builder_new (G_VARIANT_TYPE_STRING_ARRAY);
- for (l = priv->books_disabled; l != NULL; l = l->next) {
+ for (l = settings->priv->books_disabled; l != NULL; l = l->next) {
const gchar *book_id = l->data;
g_variant_builder_add (builder, "s", book_id);
}
@@ -162,17 +160,16 @@ store_books_disabled (DhSettings *settings)
variant = g_variant_builder_end (builder);
g_variant_builder_unref (builder);
- g_settings_set_value (priv->gsettings_contents, "books-disabled", variant);
+ g_settings_set_value (settings->priv->gsettings_contents, "books-disabled", variant);
}
static GList *
find_in_books_disabled (DhSettings *settings,
const gchar *book_id)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
GList *node;
- for (node = priv->books_disabled; node != NULL; node = node->next) {
+ for (node = settings->priv->books_disabled; node != NULL; node = node->next) {
const gchar *cur_book_id = node->data;
if (g_strcmp0 (book_id, cur_book_id) == 0)
@@ -186,7 +183,6 @@ static void
enable_book (DhSettings *settings,
const gchar *book_id)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
GList *node;
node = find_in_books_disabled (settings, book_id);
@@ -196,7 +192,7 @@ enable_book (DhSettings *settings,
return;
g_free (node->data);
- priv->books_disabled = g_list_delete_link (priv->books_disabled, node);
+ settings->priv->books_disabled = g_list_delete_link (settings->priv->books_disabled, node);
store_books_disabled (settings);
}
@@ -205,7 +201,6 @@ static void
disable_book (DhSettings *settings,
const gchar *book_id)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
GList *node;
node = find_in_books_disabled (settings, book_id);
@@ -214,8 +209,8 @@ disable_book (DhSettings *settings,
if (node != NULL)
return;
- priv->books_disabled = g_list_append (priv->books_disabled,
- g_strdup (book_id));
+ settings->priv->books_disabled = g_list_append (settings->priv->books_disabled,
+ g_strdup (book_id));
store_books_disabled (settings);
}
@@ -299,11 +294,10 @@ static void
dh_settings_dispose (GObject *object)
{
DhSettings *settings = DH_SETTINGS (object);
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- g_clear_object (&priv->gsettings_contents);
- g_clear_object (&priv->gsettings_fonts);
- g_clear_object (&priv->gsettings_desktop_interface);
+ g_clear_object (&settings->priv->gsettings_contents);
+ g_clear_object (&settings->priv->gsettings_fonts);
+ g_clear_object (&settings->priv->gsettings_desktop_interface);
G_OBJECT_CLASS (dh_settings_parent_class)->dispose (object);
}
@@ -312,11 +306,10 @@ static void
dh_settings_finalize (GObject *object)
{
DhSettings *settings = DH_SETTINGS (object);
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- g_list_free_full (priv->books_disabled, g_free);
- g_free (priv->variable_font);
- g_free (priv->fixed_font);
+ g_list_free_full (settings->priv->books_disabled, g_free);
+ g_free (settings->priv->variable_font);
+ g_free (settings->priv->fixed_font);
if (default_instance == settings)
default_instance = NULL;
@@ -446,24 +439,24 @@ system_font_changed_cb (GSettings *gsettings,
gchar *key,
DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- if (priv->use_system_fonts)
+ if (settings->priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
static void
dh_settings_init (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- priv->gsettings_desktop_interface = g_settings_new (SETTINGS_SCHEMA_ID_DESKTOP_INTERFACE);
+ settings->priv = dh_settings_get_instance_private (settings);
+
+ settings->priv->gsettings_desktop_interface = g_settings_new (SETTINGS_SCHEMA_ID_DESKTOP_INTERFACE);
- g_signal_connect_object (priv->gsettings_desktop_interface,
+ g_signal_connect_object (settings->priv->gsettings_desktop_interface,
"changed::" SYSTEM_FIXED_FONT_KEY,
G_CALLBACK (system_font_changed_cb),
settings,
0);
- g_signal_connect_object (priv->gsettings_desktop_interface,
+ g_signal_connect_object (settings->priv->gsettings_desktop_interface,
"changed::" SYSTEM_VARIABLE_FONT_KEY,
G_CALLBACK (system_font_changed_cb),
settings,
@@ -475,19 +468,17 @@ _dh_settings_new (const gchar *contents_path,
const gchar *fonts_path)
{
DhSettings *settings;
- DhSettingsPrivate *priv;
g_return_val_if_fail (contents_path != NULL, NULL);
settings = g_object_new (DH_TYPE_SETTINGS, NULL);
- priv = dh_settings_get_instance_private (settings);
- priv->gsettings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
- contents_path);
- priv->gsettings_fonts = g_settings_new_with_path (SETTINGS_SCHEMA_ID_FONTS,
- fonts_path);
+ settings->priv->gsettings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
+ contents_path);
+ settings->priv->gsettings_fonts = g_settings_new_with_path (SETTINGS_SCHEMA_ID_FONTS,
+ fonts_path);
- g_signal_connect_object (priv->gsettings_contents,
+ g_signal_connect_object (settings->priv->gsettings_contents,
"changed::books-disabled",
G_CALLBACK (books_disabled_changed_cb),
settings,
@@ -561,10 +552,9 @@ dh_settings_bind_all (DhSettings *settings)
gboolean
dh_settings_get_group_books_by_language (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_val_if_fail (DH_IS_SETTINGS (settings), FALSE);
- return priv->group_books_by_language;
+ return settings->priv->group_books_by_language;
}
/**
@@ -580,13 +570,12 @@ void
dh_settings_set_group_books_by_language (DhSettings *settings,
gboolean group_books_by_language)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
group_books_by_language = group_books_by_language != FALSE;
- if (priv->group_books_by_language != group_books_by_language) {
- priv->group_books_by_language = group_books_by_language;
+ if (settings->priv->group_books_by_language != group_books_by_language) {
+ settings->priv->group_books_by_language = group_books_by_language;
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_GROUP_BOOKS_BY_LANGUAGE]);
}
}
@@ -603,10 +592,9 @@ dh_settings_set_group_books_by_language (DhSettings *settings,
void
dh_settings_bind_group_books_by_language (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
- g_settings_bind (priv->gsettings_contents, "group-books-by-language",
+ g_settings_bind (settings->priv->gsettings_contents, "group-books-by-language",
settings, "group-books-by-language",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
@@ -683,10 +671,9 @@ dh_settings_set_book_enabled (DhSettings *settings,
void
dh_settings_freeze_books_disabled_changed (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
- g_signal_handlers_block_by_func (priv->gsettings_contents,
+ g_signal_handlers_block_by_func (settings->priv->gsettings_contents,
books_disabled_changed_cb,
settings);
}
@@ -705,10 +692,9 @@ dh_settings_freeze_books_disabled_changed (DhSettings *settings)
void
dh_settings_thaw_books_disabled_changed (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
- g_signal_handlers_unblock_by_func (priv->gsettings_contents,
+ g_signal_handlers_unblock_by_func (settings->priv->gsettings_contents,
books_disabled_changed_cb,
settings);
@@ -738,19 +724,18 @@ dh_settings_get_selected_fonts (DhSettings *settings,
gchar **variable_font,
gchar **fixed_font)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
g_return_if_fail (variable_font != NULL && *variable_font == NULL);
g_return_if_fail (fixed_font != NULL && *fixed_font == NULL);
- if (priv->use_system_fonts) {
- *variable_font = g_settings_get_string (priv->gsettings_desktop_interface,
+ if (settings->priv->use_system_fonts) {
+ *variable_font = g_settings_get_string (settings->priv->gsettings_desktop_interface,
SYSTEM_VARIABLE_FONT_KEY);
- *fixed_font = g_settings_get_string (priv->gsettings_desktop_interface,
+ *fixed_font = g_settings_get_string (settings->priv->gsettings_desktop_interface,
SYSTEM_FIXED_FONT_KEY);
} else {
- *variable_font = g_strdup (priv->variable_font);
- *fixed_font = g_strdup (priv->fixed_font);
+ *variable_font = g_strdup (settings->priv->variable_font);
+ *fixed_font = g_strdup (settings->priv->fixed_font);
}
}
@@ -764,10 +749,9 @@ dh_settings_get_selected_fonts (DhSettings *settings,
gboolean
dh_settings_get_use_system_fonts (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_val_if_fail (DH_IS_SETTINGS (settings), FALSE);
- return priv->use_system_fonts;
+ return settings->priv->use_system_fonts;
}
/**
@@ -783,13 +767,12 @@ void
dh_settings_set_use_system_fonts (DhSettings *settings,
gboolean use_system_fonts)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
use_system_fonts = use_system_fonts != FALSE;
- if (priv->use_system_fonts != use_system_fonts) {
- priv->use_system_fonts = use_system_fonts;
+ if (settings->priv->use_system_fonts != use_system_fonts) {
+ settings->priv->use_system_fonts = use_system_fonts;
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_USE_SYSTEM_FONTS]);
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
@@ -810,10 +793,9 @@ dh_settings_set_use_system_fonts (DhSettings *settings,
const gchar *
dh_settings_get_variable_font (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_val_if_fail (DH_IS_SETTINGS (settings), NULL);
- return priv->variable_font;
+ return settings->priv->variable_font;
}
/**
@@ -829,16 +811,15 @@ void
dh_settings_set_variable_font (DhSettings *settings,
const gchar *variable_font)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
g_return_if_fail (variable_font != NULL);
- if (g_strcmp0 (priv->variable_font, variable_font) != 0) {
- g_free (priv->variable_font);
- priv->variable_font = g_strdup (variable_font);
+ if (g_strcmp0 (settings->priv->variable_font, variable_font) != 0) {
+ g_free (settings->priv->variable_font);
+ settings->priv->variable_font = g_strdup (variable_font);
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_VARIABLE_FONT]);
- if (!priv->use_system_fonts)
+ if (!settings->priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
}
@@ -857,10 +838,9 @@ dh_settings_set_variable_font (DhSettings *settings,
const gchar *
dh_settings_get_fixed_font (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_val_if_fail (DH_IS_SETTINGS (settings), NULL);
- return priv->fixed_font;
+ return settings->priv->fixed_font;
}
/**
@@ -876,16 +856,15 @@ void
dh_settings_set_fixed_font (DhSettings *settings,
const gchar *fixed_font)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
g_return_if_fail (fixed_font != NULL);
- if (g_strcmp0 (priv->fixed_font, fixed_font) != 0) {
- g_free (priv->fixed_font);
- priv->fixed_font = g_strdup (fixed_font);
+ if (g_strcmp0 (settings->priv->fixed_font, fixed_font) != 0) {
+ g_free (settings->priv->fixed_font);
+ settings->priv->fixed_font = g_strdup (fixed_font);
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_FIXED_FONT]);
- if (!priv->use_system_fonts)
+ if (!settings->priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
}
@@ -902,20 +881,19 @@ dh_settings_set_fixed_font (DhSettings *settings,
void
dh_settings_bind_fonts (DhSettings *settings)
{
- DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
g_return_if_fail (DH_IS_SETTINGS (settings));
- g_settings_bind (priv->gsettings_fonts, "use-system-fonts",
+ g_settings_bind (settings->priv->gsettings_fonts, "use-system-fonts",
settings, "use-system-fonts",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
- g_settings_bind (priv->gsettings_fonts, "variable-font",
+ g_settings_bind (settings->priv->gsettings_fonts, "variable-font",
settings, "variable-font",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
- g_settings_bind (priv->gsettings_fonts, "fixed-font",
+ g_settings_bind (settings->priv->gsettings_fonts, "fixed-font",
settings, "fixed-font",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
diff --git a/devhelp/dh-settings.h b/devhelp/dh-settings.h
index 185f0f70..7d45dd84 100644
--- a/devhelp/dh-settings.h
+++ b/devhelp/dh-settings.h
@@ -19,7 +19,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_SETTINGS_H
+#define DH_SETTINGS_H
#include <gio/gio.h>
#include <devhelp/dh-book.h>
@@ -27,7 +28,20 @@
G_BEGIN_DECLS
#define DH_TYPE_SETTINGS (dh_settings_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhSettings, dh_settings, DH, SETTINGS, GObject)
+#define DH_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SETTINGS, DhSettings))
+#define DH_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SETTINGS))
+#define DH_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SETTINGS,
DhSettingsClass))
+#define DH_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SETTINGS))
+#define DH_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_SETTINGS,
DhSettingsClass))
+
+typedef struct _DhSettings DhSettings;
+typedef struct _DhSettingsClass DhSettingsClass;
+typedef struct _DhSettingsPrivate DhSettingsPrivate;
+
+struct _DhSettings {
+ GObject parent;
+ DhSettingsPrivate *priv;
+};
struct _DhSettingsClass {
GObjectClass parent;
@@ -40,37 +54,58 @@ struct _DhSettingsClass {
gpointer padding[12];
};
+GType dh_settings_get_type (void) G_GNUC_CONST;
+
G_GNUC_INTERNAL
-DhSettings *_dh_settings_new (const gchar *contents_path,
- const gchar *fonts_path);
-DhSettings *dh_settings_get_default (void);
+DhSettings * _dh_settings_new (const gchar *contents_path,
+ const gchar *fonts_path);
+
+DhSettings * dh_settings_get_default (void);
+
G_GNUC_INTERNAL
-void _dh_settings_unref_default (void);
-void dh_settings_bind_all (DhSettings *settings);
-gboolean dh_settings_get_group_books_by_language (DhSettings *settings);
-void dh_settings_set_group_books_by_language (DhSettings *settings,
- gboolean group_books_by_language);
-void dh_settings_bind_group_books_by_language (DhSettings *settings);
-gboolean dh_settings_is_book_enabled (DhSettings *settings,
- DhBook *book);
-void dh_settings_set_book_enabled (DhSettings *settings,
- DhBook *book,
- gboolean enabled);
-void dh_settings_freeze_books_disabled_changed (DhSettings *settings);
-void dh_settings_thaw_books_disabled_changed (DhSettings *settings);
-void dh_settings_get_selected_fonts (DhSettings *settings,
- gchar **variable_font,
- gchar **fixed_font);
-gboolean dh_settings_get_use_system_fonts (DhSettings *settings);
-void dh_settings_set_use_system_fonts (DhSettings *settings,
- gboolean use_system_fonts);
-const gchar *dh_settings_get_variable_font (DhSettings *settings);
-void dh_settings_set_variable_font (DhSettings *settings,
- const gchar *variable_font);
-const gchar *dh_settings_get_fixed_font (DhSettings *settings);
-void dh_settings_set_fixed_font (DhSettings *settings,
- const gchar *fixed_font);
-void dh_settings_bind_fonts (DhSettings *settings);
+void _dh_settings_unref_default (void);
+
+void dh_settings_bind_all (DhSettings *settings);
+
+gboolean dh_settings_get_group_books_by_language (DhSettings *settings);
+
+void dh_settings_set_group_books_by_language (DhSettings *settings,
+ gboolean group_books_by_language);
+
+void dh_settings_bind_group_books_by_language (DhSettings *settings);
+
+gboolean dh_settings_is_book_enabled (DhSettings *settings,
+ DhBook *book);
+
+void dh_settings_set_book_enabled (DhSettings *settings,
+ DhBook *book,
+ gboolean enabled);
+
+void dh_settings_freeze_books_disabled_changed (DhSettings *settings);
+
+void dh_settings_thaw_books_disabled_changed (DhSettings *settings);
+
+void dh_settings_get_selected_fonts (DhSettings *settings,
+ gchar **variable_font,
+ gchar **fixed_font);
+
+gboolean dh_settings_get_use_system_fonts (DhSettings *settings);
+
+void dh_settings_set_use_system_fonts (DhSettings *settings,
+ gboolean use_system_fonts);
+
+const gchar * dh_settings_get_variable_font (DhSettings *settings);
+
+void dh_settings_set_variable_font (DhSettings *settings,
+ const gchar *variable_font);
+
+const gchar * dh_settings_get_fixed_font (DhSettings *settings);
+
+void dh_settings_set_fixed_font (DhSettings *settings,
+ const gchar *fixed_font);
+
+void dh_settings_bind_fonts (DhSettings *settings);
G_END_DECLS
+#endif /* DH_SETTINGS_H */
diff --git a/devhelp/dh-sidebar.h b/devhelp/dh-sidebar.h
index 4033f42b..5bddd776 100644
--- a/devhelp/dh-sidebar.h
+++ b/devhelp/dh-sidebar.h
@@ -21,7 +21,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_SIDEBAR_H
+#define DH_SIDEBAR_H
#include <gtk/gtk.h>
#include <devhelp/dh-book-manager.h>
@@ -31,7 +32,17 @@
G_BEGIN_DECLS
#define DH_TYPE_SIDEBAR (dh_sidebar_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhSidebar, dh_sidebar, DH, SIDEBAR, GtkGrid)
+#define DH_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SIDEBAR, DhSidebar))
+#define DH_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SIDEBAR, DhSidebarClass))
+#define DH_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SIDEBAR))
+#define DH_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SIDEBAR))
+
+typedef struct _DhSidebar DhSidebar;
+typedef struct _DhSidebarClass DhSidebarClass;
+
+struct _DhSidebar {
+ GtkGrid parent_instance;
+};
struct _DhSidebarClass {
GtkGridClass parent_class;
@@ -44,6 +55,8 @@ struct _DhSidebarClass {
gpointer padding[12];
};
+GType dh_sidebar_get_type (void);
+
G_DEPRECATED_FOR (dh_sidebar_new2)
GtkWidget * dh_sidebar_new (DhBookManager *book_manager);
@@ -63,3 +76,4 @@ void dh_sidebar_set_search_focus (DhSidebar *sidebar);
G_END_DECLS
+#endif /* DH_SIDEBAR_H */
diff --git a/devhelp/dh-tab-label.c b/devhelp/dh-tab-label.c
index e2951664..32844a8f 100644
--- a/devhelp/dh-tab-label.c
+++ b/devhelp/dh-tab-label.c
@@ -32,9 +32,7 @@
* close button.
*/
-struct _DhTabLabel {
- GtkGrid parent_instance;
-
+struct _DhTabLabelPrivate {
/* Weak ref */
DhTab *tab;
@@ -49,7 +47,7 @@ enum {
static GParamSpec *properties[N_PROPERTIES];
-G_DEFINE_TYPE (DhTabLabel, dh_tab_label, GTK_TYPE_GRID)
+G_DEFINE_TYPE_WITH_PRIVATE (DhTabLabel, dh_tab_label, GTK_TYPE_GRID)
static void
update_label (DhTabLabel *tab_label)
@@ -57,12 +55,12 @@ update_label (DhTabLabel *tab_label)
DhWebView *web_view;
const gchar *title;
- if (tab_label->tab == NULL)
+ if (tab_label->priv->tab == NULL)
return;
- web_view = dh_tab_get_web_view (tab_label->tab);
+ web_view = dh_tab_get_web_view (tab_label->priv->tab);
title = dh_web_view_get_devhelp_title (web_view);
- gtk_label_set_text (tab_label->label, title);
+ gtk_label_set_text (tab_label->priv->label, title);
}
static void
@@ -84,10 +82,10 @@ set_tab (DhTabLabel *tab_label,
g_return_if_fail (DH_IS_TAB (tab));
- g_assert (tab_label->tab == NULL);
- tab_label->tab = tab;
- g_object_add_weak_pointer (G_OBJECT (tab_label->tab),
- (gpointer *) &tab_label->tab);
+ g_assert (tab_label->priv->tab == NULL);
+ tab_label->priv->tab = tab;
+ g_object_add_weak_pointer (G_OBJECT (tab_label->priv->tab),
+ (gpointer *) &tab_label->priv->tab);
web_view = dh_tab_get_web_view (tab);
g_signal_connect_object (web_view,
@@ -142,10 +140,10 @@ dh_tab_label_dispose (GObject *object)
{
DhTabLabel *tab_label = DH_TAB_LABEL (object);
- if (tab_label->tab != NULL) {
- g_object_remove_weak_pointer (G_OBJECT (tab_label->tab),
- (gpointer *) &tab_label->tab);
- tab_label->tab = NULL;
+ if (tab_label->priv->tab != NULL) {
+ g_object_remove_weak_pointer (G_OBJECT (tab_label->priv->tab),
+ (gpointer *) &tab_label->priv->tab);
+ tab_label->priv->tab = NULL;
}
G_OBJECT_CLASS (dh_tab_label_parent_class)->dispose (object);
@@ -201,8 +199,8 @@ static void
close_button_clicked_cb (GtkButton *close_button,
DhTabLabel *tab_label)
{
- if (tab_label->tab != NULL)
- gtk_widget_destroy (GTK_WIDGET (tab_label->tab));
+ if (tab_label->priv->tab != NULL)
+ gtk_widget_destroy (GTK_WIDGET (tab_label->priv->tab));
}
static void
@@ -210,19 +208,21 @@ dh_tab_label_init (DhTabLabel *tab_label)
{
GtkWidget *close_button;
+ tab_label->priv = dh_tab_label_get_instance_private (tab_label);
+
gtk_grid_set_column_spacing (GTK_GRID (tab_label), 4);
/* Label */
- tab_label->label = GTK_LABEL (gtk_label_new (NULL));
- gtk_widget_set_hexpand (GTK_WIDGET (tab_label->label), TRUE);
- gtk_widget_set_vexpand (GTK_WIDGET (tab_label->label), TRUE);
- gtk_widget_set_halign (GTK_WIDGET (tab_label->label), GTK_ALIGN_CENTER);
- gtk_label_set_ellipsize (tab_label->label, PANGO_ELLIPSIZE_END);
+ tab_label->priv->label = GTK_LABEL (gtk_label_new (NULL));
+ gtk_widget_set_hexpand (GTK_WIDGET (tab_label->priv->label), TRUE);
+ gtk_widget_set_vexpand (GTK_WIDGET (tab_label->priv->label), TRUE);
+ gtk_widget_set_halign (GTK_WIDGET (tab_label->priv->label), GTK_ALIGN_CENTER);
+ gtk_label_set_ellipsize (tab_label->priv->label, PANGO_ELLIPSIZE_END);
- gtk_widget_show (GTK_WIDGET (tab_label->label));
+ gtk_widget_show (GTK_WIDGET (tab_label->priv->label));
gtk_container_add (GTK_CONTAINER (tab_label),
- GTK_WIDGET (tab_label->label));
+ GTK_WIDGET (tab_label->priv->label));
/* Close button */
@@ -266,5 +266,5 @@ dh_tab_label_get_tab (DhTabLabel *tab_label)
{
g_return_val_if_fail (DH_IS_TAB_LABEL (tab_label), NULL);
- return tab_label->tab;
+ return tab_label->priv->tab;
}
diff --git a/devhelp/dh-tab-label.h b/devhelp/dh-tab-label.h
index 59c3ef5c..543aefe2 100644
--- a/devhelp/dh-tab-label.h
+++ b/devhelp/dh-tab-label.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_TAB_LABEL_H
+#define DH_TAB_LABEL_H
#include <gtk/gtk.h>
#include <devhelp/dh-tab.h>
@@ -26,10 +27,35 @@
G_BEGIN_DECLS
#define DH_TYPE_TAB_LABEL (dh_tab_label_get_type ())
-G_DECLARE_FINAL_TYPE (DhTabLabel, dh_tab_label, DH, TAB_LABEL, GtkGrid)
+#define DH_TAB_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_TAB_LABEL, DhTabLabel))
+#define DH_TAB_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_TAB_LABEL, DhTabLabelClass))
+#define DH_IS_TAB_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_TAB_LABEL))
+#define DH_IS_TAB_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_TAB_LABEL))
+#define DH_TAB_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_TAB_LABEL, DhTabLabelClass))
-GtkWidget *dh_tab_label_new (DhTab *tab);
-DhTab *dh_tab_label_get_tab (DhTabLabel *tab_label);
+typedef struct _DhTabLabel DhTabLabel;
+typedef struct _DhTabLabelClass DhTabLabelClass;
+typedef struct _DhTabLabelPrivate DhTabLabelPrivate;
+
+struct _DhTabLabel {
+ GtkGrid parent;
+
+ DhTabLabelPrivate *priv;
+};
+
+struct _DhTabLabelClass {
+ GtkGridClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_tab_label_get_type (void);
+
+GtkWidget * dh_tab_label_new (DhTab *tab);
+
+DhTab * dh_tab_label_get_tab (DhTabLabel *tab_label);
G_END_DECLS
+#endif /* DH_TAB_LABEL_H */
diff --git a/devhelp/dh-tab.c b/devhelp/dh-tab.c
index 49be28c6..093b8e73 100644
--- a/devhelp/dh-tab.c
+++ b/devhelp/dh-tab.c
@@ -30,9 +30,7 @@
* applications can add more widgets to the #GtkGrid.
*/
-struct _DhTab {
- GtkGrid parent_instance;
-
+struct _DhTabPrivate {
DhWebView *web_view;
};
@@ -44,7 +42,7 @@ enum {
static GParamSpec *properties[N_PROPERTIES];
-G_DEFINE_TYPE (DhTab, dh_tab, GTK_TYPE_GRID)
+G_DEFINE_TYPE_WITH_PRIVATE (DhTab, dh_tab, GTK_TYPE_GRID)
static void
set_web_view (DhTab *tab,
@@ -55,10 +53,10 @@ set_web_view (DhTab *tab,
g_return_if_fail (DH_IS_WEB_VIEW (web_view));
- g_assert (tab->web_view == NULL);
- tab->web_view = g_object_ref_sink (web_view);
+ g_assert (tab->priv->web_view == NULL);
+ tab->priv->web_view = g_object_ref_sink (web_view);
- gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (tab->web_view));
+ gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (tab->priv->web_view));
}
static void
@@ -107,7 +105,7 @@ dh_tab_constructed (GObject *object)
if (G_OBJECT_CLASS (dh_tab_parent_class)->constructed != NULL)
G_OBJECT_CLASS (dh_tab_parent_class)->constructed (object);
- if (tab->web_view == NULL) {
+ if (tab->priv->web_view == NULL) {
DhWebView *web_view;
web_view = dh_web_view_new (NULL);
@@ -121,7 +119,7 @@ dh_tab_dispose (GObject *object)
{
DhTab *tab = DH_TAB (object);
- g_clear_object (&tab->web_view);
+ g_clear_object (&tab->priv->web_view);
G_OBJECT_CLASS (dh_tab_parent_class)->dispose (object);
}
@@ -159,6 +157,8 @@ dh_tab_class_init (DhTabClass *klass)
static void
dh_tab_init (DhTab *tab)
{
+ tab->priv = dh_tab_get_instance_private (tab);
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (tab), GTK_ORIENTATION_VERTICAL);
}
@@ -192,5 +192,5 @@ dh_tab_get_web_view (DhTab *tab)
{
g_return_val_if_fail (DH_IS_TAB (tab), NULL);
- return tab->web_view;
+ return tab->priv->web_view;
}
diff --git a/devhelp/dh-tab.h b/devhelp/dh-tab.h
index ed5d685f..d11980f3 100644
--- a/devhelp/dh-tab.h
+++ b/devhelp/dh-tab.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_TAB_H
+#define DH_TAB_H
#include <gtk/gtk.h>
#include <devhelp/dh-web-view.h>
@@ -26,9 +27,35 @@
G_BEGIN_DECLS
#define DH_TYPE_TAB (dh_tab_get_type ())
-G_DECLARE_FINAL_TYPE (DhTab, dh_tab, DH, TAB, GtkGrid)
+#define DH_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_TAB, DhTab))
+#define DH_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_TAB, DhTabClass))
+#define DH_IS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_TAB))
+#define DH_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_TAB))
+#define DH_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_TAB, DhTabClass))
+
+typedef struct _DhTab DhTab;
+typedef struct _DhTabClass DhTabClass;
+typedef struct _DhTabPrivate DhTabPrivate;
+
+struct _DhTab {
+ GtkGrid parent;
+
+ DhTabPrivate *priv;
+};
+
+struct _DhTabClass {
+ GtkGridClass parent_class;
+
+ /* Padding for future expansion */
+ gpointer padding[12];
+};
+
+GType dh_tab_get_type (void);
+
+DhTab * dh_tab_new (DhWebView *web_view);
+
+DhWebView * dh_tab_get_web_view (DhTab *tab);
-DhTab *dh_tab_new (DhWebView *web_view);
-DhWebView *dh_tab_get_web_view (DhTab *tab);
G_END_DECLS
+#endif /* DH_TAB_H */
diff --git a/devhelp/dh-util-lib.h b/devhelp/dh-util-lib.h
index 7a0be694..6f59ed8d 100644
--- a/devhelp/dh-util-lib.h
+++ b/devhelp/dh-util-lib.h
@@ -20,7 +20,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_UTIL_LIB_H
+#define DH_UTIL_LIB_H
#include <gio/gio.h>
#include "dh-notebook.h"
@@ -55,3 +56,4 @@ void _dh_util_bind_sidebar_and_notebook (DhSidebar *sidebar,
G_END_DECLS
+#endif /* DH_UTIL_LIB_H */
diff --git a/devhelp/dh-web-view.c b/devhelp/dh-web-view.c
index 96dac85a..cfc907cb 100644
--- a/devhelp/dh-web-view.c
+++ b/devhelp/dh-web-view.c
@@ -46,11 +46,11 @@
* opening the URL with gtk_show_uri_on_window().
*/
-typedef struct {
+struct _DhWebViewPrivate {
DhProfile *profile;
gchar *search_text;
gdouble total_scroll_delta_y;
-} DhWebViewPrivate;
+};
enum {
PROP_0,
@@ -129,7 +129,6 @@ dh_web_view_scroll_event (GtkWidget *widget,
GdkEventScroll *scroll_event)
{
DhWebView *view = DH_WEB_VIEW (widget);
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
gdouble delta_y;
if ((scroll_event->state & GDK_CONTROL_MASK) == 0)
@@ -150,17 +149,17 @@ dh_web_view_scroll_event (GtkWidget *widget,
case GDK_SCROLL_SMOOTH:
gdk_event_get_scroll_deltas ((GdkEvent *)scroll_event, NULL, &delta_y);
- priv->total_scroll_delta_y += delta_y;
+ view->priv->total_scroll_delta_y += delta_y;
/* Avoiding direct float comparison.
* -1 and 1 are the thresholds for bumping the zoom level,
* which can be adjusted for taste.
*/
- if ((gint)priv->total_scroll_delta_y <= -1) {
- priv->total_scroll_delta_y = 0.f;
+ if ((gint)view->priv->total_scroll_delta_y <= -1) {
+ view->priv->total_scroll_delta_y = 0.f;
bump_zoom_level (view, 1);
- } else if ((gint)priv->total_scroll_delta_y >= 1) {
- priv->total_scroll_delta_y = 0.f;
+ } else if ((gint)view->priv->total_scroll_delta_y >= 1) {
+ view->priv->total_scroll_delta_y = 0.f;
bump_zoom_level (view, -1);
}
return GDK_EVENT_STOP;
@@ -236,7 +235,6 @@ find_equivalent_local_uri (DhWebView *view,
GList *books;
GList *book_node;
gchar *local_uri = NULL;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
g_return_val_if_fail (uri != NULL, NULL);
@@ -258,7 +256,7 @@ find_equivalent_local_uri (DhWebView *view,
goto out;
}
- book_list = dh_profile_get_book_list (priv->profile);
+ book_list = dh_profile_get_book_list (view->priv->profile);
books = dh_book_list_get_books (book_list);
for (book_node = books; book_node != NULL; book_node = book_node->next) {
@@ -374,15 +372,13 @@ static void
set_profile (DhWebView *view,
DhProfile *profile)
{
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
-
if (profile == NULL)
return;
g_return_if_fail (DH_IS_PROFILE (profile));
- g_assert (priv->profile == NULL);
- priv->profile = g_object_ref (profile);
+ g_assert (view->priv->profile == NULL);
+ view->priv->profile = g_object_ref (profile);
}
static void
@@ -465,9 +461,8 @@ update_fonts (DhWebView *view)
DhSettings *settings;
gchar *variable_font = NULL;
gchar *fixed_font = NULL;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
- settings = dh_profile_get_settings (priv->profile);
+ settings = dh_profile_get_settings (view->priv->profile);
dh_settings_get_selected_fonts (settings, &variable_font, &fixed_font);
set_fonts (WEBKIT_WEB_VIEW (view), variable_font, fixed_font);
@@ -489,7 +484,6 @@ dh_web_view_constructed (GObject *object)
DhWebView *view = DH_WEB_VIEW (object);
WebKitSettings *webkit_settings;
DhSettings *dh_settings;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
if (G_OBJECT_CLASS (dh_web_view_parent_class)->constructed != NULL)
G_OBJECT_CLASS (dh_web_view_parent_class)->constructed (object);
@@ -500,10 +494,10 @@ dh_web_view_constructed (GObject *object)
webkit_settings_set_enable_html5_local_storage (webkit_settings, FALSE);
webkit_settings_set_enable_plugins (webkit_settings, FALSE);
- if (priv->profile == NULL)
+ if (view->priv->profile == NULL)
set_profile (view, dh_profile_get_default ());
- dh_settings = dh_profile_get_settings (priv->profile);
+ dh_settings = dh_profile_get_settings (view->priv->profile);
g_signal_connect_object (dh_settings,
"fonts-changed",
G_CALLBACK (settings_fonts_changed_cb),
@@ -517,9 +511,8 @@ static void
dh_web_view_dispose (GObject *object)
{
DhWebView *view = DH_WEB_VIEW (object);
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
- g_clear_object (&priv->profile);
+ g_clear_object (&view->priv->profile);
G_OBJECT_CLASS (dh_web_view_parent_class)->dispose (object);
}
@@ -528,9 +521,8 @@ static void
dh_web_view_finalize (GObject *object)
{
DhWebView *view = DH_WEB_VIEW (object);
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
- g_free (priv->search_text);
+ g_free (view->priv->search_text);
G_OBJECT_CLASS (dh_web_view_parent_class)->finalize (object);
}
@@ -597,8 +589,8 @@ dh_web_view_class_init (DhWebViewClass *klass)
static void
dh_web_view_init (DhWebView *view)
{
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
- priv->total_scroll_delta_y = 0.f;
+ view->priv = dh_web_view_get_instance_private (view);
+ view->priv->total_scroll_delta_y = 0.f;
gtk_widget_set_hexpand (GTK_WIDGET (view), TRUE);
gtk_widget_set_vexpand (GTK_WIDGET (view), TRUE);
@@ -631,10 +623,9 @@ dh_web_view_new (DhProfile *profile)
DhProfile *
dh_web_view_get_profile (DhWebView *view)
{
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
g_return_val_if_fail (DH_IS_WEB_VIEW (view), NULL);
- return priv->profile;
+ return view->priv->profile;
}
/**
@@ -680,15 +671,14 @@ dh_web_view_set_search_text (DhWebView *view,
const gchar *search_text)
{
WebKitFindController *find_controller;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
g_return_if_fail (DH_IS_WEB_VIEW (view));
- if (g_strcmp0 (priv->search_text, search_text) == 0)
+ if (g_strcmp0 (view->priv->search_text, search_text) == 0)
return;
- g_free (priv->search_text);
- priv->search_text = g_strdup (search_text);
+ g_free (view->priv->search_text);
+ view->priv->search_text = g_strdup (search_text);
find_controller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
@@ -726,11 +716,10 @@ void
dh_web_view_search_next (DhWebView *view)
{
WebKitFindController *find_controller;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
g_return_if_fail (DH_IS_WEB_VIEW (view));
- if (priv->search_text == NULL || priv->search_text[0] == '\0')
+ if (view->priv->search_text == NULL || view->priv->search_text[0] == '\0')
return;
find_controller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
@@ -750,11 +739,10 @@ void
dh_web_view_search_previous (DhWebView *view)
{
WebKitFindController *find_controller;
- DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
g_return_if_fail (DH_IS_WEB_VIEW (view));
- if (priv->search_text == NULL || priv->search_text[0] == '\0')
+ if (view->priv->search_text == NULL || view->priv->search_text[0] == '\0')
return;
find_controller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
diff --git a/devhelp/dh-web-view.h b/devhelp/dh-web-view.h
index 1eed66eb..a3c1880a 100644
--- a/devhelp/dh-web-view.h
+++ b/devhelp/dh-web-view.h
@@ -18,7 +18,8 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_WEB_VIEW_H
+#define DH_WEB_VIEW_H
#include <webkit2/webkit2.h>
#include <devhelp/dh-profile.h>
@@ -26,7 +27,21 @@
G_BEGIN_DECLS
#define DH_TYPE_WEB_VIEW (dh_web_view_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhWebView, dh_web_view, DH, WEB_VIEW, WebKitWebView)
+#define DH_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_WEB_VIEW, DhWebView))
+#define DH_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_WEB_VIEW, DhWebViewClass))
+#define DH_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_WEB_VIEW))
+#define DH_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_WEB_VIEW))
+#define DH_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_WEB_VIEW, DhWebViewClass))
+
+typedef struct _DhWebView DhWebView;
+typedef struct _DhWebViewClass DhWebViewClass;
+typedef struct _DhWebViewPrivate DhWebViewPrivate;
+
+struct _DhWebView {
+ WebKitWebView parent;
+
+ DhWebViewPrivate *priv;
+};
struct _DhWebViewClass {
WebKitWebViewClass parent_class;
@@ -39,19 +54,33 @@ struct _DhWebViewClass {
gpointer padding[12];
};
-DhWebView *dh_web_view_new (DhProfile *profile);
-DhProfile *dh_web_view_get_profile (DhWebView *view);
-const gchar *dh_web_view_get_devhelp_title (DhWebView *view);
-void dh_web_view_set_search_text (DhWebView *view,
- const gchar *search_text);
-void dh_web_view_search_next (DhWebView *view);
-void dh_web_view_search_previous (DhWebView *view);
-gboolean dh_web_view_can_zoom_in (DhWebView *view);
-gboolean dh_web_view_can_zoom_out (DhWebView *view);
-gboolean dh_web_view_can_reset_zoom (DhWebView *view);
-void dh_web_view_zoom_in (DhWebView *view);
-void dh_web_view_zoom_out (DhWebView *view);
-void dh_web_view_reset_zoom (DhWebView *view);
+GType dh_web_view_get_type (void);
+
+DhWebView * dh_web_view_new (DhProfile *profile);
+
+DhProfile * dh_web_view_get_profile (DhWebView *view);
+
+const gchar * dh_web_view_get_devhelp_title (DhWebView *view);
+
+void dh_web_view_set_search_text (DhWebView *view,
+ const gchar *search_text);
+
+void dh_web_view_search_next (DhWebView *view);
+
+void dh_web_view_search_previous (DhWebView *view);
+
+gboolean dh_web_view_can_zoom_in (DhWebView *view);
+
+gboolean dh_web_view_can_zoom_out (DhWebView *view);
+
+gboolean dh_web_view_can_reset_zoom (DhWebView *view);
+
+void dh_web_view_zoom_in (DhWebView *view);
+
+void dh_web_view_zoom_out (DhWebView *view);
+
+void dh_web_view_reset_zoom (DhWebView *view);
G_END_DECLS
+#endif /* DH_WEB_VIEW_H */
diff --git a/src/dh-app.c b/src/dh-app.c
index b7979b9e..a9c3dfb9 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -85,12 +85,12 @@ new_window_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhApp *self = DH_APP (user_data);
+ DhApp *app = DH_APP (user_data);
GtkWidget *new_window;
- save_active_main_window_gsettings (self);
+ save_active_main_window_gsettings (app);
- new_window = dh_window_new (GTK_APPLICATION (self));
+ new_window = dh_window_new (GTK_APPLICATION (app));
gtk_widget_show_all (new_window);
}
diff --git a/src/dh-app.h b/src/dh-app.h
index dabb3629..1d60918e 100644
--- a/src/dh-app.h
+++ b/src/dh-app.h
@@ -18,7 +18,9 @@
* You should have received a copy of the GNU General Public License
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+
+#ifndef DH_APP_H
+#define DH_APP_H
#include <gtk/gtk.h>
#include "dh-window.h"
@@ -26,15 +28,30 @@
G_BEGIN_DECLS
#define DH_TYPE_APP (dh_app_get_type ())
+#define DH_APP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DH_TYPE_APP, DhApp))
+#define DH_APP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DH_TYPE_APP, DhAppClass))
+#define DH_IS_APP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DH_TYPE_APP))
+#define DH_IS_APP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DH_TYPE_APP))
+#define DH_APP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DH_TYPE_APP, DhAppClass))
+
+typedef struct _DhApp DhApp;
+typedef struct _DhAppClass DhAppClass;
-G_DECLARE_DERIVABLE_TYPE (DhApp, dh_app, DH, APP, GtkApplication)
+struct _DhApp {
+ GtkApplication parent_instance;
+};
struct _DhAppClass {
GtkApplicationClass parent_class;
};
-DhApp *dh_app_new (void);
-DhWindow *dh_app_get_active_main_window (DhApp *app,
- gboolean create_if_none);
+GType dh_app_get_type (void) G_GNUC_CONST;
+
+DhApp * dh_app_new (void);
+
+DhWindow * dh_app_get_active_main_window (DhApp *app,
+ gboolean create_if_none);
G_END_DECLS
+
+#endif /* DH_APP_H */
diff --git a/src/dh-assistant.c b/src/dh-assistant.c
index 1ab4dca1..9adc8267 100644
--- a/src/dh-assistant.c
+++ b/src/dh-assistant.c
@@ -41,7 +41,7 @@ assistant_view_open_uri_cb (DhAssistantView *view,
app = DH_APP (gtk_window_get_application (GTK_WINDOW (assistant)));
window = dh_app_get_active_main_window (app, TRUE);
- dh_window_display_uri (window, uri);
+ _dh_window_display_uri (window, uri);
}
static gboolean
diff --git a/src/dh-main.c b/src/dh-main.c
index 35410a3e..545cf622 100644
--- a/src/dh-main.c
+++ b/src/dh-main.c
@@ -29,7 +29,7 @@
int
main (int argc, char **argv)
{
- g_autoptr(DhApp) application;
+ DhApp *application;
gint status;
setlocale (LC_ALL, "");
@@ -39,6 +39,7 @@ main (int argc, char **argv)
application = dh_app_new ();
status = g_application_run (G_APPLICATION (application), argc, argv);
+ g_object_unref (application);
dh_finalize ();
dh_settings_app_unref_singleton ();
diff --git a/src/dh-preferences.c b/src/dh-preferences.c
index 5141d023..94786048 100644
--- a/src/dh-preferences.c
+++ b/src/dh-preferences.c
@@ -670,7 +670,6 @@ dh_preferences_show_dialog (GtkWindow *parent)
if (prefs == NULL) {
prefs = g_object_new (DH_TYPE_PREFERENCES,
- "modal", TRUE,
"use-header-bar", TRUE,
NULL);
diff --git a/src/dh-preferences.h b/src/dh-preferences.h
index 2e73b291..a401ffcd 100644
--- a/src/dh-preferences.h
+++ b/src/dh-preferences.h
@@ -19,21 +19,35 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_PREFERENCES_H
+#define DH_PREFERENCES_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define DH_TYPE_PREFERENCES (dh_preferences_get_type ())
+#define DH_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_PREFERENCES,
DhPreferences))
+#define DH_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_PREFERENCES,
DhPreferencesClass))
+#define DH_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_PREFERENCES))
+#define DH_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_PREFERENCES))
+#define DH_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_PREFERENCES,
DhPreferencesClass))
-G_DECLARE_DERIVABLE_TYPE (DhPreferences, dh_preferences, DH, PREFERENCES, GtkDialog)
+typedef struct _DhPreferences DhPreferences;
+typedef struct _DhPreferencesClass DhPreferencesClass;
+
+struct _DhPreferences {
+ GtkDialog parent;
+};
struct _DhPreferencesClass {
GtkDialogClass parent_class;
};
-void dh_preferences_show_dialog (GtkWindow *parent);
+GType dh_preferences_get_type (void);
+
+void dh_preferences_show_dialog (GtkWindow *parent);
G_END_DECLS
+#endif /* DH_PREFERENCES_H */
diff --git a/src/dh-settings-app.c b/src/dh-settings-app.c
index f458d957..382569a4 100644
--- a/src/dh-settings-app.c
+++ b/src/dh-settings-app.c
@@ -26,11 +26,11 @@
#define SETTINGS_SCHEMA_ID_PANED "org.gnome.devhelp.state.main.paned"
#define SETTINGS_SCHEMA_ID_ASSISTANT "org.gnome.devhelp.state.assistant.window"
-typedef struct {
+struct _DhSettingsAppPrivate {
GSettings *settings_window;
GSettings *settings_paned;
GSettings *settings_assistant;
-} DhSettingsAppPrivate;
+};
/* DhSettingsApp is a singleton. */
static DhSettingsApp *singleton = NULL;
@@ -41,11 +41,10 @@ static void
dh_settings_app_dispose (GObject *object)
{
DhSettingsApp *self = DH_SETTINGS_APP (object);
- DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
- g_clear_object (&priv->settings_window);
- g_clear_object (&priv->settings_paned);
- g_clear_object (&priv->settings_assistant);
+ g_clear_object (&self->priv->settings_window);
+ g_clear_object (&self->priv->settings_paned);
+ g_clear_object (&self->priv->settings_assistant);
G_OBJECT_CLASS (dh_settings_app_parent_class)->dispose (object);
}
@@ -71,12 +70,11 @@ dh_settings_app_class_init (DhSettingsAppClass *klass)
static void
dh_settings_app_init (DhSettingsApp *self)
{
- DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
- priv = dh_settings_app_get_instance_private (self);
+ self->priv = dh_settings_app_get_instance_private (self);
- priv->settings_window = g_settings_new (SETTINGS_SCHEMA_ID_WINDOW);
- priv->settings_paned = g_settings_new (SETTINGS_SCHEMA_ID_PANED);
- priv->settings_assistant = g_settings_new (SETTINGS_SCHEMA_ID_ASSISTANT);
+ self->priv->settings_window = g_settings_new (SETTINGS_SCHEMA_ID_WINDOW);
+ self->priv->settings_paned = g_settings_new (SETTINGS_SCHEMA_ID_PANED);
+ self->priv->settings_assistant = g_settings_new (SETTINGS_SCHEMA_ID_ASSISTANT);
}
DhSettingsApp *
@@ -103,29 +101,20 @@ dh_settings_app_unref_singleton (void)
GSettings *
dh_settings_app_peek_window_settings (DhSettingsApp *self)
{
- DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
-
g_return_val_if_fail (DH_IS_SETTINGS_APP (self), NULL);
-
- return priv->settings_window;
+ return self->priv->settings_window;
}
GSettings *
dh_settings_app_peek_paned_settings (DhSettingsApp *self)
{
- DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
-
g_return_val_if_fail (DH_IS_SETTINGS_APP (self), NULL);
-
- return priv->settings_paned;
+ return self->priv->settings_paned;
}
GSettings *
dh_settings_app_peek_assistant_settings (DhSettingsApp *self)
{
- DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
-
g_return_val_if_fail (DH_IS_SETTINGS_APP (self), NULL);
-
- return priv->settings_assistant;
+ return self->priv->settings_assistant;
}
diff --git a/src/dh-settings-app.h b/src/dh-settings-app.h
index f4c11658..b9e0cc56 100644
--- a/src/dh-settings-app.h
+++ b/src/dh-settings-app.h
@@ -26,18 +26,37 @@
G_BEGIN_DECLS
-#define DH_TYPE_SETTINGS_APP (dh_settings_app_get_type ())
-G_DECLARE_DERIVABLE_TYPE (DhSettingsApp, dh_settings_app, DH, SETTINGS_APP, GObject)
+#define DH_TYPE_SETTINGS_APP (dh_settings_app_get_type ())
+#define DH_SETTINGS_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_SETTINGS_APP,
DhSettingsApp))
+#define DH_IS_SETTINGS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_SETTINGS_APP))
+#define DH_SETTINGS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_SETTINGS_APP,
DhSettingsAppClass))
+#define DH_IS_SETTINGS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_SETTINGS_APP))
+#define DH_SETTINGS_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_SETTINGS_APP,
DhSettingsAppClass))
+
+typedef struct _DhSettingsApp DhSettingsApp;
+typedef struct _DhSettingsAppClass DhSettingsAppClass;
+typedef struct _DhSettingsAppPrivate DhSettingsAppPrivate;
+
+struct _DhSettingsApp {
+ GObject parent;
+ DhSettingsAppPrivate *priv;
+};
struct _DhSettingsAppClass {
GObjectClass parent;
};
-DhSettingsApp *dh_settings_app_get_singleton (void);
-void dh_settings_app_unref_singleton (void);
-GSettings *dh_settings_app_peek_window_settings (DhSettingsApp *self);
-GSettings *dh_settings_app_peek_paned_settings (DhSettingsApp *self);
-GSettings *dh_settings_app_peek_assistant_settings (DhSettingsApp *self);
+GType dh_settings_app_get_type (void);
+
+DhSettingsApp * dh_settings_app_get_singleton (void);
+
+void dh_settings_app_unref_singleton (void);
+
+GSettings * dh_settings_app_peek_window_settings (DhSettingsApp *self);
+
+GSettings * dh_settings_app_peek_paned_settings (DhSettingsApp *self);
+
+GSettings * dh_settings_app_peek_assistant_settings (DhSettingsApp *self);
G_END_DECLS
diff --git a/src/dh-window.c b/src/dh-window.c
index c1bed48d..460e7815 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -608,8 +608,8 @@ dh_window_search (DhWindow *window,
/* Only call this with a URI that is known to be in the docs. */
void
-dh_window_display_uri (DhWindow *window,
- const gchar *uri)
+_dh_window_display_uri (DhWindow *window,
+ const gchar *uri)
{
DhWebView *web_view;
diff --git a/src/dh-window.h b/src/dh-window.h
index ab27b114..d568fbbb 100644
--- a/src/dh-window.h
+++ b/src/dh-window.h
@@ -21,26 +21,41 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#pragma once
+#ifndef DH_WINDOW_H
+#define DH_WINDOW_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define DH_TYPE_WINDOW (dh_window_get_type ())
+#define DH_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DH_TYPE_WINDOW, DhWindow))
+#define DH_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DH_TYPE_WINDOW, DhWindowClass))
+#define DH_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DH_TYPE_WINDOW))
+#define DH_IS_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DH_TYPE_WINDOW))
+#define DH_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DH_TYPE_WINDOW, DhWindowClass))
-G_DECLARE_DERIVABLE_TYPE (DhWindow, dh_window, DH, WINDOW, GtkApplicationWindow)
+typedef struct _DhWindow DhWindow;
+typedef struct _DhWindowClass DhWindowClass;
+
+struct _DhWindow {
+ GtkApplicationWindow parent_instance;
+};
struct _DhWindowClass {
GtkApplicationWindowClass parent_class;
};
+GType dh_window_get_type (void) G_GNUC_CONST;
+
+GtkWidget * dh_window_new (GtkApplication *application);
+
+void dh_window_search (DhWindow *window,
+ const gchar *str);
-GtkWidget *dh_window_new (GtkApplication *application);
-void dh_window_search (DhWindow *window,
- const gchar *str);
-void dh_window_display_uri (DhWindow *window,
- const gchar *uri);
+void _dh_window_display_uri (DhWindow *window,
+ const gchar *uri);
G_END_DECLS
+#endif /* DH_WINDOW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]