aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-07-03 07:07:44 +0800
committerChristian Persch <chpe@src.gnome.org>2003-07-03 07:07:44 +0800
commit5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e (patch)
tree0481749d5331da848f35140ea544cfb00f8b177d /src/bookmarks
parent76e761ad2019ffa8f86d41afc848f271bea4d1e0 (diff)
downloadgsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar.gz
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar.bz2
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar.lz
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar.xz
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.tar.zst
gsoc2013-epiphany-5aa9a4c46f443d5198c04f4c5b9fdd3391e5be8e.zip
Moved bookmark tool item creation back to ephy-bookmark-action.c, For
2003-07-03 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmark-toolitem.h: * src/bookmarks/ephy-bookmark-toolitem.c: * src/bookmarks/ephy-bookmark-action.c: (create_tool_item), (ephy_bookmark_action_sync_label), (activate_cb), (create_menu_proxy), (connect_proxy), (ephy_bookmark_action_class_init): Moved bookmark tool item creation back to ephy-bookmark-action.c, For smart bookmarks, don't append ':' in the toolbar overflow menu.
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/Makefile.am2
-rw-r--r--src/bookmarks/ephy-bookmark-action.c90
-rw-r--r--src/bookmarks/ephy-bookmark-toolitem.c177
-rw-r--r--src/bookmarks/ephy-bookmark-toolitem.h60
4 files changed, 81 insertions, 248 deletions
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
index 16bf2c5d2..4425d0aa5 100644
--- a/src/bookmarks/Makefile.am
+++ b/src/bookmarks/Makefile.am
@@ -32,8 +32,6 @@ libephybookmarks_la_SOURCES = \
ephy-bookmarks-menu.h \
ephy-bookmark-properties.c \
ephy-bookmark-properties.h \
- ephy-bookmark-toolitem.c \
- ephy-bookmark-toolitem.h \
ephy-new-bookmark.c \
ephy-new-bookmark.h \
ephy-topic-action.c \
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 1362b8d02..a2fa0c7ac 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -24,7 +24,6 @@
#include <libgnomevfs/gnome-vfs-uri.h>
#include "ephy-bookmark-action.h"
-#include "ephy-bookmark-toolitem.h"
#include "ephy-bookmarks.h"
#include "ephy-shell.h"
#include "ephy-string.h"
@@ -90,6 +89,47 @@ ephy_bookmark_action_get_type (void)
return type;
}
+static GtkWidget *
+create_tool_item (EggAction *action)
+{
+ GtkWidget *item, *button, *hbox, *label, *icon, *entry;
+
+ LOG ("Creating tool item for action %p", action)
+
+ item = (* EGG_ACTION_CLASS (parent_class)->create_tool_item) (action);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (item), hbox);
+
+ button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (hbox), button);
+ g_object_set_data (G_OBJECT (item), "button", button);
+
+ entry = gtk_entry_new ();
+ gtk_widget_set_size_request (entry, 120, -1);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+ g_object_set_data (G_OBJECT (item), "entry", entry);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (button), hbox);
+
+ icon = gtk_image_new ();
+ gtk_widget_show (icon);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, TRUE, TRUE, 0);
+ g_object_set_data (G_OBJECT (item), "icon", icon);
+
+ label = gtk_label_new (NULL);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ g_object_set_data (G_OBJECT (item), "label", label);
+
+ return item;
+}
+
static void
ephy_bookmark_action_sync_smart_url (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
{
@@ -165,7 +205,8 @@ ephy_bookmark_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget
title = ephy_string_shorten (action->label, MAX_LABEL_LENGTH);
- if (EPHY_BOOKMARK_ACTION (action)->priv->smart_url)
+ if (EPHY_BOOKMARK_ACTION (action)->priv->smart_url
+ && EGG_IS_TOOL_ITEM (proxy))
{
label_text = g_strdup_printf (_("%s:"), title);
}
@@ -196,9 +237,15 @@ ephy_bookmark_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget
}
static void
-activate_cb (GtkWidget *widget, const char *text, EggAction *action)
+activate_cb (GtkWidget *widget, EggAction *action)
{
char *location = NULL;
+ char *text = NULL;
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ }
if (text != NULL && text[0] != '\0')
{
@@ -240,17 +287,35 @@ activate_cb (GtkWidget *widget, const char *text, EggAction *action)
0, location);
g_free (location);
+ g_free (text);
}
-static void
-menu_activate_cb (GtkWidget *widget, EggAction *action)
+static gboolean
+create_menu_proxy (EggToolItem *item, EggAction *action)
{
- activate_cb (widget, NULL, action);
+ EphyBookmarkAction *bm_action = EPHY_BOOKMARK_ACTION (action);
+ GtkWidget *menu_item;
+ char *menu_id;
+
+ LOG ("create_menu_proxy item %p, action %p", item, action);
+
+ menu_item = EGG_ACTION_GET_CLASS (action)->create_menu_item (action);
+
+ EGG_ACTION_GET_CLASS (action)->connect_proxy (action, menu_item);
+
+ menu_id = g_strdup_printf ("ephy-bookmark-action-%d-menu-id",
+ bm_action->priv->bookmark_id);
+
+ egg_tool_item_set_proxy_menu_item (item, menu_id, menu_item);
+
+ return TRUE;
}
static void
connect_proxy (EggAction *action, GtkWidget *proxy)
{
+ GtkWidget *button, *entry;
+
LOG ("Connecting action %p to proxy %p", action, proxy)
(* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
@@ -269,11 +334,17 @@ connect_proxy (EggAction *action, GtkWidget *proxy)
if (EGG_IS_TOOL_ITEM (proxy))
{
- g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
+ button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button"));
+ g_signal_connect (button, "clicked", G_CALLBACK (activate_cb), action);
+
+ entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
+ g_signal_connect (entry, "activate", G_CALLBACK (activate_cb), action);
+
+ g_signal_connect (proxy, "create_menu_proxy", G_CALLBACK (create_menu_proxy), action);
}
else if (GTK_IS_MENU_ITEM (proxy))
{
- g_signal_connect (proxy, "activate", G_CALLBACK (menu_activate_cb), action);
+ g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
}
}
@@ -356,7 +427,8 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
parent_class = g_type_class_peek_parent (class);
action_class = EGG_ACTION_CLASS (class);
- action_class->toolbar_item_type = EPHY_TYPE_BOOKMARK_TOOLITEM;
+ action_class->toolbar_item_type = EGG_TYPE_TOOL_ITEM;
+ action_class->create_tool_item = create_tool_item;
action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
action_class->connect_proxy = connect_proxy;
diff --git a/src/bookmarks/ephy-bookmark-toolitem.c b/src/bookmarks/ephy-bookmark-toolitem.c
deleted file mode 100644
index b4245de29..000000000
--- a/src/bookmarks/ephy-bookmark-toolitem.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2003 Christian Persch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ephy-bookmark-toolitem.h"
-#include "ephy-marshal.h"
-#include "ephy-debug.h"
-
-#include <gtk/gtk.h>
-#include <gtk/gtkimagemenuitem.h>
-
-static GObjectClass *parent_class = NULL;
-
-static void ephy_bookmark_toolitem_class_init (EphyBookmarkToolitemClass *klass);
-static void ephy_bookmark_toolitem_init (EphyBookmarkToolitem *item);
-
-enum
-{
- ACTIVATE,
- LAST_SIGNAL
-};
-static guint EphyBookmarkToolitemSignals[LAST_SIGNAL];
-
-#define MENU_ID "ephy-bookmark-toolitem-menu-id"
-
-/**
- * EphyBookmarkToolitem object
- */
-
-GType
-ephy_bookmark_toolitem_get_type (void)
-{
- static GType ephy_bookmark_toolitem_type = 0;
-
- if (ephy_bookmark_toolitem_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (EphyBookmarkToolitemClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) ephy_bookmark_toolitem_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (EphyBookmarkToolitem),
- 0, /* n_preallocs */
- (GInstanceInitFunc) ephy_bookmark_toolitem_init,
- };
-
- ephy_bookmark_toolitem_type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
- "EphyBookmarkToolitem",
- &our_info, 0);
- }
-
- return ephy_bookmark_toolitem_type;
-}
-
-static void
-activated_cb (GtkWidget *widget, EggToolItem *item)
-{
- char *text = NULL;
-
- if (GTK_IS_EDITABLE (widget))
- {
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- }
-
- g_signal_emit (item, EphyBookmarkToolitemSignals[ACTIVATE], 0, text);
-
- g_free (text);
-}
-
-static gboolean
-ephy_bookmark_toolitem_create_menu_proxy (EggToolItem *item)
-{
- GtkWidget *menu_item, *label, *icon, *image;
- GdkPixbuf *pixbuf;
- const char *text;
-
- LOG ("create menu proxy for %p", item)
-
- icon = g_object_get_data (G_OBJECT (item), "icon");
- pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (icon));
- image = gtk_image_new_from_pixbuf (pixbuf);
-
- label = g_object_get_data (G_OBJECT (item), "label");
- text = gtk_label_get_label (GTK_LABEL (label));
-
- menu_item = gtk_image_menu_item_new_with_mnemonic (text);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
-
- g_signal_connect (menu_item, "activate", G_CALLBACK (activated_cb), item);
-
- egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
-
- return TRUE;
-}
-
-static void
-ephy_bookmark_toolitem_init (EphyBookmarkToolitem *item)
-{
- GtkWidget *button, *hbox, *label, *icon, *entry;
-
- LOG ("Initialising bookmark toolitem %p", item)
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (hbox);
- gtk_container_add (GTK_CONTAINER (item), hbox);
-
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- gtk_container_add (GTK_CONTAINER (hbox), button);
- g_object_set_data (G_OBJECT (item), "button", button);
-
- entry = gtk_entry_new ();
- gtk_widget_set_size_request (entry, 120, -1);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (item), "entry", entry);
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (hbox);
- gtk_container_add (GTK_CONTAINER (button), hbox);
-
- icon = gtk_image_new ();
- gtk_widget_show (icon);
- gtk_box_pack_start (GTK_BOX (hbox), icon, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (item), "icon", icon);
-
- label = gtk_label_new (NULL);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (item), "label", label);
-
- g_signal_connect (button, "clicked", G_CALLBACK (activated_cb), item);
- g_signal_connect (entry, "activate", G_CALLBACK (activated_cb), item);
-}
-
-static void
-ephy_bookmark_toolitem_class_init (EphyBookmarkToolitemClass *klass)
-{
- EggToolItemClass *tool_item_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- tool_item_class = (EggToolItemClass *)klass;
-
- tool_item_class->create_menu_proxy = ephy_bookmark_toolitem_create_menu_proxy;
-
- EphyBookmarkToolitemSignals[ACTIVATE] = g_signal_new (
- "activate", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyBookmarkToolitemClass, activated),
- NULL, NULL,
- ephy_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
-}
diff --git a/src/bookmarks/ephy-bookmark-toolitem.h b/src/bookmarks/ephy-bookmark-toolitem.h
deleted file mode 100644
index f8248637e..000000000
--- a/src/bookmarks/ephy-bookmark-toolitem.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2003 Christian Persch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef EPHY_BOOKMARK_TOOLITEM_H
-#define EPHY_BOOKMARK_TOOLITEM_H
-
-#include "eggtoolitem.h"
-
-G_BEGIN_DECLS
-
-/* object forward declarations */
-
-typedef struct _EphyBookmarkToolitem EphyBookmarkToolitem;
-typedef struct _EphyBookmarkToolitemClass EphyBookmarkToolitemClass;
-typedef struct _EphyBookmarkToolitemPrivate EphyBookmarkToolitemPrivate;
-
-/**
- * EphyBookmarkToolitem object
- */
-
-#define EPHY_TYPE_BOOKMARK_TOOLITEM (ephy_bookmark_toolitem_get_type())
-#define EPHY_BOOKMARK_TOOLITEM(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EPHY_TYPE_BOOKMARK_TOOLITEM, EphyBookmarkToolitem))
-#define EPHY_BOOKMARK_TOOLITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EPHY_TYPE_BOOKMARK_TOOLITEM, EphyBookmarkToolitemClass))
-#define EPHY_IS_BOOKMARK_TOOLITEM(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EPHY_TYPE_BOOKMARK_TOOLITEM))
-#define EPHY_IS_BOOKMARK_TOOLITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EPHY_TYPE_BOOKMARK_TOOLITEM))
-#define EPHY_BOOKMARK_TOOLITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_BOOKMARK_TOOLITEM, EphyBookmarkToolitemClass))
-
-struct _EphyBookmarkToolitemClass
-{
- EggToolItemClass parent_class;
-
- void (* activated) (EphyBookmarkToolitem *item,
- const char *text);
-};
-
-struct _EphyBookmarkToolitem
-{
- EggToolItem parent_object;
-};
-
-GType ephy_bookmark_toolitem_get_type (void);
-
-G_END_DECLS
-
-#endif