[epiphany] EphyTopicsEntry: Correct trailing spaces.



commit 01c107c6e45b44f31c7fc82077de595287b2c3dd
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Dec 12 14:13:59 2015 +0100

    EphyTopicsEntry: Correct trailing spaces.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759401

 src/bookmarks/ephy-topics-entry.c |  133 ++++++++++++++++++-------------------
 1 files changed, 65 insertions(+), 68 deletions(-)
---
diff --git a/src/bookmarks/ephy-topics-entry.c b/src/bookmarks/ephy-topics-entry.c
index 1af25ed..c2d68ec 100644
--- a/src/bookmarks/ephy-topics-entry.c
+++ b/src/bookmarks/ephy-topics-entry.c
@@ -67,7 +67,7 @@ find_topic (EphyTopicsEntry *entry,
        GtkTreeIter iter;
        GValue value = { 0, };
        gboolean valid;
-       
+
        /* Loop through our table and set/unset topics appropriately */
        model = GTK_TREE_MODEL (entry->store);
        valid = gtk_tree_model_get_iter_first (model, &iter);
@@ -98,21 +98,21 @@ insert_text (EphyTopicsEntry *entry,
        const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint-text), ',');
        const gchar *end = g_utf8_strchr (midpoint, -1, ',');
        int startpos, endpos;
-       
+
        if (start == NULL)
-         startpos = 0;
+               startpos = 0;
        else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
-         startpos = g_utf8_pointer_to_offset (text, start)+2;
+               startpos = g_utf8_pointer_to_offset (text, start)+2;
        else
-         startpos = g_utf8_pointer_to_offset (text, start)+1;
-         
+               startpos = g_utf8_pointer_to_offset (text, start)+1;
+
        if (end == NULL)
-         endpos = -1;
+               endpos = -1;
        else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (end))))
-         endpos = g_utf8_pointer_to_offset (text, end)+2;
+               endpos = g_utf8_pointer_to_offset (text, end)+2;
        else
-         endpos = g_utf8_pointer_to_offset (text, end)+1;
-       
+               endpos = g_utf8_pointer_to_offset (text, end)+1;
+
        /* Replace the text in the current position with the title */
        gtk_editable_delete_text (editable, startpos, endpos);
        gtk_editable_insert_text (editable, title, strlen(title), &startpos);
