~mitya57/ubuntu/precise/nautilus/desktop-window-fixes

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-tree-view-drag-dest.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-16 18:53:51 UTC
  • mfrom: (1.17.16 upstream) (2.2.10 experimental)
  • Revision ID: james.westby@ubuntu.com-20110516185351-9mpn1rya1t645ixq
Tags: 1:3.0.1.1-0ubuntu1
* Resynchronize on Debian using the GNOME3 ppa work, thanks to those who
  contributed there
* Known issues:
  - the indicator-application patch needs to be updated or dropped
    (design recommended to use a normal dialog for copies so maybe drop it)
  - the indicator-appmenu export patch needs to be updated
  - desktop icons are not displayed by default in GNOME3, you can set
    org.gnome.desktop.background show-desktop-icons to true in dconf-editor
    or using the gsettings command to get those back 
* New upstream version
* Remaining diffs:
* debian/changelog, debian/rules: set epoch number (which was added by error)
* debian/control.in:
  - Build-Depend on liblaunchpad-integration-dev, libappindicator-dev
  - Don't recommends desktop-base, don't suggests tracker
* debian/mount-archive.desktop:
* debian/mount-archive.desktop.in:
  - New nautilus context menu item to allow mounting zip, iso, etc
* debian/nautilus.gschema.override:
  - Change the default desktop icon configuration
* debian/nautilus-data.install:
  - Install Apport hook
* debian/nautilus.install:
  - Install mount-archive menu
* nautilus-desktop.desktop
* debian/source_nautilus.py:
  - Apport hook to list versions of files in /usr/lib/nautilus and reassign
    the crashes when there are not due to nautilus code directly
* debian/patches/00_do_not_require_unpackage_libexif.patch:
  - dropped, not required in Ubuntu since libexif is recent enough
* debian/patches/01_lpi.patch:
  - Launchpad changes.
* debian/patches/02_additional_marge_for_unity.patch:
  - ensure we don't move desktop icons when locking or unlocking the unity
    launcher 
* debian/patches/03_translations_list_update.patch:
  - Translate the mount-archive menu entry
* debian/patches/04_suppress_umount_in_ltsp.patch:
  - Don't list unmount and eject actions on LTSP clients
* debian/patches/05_desktop_menu_export.patch:
  - export the desktop menus for appmenu (lp #624274), commented for now
* debian/patches/06_never_exec_nonexec_launchers.patch:
  - Implement non-exec policy for .desktop handler.
* debian/patches/07_use_application_indicator.patch:
  - Use the application-indicator, needs to be updated
* debian/patches/08_fix_nautilus_desktop_autostart.patch
  - git commit, remove obsolete autostart code so that Nautilus windows
    can still be opened when desktop icons are shown
* debian/patches/09_no-initial-fade.patch:
  - Patch to disable the initial fade-in of the background without disabling 
    crossfades when the background is changed.
* debian/watch:
  - Watch unstable series
* Dropped:
* debian/patches/02_dont_set_default.patch:
  - deprecated in the new version
* debian/patches/03_menu_entry.patch:
  - no menu simplication needed with unity or gnome-shell
* debian/patches/17_disable_locked_automounting.patch:
  - the change is in the new upstream version
* debian/patches/82_gnome-app-install.patch:
  - don't use gnome-app-install it's deprecated
* debian/patches/90_git_audio_preview_url.patch:
  - the change is in the new version
* debian/patches/91_correct_rgba_use.patch:
  - the gtk rgba ubuntu specific work never landed no need to keep that one
* debian/patches/97_keyboard_nav_in_sidebar.patch:
  - the change is in the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 */
30
30
 
31
31
#include <config.h>
 
32
 
32
33
#include "nautilus-tree-view-drag-dest.h"
33
34
 
34
 
#include <eel/eel-gtk-macros.h>
35
 
#include <gtk/gtk.h>
36
35
#include "nautilus-file-dnd.h"
37
36
#include "nautilus-file-changes-queue.h"
38
37
#include "nautilus-icon-dnd.h"
39
38
#include "nautilus-link.h"
40
39
#include "nautilus-marshal.h"
41
 
#include "nautilus-debug-log.h"
 
40
 
 
41
#include <eel/eel-gtk-macros.h>
 
42
#include <gtk/gtk.h>
 
43
 
42
44
#include <stdio.h>
43
45
#include <string.h>
44
46
 
 
47
#define DEBUG_FLAG NAUTILUS_DEBUG_LIST_VIEW
 
48
#include "nautilus-debug.h"
 
49
 
45
50
#define AUTO_SCROLL_MARGIN 20
46
51
 
47
52
#define HOVER_EXPAND_TIMEOUT 1
88
93
        /* prefer "_NETSCAPE_URL" over "text/uri-list" to satisfy web browsers. */
89
94
        { NAUTILUS_ICON_DND_NETSCAPE_URL_TYPE, 0, NAUTILUS_ICON_DND_NETSCAPE_URL },
90
95
        { NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
91
 
        { NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD },
92
96
        { NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, 0, NAUTILUS_ICON_DND_XDNDDIRECTSAVE }, /* XDS Protocol Type */
93
97
        { NAUTILUS_ICON_DND_RAW_TYPE, 0, NAUTILUS_ICON_DND_RAW }
94
98
};
105
109
        float value;
106
110
        
107
111
        window = gtk_tree_view_get_bin_window (tree_view);
108
 
        vadjustment = gtk_tree_view_get_vadjustment (tree_view);
 
112
        vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
109
113
        
110
114
        gdk_window_get_pointer (window, NULL, &y, NULL);
111
115
        
173
177
}
174
178
 
175
179
static gboolean
176
 
