[latexila/wip/latexila-next] Remove curly braces around one-line blocks



commit 7e0304d44bec6d7454686d3c172ac27fda6defe9
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Oct 5 16:51:39 2014 +0200

    Remove curly braces around one-line blocks
    
    To fully follow GLib/GTK+ code conventions.

 src/liblatexila/latexila-build-job.c            |   20 ++-------
 src/liblatexila/latexila-build-tool.c           |   48 ++++++---------------
 src/liblatexila/latexila-build-tools-default.c  |   34 ++-------------
 src/liblatexila/latexila-build-tools-personal.c |    8 +---
 src/liblatexila/latexila-build-tools.c          |   37 ++++++----------
 src/liblatexila/latexila-build-view.c           |   52 +++++-----------------
 src/liblatexila/latexila-post-processor.c       |    4 +-
 src/liblatexila/latexila-synctex.c              |    4 +-
 src/liblatexila/latexila-utils.c                |   28 +++---------
 9 files changed, 59 insertions(+), 176 deletions(-)
---
diff --git a/src/liblatexila/latexila-build-job.c b/src/liblatexila/latexila-build-job.c
index 970fc90..8daa601 100644
--- a/src/liblatexila/latexila-build-job.c
+++ b/src/liblatexila/latexila-build-job.c
@@ -238,9 +238,7 @@ get_command_argv (LatexilaBuildJob  *build_job,
   /* Separate arguments */
   if (!g_shell_parse_argv (build_job->priv->command, NULL, &argv, error) ||
       argv == NULL)
-    {
-      return NULL;
-    }
+    return NULL;
 
   /* Re-add quotes if needed */
   if (for_printing)
@@ -300,13 +298,9 @@ get_command_name (LatexilaBuildJob *build_job)
   argv = get_command_argv (build_job, TRUE, NULL);
 
   if (argv == NULL || argv[0] == NULL || argv[0][0] == '\0')
-    {
-      command_name = NULL;
-    }
+    command_name = NULL;
   else
-    {
-      command_name = g_strdup (argv[0]);
-    }
+    command_name = g_strdup (argv[0]);
 
   g_strfreev (argv);
   return command_name;
@@ -619,14 +613,10 @@ latexila_build_job_run_async (LatexilaBuildJob    *build_job,
   build_job->priv->build_view = g_object_ref (build_view);
 
   if (!display_command_line (build_job))
-    {
-      return;
-    }
+    return;
 
   if (!g_task_return_error_if_cancelled (build_job->priv->task))
-    {
-      launch_subprocess (build_job);
-    }
+    launch_subprocess (build_job);
 }
 
 /**
diff --git a/src/liblatexila/latexila-build-tool.c b/src/liblatexila/latexila-build-tool.c
index c2914f0..892fcc3 100644
--- a/src/liblatexila/latexila-build-tool.c
+++ b/src/liblatexila/latexila-build-tool.c
@@ -163,9 +163,7 @@ latexila_build_tool_set_property (GObject      *object,
       g_strfreev (build_tool->priv->files_to_open_split);
       build_tool->priv->files_to_open_split = NULL;
       if (build_tool->priv->files_to_open != NULL)
-        {
-          build_tool->priv->files_to_open_split = g_strsplit (build_tool->priv->files_to_open, " ", -1);
-        }
+        build_tool->priv->files_to_open_split = g_strsplit (build_tool->priv->files_to_open, " ", -1);
       break;
 
     case PROP_ID:
@@ -374,9 +372,7 @@ latexila_build_tool_get_description (LatexilaBuildTool *build_tool)
 {
   if (build_tool->priv->description == NULL ||
       build_tool->priv->description[0] == '\0')
-    {
-      return build_tool->priv->label;
-    }
+    return build_tool->priv->label;
 
   return build_tool->priv->description;
 }
@@ -475,13 +471,9 @@ failed (LatexilaBuildTool *build_tool)
 
   cancellable = g_task_get_cancellable (build_tool->priv->task);
   if (g_cancellable_is_cancelled (cancellable))
-    {
-      state = LATEXILA_BUILD_STATE_ABORTED;
-    }
+    state = LATEXILA_BUILD_STATE_ABORTED;
   else
-    {
-      state = LATEXILA_BUILD_STATE_FAILED;
-    }
+    state = LATEXILA_BUILD_STATE_FAILED;
 
   latexila_build_view_set_title_state (build_tool->priv->build_view,
                                        &build_tool->priv->main_title,
@@ -614,13 +606,9 @@ open_file (LatexilaBuildTool *build_tool)
        * two contiguous spaces in priv->files_to_open for example.
        */
       if (build_tool->priv->current_file_to_open[0][0] == '\0')
-        {
-          build_tool->priv->current_file_to_open++;
-        }
+        build_tool->priv->current_file_to_open++;
       else
-        {
-          break;
-        }
+        break;
     }
 
   file_to_open = build_tool->priv->current_file_to_open[0];
