[maemo-commits] [maemo-commits] r12692 - in projects/haf/trunk/hildon-desktop: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jul 9 14:23:53 EEST 2007
Author: jobi
Date: 2007-07-09 14:23:49 +0300 (Mon, 09 Jul 2007)
New Revision: 12692

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/src/hd-app-menu-tree.c
Log:

2007-07-09  Johan Bilien  <johan.bilien at nokia.com>

	* src/hd-app-menu-tree.c: Added drag-begin applet
	to set the drag icon as specified



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-07-09 10:13:10 UTC (rev 12691)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-07-09 11:23:49 UTC (rev 12692)
@@ -1,5 +1,10 @@
 2007-07-09  Johan Bilien  <johan.bilien at nokia.com>
 
+	* src/hd-app-menu-tree.c: Added drag-begin applet
+	to set the drag icon as specified
+
+2007-07-09  Johan Bilien  <johan.bilien at nokia.com>
+
 	* data/applications-menu.desktop.in: added Icon:
 	* data/Makefile.am: do not install others-button.desktop
 

Modified: projects/haf/trunk/hildon-desktop/src/hd-app-menu-tree.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-app-menu-tree.c	2007-07-09 10:13:10 UTC (rev 12691)
+++ projects/haf/trunk/hildon-desktop/src/hd-app-menu-tree.c	2007-07-09 11:23:49 UTC (rev 12692)
@@ -95,6 +95,11 @@
                                          gint                    y,
                                          guint                   time);
 
+static void
+hd_app_menu_tree_drag_begin (HDAppMenuTree     *tree,
+                             GdkDragContext    *context,
+                             GtkWidget         *widget);
+
 struct _HDAppMenuTreePrivate
 {
   GtkTreeModel         *model, *navigation_model, *content_model;
@@ -225,6 +230,10 @@
                             G_CALLBACK (hd_app_menu_tree_navigation_drag_received),
                             object);
 
+  g_signal_connect_swapped (priv->navigation_pane, "drag-begin",
+                            G_CALLBACK (hd_app_menu_tree_drag_begin),
+                            object);
+
   g_signal_connect_swapped (priv->navigation_pane, "cursor-changed",
                             G_CALLBACK (hd_app_menu_tree_navigation_changed),
                             object);
@@ -280,6 +289,10 @@
                             G_CALLBACK (hd_app_menu_tree_content_drag_motion),
                             object);
 
+  g_signal_connect_swapped (priv->content_pane, "drag-begin",
+                            G_CALLBACK (hd_app_menu_tree_drag_begin),
+                            object);
+
   g_signal_connect_swapped (priv->content_pane, "cursor-changed",
                             G_CALLBACK (hd_app_menu_tree_content_changed),
                             object);
@@ -453,6 +466,51 @@
 }
 
 static void
+hd_app_menu_tree_drag_begin (HDAppMenuTree     *tree,
+                             GdkDragContext    *context,
+                             GtkWidget         *widget)
+{
+  HDAppMenuTreePrivate *priv = tree->priv;
+  GtkTreeIter           iter;
+  GdkPixbuf            *icon = NULL;
+
+  GTK_WIDGET_GET_CLASS (widget)->drag_begin (widget, context);
+
+  if (widget == priv->content_pane)
+  {
+    if (!gtk_tree_selection_get_selected (priv->content_selection,
+                                          NULL,
+                                          &iter))
+      return;
+
+    gtk_tree_model_get (priv->content_model, &iter,
+                        TREE_MODEL_ICON, &icon,
+                        -1);
+  }
+  else if (widget == priv->navigation_pane)
+  {
+    if (!gtk_tree_selection_get_selected (priv->navigation_selection,
+                                          NULL,
+                                          &iter))
+      return;
+
+    gtk_tree_model_get (priv->navigation_model, &iter,
+                        TREE_MODEL_ICON, &icon,
+                        -1);
+  }
+
+  if (icon)
+  {
+    gtk_drag_set_icon_pixbuf (context, icon, 0, 0);
+    g_object_unref (icon);
+  }
+
+  /* Stop the emission or gtk will use the default icon */
+  g_signal_stop_emission_by_name (widget, "drag-begin");
+
+}
+
+static void
 hd_app_menu_tree_content_drag_received (HDAppMenuTree          *tree,
                                         GdkDragContext         *context,
                                         gint                    x,


More information about the maemo-commits mailing list