Documentation: Use G_SOURCE_CONTINUE and G_SOURCE_REMOVE
[geeqie.git] / src / view-file / view-file.cc
index 0304603..b97ac28 100644 (file)
@@ -70,7 +70,7 @@ void vf_sort_set(ViewFile *vf, SortType type, gboolean ascend)
 
 FileData *vf_index_get_data(ViewFile *vf, gint row)
 {
-       return g_list_nth_data(vf->list, row);
+       return static_cast<FileData *>(g_list_nth_data(vf->list, row));
 }
 
 gint vf_index_by_fd(ViewFile *vf, FileData *fd)
@@ -97,7 +97,7 @@ guint vf_count(ViewFile *vf, gint64 *bytes)
                work = vf->list;
                while (work)
                        {
-                       FileData *fd = work->data;
+                       FileData *fd = (FileData *)work->data;
                        work = work->next;
 
                        b += fd->size;
@@ -115,7 +115,7 @@ GList *vf_get_list(ViewFile *vf)
        GList *work;
        for (work = vf->list; work; work = work->next)
                {
-               FileData *fd = work->data;
+               FileData *fd = (FileData *)work->data;
                list = g_list_prepend(list, file_data_ref(fd));
                }
 
@@ -130,7 +130,7 @@ GList *vf_get_list(ViewFile *vf)
 
 static gboolean vf_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gboolean ret;
 
        switch (vf->type)
@@ -151,7 +151,7 @@ static gboolean vf_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer
 
 static gboolean vf_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gboolean ret;
 
        switch (vf->type)
@@ -166,7 +166,7 @@ static gboolean vf_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer
 
 static gboolean vf_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gboolean ret;
 
        switch (vf->type)
@@ -344,9 +344,9 @@ GList *vf_selection_get_one(ViewFile *vf, FileData *fd)
 static void vf_pop_menu_edit_cb(GtkWidget *widget, gpointer data)
 {
        ViewFile *vf;
-       const gchar *key = data;
+       const gchar *key = static_cast<const gchar *>(data);
 
-       vf = submenu_item_get_data(widget);
+       vf = static_cast<ViewFile *>(submenu_item_get_data(widget));
 
        if (!vf) return;
 
@@ -355,7 +355,7 @@ static void vf_pop_menu_edit_cb(GtkWidget *widget, gpointer data)
 
 static void vf_pop_menu_view_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        switch (vf->type)
        {
@@ -366,9 +366,9 @@ static void vf_pop_menu_view_cb(GtkWidget *widget, gpointer data)
 
 static void vf_pop_menu_open_archive_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        LayoutWindow *lw_new;
-       FileData *fd;
+       FileData *fd = NULL;
        gchar *dest_dir;
 
        switch (vf->type)
@@ -396,21 +396,21 @@ static void vf_pop_menu_open_archive_cb(GtkWidget *UNUSED(widget), gpointer data
 
 static void vf_pop_menu_copy_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_util_copy(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview);
 }
 
 static void vf_pop_menu_move_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_util_move(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview);
 }
 
 static void vf_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        switch (vf->type)
        {
@@ -421,7 +421,7 @@ static void vf_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
 
 static void vf_pop_menu_delete_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        options->file_ops.safe_delete_enable = FALSE;
        file_util_delete(NULL, vf_pop_menu_file_list(vf), vf->listview);
@@ -429,7 +429,7 @@ static void vf_pop_menu_delete_cb(GtkWidget *UNUSED(widget), gpointer data)
 
 static void vf_pop_menu_move_to_trash_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        options->file_ops.safe_delete_enable = TRUE;
        file_util_delete(NULL, vf_pop_menu_file_list(vf), vf->listview);
@@ -437,28 +437,28 @@ static void vf_pop_menu_move_to_trash_cb(GtkWidget *UNUSED(widget), gpointer dat
 
 static void vf_pop_menu_copy_path_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_util_copy_path_list_to_clipboard(vf_pop_menu_file_list(vf), TRUE);
 }
 
 static void vf_pop_menu_copy_path_unquoted_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_util_copy_path_list_to_clipboard(vf_pop_menu_file_list(vf), FALSE);
 }
 
 static void vf_pop_menu_enable_grouping_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_data_disable_grouping_list(vf_pop_menu_file_list(vf), FALSE);
 }
 
 static void vf_pop_menu_duplicates_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        DupeWindow *dw;
 
        dw = dupe_window_new();
@@ -467,7 +467,7 @@ static void vf_pop_menu_duplicates_cb(GtkWidget *UNUSED(widget), gpointer data)
 
 static void vf_pop_menu_disable_grouping_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        file_data_disable_grouping_list(vf_pop_menu_file_list(vf), TRUE);
 }
