aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks.c53
-rw-r--r--src/bookmarks/ephy-bookmarks.h5
-rw-r--r--src/bookmarks/ephy-new-bookmark.c2
-rw-r--r--src/popup-commands.c3
-rwxr-xr-xsrc/toolbar.c61
-rw-r--r--src/window-commands.c3
6 files changed, 117 insertions, 10 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index cd159994d..5db21ad14 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -49,8 +49,17 @@ ephy_bookmarks_finalize (GObject *object);
static void
ephy_bookmarks_autocompletion_source_init (EphyAutocompletionSourceIface *iface);
+enum
+{
+ BOOKMARK_REMOVE,
+ TOPIC_REMOVE,
+ LAST_SIGNAL
+};
+
static GObjectClass *parent_class = NULL;
+static guint ephy_bookmarks_signals[LAST_SIGNAL] = { 0 };
+
GType
ephy_bookmarks_get_type (void)
{
@@ -160,6 +169,27 @@ ephy_bookmarks_class_init (EphyBookmarksClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_bookmarks_finalize;
+
+ ephy_bookmarks_signals[BOOKMARK_REMOVE] =
+ g_signal_new ("bookmark_remove",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyBookmarksClass, bookmark_remove),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+ ephy_bookmarks_signals[TOPIC_REMOVE] =
+ g_signal_new ("topic_remove",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyBookmarksClass, topic_remove),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
}
static void
@@ -374,10 +404,28 @@ bookmarks_removed_cb (EphyNode *node,
EphyNode *child,
EphyBookmarks *eb)
{
+ long id;
+
+ id = ephy_node_get_id (child);
+ g_signal_emit (eb, ephy_bookmarks_signals[BOOKMARK_REMOVE],
+ 0, id);
+
ephy_bookmarks_emit_data_changed (eb);
}
static void
+topics_removed_cb (EphyNode *node,
+ EphyNode *child,
+ EphyBookmarks *eb)
+{
+ long id;
+
+ id = ephy_node_get_id (child);
+ g_signal_emit (eb, ephy_bookmarks_signals[TOPIC_REMOVE],
+ 0, id);
+}
+
+static void
ephy_bookmarks_init (EphyBookmarks *eb)
{
GValue value = { 0, };
@@ -417,6 +465,11 @@ ephy_bookmarks_init (EphyBookmarks *eb)
EPHY_NODE_KEYWORD_PROP_PRIORITY,
&value);
g_value_unset (&value);
+ g_signal_connect_object (G_OBJECT (eb->priv->keywords),
+ "child_removed",
+ G_CALLBACK (topics_removed_cb),
+ G_OBJECT (eb),
+ 0);
ephy_node_add_child (eb->priv->keywords,
eb->priv->bookmarks);
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index e31831c6f..174c3c930 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -63,6 +63,11 @@ struct EphyBookmarks
struct EphyBookmarksClass
{
GObjectClass parent_class;
+
+ void (* bookmark_remove) (EphyBookmarks *eb,
+ long id);
+ void (* topic_remove) (EphyBookmarks *eb,
+ long id);
};
GType ephy_bookmarks_get_type (void);
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index 6eb5d7a12..f133e167d 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -183,8 +183,6 @@ ephy_new_bookmark_response_cb (GtkDialog *dialog,
ephy_new_bookmark_add (new_bookmark);
break;
}
-
- gtk_widget_destroy (GTK_WIDGET (new_bookmark));
}
static GtkWidget *
diff --git a/src/popup-commands.c b/src/popup-commands.c
index b66c92c31..2e2bb9080 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -162,7 +162,8 @@ popup_cmd_bookmark_link (EggAction *action,
(EPHY_NEW_BOOKMARK (new_bookmark), title);
ephy_new_bookmark_set_smarturl
(EPHY_NEW_BOOKMARK (new_bookmark), rel);
- gtk_widget_show (new_bookmark);
+ gtk_dialog_run (GTK_DIALOG (new_bookmark));
+ gtk_widget_destroy (new_bookmark);
}
void
diff --git a/src/toolbar.c b/src/toolbar.c
index ff28353a0..18fc59f61 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -62,6 +62,8 @@ enum
PROP_EPHY_WINDOW
};
+static EggToolbarsGroup *toolbars_group = NULL;
+
static GObjectClass *parent_class = NULL;
struct ToolbarPrivate
@@ -197,6 +199,8 @@ toolbar_get_action_name (EggEditableToolbar *etoolbar,
}
}
+ LOG ("Action name is %s", res)
+
return res;
}
@@ -219,6 +223,7 @@ toolbar_get_action (EggEditableToolbar *etoolbar,
}
else if (g_str_has_prefix (name, "GoBookmarkId"))
{
+ LOG ("Create action %s", name)
if (!ephy_str_to_int (name + strlen ("GoBookmarkId"), &id))
{
return NULL;
@@ -228,6 +233,7 @@ toolbar_get_action (EggEditableToolbar *etoolbar,
}
else if (g_str_has_prefix (name, "GoTopicId"))
{
+ LOG ("Create action %s", name)
if (!ephy_str_to_int (name + strlen ("GoTopicId"), &id))
{
return NULL;
@@ -395,10 +401,46 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
}
static void
-toolbar_init (Toolbar *t)
+topic_remove_cb (EphyBookmarks *eb,
+ long id,
+ Toolbar *t)
+{
+ EggAction *action;
+ char *name;
+
+ name = g_strdup_printf ("GoTopicId%ld", id);
+ action = egg_action_group_get_action (t->priv->action_group, name);
+ if (action)
+ {
+ egg_toolbars_group_remove_action (toolbars_group, action->name);
+ egg_action_group_remove_action (t->priv->action_group, action);
+ }
+
+ g_free (name);
+}
+
+static void
+bookmark_remove_cb (EphyBookmarks *eb,
+ long id,
+ Toolbar *t)
{
- static EggToolbarsGroup *group = NULL;
+ EggAction *action;
+ char *name;
+
+ name = g_strdup_printf ("GoBookmarkId%ld", id);
+ action = egg_action_group_get_action (t->priv->action_group, name);
+ if (action)
+ {
+ egg_toolbars_group_remove_action (toolbars_group, action->name);
+ egg_action_group_remove_action (t->priv->action_group, action);
+ }
+ g_free (name);
+}
+
+static void
+toolbar_init (Toolbar *t)
+{
t->priv = g_new0 (ToolbarPrivate, 1);
t->priv->window = NULL;
@@ -410,18 +452,25 @@ toolbar_init (Toolbar *t)
egg_editable_toolbar_add_drag_type (EGG_EDITABLE_TOOLBAR (t),
EPHY_DND_URL_TYPE);
- if (group == NULL)
+ if (toolbars_group == NULL)
{
char *user;
+ EphyBookmarks *bookmarks;
user = g_build_filename (ephy_dot_dir (), "toolbar.xml", NULL);
- group = egg_toolbars_group_new ();
+ toolbars_group = egg_toolbars_group_new ();
egg_toolbars_group_set_source
- (group, ephy_file ("epiphany-toolbar.xml"), user);
+ (toolbars_group, ephy_file ("epiphany-toolbar.xml"), user);
g_free (user);
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ g_signal_connect (bookmarks, "bookmark_remove",
+ G_CALLBACK (bookmark_remove_cb), t);
+ g_signal_connect (bookmarks, "topic_remove",
+ G_CALLBACK (topic_remove_cb), t);
}
- g_object_set (t, "ToolbarsGroup", group, NULL);
+ g_object_set (t, "ToolbarsGroup", toolbars_group, NULL);
}
static void
diff --git a/src/window-commands.c b/src/window-commands.c
index a4c5844e0..f9e5ecf72 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -315,7 +315,8 @@ window_cmd_file_bookmark_page (EggAction *action,
(EPHY_NEW_BOOKMARK (new_bookmark), title);
ephy_new_bookmark_set_icon
(EPHY_NEW_BOOKMARK (new_bookmark), icon);
- gtk_widget_show (new_bookmark);
+ gtk_dialog_run (GTK_DIALOG (new_bookmark));
+ gtk_widget_destroy (new_bookmark);
}
void