Bug fix: Minor coding error in bar_rating.c
[geeqie.git] / src / view_dir_list.c
index caa6680..3721127 100644 (file)
@@ -149,6 +149,13 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
        FileData *fd;
        SortType sort_type = SORT_NAME;
        gboolean sort_ascend = TRUE;
+       gchar *link = NULL;
+
+       if (vd->layout)
+               {
+               sort_type = vd->layout->options.dir_view_list_sort.method;
+               sort_ascend = vd->layout->options.dir_view_list_sort.ascend;
+               }
 
        old_list = VDLIST(vd)->list;
 
@@ -190,7 +197,11 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
 
                if (access_file(fd->path, R_OK | X_OK) && fd->name)
                        {
-                       if (fd->name[0] == '.' && fd->name[1] == '\0')
+                       if (islink(fd->path))
+                               {
+                               pixbuf = vd->pf->link;
+                               }
+                       else if (fd->name[0] == '.' && fd->name[1] == '\0')
                                {
                                pixbuf = vd->pf->open;
                                }
@@ -237,6 +248,15 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
                                match = -1;
                                }
 
+                       if (islink(fd->path))
+                               {
+                               link = realpath(fd->path, NULL);
+                               }
+                       else
+                               {
+                               link = NULL;
+                               }
+
                        if (match < 0)
                                {
                                GtkTreeIter new;
@@ -254,6 +274,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
                                                   DIR_COLUMN_POINTER, fd,
                                                   DIR_COLUMN_ICON, pixbuf,
                                                   DIR_COLUMN_NAME, fd->name,
+                                                  DIR_COLUMN_LINK, link,
                                                   DIR_COLUMN_DATE, date,
                                                   -1);
 
@@ -268,6 +289,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
                                gtk_list_store_set(store, &iter,
                                                   DIR_COLUMN_ICON, pixbuf,
                                                   DIR_COLUMN_NAME, fd->name,
+                                                  DIR_COLUMN_LINK, link,
                                                   DIR_COLUMN_DATE, date,
                                                   -1);
 
@@ -292,6 +314,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
        vd->drop_fd = NULL;
 
        filelist_free(old_list);
+       g_free(link);
        return ret;
 }
 
@@ -320,31 +343,22 @@ gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
 
        ret = vdlist_populate(vd, TRUE);
 
-       if (old_path)
-               {
-               /* scroll to make last path visible */
-               FileData *found = NULL;
-               GList *work;
-
-               work = VDLIST(vd)->list;
-               while (work && !found)
-                       {
-                       FileData *fd = work->data;
-                       if (strcmp(old_path, fd->name) == 0) found = fd;
-                       work = work->next;
-                       }
-
-               if (found) vdlist_scroll_to_row(vd, found, 0.5);
-
-               g_free(old_path);
-               return ret;
-               }
+       /* scroll to make last path visible */
+       FileData *found = NULL;
+       GList *work;
 
-       if (gtk_widget_get_realized(vd->view))
+       work = VDLIST(vd)->list;
+       while (work && !found)
                {
-               gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vd->view), 0, 0);
+               FileData *fd = work->data;
+               if (!old_path || strcmp(old_path, fd->name) == 0) found = fd;
+               work = work->next;
                }
 
+       if (found) vdlist_scroll_to_row(vd, found, 0.5);
+
+       if (old_path) g_free(old_path);
+
        return ret;
 }
 
@@ -406,16 +420,19 @@ gboolean vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer dat
                }
 
        vd->click_fd = fd;
-       vd_color_set(vd, vd->click_fd, TRUE);
+
+       if (options->view_dir_list_single_click_enter)
+               vd_color_set(vd, vd->click_fd, TRUE);
 
        if (bevent->button == MOUSE_BUTTON_RIGHT)
                {
                vd->popup = vd_pop_menu(vd, vd->click_fd);
                gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
                               bevent->button, bevent->time);
+               return TRUE;
                }
 
-       return TRUE;
+       return options->view_dir_list_single_click_enter;
 }
 
 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
@@ -439,7 +456,7 @@ ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
 
        vd->type = DIRVIEW_LIST;
 
-       store = gtk_list_store_new(5, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
+       store = gtk_list_store_new(6, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
        vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
        g_object_unref(store);
 
@@ -469,6 +486,8 @@ ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
 
        gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
 
+       gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(vd->view), DIR_COLUMN_LINK);
+
        return vd;
 }
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */