[devhelp/wip/swilmet/maintenance: 10/21] Fix code indentation, replace tabs by 8 spaces
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/swilmet/maintenance: 10/21] Fix code indentation, replace tabs by 8 spaces
- Date: Sat, 23 May 2015 18:33:00 +0000 (UTC)
commit 42dd1972ba6fb12194475a1ce2cf09a7848222bc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat May 16 13:45:57 2015 +0200
Fix code indentation, replace tabs by 8 spaces
For consistency.
Only in src/dh-*.{c,h}.
src/dh-book-manager.c | 2 +-
src/dh-book-tree.c | 246 ++++++++++++++++++++++++------------------------
src/dh-book.c | 70 +++++++-------
src/dh-parser.c | 232 +++++++++++++++++++++++-----------------------
src/dh-settings.c | 36 ++++----
src/dh-settings.h | 8 +-
src/dh-window.c | 12 +-
7 files changed, 303 insertions(+), 303 deletions(-)
---
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index 51110d2..20b0317 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -406,7 +406,7 @@ book_manager_booklist_monitor_event_cb (GFileMonitor *file_monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
- gpointer user_data)
+ gpointer user_data)
{
DhBookManager *book_manager = user_data;
NewPossibleBookData *data;
diff --git a/src/dh-book-tree.c b/src/dh-book-tree.c
index 9e4059d..c47eee4 100644
--- a/src/dh-book-tree.c
+++ b/src/dh-book-tree.c
@@ -64,12 +64,12 @@ enum {
};
enum {
- COL_TITLE,
- COL_LINK,
+ COL_TITLE,
+ COL_LINK,
COL_BOOK,
- COL_WEIGHT,
+ COL_WEIGHT,
COL_UNDERLINE,
- N_COLUMNS
+ N_COLUMNS
};
enum {
@@ -167,57 +167,57 @@ dh_book_tree_init (DhBookTree *tree)
priv = dh_book_tree_get_instance_private (tree);
- priv->store = gtk_tree_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_POINTER,
+ priv->store = gtk_tree_store_new (N_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_POINTER,
G_TYPE_OBJECT,
PANGO_TYPE_WEIGHT,
PANGO_TYPE_UNDERLINE);
- priv->selected_link = NULL;
- gtk_tree_view_set_model (GTK_TREE_VIEW (tree),
- GTK_TREE_MODEL (priv->store));
+ priv->selected_link = NULL;
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree),
+ GTK_TREE_MODEL (priv->store));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
- book_tree_add_columns (tree);
+ book_tree_add_columns (tree);
- book_tree_setup_selection (tree);
+ book_tree_setup_selection (tree);
}
static void
book_tree_add_columns (DhBookTree *tree)
{
- GtkCellRenderer *cell;
- GtkTreeViewColumn *column;
-
- column = gtk_tree_view_column_new ();
-
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_attributes (column, cell,
- "text", COL_TITLE,
+ GtkCellRenderer *cell;
+ GtkTreeViewColumn *column;
+
+ column = gtk_tree_view_column_new ();
+
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
+ gtk_tree_view_column_pack_start (column, cell, TRUE);
+ gtk_tree_view_column_set_attributes (column, cell,
+ "text", COL_TITLE,
"weight", COL_WEIGHT,
"underline", COL_UNDERLINE,
- NULL);
+ NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
}
static void
book_tree_setup_selection (DhBookTree *tree)
{
- GtkTreeSelection *selection;
+ GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- g_signal_connect (selection, "changed",
- G_CALLBACK (book_tree_selection_changed_cb),
- tree);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (book_tree_selection_changed_cb),
+ tree);
}
/* Tries to find:
@@ -596,21 +596,21 @@ book_tree_book_deleted_or_disabled_cb (DhBookManager *book_manager,
static void
book_tree_insert_node (DhBookTree *tree,
- GNode *node,
+ GNode *node,
GtkTreeIter *current_iter,
DhBook *book)
{
DhBookTreePrivate *priv = dh_book_tree_get_instance_private (tree);
- DhLink *link;
+ DhLink *link;
PangoWeight weight;
- GNode *child;
+ GNode *child;
- link = node->data;
+ link = node->data;
- if (dh_link_get_link_type (link) == DH_LINK_TYPE_BOOK) {
+ if (dh_link_get_link_type (link) == DH_LINK_TYPE_BOOK) {
weight = PANGO_WEIGHT_BOLD;
- } else {
+ } else {
weight = PANGO_WEIGHT_NORMAL;
}
@@ -623,29 +623,29 @@ book_tree_insert_node (DhBookTree *tree,
COL_UNDERLINE, PANGO_UNDERLINE_NONE,
-1);
- for (child = g_node_first_child (node);
- child;
- child = g_node_next_sibling (child)) {
+ for (child = g_node_first_child (node);
+ child;
+ child = g_node_next_sibling (child)) {
GtkTreeIter iter;
/* Append new iter */
gtk_tree_store_append (priv->store, &iter, current_iter);
- book_tree_insert_node (tree, child, &iter, NULL);
- }
+ book_tree_insert_node (tree, child, &iter, NULL);
+ }
}
static void
book_tree_selection_changed_cb (GtkTreeSelection *selection,
- DhBookTree *tree)
+ DhBookTree *tree)
{
DhBookTreePrivate *priv = dh_book_tree_get_instance_private (tree);
GtkTreeIter iter;
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
DhLink *link;
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store),
- &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->store),
+ &iter,
COL_LINK, &link,
-1);
if (link) {
@@ -654,7 +654,7 @@ book_tree_selection_changed_cb (GtkTreeSelection *selection,
}
priv->selected_link = link;
}
- }
+ }
}
static void
@@ -677,17 +677,17 @@ book_tree_init_selection (DhBookTree *tree)
priv = dh_book_tree_get_instance_private (tree);
- /* Mark the first item as selected, or it would get automatically
- * selected when the treeview will get focus; but that's not even
- * enough as a selection changed would still be emitted when there
- * is no change, hence the manual tracking of selection in
- * selected_link.
- * https://bugzilla.gnome.org/show_bug.cgi?id=492206
- */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
- g_signal_handlers_block_by_func (selection,
- book_tree_selection_changed_cb,
- tree);
+ /* Mark the first item as selected, or it would get automatically
+ * selected when the treeview will get focus; but that's not even
+ * enough as a selection changed would still be emitted when there
+ * is no change, hence the manual tracking of selection in
+ * selected_link.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=492206
+ */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ g_signal_handlers_block_by_func (selection,
+ book_tree_selection_changed_cb,
+ tree);
/* If grouping by languages, get first book in the first language */
if (dh_book_manager_get_group_by_language (priv->book_manager)) {
@@ -713,9 +713,9 @@ book_tree_init_selection (DhBookTree *tree)
gtk_tree_selection_select_iter (selection, &iter);
}
- g_signal_handlers_unblock_by_func (selection,
- book_tree_selection_changed_cb,
- tree);
+ g_signal_handlers_unblock_by_func (selection,
+ book_tree_selection_changed_cb,
+ tree);
}
static void
@@ -773,13 +773,13 @@ dh_book_tree_class_init (DhBookTreeClass *klass)
signals[LINK_SELECTED] =
g_signal_new ("link-selected",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
}
GtkWidget *
@@ -790,15 +790,15 @@ dh_book_tree_new (DhBookManager *book_manager)
static gboolean
book_tree_find_uri_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- FindURIData *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ FindURIData *data)
{
- DhLink *link;
+ DhLink *link;
- gtk_tree_model_get (model, iter,
- COL_LINK, &link,
- -1);
+ gtk_tree_model_get (model, iter,
+ COL_LINK, &link,
+ -1);
if (link) {
gchar *link_uri;
@@ -811,81 +811,81 @@ book_tree_find_uri_foreach (GtkTreeModel *model,
g_free (link_uri);
}
- return data->found;
+ return data->found;
}
void
dh_book_tree_select_uri (DhBookTree *tree,
- const gchar *uri)
+ const gchar *uri)
{
DhBookTreePrivate *priv = dh_book_tree_get_instance_private (tree);
- GtkTreeSelection *selection;
- FindURIData data;
+ GtkTreeSelection *selection;
+ FindURIData data;
- data.found = FALSE;
- data.uri = uri;
+ data.found = FALSE;
+ data.uri = uri;
- gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
- (GtkTreeModelForeachFunc) book_tree_find_uri_foreach,
- &data);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
+ (GtkTreeModelForeachFunc) book_tree_find_uri_foreach,
+ &data);
- if (!data.found) {
- return;
- }
+ if (!data.found) {
+ return;
+ }
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
/* Do not re-select (which will expand current additionally) if already
* there. */
if (gtk_tree_selection_iter_is_selected (selection, &data.iter))
return;
- g_signal_handlers_block_by_func (selection,
- book_tree_selection_changed_cb,
- tree);
+ g_signal_handlers_block_by_func (selection,
+ book_tree_selection_changed_cb,
+ tree);
- gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree), data.path);
- gtk_tree_selection_select_iter (selection, &data.iter);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree), data.path, NULL, 0);
+ gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree), data.path);
+ gtk_tree_selection_select_iter (selection, &data.iter);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree), data.path, NULL, 0);
- g_signal_handlers_unblock_by_func (selection,
- book_tree_selection_changed_cb,
- tree);
+ g_signal_handlers_unblock_by_func (selection,
+ book_tree_selection_changed_cb,
+ tree);
- gtk_tree_path_free (data.path);
+ gtk_tree_path_free (data.path);
}
DhLink *
dh_book_tree_get_selected_book (DhBookTree *tree)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
- DhLink *link;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ DhLink *link;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
- if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
- return NULL;
- }
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ return NULL;
+ }
- path = gtk_tree_model_get_path (model, &iter);
+ path = gtk_tree_model_get_path (model, &iter);
- /* Get the book node for this link. */
- while (1) {
- if (gtk_tree_path_get_depth (path) <= 1) {
- break;
- }
+ /* Get the book node for this link. */
+ while (1) {
+ if (gtk_tree_path_get_depth (path) <= 1) {
+ break;
+ }
- gtk_tree_path_up (path);
- }
+ gtk_tree_path_up (path);
+ }
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
- gtk_tree_model_get (model, &iter,
- COL_LINK, &link,
- -1);
+ gtk_tree_model_get (model, &iter,
+ COL_LINK, &link,
+ -1);
- return link;
+ return link;
}
diff --git a/src/dh-book.c b/src/dh-book.c
index d3da2ef..1be8bec 100644
--- a/src/dh-book.c
+++ b/src/dh-book.c
@@ -37,9 +37,9 @@
enum {
BOOK_ENABLED,
BOOK_DISABLED,
- BOOK_UPDATED,
+ BOOK_UPDATED,
BOOK_DELETED,
- BOOK_LAST_SIGNAL
+ BOOK_LAST_SIGNAL
};
typedef enum {
@@ -83,7 +83,7 @@ static void book_monitor_event_cb (GFileMonitor *file_monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
- gpointer user_data);
+ gpointer user_data);
static void unref_node_link (GNode *node,
gpointer data);
@@ -130,46 +130,46 @@ dh_book_class_init (DhBookClass *klass)
object_class->finalize = dh_book_finalize;
- signals[BOOK_ENABLED] =
- g_signal_new ("enabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
+ signals[BOOK_ENABLED] =
+ g_signal_new ("enabled",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
+ G_TYPE_NONE,
0);
- signals[BOOK_DISABLED] =
- g_signal_new ("disabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
+ signals[BOOK_DISABLED] =
+ g_signal_new ("disabled",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
+ G_TYPE_NONE,
0);
- signals[BOOK_UPDATED] =
- g_signal_new ("updated",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
+ signals[BOOK_UPDATED] =
+ g_signal_new ("updated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
+ G_TYPE_NONE,
0);
- signals[BOOK_DELETED] =
- g_signal_new ("deleted",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
+ signals[BOOK_DELETED] =
+ g_signal_new ("deleted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ G_TYPE_NONE,
+ 0);
}
static void
@@ -276,14 +276,14 @@ book_monitor_event_timeout_cb (gpointer data)
/* Emit the signal, but make sure we hold a reference
* while doing it */
g_object_ref (book);
- g_signal_emit (book, signals[BOOK_DELETED], 0);
+ g_signal_emit (book, signals[BOOK_DELETED], 0);
g_object_unref (book);
break;
case BOOK_MONITOR_EVENT_UPDATED:
/* Emit the signal, but make sure we hold a reference
* while doing it */
g_object_ref (book);
- g_signal_emit (book, signals[BOOK_UPDATED], 0);
+ g_signal_emit (book, signals[BOOK_UPDATED], 0);
g_object_unref (book);
break;
default:
@@ -303,7 +303,7 @@ book_monitor_event_cb (GFileMonitor *file_monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
- gpointer user_data)
+ gpointer user_data)
{
DhBook *book = user_data;
DhBookPrivate *priv = dh_book_get_instance_private (book);
diff --git a/src/dh-parser.c b/src/dh-parser.c
index 3972f00..5736ca1 100644
--- a/src/dh-parser.c
+++ b/src/dh-parser.c
@@ -32,30 +32,30 @@
#define BYTES_PER_READ 4096
typedef struct {
- GMarkupParser *m_parser;
- GMarkupParseContext *context;
+ GMarkupParser *m_parser;
+ GMarkupParseContext *context;
- const gchar *path;
+ const gchar *path;
/* Primary metadata of the book */
gchar **book_title;
gchar **book_name;
gchar **book_language;
- /* Top node of book */
- GNode *book_node;
+ /* Top node of book */
+ GNode *book_node;
- /* Current sub section node */
- GNode *parent;
+ /* Current sub section node */
+ GNode *parent;
- gboolean parsing_chapters;
- gboolean parsing_keywords;
+ gboolean parsing_chapters;
+ gboolean parsing_keywords;
- GNode **book_tree;
- GList **keywords;
+ GNode **book_tree;
+ GList **keywords;
- /* Version 2 uses <keyword> instead of <function>. */
- gint version;
+ /* Version 2 uses <keyword> instead of <function>. */
+ gint version;
} DhParser;
static void
@@ -85,7 +85,7 @@ parser_start_node_book (DhParser *parser,
const gchar *title = NULL;
const gchar *name = NULL;
const gchar *language = NULL;
- DhLink *link;
+ DhLink *link;
if (g_ascii_strcasecmp (node_name, "book") != 0) {
g_markup_parse_context_get_position (context, &line, &col);
@@ -185,7 +185,7 @@ parser_start_node_chapter (DhParser *parser,
gint line, col;
const gchar *name = NULL;
const gchar *uri = NULL;
- DhLink *link;
+ DhLink *link;
GNode *node;
if (g_ascii_strcasecmp (node_name, "sub") != 0) {
@@ -248,7 +248,7 @@ parser_start_node_keyword (DhParser *parser,
const gchar *type = NULL;
const gchar *deprecated = NULL;
DhLinkType link_type;
- DhLink *link;
+ DhLink *link;
gchar *tmp;
if (parser->version == 2 &&
@@ -400,13 +400,13 @@ parser_start_node_keyword (DhParser *parser,
static void
parser_start_node_cb (GMarkupParseContext *context,
- const gchar *node_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
+ const gchar *node_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
{
- DhParser *parser = user_data;
+ DhParser *parser = user_data;
if (parser->parsing_keywords) {
parser_start_node_keyword (parser,
@@ -426,95 +426,95 @@ parser_start_node_cb (GMarkupParseContext *context,
error);
return;
}
- else if (g_ascii_strcasecmp (node_name, "functions") == 0) {
- parser->parsing_keywords = TRUE;
- }
- else if (g_ascii_strcasecmp (node_name, "chapters") == 0) {
- parser->parsing_chapters = TRUE;
- }
- if (!parser->book_node) {
+ else if (g_ascii_strcasecmp (node_name, "functions") == 0) {
+ parser->parsing_keywords = TRUE;
+ }
+ else if (g_ascii_strcasecmp (node_name, "chapters") == 0) {
+ parser->parsing_chapters = TRUE;
+ }
+ if (!parser->book_node) {
parser_start_node_book (parser,
context,
node_name,
attribute_names,
attribute_values,
error);
- return;
- }
+ return;
+ }
}
static void
parser_end_node_cb (GMarkupParseContext *context,
- const gchar *node_name,
- gpointer user_data,
- GError **error)
+ const gchar *node_name,
+ gpointer user_data,
+ GError **error)
{
- DhParser *parser = user_data;
+ DhParser *parser = user_data;
if (parser->parsing_keywords) {
if (g_ascii_strcasecmp (node_name, "functions") == 0) {
- parser->parsing_keywords = FALSE;
- }
- }
- else if (parser->parsing_chapters) {
- g_node_reverse_children (parser->parent);
- if (g_ascii_strcasecmp (node_name, "sub") == 0) {
- parser->parent = parser->parent->parent;
- /* Move up in the tree */
- }
- else if (g_ascii_strcasecmp (node_name, "chapters") == 0) {
- parser->parsing_chapters = FALSE;
- }
- }
+ parser->parsing_keywords = FALSE;
+ }
+ }
+ else if (parser->parsing_chapters) {
+ g_node_reverse_children (parser->parent);
+ if (g_ascii_strcasecmp (node_name, "sub") == 0) {
+ parser->parent = parser->parent->parent;
+ /* Move up in the tree */
+ }
+ else if (g_ascii_strcasecmp (node_name, "chapters") == 0) {
+ parser->parsing_chapters = FALSE;
+ }
+ }
}
static gboolean
parser_read_gz_file (DhParser *parser,
const gchar *path,
- GError **error)
+ GError **error)
{
- gchar buf[BYTES_PER_READ];
- gzFile file;
-
- file = gzopen (path, "r");
- if (!file) {
- g_set_error (error,
- DH_ERROR,
- DH_ERROR_FILE_NOT_FOUND,
- "%s", g_strerror (errno));
- return FALSE;
- }
-
- while (TRUE) {
- gsize bytes_read;
-
- bytes_read = gzread (file, buf, BYTES_PER_READ);
- if (bytes_read == -1) {
- gint err;
- const gchar *message;
-
- message = gzerror (file, &err);
- g_set_error (error,
- DH_ERROR,
- DH_ERROR_INTERNAL_ERROR,
- _("Cannot uncompress book '%s': %s"),
- path, message);
- return FALSE;
- }
-
- g_markup_parse_context_parse (parser->context, buf,
- bytes_read, error);
- if (error != NULL && *error != NULL) {
- return FALSE;
- }
- if (bytes_read < BYTES_PER_READ) {
- break;
- }
- }
-
- gzclose (file);
-
- return TRUE;
+ gchar buf[BYTES_PER_READ];
+ gzFile file;
+
+ file = gzopen (path, "r");
+ if (!file) {
+ g_set_error (error,
+ DH_ERROR,
+ DH_ERROR_FILE_NOT_FOUND,
+ "%s", g_strerror (errno));
+ return FALSE;
+ }
+
+ while (TRUE) {
+ gsize bytes_read;
+
+ bytes_read = gzread (file, buf, BYTES_PER_READ);
+ if (bytes_read == -1) {
+ gint err;
+ const gchar *message;
+
+ message = gzerror (file, &err);
+ g_set_error (error,
+ DH_ERROR,
+ DH_ERROR_INTERNAL_ERROR,
+ _("Cannot uncompress book '%s': %s"),
+ path, message);
+ return FALSE;
+ }
+
+ g_markup_parse_context_parse (parser->context, buf,
+ bytes_read, error);
+ if (error != NULL && *error != NULL) {
+ return FALSE;
+ }
+ if (bytes_read < BYTES_PER_READ) {
+ break;
+ }
+ }
+
+ gzclose (file);
+
+ return TRUE;
}
gboolean
@@ -522,45 +522,45 @@ dh_parser_read_file (const gchar *path,
gchar **book_title,
gchar **book_name,
gchar **book_language,
- GNode **book_tree,
- GList **keywords,
- GError **error)
+ GNode **book_tree,
+ GList **keywords,
+ GError **error)
{
- DhParser *parser;
+ DhParser *parser;
gboolean gz;
- GIOChannel *io = NULL;
- gchar buf[BYTES_PER_READ];
- gboolean result = TRUE;
+ GIOChannel *io = NULL;
+ gchar buf[BYTES_PER_READ];
+ gboolean result = TRUE;
- parser = g_new0 (DhParser, 1);
+ parser = g_new0 (DhParser, 1);
- if (g_str_has_suffix (path, ".devhelp2")) {
- parser->version = 2;
+ if (g_str_has_suffix (path, ".devhelp2")) {
+ parser->version = 2;
gz = FALSE;
}
else if (g_str_has_suffix (path, ".devhelp")) {
- parser->version = 1;
+ parser->version = 1;
gz = FALSE;
}
else if (g_str_has_suffix (path, ".devhelp2.gz")) {
- parser->version = 2;
+ parser->version = 2;
gz = TRUE;
} else {
- parser->version = 1;
+ parser->version = 1;
gz = TRUE;
}
- parser->m_parser = g_new0 (GMarkupParser, 1);
+ parser->m_parser = g_new0 (GMarkupParser, 1);
- parser->m_parser->start_element = parser_start_node_cb;
- parser->m_parser->end_element = parser_end_node_cb;
+ parser->m_parser->start_element = parser_start_node_cb;
+ parser->m_parser->end_element = parser_end_node_cb;
- parser->context = g_markup_parse_context_new (parser->m_parser, 0,
- parser, NULL);
+ parser->context = g_markup_parse_context_new (parser->m_parser, 0,
+ parser, NULL);
- parser->path = path;
- parser->book_tree = book_tree;
- parser->keywords = keywords;
+ parser->path = path;
+ parser->book_tree = book_tree;
+ parser->keywords = keywords;
parser->book_title = book_title;
parser->book_name = book_name;
parser->book_language = book_language;
@@ -572,7 +572,7 @@ dh_parser_read_file (const gchar *path,
result = FALSE;
}
goto exit;
- } else {
+ } else {
io = g_io_channel_new_file (path, "r", error);
if (!io) {
result = FALSE;
@@ -609,10 +609,10 @@ dh_parser_read_file (const gchar *path,
}
exit:
- if (io) {
+ if (io) {
g_io_channel_unref (io);
}
- dh_parser_free (parser);
+ dh_parser_free (parser);
- return result;
+ return result;
}
diff --git a/src/dh-settings.c b/src/dh-settings.c
index 2e34d09..1973033 100644
--- a/src/dh-settings.c
+++ b/src/dh-settings.c
@@ -44,7 +44,7 @@ static void fonts_changed_cb (GSettings *settings, gchar *key, gpointer user_dat
struct _DhSettingsPrivate {
GSettings *settings_desktop_interface;
GSettings *settings_fonts;
- GSettings *settings_window;
+ GSettings *settings_window;
GSettings *settings_contents;
GSettings *settings_paned;
GSettings *settings_search_notebook;
@@ -82,37 +82,37 @@ dh_settings_init (DhSettings *self)
static void
dispose (GObject *object)
{
- DhSettings *self = DH_SETTINGS (object);
+ DhSettings *self = DH_SETTINGS (object);
g_clear_object (&self->priv->settings_desktop_interface);
g_clear_object (&self->priv->settings_fonts);
- g_clear_object (&self->priv->settings_window);
+ g_clear_object (&self->priv->settings_window);
g_clear_object (&self->priv->settings_contents);
g_clear_object (&self->priv->settings_paned);
g_clear_object (&self->priv->settings_search_notebook);
g_clear_object (&self->priv->settings_assistant);
- G_OBJECT_CLASS (dh_settings_parent_class)->dispose (object);
+ G_OBJECT_CLASS (dh_settings_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
- singleton = NULL;
+ singleton = NULL;
- /* Chain up to the parent class */
- G_OBJECT_CLASS (dh_settings_parent_class)->finalize(object);
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (dh_settings_parent_class)->finalize(object);
}
static void
dh_settings_class_init (DhSettingsClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (object_class, sizeof (DhSettingsPrivate));
- object_class->dispose = dispose;
- object_class->finalize = finalize;
+ g_type_class_add_private (object_class, sizeof (DhSettingsPrivate));
+ object_class->dispose = dispose;
+ object_class->finalize = finalize;
signals[FONTS_CHANGED] =
g_signal_new ("fonts-changed",
@@ -146,13 +146,13 @@ fonts_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
DhSettings *
dh_settings_get (void)
{
- if (!singleton) {
- singleton = DH_SETTINGS (g_object_new (DH_TYPE_SETTINGS, NULL));
- } else {
- g_object_ref (singleton);
- }
- g_assert (singleton);
- return singleton;
+ if (!singleton) {
+ singleton = DH_SETTINGS (g_object_new (DH_TYPE_SETTINGS, NULL));
+ } else {
+ g_object_ref (singleton);
+ }
+ g_assert (singleton);
+ return singleton;
}
void
diff --git a/src/dh-settings.h b/src/dh-settings.h
index db49167..dd3dd44 100644
--- a/src/dh-settings.h
+++ b/src/dh-settings.h
@@ -38,13 +38,13 @@ typedef struct _DhSettingsPrivate DhSettingsPrivate;
struct _DhSettings{
- GObject parent;
- /*<private>*/
- DhSettingsPrivate *priv;
+ GObject parent;
+ /*<private>*/
+ DhSettingsPrivate *priv;
};
struct _DhSettingsClass{
- GObjectClass parent;
+ GObjectClass parent;
/* Signals */
void (*fonts_changed) (DhSettings *settings,
const gchar *font_name_fixed,
diff --git a/src/dh-window.c b/src/dh-window.c
index 60fb27d..fdd58e3 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -340,7 +340,7 @@ zoom_in_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhWindow *window = user_data;
+ DhWindow *window = user_data;
int zoom_level_idx;
zoom_level_idx = window_get_current_zoom_level_index (window);
@@ -359,7 +359,7 @@ zoom_out_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhWindow *window = user_data;
+ DhWindow *window = user_data;
int zoom_level_idx;
zoom_level_idx = window_get_current_zoom_level_index (window);
@@ -377,7 +377,7 @@ zoom_default_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhWindow *window = user_data;
+ DhWindow *window = user_data;
WebKitWebView *web_view;
web_view = window_get_active_web_view (window);
@@ -589,7 +589,7 @@ window_configure_event_cb (GtkWidget *window,
dh_util_window_settings_save (
GTK_WINDOW (window),
dh_settings_peek_window_settings (priv->settings), TRUE);
- return FALSE;
+ return FALSE;
}
static void
@@ -678,8 +678,8 @@ dh_window_dispose (GObject *object)
g_clear_object (&priv->settings);
- /* Chain up to the parent class */
- G_OBJECT_CLASS (dh_window_parent_class)->dispose (object);
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (dh_window_parent_class)->dispose (object);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]