@@ -631,17 +619,11 @@ open_file (LatexilaBuildTool *build_tool)
   shortname = latexila_utils_get_shortname (filename);
 
   if (strstr (file_to_open, "$filename") != NULL)
-    {
-      uri = latexila_utils_str_replace (file_to_open, "$filename", filename);
-    }
+    uri = latexila_utils_str_replace (file_to_open, "$filename", filename);
   else if (strstr (file_to_open, "$shortname") != NULL)
-    {
-      uri = latexila_utils_str_replace (file_to_open, "$shortname", shortname);
-    }
+    uri = latexila_utils_str_replace (file_to_open, "$shortname", shortname);
   else
-    {
-      uri = g_strdup_printf ("file://%s", file_to_open);
-    }
+    uri = g_strdup_printf ("file://%s", file_to_open);
 
   /* Add job title in the build view */
 
@@ -701,9 +683,7 @@ run_job (LatexilaBuildTool *build_tool)
   LatexilaBuildJob *build_job;
 
   if (g_task_return_error_if_cancelled (build_tool->priv->task))
-    {
-      return;
-    }
+    return;
 
   if (build_tool->priv->current_job == NULL)
     {
@@ -780,11 +760,9 @@ latexila_build_tool_run_finish (LatexilaBuildTool *build_tool,
 
   cancellable = g_task_get_cancellable (G_TASK (result));
   if (g_cancellable_is_cancelled (cancellable))
-    {
-      latexila_build_view_set_title_state (build_tool->priv->build_view,
-                                           &build_tool->priv->main_title,
-                                           LATEXILA_BUILD_STATE_ABORTED);
-    }
+    latexila_build_view_set_title_state (build_tool->priv->build_view,
+                                         &build_tool->priv->main_title,
+                                         LATEXILA_BUILD_STATE_ABORTED);
 
   g_task_propagate_boolean (G_TASK (result), NULL);
 
diff --git a/src/liblatexila/latexila-build-tools-default.c b/src/liblatexila/latexila-build-tools-default.c
index 6f3f1a0..dd7dad0 100644
--- a/src/liblatexila/latexila-build-tools-default.c
+++ b/src/liblatexila/latexila-build-tools-default.c
@@ -90,9 +90,7 @@ load_settings (LatexilaBuildToolsDefault *build_tools)
   g_variant_get (tools, "ai", &iter);
 
   while (g_variant_iter_loop (iter, "i", &tool_id))
-    {
-      set_enabled_by_id (build_tools, tool_id, TRUE);
-    }
+    set_enabled_by_id (build_tools, tool_id, TRUE);
 
   g_variant_iter_free (iter);
   g_variant_unref (tools);
@@ -101,9 +99,7 @@ load_settings (LatexilaBuildToolsDefault *build_tools)
   g_variant_get (tools, "ai", &iter);
 
   while (g_variant_iter_loop (iter, "i", &tool_id))
-    {
-      set_enabled_by_id (build_tools, tool_id, FALSE);
-    }
+    set_enabled_by_id (build_tools, tool_id, FALSE);
 
   g_variant_iter_free (iter);
   g_variant_unref (tools);
@@ -136,13 +132,9 @@ save_settings (LatexilaBuildToolsDefault *build_tools)
                     NULL);
 
       if (enabled)
-        {
-          g_variant_builder_add (&builder_enabled, "i", id);
-        }
+        g_variant_builder_add (&builder_enabled, "i", id);
       else
-        {
-          g_variant_builder_add (&builder_disabled, "i", id);
-        }
+        g_variant_builder_add (&builder_disabled, "i", id);
     }
 
   enabled_tools = g_variant_builder_end (&builder_enabled);