highlight_expose (GtkWidget *widget,
177
 
                  GdkEventExpose *event,
178
 
                  gpointer data)
 
180
highlight_draw (GtkWidget *widget,
 
181
                cairo_t   *cr,
 
182
                gpointer data)
179
183
{
180
184
        GdkWindow *bin_window;
181
185
        int width;
182
186
        int height;
183
 
 
184
 
        if (gtk_widget_is_drawable (widget)) {
185
 
                bin_window = 
186
 
                        gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
187
 
                
188
 
                gdk_drawable_get_size (bin_window, &width, &height);
189
 
                
190
 
                gtk_paint_focus (gtk_widget_get_style (widget),
191
 
                                 bin_window,
192
 
                                 gtk_widget_get_state (widget),
193
 
                                 NULL,
194
 
                                 widget,
195
 
                                 "treeview-drop-indicator",
196
 
                                 0, 0, width, height);
197
 
        }
198
 
        
 
187
        GtkStyleContext *style;
 
188
 
 
189
        /* FIXMEchpe: is bin window right here??? */
 
190
        bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
 
191
 
 
192
        width = gdk_window_get_width (bin_window);
 
193
        height = gdk_window_get_height (bin_window);
 
194
 
 
195
        style = gtk_widget_get_style_context (widget);
 
196
 
 
197
        gtk_style_context_save (style);
 
198
        gtk_style_context_add_class (style, "treeview-drop-indicator");
 
199
 
 
200
        gtk_render_focus (style,
 
201
                          cr,
 
202
                          0, 0, width, height);
 
203
 
 
204
        gtk_style_context_restore (style);
 
205
 
199
206
        return FALSE;
200
207
}
201
208
 
212
219
        if (highlight && !dest->details->highlight_id) {
213
220
                dest->details->highlight_id = 
214
221
                        g_signal_connect_object (dest->details->tree_view,
215
 
                                                 "expose_event",
216
 
                                                 G_CALLBACK (highlight_expose),
 
222
                                                 "draw",
 
223
                                                 G_CALLBACK (highlight_draw),
217
224
                                                 dest, 0);
218
225
                gtk_widget_queue_draw (GTK_WIDGET (dest->details->tree_view));
219
226
        }
437
444
        case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
438
445
                return GDK_ACTION_COPY;
439
446
 
440
 
        case NAUTILUS_ICON_DND_KEYWORD:
441
 
 
442
 
                if (!path) {
443
 
                        return 0;
444
 
                }
445
 
 
446
 
                return GDK_ACTION_COPY;
447
447
        }
448
448
 
449
449
        return 0;
751
751
        g_free (drop_target);
752
752
}
753
753
 
754
 
static void
755
 
receive_dropped_keyword (NautilusTreeViewDragDest *dest,
756
 
                         GdkDragContext *context,
757
 
                         int x, int y)
758
 
{
759
 
        char *drop_target_uri;
760
 
        NautilusFile *drop_target_file;
761
 
 
762
 
        if (!dest->details->drag_data) {
763
 
                return;
764
 
        }
765
 
 
766
 
        drop_target_uri = get_drop_target_uri_at_pos (dest, x, y);
767
 
        g_assert (drop_target_uri != NULL);
768
 
 
769
 
        drop_target_file = nautilus_file_get_by_uri (drop_target_uri);
770
 
 
771
 
        if (drop_target_file != NULL) {
772
 
                nautilus_drag_file_receive_dropped_keyword (drop_target_file,
773
 
                                                            (char *) gtk_selection_data_get_data (dest->details->drag_data));
774
 
                nautilus_file_unref (drop_target_file);
775
 
        }
776
 
 
777
 
        g_free (drop_target_uri);
778
 
}
779
 
 
780
754
static gboolean
781
755
receive_xds (NautilusTreeViewDragDest *dest,
782
756
             GtkWidget *widget,
870
844
                        receive_dropped_raw (dest, tmp, length, context, x, y);
871
845
                        success = TRUE;
872
846
                        break;
873
 
                case NAUTILUS_ICON_DND_KEYWORD:
874
 
                        receive_dropped_keyword (dest, context, x, y);
875
 
                        success = TRUE;
876
 
                        break;
877
847
                case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
878
848
                        finished = receive_xds (dest, widget, time, context, x, y);
879
849
                        success = TRUE;
914
884
        /* Verify that the file name provided by the source is valid */
915
885
        if (*prop_text == '\0' ||
916
886
            strchr ((const gchar *) prop_text, G_DIR_SEPARATOR) != NULL) {
917
 
                nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
918
 
                                    "Invalid filename provided by XDS drag site");
 
887
                DEBUG ("Invalid filename provided by XDS drag site");
919
888
                g_free (prop_text);
920
889
                return NULL;
921
890
        }
949
918
                        g_object_unref (child);
950
919
 
951
920
                        /* Change the property */
952
 
                        gdk_property_change (GDK_DRAWABLE (gdk_drag_context_get_source_window (context)),
 
921
                        gdk_property_change (gdk_drag_context_get_source_window (context),
953
922
                                             gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE),
954
923
                                             gdk_atom_intern ("text/plain", FALSE), 8,
955
924
                                             GDK_PROP_MODE_REPLACE, (const guchar *) uri,
957
926
 
958
927
                        dest->details->direct_save_uri = uri;
959
928
                } else {
960
 
                        nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
961
 
                                            "Invalid filename provided by XDS drag site");
 
929
                        DEBUG ("Invalid filename provided by XDS drag site");
962
930
                }
963
931
        } else {
964
 
                nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
965
 
                                    "Could not retrieve XDS drop destination");
 
932
                DEBUG ("Could not retrieve XDS drop destination");
966
933
        }
967
934
 
968
935
        return uri != NULL;