@@ -125,7 +125,7 @@ static void
 update_widget (EphyTopicsEntry *entry)
 {
        GtkEditable *editable = GTK_EDITABLE (entry);
-       
+
        EphyNode *node;
        GPtrArray *children, *topics;
        GtkTreeIter iter;
@@ -133,15 +133,15 @@ update_widget (EphyTopicsEntry *entry)
        const char *title;
        char *tmp1, *tmp2;
        gboolean is_focus;
-       
+
        /* Prevent any changes to the database */
        if (entry->lock) return;
        entry->lock = TRUE;
-       
+
        node = ephy_bookmarks_get_keywords (entry->bookmarks);
        children = ephy_node_get_children (node);
        topics = g_ptr_array_sized_new (children->len);
-       
+
        for (i = 0; i < children->len; i++)
        {
                node = g_ptr_array_index (children, i);
@@ -149,11 +149,11 @@ update_widget (EphyTopicsEntry *entry)
                priority = ephy_node_get_property_int 
                  (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
                if (priority != EPHY_NODE_NORMAL_PRIORITY)
-                 continue;
-               
+                       continue;
+
                g_ptr_array_add (topics, node);
        }
-       
+
        g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
        gtk_list_store_clear (entry->store);
 
@@ -162,12 +162,12 @@ update_widget (EphyTopicsEntry *entry)
        {
                gtk_editable_delete_text (editable, 0, -1);
        }
-       
+
        for (pos = 0, i = 0; i < topics->len; i++)
        {
                node = g_ptr_array_index (topics, i);
                title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
-                 
+
                if (!is_focus && ephy_node_has_child (node, entry->bookmark))
                {
                        if (pos > 0)
@@ -186,8 +186,7 @@ update_widget (EphyTopicsEntry *entry)
                g_free (tmp2);
                g_free (tmp1);
        }
-       
-       
+
        if (!is_focus)
        {
                gtk_editable_set_position (editable, -1);
@@ -205,9 +204,9 @@ update_database (EphyTopicsEntry *entry)
        EphyNode *node;
        const char *text;
        char **split;
-        char *tmp;
+       char *tmp;
        gint i;
-       
+
        GtkTreeModel *model;
        GtkTreeIter iter;
        GValue value = { 0, };
@@ -216,17 +215,17 @@ update_database (EphyTopicsEntry *entry)
        /* Prevent any changes to the text entry or completion model */
        if (entry->lock) return;
        entry->lock = TRUE;
-       
+
        /* Get the list of strings input by the user */
        text = gtk_entry_get_text (GTK_ENTRY (entry));
        split = g_strsplit (text, ",", 0);
        for (i=0; split[i]; i++)
        {
                g_strstrip (split[i]);
-               
+
                tmp = g_utf8_casefold (split[i], -1);
                g_free (split[i]);
-               
+
                split[i] = g_utf8_normalize (tmp, -1, G_NORMALIZE_DEFAULT);
                g_free (tmp);
        }
@@ -239,14 +238,14 @@ update_database (EphyTopicsEntry *entry)
                gtk_tree_model_get_value (model, &iter, COLUMN_NODE, &value);
                node = g_value_get_pointer (&value);
                g_value_unset (&value);
-               
+
                gtk_tree_model_get_value (model, &iter, COLUMN_KEY, &value);
                text = g_value_get_string (&value);
-               
+
                for (i=0; split[i]; i++)
-                 if (strcmp (text, split[i]) == 0)
-                   break;
-               
+                       if (strcmp (text, split[i]) == 0)
+                               break;
+
                if (split[i])
                {
                        split[i][0] = 0;
@@ -256,7 +255,7 @@ update_database (EphyTopicsEntry *entry)
                {
                        ephy_bookmarks_unset_keyword (entry->bookmarks, node, entry->bookmark);
                }
-               
+
                g_value_unset (&value);
                valid = gtk_tree_model_iter_next (model, &iter);
        }
@@ -272,28 +271,26 @@ update_key (EphyTopicsEntry *entry)
 {
        GtkEditable *editable = GTK_EDITABLE (entry);
        char *input;
-       
+
        const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
        const gchar *midpoint = g_utf8_offset_to_pointer (text, gtk_editable_get_position (editable));
        const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint-text), ',');
        const gchar *end = g_utf8_strchr (midpoint, -1, ',');
-       
+
        if (start == NULL)
-         start = text;
+               start = text;
        else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
-         start = g_utf8_next_char (g_utf8_next_char (start));
+               start = g_utf8_next_char (g_utf8_next_char (start));
        else
-         start = g_utf8_next_char (start);
-         
+               start = g_utf8_next_char (start);
+
        if (end == NULL)
-         end = text+strlen(text);
+               end = text+strlen(text);
 
        /* If there was something we could create, then delete the action. */
        if (entry->create)
-       {
                gtk_entry_completion_delete_action (entry->completion, 0);
-       }
-       
+
        g_free (entry->create);
        g_free (entry->key);
        entry->create = 0;
@@ -305,11 +302,11 @@ update_key (EphyTopicsEntry *entry)
                input = g_strndup (start, end-start);
                g_strstrip (input);
                entry->create = input;
-               
+
                input = g_utf8_casefold (input, -1);
                entry->key = g_utf8_normalize (input, -1, G_NORMALIZE_DEFAULT);
                g_free (input);
-               
+
                if (entry->create[0] == '\0' ||
                    find_topic (entry, entry->key) != NULL)
                {
@@ -335,16 +332,16 @@ match_func (GtkEntryCompletion *completion,
 {
        EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
        GtkTreeModel *model = gtk_entry_completion_get_model (completion);
-       
+
        gboolean result;
        GValue value = { 0, };
        EphyNode *node;
-       
+
        if (entry->key == NULL)
        {
                return FALSE;
        }
-       
+
        /* If no node at all (this happens for unknown reasons) then don't show. */
        gtk_tree_model_get_value (model, iter, COLUMN_NODE, &value);
        node = g_value_get_pointer (&value);
@@ -361,7 +358,7 @@ match_func (GtkEntryCompletion *completion,
                result = (strcmp (g_value_get_string (&value), entry->key) == 0);
                g_value_unset (&value);
        }
-       
+
        /* If it's not selected, show it if it matches. */
        else
        {
@@ -369,7 +366,7 @@ match_func (GtkEntryCompletion *completion,
                result = (g_str_has_prefix (g_value_get_string (&value), entry->key));
                g_value_unset (&value);
        }
-       
+
        return result;
 }
 
@@ -380,12 +377,12 @@ action_cb (GtkEntryCompletion *completion,
 {
        EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
        char *title;
-       
+
        title = g_strdup (entry->create);
-       
+
        ephy_bookmarks_add_keyword (entry->bookmarks, title);
        update_widget (entry);
-       
+
        insert_text (entry, title);
        g_free (title);
 }
@@ -398,18 +395,18 @@ match_selected_cb (GtkEntryCompletion *completion,
 {
        EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
        GValue value = { 0, };
-       
+
        gtk_tree_model_get_value (model, iter, COLUMN_TITLE, &value);
        insert_text (entry, g_value_get_string (&value));
        g_value_unset (&value);
-       
+
        return TRUE;
 }
 
 static void
 activate_cb (GtkEditable *editable,
             gpointer user_data)
-{      
+{
        EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (editable);
        GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (entry));
 
@@ -417,7 +414,7 @@ activate_cb (GtkEditable *editable,
        GtkTreeModel *model;
        GtkTreeIter iter;
        gboolean valid;
-       
+
        if (entry->key == NULL || entry->key[0] == '\0')
        {
                gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
@@ -427,7 +424,7 @@ activate_cb (GtkEditable *editable,
        {
                gtk_entry_set_activates_default (GTK_ENTRY (entry), FALSE);
        }
-       
+
        /* Loop through the completion model and find the first item to use, if any. */
        model = GTK_TREE_MODEL (entry->store);
        valid = gtk_tree_model_get_iter_first (model, &iter);
@@ -439,14 +436,14 @@ activate_cb (GtkEditable *editable,
        if (valid)
        {
                gtk_tree_model_get_value (model, &iter, COLUMN_TITLE, &value);
-               
+
                /* See if there were any others. */
                valid = gtk_tree_model_iter_next (model, &iter);
                while (valid && !match_func (completion, NULL, &iter, NULL))
                {
                        valid = gtk_tree_model_iter_next (model, &iter);
                }
-               
+
                if (!valid)
                {
                        insert_text (EPHY_TOPICS_ENTRY (editable), g_value_get_string (&value));
@@ -530,28 +527,28 @@ ephy_topics_entry_constructor (GType type,
        EphyTopicsEntry *entry;
 
        object = G_OBJECT_CLASS (ephy_topics_entry_parent_class)->constructor (type,
-                                                                               n_construct_properties,
-                                                                               construct_params);
+                                                                              n_construct_properties,
+                                                                              construct_params);
        entry = EPHY_TOPICS_ENTRY (object);
 
        entry->store = gtk_list_store_new (3, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
        entry->completion = gtk_entry_completion_new ();
-       
+
        gtk_entry_completion_set_model (entry->completion, GTK_TREE_MODEL (entry->store));
        gtk_entry_completion_set_text_column (entry->completion, COLUMN_TITLE);
        gtk_entry_completion_set_popup_completion (entry->completion, TRUE);
        gtk_entry_completion_set_popup_single_match (entry->completion, TRUE);
        gtk_entry_completion_set_match_func (entry->completion, match_func, NULL, NULL);
        gtk_entry_set_completion (GTK_ENTRY (entry), entry->completion);
-       
+
        g_signal_connect (entry->completion, "match-selected",
                          G_CALLBACK (match_selected_cb), NULL);
        g_signal_connect (entry->completion, "action-activated",
                          G_CALLBACK (action_cb), NULL);
-       
+
        g_signal_connect (object, "activate",
                          G_CALLBACK (activate_cb), NULL);
-       
+
        g_signal_connect (object, "changed",
                          G_CALLBACK (update_database), NULL);
        g_signal_connect (object, "notify::is-focus",
@@ -560,10 +557,10 @@ ephy_topics_entry_constructor (GType type,
                          G_CALLBACK (update_key), NULL);
        g_signal_connect (object, "notify::text",
                          G_CALLBACK (update_key), NULL);
-       
+
        update_key (entry);
        update_widget (entry);
-       
+
        return object;
 }
 
@@ -576,7 +573,7 @@ static void
 ephy_topics_entry_finalize (GObject *object)
 {
        EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (object);
-       
+
        g_free (entry->create);
        g_free (entry->key);
 


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