evolution-data-server r9760 - in trunk: docs/reference/libedataserverui/tmpl libedataserverui
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9760 - in trunk: docs/reference/libedataserverui/tmpl libedataserverui
- Date: Mon, 17 Nov 2008 21:04:50 +0000 (UTC)
Author: mbarnes
Date: Mon Nov 17 21:04:50 2008
New Revision: 9760
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9760&view=rev
Log:
2008-11-17 Matthew Barnes <mbarnes redhat com>
** Fixes part of bug #557818
* libedataserverui/e-source-selector.c:
Allow the ESourceSelector widget to determine whether a drag and
drop event is valid, and emit a new signal ("data-dropped") if it
_is_ valid. This eliminates a lot of duplicate code in Evolution.
Note, while this is technically an ABI break, we explicitly
decided NOT to bump the libedataserverui soname because the
changes only affect Evolution. And while we're at it, add
extra padding to the end of ESourceSelectorClass to allow for
future expansion.
Modified:
trunk/docs/reference/libedataserverui/tmpl/e-source-selector.sgml
trunk/libedataserverui/ChangeLog
trunk/libedataserverui/e-data-server-ui-marshal.list
trunk/libedataserverui/e-source-selector.c
trunk/libedataserverui/e-source-selector.h
Modified: trunk/docs/reference/libedataserverui/tmpl/e-source-selector.sgml
==============================================================================
--- trunk/docs/reference/libedataserverui/tmpl/e-source-selector.sgml (original)
+++ trunk/docs/reference/libedataserverui/tmpl/e-source-selector.sgml Mon Nov 17 21:04:50 2008
@@ -23,6 +23,18 @@
</para>
+<!-- ##### SIGNAL ESourceSelector::data-dropped ##### -->
+<para>
+
+</para>
+
+ esourceselector: the object which received the signal.
+ arg1:
+ arg2:
+ arg3:
+ arg4:
+ Returns:
+
<!-- ##### SIGNAL ESourceSelector::popup-event ##### -->
<para>
Modified: trunk/libedataserverui/e-data-server-ui-marshal.list
==============================================================================
--- trunk/libedataserverui/e-data-server-ui-marshal.list (original)
+++ trunk/libedataserverui/e-data-server-ui-marshal.list Mon Nov 17 21:04:50 2008
@@ -1 +1,2 @@
BOOLEAN:OBJECT,BOXED
+BOOLEAN:BOXED,OBJECT,FLAGS,UINT
Modified: trunk/libedataserverui/e-source-selector.c
==============================================================================
--- trunk/libedataserverui/e-source-selector.c (original)
+++ trunk/libedataserverui/e-source-selector.c Mon Nov 17 21:04:50 2008
@@ -68,12 +68,11 @@
SELECTION_CHANGED,
PRIMARY_SELECTION_CHANGED,
POPUP_EVENT,
+ DATA_DROPPED,
NUM_SIGNALS
};
static unsigned int signals[NUM_SIGNALS] = { 0 };
-static gboolean selector_popup_menu (GtkWidget *widget);
-
G_DEFINE_TYPE (ESourceSelector, e_source_selector, GTK_TYPE_TREE_VIEW)
/* Selection management. */
@@ -673,18 +672,6 @@
}
static gboolean
-selector_popup_menu (GtkWidget *widget)
-{
- ESourceSelector *selector = E_SOURCE_SELECTOR (widget);
- ESource *source;
- gboolean res = FALSE;
-
- source = e_source_selector_peek_primary_selection (selector);
- g_signal_emit (selector, signals[POPUP_EVENT], 0, source, NULL, &res);
- return res;
-}
-
-static gboolean
selector_button_press_event (GtkWidget *widget, GdkEventButton *event, ESourceSelector *selector)
{
ESourceSelectorPrivate *priv = selector->priv;
@@ -827,6 +814,161 @@
G_OBJECT_CLASS (e_source_selector_parent_class)->finalize (object);
}
+static void
+source_selector_drag_leave (GtkWidget *widget,
+ GdkDragContext *context,
+ guint time_)
+{
+ GtkTreeView *tree_view;
+ GtkTreeViewDropPosition pos;
+
+ tree_view = GTK_TREE_VIEW (widget);
+ pos = GTK_TREE_VIEW_DROP_BEFORE;
+
+ gtk_tree_view_set_drag_dest_row (tree_view, NULL, pos);
+}
+
+static gboolean
+source_selector_drag_motion (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time_)
+{
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GtkTreePath *path = NULL;
+ GtkTreeIter iter;
+ GtkTreeViewDropPosition pos;
+ GdkDragAction action = 0;
+ gpointer object = NULL;
+
+ tree_view = GTK_TREE_VIEW (widget);
+ model = gtk_tree_view_get_model (tree_view);
+
+ if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, NULL))
+ goto exit;
+
+ if (!gtk_tree_model_get_iter (model, &iter, path))
+ goto exit;
+
+ gtk_tree_model_get (model, &iter, 0, &object, -1);
+
+ if (E_IS_SOURCE_GROUP (object) || e_source_get_readonly (object))
+ goto exit;
+
+ pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
+ gtk_tree_view_set_drag_dest_row (tree_view, path, pos);
+
+ if (context->actions & GDK_ACTION_MOVE)
+ action = GDK_ACTION_MOVE;
+ else
+ action = context->suggested_action;
+
+exit:
+ if (path != NULL)
+ gtk_tree_path_free (path);
+
+ if (object != NULL)
+ g_object_unref (object);
+
+ gdk_drag_status (context, action, time_);
+
+ return TRUE;
+}
+
+static gboolean
+source_selector_drag_drop (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time_)
+{
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gboolean drop_zone;
+ gboolean valid;
+ gpointer object;
+
+ tree_view = GTK_TREE_VIEW (widget);
+ model = gtk_tree_view_get_model (tree_view);
+
+ if (!gtk_tree_view_get_path_at_pos (
+ tree_view, x, y, &path, NULL, NULL, NULL))
+ return FALSE;
+
+ valid = gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+ g_return_val_if_fail (valid, FALSE);
+
+ gtk_tree_model_get (model, &iter, 0, &object, -1);
+ drop_zone = E_IS_SOURCE (object);
+ g_object_unref (object);
+
+ return drop_zone;
+}
+
+static void
+source_selector_drag_data_received (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time_)
+{
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GtkTreePath *path = NULL;
+ GtkTreeIter iter;
+ gpointer object = NULL;
+ gboolean delete;
+ gboolean success = FALSE;
+
+ tree_view = GTK_TREE_VIEW (widget);
+ model = gtk_tree_view_get_model (tree_view);
+ delete = (context->action == GDK_ACTION_MOVE);
+
+ if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, NULL))
+ goto exit;
+
+ if (!gtk_tree_model_get_iter (model, &iter, path))
+ goto exit;
+
+ gtk_tree_model_get (model, &iter, 0, &object, -1);
+
+ if (!E_IS_SOURCE (object) || e_source_get_readonly (object))
+ goto exit;
+
+ g_signal_emit (
+ widget, signals[DATA_DROPPED], 0, selection_data,
+ object, context->action, info, &success);
+
+exit:
+ if (path != NULL)
+ gtk_tree_path_free (path);
+
+ if (object != NULL)
+ g_object_unref (object);
+
+ gtk_drag_finish (context, success, delete, time_);
+}
+
+static gboolean
+source_selector_popup_menu (GtkWidget *widget)
+{
+ ESourceSelector *selector;
+ ESource *source;
+ gboolean res = FALSE;
+
+ selector = E_SOURCE_SELECTOR (widget);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_signal_emit (selector, signals[POPUP_EVENT], 0, source, NULL, &res);
+
+ return res;
+}
/* Initialization. */
static gboolean
@@ -854,7 +996,11 @@
object_class->finalize = source_selector_finalize;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->popup_menu = selector_popup_menu;
+ widget_class->drag_leave = source_selector_drag_leave;
+ widget_class->drag_motion = source_selector_drag_motion;
+ widget_class->drag_drop = source_selector_drag_drop;
+ widget_class->drag_data_received = source_selector_drag_data_received;
+ widget_class->popup_menu = source_selector_popup_menu;
g_object_class_install_property (
object_class,
@@ -893,6 +1039,18 @@
e_data_server_ui_marshal_BOOLEAN__OBJECT_BOXED,
G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT,
GDK_TYPE_EVENT|G_SIGNAL_TYPE_STATIC_SCOPE);
+ signals[DATA_DROPPED] =
+ g_signal_new ("data_dropped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESourceSelectorClass, data_dropped),
+ NULL, NULL,
+ e_data_server_ui_marshal_BOOLEAN__BOXED_OBJECT_FLAGS_UINT,
+ G_TYPE_BOOLEAN, 4,
+ GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
+ E_TYPE_SOURCE,
+ GDK_TYPE_DRAG_ACTION,
+ G_TYPE_UINT);
}
static gboolean
Modified: trunk/libedataserverui/e-source-selector.h
==============================================================================
--- trunk/libedataserverui/e-source-selector.h (original)
+++ trunk/libedataserverui/e-source-selector.h Mon Nov 17 21:04:50 2008
@@ -49,9 +49,21 @@
struct _ESourceSelectorClass {
GtkTreeViewClass parent_class;
- void (* selection_changed) (ESourceSelector *selector);
- void (* primary_selection_changed) (ESourceSelector *selector);
- gboolean (*popup_event)(ESourceSelector *selector, ESource *primary, GdkEventButton *event);
+ void (*selection_changed) (ESourceSelector *selector);
+ void (*primary_selection_changed)
+ (ESourceSelector *selector);
+ gboolean (*popup_event) (ESourceSelector *selector,
+ ESource *primary,
+ GdkEventButton *event);
+ gboolean (*data_dropped) (ESourceSelector *selector,
+ GtkSelectionData *data,
+ ESource *destination,
+ GdkDragAction action,
+ guint target_info);
+
+ gpointer padding1;
+ gpointer padding2;
+ gpointer padding3;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]