aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c241
-rw-r--r--src/bookmarks/ephy-bookmarks.c56
-rw-r--r--src/bookmarks/ephy-bookmarks.h5
-rw-r--r--src/bookmarks/ephy-topics-entry.c97
-rw-r--r--src/bookmarks/ephy-topics-palette.c20
5 files changed, 280 insertions, 139 deletions
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 559b16b01..a1c7066e8 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -59,7 +59,9 @@ struct _EphyBookmarkPropertiesPrivate
EphyNode *bookmark;
gboolean creating;
- EphyNode *duplicate;
+ gint duplicate_count;
+ gint duplicate_idle;
+
GtkWidget *warning;
GtkWidget *entry;
GtkWidget *palette;
@@ -75,20 +77,45 @@ enum
static GObjectClass *parent_class;
+static gboolean
+update_warning (EphyBookmarkProperties *properties)
+{
+ EphyBookmarkPropertiesPrivate *priv = properties->priv;
+ char *label;
+
+ priv->duplicate_idle = 0;
+ priv->duplicate_count = ephy_bookmarks_count_duplicates
+ (priv->bookmarks, priv->bookmark);
+
+ label = g_strdup_printf (_("%d _Similar"), priv->duplicate_count);
+ gtk_button_set_label (GTK_BUTTON (priv->warning), label);
+ g_free (label);
+
+ g_object_set (priv->warning, "sensitive", priv->duplicate_count > 0, NULL);
+
+ return FALSE;
+}
+
static void
-node_added_cb (EphyNode *bookmarks,
- EphyNode *bookmark,
- EphyBookmarkProperties *properties)
+update_warning_idle (EphyBookmarkProperties *properties)
{
EphyBookmarkPropertiesPrivate *priv = properties->priv;
- if (priv->duplicate == NULL)
+ if(priv->duplicate_idle != 0)
{
- priv->duplicate = ephy_bookmarks_find_duplicate
- (priv->bookmarks, priv->bookmark);
- g_object_set (priv->warning, "visible",
- priv->duplicate != NULL, NULL);
+ g_source_remove (priv->duplicate_idle);
}
+
+ priv->duplicate_idle = g_timeout_add
+ (500, (GSourceFunc)update_warning, properties);
+}
+
+static void
+node_added_cb (EphyNode *bookmarks,
+ EphyNode *bookmark,
+ EphyBookmarkProperties *properties)
+{
+ update_warning_idle (properties);
}
static void
@@ -97,15 +124,9 @@ node_changed_cb (EphyNode *bookmarks,
guint property,
EphyBookmarkProperties *properties)
{
- EphyBookmarkPropertiesPrivate *priv = properties->priv;
-
- if (priv->duplicate == bookmark || priv->bookmark == bookmark ||
- priv->duplicate == NULL)
+ if (property == EPHY_NODE_BMK_PROP_LOCATION)
{
- priv->duplicate = ephy_bookmarks_find_duplicate
- (priv->bookmarks, priv->bookmark);
- g_object_set (priv->warning, "visible",
- priv->duplicate != NULL, NULL);
+ update_warning_idle (properties);
}
}
@@ -115,21 +136,14 @@ node_removed_cb (EphyNode *bookmarks,
guint index,
EphyBookmarkProperties *properties)
{
- EphyBookmarkPropertiesPrivate *priv = properties->priv;
-
- if (priv->duplicate == bookmark)
- {
- priv->duplicate = ephy_bookmarks_find_duplicate
- (priv->bookmarks, priv->bookmark);
- g_object_set (priv->warning, "visible",
- priv->duplicate != NULL, NULL);
- }
+ update_warning_idle (properties);
}
static void
node_destroy_cb (EphyNode *bookmark,
GtkWidget *dialog)
{
+ EPHY_BOOKMARK_PROPERTIES (dialog)->priv->creating = FALSE;
gtk_widget_destroy (dialog);
}
@@ -157,17 +171,97 @@ ephy_bookmark_properties_set_bookmark (EphyBookmarkProperties *properties,
G_OBJECT (properties));
}
+static void
+activate_merge_cb (GtkMenuItem *item,
+ EphyBookmarkProperties *properties)
+{
+ EphyBookmarkPropertiesPrivate *priv = properties->priv;
+ GPtrArray *duplicates;
+ GPtrArray *topics;
+ EphyNode *node, *topic;
+ gint i, j;
+
+ duplicates = ephy_bookmarks_find_duplicates
+ (priv->bookmarks, priv->bookmark);
+
+ node = ephy_bookmarks_get_keywords (priv->bookmarks);
+ topics = ephy_node_get_children (node);
+
+ for (i = 0; i < duplicates->len; i++)
+ {
+ node = g_ptr_array_index (duplicates, i);
+ for (j = 0; j < topics->len; j++)
+ {
+ topic = g_ptr_array_index (topics, j);
+
+ if (ephy_node_has_child (topic, node))
+ {
+ ephy_bookmarks_set_keyword
+ (priv->bookmarks, topic, priv->bookmark);
+ }
+ }
+ ephy_node_unref (node);
+ }
+
+ g_ptr_array_free (duplicates, TRUE);
+
+ update_warning (properties);
+}
+
+static void
+activate_show_cb (GtkMenuItem *item,
+ EphyNode *node)
+{
+ ephy_bookmarks_ui_show_bookmark (node);
+}
static void
show_duplicate_cb (GtkButton *button,
EphyBookmarkProperties *properties)
{
EphyBookmarkPropertiesPrivate *priv = properties->priv;
- EphyNode *dup = ephy_bookmarks_find_duplicate (priv->bookmarks, priv->bookmark);
+ EphyNode *node;
+ GPtrArray *duplicates;
+ GtkMenuShell *menu;
+ GtkWidget *item, *image;
+ gint i;
+
+ update_warning (properties);
+ if (priv->duplicate_count == 0)
+ {
+ return;
+ }
- g_return_if_fail (dup != NULL);
+ duplicates = ephy_bookmarks_find_duplicates
+ (priv->bookmarks, priv->bookmark);
- ephy_bookmarks_ui_show_bookmark (dup);
+ menu = GTK_MENU_SHELL (gtk_menu_new ());
+ item = gtk_image_menu_item_new_with_mnemonic (_("_Merge"));
+ image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ g_signal_connect (item, "activate", G_CALLBACK (activate_merge_cb), properties);
+ gtk_widget_show (image);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (menu, item);
+
+ item = gtk_separator_menu_item_new ();
+ gtk_widget_show (item);
+ gtk_menu_shell_append (menu, item);
+
+ for (i = 0; i < duplicates->len; i++)
+ {
+ node = g_ptr_array_index (duplicates, i);
+ item = gtk_image_menu_item_new_with_label
+ (ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE));
+ g_signal_connect (item, "activate", G_CALLBACK (activate_show_cb), node);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (menu, item);
+ }
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_under_widget, button,
+ 0, gtk_get_current_event_time ());
+
+ g_ptr_array_free (duplicates, TRUE);
}
static void
@@ -177,10 +271,16 @@ bookmark_properties_destroy_cb (GtkDialog *dialog,
EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog);
EphyBookmarkPropertiesPrivate *priv = properties->priv;
- if (priv->creating && priv->bookmark != NULL)
+ if (priv->creating)
{
ephy_node_unref (priv->bookmark);
- priv->bookmark = NULL;
+ priv->creating = FALSE;
+ }
+
+ if(priv->duplicate_idle != 0)
+ {
+ g_source_remove (priv->duplicate_idle);
+ priv->duplicate_idle = 0;
}
}
@@ -199,11 +299,8 @@ bookmark_properties_response_cb (GtkDialog *dialog,
"epiphany",
"to-edit-bookmark-properties");
return;
- case GTK_RESPONSE_ACCEPT:
- /* On destruction of the dialog, if priv->creating==TRUE,
- * we will unref any bookmark we have, so we set it
- * to NULL here to 'protect' it from unreffing. */
- priv->bookmark = NULL;
+ case GTK_RESPONSE_ACCEPT:
+ priv->creating = FALSE;
break;
default:
break;
@@ -273,7 +370,7 @@ toggled_cb (GtkToggleButton *button,
if(gtk_toggle_button_get_active (button))
{
g_object_set (priv->entry, "sensitive", FALSE, NULL);
- g_object_set (priv->palette, "visible", TRUE, NULL);
+ gtk_widget_show (priv->palette);
geometry.min_width = -1;
geometry.min_height = 230;
@@ -284,7 +381,7 @@ toggled_cb (GtkToggleButton *button,
else
{
g_object_set (priv->entry, "sensitive", TRUE, NULL);
- g_object_set (priv->palette, "visible", FALSE, NULL);
+ gtk_widget_hide (priv->palette);
geometry.max_height = -1;
geometry.max_width = G_MAXINT;
@@ -310,10 +407,11 @@ ephy_bookmark_properties_constructor (GType type,
EphyBookmarkProperties *properties;
EphyBookmarkPropertiesPrivate *priv;
GtkWidget *widget, *table, *label, *entry, *button;
- GtkWidget *scrolled_window, *palette;
+ GtkWidget *container, *palette;
GtkWindow *window;
GtkDialog *dialog;
const char *tmp;
+ char *text;
object = parent_class->constructor (type, n_construct_properties,
construct_params);
@@ -349,7 +447,7 @@ ephy_bookmark_properties_constructor (GType type,
table = gtk_table_new (4, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_table_set_col_spacing (GTK_TABLE (table), 1, 3);
+ gtk_table_set_col_spacing (GTK_TABLE (table), 1, 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_widget_show (table);
@@ -384,17 +482,6 @@ ephy_bookmark_properties_constructor (GType type,
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- widget = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_BUTTON);
- priv->warning = gtk_button_new_with_mnemonic (_("_Show similar bookmark"));
- gtk_button_set_image (GTK_BUTTON (priv->warning), widget);
- g_signal_connect (priv->warning, "clicked",
- G_CALLBACK(show_duplicate_cb), properties);
- gtk_widget_show (priv->warning);
- gtk_table_set_row_spacing (GTK_TABLE (table), 1, 0);
- gtk_table_attach (GTK_TABLE (table), priv->warning, 1, 3, 2, 3, GTK_FILL, 0, 0, 3);
- priv->duplicate = ephy_bookmarks_find_duplicate (priv->bookmarks, priv->bookmark);
- g_object_set (priv->warning, "visible", priv->duplicate != NULL, NULL);
-
entry = ephy_topics_entry_new (priv->bookmarks, priv->bookmark);
priv->entry = entry;
gtk_widget_show (entry);
@@ -402,39 +489,57 @@ ephy_bookmark_properties_constructor (GType type,
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
palette = ephy_topics_palette_new (priv->bookmarks, priv->bookmark);
- scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "hadjustment", NULL,
- "vadjustment", NULL,
- "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "shadow_type", GTK_SHADOW_IN,
- NULL);
- priv->palette = scrolled_window;
- gtk_container_add (GTK_CONTAINER (scrolled_window), palette);
+ container = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
+ "hadjustment", NULL,
+ "vadjustment", NULL,
+ "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "shadow_type", GTK_SHADOW_IN,
+ NULL);
+ priv->palette = container;
+ gtk_container_add (GTK_CONTAINER (container), palette);
gtk_widget_show (palette);
- gtk_table_attach (GTK_TABLE (table), scrolled_window, 1, 3, 4, 5,
+ gtk_table_attach (GTK_TABLE (table), container, 1, 3, 3, 4,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
- gtk_widget_show (scrolled_window);
+ gtk_widget_show (container);
widget = gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_BUTTON);
gtk_widget_show (widget);
button = gtk_toggle_button_new_with_label ("");
gtk_button_set_image (GTK_BUTTON (button), widget);
g_signal_connect (button, "toggled", G_CALLBACK (toggled_cb), properties);
- toggled_cb (button, properties);
+ toggled_cb (GTK_TOGGLE_BUTTON (button), properties);
gtk_widget_show (button);
- gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
-
+ gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
+
gtk_box_pack_start (GTK_BOX (dialog->vbox), table, TRUE, TRUE, 0);
+ priv->warning = gtk_button_new ();
+ gtk_button_set_use_underline (GTK_BUTTON (priv->warning), TRUE);
+ text = g_strdup_printf (_("%d _Similar"), 0);
+ gtk_button_set_label (GTK_BUTTON (priv->warning), text);
+ g_free (text);
+ widget = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (widget);
+ gtk_button_set_image (GTK_BUTTON (priv->warning), widget);
+ g_object_set (priv->warning, "sensitive", FALSE, NULL);
+ gtk_widget_show (priv->warning);
+ g_signal_connect (priv->warning, "clicked",
+ G_CALLBACK(show_duplicate_cb), properties);
+
gtk_dialog_add_button (dialog,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP);
+ gtk_box_pack_end (GTK_BOX (dialog->action_area),
+ priv->warning, FALSE, TRUE, 0);
+ gtk_button_box_set_child_secondary
+ (GTK_BUTTON_BOX (dialog->action_area), priv->warning, TRUE);
+
if (priv->creating)
{
gtk_dialog_add_button (dialog,
@@ -453,6 +558,8 @@ ephy_bookmark_properties_constructor (GType type,
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CLOSE);
}
+ update_warning_idle (properties);
+
return object;
}
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 7770265f7..207b55e62 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -1186,11 +1186,12 @@ ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
return NULL;
}
-EphyNode *
-ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
- EphyNode *bookmark)
+GPtrArray *
+ephy_bookmarks_find_duplicates (EphyBookmarks *eb,
+ EphyNode *bookmark)
{
GPtrArray *children;
+ GPtrArray *result;
const char *url;
int i;
@@ -1202,6 +1203,8 @@ ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
(bookmark, EPHY_NODE_BMK_PROP_LOCATION);
g_return_val_if_fail (url != NULL, NULL);
+
+ result = g_ptr_array_new ();
children = ephy_node_get_children (eb->priv->bookmarks);
for (i = 0; i < children->len; i++)
@@ -1220,11 +1223,54 @@ ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
if (location != NULL && strcmp (url, location) == 0)
{
- return kid;
+ g_ptr_array_add (result, kid);
}
}
- return NULL;
+ return result;
+}
+
+gint
+ephy_bookmarks_count_duplicates (EphyBookmarks *eb,
+ EphyNode *bookmark)
+{
+ GPtrArray *children;
+ const char *url;
+ int i, result;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), -1);
+ g_return_val_if_fail (eb->priv->bookmarks != NULL, -1);
+ g_return_val_if_fail (bookmark != NULL, -1);
+
+ url = ephy_node_get_property_string
+ (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+
+ g_return_val_if_fail (url != NULL, -1);
+
+ result = 0;
+
+ children = ephy_node_get_children (eb->priv->bookmarks);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+ const char *location;
+
+ kid = g_ptr_array_index (children, i);
+ if (kid == bookmark)
+ {
+ continue;
+ }
+
+ location = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+
+ if (location != NULL && strcmp (url, location) == 0)
+ {
+ result++;
+ }
+ }
+
+ return result;
}
void
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index f5874678e..774fa2a62 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -88,7 +88,10 @@ EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
EphyNode* ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
const char *url);
-EphyNode* ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
+GPtrArray *ephy_bookmarks_find_duplicates (EphyBookmarks *eb,
+ EphyNode *bookmark);
+
+gint ephy_bookmarks_count_duplicates (EphyBookmarks *eb,
EphyNode *bookmark);
void ephy_bookmarks_set_icon (EphyBookmarks *eb,
diff --git a/src/bookmarks/ephy-topics-entry.c b/src/bookmarks/ephy-topics-entry.c
index 6153e53a7..e9fc3ab74 100644
--- a/src/bookmarks/ephy-topics-entry.c
+++ b/src/bookmarks/ephy-topics-entry.c
@@ -125,39 +125,32 @@ insert_text (EphyTopicsEntry *entry,
const char *title)
{
GtkEditable *editable = GTK_EDITABLE (entry);
- const char *text = gtk_entry_get_text (GTK_ENTRY (entry));
- gint start, end;
- /* Find the start and end locations */
- start = gtk_editable_get_position (editable);
- while (start > 0 && text[start-1] != ';')
- {
- start--;
- }
- if(start > 0 && text[start-1] == ';' && text[start] == ' ')
- {
- start++;
- }
- end = start;
- while (text[end] && text[end] != ';')
- {
- end++;
- }
- end = end;
- if (text[end] == ';')
- {
- end++;
- if (text[end] == ' ')
- {
- end++;
- }
- }
+ 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, ',');
+ int startpos, endpos;
+
+ if (start == NULL)
+ 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;
+ else
+ startpos = g_utf8_pointer_to_offset (text, start)+1;
+
+ if (end == NULL)
+ 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;
+ else
+ endpos = g_utf8_pointer_to_offset (text, end)+1;
/* Replace the text in the current position with the title */
- gtk_editable_delete_text (editable, start, end);
- gtk_editable_insert_text (editable, title, strlen(title), &start);
- gtk_editable_insert_text (editable, "; ", 2, &start);
- gtk_editable_set_position (editable, start);
+ gtk_editable_delete_text (editable, startpos, endpos);
+ gtk_editable_insert_text (editable, title, strlen(title), &startpos);
+ gtk_editable_insert_text (editable, ", ", 2, &startpos);
+ gtk_editable_set_position (editable, startpos);
}
/* Updates the text entry and the completion model to match the database */
@@ -204,7 +197,7 @@ update_widget (EphyTopicsEntry *entry)
gtk_editable_delete_text (editable, 0, -1);
}
- for (pos = 0, i = 0; i < topics->len; i++)
+ for (pos = -1, 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);
@@ -212,7 +205,7 @@ update_widget (EphyTopicsEntry *entry)
if (update_text && ephy_node_has_child (node, priv->bookmark))
{
gtk_editable_insert_text (editable, title, -1, &pos);
- gtk_editable_insert_text (editable, "; ", -1, &pos);
+ gtk_editable_insert_text (editable, ", ", -1, &pos);
}
tmp1 = g_utf8_casefold (title, -1);
@@ -258,7 +251,7 @@ update_database (EphyTopicsEntry *entry)
/* Get the list of strings input by the user */
text = gtk_entry_get_text (GTK_ENTRY (entry));
- split = g_strsplit (text, ";", 0);
+ split = g_strsplit (text, ",", 0);
for (i=0; split[i]; i++)
{
g_strstrip (split[i]);
@@ -309,12 +302,24 @@ update_database (EphyTopicsEntry *entry)
static void
update_key (EphyTopicsEntry *entry)
{
- GtkEditable *editable = GTK_EDITABLE (entry);
EphyTopicsEntryPrivate *priv = entry->priv;
-
- const char *text = gtk_entry_get_text (GTK_ENTRY (entry));
+ GtkEditable *editable = GTK_EDITABLE (entry);
char *input;
- gint start, end;
+
+ 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;
+ else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
+ start = g_utf8_next_char (g_utf8_next_char (start));
+ else
+ start = g_utf8_next_char (start);
+
+ if (end == NULL)
+ end = text+strlen(text);
/* If there was something we could create, then delete the action. */
if (priv->create)
@@ -327,24 +332,8 @@ update_key (EphyTopicsEntry *entry)
priv->create = 0;
priv->key = 0;
- /* Find the start and end locations */
- start = gtk_editable_get_position (editable);
- while (start > 0 && text[start-1] != ';')
- {
- start--;
- }
- if(start > 0 && text[start-1] == ';' && text[start] == ' ')
- {
- start++;
- }
- end = start;
- while (text[end] && text[end] != ';')
- {
- end++;
- }
-
/* Set the priv->create and priv->key appropriately. */
- input = g_strndup (text+start, end-start);
+ input = g_strndup (start, end-start);
g_strstrip (input);
if (*input != 0)
{
diff --git a/src/bookmarks/ephy-topics-palette.c b/src/bookmarks/ephy-topics-palette.c
index 91618699d..db1897656 100644
--- a/src/bookmarks/ephy-topics-palette.c
+++ b/src/bookmarks/ephy-topics-palette.c
@@ -255,18 +255,11 @@ update_list (EphyTopicsPalette *palette)
(gtk_tree_view_get_selection (GTK_TREE_VIEW (palette)));
}
-static gboolean
-update_list_idle (EphyTopicsPalette *palette)
-{
- update_list (palette);
- return FALSE;
-}
-
static void
tree_changed_cb (EphyBookmarks *bookmarks,
EphyTopicsPalette *palette)
{
- g_idle_add ((GSourceFunc) update_list_idle, palette);
+ update_list (palette);
}
static void
@@ -274,7 +267,7 @@ node_added_cb (EphyNode *parent,
EphyNode *child,
EphyTopicsPalette *palette)
{
- g_idle_add ((GSourceFunc) update_list_idle, palette);
+ update_list (palette);
}
static void
@@ -283,7 +276,7 @@ node_changed_cb (EphyNode *parent,
guint property_id,
EphyTopicsPalette *palette)
{
- g_idle_add ((GSourceFunc) update_list_idle, palette);
+ update_list (palette);
}
static void
@@ -292,7 +285,7 @@ node_removed_cb (EphyNode *parent,
guint index,
EphyTopicsPalette *palette)
{
- g_idle_add ((GSourceFunc) update_list_idle, palette);
+ update_list (palette);
}
static void
@@ -324,7 +317,7 @@ ephy_topics_palette_set_property (GObject *object,
break;
case PROP_MODE:
palette->priv->mode = g_value_get_int (value);
- update_list_idle (palette);
+ update_list (palette);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -366,6 +359,9 @@ toggled (GtkCellRendererToggle *cell_renderer,
gtk_tree_model_get (model, &iter, COLUMN_NODE, &topic, -1);
+ /* Need to protect against toggling separators. */
+ if (topic == NULL) return;
+
if (ephy_node_has_child (topic, palette->priv->bookmark))
{
ephy_bookmarks_unset_keyword (palette->priv->bookmarks,