Bug fix: Non-portable functions
[geeqie.git] / src / ui_bookmark.c
index 517be7b..725b278 100644 (file)
@@ -288,7 +288,7 @@ static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *parent
        g_signal_connect(G_OBJECT(gd->dialog), "destroy",
                         G_CALLBACK(bookmark_edit_destroy_cb), p);
 
-       generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL);
+       generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL, FALSE);
 
        generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
                                  bookmark_edit_ok_cb, TRUE);
@@ -450,6 +450,7 @@ static gboolean bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpoi
                {
                case GDK_KEY_F10:
                        if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
+                       /* fall through */
                case GDK_KEY_Menu:
                        bookmark_menu_popup(bm, button, 0, event->time, TRUE);
                        return TRUE;
@@ -482,6 +483,7 @@ static void bookmark_drag_set_data(GtkWidget *button,
        GList *list = NULL;
 
 #if GTK_CHECK_VERSION(3,0,0)
+       return;
        if (gdk_drag_context_get_dest_window(context) == gtk_widget_get_window(bm->widget)) return;
 #else
        if (context->dest_window == bm->widget->window) return;
@@ -492,7 +494,7 @@ static void bookmark_drag_set_data(GtkWidget *button,
 
        list = g_list_append(list, b->path);
 
-       gchar **uris = uris_from_filelist(list);
+       gchar **uris = uris_from_pathlist(list);
        gboolean ret = gtk_selection_data_set_uris(selection_data, uris);
        if (!ret)
                {
@@ -511,6 +513,10 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi
        GdkModifierType mask;
        gint x, y;
        GtkAllocation allocation;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        gtk_widget_get_allocation(button, &allocation);
 
@@ -518,20 +524,33 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi
        pixbuf = gdk_pixbuf_get_from_window(gtk_widget_get_window(button),
                                            allocation.x, allocation.y,
                                            allocation.width, allocation.height);
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(gtk_widget_get_window(button)));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_widget_get_window(button), device, &x, &y, &mask);
 #else
        pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
                                allocation.width, allocation.height);
        gdk_pixbuf_get_from_drawable(pixbuf, gtk_widget_get_window(button), NULL,
                                     allocation.x, allocation.y,
                                     0, 0, allocation.width, allocation.height);
-#endif
        gdk_window_get_pointer(gtk_widget_get_window(button), &x, &y, &mask);
+#endif
 
        gtk_drag_set_icon_pixbuf(context, pixbuf,
                                 x - allocation.x, y - allocation.y);
        g_object_unref(pixbuf);
 }
 
+static gboolean bookmark_path_tooltip_cb(GtkWidget *button, gpointer data)
+{
+       BookButtonData *b;
+
+       b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
+       gtk_widget_set_tooltip_text(GTK_WIDGET(button), b->path);
+
+       return FALSE;
+}
+
 static void bookmark_populate(BookMarkData *bm)
 {
        GtkBox *box;
@@ -682,6 +701,9 @@ static void bookmark_populate(BookMarkData *bm)
                                         G_CALLBACK(bookmark_drag_set_data), bm);
                        g_signal_connect(G_OBJECT(b->button), "drag_begin",
                                         G_CALLBACK(bookmark_drag_begin), bm);
+
+                       gtk_widget_set_has_tooltip(GTK_WIDGET(b->button), TRUE);
+                       g_signal_connect(G_OBJECT(b->button), "query_tooltip", G_CALLBACK(bookmark_path_tooltip_cb), bm);
                        }
 
                work = work->prev;
@@ -722,32 +744,35 @@ static void bookmark_dnd_get_data(GtkWidget *widget,
 
        if (!bm->editable) return;
 
-       uris = gtk_selection_data_get_uris(selection_data);
-       list = uri_filelist_from_uris(uris, &errors);
-       if(errors)
+       uris = gtk_selection_data_get_uris(selection_data);
+       if (uris)
                {
-               warning_dialog_dnd_uri_error(errors);
-               string_list_free(errors);
-               }
-       g_strfreev(uris);
+               list = uri_pathlist_from_uris(uris, &errors);
+               if(errors)
+                       {
+                       warning_dialog_dnd_uri_error(errors);
+                       string_list_free(errors);
+                       }
+               g_strfreev(uris);
 
-       work = list;
-       while (work)
-               {
-               gchar *path = work->data;
-               gchar *buf;
+               work = list;
+               while (work)
+                       {
+                       gchar *path = work->data;
+                       gchar *buf;
 
-               work = work->next;
+                       work = work->next;
 
-               if (bm->only_directories && !isdir(path)) continue;
-               buf = bookmark_string(filename_from_path(path), path, NULL);
-               history_list_add_to_key(bm->key, buf, 0);
-               g_free(buf);
-               }
+                       if (bm->only_directories && !isdir(path)) continue;
+                       buf = bookmark_string(filename_from_path(path), path, NULL);
+                       history_list_add_to_key(bm->key, buf, 0);
+                       g_free(buf);
+                       }
 
-       string_list_free(list);
+               string_list_free(list);
 
-       bookmark_populate_all(bm->key);
+               bookmark_populate_all(bm->key);
+               }
 }
 
 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)
@@ -779,8 +804,20 @@ GtkWidget *bookmark_list_new(const gchar *key,
        bm->only_directories = FALSE;
 
        scrolled = gtk_scrolled_window_new(NULL, NULL);
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
-                                      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+#if GTK_CHECK_VERSION(3,0,0)
+       PangoLayout *layout;
+       gint width, height;
+
+       layout = gtk_widget_create_pango_layout(GTK_WIDGET(scrolled), "reasonable width");
+       pango_layout_get_pixel_size(layout, &width, &height);
+       gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(scrolled), width);
+       g_object_unref(layout);
+
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+#else
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+#endif
 
        bm->box = gtk_vbox_new(FALSE, 0);
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);