@@ -155,23 +147,9 @@ save_settings (LatexilaBuildToolsDefault *build_tools)
   g_object_unref (settings);
 }
 
-#if 0
-static void
-latexila_build_tools_default_finalize (GObject *object)
-{
-
-  G_OBJECT_CLASS (latexila_build_tools_default_parent_class)->finalize (object);
-}
-#endif
-
 static void
 latexila_build_tools_default_class_init (LatexilaBuildToolsDefaultClass *klass)
 {
-#if 0
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->finalize = latexila_build_tools_default_finalize;
-#endif
 }
 
 static GFile *
@@ -224,9 +202,7 @@ LatexilaBuildToolsDefault *
 latexila_build_tools_default_get_instance (void)
 {
   if (instance == NULL)
-    {
-      instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_DEFAULT, NULL);
-    }
+    instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_DEFAULT, NULL);
 
   return instance;
 }
diff --git a/src/liblatexila/latexila-build-tools-personal.c b/src/liblatexila/latexila-build-tools-personal.c
index e2262c4..f330201 100644
--- a/src/liblatexila/latexila-build-tools-personal.c
+++ b/src/liblatexila/latexila-build-tools-personal.c
@@ -116,9 +116,7 @@ LatexilaBuildToolsPersonal *
 latexila_build_tools_personal_get_instance (void)
 {
   if (instance == NULL)
-    {
-      instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_PERSONAL, NULL);
-    }
+    instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_PERSONAL, NULL);
 
   return instance;
 }
@@ -168,9 +166,7 @@ latexila_build_tools_personal_save (LatexilaBuildToolsPersonal *build_tools)
 
   if (!build_tools->priv->modified ||
       build_tools->priv->xml_file_contents != NULL)
-    {
-      return;
-    }
+    return;
 
   contents = g_string_new ("<tools>");
   build_tools->priv->xml_file_contents = contents;
diff --git a/src/liblatexila/latexila-build-tools.c b/src/liblatexila/latexila-build-tools.c
index 4daa0d6..f2f7014 100644
--- a/src/liblatexila/latexila-build-tools.c
+++ b/src/liblatexila/latexila-build-tools.c
@@ -183,16 +183,12 @@ parser_start_element (GMarkupParseContext  *context,
               LatexilaPostProcessorType type;
 
               if (latexila_post_processor_get_type_from_name (attribute_values[i], &type))
-                {
-                  g_object_set (cur_job, "post-processor-type", type, NULL);
-                }
+                g_object_set (cur_job, "post-processor-type", type, NULL);
               else if (error != NULL)
-                {
-                  *error = g_error_new (G_MARKUP_ERROR,
-                                        G_MARKUP_ERROR_INVALID_CONTENT,
-                                        "unknown post processor \"%s\"",
-                                        attribute_values[i]);
-                }
+                *error = g_error_new (G_MARKUP_ERROR,
+                                      G_MARKUP_ERROR_INVALID_CONTENT,
+                                      "unknown post processor \"%s\"",
+                                      attribute_values[i]);
             }
 
           /* For compatibility (no longer used) */
