aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog28
-rw-r--r--embed/mozilla/EphyWrapper.cpp2
-rw-r--r--embed/mozilla/Makefile.am2
-rw-r--r--lib/egg/egg-action.c11
-rw-r--r--lib/egg/egg-menu-merge.c4
-rw-r--r--lib/ephy-dnd.c50
-rw-r--r--lib/ephy-dnd.h1
-rw-r--r--lib/ephy-string.c3
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c51
-rw-r--r--src/bookmarks/ephy-bookmarks.c2
-rw-r--r--src/bookmarks/ephy-new-bookmark.c18
-rw-r--r--src/bookmarks/ephy-new-bookmark.h3
-rw-r--r--src/popup-commands.c3
-rwxr-xr-xsrc/toolbar.c76
-rw-r--r--src/window-commands.c3
15 files changed, 205 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index ead24c9cd..370b14fca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,33 @@
2003-01-30 Marco Pesenti Gritti <marco@it.gnome.org>
+ * data/ui/epiphany-toolbar.xml.in:
+ * embed/mozilla/EphyWrapper.cpp:
+ * embed/mozilla/Makefile.am:
+ * lib/egg/egg-action.c: (disconnect_proxy):
+ * lib/egg/egg-menu-merge.c: (update_node):
+ * lib/ephy-dnd.c: (ephy_dnd_uri_list_extract_uris):
+ * lib/ephy-dnd.h:
+ * lib/ephy-string.c: (ephy_str_to_int):
+ * lib/widgets/ephy-editable-toolbar.c: (item_node_new),
+ (impl_get_action), (add_action), (parse_item_list),
+ (toolbar_list_to_xml), (ephy_editable_toolbar_save), (do_merge),
+ (free_node), (ephy_editable_toolbar_finalize):
+ * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_bookmark_id):
+ * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add),
+ (ephy_new_bookmark_response_cb), (ephy_new_bookmark_init),
+ (ephy_new_bookmark_set_icon), (ephy_new_bookmark_get_id):
+ * src/bookmarks/ephy-new-bookmark.h:
+ * src/popup-commands.c: (popup_cmd_add_link_bookmark):
+ * src/toolbar.c: (get_bookmark_action), (toolbar_get_action):
+ * src/window-commands.c: (window_cmd_file_add_bookmark):
+
+ Allow to drag also normal urls in the toolbars.
+ Commit some fixes I did to the eggmenu stuff, now
+ toolbar editor should work well, please start
+ reporting bugs :)
+
+2003-01-30 Marco Pesenti Gritti <marco@it.gnome.org>
+
* lib/ephy-dnd.c: (ephy_dnd_url_drag_source_set),
(ephy_dnd_enable_model_drag_source):
* lib/ephy-dnd.h:
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp
index 8473d1a6f..ce89557da 100644
--- a/embed/mozilla/EphyWrapper.cpp
+++ b/embed/mozilla/EphyWrapper.cpp
@@ -42,7 +42,7 @@
#include "nsIComponentManager.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
-
+#include "nsToolkitCompsCID.h"
#include "nsIDOMWindowInternal.h"
#include "nsIInterfaceRequestor.h"
#include "nsIFocusController.h"
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 0bac73513..6b28eb267 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -30,6 +30,7 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT)/progressDlg \
-I$(MOZILLA_INCLUDE_ROOT)/sidebar \
-I$(MOZILLA_INCLUDE_ROOT)/shistory \
+ -I$(MOZILLA_INCLUDE_ROOT)/history \
-I$(MOZILLA_INCLUDE_ROOT)/uconv \
-I$(MOZILLA_INCLUDE_ROOT)/uriloader \
-I$(MOZILLA_INCLUDE_ROOT)/unicharutil \
@@ -40,6 +41,7 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT)/widget \
-I$(MOZILLA_INCLUDE_ROOT)/windowwatcher \
-I$(MOZILLA_INCLUDE_ROOT)/typeaheadfind \
+ -I$(MOZILLA_INCLUDE_ROOT)/toolkitcomps \
$(GCONF_CFLAGS) \
$(EPIPHANY_DEPENDENCY_CFLAGS) \
-DLIB_DIR=\"$(pkglibdir)\" \
diff --git a/lib/egg/egg-action.c b/lib/egg/egg-action.c
index 360ba358e..89886b575 100644
--- a/lib/egg/egg-action.c
+++ b/lib/egg/egg-action.c
@@ -560,11 +560,14 @@ disconnect_proxy (EggAction *action, GtkWidget *proxy)
G_CALLBACK (egg_action_sync_stock_id), proxy);
/* menu item specific synchronisers ... */
- g_signal_handlers_disconnect_by_func (action,
- G_CALLBACK (egg_action_sync_label),
- proxy);
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_handlers_disconnect_by_func (action,
+ G_CALLBACK (egg_action_sync_label),
+ proxy);
- gtk_menu_item_set_accel_path (GTK_MENU_ITEM (proxy), NULL);
+ gtk_menu_item_set_accel_path (GTK_MENU_ITEM (proxy), NULL);
+ }
/* toolbar button specific synchronisers ... */
g_signal_handlers_disconnect_by_func (action,
diff --git a/lib/egg/egg-menu-merge.c b/lib/egg/egg-menu-merge.c
index 3bdd73156..bacc34dde 100644
--- a/lib/egg/egg-menu-merge.c
+++ b/lib/egg/egg-menu-merge.c
@@ -992,8 +992,8 @@ update_node (EggMenuMerge *self, GNode *node)
goto recurse_children;
}
- if (info->action)
- g_object_unref (info->action);
+/* if (info->action)
+ g_object_unref (info->action);*/
info->action = action;
/* if (info->action)
g_object_ref (info->action);*/
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c
index 03fa83544..99438495c 100644
--- a/lib/ephy-dnd.c
+++ b/lib/ephy-dnd.c
@@ -20,6 +20,7 @@
#include <gtk/gtkselection.h>
#include <gtk/gtktreeview.h>
+#include <string.h>
static GtkTargetEntry url_drag_types [] =
{
@@ -108,3 +109,52 @@ ephy_dnd_enable_model_drag_source (GtkWidget *treeview)
GDK_ACTION_COPY);
}
+GList *
+ephy_dnd_uri_list_extract_uris (const char *uri_list)
+{
+ /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */
+
+ const gchar *p, *q;
+ gchar *retval;
+ GList *result = NULL;
+
+ g_return_val_if_fail (uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p != NULL) {
+ if (*p != '#') {
+ while (g_ascii_isspace (*p))
+ p++;
+
+ q = p;
+ while ((*q != '\0')
+ && (*q != '\n')
+ && (*q != '\r'))
+ q++;
+
+ if (q > p) {
+ q--;
+ while (q > p
+ && g_ascii_isspace (*q))
+ q--;
+
+ retval = g_malloc (q - p + 2);
+ strncpy (retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ result = g_list_prepend (result, retval);
+ }
+ }
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+
+ return g_list_reverse (result);
+}
diff --git a/lib/ephy-dnd.h b/lib/ephy-dnd.h
index 7d5281128..e888977a8 100644
--- a/lib/ephy-dnd.h
+++ b/lib/ephy-dnd.h
@@ -59,6 +59,7 @@ void ephy_dnd_url_drag_source_set (GtkWidget *widget);
void ephy_dnd_enable_model_drag_source (GtkWidget *treeview);
+GList *ephy_dnd_uri_list_extract_uris (const char *uri_list);
G_END_DECLS
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index ca32e824c..46ea0194f 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -156,9 +156,6 @@ ephy_str_to_int (const char *string, gulong *integer)
if ((result == G_MINLONG || result == G_MAXLONG) && errno == ERANGE) {
return FALSE;
}
- if (result < G_MININT || result > G_MAXINT) {
- return FALSE;
- }
/* Check that all the trailing characters are spaces. */
while (*parse_end != '\0') {
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
index b082d6c31..8ab1a1904 100755
--- a/lib/widgets/ephy-editable-toolbar.c
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -88,7 +88,6 @@ typedef struct
{
gboolean separator;
EggAction *action;
- char *type;
} ItemNode;
GType
@@ -132,14 +131,13 @@ toolbar_node_new (void)
}
static ItemNode *
-item_node_new (EggAction *action, const char *type, gboolean separator)
+item_node_new (EggAction *action, gboolean separator)
{
ItemNode *item;
item = g_new0 (ItemNode, 1);
item->action = action;
item->separator = separator;
- item->type = type ? g_strdup (type) : NULL;
return item;
}
@@ -188,8 +186,6 @@ impl_get_action (EphyEditableToolbar *etoolbar,
{
EggAction *action;
- LOG ("Getting an action");
-
if (type == NULL)
{
action = find_action (etoolbar, name);
@@ -218,9 +214,10 @@ add_action (EphyEditableToolbar *t,
if (!separator)
{
action = ephy_editable_toolbar_get_action (t, type, name);
+ g_return_if_fail (action != NULL);
}
- item = item_node_new (action, type, separator);
+ item = item_node_new (action, separator);
node = g_node_new (item);
g_node_insert_before (parent, sibling, node);
@@ -236,14 +233,11 @@ parse_item_list (EphyEditableToolbar *t,
if (xmlStrEqual (child->name, "toolitem"))
{
xmlChar *verb;
- xmlChar *type;
verb = xmlGetProp (child, "verb");
- type = xmlGetProp (child, "type");
- add_action (t, parent, NULL, type, verb);
+ add_action (t, parent, NULL, NULL, verb);
xmlFree (verb);
- xmlFree (type);
}
else if (xmlStrEqual (child->name, "separator"))
{
@@ -367,10 +361,6 @@ toolbar_list_to_xml (EphyEditableToolbar *t, GNode *tl)
{
node = xmlNewChild (tnode, NULL, "toolitem", NULL);
xmlSetProp (node, "verb", item->action->name);
- if (item->type)
- {
- xmlSetProp (node, "type", item->type);
- }
}
}
}
@@ -628,6 +618,17 @@ ensure_toolbars_min_size (EphyEditableToolbar *t)
}
static void
+ephy_editable_toolbar_save (EphyEditableToolbar *t)
+{
+ xmlDocPtr doc;
+
+ doc = toolbar_list_to_xml (t, t->priv->toolbars);
+ xmlSaveFormatFile (t->priv->filename, doc, 1);
+ xmlFreeDoc (doc);
+}
+
+
+static void
do_merge (EphyEditableToolbar *t)
{
char *str;
@@ -656,6 +657,8 @@ do_merge (EphyEditableToolbar *t)
ensure_toolbars_min_size (t);
+ ephy_editable_toolbar_save (t);
+
g_free (str);
}
@@ -740,13 +743,9 @@ ephy_editable_toolbar_init (EphyEditableToolbar *t)
}
static void
-ephy_editable_toolbar_save (EphyEditableToolbar *t)
+free_node (GNode *node)
{
- xmlDocPtr doc;
-
- doc = toolbar_list_to_xml (t, t->priv->toolbars);
- xmlSaveFormatFile (t->priv->filename, doc, 1);
- xmlFreeDoc (doc);
+ g_free (node->data);
}
static void
@@ -757,7 +756,17 @@ ephy_editable_toolbar_finalize (GObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (object));
- ephy_editable_toolbar_save (t);
+ if (t->priv->editor)
+ {
+ gtk_widget_destroy (t->priv->editor);
+ }
+
+ g_node_children_foreach (t->priv->available_actions, G_IN_ORDER,
+ (GNodeForeachFunc)free_node, NULL);
+ g_node_children_foreach (t->priv->toolbars, G_IN_ORDER,
+ (GNodeForeachFunc)free_node, NULL);
+ g_node_destroy (t->priv->available_actions);
+ g_node_destroy (t->priv->toolbars);
g_free (t->priv->filename);
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 7e1d2bdd5..42be2aa12 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -675,7 +675,7 @@ ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb,
}
else
{
- return -1;
+ return 0;
}
}
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index de3cdbe80..dab846439 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -48,6 +48,7 @@ struct EphyNewBookmarkPrivate
char *location;
char *smarturl;
char *icon;
+ gulong id;
GtkWidget *title_entry;
GtkWidget *keywords_entry;
@@ -144,14 +145,16 @@ ephy_new_bookmark_add (EphyNewBookmark *new_bookmark)
{
char *title;
char *keywords;
+ EphyNode *node;
title = gtk_editable_get_chars
(GTK_EDITABLE (new_bookmark->priv->title_entry), 0, -1);
keywords = gtk_editable_get_chars
(GTK_EDITABLE (new_bookmark->priv->keywords_entry), 0, -1);
- ephy_bookmarks_add (new_bookmark->priv->bookmarks, title,
- new_bookmark->priv->location,
- new_bookmark->priv->smarturl, keywords);
+ node = ephy_bookmarks_add (new_bookmark->priv->bookmarks, title,
+ new_bookmark->priv->location,
+ new_bookmark->priv->smarturl, keywords);
+ new_bookmark->priv->id = ephy_node_get_id (node);
if (new_bookmark->priv->icon)
{
@@ -174,8 +177,6 @@ ephy_new_bookmark_response_cb (GtkDialog *dialog,
ephy_new_bookmark_add (new_bookmark);
break;
}
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
}
static GtkWidget *
@@ -334,6 +335,7 @@ ephy_new_bookmark_init (EphyNewBookmark *editor)
editor->priv->location = NULL;
editor->priv->smarturl = NULL;
editor->priv->icon = NULL;
+ editor->priv->id = 0;
}
void
@@ -361,3 +363,9 @@ ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark,
bookmark->priv->icon = icon ? g_strdup (icon) : NULL;
}
+gulong
+ephy_new_bookmark_get_id (EphyNewBookmark *bookmark)
+{
+ return bookmark->priv->id;
+}
+
diff --git a/src/bookmarks/ephy-new-bookmark.h b/src/bookmarks/ephy-new-bookmark.h
index d0219ea14..7e351dc55 100644
--- a/src/bookmarks/ephy-new-bookmark.h
+++ b/src/bookmarks/ephy-new-bookmark.h
@@ -63,6 +63,9 @@ void ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark,
void ephy_new_bookmark_set_smarturl (EphyNewBookmark *bookmark,
const char *url);
+gulong ephy_new_bookmark_get_id (EphyNewBookmark *bookmark);
+
+
G_END_DECLS
#endif /* EPHY_NEW_BOOKMARK_H */
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 84ce259c8..95e8eee78 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -162,7 +162,8 @@ popup_cmd_add_link_bookmark (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 826adc596..1df62677c 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -32,6 +32,7 @@
#include "window-commands.h"
#include "ephy-string.h"
#include "ephy-debug.h"
+#include "ephy-new-bookmark.h"
#include <string.h>
@@ -111,6 +112,25 @@ go_location_cb (EggAction *action, char *location, EphyWindow *window)
}
static EggAction *
+get_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id)
+{
+ char action_name[255];
+ EggAction *action;
+
+ LOG ("Creating action for bookmark id %ld", id)
+
+ snprintf (action_name, 255, "GoBookmarkId%ld", id);
+ action = ephy_bookmark_action_new (action_name, id);
+
+ g_signal_connect (action, "go_location",
+ G_CALLBACK (go_location_cb), t->priv->window);
+ egg_action_group_add_action (t->priv->action_group, action);
+ g_object_unref (action);
+
+ return action;
+}
+
+static EggAction *
toolbar_get_action (EphyEditableToolbar *etoolbar,
const char *type,
const char *name)
@@ -120,22 +140,52 @@ toolbar_get_action (EphyEditableToolbar *etoolbar,
EphyBookmarks *bookmarks;
gulong id = 0;
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+
if (type && (strcmp (type, EPHY_DND_URL_TYPE) == 0))
{
- char action_name[255];
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- id = ephy_bookmarks_get_bookmark_id (bookmarks, name);
-
- snprintf (action_name, 255, "GoBookmarkId%ld", id);
- action = ephy_bookmark_action_new (name, id);
-
- g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb), t->priv->window);
- egg_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
+ GtkWidget *new_bookmark;
+ const char *url;
+ const char *title = NULL;
+ GList *uris;
+
+ uris = ephy_dnd_uri_list_extract_uris (name);
+ g_return_val_if_fail (uris != NULL, NULL);
+ url = (const char *)uris->data;
+ if (uris->next)
+ {
+ title = (const char *)uris->next->data;
+ }
+
+ id = ephy_bookmarks_get_bookmark_id (bookmarks, url);
+
+ if (id == 0)
+ {
+ new_bookmark = ephy_new_bookmark_new
+ (bookmarks, GTK_WINDOW (t->priv->window), url);
+ ephy_new_bookmark_set_title (EPHY_NEW_BOOKMARK (new_bookmark),
+ title);
+ gtk_dialog_run (GTK_DIALOG (new_bookmark));
+ id = ephy_new_bookmark_get_id (EPHY_NEW_BOOKMARK (new_bookmark));
+ gtk_widget_destroy (new_bookmark);
+ }
+
+ g_return_val_if_fail (id != 0, NULL);
+
+ action = get_bookmark_action (t, bookmarks, id);
+
+ g_list_foreach (uris, (GFunc)g_free, NULL);
+ g_list_free (uris);
}
- else
+ else if (g_str_has_prefix (name, "GoBookmarkId"))
+ {
+ if (ephy_str_to_int (name + strlen ("GoBookmarkId"), &id))
+ {
+ action = get_bookmark_action (t, bookmarks, id);
+ }
+ }
+
+ if (action == NULL)
{
action = EPHY_EDITABLE_TOOLBAR_CLASS
(parent_class)->get_action (etoolbar, type, name);
diff --git a/src/window-commands.c b/src/window-commands.c
index 11040d8e5..f83f56a89 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -294,7 +294,8 @@ window_cmd_file_add_bookmark (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