@@ -479,7 +479,7 @@ static void vf_pop_menu_sort_cb(GtkWidget *widget, gpointer data)
 
        if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return;
 
-       vf = submenu_item_get_data(widget);
+       vf = static_cast<ViewFile *>(submenu_item_get_data(widget));
        if (!vf) return;
 
        type = (SortType)GPOINTER_TO_INT(data);
@@ -501,7 +501,7 @@ static void vf_pop_menu_sort_cb(GtkWidget *widget, gpointer data)
 
 static void vf_pop_menu_sort_ascend_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        if (vf->layout)
                {
@@ -515,50 +515,50 @@ static void vf_pop_menu_sort_ascend_cb(GtkWidget *UNUSED(widget), gpointer data)
 
 static void vf_pop_menu_sel_mark_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_SET);
 }
 
 static void vf_pop_menu_sel_mark_and_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_AND);
 }
 
 static void vf_pop_menu_sel_mark_or_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_OR);
 }
 
 static void vf_pop_menu_sel_mark_minus_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_MINUS);
 }
 
 static void vf_pop_menu_set_mark_sel_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_selection_to_mark(vf, vf->active_mark, STM_MODE_SET);
 }
 
 static void vf_pop_menu_res_mark_sel_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_selection_to_mark(vf, vf->active_mark, STM_MODE_RESET);
 }
 
 static void vf_pop_menu_toggle_mark_sel_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_selection_to_mark(vf, vf->active_mark, STM_MODE_TOGGLE);
 }
 
 static void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
-       FileViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data"));
+       ViewFile *vf = (ViewFile *)data;
+       FileViewType new_type = static_cast<FileViewType>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data")));
        if (!vf->layout) return;
 
        layout_views_set(vf->layout, vf->layout->options.dir_view_type, new_type);