@@ -271,21 +267,16 @@ parser_text (GMarkupParseContext  *context,
   stripped_text = g_strstrip (stripped_text);
 
   if (g_str_equal (element_name, "job"))
-    {
-      g_object_set (build_tools->priv->cur_job, "command", stripped_text, NULL);
-    }
+    g_object_set (build_tools->priv->cur_job, "command", stripped_text, NULL);
+
   else if (g_str_equal (element_name, "label"))
-    {
-      g_object_set (build_tools->priv->cur_tool, "label", _(stripped_text), NULL);
-    }
+    g_object_set (build_tools->priv->cur_tool, "label", _(stripped_text), NULL);
+
   else if (g_str_equal (element_name, "description"))
-    {
-      g_object_set (build_tools->priv->cur_tool, "description", _(stripped_text), NULL);
-    }
+    g_object_set (build_tools->priv->cur_tool, "description", _(stripped_text), NULL);
+
   else if (g_str_equal (element_name, "open"))
-    {
-      g_object_set (build_tools->priv->cur_tool, "files-to-open", stripped_text, NULL);
-    }
+    g_object_set (build_tools->priv->cur_tool, "files-to-open", stripped_text, NULL);
 
   g_free (stripped_text);
 }
@@ -371,9 +362,7 @@ load_contents_cb (GFile              *xml_file,
     }
 
   if (contents != NULL)
-    {
-      parse_contents (build_tools, contents);
-    }
+    parse_contents (build_tools, contents);
 
   g_object_unref (build_tools);
 }
diff --git a/src/liblatexila/latexila-build-view.c b/src/liblatexila/latexila-build-view.c
index bcfb125..a8ca5ae 100644
--- a/src/liblatexila/latexila-build-view.c
+++ b/src/liblatexila/latexila-build-view.c
@@ -263,18 +263,14 @@ latexila_build_view_set_property (GObject      *object,
       build_view->priv->show_warnings = g_value_get_boolean (value);
 
       if (build_view->priv->filtered_model != NULL)
-        {
-          gtk_tree_model_filter_refilter (build_view->priv->filtered_model);
-        }
+        gtk_tree_model_filter_refilter (build_view->priv->filtered_model);
       break;
 
     case PROP_SHOW_BADBOXES:
       build_view->priv->show_badboxes = g_value_get_boolean (value);
 
       if (build_view->priv->filtered_model != NULL)
-        {
-          gtk_tree_model_filter_refilter (build_view->priv->filtered_model);
-        }
+        gtk_tree_model_filter_refilter (build_view->priv->filtered_model);
       break;
 
     case PROP_SHOW_DETAILS:
@@ -302,15 +298,6 @@ latexila_build_view_dispose (GObject *object)
   G_OBJECT_CLASS (latexila_build_view_parent_class)->dispose (object);
 }
 
