Ref #761: Severe stall/hang at start-up
[geeqie.git] / src / view_file / view_file.c
index bb5eda2..e07670a 100644 (file)
@@ -485,23 +485,6 @@ static void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data)
        layout_views_set(vf->layout, vf->layout->options.dir_view_type, new_type);
 }
 
-static void vf_pop_menu_toggle_star_rating(ViewFile *vf)
-{
-       GtkAllocation allocation;
-
-       options->show_star_rating = !options->show_star_rating;
-
-       gtk_widget_get_allocation(vf->listview, &allocation);
-       vf_star_rating_set(vf, options->show_star_rating);
-}
-
-static void vf_pop_menu_show_star_rating_cb(GtkWidget *widget, gpointer data)
-{
-       ViewFile *vf = data;
-
-       vf_pop_menu_toggle_star_rating(vf);
-}
-
 static void vf_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
 {
        ViewFile *vf = data;
@@ -1060,6 +1043,14 @@ static GtkWidget *class_filter_menu (ViewFile *vf)
        return menu;
 }
 
+static void case_sensitive_cb(GtkWidget *widget, gpointer data)
+{
+       ViewFile *vf = data;
+
+       vf->file_filter.case_sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+       vf_refresh(vf);
+}
+
 static GtkWidget *vf_file_filter_init(ViewFile *vf)
 {
        GtkWidget *frame = gtk_frame_new(NULL);
@@ -1069,6 +1060,7 @@ static GtkWidget *vf_file_filter_init(ViewFile *vf)
        GtkWidget *combo_entry;
        GtkWidget *menubar;
        GtkWidget *menuitem;
+       GtkWidget *case_sensitive;
 
        vf->file_filter.combo = gtk_combo_box_text_new_with_entry();
        combo_entry = gtk_bin_get_child(GTK_BIN(vf->file_filter.combo));
@@ -1100,6 +1092,12 @@ static GtkWidget *vf_file_filter_init(ViewFile *vf)
        gtk_container_add(GTK_CONTAINER(frame), hbox);
        gtk_widget_show(hbox);
 
+       case_sensitive = gtk_check_button_new_with_label("Case");
+       gtk_box_pack_start(GTK_BOX(hbox), case_sensitive, FALSE, FALSE, 0);
+       gtk_widget_set_tooltip_text(GTK_WIDGET(case_sensitive), _("Case sensitive"));
+       g_signal_connect(G_OBJECT(case_sensitive), "clicked", G_CALLBACK(case_sensitive_cb), vf);
+       gtk_widget_show(case_sensitive);
+
        menubar = gtk_menu_bar_new();
        gtk_box_pack_start(GTK_BOX(hbox), menubar, FALSE, TRUE, 0);
        gtk_widget_show(menubar);
@@ -1369,6 +1367,97 @@ void vf_thumb_update(ViewFile *vf)
        while (vf_thumb_next(vf));
 }
 
+void vf_star_cleanup(ViewFile *vf)
+{
+       if (vf->stars_id != 0)
+               {
+               g_source_remove(vf->stars_id);
+               }
+
+       vf->stars_id = 0;
+       vf->stars_filedata = NULL;
+}
+
+void vf_star_stop(ViewFile *vf)
+{
+        vf_star_cleanup(vf);
+}
+
+static void vf_set_star_fd(ViewFile *vf, FileData *fd)
+{
+       switch (vf->type)
+               {
+               case FILEVIEW_LIST: vflist_set_star_fd(vf, fd); break;
+               case FILEVIEW_ICON: vficon_set_star_fd(vf, fd); break;
+               default: break;
+               }
+}
+
+static void vf_star_do(ViewFile *vf, FileData *fd)
+{
+       if (!fd) return;
+
+       vf_set_star_fd(vf, fd);
+}
+
+static gboolean vf_star_next(ViewFile *vf)
+{
+       FileData *fd = NULL;
+
+       switch (vf->type)
+               {
+               case FILEVIEW_LIST: fd = vflist_star_next_fd(vf); break;
+               case FILEVIEW_ICON: fd = vficon_star_next_fd(vf); break;
+               default: break;
+               }
+
+       if (!fd)
+               {
+               /* done */
+               vf_star_cleanup(vf);
+               return FALSE;
+               }
+
+       return TRUE;
+}
+
+gboolean vf_stars_cb(gpointer data)
+{
+       ViewFile *vf = data;
+       FileData *fd = vf->stars_filedata;
+
+       if (fd)
+               {
+               read_rating_data(fd);
+
+               vf_star_do(vf, fd);
+
+               if (vf_star_next(vf))
+                       {
+                       return TRUE;
+                       }
+               else
+                       {
+                       vf->stars_filedata = NULL;
+                       vf->stars_id = 0;
+                       return FALSE;
+                       }
+               }
+
+       return FALSE;
+}
+
+void vf_star_update(ViewFile *vf)
+{
+       vf_star_stop(vf);
+
+       if (!options->show_star_rating)
+               {
+               return;
+               }
+
+       vf_star_next(vf);
+}
 
 void vf_marks_set(ViewFile *vf, gboolean enable)
 {
@@ -1433,7 +1522,7 @@ GRegex *vf_file_filter_get_filter(ViewFile *vf)
 
        if (file_filter_text[0] != '\0')
                {
-               ret = g_regex_new(file_filter_text, 0, 0, &error);
+               ret = g_regex_new(file_filter_text, vf->file_filter.case_sensitive ? 0 : G_REGEX_CASELESS, 0, &error);
                if (error)
                        {
                        log_printf("Error: could not compile regular expression %s\n%s\n", file_filter_text, error->message);
@@ -1568,7 +1657,6 @@ static gboolean vf_read_metadata_in_idle_cb(gpointer data)
 {
        FileData *fd;
        ViewFile *vf = data;
-       GList *list_entry;
        GList *work;
 
        vf_thumb_status(vf, vf_read_metadata_in_idle_progress(vf), _("Loading meta..."));
@@ -1615,9 +1703,6 @@ static void vf_read_metadata_in_idle_finished_cb(gpointer data)
 
 void vf_read_metadata_in_idle(ViewFile *vf)
 {
-       GList *work;
-       FileData *fd;
-
        if (!vf) return;
 
        if (vf->read_metadata_in_idle_id)