@@ -566,7 +566,7 @@ static void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data)
 
 static void vf_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        switch (vf->type)
        {
@@ -577,7 +577,7 @@ static void vf_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
 
 static void vf_popup_destroy_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        switch (vf->type)
        {
@@ -601,7 +601,7 @@ static void vf_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
        ViewFile *vf;
        GList *selection_list;
 
-       vf = submenu_item_get_data(widget);
+       vf = static_cast<ViewFile *>(submenu_item_get_data(widget));
        selection_list = vf_selection_get_list(vf);
        pop_menu_collections(selection_list, data);
 
@@ -808,7 +808,7 @@ gboolean vf_set_fd(ViewFile *vf, FileData *dir_fd)
 
 static void vf_destroy_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        switch (vf->type)
        {
@@ -834,7 +834,7 @@ static void vf_destroy_cb(GtkWidget *widget, gpointer data)
 
 static void vf_marks_filter_toggle_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf_refresh_idle(vf);
 }
 
@@ -849,7 +849,7 @@ struct _MarksTextEntry {
 
 static void vf_marks_tooltip_cancel_cb(GenericDialog *gd, gpointer data)
 {
-       MarksTextEntry *mte = data;
+       MarksTextEntry *mte = (MarksTextEntry *)data;
 
        g_free(mte->text_entry);
        generic_dialog_close(gd);
@@ -857,7 +857,7 @@ static void vf_marks_tooltip_cancel_cb(GenericDialog *gd, gpointer data)
 
 static void vf_marks_tooltip_ok_cb(GenericDialog *gd, gpointer data)
 {
-       MarksTextEntry *mte = data;
+       MarksTextEntry *mte = (MarksTextEntry *)data;
 
        g_free(options->marks_tooltips[mte->mark_no]);
        options->marks_tooltips[mte->mark_no] = g_strdup(gtk_entry_get_text(GTK_ENTRY(mte->edit_widget)));
@@ -871,7 +871,7 @@ static void vf_marks_tooltip_ok_cb(GenericDialog *gd, gpointer data)
 void vf_marks_filter_on_icon_press(GtkEntry *UNUSED(entry), GtkEntryIconPosition UNUSED(pos),
                                                                        GdkEvent *UNUSED(event), gpointer userdata)
 {
-       MarksTextEntry *mte = userdata;
+       MarksTextEntry *mte = static_cast<MarksTextEntry *>(userdata);
 
        g_free(mte->text_entry);
        mte->text_entry = g_strdup("");
@@ -938,7 +938,7 @@ static gboolean vf_marks_tooltip_cb(GtkWidget *widget,
 
 static void vf_file_filter_save_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gchar *entry_text;
        gchar *remove_text = NULL;
        gchar *index_text = NULL;
@@ -997,14 +997,14 @@ static void vf_file_filter_save_cb(GtkWidget *UNUSED(widget), gpointer data)
 
 static void vf_file_filter_cb(GtkWidget *UNUSED(widget), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        vf_refresh(vf);
 }
 
 static gboolean vf_file_filter_press_cb(GtkWidget *widget, GdkEventButton *UNUSED(bevent), gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        vf->file_filter.last_selected = gtk_combo_box_get_active(GTK_COMBO_BOX(vf->file_filter.combo));
 
        gtk_widget_grab_focus(widget);
@@ -1055,7 +1055,7 @@ void vf_file_filter_set(ViewFile *vf, gboolean enable)
 
 static gboolean vf_file_filter_class_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gint i;
 
        gboolean state = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
@@ -1074,7 +1074,7 @@ static gboolean vf_file_filter_class_cb(GtkWidget *widget, gpointer data)
 
 static gboolean vf_file_filter_class_set_all_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        GtkWidget *parent;
        GList *children;
        GtkWidget *child;
@@ -1100,7 +1100,7 @@ static gboolean vf_file_filter_class_set_all_cb(GtkWidget *widget, gpointer data
        children = gtk_container_get_children(GTK_CONTAINER(parent));
        while (children)
                {
-               child = children->data;
+               child = static_cast<GtkWidget *>(children->data);
                if (i < FILE_FORMAT_CLASSES)
                        {
                        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(child), state);
@@ -1146,7 +1146,7 @@ static GtkWidget *class_filter_menu (ViewFile *vf)
 
 static void case_sensitive_cb(GtkWidget *widget, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        vf->file_filter.case_sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        vf_refresh(vf);
@@ -1392,7 +1392,7 @@ void vf_thumb_stop(ViewFile *vf)
 
 static void vf_thumb_common_cb(ThumbLoader *tl, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        if (vf->thumbs_filedata && vf->thumbs_loader == tl)
                {
@@ -1464,7 +1464,7 @@ static void vf_thumb_reset_all(ViewFile *vf)
 
        for (work = vf->list; work; work = work->next)
                {
-               FileData *fd = work->data;
+               FileData *fd = (FileData *)work->data;
                if (fd->thumb_pixbuf)
                        {
                        g_object_unref(fd->thumb_pixbuf);
@@ -1547,7 +1547,7 @@ static gboolean vf_star_next(ViewFile *vf)
 
 gboolean vf_stars_cb(gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        FileData *fd = vf->stars_filedata;
 
        if (fd)
@@ -1558,17 +1558,17 @@ gboolean vf_stars_cb(gpointer data)
 
                if (vf_star_next(vf))
                        {
-                       return TRUE;
+                       return G_SOURCE_CONTINUE;
                        }
                else
                        {
                        vf->stars_filedata = NULL;
                        vf->stars_id = 0;
-                       return FALSE;
+                       return G_SOURCE_REMOVE;
                        }
                }
 
-       return FALSE;
+       return G_SOURCE_REMOVE;
 }
 
 void vf_star_update(ViewFile *vf)
@@ -1602,18 +1602,18 @@ void vf_marks_set(ViewFile *vf, gboolean enable)
        vf_refresh_idle(vf);
 }
 
-void vf_star_rating_set(ViewFile *vf, gboolean enable)
-{
-       if (options->show_star_rating == enable) return;
-       options->show_star_rating = enable;
+//void vf_star_rating_set(ViewFile *vf, gboolean enable)
+//{
+       //if (options->show_star_rating == enable) return;
+       //options->show_star_rating = enable;
 
-       switch (vf->type)
-               {
-               case FILEVIEW_LIST: vflist_star_rating_set(vf, enable); break;
-               case FILEVIEW_ICON: vficon_star_rating_set(vf, enable); break;
-               }
-       vf_refresh_idle(vf);
-}
+       //switch (vf->type)
+               //{
+               //case FILEVIEW_LIST: vflist_star_rating_set(vf, enable); break;
+               //case FILEVIEW_ICON: vficon_star_rating_set(vf, enable); break;
+               //}
+       //vf_refresh_idle(vf);
+//}
 
 guint vf_marks_get_filter(ViewFile *vf)
 {
@@ -1639,26 +1639,26 @@ GRegex *vf_file_filter_get_filter(ViewFile *vf)
 
        if (!gtk_widget_get_visible(vf->file_filter.combo))
                {
-               return g_regex_new("", 0, 0, NULL);
+               return g_regex_new("", GRegexCompileFlags(0), GRegexMatchFlags(0), NULL);
                }
 
        file_filter_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vf->file_filter.combo));
 
        if (file_filter_text[0] != '\0')
                {
-               ret = g_regex_new(file_filter_text, vf->file_filter.case_sensitive ? 0 : G_REGEX_CASELESS, 0, &error);
+               ret = g_regex_new(file_filter_text, vf->file_filter.case_sensitive ? GRegexCompileFlags(0) : G_REGEX_CASELESS, GRegexMatchFlags(0), &error);
                if (error)
                        {
                        log_printf("Error: could not compile regular expression %s\n%s\n", file_filter_text, error->message);
                        g_error_free(error);
                        error = NULL;
-                       ret = g_regex_new("", 0, 0, NULL);
+                       ret = g_regex_new("", GRegexCompileFlags(0), GRegexMatchFlags(0), NULL);
                        }
                g_free(file_filter_text);
                }
        else
                {
-               ret = g_regex_new("", 0, 0, NULL);
+               ret = g_regex_new("", GRegexCompileFlags(0), GRegexMatchFlags(0), NULL);
                }
 
        return ret;
@@ -1699,11 +1699,11 @@ void vf_set_layout(ViewFile *vf, LayoutWindow *layout)
 
 static gboolean vf_refresh_idle_cb(gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        vf_refresh(vf);
        vf->refresh_idle_id = 0;
-       return FALSE;
+       return G_SOURCE_REMOVE;
 }
 
 void vf_refresh_idle_cancel(ViewFile *vf)
@@ -1735,11 +1735,11 @@ void vf_refresh_idle(ViewFile *vf)
 
 void vf_notify_cb(FileData *fd, NotifyType type, gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        gboolean refresh;
 
-       NotifyType interested = NOTIFY_CHANGE | NOTIFY_REREAD | NOTIFY_GROUPING;
-       if (vf->marks_enabled) interested |= NOTIFY_MARKS | NOTIFY_METADATA;
+       NotifyType interested = static_cast<NotifyType>(NOTIFY_CHANGE | NOTIFY_REREAD | NOTIFY_GROUPING);
+       if (vf->marks_enabled) interested = static_cast<NotifyType>(interested | NOTIFY_MARKS | NOTIFY_METADATA);
        /** @FIXME NOTIFY_METADATA should be checked by the keyword-to-mark functions and converted to NOTIFY_MARKS only if there was a change */
 
        if (!(type & interested) || vf->refresh_idle_id || !vf->dir_fd) return;
@@ -1780,7 +1780,7 @@ void vf_notify_cb(FileData *fd, NotifyType type, gpointer data)
 static gboolean vf_read_metadata_in_idle_cb(gpointer data)
 {
        FileData *fd;
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
        GList *work;
 
        vf_thumb_status(vf, vf_read_metadata_in_idle_progress(vf), _("Loading meta..."));
@@ -1789,7 +1789,7 @@ static gboolean vf_read_metadata_in_idle_cb(gpointer data)
 
        while (work)
                {
-               fd = work->data;
+               fd = static_cast<FileData *>(work->data);
 
                if (fd && !fd->metadata_in_idle_loaded)
                        {
@@ -1806,7 +1806,7 @@ static gboolean vf_read_metadata_in_idle_cb(gpointer data)
                                read_rating_data(fd);
                                }
                        fd->metadata_in_idle_loaded = TRUE;
-                       return TRUE;
+                       return G_SOURCE_CONTINUE;
                        }
                work = work->next;
                }
@@ -1814,12 +1814,12 @@ static gboolean vf_read_metadata_in_idle_cb(gpointer data)
        vf_thumb_status(vf, 0.0, NULL);
        vf->read_metadata_in_idle_id = 0;
        vf_refresh(vf);
-       return FALSE;
+       return G_SOURCE_REMOVE;
 }
 
 static void vf_read_metadata_in_idle_finished_cb(gpointer data)
 {
-       ViewFile *vf = data;
+       ViewFile *vf = (ViewFile *)data;
 
        vf_thumb_status(vf, 0.0, "Loading meta...");
        vf->read_metadata_in_idle_id = 0;