aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rwxr-xr-xlib/egg/egg-editable-toolbar.c77
-rwxr-xr-xlib/egg/egg-editable-toolbar.h2
-rw-r--r--src/ephy-favicon-action.c63
-rwxr-xr-xsrc/toolbar.c5
5 files changed, 122 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index b3abd4afd..399039286 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2003-04-05 Christian Persch <chpe@stud.uni-saarland.de>
+
+ * src/ephy-favicon-action.c: (create_tool_item), (connect_proxy):
+
+ Set drag source on the event box, to avoid conflicts with toolbars
+ drag and drop.
+
+2003-04-05 Marco Pesenti Gritti <marco@it.gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c:
+ * lib/egg/egg-editable-toolbar.h:
+
+ Update from egg.
+
+ * src/toolbar.c: (toolbar_init):
+
+ Use the new api to add drag types. Bookmarks dnd working again.
+
2003-04-04 Marco Pesenti Gritti <marco@it.gnome.org>
* configure.in:
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 4d1ce4875..d0f747ba5 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -21,16 +21,11 @@
#include "eggtoolitem.h"
#include "eggtoolbar.h"
#include "eggseparatortoolitem.h"
+#include "eggintl.h"
#include <string.h>
-#ifndef _
-# define _(s) (s)
-#endif
-
-#ifndef N_
-# define N_(s) (s)
-#endif
+#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
enum
{
@@ -38,12 +33,13 @@ enum
};
static GtkTargetEntry dest_drag_types[] = {
- {"application/x-toolbar-item", 0, X_TOOLBAR_ITEM},
+ {EGG_TOOLBAR_ITEM_TYPE, 0, X_TOOLBAR_ITEM},
};
+
static int n_dest_drag_types = G_N_ELEMENTS (dest_drag_types);
static GtkTargetEntry source_drag_types[] = {
- {"application/x-toolbar-item", 0, X_TOOLBAR_ITEM},
+ {EGG_TOOLBAR_ITEM_TYPE, 0, X_TOOLBAR_ITEM},
};
static int n_source_drag_types = G_N_ELEMENTS (source_drag_types);
@@ -109,6 +105,8 @@ struct EggEditableToolbarPrivate
EggActionGroup *popup_action_group;
GList *actions_list;
+
+ GList *drag_types;
};
typedef struct
@@ -245,6 +243,8 @@ drag_data_received_cb (GtkWidget *widget,
const char *type = NULL;
EggAction *action = NULL;
int pos;
+ GdkAtom target;
+ GList *l;
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
@@ -256,9 +256,19 @@ drag_data_received_cb (GtkWidget *widget,
/* HACK placeholder are implemented as separators */
pos = pos / 3 + 1;
- /* FIXME custom dnd types */
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+
+ for (l = etoolbar->priv->drag_types; l != NULL; l = l->next)
+ {
+ char *drag_type = (char *)l->data;
+
+ if (gdk_atom_intern (drag_type, FALSE) == target)
+ {
+ type = drag_type;
+ }
+ }
- if (type)
+ if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) != 0)
{
char *name;
@@ -461,6 +471,8 @@ disconnect_item_drag_source (EggToolbarsItem *item,
egg_tool_item_set_use_drag_window (EGG_TOOL_ITEM (toolitem), FALSE);
+ gtk_drag_source_unset (toolitem);
+
g_signal_handlers_disconnect_by_func (toolitem,
G_CALLBACK (drag_data_get_cb),
etoolbar);
@@ -543,6 +555,25 @@ popup_toolbar_context_menu (EggToolbar *toolbar,
gtk_get_current_event_time ());
}
+static GtkTargetList *
+get_dest_targets (EggEditableToolbar *etoolbar)
+{
+ GList *l;
+ GtkTargetList *targets;
+ int i;
+
+ targets = gtk_target_list_new (NULL, 0);
+
+ for (l = etoolbar->priv->drag_types; l != NULL; l = l->next)
+ {
+ char *type = (char *)l->data;
+ gtk_target_list_add (targets, gdk_atom_intern (type, FALSE), 0, i);
+ i++;
+ }
+
+ return targets;
+}
+
static void
setup_toolbar (EggToolbarsToolbar *toolbar,
EggEditableToolbar *etoolbar)
@@ -559,11 +590,16 @@ setup_toolbar (EggToolbarsToolbar *toolbar,
if (!g_object_get_data (G_OBJECT (widget), "drag_dest_set"))
{
+ GtkTargetList *targets;
+
g_object_set_data (G_OBJECT (widget), "drag_dest_set",
GINT_TO_POINTER (TRUE));
gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, n_dest_drag_types,
+ NULL, 0,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ targets = get_dest_targets (etoolbar);
+ gtk_drag_dest_set_target_list (widget, targets);
+ gtk_target_list_unref (targets);
g_signal_connect (widget, "drag_data_received",
G_CALLBACK (drag_data_received_cb), etoolbar);
}
@@ -789,6 +825,9 @@ egg_editable_toolbar_init (EggEditableToolbar *t)
t->priv->editor_sheet_dirty = FALSE;
t->priv->edit_mode = FALSE;
t->priv->actions_list = NULL;
+ t->priv->drag_types = NULL;
+
+ egg_editable_toolbar_add_drag_type (t, EGG_TOOLBAR_ITEM_TYPE);
for (i = 0; i < egg_toolbar_popups_n_entries; i++)
{
@@ -824,6 +863,12 @@ egg_editable_toolbar_finalize (GObject *object)
gtk_widget_destroy (t->priv->editor);
}
+ if (t->priv->drag_types)
+ {
+ g_list_foreach (t->priv->drag_types, (GFunc)g_free, NULL);
+ g_list_free (t->priv->drag_types);
+ }
+
g_object_unref (t->priv->popup_action_group);
egg_menu_merge_remove_action_group (t->priv->popup_merge,
t->priv->popup_action_group);
@@ -1131,6 +1176,14 @@ egg_editable_toolbar_edit (EggEditableToolbar *etoolbar,
show_editor (etoolbar);
}
+void
+egg_editable_toolbar_add_drag_type (EggEditableToolbar *etoolbar,
+ const char *drag_type)
+{
+ etoolbar->priv->drag_types = g_list_append
+ (etoolbar->priv->drag_types, g_strdup (drag_type));
+}
+
char *
egg_editable_toolbar_get_action_name (EggEditableToolbar *etoolbar,
const char *drag_type,
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 36d65cd35..29ccf8200 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -67,6 +67,8 @@ char *egg_editable_toolbar_get_action_name (EggEditableToolbar *etoolbar,
const char *data);
EggAction *egg_editable_toolbar_get_action (EggEditableToolbar *etoolbar,
const char *name);
+void egg_editable_toolbar_add_drag_type (EggEditableToolbar *etoolbar,
+ const char *drag_type);
G_END_DECLS
diff --git a/src/ephy-favicon-action.c b/src/ephy-favicon-action.c
index 4fa4a510a..1609f77c3 100644
--- a/src/ephy-favicon-action.c
+++ b/src/ephy-favicon-action.c
@@ -80,28 +80,6 @@ ephy_favicon_action_get_type (void)
return type;
}
-static GtkWidget *
-create_tool_item (EggAction *action)
-{
- GtkWidget *image;
- GtkWidget *ebox;
- GtkWidget *item;
-
- item = GTK_WIDGET (egg_tool_item_new ());
-
- ebox = gtk_event_box_new ();
- image = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (ebox), image);
- gtk_container_set_border_width (GTK_CONTAINER (ebox), 2);
- gtk_container_add (GTK_CONTAINER (item), ebox);
- gtk_widget_show (image);
- gtk_widget_show (ebox);
-
- g_object_set_data (G_OBJECT (item), "image", image);
-
- return item;
-}
-
static void
each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
gpointer iterator_context, gpointer data)
@@ -131,6 +109,38 @@ favicon_drag_data_get_cb (GtkWidget *widget,
info, time, window, each_url_get_data_binder);
}
+static GtkWidget *
+create_tool_item (EggAction *action)
+{
+ GtkWidget *image;
+ GtkWidget *ebox;
+ GtkWidget *item;
+
+ item = GTK_WIDGET (egg_tool_item_new ());
+
+ ebox = gtk_event_box_new ();
+ image = gtk_image_new ();
+ gtk_container_add (GTK_CONTAINER (ebox), image);
+ gtk_container_set_border_width (GTK_CONTAINER (ebox), 2);
+ gtk_container_add (GTK_CONTAINER (item), ebox);
+ gtk_widget_show (image);
+ gtk_widget_show (ebox);
+
+ g_object_set_data (G_OBJECT (item), "image", image);
+
+ gtk_drag_source_set (ebox,
+ GDK_BUTTON1_MASK,
+ url_drag_types,
+ n_url_drag_types,
+ GDK_ACTION_COPY);
+ g_signal_connect (ebox,
+ "drag_data_get",
+ G_CALLBACK (favicon_drag_data_get_cb),
+ EPHY_FAVICON_ACTION (action)->priv->window);
+
+ return item;
+}
+
static void
ephy_favicon_action_sync_icon (EggAction *action, GParamSpec *pspec,
GtkWidget *proxy)
@@ -164,16 +174,7 @@ ephy_favicon_action_sync_icon (EggAction *action, GParamSpec *pspec,
static void
connect_proxy (EggAction *action, GtkWidget *proxy)
{
- gtk_drag_source_set (proxy,
- GDK_BUTTON1_MASK,
- url_drag_types,
- n_url_drag_types,
- GDK_ACTION_COPY);
ephy_favicon_action_sync_icon (action, NULL, proxy);
- g_signal_connect (proxy,
- "drag_data_get",
- G_CALLBACK (favicon_drag_data_get_cb),
- EPHY_FAVICON_ACTION (action)->priv->window);
g_signal_connect_object (action, "notify::icon",
G_CALLBACK (ephy_favicon_action_sync_icon),
proxy, 0);
diff --git a/src/toolbar.c b/src/toolbar.c
index 146282058..ff28353a0 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -405,6 +405,11 @@ toolbar_init (Toolbar *t)
t->priv->ui_merge = NULL;
t->priv->visibility = TRUE;
+ egg_editable_toolbar_add_drag_type (EGG_EDITABLE_TOOLBAR (t),
+ EPHY_DND_TOPIC_TYPE);
+ egg_editable_toolbar_add_drag_type (EGG_EDITABLE_TOOLBAR (t),
+ EPHY_DND_URL_TYPE);
+
if (group == NULL)
{
char *user;