diff options
Diffstat (limited to 'plugins/sample/sample.c')
-rw-r--r-- | plugins/sample/sample.c | 82 |
1 files changed, 78 insertions, 4 deletions
diff --git a/plugins/sample/sample.c b/plugins/sample/sample.c index e19450401..c36352e6f 100644 --- a/plugins/sample/sample.c +++ b/plugins/sample/sample.c @@ -20,23 +20,97 @@ #include <gmodule.h> #include <glib-object.h> -#include "ephy-shell.h" +#include "epiphany/ephy-shell.h" +#include "epiphany/session.h" static void -bmks_changed (EphyBookmarks *bookmarks) +bmk_added (EphyNode *node, EphyNode *child) { - g_print ("Bookmarks changed !\n"); + g_print ("Bookmark added\n"); +} + +static void +bmk_removed (EphyNode *node, EphyNode *child) +{ + g_print ("Bookmark removed\n"); +} + +static void +bmk_changed (EphyNode *node, EphyNode *child) +{ + g_print ("Bookmark changed\n"); +} + +static void +switch_page_cb (GtkWidget *widget) +{ + GtkWidget *toplevel; + EphyTab *tab; + + toplevel = gtk_widget_get_toplevel (widget); + + tab = ephy_window_get_active_tab (EPHY_WINDOW (toplevel)); + g_print ("New active tab is %p\n", tab); +} + +static void +window_focus_in_cb (GtkWidget *widget, GdkEventFocus *event) +{ + EphyTab *tab; + + tab = ephy_window_get_active_tab (EPHY_WINDOW (widget)); + g_print ("New active tab is %p\n", tab); +} + +static void +location_changed_cb (EphyEmbed *embed, char *location) +{ + g_print ("New location %s\n", location); +} + +static void +tab_added_cb (GtkWidget *nb, GtkWidget *child) +{ + g_signal_connect (child, "ge_location", + G_CALLBACK (location_changed_cb), NULL); +} + +static void +new_window_cb (Session *session, EphyWindow *window) +{ + GtkWidget *nb; + + nb = ephy_window_get_notebook (window); + + g_signal_connect (window, "focus_in_event", + G_CALLBACK (window_focus_in_cb), NULL); + g_signal_connect (nb, "switch_page", + G_CALLBACK (switch_page_cb), NULL); + g_signal_connect (nb, "tab_added", + G_CALLBACK (tab_added_cb), NULL); } G_MODULE_EXPORT void plugin_init (GTypeModule *module) { EphyBookmarks *bookmarks; + Session *session; + EphyNode *bmks; g_print ("plugin init\n"); bookmarks = ephy_shell_get_bookmarks (ephy_shell); - g_signal_connect (bookmarks, "tree_changed", G_CALLBACK (bmks_changed), NULL); + bmks = ephy_bookmarks_get_bookmarks (bookmarks); + ephy_node_signal_connect_object (bmks, EPHY_NODE_CHILD_ADDED, + (EphyNodeCallback) bmk_added, NULL); + ephy_node_signal_connect_object (bmks, EPHY_NODE_CHILD_CHANGED, + (EphyNodeCallback) bmk_changed, NULL); + ephy_node_signal_connect_object (bmks, EPHY_NODE_CHILD_REMOVED, + (EphyNodeCallback) bmk_removed, NULL); + + session = SESSION (ephy_shell_get_session (ephy_shell)); + g_signal_connect (session, "new_window", + G_CALLBACK (new_window_cb), NULL); } G_MODULE_EXPORT void |