-#if 0
-static void
-latexila_build_view_finalize (GObject *object)
-{
-
-  G_OBJECT_CLASS (latexila_build_view_parent_class)->finalize (object);
-}
-#endif
-
 static void
 latexila_build_view_class_init (LatexilaBuildViewClass *klass)
 {
@@ -319,7 +306,6 @@ latexila_build_view_class_init (LatexilaBuildViewClass *klass)
   object_class->get_property = latexila_build_view_get_property;
   object_class->set_property = latexila_build_view_set_property;
   object_class->dispose = latexila_build_view_dispose;
-  /*object_class->finalize = latexila_build_view_finalize;*/
 
   g_object_class_install_property (object_class,
                                    PROP_SHOW_WARNINGS,
@@ -449,20 +435,14 @@ select_row (LatexilaBuildView *build_view,
   gint end_line;
 
   if (!gtk_tree_model_get_iter (model, &iter, path))
-    {
-      return FALSE;
-    }
+    return FALSE;
 
   if (gtk_tree_model_iter_has_child (model, &iter))
     {
       if (gtk_tree_view_row_expanded (tree_view, path))
-        {
-          gtk_tree_view_collapse_row (tree_view, path);
-        }
+        gtk_tree_view_collapse_row (tree_view, path);
       else
-        {
-          gtk_tree_view_expand_to_path (tree_view, path);
-        }
+        gtk_tree_view_expand_to_path (tree_view, path);
 
       return FALSE;
     }
@@ -744,15 +724,11 @@ latexila_build_view_append_single_message (LatexilaBuildView *build_view,
     }
 
   if (message->start_line != -1)
-    {
-      line_str = g_strdup_printf ("%d", message->start_line);
-    }
+    line_str = g_strdup_printf ("%d", message->start_line);
 
   end_line = message->end_line;
   if (message->start_line != -1 && end_line == -1)
-    {
-      end_line = message->start_line + 1;
-    }
+    end_line = message->start_line + 1;
 
   gtk_tree_store_append (build_view->priv->store, &iter, parent);
   gtk_tree_store_set (build_view->priv->store, &iter,
@@ -769,9 +745,7 @@ latexila_build_view_append_single_message (LatexilaBuildView *build_view,
                       -1);
 
   if (file != NULL)
-    {
-      g_object_unref (file);
-    }
+    g_object_unref (file);
 
   g_free (path);
   g_free (basename);
@@ -808,12 +782,10 @@ latexila_build_view_append_messages (LatexilaBuildView *build_view,
       child = latexila_build_view_append_single_message (build_view, parent, build_msg);
 
       if (build_msg->children != NULL)
-        {
-          latexila_build_view_append_messages (build_view,
-                                               &child,
-                                               build_msg->children->head,
-                                               build_msg->expand);
-        }
+        latexila_build_view_append_messages (build_view,
+                                             &child,
+                                             build_msg->children->head,
+                                             build_msg->expand);
     }
 
   if (expand)
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index b4a17fc..b46a14a 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -319,9 +319,7 @@ read_stream_cb (GInputStream          *stream,
   if (g_cancellable_is_cancelled (cancellable))
     {
       if (error != NULL)
-        {
-          g_error_free (error);
-        }
+        g_error_free (error);
 
       g_task_return_boolean (pp->priv->task, FALSE);
       return;
diff --git a/src/liblatexila/latexila-synctex.c b/src/liblatexila/latexila-synctex.c
index 75416a3..5c1b0a5 100644
--- a/src/liblatexila/latexila-synctex.c
+++ b/src/liblatexila/latexila-synctex.c
@@ -166,9 +166,7 @@ LatexilaSynctex *
 latexila_synctex_get_instance (void)
 {
   if (instance == NULL)
-    {
-      instance = g_object_new (LATEXILA_TYPE_SYNCTEX, NULL);
-    }
+    instance = g_object_new (LATEXILA_TYPE_SYNCTEX, NULL);
 
   return instance;
 }
diff --git a/src/liblatexila/latexila-utils.c b/src/liblatexila/latexila-utils.c
index 686a6e4..c101530 100644
--- a/src/liblatexila/latexila-utils.c
+++ b/src/liblatexila/latexila-utils.c
@@ -41,9 +41,7 @@ get_extension_position (const gchar *filename)
   gint length;
 
   if (filename == NULL)
-    {
-      return 0;
-    }
+    return 0;
 
   length = strlen (filename);
   pos = filename + length;
@@ -54,14 +52,10 @@ get_extension_position (const gchar *filename)
       pos = g_utf8_find_prev_char (filename, pos);
 
       if (pos == NULL || pos[0] == '/')
-        {
-          break;
-        }
+        break;
 
       if (pos[0] == '.')
-        {
-          return pos - filename;
-        }
+        return pos - filename;
     }
 
   return length;
@@ -116,15 +110,11 @@ latexila_utils_replace_home_dir_with_tilde (const gchar *filename)
   tmp = (gchar *) g_get_home_dir ();
 
   if (tmp == NULL)
-    {
-      return g_strdup (filename);
-    }
+    return g_strdup (filename);
 
   home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
   if (home == NULL)
-    {
-      return g_strdup (filename);
-    }
+    return g_strdup (filename);
 
   if (strcmp (filename, home) == 0)
     {
@@ -192,13 +182,9 @@ latexila_utils_str_replace (const gchar *string,
 
   chunks = g_strsplit (string, search, -1);
   if (chunks != NULL && chunks[0] != NULL)
-    {
-      ret = g_strjoinv (replacement, chunks);
-    }
+    ret = g_strjoinv (replacement, chunks);
   else
-    {
-      ret = g_strdup (string);
-    }
+    ret = g_strdup (string);
 
   g_strfreev (chunks);
   return ret;


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