aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-04-09 06:42:33 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-04-09 06:42:33 +0800
commitb934ed62cfeb93b86c0f655eff39ff0de63ef7df (patch)
tree6f63b812bdd1e14a3e0581c59216c59790def63d /src
parentfaca041aa2dfd5e8243eb10ab8dbf609352ffbf5 (diff)
downloadgsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar.gz
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar.bz2
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar.lz
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar.xz
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.tar.zst
gsoc2013-epiphany-b934ed62cfeb93b86c0f655eff39ff0de63ef7df.zip
Add funcs to add/remove focus monitor. Make the code nicer and fix warning
2003-04-09 Marco Pesenti Gritti <marco@it.gnome.org> * src/bookmarks/ephy-bookmarks-editor.c: (add_focus_monitor), (remove_focus_monitor), (ephy_bookmarks_editor_dispose), (ephy_bookmarks_editor_node_selected_cb), (ephy_bookmarks_editor_construct): Add funcs to add/remove focus monitor. Make the code nicer and fix warning on destroy.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c145
1 files changed, 78 insertions, 67 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index e1c8c168d..4786c9d67 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -398,48 +398,6 @@ ephy_bookmarks_editor_class_init (EphyBookmarksEditorClass *klass)
}
static void
-ephy_bookmarks_editor_dispose (GObject *object)
-{
- EphyBookmarksEditor *editor;
- long selected_id;
- char *selected_id_str;
- GList *selection;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (EPHY_IS_BOOKMARKS_EDITOR (object));
-
- editor = EPHY_BOOKMARKS_EDITOR (object);
-
- g_return_if_fail (editor->priv != NULL);
-
- if (editor->priv->key_view != NULL)
- {
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view));
- if (selection == NULL || selection->data == NULL)
- {
- editor->priv->key_view = NULL;
- G_OBJECT_CLASS (parent_class)->dispose (object);
- return;
- }
-
- selected_id = ephy_node_get_id (EPHY_NODE (selection->data));
- if (selected_id >= 0)
- {
- selected_id_str = g_strdup_printf ("%ld", selected_id);
- eel_gconf_set_string (CONF_BOOKMARKS_SELECTED_NODE,
- selected_id_str);
- g_free (selected_id_str);
- }
-
- g_list_free (selection);
-
- editor->priv->key_view = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
ephy_bookmarks_editor_finalize (GObject *object)
{
EphyBookmarksEditor *editor;
@@ -551,14 +509,6 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor,
g_object_set (action, "sensitive", properties, NULL);
}
-static void
-ephy_bookmarks_editor_node_selected_cb (EphyNodeView *view,
- EphyNode *node,
- EphyBookmarksEditor *editor)
-{
- ephy_bookmarks_editor_update_menu (editor, view);
-}
-
static gboolean
view_focus_cb (EphyNodeView *view,
GdkEventFocus *event,
@@ -570,6 +520,81 @@ view_focus_cb (EphyNodeView *view,
}
static void
+add_focus_monitor (EphyBookmarksEditor *editor, GtkWidget *widget)
+{
+ g_signal_connect (G_OBJECT (widget),
+ "focus_in_event",
+ G_CALLBACK (view_focus_cb),
+ editor);
+ g_signal_connect (G_OBJECT (widget),
+ "focus_out_event",
+ G_CALLBACK (view_focus_cb),
+ editor);
+}
+
+static void
+remove_focus_monitor (EphyBookmarksEditor *editor, GtkWidget *widget)
+{
+ g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
+ G_CALLBACK (view_focus_cb),
+ editor);
+}
+
+static void
+ephy_bookmarks_editor_dispose (GObject *object)
+{
+ EphyBookmarksEditor *editor;
+ long selected_id;
+ char *selected_id_str;
+ GList *selection;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EPHY_IS_BOOKMARKS_EDITOR (object));
+
+ editor = EPHY_BOOKMARKS_EDITOR (object);
+
+ g_return_if_fail (editor->priv != NULL);
+
+ if (editor->priv->key_view != NULL)
+ {
+ remove_focus_monitor (editor, editor->priv->key_view);
+ remove_focus_monitor (editor, editor->priv->bm_view);
+
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view));
+ if (selection == NULL || selection->data == NULL)
+ {
+ editor->priv->key_view = NULL;
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+ return;
+ }
+
+ selected_id = ephy_node_get_id (EPHY_NODE (selection->data));
+ if (selected_id >= 0)
+ {
+ selected_id_str = g_strdup_printf ("%ld", selected_id);
+ eel_gconf_set_string (CONF_BOOKMARKS_SELECTED_NODE,
+ selected_id_str);
+ g_free (selected_id_str);
+ }
+
+ g_list_free (selection);
+
+ editor->priv->key_view = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+
+static void
+ephy_bookmarks_editor_node_selected_cb (EphyNodeView *view,
+ EphyNode *node,
+ EphyBookmarksEditor *editor)
+{
+ ephy_bookmarks_editor_update_menu (editor, view);
+}
+
+static void
bookmarks_filter (EphyBookmarksEditor *editor,
EphyNode *keyword)
{
@@ -806,10 +831,11 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
ephy_node_view_set_browse_mode (EPHY_NODE_VIEW (key_view));
ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"),
EPHY_TREE_MODEL_NODE_COL_KEYWORD, TRUE, TRUE);
- gtk_container_add (GTK_CONTAINER (scrolled_window), key_view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), key_view);
gtk_widget_set_size_request (key_view, 130, -1);
gtk_widget_show (key_view);
editor->priv->key_view = key_view;
+ add_focus_monitor (editor, key_view);
g_signal_connect (G_OBJECT (key_view),
"key_press_event",
G_CALLBACK (key_pressed_cb),
@@ -819,14 +845,6 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
G_CALLBACK (keyword_node_selected_cb),
editor);
g_signal_connect (G_OBJECT (key_view),
- "focus_in_event",
- G_CALLBACK (view_focus_cb),
- editor);
- g_signal_connect (G_OBJECT (key_view),
- "focus_out_event",
- G_CALLBACK (view_focus_cb),
- editor);
- g_signal_connect (G_OBJECT (key_view),
"show_popup",
G_CALLBACK (keyword_node_show_popup_cb),
editor);
@@ -870,6 +888,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view);
gtk_widget_show (bm_view);
editor->priv->bm_view = bm_view;
+ add_focus_monitor (editor, bm_view);
g_signal_connect (G_OBJECT (bm_view),
"key_press_event",
G_CALLBACK (key_pressed_cb),
@@ -883,14 +902,6 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
G_CALLBACK (ephy_bookmarks_editor_node_selected_cb),
editor);
g_signal_connect (G_OBJECT (bm_view),
- "focus_in_event",
- G_CALLBACK (view_focus_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
- "focus_out_event",
- G_CALLBACK (view_focus_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
"show_popup",
G_CALLBACK (ephy_bookmarks_editor_show_popup_cb),
editor);