diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-03-29 08:45:35 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-03-29 08:45:35 +0800 |
commit | 68ff809d73900bcf7e9342bf358f6c29eb865181 (patch) | |
tree | 99fc8b7688b6620784b49d6eea09e2a323397d25 | |
parent | 991ec0a565029dd58b28160fddbb20126d5170df (diff) | |
download | gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar.gz gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar.bz2 gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar.lz gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar.xz gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.tar.zst gsoc2013-epiphany-68ff809d73900bcf7e9342bf358f6c29eb865181.zip |
Implement topics menu. TODO: All should generate the crappy bookmarks
2003-03-29 Marco Pesenti Gritti <marco@it.gnome.org>
* src/bookmarks/ephy-topic-action.c: (create_tool_item),
(menu_deactivate_cb), (menu_activate_cb), (build_topics_menu),
(button_press_cb), (ephy_topic_action_set_property),
(ephy_topic_action_get_property), (ephy_topic_action_class_init),
(ephy_topic_action_new):
Implement topics menu.
TODO: All should generate the crappy bookmarks menu, favicons,
topic icon.
These are lower priority for me now though.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 89 |
2 files changed, 88 insertions, 14 deletions
@@ -1,3 +1,16 @@ +2003-03-29 Marco Pesenti Gritti <marco@it.gnome.org> + + * src/bookmarks/ephy-topic-action.c: (create_tool_item), + (menu_deactivate_cb), (menu_activate_cb), (build_topics_menu), + (button_press_cb), (ephy_topic_action_set_property), + (ephy_topic_action_get_property), (ephy_topic_action_class_init), + (ephy_topic_action_new): + + Implement topics menu. + TODO: All should generate the crappy bookmarks menu, favicons, + topic icon. + These are lower priority for me now though. + 2003-03-29 Xan Lopez <xan@masilla.org> * help/.cvsignore: diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index a560817e4..54fb87eba 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -21,13 +21,14 @@ #include "ephy-shell.h" #include "eggtoolitem.h" #include "ephy-debug.h" +#include "ephy-gui.h" static void ephy_topic_action_init (EphyTopicAction *action); static void ephy_topic_action_class_init (EphyTopicActionClass *class); struct EphyTopicActionPrivate { - int bookmark_id; + int topic_id; }; enum @@ -87,7 +88,7 @@ create_tool_item (EggAction *action) gtk_widget_show (hbox); gtk_container_add (GTK_CONTAINER (item), hbox); - button = gtk_button_new (); + button = gtk_toggle_button_new (); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_widget_show (button); gtk_container_add (GTK_CONTAINER (hbox), button); @@ -106,6 +107,25 @@ create_tool_item (EggAction *action) } static void +menu_deactivate_cb (GtkMenuShell *ms, GtkWidget *button) +{ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE); +} + +static void +menu_activate_cb (GtkWidget *item, EggAction *action) +{ + EphyNode *node; + const char *location; + + node = EPHY_NODE (g_object_get_data (G_OBJECT (item), "node")); + location = ephy_node_get_property_string + (node, EPHY_NODE_BMK_PROP_LOCATION); + g_signal_emit (action, ephy_topic_action_signals[GO_LOCATION], + 0, location); +} + +static void ephy_topic_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget *proxy) { GtkLabel *label; @@ -118,21 +138,61 @@ ephy_topic_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget *p gtk_label_set_label (label, action->label); } -static void +static GtkWidget * +build_topics_menu (EphyTopicAction *action, GtkWidget *button) +{ + GtkWidget *menu, *item; + GPtrArray *children; + int i; + EphyNode *node; + + node = ephy_node_get_from_id (action->priv->topic_id); + + menu = gtk_menu_new (); + g_signal_connect (menu, "deactivate", + G_CALLBACK (menu_deactivate_cb), button); + + children = ephy_node_get_children (node); + for (i = 0; i < children->len; i++) + { + EphyNode *kid; + const char *title; + + kid = g_ptr_array_index (children, i); + + title = ephy_node_get_property_string + (kid, EPHY_NODE_BMK_PROP_TITLE); + + item = gtk_menu_item_new_with_label (title); + g_object_set_data (G_OBJECT (item), "node", kid); + g_signal_connect (item, "activate", + G_CALLBACK (menu_activate_cb), action); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + } + ephy_node_thaw (node); + + return menu; +} + +static gboolean button_press_cb (GtkWidget *button, GdkEventButton *event, EphyTopicAction *action) { -/* - if (event->button == 3) + if (event->button == 1) { GtkWidget *menu; - menu = build_topics_menu (action); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, - gtk_get_current_event_time ()); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + + menu = build_topics_menu (action, button); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, + ephy_gui_menu_position_under_widget, + button, 1, gtk_get_current_event_time ()); } -*/ + + return FALSE; } static void @@ -164,7 +224,7 @@ ephy_topic_action_set_property (GObject *object, switch (prop_id) { case PROP_BOOKMARK_ID: - bmk->priv->bookmark_id = g_value_get_int (value); + bmk->priv->topic_id = g_value_get_int (value); break; } } @@ -182,7 +242,7 @@ ephy_topic_action_get_property (GObject *object, switch (prop_id) { case PROP_BOOKMARK_ID: - g_value_set_boolean (value, bmk->priv->bookmark_id); + g_value_set_boolean (value, bmk->priv->topic_id); break; } } @@ -235,9 +295,9 @@ ephy_topic_action_class_init (EphyTopicActionClass *class) g_object_class_install_property (object_class, PROP_BOOKMARK_ID, - g_param_spec_int ("bookmark_id", - "bookmark_id", - "bookmark_id", + g_param_spec_int ("topic_id", + "topic_id", + "topic_id", 0, G_MAXINT, 0, @@ -266,6 +326,7 @@ ephy_topic_action_new (const char *name, guint id) (bmk, EPHY_NODE_KEYWORD_PROP_NAME); return EGG_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION, + "topic_id", id, "name", name, "label", title, NULL)); |