[devhelp] modernize the code base
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] modernize the code base
- Date: Thu, 30 Aug 2018 19:08:21 +0000 (UTC)
commit 4f65b8c38f1e7ee3328b67caea61e5a589796ad9
Author: Günther Wagner <info gunibert de>
Date: Fri Aug 17 08:27:58 2018 +0200
modernize the code base
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 | 7 +-
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, 602 insertions(+), 1034 deletions(-)
---
diff --git a/devhelp/dh-application-window.h b/devhelp/dh-application-window.h
index 2005b713..106191e8 100644
--- a/devhelp/dh-application-window.h
+++ b/devhelp/dh-application-window.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_APPLICATION_WINDOW_H
-#define DH_APPLICATION_WINDOW_H
+#pragma once
#include <glib.h>
#include <devhelp/dh-notebook.h>
@@ -32,4 +31,3 @@ 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 602206f2..12c53922 100644
--- a/devhelp/dh-assistant-view.h
+++ b/devhelp/dh-assistant-view.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_ASSISTANT_VIEW_H
-#define DH_ASSISTANT_VIEW_H
+#pragma once
#include <webkit2/webkit2.h>
#include <devhelp/dh-link.h>
@@ -27,18 +26,7 @@
G_BEGIN_DECLS
#define DH_TYPE_ASSISTANT_VIEW (dh_assistant_view_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhAssistantView, dh_assistant_view, DH, ASSISTANT_VIEW, WebKitWebView)
struct _DhAssistantViewClass {
WebKitWebViewClass parent_class;
@@ -47,16 +35,10 @@ struct _DhAssistantViewClass {
gpointer padding[12];
};
-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);
-
+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 14dbf4e3..0f385e32 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.
*/
-struct _DhBookListBuilderPrivate {
+typedef struct {
/* List of DhBookList*. */
GList *sub_book_lists;
DhSettings *settings;
-};
+} DhBookListBuilderPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (DhBookListBuilder, dh_book_list_builder, G_TYPE_OBJECT)
@@ -51,11 +51,12 @@ 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 (builder->priv->sub_book_lists, g_object_unref);
- builder->priv->sub_book_lists = NULL;
+ g_list_free_full (priv->sub_book_lists, g_object_unref);
+ priv->sub_book_lists = NULL;
- g_clear_object (&builder->priv->settings);
+ g_clear_object (&priv->settings);
G_OBJECT_CLASS (dh_book_list_builder_parent_class)->dispose (object);
}
@@ -71,7 +72,6 @@ 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,11 +106,13 @@ 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));
- builder->priv->sub_book_lists = g_list_append (builder->priv->sub_book_lists,
- g_object_ref (sub_book_list));
+ priv->sub_book_lists = g_list_append (priv->sub_book_lists,
+ g_object_ref (sub_book_list));
}
static void
@@ -233,10 +235,12 @@ 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 (&builder->priv->settings, settings);
+ g_set_object (&priv->settings, settings);
}
/**
@@ -252,8 +256,10 @@ 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 (builder->priv->sub_book_lists,
- builder->priv->settings);
+ return _dh_book_list_simple_new (priv->sub_book_lists,
+ priv->settings);
}
diff --git a/devhelp/dh-book-list-builder.h b/devhelp/dh-book-list-builder.h
index 395149e7..243b0ce8 100644
--- a/devhelp/dh-book-list-builder.h
+++ b/devhelp/dh-book-list-builder.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_LIST_BUILDER_H
-#define DH_BOOK_LIST_BUILDER_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -28,21 +27,7 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST_BUILDER (dh_book_list_builder_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhBookListBuilder, dh_book_list_builder, DH, BOOK_LIST_BUILDER, GObject)
struct _DhBookListBuilderClass {
GObjectClass parent_class;
@@ -51,21 +36,13 @@ struct _DhBookListBuilderClass {
gpointer padding[12];
};
-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);
+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 a61c05c5..5e0ac0e5 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;
-struct _DhBookListDirectoryPrivate {
+typedef struct {
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 = data->list_directory->priv;
+ DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private
(data->list_directory);
data->timeout_id = 0;
@@ -238,7 +238,7 @@ books_directory_changed_cb (GFileMonitor *directory_monitor,
GFileMonitorEvent event_type,
DhBookListDirectory *list_directory)
{
- DhBookListDirectoryPrivate *priv = list_directory->priv;
+ DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
NewPossibleBookData *data;
/* With the GFileMonitor here we only handle events for new directories
@@ -266,17 +266,18 @@ static void
monitor_books_directory (DhBookListDirectory *list_directory)
{
GError *error = NULL;
+ DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
- 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);
+ g_assert (priv->directory_monitor == NULL);
+ priv->directory_monitor = g_file_monitor_directory (priv->directory,
+ G_FILE_MONITOR_NONE,
+ NULL,
+ &error);
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (list_directory->priv->directory);
+ parse_name = g_file_get_parse_name (priv->directory);
g_warning ("Failed to create file monitor on directory “%s”: %s",
parse_name,
@@ -286,8 +287,8 @@ monitor_books_directory (DhBookListDirectory *list_directory)
g_clear_error (&error);
}
- if (list_directory->priv->directory_monitor != NULL) {
- g_signal_connect_object (list_directory->priv->directory_monitor,
+ if (priv->directory_monitor != NULL) {
+ g_signal_connect_object (priv->directory_monitor,
"changed",
G_CALLBACK (books_directory_changed_cb),
list_directory,
@@ -300,8 +301,9 @@ 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 (list_directory->priv->directory,
+ enumerator = g_file_enumerate_children (priv->directory,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
NULL,
@@ -315,7 +317,7 @@ find_books (DhBookListDirectory *list_directory)
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (list_directory->priv->directory);
+ parse_name = g_file_get_parse_name (priv->directory);
g_warning ("Error when reading directory '%s': %s",
parse_name,
@@ -336,7 +338,7 @@ find_books (DhBookListDirectory *list_directory)
if (error != NULL) {
gchar *parse_name;
- parse_name = g_file_get_parse_name (list_directory->priv->directory);
+ parse_name = g_file_get_parse_name (priv->directory);
g_warning ("Error when enumerating directory '%s': %s",
parse_name,
@@ -361,10 +363,11 @@ static void
set_directory (DhBookListDirectory *list_directory,
GFile *directory)
{
- g_assert (list_directory->priv->directory == NULL);
+ DhBookListDirectoryPrivate *priv = dh_book_list_directory_get_instance_private (list_directory);
+ g_assert (priv->directory == NULL);
g_return_if_fail (G_IS_FILE (directory));
- list_directory->priv->directory = g_object_ref (directory);
+ priv->directory = g_object_ref (directory);
find_books (list_directory);
}
@@ -410,12 +413,13 @@ 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 (&list_directory->priv->directory);
- g_clear_object (&list_directory->priv->directory_monitor);
+ g_clear_object (&priv->directory);
+ g_clear_object (&priv->directory_monitor);
- 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_slist_free_full (priv->new_possible_books_data, new_possible_book_data_free);
+ priv->new_possible_books_data = NULL;
G_OBJECT_CLASS (dh_book_list_directory_parent_class)->dispose (object);
}
@@ -462,8 +466,6 @@ 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);
}
@@ -493,9 +495,10 @@ 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 (cur_list_directory->priv->directory != NULL &&
- g_file_equal (cur_list_directory->priv->directory, directory))
+ if (priv->directory != NULL &&
+ g_file_equal (priv->directory, directory))
return g_object_ref (cur_list_directory);
}
@@ -514,7 +517,9 @@ 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 list_directory->priv->directory;
+ return priv->directory;
}
diff --git a/devhelp/dh-book-list-directory.h b/devhelp/dh-book-list-directory.h
index 1aade54f..bc732c29 100644
--- a/devhelp/dh-book-list-directory.h
+++ b/devhelp/dh-book-list-directory.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_LIST_DIRECTORY_H
-#define DH_BOOK_LIST_DIRECTORY_H
+#pragma once
#include <gio/gio.h>
#include <devhelp/dh-book-list.h>
@@ -27,21 +26,7 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST_DIRECTORY (dh_book_list_directory_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhBookListDirectory, dh_book_list_directory, DH, BOOK_LIST_DIRECTORY, DhBookList)
struct _DhBookListDirectoryClass {
DhBookListClass parent_class;
@@ -50,12 +35,8 @@ struct _DhBookListDirectoryClass {
gpointer padding[12];
};
-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);
+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 de476ffe..4770fc38 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"
-struct _DhBookListSimplePrivate {
+typedef struct {
/* 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,17 +41,18 @@ 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 (list_simple->priv->sub_book_lists, g_object_unref);
- list_simple->priv->sub_book_lists = NULL;
+ g_list_free_full (priv->sub_book_lists, g_object_unref);
+ priv->sub_book_lists = NULL;
- g_clear_object (&list_simple->priv->settings);
+ g_clear_object (&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);
@@ -59,9 +60,8 @@ _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,16 +69,17 @@ 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 (list_simple->priv->settings == NULL)
+ if (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 (list_simple->priv->settings, book))
+ if (dh_settings_is_book_enabled (priv->settings, book))
new_list = g_list_prepend (new_list, g_object_ref (book));
}
@@ -92,8 +93,9 @@ 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 = list_simple->priv->sub_book_lists;
+ for (book_list_node = 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);
@@ -103,7 +105,7 @@ generate_list (DhBookListSimple *list_simple)
books = dh_book_list_get_books (book_list);
/* First DhBookList, take all DhBook's. */
- if (book_list_node == list_simple->priv->sub_book_lists) {
+ if (book_list_node == priv->sub_book_lists) {
g_assert (ret == NULL);
ret = g_list_copy_deep (books, book_copy_func, NULL);
continue;
@@ -173,9 +175,10 @@ 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 (list_simple->priv->sub_book_lists == NULL);
+ g_assert (priv->sub_book_lists == NULL);
for (l = sub_book_lists; l != NULL; l = l->next) {
DhBookList *book_list;
@@ -186,8 +189,8 @@ set_sub_book_lists (DhBookListSimple *list_simple,
}
book_list = l->data;
- list_simple->priv->sub_book_lists = g_list_prepend (list_simple->priv->sub_book_lists,
- g_object_ref (book_list));
+ priv->sub_book_lists = g_list_prepend (priv->sub_book_lists,
+ g_object_ref (book_list));
g_signal_connect_object (book_list,
"add-book",
@@ -202,7 +205,7 @@ set_sub_book_lists (DhBookListSimple *list_simple,
G_CONNECT_AFTER);
}
- list_simple->priv->sub_book_lists = g_list_reverse (list_simple->priv->sub_book_lists);
+ priv->sub_book_lists = g_list_reverse (priv->sub_book_lists);
}
static void
@@ -218,14 +221,16 @@ _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) {
- list_simple->priv->settings = g_object_ref (settings);
+ 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 414d518e..644672f7 100644
--- a/devhelp/dh-book-list-simple.h
+++ b/devhelp/dh-book-list-simple.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_LIST_SIMPLE_H
-#define DH_BOOK_LIST_SIMPLE_H
+#pragma once
#include <glib-object.h>
#include "dh-book-list.h"
@@ -27,22 +26,8 @@
G_BEGIN_DECLS
-#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;
-};
+#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)
struct _DhBookListSimpleClass {
DhBookListClass parent_class;
@@ -52,12 +37,7 @@ struct _DhBookListSimpleClass {
};
G_GNUC_INTERNAL
-GType _dh_book_list_simple_get_type (void);
-
-G_GNUC_INTERNAL
-DhBookList * _dh_book_list_simple_new (GList *sub_book_lists,
- DhSettings *settings);
-
+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 791e8fcc..d2c4b7f4 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.
*/
-struct _DhBookListPrivate {
+typedef struct {
/* The list of DhBook's. */
GList *books;
-};
+} DhBookListPrivate;
enum {
SIGNAL_ADD_BOOK,
@@ -57,7 +57,8 @@ static gboolean
book_id_present_in_list (DhBookList *book_list,
DhBook *book)
{
- return g_list_find_custom (book_list->priv->books,
+ DhBookListPrivate *priv = dh_book_list_get_instance_private (book_list);
+ return g_list_find_custom (priv->books,
book,
(GCompareFunc) dh_book_cmp_by_id) != NULL;
}
@@ -66,9 +67,10 @@ 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 (book_list->priv->books, g_object_unref);
- book_list->priv->books = NULL;
+ g_list_free_full (priv->books, g_object_unref);
+ priv->books = NULL;
G_OBJECT_CLASS (dh_book_list_parent_class)->dispose (object);
}
@@ -86,24 +88,26 @@ 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));
- book_list->priv->books = g_list_prepend (book_list->priv->books,
- g_object_ref (book));
+ priv->books = g_list_prepend (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 (book_list->priv->books, book);
+ node = g_list_find (priv->books, book);
g_return_if_fail (node != NULL);
- book_list->priv->books = g_list_delete_link (book_list->priv->books, node);
+ priv->books = g_list_delete_link (priv->books, node);
- if (g_list_find (book_list->priv->books, book) != NULL)
+ if (g_list_find (priv->books, book) != NULL)
g_warning ("The same DhBook was inserted several times.");
g_object_unref (book);
@@ -112,7 +116,10 @@ dh_book_list_remove_book_default (DhBookList *book_list,
static GList *
dh_book_list_get_books_default (DhBookList *book_list)
{
- return book_list->priv->books;
+ 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;
}
static void
@@ -177,7 +184,6 @@ 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 9660715d..5ae74d72 100644
--- a/devhelp/dh-book-list.h
+++ b/devhelp/dh-book-list.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_LIST_H
-#define DH_BOOK_LIST_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-book.h>
@@ -27,21 +26,7 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_LIST (dh_book_list_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhBookList, dh_book_list, DH, BOOK_LIST, GObject)
/**
* DhBookListClass:
@@ -59,36 +44,24 @@ 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];
};
-GType dh_book_list_get_type (void);
-
-DhBookList * dh_book_list_new (void);
-
-DhBookList * dh_book_list_get_default (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 a499960d..55d99e59 100644
--- a/devhelp/dh-book-manager.c
+++ b/devhelp/dh-book-manager.c
@@ -39,6 +39,10 @@
* </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 8251e588..aef79a43 100644
--- a/devhelp/dh-book-manager.h
+++ b/devhelp/dh-book-manager.h
@@ -19,42 +19,19 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_MANAGER_H
-#define DH_BOOK_MANAGER_H
+#pragma once
#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 ())
-#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_DECLARE_FINAL_TYPE (DhBookManager, dh_book_manager, DH, BOOK_MANAGER, GObject)
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 f9bad5cf..287c4054 100644
--- a/devhelp/dh-book-tree.c
+++ b/devhelp/dh-book-tree.c
@@ -46,6 +46,10 @@
* emitted. Only one element can be selected at a time.
*/
+struct _DhBookTree {
+ GtkTreeView parent_instance;
+};
+
typedef struct {
DhProfile *profile;
GtkTreeStore *store;
@@ -106,7 +110,7 @@ book_tree_selection_changed_cb (GtkTreeSelection *selection,
if (link != NULL &&
link != priv->selected_link) {
- g_clear_pointer (&priv->selected_link, (GDestroyNotify)dh_link_unref);
+ g_clear_pointer (&priv->selected_link, dh_link_unref);
priv->selected_link = dh_link_ref (link);
g_signal_emit (tree, signals[LINK_SELECTED], 0, link);
}
@@ -581,7 +585,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, (GDestroyNotify)dh_link_unref);
+ g_clear_pointer (&priv->selected_link, dh_link_unref);
priv->selected_link = link;
gtk_tree_selection_select_iter (selection, &iter);
}
@@ -718,7 +722,7 @@ dh_book_tree_dispose (GObject *object)
g_clear_object (&priv->profile);
g_clear_object (&priv->store);
- g_clear_pointer (&priv->selected_link, (GDestroyNotify)dh_link_unref);
+ g_clear_pointer (&priv->selected_link, 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 d6f4c16b..58a3ea7c 100644
--- a/devhelp/dh-book-tree.h
+++ b/devhelp/dh-book-tree.h
@@ -19,8 +19,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_TREE_H
-#define DH_BOOK_TREE_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-link.h>
@@ -29,36 +28,13 @@
G_BEGIN_DECLS
#define DH_TYPE_BOOK_TREE (dh_book_tree_get_type ())
-#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))
+G_DECLARE_FINAL_TYPE (DhBookTree, dh_book_tree, DH, BOOK_TREE, GtkTreeView)
-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);
+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 94143b61..9ea9f8b0 100644
--- a/devhelp/dh-book.h
+++ b/devhelp/dh-book.h
@@ -22,27 +22,16 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_BOOK_H
-#define DH_BOOK_H
+#pragma once
+#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 ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhBook, dh_book, DH, BOOK, GObject)
struct _DhBookClass {
GObjectClass parent_class;
@@ -51,30 +40,17 @@ struct _DhBookClass {
gpointer padding[12];
};
-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);
-
+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 21ea0c24..2ee68ff5 100644
--- a/devhelp/dh-completion.c
+++ b/devhelp/dh-completion.c
@@ -43,10 +43,10 @@
* from the #GList.
*/
-struct _DhCompletionPrivate {
+typedef struct {
/* Element types: gchar*, owned. */
GSequence *sequence;
-};
+} DhCompletionPrivate;
typedef struct {
const gchar *prefix;
@@ -86,8 +86,9 @@ static void
dh_completion_finalize (GObject *object)
{
DhCompletion *completion = DH_COMPLETION (object);
+ DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
- g_sequence_free (completion->priv->sequence);
+ g_sequence_free (priv->sequence);
G_OBJECT_CLASS (dh_completion_parent_class)->finalize (object);
}
@@ -103,9 +104,8 @@ dh_completion_class_init (DhCompletionClass *klass)
static void
dh_completion_init (DhCompletion *completion)
{
- completion->priv = dh_completion_get_instance_private (completion);
-
- completion->priv->sequence = g_sequence_new (g_free);
+ DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
+ priv->sequence = g_sequence_new (g_free);
}
/**
@@ -135,10 +135,12 @@ 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 (completion->priv->sequence, g_strdup (str));
+ g_sequence_append (priv->sequence, g_strdup (str));
}
/**
@@ -153,9 +155,11 @@ 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 (completion->priv->sequence,
+ g_sequence_sort (priv->sequence,
compare_func,
NULL);
}
@@ -256,6 +260,7 @@ do_complete (DhCompletion *completion,
const gchar *prefix,
gboolean *found_string_with_prefix)
{
+ DhCompletionPrivate *priv = dh_completion_get_instance_private (completion);
GSequenceIter *iter;
CompletionData data;
@@ -265,7 +270,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 (completion->priv->sequence,
+ iter = g_sequence_search (priv->sequence,
(gpointer) prefix,
compare_func,
NULL);
diff --git a/devhelp/dh-completion.h b/devhelp/dh-completion.h
index 7f9b0d7c..cbd16a9b 100644
--- a/devhelp/dh-completion.h
+++ b/devhelp/dh-completion.h
@@ -18,29 +18,14 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_COMPLETION_H
-#define DH_COMPLETION_H
+#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
#define DH_TYPE_COMPLETION (dh_completion_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhCompletion, dh_completion, DH, COMPLETION, GObject)
struct _DhCompletionClass {
GObjectClass parent_class;
@@ -49,21 +34,14 @@ struct _DhCompletionClass {
gpointer padding[12];
};
-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);
+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 bab5f977..a0800ca8 100644
--- a/devhelp/dh-keyword-model.c
+++ b/devhelp/dh-keyword-model.c
@@ -75,6 +75,10 @@
* 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 4dd0bfa6..fd1d3b58 100644
--- a/devhelp/dh-keyword-model.h
+++ b/devhelp/dh-keyword-model.h
@@ -20,8 +20,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_KEYWORD_MODEL_H
-#define DH_KEYWORD_MODEL_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-link.h>
@@ -30,25 +29,7 @@
G_BEGIN_DECLS
#define DH_TYPE_KEYWORD_MODEL (dh_keyword_model_get_type ())
-#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];
-};
+G_DECLARE_FINAL_TYPE (DhKeywordModel, dh_keyword_model, DH, KEYWORD_MODEL, GObject)
enum {
DH_KEYWORD_MODEL_COL_NAME,
@@ -57,15 +38,11 @@ enum {
DH_KEYWORD_MODEL_NUM_COLS
};
-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);
+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 51641f51..a9532ac7 100644
--- a/devhelp/dh-link.h
+++ b/devhelp/dh-link.h
@@ -20,8 +20,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_LINK_H
-#define DH_LINK_H
+#pragma once
#include <glib-object.h>
@@ -113,4 +112,3 @@ 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 e31bd043..233b21ca 100644
--- a/devhelp/dh-notebook.c
+++ b/devhelp/dh-notebook.c
@@ -33,9 +33,9 @@
* #DhTab.
*/
-struct _DhNotebookPrivate {
+typedef struct {
DhProfile *profile;
-};
+} DhNotebookPrivate;
enum {
PROP_0,
@@ -51,13 +51,14 @@ 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 (notebook->priv->profile == NULL);
- notebook->priv->profile = g_object_ref (profile);
+ g_assert (priv->profile == NULL);
+ priv->profile = g_object_ref (profile);
}
static void
@@ -102,11 +103,12 @@ 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 (notebook->priv->profile == NULL)
+ if (priv->profile == NULL)
set_profile (notebook, dh_profile_get_default ());
}
@@ -114,8 +116,9 @@ static void
dh_notebook_dispose (GObject *object)
{
DhNotebook *notebook = DH_NOTEBOOK (object);
+ DhNotebookPrivate *priv = dh_notebook_get_instance_private (notebook);
- g_clear_object (¬ebook->priv->profile);
+ g_clear_object (&priv->profile);
G_OBJECT_CLASS (dh_notebook_parent_class)->dispose (object);
}
@@ -188,8 +191,6 @@ 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);
}
@@ -220,9 +221,10 @@ 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 notebook->priv->profile;
+ return priv->profile;
}
static void
@@ -255,10 +257,11 @@ 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 (notebook->priv->profile);
+ web_view = dh_web_view_new (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 68209d36..e1411fb2 100644
--- a/devhelp/dh-notebook.h
+++ b/devhelp/dh-notebook.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_NOTEBOOK_H
-#define DH_NOTEBOOK_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-profile.h>
@@ -29,21 +28,7 @@
G_BEGIN_DECLS
#define DH_TYPE_NOTEBOOK (dh_notebook_get_type ())
-#define DH_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DH_TYPE_NOTEBOOK, DhNotebook))
-#define DH_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DH_TYPE_NOTEBOOK, DhNotebookClass))
-#define DH_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DH_TYPE_NOTEBOOK))
-#define DH_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DH_TYPE_NOTEBOOK))
-#define DH_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DH_TYPE_NOTEBOOK, DhNotebookClass))
-
-typedef struct _DhNotebook DhNotebook;
-typedef struct _DhNotebookClass DhNotebookClass;
-typedef struct _DhNotebookPrivate DhNotebookPrivate;
-
-struct _DhNotebook {
- GtkNotebook parent;
-
- DhNotebookPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE (DhNotebook, dh_notebook, DH, NOTEBOOK, GtkNotebook)
struct _DhNotebookClass {
GtkNotebookClass parent_class;
@@ -52,22 +37,14 @@ struct _DhNotebookClass {
gpointer padding[12];
};
-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);
+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 6cfe46c1..fdbc0656 100644
--- a/devhelp/dh-parser.h
+++ b/devhelp/dh-parser.h
@@ -20,8 +20,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_PARSER_H
-#define DH_PARSER_H
+#pragma once
#include <gio/gio.h>
@@ -38,4 +37,3 @@ 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 16ec6f3a..5ab4be85 100644
--- a/devhelp/dh-profile-builder.c
+++ b/devhelp/dh-profile-builder.c
@@ -35,10 +35,14 @@
* but it is implemented in a simpler way, to have less boilerplate.
*/
-struct _DhProfileBuilderPrivate {
+struct _DhProfileBuilder {
+ GObject parent_instance;
+};
+
+typedef struct {
DhSettings *settings;
DhBookList *book_list;
-};
+} DhProfileBuilderPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (DhProfileBuilder, dh_profile_builder, G_TYPE_OBJECT)
@@ -46,9 +50,10 @@ 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 (&builder->priv->settings);
- g_clear_object (&builder->priv->book_list);
+ g_clear_object (&priv->settings);
+ g_clear_object (&priv->book_list);
G_OBJECT_CLASS (dh_profile_builder_parent_class)->dispose (object);
}
@@ -64,7 +69,6 @@ dh_profile_builder_class_init (DhProfileBuilderClass *klass)
static void
dh_profile_builder_init (DhProfileBuilder *builder)
{
- builder->priv = dh_profile_builder_get_instance_private (builder);
}
/**
@@ -95,10 +99,12 @@ 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 (&builder->priv->settings, settings);
+ g_set_object (&priv->settings, settings);
}
/**
@@ -117,10 +123,12 @@ 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 (&builder->priv->book_list, book_list);
+ g_set_object (&priv->book_list, book_list);
}
/**
@@ -133,18 +141,20 @@ 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 (builder->priv->settings == NULL)
+ if (priv->settings == NULL)
dh_profile_builder_set_settings (builder, dh_settings_get_default ());
- if (builder->priv->book_list == NULL)
+ if (priv->book_list == NULL)
dh_profile_builder_set_book_list (builder, dh_book_list_get_default ());
- return _dh_profile_new (builder->priv->settings,
- builder->priv->book_list);
+ return _dh_profile_new (priv->settings,
+ priv->book_list);
}
diff --git a/devhelp/dh-profile-builder.h b/devhelp/dh-profile-builder.h
index 25e409cc..d116b14a 100644
--- a/devhelp/dh-profile-builder.h
+++ b/devhelp/dh-profile-builder.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_PROFILE_BUILDER_H
-#define DH_PROFILE_BUILDER_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -29,41 +28,14 @@
G_BEGIN_DECLS
#define DH_TYPE_PROFILE_BUILDER (dh_profile_builder_get_type ())
-#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))
+G_DECLARE_FINAL_TYPE (DhProfileBuilder, dh_profile_builder, DH, PROFILE_BUILDER, GObject)
-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);
+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 0a058734..c8be6fda 100644
--- a/devhelp/dh-profile.c
+++ b/devhelp/dh-profile.c
@@ -47,11 +47,14 @@
* 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;
+};
-struct _DhProfilePrivate {
+typedef struct {
DhSettings *settings;
DhBookList *book_list;
-};
+} DhProfilePrivate;
static DhProfile *default_instance = NULL;
@@ -61,9 +64,10 @@ static void
dh_profile_dispose (GObject *object)
{
DhProfile *profile = DH_PROFILE (object);
+ DhProfilePrivate *priv = dh_profile_get_instance_private (profile);
- g_clear_object (&profile->priv->settings);
- g_clear_object (&profile->priv->book_list);
+ g_clear_object (&priv->settings);
+ g_clear_object (&priv->book_list);
G_OBJECT_CLASS (dh_profile_parent_class)->dispose (object);
}
@@ -89,7 +93,6 @@ dh_profile_class_init (DhProfileClass *klass)
static void
dh_profile_init (DhProfile *profile)
{
- profile->priv = dh_profile_get_instance_private (profile);
}
DhProfile *
@@ -97,13 +100,15 @@ _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);
- profile->priv->settings = g_object_ref (settings);
- profile->priv->book_list = g_object_ref (book_list);
+ priv = dh_profile_get_instance_private (profile);
+ priv->settings = g_object_ref (settings);
+ priv->book_list = g_object_ref (book_list);
return profile;
}
@@ -157,9 +162,10 @@ _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 profile->priv->settings;
+ return priv->settings;
}
/**
@@ -175,7 +181,8 @@ 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 profile->priv->book_list;
+ return priv->book_list;
}
diff --git a/devhelp/dh-profile.h b/devhelp/dh-profile.h
index 5af1bfc3..4098a264 100644
--- a/devhelp/dh-profile.h
+++ b/devhelp/dh-profile.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_PROFILE_H
-#define DH_PROFILE_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-book-list.h>
@@ -28,44 +27,16 @@
G_BEGIN_DECLS
#define DH_TYPE_PROFILE (dh_profile_get_type ())
-#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_DECLARE_FINAL_TYPE (DhProfile, dh_profile, DH, PROFILE, GObject)
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 872dff8a..e0b3e5c4 100644
--- a/devhelp/dh-search-bar.c
+++ b/devhelp/dh-search-bar.c
@@ -37,10 +37,10 @@
* you).
*/
-struct _DhSearchBarPrivate {
+typedef struct {
DhNotebook *notebook;
GtkSearchEntry *search_entry;
-};
+} DhSearchBarPrivate;
enum {
PROP_0,
@@ -56,10 +56,14 @@ 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 (search_bar->priv->search_entry));
+ search_text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
dh_web_view_set_search_text (view, search_text);
}
@@ -67,9 +71,12 @@ 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;
- web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
+ g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
+
+ web_view = dh_notebook_get_active_web_view (priv->notebook);
if (web_view != NULL)
update_search_in_web_view (search_bar, web_view);
}
@@ -77,10 +84,13 @@ 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;
- web_views = dh_notebook_get_all_web_views (search_bar->priv->notebook);
+ g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
+
+ web_views = dh_notebook_get_all_web_views (priv->notebook);
for (l = web_views; l != NULL; l = l->next) {
DhWebView *web_view = DH_WEB_VIEW (l->data);
@@ -93,9 +103,12 @@ 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;
- web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
+ g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
+
+ web_view = dh_notebook_get_active_web_view (priv->notebook);
if (web_view == NULL)
return;
@@ -106,9 +119,12 @@ 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;
- web_view = dh_notebook_get_active_web_view (search_bar->priv->notebook);
+ g_return_if_fail (DH_IS_SEARCH_BAR (search_bar));
+
+ web_view = dh_notebook_get_active_web_view (priv->notebook);
if (web_view == NULL)
return;
@@ -180,6 +196,7 @@ 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);
@@ -191,22 +208,22 @@ dh_search_bar_constructed (GObject *object)
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
/* Search entry */
- 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);
+ priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
+ gtk_widget_set_size_request (GTK_WIDGET (priv->search_entry), 300, -1);
gtk_container_add (GTK_CONTAINER (hgrid),
- GTK_WIDGET (search_bar->priv->search_entry));
+ GTK_WIDGET (priv->search_entry));
- g_signal_connect (search_bar->priv->search_entry,
+ g_signal_connect (priv->search_entry,
"search-changed",
G_CALLBACK (search_changed_cb),
search_bar);
- g_signal_connect (search_bar->priv->search_entry,
+ g_signal_connect (priv->search_entry,
"previous-match",
G_CALLBACK (previous_match_cb),
search_bar);
- g_signal_connect (search_bar->priv->search_entry,
+ g_signal_connect (priv->search_entry,
"next-match",
G_CALLBACK (next_match_cb),
search_bar);
@@ -234,7 +251,7 @@ dh_search_bar_constructed (GObject *object)
G_CALLBACK (search_mode_enabled_notify_cb),
NULL);
- g_signal_connect_object (search_bar->priv->notebook,
+ g_signal_connect_object (priv->notebook,
"switch-page",
G_CALLBACK (notebook_switch_page_after_cb),
search_bar,
@@ -244,7 +261,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 (search_bar->priv->search_entry));
+ GTK_ENTRY (priv->search_entry));
}
static void
@@ -273,11 +290,12 @@ 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 (search_bar->priv->notebook == NULL);
- search_bar->priv->notebook = g_object_ref_sink (g_value_get_object (value));
+ g_assert (priv->notebook == NULL);
+ priv->notebook = g_object_ref_sink (g_value_get_object (value));
break;
default:
@@ -290,9 +308,10 @@ 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 (&search_bar->priv->notebook);
- search_bar->priv->search_entry = NULL;
+ g_clear_object (&priv->notebook);
+ priv->search_entry = NULL;
G_OBJECT_CLASS (dh_search_bar_parent_class)->dispose (object);
}
@@ -330,7 +349,6 @@ 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);
}
/**
@@ -360,7 +378,8 @@ 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 search_bar->priv->notebook;
+ return priv->notebook;
}
diff --git a/devhelp/dh-search-bar.h b/devhelp/dh-search-bar.h
index 72f2cd7c..12e91bd5 100644
--- a/devhelp/dh-search-bar.h
+++ b/devhelp/dh-search-bar.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_SEARCH_BAR_H
-#define DH_SEARCH_BAR_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-notebook.h>
@@ -27,21 +26,7 @@
G_BEGIN_DECLS
#define DH_TYPE_SEARCH_BAR (dh_search_bar_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhSearchBar, dh_search_bar, DH, SEARCH_BAR, GtkSearchBar)
struct _DhSearchBarClass {
GtkSearchBarClass parent_class;
@@ -50,12 +35,8 @@ struct _DhSearchBarClass {
gpointer padding[12];
};
-GType dh_search_bar_get_type (void);
-
-DhSearchBar * dh_search_bar_new (DhNotebook *notebook);
-
-DhNotebook * dh_search_bar_get_notebook (DhSearchBar *search_bar);
+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 6f5ffb2c..f58fe5b5 100644
--- a/devhelp/dh-search-context.h
+++ b/devhelp/dh-search-context.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_SEARCH_CONTEXT_H
-#define DH_SEARCH_CONTEXT_H
+#pragma once
#include <glib.h>
#include "dh-book.h"
@@ -62,4 +61,3 @@ 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 fbf9aef5..b76e7b91 100644
--- a/devhelp/dh-settings-builder.c
+++ b/devhelp/dh-settings-builder.c
@@ -51,20 +51,22 @@
* but it is implemented in a simpler way, to have less boilerplate.
*/
-struct _DhSettingsBuilderPrivate {
+struct _DhSettingsBuilder {
+ GObject parent_instance;
+
gchar *contents_path;
gchar *fonts_path;
};
-G_DEFINE_TYPE_WITH_PRIVATE (DhSettingsBuilder, dh_settings_builder, G_TYPE_OBJECT)
+G_DEFINE_TYPE (DhSettingsBuilder, dh_settings_builder, G_TYPE_OBJECT)
static void
dh_settings_builder_finalize (GObject *object)
{
DhSettingsBuilder *builder = DH_SETTINGS_BUILDER (object);
- g_free (builder->priv->contents_path);
- g_free (builder->priv->fonts_path);
+ g_free (builder->contents_path);
+ g_free (builder->fonts_path);
G_OBJECT_CLASS (dh_settings_builder_parent_class)->finalize (object);
}
@@ -80,7 +82,7 @@ dh_settings_builder_class_init (DhSettingsBuilderClass *klass)
static void
dh_settings_builder_init (DhSettingsBuilder *builder)
{
- builder->priv = dh_settings_builder_get_instance_private (builder);
+ builder = dh_settings_builder_get_instance_private (builder);
}
/**
@@ -114,8 +116,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->priv->contents_path);
- builder->priv->contents_path = g_strdup (contents_path);
+ g_free (builder->contents_path);
+ builder->contents_path = g_strdup (contents_path);
}
/**
@@ -137,8 +139,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->priv->fonts_path);
- builder->priv->fonts_path = g_strdup (fonts_path);
+ g_free (builder->fonts_path);
+ builder->fonts_path = g_strdup (fonts_path);
}
/**
@@ -157,15 +159,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->priv->contents_path == NULL) {
+ if (builder->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->priv->fonts_path == NULL) {
+ if (builder->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->priv->contents_path,
- builder->priv->fonts_path);
+ return _dh_settings_new (builder->contents_path,
+ builder->fonts_path);
}
diff --git a/devhelp/dh-settings-builder.h b/devhelp/dh-settings-builder.h
index bb1f31d7..a7afea04 100644
--- a/devhelp/dh-settings-builder.h
+++ b/devhelp/dh-settings-builder.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_SETTINGS_BUILDER_H
-#define DH_SETTINGS_BUILDER_H
+#pragma once
#include <glib-object.h>
#include <devhelp/dh-settings.h>
@@ -27,42 +26,13 @@
G_BEGIN_DECLS
#define DH_TYPE_SETTINGS_BUILDER (dh_settings_builder_get_type ())
-#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_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);
G_END_DECLS
-#endif /* DH_SETTINGS_BUILDER_H */
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index 873f55fa..716046b0 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"
-struct _DhSettingsPrivate {
+typedef struct {
GSettings *gsettings_contents;
GSettings *gsettings_fonts;
GSettings *gsettings_desktop_interface;
@@ -95,7 +95,7 @@ struct _DhSettingsPrivate {
guint group_books_by_language : 1;
guint use_system_fonts : 1;
-};
+} DhSettingsPrivate;
enum {
PROP_0,
@@ -121,13 +121,14 @@ 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 (settings->priv->books_disabled, g_free);
- settings->priv->books_disabled = NULL;
+ g_list_free_full (priv->books_disabled, g_free);
+ priv->books_disabled = NULL;
- books_disabled_strv = g_settings_get_strv (settings->priv->gsettings_contents,
+ books_disabled_strv = g_settings_get_strv (priv->gsettings_contents,
"books-disabled");
if (books_disabled_strv == NULL)
@@ -135,10 +136,10 @@ load_books_disabled (DhSettings *settings)
for (i = 0; books_disabled_strv[i] != NULL; i++) {
gchar *book_id = books_disabled_strv[i];
- settings->priv->books_disabled = g_list_prepend (settings->priv->books_disabled, book_id);
+ priv->books_disabled = g_list_prepend (priv->books_disabled, book_id);
}
- settings->priv->books_disabled = g_list_reverse (settings->priv->books_disabled);
+ priv->books_disabled = g_list_reverse (priv->books_disabled);
g_free (books_disabled_strv);
}
@@ -146,13 +147,14 @@ 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 = settings->priv->books_disabled; l != NULL; l = l->next) {
+ for (l = priv->books_disabled; l != NULL; l = l->next) {
const gchar *book_id = l->data;
g_variant_builder_add (builder, "s", book_id);
}
@@ -160,16 +162,17 @@ store_books_disabled (DhSettings *settings)
variant = g_variant_builder_end (builder);
g_variant_builder_unref (builder);
- g_settings_set_value (settings->priv->gsettings_contents, "books-disabled", variant);
+ g_settings_set_value (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 = settings->priv->books_disabled; node != NULL; node = node->next) {
+ for (node = priv->books_disabled; node != NULL; node = node->next) {
const gchar *cur_book_id = node->data;
if (g_strcmp0 (book_id, cur_book_id) == 0)
@@ -183,6 +186,7 @@ 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);
@@ -192,7 +196,7 @@ enable_book (DhSettings *settings,
return;
g_free (node->data);
- settings->priv->books_disabled = g_list_delete_link (settings->priv->books_disabled, node);
+ priv->books_disabled = g_list_delete_link (priv->books_disabled, node);
store_books_disabled (settings);
}
@@ -201,6 +205,7 @@ 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);
@@ -209,8 +214,8 @@ disable_book (DhSettings *settings,
if (node != NULL)
return;
- settings->priv->books_disabled = g_list_append (settings->priv->books_disabled,
- g_strdup (book_id));
+ priv->books_disabled = g_list_append (priv->books_disabled,
+ g_strdup (book_id));
store_books_disabled (settings);
}
@@ -294,10 +299,11 @@ static void
dh_settings_dispose (GObject *object)
{
DhSettings *settings = DH_SETTINGS (object);
+ DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- g_clear_object (&settings->priv->gsettings_contents);
- g_clear_object (&settings->priv->gsettings_fonts);
- g_clear_object (&settings->priv->gsettings_desktop_interface);
+ g_clear_object (&priv->gsettings_contents);
+ g_clear_object (&priv->gsettings_fonts);
+ g_clear_object (&priv->gsettings_desktop_interface);
G_OBJECT_CLASS (dh_settings_parent_class)->dispose (object);
}
@@ -306,10 +312,11 @@ static void
dh_settings_finalize (GObject *object)
{
DhSettings *settings = DH_SETTINGS (object);
+ DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
- g_list_free_full (settings->priv->books_disabled, g_free);
- g_free (settings->priv->variable_font);
- g_free (settings->priv->fixed_font);
+ g_list_free_full (priv->books_disabled, g_free);
+ g_free (priv->variable_font);
+ g_free (priv->fixed_font);
if (default_instance == settings)
default_instance = NULL;
@@ -439,24 +446,24 @@ system_font_changed_cb (GSettings *gsettings,
gchar *key,
DhSettings *settings)
{
- if (settings->priv->use_system_fonts)
+ DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
+ if (priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
static void
dh_settings_init (DhSettings *settings)
{
- settings->priv = dh_settings_get_instance_private (settings);
-
- settings->priv->gsettings_desktop_interface = g_settings_new (SETTINGS_SCHEMA_ID_DESKTOP_INTERFACE);
+ DhSettingsPrivate *priv = dh_settings_get_instance_private (settings);
+ priv->gsettings_desktop_interface = g_settings_new (SETTINGS_SCHEMA_ID_DESKTOP_INTERFACE);
- g_signal_connect_object (settings->priv->gsettings_desktop_interface,
+ g_signal_connect_object (priv->gsettings_desktop_interface,
"changed::" SYSTEM_FIXED_FONT_KEY,
G_CALLBACK (system_font_changed_cb),
settings,
0);
- g_signal_connect_object (settings->priv->gsettings_desktop_interface,
+ g_signal_connect_object (priv->gsettings_desktop_interface,
"changed::" SYSTEM_VARIABLE_FONT_KEY,
G_CALLBACK (system_font_changed_cb),
settings,
@@ -468,17 +475,19 @@ _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);
- 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);
+ 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);
- g_signal_connect_object (settings->priv->gsettings_contents,
+ g_signal_connect_object (priv->gsettings_contents,
"changed::books-disabled",
G_CALLBACK (books_disabled_changed_cb),
settings,
@@ -552,9 +561,10 @@ 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 settings->priv->group_books_by_language;
+ return priv->group_books_by_language;
}
/**
@@ -570,12 +580,13 @@ 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 (settings->priv->group_books_by_language != group_books_by_language) {
- settings->priv->group_books_by_language = group_books_by_language;
+ if (priv->group_books_by_language != group_books_by_language) {
+ priv->group_books_by_language = group_books_by_language;
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_GROUP_BOOKS_BY_LANGUAGE]);
}
}
@@ -592,9 +603,10 @@ 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 (settings->priv->gsettings_contents, "group-books-by-language",
+ g_settings_bind (priv->gsettings_contents, "group-books-by-language",
settings, "group-books-by-language",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
@@ -671,9 +683,10 @@ 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 (settings->priv->gsettings_contents,
+ g_signal_handlers_block_by_func (priv->gsettings_contents,
books_disabled_changed_cb,
settings);
}
@@ -692,9 +705,10 @@ 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 (settings->priv->gsettings_contents,
+ g_signal_handlers_unblock_by_func (priv->gsettings_contents,
books_disabled_changed_cb,
settings);
@@ -724,18 +738,19 @@ 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 (settings->priv->use_system_fonts) {
- *variable_font = g_settings_get_string (settings->priv->gsettings_desktop_interface,
+ if (priv->use_system_fonts) {
+ *variable_font = g_settings_get_string (priv->gsettings_desktop_interface,
SYSTEM_VARIABLE_FONT_KEY);
- *fixed_font = g_settings_get_string (settings->priv->gsettings_desktop_interface,
+ *fixed_font = g_settings_get_string (priv->gsettings_desktop_interface,
SYSTEM_FIXED_FONT_KEY);
} else {
- *variable_font = g_strdup (settings->priv->variable_font);
- *fixed_font = g_strdup (settings->priv->fixed_font);
+ *variable_font = g_strdup (priv->variable_font);
+ *fixed_font = g_strdup (priv->fixed_font);
}
}
@@ -749,9 +764,10 @@ 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 settings->priv->use_system_fonts;
+ return priv->use_system_fonts;
}
/**
@@ -767,12 +783,13 @@ 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 (settings->priv->use_system_fonts != use_system_fonts) {
- settings->priv->use_system_fonts = use_system_fonts;
+ if (priv->use_system_fonts != use_system_fonts) {
+ 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);
@@ -793,9 +810,10 @@ 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 settings->priv->variable_font;
+ return priv->variable_font;
}
/**
@@ -811,15 +829,16 @@ 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 (settings->priv->variable_font, variable_font) != 0) {
- g_free (settings->priv->variable_font);
- settings->priv->variable_font = g_strdup (variable_font);
+ if (g_strcmp0 (priv->variable_font, variable_font) != 0) {
+ g_free (priv->variable_font);
+ priv->variable_font = g_strdup (variable_font);
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_VARIABLE_FONT]);
- if (!settings->priv->use_system_fonts)
+ if (!priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
}
@@ -838,9 +857,10 @@ 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 settings->priv->fixed_font;
+ return priv->fixed_font;
}
/**
@@ -856,15 +876,16 @@ 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 (settings->priv->fixed_font, fixed_font) != 0) {
- g_free (settings->priv->fixed_font);
- settings->priv->fixed_font = g_strdup (fixed_font);
+ if (g_strcmp0 (priv->fixed_font, fixed_font) != 0) {
+ g_free (priv->fixed_font);
+ priv->fixed_font = g_strdup (fixed_font);
g_object_notify_by_pspec (G_OBJECT (settings), properties[PROP_FIXED_FONT]);
- if (!settings->priv->use_system_fonts)
+ if (!priv->use_system_fonts)
g_signal_emit (settings, signals[SIGNAL_FONTS_CHANGED], 0);
}
}
@@ -881,19 +902,20 @@ 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 (settings->priv->gsettings_fonts, "use-system-fonts",
+ g_settings_bind (priv->gsettings_fonts, "use-system-fonts",
settings, "use-system-fonts",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
- g_settings_bind (settings->priv->gsettings_fonts, "variable-font",
+ g_settings_bind (priv->gsettings_fonts, "variable-font",
settings, "variable-font",
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
- g_settings_bind (settings->priv->gsettings_fonts, "fixed-font",
+ g_settings_bind (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 7d45dd84..185f0f70 100644
--- a/devhelp/dh-settings.h
+++ b/devhelp/dh-settings.h
@@ -19,8 +19,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_SETTINGS_H
-#define DH_SETTINGS_H
+#pragma once
#include <gio/gio.h>
#include <devhelp/dh-book.h>
@@ -28,20 +27,7 @@
G_BEGIN_DECLS
#define DH_TYPE_SETTINGS (dh_settings_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhSettings, dh_settings, DH, SETTINGS, GObject)
struct _DhSettingsClass {
GObjectClass parent;
@@ -54,58 +40,37 @@ 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 5bddd776..4033f42b 100644
--- a/devhelp/dh-sidebar.h
+++ b/devhelp/dh-sidebar.h
@@ -21,8 +21,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_SIDEBAR_H
-#define DH_SIDEBAR_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-book-manager.h>
@@ -32,17 +31,7 @@
G_BEGIN_DECLS
#define DH_TYPE_SIDEBAR (dh_sidebar_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhSidebar, dh_sidebar, DH, SIDEBAR, GtkGrid)
struct _DhSidebarClass {
GtkGridClass parent_class;
@@ -55,8 +44,6 @@ struct _DhSidebarClass {
gpointer padding[12];
};
-GType dh_sidebar_get_type (void);
-
G_DEPRECATED_FOR (dh_sidebar_new2)
GtkWidget * dh_sidebar_new (DhBookManager *book_manager);
@@ -76,4 +63,3 @@ 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 32844a8f..e2951664 100644
--- a/devhelp/dh-tab-label.c
+++ b/devhelp/dh-tab-label.c
@@ -32,7 +32,9 @@
* close button.
*/
-struct _DhTabLabelPrivate {
+struct _DhTabLabel {
+ GtkGrid parent_instance;
+
/* Weak ref */
DhTab *tab;
@@ -47,7 +49,7 @@ enum {
static GParamSpec *properties[N_PROPERTIES];
-G_DEFINE_TYPE_WITH_PRIVATE (DhTabLabel, dh_tab_label, GTK_TYPE_GRID)
+G_DEFINE_TYPE (DhTabLabel, dh_tab_label, GTK_TYPE_GRID)
static void
update_label (DhTabLabel *tab_label)
@@ -55,12 +57,12 @@ update_label (DhTabLabel *tab_label)
DhWebView *web_view;
const gchar *title;
- if (tab_label->priv->tab == NULL)
+ if (tab_label->tab == NULL)
return;
- web_view = dh_tab_get_web_view (tab_label->priv->tab);
+ web_view = dh_tab_get_web_view (tab_label->tab);
title = dh_web_view_get_devhelp_title (web_view);
- gtk_label_set_text (tab_label->priv->label, title);
+ gtk_label_set_text (tab_label->label, title);
}
static void
@@ -82,10 +84,10 @@ set_tab (DhTabLabel *tab_label,
g_return_if_fail (DH_IS_TAB (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);
+ g_assert (tab_label->tab == NULL);
+ tab_label->tab = tab;
+ g_object_add_weak_pointer (G_OBJECT (tab_label->tab),
+ (gpointer *) &tab_label->tab);
web_view = dh_tab_get_web_view (tab);
g_signal_connect_object (web_view,
@@ -140,10 +142,10 @@ dh_tab_label_dispose (GObject *object)
{
DhTabLabel *tab_label = DH_TAB_LABEL (object);
- 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;
+ if (tab_label->tab != NULL) {
+ g_object_remove_weak_pointer (G_OBJECT (tab_label->tab),
+ (gpointer *) &tab_label->tab);
+ tab_label->tab = NULL;
}
G_OBJECT_CLASS (dh_tab_label_parent_class)->dispose (object);
@@ -199,8 +201,8 @@ static void
close_button_clicked_cb (GtkButton *close_button,
DhTabLabel *tab_label)
{
- if (tab_label->priv->tab != NULL)
- gtk_widget_destroy (GTK_WIDGET (tab_label->priv->tab));
+ if (tab_label->tab != NULL)
+ gtk_widget_destroy (GTK_WIDGET (tab_label->tab));
}
static void
@@ -208,21 +210,19 @@ 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->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);
+ 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);
- gtk_widget_show (GTK_WIDGET (tab_label->priv->label));
+ gtk_widget_show (GTK_WIDGET (tab_label->label));
gtk_container_add (GTK_CONTAINER (tab_label),
- GTK_WIDGET (tab_label->priv->label));
+ GTK_WIDGET (tab_label->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->priv->tab;
+ return tab_label->tab;
}
diff --git a/devhelp/dh-tab-label.h b/devhelp/dh-tab-label.h
index 543aefe2..59c3ef5c 100644
--- a/devhelp/dh-tab-label.h
+++ b/devhelp/dh-tab-label.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_TAB_LABEL_H
-#define DH_TAB_LABEL_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-tab.h>
@@ -27,35 +26,10 @@
G_BEGIN_DECLS
#define DH_TYPE_TAB_LABEL (dh_tab_label_get_type ())
-#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))
+G_DECLARE_FINAL_TYPE (DhTabLabel, dh_tab_label, DH, TAB_LABEL, GtkGrid)
-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);
+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 093b8e73..49be28c6 100644
--- a/devhelp/dh-tab.c
+++ b/devhelp/dh-tab.c
@@ -30,7 +30,9 @@
* applications can add more widgets to the #GtkGrid.
*/
-struct _DhTabPrivate {
+struct _DhTab {
+ GtkGrid parent_instance;
+
DhWebView *web_view;
};
@@ -42,7 +44,7 @@ enum {
static GParamSpec *properties[N_PROPERTIES];
-G_DEFINE_TYPE_WITH_PRIVATE (DhTab, dh_tab, GTK_TYPE_GRID)
+G_DEFINE_TYPE (DhTab, dh_tab, GTK_TYPE_GRID)
static void
set_web_view (DhTab *tab,
@@ -53,10 +55,10 @@ set_web_view (DhTab *tab,
g_return_if_fail (DH_IS_WEB_VIEW (web_view));
- g_assert (tab->priv->web_view == NULL);
- tab->priv->web_view = g_object_ref_sink (web_view);
+ g_assert (tab->web_view == NULL);
+ tab->web_view = g_object_ref_sink (web_view);
- gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (tab->priv->web_view));
+ gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (tab->web_view));
}
static void
@@ -105,7 +107,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->priv->web_view == NULL) {
+ if (tab->web_view == NULL) {
DhWebView *web_view;
web_view = dh_web_view_new (NULL);
@@ -119,7 +121,7 @@ dh_tab_dispose (GObject *object)
{
DhTab *tab = DH_TAB (object);
- g_clear_object (&tab->priv->web_view);
+ g_clear_object (&tab->web_view);
G_OBJECT_CLASS (dh_tab_parent_class)->dispose (object);
}
@@ -157,8 +159,6 @@ 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->priv->web_view;
+ return tab->web_view;
}
diff --git a/devhelp/dh-tab.h b/devhelp/dh-tab.h
index d11980f3..ed5d685f 100644
--- a/devhelp/dh-tab.h
+++ b/devhelp/dh-tab.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_TAB_H
-#define DH_TAB_H
+#pragma once
#include <gtk/gtk.h>
#include <devhelp/dh-web-view.h>
@@ -27,35 +26,9 @@
G_BEGIN_DECLS
#define DH_TYPE_TAB (dh_tab_get_type ())
-#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);
+G_DECLARE_FINAL_TYPE (DhTab, dh_tab, DH, TAB, GtkGrid)
+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 6f59ed8d..7a0be694 100644
--- a/devhelp/dh-util-lib.h
+++ b/devhelp/dh-util-lib.h
@@ -20,8 +20,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_UTIL_LIB_H
-#define DH_UTIL_LIB_H
+#pragma once
#include <gio/gio.h>
#include "dh-notebook.h"
@@ -56,4 +55,3 @@ 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 cfc907cb..96dac85a 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().
*/
-struct _DhWebViewPrivate {
+typedef struct {
DhProfile *profile;
gchar *search_text;
gdouble total_scroll_delta_y;
-};
+} DhWebViewPrivate;
enum {
PROP_0,
@@ -129,6 +129,7 @@ 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)
@@ -149,17 +150,17 @@ dh_web_view_scroll_event (GtkWidget *widget,
case GDK_SCROLL_SMOOTH:
gdk_event_get_scroll_deltas ((GdkEvent *)scroll_event, NULL, &delta_y);
- view->priv->total_scroll_delta_y += delta_y;
+ 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)view->priv->total_scroll_delta_y <= -1) {
- view->priv->total_scroll_delta_y = 0.f;
+ if ((gint)priv->total_scroll_delta_y <= -1) {
+ priv->total_scroll_delta_y = 0.f;
bump_zoom_level (view, 1);
- } else if ((gint)view->priv->total_scroll_delta_y >= 1) {
- view->priv->total_scroll_delta_y = 0.f;
+ } else if ((gint)priv->total_scroll_delta_y >= 1) {
+ priv->total_scroll_delta_y = 0.f;
bump_zoom_level (view, -1);
}
return GDK_EVENT_STOP;
@@ -235,6 +236,7 @@ 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);
@@ -256,7 +258,7 @@ find_equivalent_local_uri (DhWebView *view,
goto out;
}
- book_list = dh_profile_get_book_list (view->priv->profile);
+ book_list = dh_profile_get_book_list (priv->profile);
books = dh_book_list_get_books (book_list);
for (book_node = books; book_node != NULL; book_node = book_node->next) {
@@ -372,13 +374,15 @@ 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 (view->priv->profile == NULL);
- view->priv->profile = g_object_ref (profile);
+ g_assert (priv->profile == NULL);
+ priv->profile = g_object_ref (profile);
}
static void
@@ -461,8 +465,9 @@ 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 (view->priv->profile);
+ settings = dh_profile_get_settings (priv->profile);
dh_settings_get_selected_fonts (settings, &variable_font, &fixed_font);
set_fonts (WEBKIT_WEB_VIEW (view), variable_font, fixed_font);
@@ -484,6 +489,7 @@ 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);
@@ -494,10 +500,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 (view->priv->profile == NULL)
+ if (priv->profile == NULL)
set_profile (view, dh_profile_get_default ());
- dh_settings = dh_profile_get_settings (view->priv->profile);
+ dh_settings = dh_profile_get_settings (priv->profile);
g_signal_connect_object (dh_settings,
"fonts-changed",
G_CALLBACK (settings_fonts_changed_cb),
@@ -511,8 +517,9 @@ 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 (&view->priv->profile);
+ g_clear_object (&priv->profile);
G_OBJECT_CLASS (dh_web_view_parent_class)->dispose (object);
}
@@ -521,8 +528,9 @@ 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 (view->priv->search_text);
+ g_free (priv->search_text);
G_OBJECT_CLASS (dh_web_view_parent_class)->finalize (object);
}
@@ -589,8 +597,8 @@ dh_web_view_class_init (DhWebViewClass *klass)
static void
dh_web_view_init (DhWebView *view)
{
- view->priv = dh_web_view_get_instance_private (view);
- view->priv->total_scroll_delta_y = 0.f;
+ DhWebViewPrivate *priv = dh_web_view_get_instance_private (view);
+ priv->total_scroll_delta_y = 0.f;
gtk_widget_set_hexpand (GTK_WIDGET (view), TRUE);
gtk_widget_set_vexpand (GTK_WIDGET (view), TRUE);
@@ -623,9 +631,10 @@ 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 view->priv->profile;
+ return priv->profile;
}
/**
@@ -671,14 +680,15 @@ 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 (view->priv->search_text, search_text) == 0)
+ if (g_strcmp0 (priv->search_text, search_text) == 0)
return;
- g_free (view->priv->search_text);
- view->priv->search_text = g_strdup (search_text);
+ g_free (priv->search_text);
+ priv->search_text = g_strdup (search_text);
find_controller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
@@ -716,10 +726,11 @@ 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 (view->priv->search_text == NULL || view->priv->search_text[0] == '\0')
+ if (priv->search_text == NULL || priv->search_text[0] == '\0')
return;
find_controller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
@@ -739,10 +750,11 @@ 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 (view->priv->search_text == NULL || view->priv->search_text[0] == '\0')
+ if (priv->search_text == NULL || 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 a3c1880a..1eed66eb 100644
--- a/devhelp/dh-web-view.h
+++ b/devhelp/dh-web-view.h
@@ -18,8 +18,7 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_WEB_VIEW_H
-#define DH_WEB_VIEW_H
+#pragma once
#include <webkit2/webkit2.h>
#include <devhelp/dh-profile.h>
@@ -27,21 +26,7 @@
G_BEGIN_DECLS
#define DH_TYPE_WEB_VIEW (dh_web_view_get_type ())
-#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;
-};
+G_DECLARE_DERIVABLE_TYPE (DhWebView, dh_web_view, DH, WEB_VIEW, WebKitWebView)
struct _DhWebViewClass {
WebKitWebViewClass parent_class;
@@ -54,33 +39,19 @@ struct _DhWebViewClass {
gpointer padding[12];
};
-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);
+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 a9c3dfb9..ceda548b 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -85,12 +85,13 @@ new_window_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhApp *app = DH_APP (user_data);
+ DhApp *self = DH_APP (user_data);
+ DhAppPrivate *priv = dh_app_get_instance_private (self);
GtkWidget *new_window;
- save_active_main_window_gsettings (app);
+ save_active_main_window_gsettings (self);
- new_window = dh_window_new (GTK_APPLICATION (app));
+ new_window = dh_window_new (GTK_APPLICATION (self));
gtk_widget_show_all (new_window);
}
diff --git a/src/dh-app.h b/src/dh-app.h
index 1d60918e..dabb3629 100644
--- a/src/dh-app.h
+++ b/src/dh-app.h
@@ -18,9 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-
-#ifndef DH_APP_H
-#define DH_APP_H
+#pragma once
#include <gtk/gtk.h>
#include "dh-window.h"
@@ -28,30 +26,15 @@
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;
-struct _DhApp {
- GtkApplication parent_instance;
-};
+G_DECLARE_DERIVABLE_TYPE (DhApp, dh_app, DH, APP, GtkApplication)
struct _DhAppClass {
GtkApplicationClass parent_class;
};
-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);
+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 9adc8267..1ab4dca1 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 545cf622..35410a3e 100644
--- a/src/dh-main.c
+++ b/src/dh-main.c
@@ -29,7 +29,7 @@
int
main (int argc, char **argv)
{
- DhApp *application;
+ g_autoptr(DhApp) application;
gint status;
setlocale (LC_ALL, "");
@@ -39,7 +39,6 @@ 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 94786048..5141d023 100644
--- a/src/dh-preferences.c
+++ b/src/dh-preferences.c
@@ -670,6 +670,7 @@ 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 a401ffcd..2e73b291 100644
--- a/src/dh-preferences.h
+++ b/src/dh-preferences.h
@@ -19,35 +19,21 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_PREFERENCES_H
-#define DH_PREFERENCES_H
+#pragma once
#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))
-typedef struct _DhPreferences DhPreferences;
-typedef struct _DhPreferencesClass DhPreferencesClass;
-
-struct _DhPreferences {
- GtkDialog parent;
-};
+G_DECLARE_DERIVABLE_TYPE (DhPreferences, dh_preferences, DH, PREFERENCES, GtkDialog)
struct _DhPreferencesClass {
GtkDialogClass parent_class;
};
-GType dh_preferences_get_type (void);
-
-void dh_preferences_show_dialog (GtkWindow *parent);
+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 382569a4..f458d957 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"
-struct _DhSettingsAppPrivate {
+typedef struct {
GSettings *settings_window;
GSettings *settings_paned;
GSettings *settings_assistant;
-};
+} DhSettingsAppPrivate;
/* DhSettingsApp is a singleton. */
static DhSettingsApp *singleton = NULL;
@@ -41,10 +41,11 @@ 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 (&self->priv->settings_window);
- g_clear_object (&self->priv->settings_paned);
- g_clear_object (&self->priv->settings_assistant);
+ g_clear_object (&priv->settings_window);
+ g_clear_object (&priv->settings_paned);
+ g_clear_object (&priv->settings_assistant);
G_OBJECT_CLASS (dh_settings_app_parent_class)->dispose (object);
}
@@ -70,11 +71,12 @@ dh_settings_app_class_init (DhSettingsAppClass *klass)
static void
dh_settings_app_init (DhSettingsApp *self)
{
- self->priv = dh_settings_app_get_instance_private (self);
+ DhSettingsAppPrivate *priv = dh_settings_app_get_instance_private (self);
+ priv = dh_settings_app_get_instance_private (self);
- 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);
+ 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);
}
DhSettingsApp *
@@ -101,20 +103,29 @@ 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 self->priv->settings_window;
+
+ return 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 self->priv->settings_paned;
+
+ return 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 self->priv->settings_assistant;
+
+ return priv->settings_assistant;
}
diff --git a/src/dh-settings-app.h b/src/dh-settings-app.h
index b9e0cc56..f4c11658 100644
--- a/src/dh-settings-app.h
+++ b/src/dh-settings-app.h
@@ -26,37 +26,18 @@
G_BEGIN_DECLS
-#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;
-};
+#define DH_TYPE_SETTINGS_APP (dh_settings_app_get_type ())
+G_DECLARE_DERIVABLE_TYPE (DhSettingsApp, dh_settings_app, DH, SETTINGS_APP, GObject)
struct _DhSettingsAppClass {
GObjectClass parent;
};
-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);
+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 460e7815..c1bed48d 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 d568fbbb..ab27b114 100644
--- a/src/dh-window.h
+++ b/src/dh-window.h
@@ -21,41 +21,26 @@
* along with Devhelp. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DH_WINDOW_H
-#define DH_WINDOW_H
+#pragma once
#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))
-typedef struct _DhWindow DhWindow;
-typedef struct _DhWindowClass DhWindowClass;
-
-struct _DhWindow {
- GtkApplicationWindow parent_instance;
-};
+G_DECLARE_DERIVABLE_TYPE (DhWindow, dh_window, DH, WINDOW, GtkApplicationWindow)
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);
-void _dh_window_display_uri (DhWindow *window,
- const gchar *uri);
+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);
G_END_DECLS
-#endif /* DH_WINDOW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]