Fix up event source ids type: gint -> guint.
authorLaurent Monin <geeqie@norz.org>
Mon, 6 Apr 2009 22:13:54 +0000 (22:13 +0000)
committerLaurent Monin <geeqie@norz.org>
Mon, 6 Apr 2009 22:13:54 +0000 (22:13 +0000)
Functions like g_timeout_add() or g_idle_add() return a guint
greater than 0, but in most places it was wrongly stored as int
and initialized to -1.
This broke assertions matching in g_source_remove() for example
since id was always greater than 0 even when timer was not set
(-1 was casted to the biggest guint).

38 files changed:
src/bar_histogram.c
src/bar_keywords.c
src/cache-loader.c
src/cache-loader.h
src/cache_maint.c
src/collect-io.c
src/collect-table.c
src/color-man.c
src/color-man.h
src/dupe.c
src/dupe.h
src/filedata.c
src/fullscreen.c
src/histogram.c
src/image-load.c
src/image-load.h
src/image-overlay.c
src/lirc.c
src/metadata.c
src/pan-types.h
src/pan-view.c
src/pixbuf-renderer.c
src/pixbuf-renderer.h
src/print.c
src/remote.c
src/search.c
src/slideshow.c
src/thumb.c
src/thumb_standard.c
src/typedefs.h
src/ui_spinner.c
src/ui_tree_edit.c
src/utilops.c
src/view_dir.c
src/view_dir_tree.c
src/view_file.c
src/view_file_icon.c
src/view_file_list.c

index 04a001e..ebb7537 100644 (file)
@@ -43,7 +43,7 @@ struct _PaneHistogramData
        GdkPixbuf *pixbuf;
        FileData *fd;
        gboolean need_update;
-       gint idle_id;
+       guint idle_id; /* event source id */
 };
 
 static gboolean bar_pane_histogram_update_cb(gpointer data);
@@ -63,7 +63,10 @@ static void bar_pane_histogram_update(PaneHistogramData *phd)
           FIXME: this does not work for fullscreen*/
        if (GTK_WIDGET_DRAWABLE(phd->drawing_area))
                {
-               if (phd->idle_id == -1) phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL);
+               if (!phd->idle_id)
+                       {
+                       phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL);
+                       }
                }
        else
                {
@@ -76,7 +79,7 @@ static gboolean bar_pane_histogram_update_cb(gpointer data)
        const HistMap *histmap;
        PaneHistogramData *phd = data;
 
-       phd->idle_id = -1;
+       phd->idle_id = 0;
        phd->need_update = FALSE;
        
        gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height);
@@ -182,7 +185,7 @@ static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data)
 {
        PaneHistogramData *phd = data;
        
-       g_source_remove(phd->idle_id);
+       if (phd->idle_id) g_source_remove(phd->idle_id);
        file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd);
 
        file_data_unref(phd->fd);
@@ -346,7 +349,6 @@ static GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gi
        phd->pane.type = PANE_HISTOGRAM;
 
        phd->pane.expanded = expanded;
-       phd->idle_id = -1;
        
        phd->histogram = histogram_new();
 
index 7f2b40b..fcc41d4 100644 (file)
@@ -110,7 +110,7 @@ struct _PaneKeywordsData
        gboolean collapse_unchecked;
        gboolean hide_unchecked;
 
-       gint idle_id;   
+       guint idle_id; /* event source id */    
        FileData *fd;
        gchar *key;
 };
@@ -426,7 +426,7 @@ static gboolean bar_pane_keywords_changed_idle_cb(gpointer data)
        bar_pane_keywords_write(pkd);
        bar_keyword_tree_sync(pkd);
        file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
-       pkd->idle_id = -1;
+       pkd->idle_id = 0;
        return FALSE;
 }
 
@@ -434,7 +434,7 @@ static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data)
 {
        PaneKeywordsData *pkd = data;
 
-       if (pkd->idle_id != -1) return;
+       if (pkd->idle_id) return;
        /* higher prio than redraw */
        pkd->idle_id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, bar_pane_keywords_changed_idle_cb, pkd, NULL);
 }
@@ -1196,7 +1196,7 @@ static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data)
        PaneKeywordsData *pkd = data;
 
         if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
-       if (pkd->idle_id != -1) g_source_remove(pkd->idle_id);
+       if (pkd->idle_id) g_source_remove(pkd->idle_id);
        file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
 
        file_data_unref(pkd->fd);
@@ -1231,8 +1231,6 @@ static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, con
        
        pkd->expand_checked = TRUE;
        
-       pkd->idle_id = -1;
-
        hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
 
        pkd->widget = hbox;
index 3b2932b..e63e46e 100644 (file)
@@ -174,7 +174,7 @@ static gboolean cache_loader_process(CacheLoader *cl)
                        g_free(base);
                        }
 
-               cl->idle_id = -1;
+               cl->idle_id = 0;
 
                if (cl->done_func)
                        {
@@ -232,10 +232,10 @@ void cache_loader_free(CacheLoader *cl)
 {
        if (!cl) return;
 
-       if (cl->idle_id != -1)
+       if (cl->idle_id)
                {
                g_source_remove(cl->idle_id);
-               cl->idle_id = -1;
+               cl->idle_id = 0;
                }
 
        image_loader_free(cl->il);
index 6034fbf..497e745 100644 (file)
@@ -45,7 +45,7 @@ struct _CacheLoader {
        gboolean error;
 
        ImageLoader *il;
-       gint idle_id;
+       guint idle_id; /* event source id */
 };
 
 
index edb659a..bed5c91 100644 (file)
@@ -30,7 +30,7 @@ struct _CMData
 {
        GList *list;
        GList *done_list;
-       gint idle_id;
+       guint idle_id; /* event source id */
        GenericDialog *gd;
        GtkWidget *entry;
        GtkWidget *spinner;
@@ -111,7 +111,7 @@ static gboolean isempty(const gchar *path)
 
 static void cache_maintain_home_close(CMData *cm)
 {
-       if (cm->idle_id != -1) g_source_remove(cm->idle_id);
+       if (cm->idle_id) g_source_remove(cm->idle_id);
        if (cm->gd) generic_dialog_close(cm->gd);
        filelist_free(cm->list);
        g_list_free(cm->done_list);
@@ -120,10 +120,10 @@ static void cache_maintain_home_close(CMData *cm)
 
 static void cache_maintain_home_stop(CMData *cm)
 {
-       if (cm->idle_id != -1)
+       if (cm->idle_id)
                {
                g_source_remove(cm->idle_id);
-               cm->idle_id = -1;
+               cm->idle_id = 0;
                }
 
        gtk_entry_set_text(GTK_ENTRY(cm->entry), _("done"));
@@ -158,7 +158,7 @@ static gboolean cache_maintain_home_cb(gpointer data)
        if (!cm->list)
                {
                DEBUG_1("purge chk done.");
-               cm->idle_id = -1;
+               cm->idle_id = 0;
                cache_maintain_home_stop(cm);
                return FALSE;
                }
@@ -689,7 +689,7 @@ struct _CleanData
        gboolean local;
        gboolean recurse;
 
-       gint idle_id;
+       guint idle_id; /* event source id */
 };
 
 static void cache_manager_render_reset(CleanData *cd)
@@ -937,10 +937,10 @@ static void cache_manager_standard_clean_done(CleanData *cd)
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), 1.0);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("done"));
 
-       if (cd->idle_id != -1)
+       if (cd->idle_id)
                {
                g_source_remove(cd->idle_id);
-               cd->idle_id = -1;
+               cd->idle_id = 0;
                }
 
        thumb_loader_std_thumb_file_validate_cancel(cd->tl);
@@ -983,7 +983,7 @@ static gint cache_manager_standard_clean_clear_cb(gpointer data)
                return TRUE;
                }
 
-       cd->idle_id = -1;
+       cd->idle_id = 0;
        cache_manager_standard_clean_done(cd);
        return FALSE;
 }
@@ -1118,7 +1118,7 @@ static void cache_manager_standard_process(GtkWidget *widget, gboolean clear)
 
        cd->days = 30;
        cd->tl = NULL;
-       cd->idle_id = -1;
+       cd->idle_id = 0;
 
        gtk_widget_show(cd->gd->dialog);
 }
index ee6626b..9c7d11c 100644 (file)
@@ -447,7 +447,7 @@ struct _CollectManagerAction
 static GList *collection_manager_entry_list = NULL;
 static GList *collection_manager_action_list = NULL;
 static GList *collection_manager_action_tail = NULL;
-static gint collection_manager_timer_id = -1;
+static guint collection_manager_timer_id = 0; /* event source id */
 
 
 static CollectManagerAction *collect_manager_action_new(const gchar *oldpath, const gchar *newpath,
@@ -833,18 +833,18 @@ static gboolean collect_manager_timer_cb(gpointer data)
 
        g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, NULL, NULL);
 
-       collection_manager_timer_id = -1;
+       collection_manager_timer_id = 0;
        return FALSE;
 }
 
 static void collect_manager_timer_push(gint stop)
 {
-       if (collection_manager_timer_id != -1)
+       if (collection_manager_timer_id)
                {
                if (!stop) return;
 
                g_source_remove(collection_manager_timer_id);
-               collection_manager_timer_id = -1;
+               collection_manager_timer_id = 0;
                }
 
        if (!stop)
index bdb6478..621a2eb 100644 (file)
@@ -552,11 +552,11 @@ static gboolean tip_schedule_cb(gpointer data)
 {
        CollectTable *ct = data;
 
-       if (ct->tip_delay_id == -1) return FALSE;
+       if (!ct->tip_delay_id) return FALSE;
 
        tip_show(ct);
 
-       ct->tip_delay_id = -1;
+       ct->tip_delay_id = 0;
        return FALSE;
 }
 
@@ -564,10 +564,10 @@ static void tip_schedule(CollectTable *ct)
 {
        tip_hide(ct);
 
-       if (ct->tip_delay_id != -1)
+       if (ct->tip_delay_id)
                {
                g_source_remove(ct->tip_delay_id);
-               ct->tip_delay_id = -1;
+               ct->tip_delay_id = 0;
                }
 
        ct->tip_delay_id = g_timeout_add(ct->show_text ? COLLECT_TABLE_TIP_DELAY_PATH : COLLECT_TABLE_TIP_DELAY, tip_schedule_cb, ct);
@@ -577,8 +577,11 @@ static void tip_unschedule(CollectTable *ct)
 {
        tip_hide(ct);
 
-       if (ct->tip_delay_id != -1) g_source_remove(ct->tip_delay_id);
-       ct->tip_delay_id = -1;
+       if (ct->tip_delay_id)
+               {
+               g_source_remove(ct->tip_delay_id);
+               ct->tip_delay_id = 0;
+               }
 }
 
 static void tip_update(CollectTable *ct, CollectInfo *info)
@@ -1452,7 +1455,7 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
        gint x, y;
        gint w, h;
 
-       if (ct->drop_idle_id == -1) return FALSE;
+       if (!ct->drop_idle_id) return FALSE;
 
        window = ct->listview->window;
        gdk_window_get_pointer(window, &x, &y, NULL);
@@ -1462,7 +1465,7 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
                collection_table_motion_update(ct, x, y, TRUE);
                }
 
-       ct->drop_idle_id = -1;
+       ct->drop_idle_id = 0;
        return FALSE;
 }
 
@@ -1470,7 +1473,10 @@ static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x
 {
        CollectTable *ct = data;
 
-       if (ct->drop_idle_id == -1) ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct);
+       if (!ct->drop_idle_id)
+               {
+               ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct);
+               }
 
        return TRUE;
 }
@@ -1479,10 +1485,10 @@ static void collection_table_scroll(CollectTable *ct, gboolean scroll)
 {
        if (!scroll)
                {
-               if (ct->drop_idle_id != -1)
+               if (ct->drop_idle_id)
                        {
                        g_source_remove(ct->drop_idle_id);
-                       ct->drop_idle_id = -1;
+                       ct->drop_idle_id = 0;
                        }
                widget_auto_scroll_stop(ct->listview);
                collection_table_insert_marker(ct, NULL, FALSE);
@@ -1810,8 +1816,9 @@ static gboolean collection_table_sync_idle_cb(gpointer data)
 {
        CollectTable *ct = data;
 
-       if (ct->sync_idle_id == -1) return FALSE;
-       ct->sync_idle_id = -1;
+       if (!ct->sync_idle_id) return FALSE;
+       g_source_remove(ct->sync_idle_id);
+       ct->sync_idle_id = 0;
 
        collection_table_sync(ct);
        return FALSE;
@@ -1819,7 +1826,7 @@ static gboolean collection_table_sync_idle_cb(gpointer data)
 
 static void collection_table_sync_idle(CollectTable *ct)
 {
-       if (ct->sync_idle_id == -1)
+       if (!ct->sync_idle_id)
                {
                /* high priority, the view needs to be resynced before a redraw
                 * may contain invalid pointers at this time
@@ -2416,7 +2423,7 @@ static void collection_table_destroy(GtkWidget *widget, gpointer data)
                gtk_widget_destroy(ct->popup);
                }
 
-       if (ct->sync_idle_id != -1) g_source_remove(ct->sync_idle_id);
+       if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id);
 
        tip_unschedule(ct);
        collection_table_scroll(ct, FALSE);
@@ -2441,12 +2448,8 @@ CollectTable *collection_table_new(CollectionData *cd)
        ct = g_new0(CollectTable, 1);
        
        ct->cd = cd;
-       ct->tip_delay_id = -1;
        ct->show_text = options->show_icon_names;
 
-       ct->sync_idle_id = -1;
-       ct->drop_idle_id = -1;
-
        ct->scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled),
index eb3364f..54ea188 100644 (file)
@@ -326,7 +326,7 @@ static gboolean color_man_idle_cb(gpointer data)
        if (cm->imd &&
            cm->pixbuf != image_get_pixbuf(cm->imd))
                {
-               cm->idle_id = -1;
+               cm->idle_id = 0;
                color_man_done(cm, COLOR_RETURN_IMAGE_CHANGED);
                return FALSE;
                }
@@ -341,7 +341,7 @@ static gboolean color_man_idle_cb(gpointer data)
                        image_area_changed(cm->imd, 0, 0, width, height);
                        }
 
-               cm->idle_id = -1;
+               cm->idle_id = 0;
                color_man_done(cm, COLOR_RETURN_SUCCESS);
                return FALSE;
                }
@@ -369,10 +369,6 @@ static ColorMan *color_man_new_real(ImageWindow *imd, GdkPixbuf *pixbuf,
        cm->pixbuf = pixbuf;
        if (cm->pixbuf) g_object_ref(cm->pixbuf);
 
-       cm->incremental_sync = FALSE;
-       cm->row = 0;
-       cm->idle_id = -1;
-
        has_alpha = pixbuf ? gdk_pixbuf_get_has_alpha(pixbuf) : FALSE;
 
        cm->profile = color_man_cache_get(input_type, input_file, input_data, input_data_len,
@@ -415,7 +411,7 @@ void color_man_free(ColorMan *cm)
 {
        if (!cm) return;
 
-       if (cm->idle_id != -1) g_source_remove(cm->idle_id);
+       if (cm->idle_id) g_source_remove(cm->idle_id);
        if (cm->pixbuf) g_object_unref(cm->pixbuf);
 
        color_man_cache_unref(cm->profile);
index 0f35af7..5ff4be7 100644 (file)
@@ -40,7 +40,7 @@ struct _ColorMan {
 
        gpointer profile;
 
-       gint idle_id;
+       guint idle_id; /* event source id */
 
        ColorManDoneFunc func_done;
        gpointer func_done_data;
index 0fd442d..586e9c5 100644 (file)
@@ -1347,10 +1347,10 @@ static void dupe_thumb_step(DupeWindow *dw)
 
 static void dupe_check_stop(DupeWindow *dw)
 {
-       if (dw->idle_id != -1 || dw->img_loader || dw->thumb_loader)
+       if (dw->idle_id || dw->img_loader || dw->thumb_loader)
                {
                g_source_remove(dw->idle_id);
-               dw->idle_id = -1;
+               dw->idle_id = 0;
                dupe_window_update_progress(dw, NULL, 0.0, FALSE);
                widget_set_cursor(dw->listview, -1);
                }
@@ -1424,7 +1424,7 @@ static gboolean dupe_check_cb(gpointer data)
 {
        DupeWindow *dw = data;
 
-       if (dw->idle_id == -1) return FALSE;
+       if (!dw->idle_id) return FALSE;
 
        if (!dw->setup_done)
                {
@@ -1535,7 +1535,7 @@ static gboolean dupe_check_cb(gpointer data)
                                                dw->img_loader = NULL;
                                                return TRUE;
                                                }
-                                       dw->idle_id = -1;
+                                       dw->idle_id = 0;
                                        return FALSE;
                                        }
 
@@ -1559,7 +1559,7 @@ static gboolean dupe_check_cb(gpointer data)
                        dupe_window_update_progress(dw, _("Sorting..."), 1.0, TRUE);
                        return TRUE;
                        }
-               dw->idle_id = -1;
+               dw->idle_id = 0;
                dupe_window_update_progress(dw, NULL, 0.0, FALSE);
 
                dupe_match_rank(dw);
@@ -1599,7 +1599,7 @@ static void dupe_check_start(DupeWindow *dw)
        dupe_window_update_count(dw, TRUE);
        widget_set_cursor(dw->listview, GDK_WATCH);
 
-       if (dw->idle_id != -1) return;
+       if (dw->idle_id) return;
 
        dw->idle_id = g_idle_add(dupe_check_cb, dw);
 }
@@ -3116,14 +3116,7 @@ DupeWindow *dupe_window_new(DupeMatchType match_mask)
 
        dw = g_new0(DupeWindow, 1);
 
-       dw->list = NULL;
-       dw->dupes = NULL;
        dw->match_mask = match_mask;
-       dw->show_thumbs = FALSE;
-
-       dw->idle_id = -1;
-
-       dw->second_set = FALSE;
 
        dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", NULL, NULL, _("Find duplicates"));
 
index b4dad57..f52284f 100644 (file)
@@ -81,7 +81,7 @@ struct _DupeWindow
 
        gboolean show_thumbs;
 
-       gint idle_id;
+       guint idle_id; /* event source id */
        GList *working;
        gint setup_done;
        gint setup_count;
index e0ec063..8f0427d 100644 (file)
@@ -2398,7 +2398,7 @@ void file_data_send_notification(FileData *fd, NotifyType type)
 }
 
 static GHashTable *file_data_monitor_pool = NULL;
-static gint realtime_monitor_id = -1;
+static guint realtime_monitor_id = 0; /* event source id */
 
 static void realtime_monitor_check_cb(gpointer key, gpointer value, gpointer data)
 {
@@ -2432,7 +2432,7 @@ gboolean file_data_register_real_time_monitor(FileData *fd)
        count++;
        g_hash_table_insert(file_data_monitor_pool, fd, GINT_TO_POINTER(count));
        
-       if (realtime_monitor_id == -1)
+       if (!realtime_monitor_id)
                {
                realtime_monitor_id = g_timeout_add(5000, realtime_monitor_cb, NULL);
                }
@@ -2464,7 +2464,7 @@ gboolean file_data_unregister_real_time_monitor(FileData *fd)
        if (g_hash_table_size(file_data_monitor_pool) == 0)
                {
                g_source_remove(realtime_monitor_id);
-               realtime_monitor_id = -1;
+               realtime_monitor_id = 0;
                return FALSE;
                }
        
index daaa5de..2782c40 100644 (file)
@@ -74,21 +74,22 @@ static gboolean fullscreen_hide_mouse_cb(gpointer data)
 {
        FullScreenData *fs = data;
 
-       if (fs->hide_mouse_id == -1) return FALSE;
+       if (!fs->hide_mouse_id) return FALSE;
 
        fs->cursor_state &= ~FULLSCREEN_CURSOR_NORMAL;
        if (!(fs->cursor_state & FULLSCREEN_CURSOR_BUSY)) clear_mouse_cursor(fs->window, fs->cursor_state);
 
-       fs->hide_mouse_id = -1;
+       g_source_remove(fs->hide_mouse_id);
+       fs->hide_mouse_id = 0;
        return FALSE;
 }
 
 static void fullscreen_hide_mouse_disable(FullScreenData *fs)
 {
-       if (fs->hide_mouse_id != -1)
+       if (fs->hide_mouse_id)
                {
                g_source_remove(fs->hide_mouse_id);
-               fs->hide_mouse_id = -1;
+               fs->hide_mouse_id = 0;
                }
 }
 
@@ -114,10 +115,10 @@ static gboolean fullscreen_mouse_moved(GtkWidget *widget, GdkEventButton *bevent
 
 static void fullscreen_busy_mouse_disable(FullScreenData *fs)
 {
-       if (fs->busy_mouse_id != -1)
+       if (fs->busy_mouse_id)
                {
                g_source_remove(fs->busy_mouse_id);
-               fs->busy_mouse_id = -1;
+               fs->busy_mouse_id = 0;
                }
 }
 
@@ -143,14 +144,14 @@ static gboolean fullscreen_mouse_set_busy_cb(gpointer data)
 {
        FullScreenData *fs = data;
 
-       fs->busy_mouse_id = -1;
+       fs->busy_mouse_id = 0;
        fullscreen_mouse_set_busy(fs, TRUE);
        return FALSE;
 }
 
 static void fullscreen_mouse_set_busy_idle(FullScreenData *fs)
 {
-       if (fs->busy_mouse_id == -1)
+       if (!fs->busy_mouse_id)
                {
                fs->busy_mouse_id = g_timeout_add(FULL_SCREEN_BUSY_MOUSE_DELAY,
                                                  fullscreen_mouse_set_busy_cb, fs);
@@ -227,8 +228,6 @@ FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd,
 
        fs = g_new0(FullScreenData, 1);
 
-       fs->hide_mouse_id = -1;
-       fs->busy_mouse_id = -1;
        fs->cursor_state = FULLSCREEN_CURSOR_HIDDEN;
 
        fs->normal_window = window;
@@ -335,7 +334,7 @@ void fullscreen_stop(FullScreenData *fs)
 {
        if (!fs) return;
 
-       g_source_remove(fs->saver_block_id);
+       if (fs->saver_block_id) g_source_remove(fs->saver_block_id);
 
        fullscreen_hide_mouse_disable(fs);
        fullscreen_busy_mouse_disable(fs);
index ac7d8e8..f1d6ad3 100644 (file)
@@ -32,7 +32,7 @@ struct _HistMap {
        gulong b[HISTMAP_SIZE];
        gulong max[HISTMAP_SIZE];
        
-       gint idle_id;
+       guint idle_id; /* event source id */
        GdkPixbuf *pixbuf;
        gint y;
 };
@@ -131,14 +131,13 @@ const gchar *histogram_label(Histogram *histogram)
 static HistMap *histmap_new(void)
 {
        HistMap *histmap = g_new0(HistMap, 1);
-       histmap->idle_id = -1;
        return histmap;
 }
 
 void histmap_free(HistMap *histmap)
 {
        if (!histmap) return;
-       if (histmap->idle_id != -1) g_source_remove(histmap->idle_id);
+       if (histmap->idle_id) g_source_remove(histmap->idle_id);
        if (histmap->pixbuf) g_object_unref(histmap->pixbuf);
        g_free(histmap);
 }
@@ -190,7 +189,7 @@ static gboolean histmap_read(HistMap *histmap, gboolean whole)
 
 const HistMap *histmap_get(FileData *fd)
 {
-       if (fd->histmap && fd->histmap->idle_id == -1) return fd->histmap; /* histmap exists and is finished */
+       if (fd->histmap && !fd->histmap->idle_id) return fd->histmap; /* histmap exists and is finished */
        
        return NULL;
 }
@@ -203,7 +202,7 @@ static gboolean histmap_idle_cb(gpointer data)
                /* finished */
                g_object_unref(fd->histmap->pixbuf); /*pixbuf is no longer needed */
                fd->histmap->pixbuf = NULL;
-               fd->histmap->idle_id = -1;
+               fd->histmap->idle_id = 0;
                file_data_send_notification(fd, NOTIFY_HISTMAP);
                return FALSE;
                }
index f29e275..87f8abe 100644 (file)
@@ -72,7 +72,7 @@ static void image_loader_init(GTypeInstance *instance, gpointer g_class)
        ImageLoader *il = (ImageLoader *)instance;
 
        il->pixbuf = NULL;
-       il->idle_id = -1;
+       il->idle_id = 0;
        il->idle_priority = G_PRIORITY_DEFAULT_IDLE;
        il->done = FALSE;
        il->loader = NULL;
@@ -80,7 +80,7 @@ static void image_loader_init(GTypeInstance *instance, gpointer g_class)
        il->bytes_read = 0;
        il->bytes_total = 0;
 
-       il->idle_done_id = -1;
+       il->idle_done_id = 0;
 
        il->idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT;
        il->read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
@@ -162,7 +162,11 @@ static void image_loader_finalize(GObject *object)
 
        DEBUG_1("freeing image loader %p bytes_read=%d", il, il->bytes_read);
 
-       if (il->idle_done_id != -1) g_source_remove(il->idle_done_id);
+       if (il->idle_done_id)
+               {
+               g_source_remove(il->idle_done_id);
+               il->idle_done_id = 0;
+               }
 
        while (g_source_remove_by_user_data(il)) 
                {
@@ -683,10 +687,10 @@ static void image_loader_stop(ImageLoader *il)
 {
        if (!il) return;
 
-       if (il->idle_id != -1)
+       if (il->idle_id)
                {
                g_source_remove(il->idle_id);
-               il->idle_id = -1;
+               il->idle_id = 0;
                }
                
        if (il->thread)
@@ -743,7 +747,7 @@ static gboolean image_loader_idle_cb(gpointer data)
        gboolean ret = FALSE;
        ImageLoader *il = data;
 
-       if (il->idle_id != -1)
+       if (il->idle_id)
                {
                ret = image_loader_continue(il);
                }
index fd04b74..e9efa3a 100644 (file)
@@ -38,13 +38,13 @@ struct _ImageLoader
        gboolean shrunk;
 
        gboolean done;
-       gint idle_id;
+       guint idle_id; /* event source id */
        gint idle_priority;
 
        GdkPixbufLoader *loader;
        GError *error;
 
-       gint idle_done_id;
+       guint idle_done_id; /* event source id */
        GList *area_param_list;
        GList *area_param_delayed_list;
        
index 06eafce..c401c83 100644 (file)
@@ -51,8 +51,8 @@ struct _OverlayStateData {
        gint icon_time[IMAGE_OSD_COUNT];
        gint icon_id[IMAGE_OSD_COUNT];
 
-       gint idle_id;
-       gint timer_id;
+       guint idle_id; /* event source id */
+       guint timer_id; /* event source id */
        gulong destroy_id;
 };
 
@@ -890,7 +890,7 @@ static gboolean image_osd_update_cb(gpointer data)
 
        osd->changed_states = IMAGE_STATE_NONE;
        osd->notify = 0;
-       osd->idle_id = -1;
+       osd->idle_id = 0;
        return FALSE;
 }
 
@@ -898,7 +898,7 @@ static void image_osd_update_schedule(OverlayStateData *osd, gboolean force)
 {
        if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
 
-       if (osd->idle_id == -1)
+       if (!osd->idle_id)
                {
                osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
                }
@@ -941,7 +941,7 @@ static gboolean image_osd_timer_cb(gpointer data)
 
        if (done)
                {
-               osd->timer_id = -1;
+               osd->timer_id = 0;
                return FALSE;
                }
 
@@ -950,7 +950,7 @@ static gboolean image_osd_timer_cb(gpointer data)
 
 static void image_osd_timer_schedule(OverlayStateData *osd)
 {
-       if (osd->timer_id == -1)
+       if (!osd->timer_id)
                {
                osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
                }
@@ -981,8 +981,8 @@ static void image_osd_free(OverlayStateData *osd)
 {
        if (!osd) return;
 
-       if (osd->idle_id != -1) g_source_remove(osd->idle_id);
-       if (osd->timer_id != -1) g_source_remove(osd->timer_id);
+       if (osd->idle_id) g_source_remove(osd->idle_id);
+       if (osd->timer_id) g_source_remove(osd->timer_id);
 
        file_data_unregister_notify_func(image_osd_notify_cb, osd);
 
@@ -1025,8 +1025,6 @@ static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
                {
                osd = g_new0(OverlayStateData, 1);
                osd->imd = imd;
-               osd->idle_id = -1;
-               osd->timer_id = -1;
                osd->show = OSD_SHOW_NOTHING;
                osd->x = options->image_overlay.x;
                osd->y = options->image_overlay.y;
index 2f15ec1..40fd071 100644 (file)
@@ -16,7 +16,7 @@
 
 gint lirc_fd = -1;
 struct lirc_config *config = NULL;
-guint input_tag;
+guint input_tag = 0; /* event source id */
 GIOChannel *gio_chan;
 
 /*
index 02439b2..5552371 100644 (file)
@@ -47,7 +47,7 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except);
  */
 
 static GList *metadata_write_queue = NULL;
-static gint metadata_write_idle_id = -1;
+static guint metadata_write_idle_id = 0; /* event source id */
 
 static void metadata_write_queue_add(FileData *fd)
 {
@@ -59,10 +59,10 @@ static void metadata_write_queue_add(FileData *fd)
                layout_status_update_write_all();
                }
 
-       if (metadata_write_idle_id != -1
+       if (metadata_write_idle_id) 
                {
                g_source_remove(metadata_write_idle_id);
-               metadata_write_idle_id = -1;
+               metadata_write_idle_id = 0;
                }
        
        if (options->metadata.confirm_after_timeout)
@@ -130,7 +130,7 @@ gboolean metadata_write_queue_confirm(FileUtilDoneFunc done_func, gpointer done_
 static gboolean metadata_write_queue_idle_cb(gpointer data)
 {
        metadata_write_queue_confirm(NULL, NULL);
-       metadata_write_idle_id = -1;
+       metadata_write_idle_id = 0;
        return FALSE;
 }
 
index 8c78622..2cf6097 100644 (file)
@@ -192,8 +192,6 @@ struct _PanWindow
        GtkWidget *scrollbar_h;
        GtkWidget *scrollbar_v;
 
-       gint overlay_id;
-
        FileData *dir_fd;
        PanLayoutType layout;
        PanImageSize size;
index 7cf4531..f1b37b3 100644 (file)
@@ -1107,7 +1107,7 @@ static gint pan_layout_update_idle_cb(gpointer data)
 
                        if (pan_cache_step(pw)) return TRUE;
 
-                       pw->idle_id = -1;
+                       pw->idle_id = 0;
                        return FALSE;
                        }
                }
@@ -1142,13 +1142,13 @@ static gint pan_layout_update_idle_cb(gpointer data)
 
        pan_window_message(pw, NULL);
 
-       pw->idle_id = -1;
+       pw->idle_id = 0;
        return FALSE;
 }
 
 static void pan_layout_update_idle(PanWindow *pw)
 {
-       if (pw->idle_id == -1)
+       if (!pw->idle_id)
                {
                pw->idle_id = g_idle_add(pan_layout_update_idle_cb, pw);
                }
@@ -2301,7 +2301,7 @@ static void pan_window_close(PanWindow *pw)
        pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_IMAGE, pw->info_image_size);
        pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_EXIF, pw->info_includes_exif);
 
-       if (pw->idle_id != -1)
+       if (pw->idle_id)
                {
                g_source_remove(pw->idle_id);
                }
@@ -2359,8 +2359,7 @@ static void pan_window_new_real(FileData *dir_fd)
 
        pw->ignore_symlinks = TRUE;
 
-       pw->overlay_id = -1;
-       pw->idle_id = -1;
+       pw->idle_id = 0;
 
        pw->window = window_new(GTK_WINDOW_TOPLEVEL, "panview", NULL, NULL, _("Pan View"));
 
index ccc454f..5561a4e 100644 (file)
@@ -508,7 +508,7 @@ static void pixbuf_renderer_init(PixbufRenderer *pr)
 
        pr->scroll_reset = PR_SCROLL_RESET_TOPLEFT;
 
-       pr->draw_idle_id = -1;
+       pr->draw_idle_id = 0;
 
        pr->tile_width = PR_TILE_SIZE;
        pr->tile_height = PR_TILE_SIZE;
@@ -518,7 +518,7 @@ static void pixbuf_renderer_init(PixbufRenderer *pr)
 
        pr->tile_cache_max = PR_CACHE_SIZE_DEFAULT;
 
-       pr->scroller_id = -1;
+       pr->scroller_id = 0;
        pr->scroller_overlay = -1;
        
        pr->x_mouse = -1;
@@ -1266,10 +1266,10 @@ static gboolean pr_scroller_update_cb(gpointer data)
 
 static void pr_scroller_timer_set(PixbufRenderer *pr, gboolean start)
 {
-       if (pr->scroller_id != -1)
+       if (pr->scroller_id)
                {
                g_source_remove(pr->scroller_id);
-               pr->scroller_id = -1;
+               pr->scroller_id = 0;
                }
 
        if (start)
@@ -1309,7 +1309,7 @@ static void pr_scroller_start(PixbufRenderer *pr, gint x, gint y)
 
 static void pr_scroller_stop(PixbufRenderer *pr)
 {
-       if (pr->scroller_id == -1) return;
+       if (!pr->scroller_id) return;
 
        pixbuf_renderer_overlay_remove(pr, pr->scroller_overlay);
        pr->scroller_overlay = -1;
@@ -2817,11 +2817,11 @@ static gboolean pr_queue_draw_idle_cb(gpointer data)
 
        if ((!pr->pixbuf && !pr->source_tiles_enabled) ||
            (!pr->draw_queue && !pr->draw_queue_2pass) ||
-           pr->draw_idle_id == -1)
+           !pr->draw_idle_id)
                {
                pr_render_complete_signal(pr);
 
-               pr->draw_idle_id = -1;
+               pr->draw_idle_id = 0;
                return FALSE;
                }
 
@@ -2893,7 +2893,7 @@ static gboolean pr_queue_draw_idle_cb(gpointer data)
                {
                pr_render_complete_signal(pr);
 
-               pr->draw_idle_id = -1;
+               pr->draw_idle_id = 0;
                return FALSE;
                }
 
@@ -2928,8 +2928,11 @@ static void pr_queue_clear(PixbufRenderer *pr)
        pr_queue_list_free(pr->draw_queue_2pass);
        pr->draw_queue_2pass = NULL;
 
-       if (pr->draw_idle_id != -1) g_source_remove(pr->draw_idle_id);
-       pr->draw_idle_id = -1;
+       if (pr->draw_idle_id)
+               {
+               g_source_remove(pr->draw_idle_id);
+               pr->draw_idle_id = 0;
+               }
 }
 
 static void pr_queue_merge(QueueData *parent, QueueData *qd)
@@ -3087,9 +3090,13 @@ static void pr_queue(PixbufRenderer *pr, gint x, gint y, gint w, gint h,
        if (w < 1 || h < 1) return;
 
        if (pr_queue_to_tiles(pr, nx, ny, w, h, clamp, render, new_data, only_existing) &&
-           ((!pr->draw_queue && !pr->draw_queue_2pass) || pr->draw_idle_id == -1))
+           ((!pr->draw_queue && !pr->draw_queue_2pass) || !pr->draw_idle_id))
                {
-               if (pr->draw_idle_id != -1) g_source_remove(pr->draw_idle_id);
+               if (pr->draw_idle_id)
+                       {
+                       g_source_remove(pr->draw_idle_id);
+                       pr->draw_idle_id = 0;
+                       }
                pr_queue_schedule_next_draw(pr, TRUE);
                }
 }
@@ -3710,7 +3717,7 @@ static gboolean pr_mouse_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gp
 
        pr = PIXBUF_RENDERER(widget);
 
-       if (pr->scroller_id != -1)
+       if (pr->scroller_id)
                {
                pr->scroller_xpos = bevent->x;
                pr->scroller_ypos = bevent->y;
@@ -3759,7 +3766,7 @@ static gboolean pr_mouse_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpo
 
        pr = PIXBUF_RENDERER(widget);
 
-       if (pr->scroller_id != -1) return TRUE;
+       if (pr->scroller_id) return TRUE;
 
        switch (bevent->button)
                {
@@ -3798,7 +3805,7 @@ static gboolean pr_mouse_release_cb(GtkWidget *widget, GdkEventButton *bevent, g
 
        pr = PIXBUF_RENDERER(widget);
 
-       if (pr->scroller_id != -1)
+       if (pr->scroller_id)
                {
                pr_scroller_stop(pr);
                return TRUE;
@@ -3834,7 +3841,7 @@ static gboolean pr_mouse_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gp
 
        pr = PIXBUF_RENDERER(widget);
 
-       if (pr->scroller_id != -1)
+       if (pr->scroller_id)
                {
                pr->scroller_xpos = pr->scroller_x;
                pr->scroller_ypos = pr->scroller_y;
index dc290a6..f336cba 100644 (file)
@@ -114,7 +114,7 @@ struct _PixbufRenderer
        GList *draw_queue;      /* list of areas to redraw */
        GList *draw_queue_2pass;/* list when 2 pass is enabled */
 
-       gint draw_idle_id;
+       guint draw_idle_id; /* event source id */
 
        gboolean in_drag;
        gint drag_last_x;
@@ -142,7 +142,7 @@ struct _PixbufRenderer
        gboolean complete;
        gboolean debug_updated; /* debug only */
 
-       gint scroller_id;
+       guint scroller_id; /* event source id */
        gint scroller_overlay;
        gint scroller_x;
        gint scroller_y;
index 3f09cce..5737450 100644 (file)
@@ -232,7 +232,7 @@ struct _PrintWindow
        gdouble layout_width;
        gdouble layout_height;
 
-       gint layout_idle_id;
+       guint layout_idle_id; /* event source id */
 
        gdouble image_scale;
 
@@ -570,10 +570,10 @@ static void print_window_layout_status(PrintWindow *pw)
 
 static void print_window_layout_render_stop(PrintWindow *pw)
 {
-       if (pw->layout_idle_id != -1)
+       if (pw->layout_idle_id)
                {
                g_source_remove(pw->layout_idle_id);
-               pw->layout_idle_id = -1;
+               pw->layout_idle_id = 0;
                }
 }
 
@@ -584,7 +584,7 @@ static gboolean print_window_layout_render_idle(gpointer data)
        print_job_close(pw, FALSE);
        print_job_start(pw, RENDER_FORMAT_PREVIEW, 0);
 
-       pw->layout_idle_id = -1;
+       pw->layout_idle_id = 0;
        return FALSE;
 }
 
@@ -598,7 +598,7 @@ static void print_window_layout_render(PrintWindow *pw)
 
        print_window_layout_status(pw);
 
-       if (pw->layout_idle_id == -1)
+       if (!pw->layout_idle_id)
                {
                pw->layout_idle_id = g_idle_add(print_window_layout_render_idle, pw);
                }
@@ -750,7 +750,7 @@ static GtkWidget *print_window_layout_setup(PrintWindow *pw, GtkWidget *box)
        vbox = pref_box_new(box, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
        group = pref_frame_new(vbox, TRUE, _("Preview"), GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
 
-       pw->layout_idle_id = -1;
+       pw->layout_idle_id = 0;
 
        pw->layout_image = image_new(FALSE);
        gtk_widget_set_size_request(pw->layout_image->widget, PRINT_DLG_PREVIEW_WIDTH, PRINT_DLG_PREVIEW_HEIGHT);
index 359a715..8e9b57b 100644 (file)
@@ -47,7 +47,7 @@ static gint remote_client_send(RemoteConnection *rc, const gchar *text);
 typedef struct _RemoteClient RemoteClient;
 struct _RemoteClient {
        gint fd;
-       gint channel_id;
+       guint channel_id; /* event source id */
        RemoteConnection *rc;
 };
 
index cf6aa9a..c5673ad 100644 (file)
@@ -179,8 +179,8 @@ struct _SearchData
        gint search_total;
        gint search_buffer_count;
 
-       gint search_idle_id;
-       gint update_idle_id;
+       guint search_idle_id; /* event source id */
+       guint update_idle_id; /* event source id */
 
        ImageLoader *img_loader;
        CacheData   *img_cd;
@@ -686,14 +686,17 @@ static gboolean search_result_update_idle_cb(gpointer data)
 
        search_status_update(sd);
 
-       sd->update_idle_id = -1;
+       sd->update_idle_id = 0;
        return FALSE;
 }
 
 static void search_result_update_idle_cancel(SearchData *sd)
 {
-       if (sd->update_idle_id != -1) g_source_remove(sd->update_idle_id);
-       sd->update_idle_id = -1;
+       if (sd->update_idle_id)
+               {
+               g_source_remove(sd->update_idle_id);
+               sd->update_idle_id = 0;
+               }
 }
 
 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store,
@@ -701,7 +704,7 @@ static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeMode
 {
        SearchData *sd = data;
 
-       if (sd->update_idle_id == -1)
+       if (!sd->update_idle_id)
                {
                sd->update_idle_id = g_idle_add(search_result_update_idle_cb, sd);
                }
@@ -1479,10 +1482,10 @@ static void search_buffer_flush(SearchData *sd)
 
 static void search_stop(SearchData *sd)
 {
-       if (sd->search_idle_id != -1)
+       if (sd->search_idle_id)
                {
                g_source_remove(sd->search_idle_id);
-               sd->search_idle_id = -1;
+               sd->search_idle_id = 0;
                }
 
        image_loader_free(sd->img_loader);
@@ -1968,7 +1971,7 @@ static gboolean search_step_cb(gpointer data)
                {
                if (search_file_next(sd))
                        {
-                       sd->search_idle_id = -1;
+                       sd->search_idle_id = 0;
                        return FALSE;
                        }
                return TRUE;
@@ -1976,7 +1979,7 @@ static gboolean search_step_cb(gpointer data)
 
        if (!sd->search_file_list && !sd->search_folder_list)
                {
-               sd->search_idle_id = -1;
+               sd->search_idle_id = 0;
 
                search_stop(sd);
                search_result_thumb_step(sd);
@@ -2636,9 +2639,6 @@ void search_new(FileData *dir_fd, FileData *example_file)
                sd->search_similarity_path = g_strdup(example_file->path);
                }
 
-       sd->search_idle_id = -1;
-       sd->update_idle_id = -1;
-
        sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", NULL, NULL, _("Image search"));
 
        gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);
index a15da53..265707b 100644 (file)
@@ -297,7 +297,7 @@ static gboolean slideshow_loop_cb(gpointer data)
 
        if (!slideshow_step(ss, TRUE))
                {
-               ss->timeout_id = -1;
+               ss->timeout_id = 0;
                slideshow_free(ss);
                return FALSE;
                }
@@ -307,17 +307,17 @@ static gboolean slideshow_loop_cb(gpointer data)
 
 static void slideshow_timer_stop(SlideShowData *ss)
 {
-       if (ss->timeout_id == -1) return;
+       if (!ss->timeout_id) return;
 
        g_source_remove(ss->timeout_id);
-       ss->timeout_id = -1;
+       ss->timeout_id = 0;
 }
 
 static void slideshow_timer_reset(SlideShowData *ss)
 {
        if (options->slideshow.delay < 1) options->slideshow.delay = 1;
 
-       if (ss->timeout_id != -1) g_source_remove(ss->timeout_id);
+       if (ss->timeout_id) g_source_remove(ss->timeout_id);
        ss->timeout_id = g_timeout_add(options->slideshow.delay * 1000 / SLIDESHOW_SUBSECOND_PRECISION,
                                       slideshow_loop_cb, ss);
 }
@@ -361,7 +361,6 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
        ss->filelist = filelist;
        ss->cd = cd;
        ss->layout = lw;
-       ss->timeout_id = -1;
 
        if (ss->filelist)
                {
index 585046e..0331e9a 100644 (file)
@@ -250,7 +250,7 @@ static gboolean thumb_loader_done_delay_cb(gpointer data)
 {
        ThumbLoader *tl = data;
 
-       tl->idle_done_id = -1;
+       tl->idle_done_id = 0;
 
        if (tl->func_done) tl->func_done(tl, tl->data);
 
@@ -259,7 +259,7 @@ static gboolean thumb_loader_done_delay_cb(gpointer data)
 
 static void thumb_loader_delay_done(ThumbLoader *tl)
 {
-       if (tl->idle_done_id == -1) tl->idle_done_id = g_idle_add(thumb_loader_done_delay_cb, tl);
+       if (!tl->idle_done_id) tl->idle_done_id = g_idle_add(thumb_loader_done_delay_cb, tl);
 }
 
 static void thumb_loader_setup(ThumbLoader *tl, const gchar *path)
@@ -477,7 +477,6 @@ ThumbLoader *thumb_loader_new(gint width, gint height)
        tl->percent_done = 0.0;
        tl->max_w = width;
        tl->max_h = height;
-       tl->idle_done_id = -1;
 
        return tl;
 }
@@ -495,7 +494,7 @@ void thumb_loader_free(ThumbLoader *tl)
        image_loader_free(tl->il);
        file_data_unref(tl->fd);
 
-       if (tl->idle_done_id != -1) g_source_remove(tl->idle_done_id);
+       if (tl->idle_done_id) g_source_remove(tl->idle_done_id);
 
        g_free(tl);
 }
index 892674b..0d49f06 100644 (file)
@@ -738,7 +738,7 @@ struct _ThumbValidate
        void (*func_valid)(const gchar *path, gboolean valid, gpointer data);
        gpointer data;
 
-       gint idle_id;
+       guint idle_id; /* event source id */
 };
 
 static void thumb_loader_std_thumb_file_validate_free(ThumbValidate *tv)
@@ -756,8 +756,11 @@ void thumb_loader_std_thumb_file_validate_cancel(ThumbLoaderStd *tl)
 
        tv = tl->data;
 
-       if (tv->idle_id != -1) g_source_remove(tv->idle_id);
-       tv->idle_id = -1;
+       if (tv->idle_id)
+               {
+               g_source_remove(tv->idle_id);
+               tv->idle_id = 0;
+               }
 
        thumb_loader_std_thumb_file_validate_free(tv);
 }
@@ -835,7 +838,7 @@ static gboolean thumb_loader_std_thumb_file_validate_idle_cb(gpointer data)
 {
        ThumbValidate *tv = data;
 
-       tv->idle_id = -1;
+       tv->idle_id = 0;
        thumb_loader_std_thumb_file_validate_finish(tv, FALSE);
 
        return FALSE;
@@ -868,7 +871,7 @@ ThumbLoaderStd *thumb_loader_std_thumb_file_validate(const gchar *thumb_path, gi
                }
        else
                {
-               tv->idle_id = -1;
+               tv->idle_id = 0;
                }
 
        return tv->tl;
index 63c32ae..9eccfe1 100644 (file)
@@ -263,7 +263,7 @@ struct _ThumbLoader
 
        gpointer data;
 
-       gint idle_done_id;
+       guint idle_done_id; /* event source id */
 };
 
 struct _CollectInfo
@@ -316,7 +316,7 @@ struct _CollectTable
        CollectInfo *click_info;
 
        GtkWidget *tip_window;
-       gint tip_delay_id;
+       guint tip_delay_id; /* event source id */
        CollectInfo *tip_info;
 
        GdkWindow *marker_window;
@@ -333,8 +333,8 @@ struct _CollectTable
        CollectInfo *drop_info;
        GList *drop_list;
 
-       gint sync_idle_id;
-       gint drop_idle_id;
+       guint sync_idle_id; /* event source id */
+       guint drop_idle_id; /* event source id */
 
        gboolean show_text;
 
@@ -681,7 +681,7 @@ struct _ViewDir
 
        FileData *drop_fd;
        GList *drop_list;
-       gint drop_scroll_id;
+       guint drop_scroll_id; /* event source id */
 
        /* func list */
        void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
@@ -704,7 +704,7 @@ struct _ViewDirInfoList
 
 struct _ViewDirInfoTree
 {
-       gint drop_expand_id;
+       guint drop_expand_id; /* event source id */
        gint busy_ref;
 };
 
@@ -748,7 +748,7 @@ struct _ViewFile
        gint clicked_mark;
        
        /* refresh */
-       gint refresh_idle_id;
+       guint refresh_idle_id; /* event source id */
 
        /* file list for edit menu */
        GList *editmenu_fd_list;
@@ -761,7 +761,7 @@ struct _ViewFileInfoList
 
        gboolean thumbs_enabled;
 
-       gint select_idle_id;
+       guint select_idle_id; /* event source id */
 };
 
 struct _IconData;
@@ -776,7 +776,7 @@ struct _ViewFileInfoIcon
        struct _IconData *prev_selection;
 
        GtkWidget *tip_window;
-       gint tip_delay_id;
+       guint tip_delay_id; /* event source id */
        struct _IconData *tip_id;
 
        struct _IconData *click_id;
@@ -803,7 +803,7 @@ struct _SlideShowData
        FileData *slide_fd;
 
        guint slide_count;
-       gint timeout_id;
+       guint timeout_id; /* event source id */
 
        gboolean from_selection;
 
@@ -821,11 +821,12 @@ struct _FullScreenData
        GtkWidget *normal_window;
        ImageWindow *normal_imd;
 
-       gint hide_mouse_id;
-       gint busy_mouse_id;
+       guint hide_mouse_id; /* event source id */
+       guint busy_mouse_id; /* event source id */
+
        gint cursor_state;
 
-       gint saver_block_id;
+       guint saver_block_id; /* event source id */
 
        void (*stop_func)(FullScreenData *, gpointer);
        gpointer stop_data;
index ac64274..af1cf52 100644 (file)
@@ -42,7 +42,7 @@ struct _SpinnerData {
        GtkWidget *image;
        GList *list;            /* list of pixbufs */
        guint frame;
-       gint timer_id;
+       guint timer_id; /* event source id */
 };
 
 static void spinner_set_frame(SpinnerData *sp, guint frame)
@@ -75,10 +75,10 @@ static void spinner_set_timeout(SpinnerData *sp, gint interval)
 {
        if (!sp) return;
 
-       if (sp->timer_id != -1)
+       if (sp->timer_id)
                {
                g_source_remove(sp->timer_id);
-               sp->timer_id = -1;
+               sp->timer_id = 0;
                }
 
        if (interval > 0)
@@ -117,8 +117,6 @@ GtkWidget *spinner_new(const gchar *path, gint interval)
        SpinnerData *sp;
 
        sp = g_new0(SpinnerData, 1);
-       sp->list = NULL;
-       sp->timer_id = -1;
 
        if (path)
                {
@@ -198,7 +196,7 @@ void spinner_step(GtkWidget *spinner, gboolean reset)
        SpinnerData *sp;
 
        sp = g_object_get_data(G_OBJECT(spinner), "spinner");
-       if (sp->timer_id != -1)
+       if (sp->timer_id)
                {
                log_printf("spinner warning: attempt to step with timer set\n");
                return;
index 3f0923d..48d232d 100644 (file)
@@ -524,7 +524,7 @@ void style_shift_color(GtkStyle *style, GtkStateType type, gshort shift_value, g
 typedef struct _AutoScrollData AutoScrollData;
 struct _AutoScrollData
 {
-       gint timer_id;
+       guint timer_id; /* event source id */
        gint region_size;
        GtkWidget *widget;
        GtkAdjustment *adj;
@@ -542,7 +542,7 @@ void widget_auto_scroll_stop(GtkWidget *widget)
        if (!sd) return;
        g_object_set_data(G_OBJECT(widget), "autoscroll", NULL);
 
-       if (sd->timer_id != -1) g_source_remove(sd->timer_id);
+       if (sd->timer_id) g_source_remove(sd->timer_id);
        g_free(sd);
 }
 
@@ -565,7 +565,7 @@ static gboolean widget_auto_scroll_cb(gpointer data)
 
        if (x < 0 || x >= w || y < 0 || y >= h)
                {
-               sd->timer_id = -1;
+               sd->timer_id = 0;
                widget_auto_scroll_stop(sd->widget);
                return FALSE;
                }
@@ -596,7 +596,7 @@ static gboolean widget_auto_scroll_cb(gpointer data)
                        /* only notify when scrolling is needed */
                        if (sd->notify_func && !sd->notify_func(sd->widget, x, y, sd->notify_data))
                                {
-                               sd->timer_id = -1;
+                               sd->timer_id = 0;
                                widget_auto_scroll_stop(sd->widget);
                                return FALSE;
                                }
index 04c1aec..372afa3 100644 (file)
@@ -283,9 +283,8 @@ struct _UtilityData {
        GenericDialog *gd;
        FileDialog *fdlg;
        
-       gint update_idle_id;
-
-       gint perform_idle_id;
+       guint update_idle_id; /* event source id */
+       guint perform_idle_id; /* event source id */
 
        gboolean with_sidecars; /* operate on grouped or single files; TRUE = use file_data_sc_, FALSE = use file_data_ functions */
        
@@ -344,8 +343,6 @@ static UtilityData *file_util_data_new(UtilityType type)
        
        ud->type = type;
        ud->phase = UTILITY_PHASE_START;
-       ud->update_idle_id = -1;
-       ud->perform_idle_id = -1;
        
        return ud;
 }
@@ -354,8 +351,8 @@ static void file_util_data_free(UtilityData *ud)
 {
        if (!ud) return;
 
-       if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id);
-       if (ud->perform_idle_id != -1) g_source_remove(ud->perform_idle_id);
+       if (ud->update_idle_id) g_source_remove(ud->update_idle_id);
+       if (ud->perform_idle_id) g_source_remove(ud->perform_idle_id);
 
        file_data_unref(ud->dir_fd);
        filelist_free(ud->content_list);
@@ -592,7 +589,7 @@ static gboolean file_util_perform_ci_internal(gpointer data)
 {
        UtilityData *ud = data;
 
-       if (ud->perform_idle_id == -1
+       if (!ud->perform_idle_id
                {
                /* this function was called directly
                   just setup idle callback and wait until we are called again
@@ -1226,7 +1223,7 @@ static gboolean file_util_rename_idle_cb(gpointer data)
 
        file_util_rename_preview_update(ud);
 
-       ud->update_idle_id = -1;
+       ud->update_idle_id = 0;
        return FALSE;
 }
 
@@ -1235,7 +1232,7 @@ static void file_util_rename_preview_order_cb(GtkTreeModel *treemodel, GtkTreePa
 {
        UtilityData *ud = data;
 
-       if (ud->update_idle_id != -1) return;
+       if (ud->update_idle_id) return;
 
        ud->update_idle_id = g_idle_add(file_util_rename_idle_cb, ud);
 }
index a4418f9..f5f05bc 100644 (file)
@@ -67,8 +67,6 @@ ViewDir *vd_new(DirViewType type, FileData *dir_fd)
 
        ViewDir *vd = g_new0(ViewDir, 1);
 
-       vd->drop_scroll_id = -1;
-
        vd->widget = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vd->widget), GTK_SHADOW_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget),
@@ -803,8 +801,11 @@ static void vd_dnd_drop_update(ViewDir *vd, gint x, gint y)
 
 void vd_dnd_drop_scroll_cancel(ViewDir *vd)
 {
-       if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id);
-       vd->drop_scroll_id = -1;
+       if (vd->drop_scroll_id)
+               {
+               g_source_remove(vd->drop_scroll_id);
+               vd->drop_scroll_id = 0;
+               }
 }
 
 static gboolean vd_auto_scroll_idle_cb(gpointer data)
@@ -826,7 +827,7 @@ static gboolean vd_auto_scroll_idle_cb(gpointer data)
                        }
                }
 
-       vd->drop_scroll_id = -1;
+       vd->drop_scroll_id = 0;
        return FALSE;
 }
 
@@ -836,7 +837,7 @@ static gboolean vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpoi
 
        if (!vd->drop_fd || vd->drop_list) return FALSE;
 
-       if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd);
+       if (!vd->drop_scroll_id) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd);
 
        return TRUE;
 }
index ec4f5bb..0b93d3f 100644 (file)
@@ -173,14 +173,17 @@ static gboolean vdtree_dnd_drop_expand_cb(gpointer data)
                vdtree_expand_by_data(vd, vd->drop_fd, TRUE);
                }
 
-       VDTREE(vd)->drop_expand_id = -1;
+       VDTREE(vd)->drop_expand_id = 0;
        return FALSE;
 }
 
 static void vdtree_dnd_drop_expand_cancel(ViewDir *vd)
 {
-       if (VDTREE(vd)->drop_expand_id != -1) g_source_remove(VDTREE(vd)->drop_expand_id);
-       VDTREE(vd)->drop_expand_id = -1;
+       if (VDTREE(vd)->drop_expand_id)
+               {
+               g_source_remove(VDTREE(vd)->drop_expand_id);
+               VDTREE(vd)->drop_expand_id = 0;
+               }
 }
 
 static void vdtree_dnd_drop_expand(ViewDir *vd)
@@ -959,7 +962,6 @@ ViewDir *vdtree_new(ViewDir *vd, FileData *dir_fd)
        vd->info = g_new0(ViewDirInfoTree, 1);
 
        vd->type = DIRVIEW_TREE;
-       VDTREE(vd)->drop_expand_id = -1;
 
        vd->dnd_drop_leave_func = vdtree_dnd_drop_expand_cancel;
        vd->dnd_drop_update_func = vdtree_dnd_drop_expand;
index d317199..74a1cb6 100644 (file)
@@ -709,7 +709,6 @@ ViewFile *vf_new(FileViewType type, FileData *dir_fd)
        vf->type = type;
        vf->sort_method = SORT_NAME;
        vf->sort_ascend = TRUE;
-       vf->refresh_idle_id = -1;
 
        vf->scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vf->scrolled), GTK_SHADOW_IN);
@@ -822,20 +821,23 @@ static gboolean vf_refresh_idle_cb(gpointer data)
        ViewFile *vf = data;
 
        vf_refresh(vf);
-       vf->refresh_idle_id = -1;
+       vf->refresh_idle_id = 0;
        return FALSE;
 }
 
 void vf_refresh_idle_cancel(ViewFile *vf)
 {
-       if (vf->refresh_idle_id != -1) g_source_remove(vf->refresh_idle_id);
-       vf->refresh_idle_id = -1;
+       if (vf->refresh_idle_id)
+               {
+               g_source_remove(vf->refresh_idle_id);
+               vf->refresh_idle_id = 0;
+               }
 }
 
 
 void vf_refresh_idle(ViewFile *vf)
 {
-       if (vf->refresh_idle_id == -1)
+       if (!vf->refresh_idle_id)
                {
                vf->refresh_idle_id = g_idle_add(vf_refresh_idle_cb, vf);
                }
@@ -850,7 +852,7 @@ void vf_notify_cb(FileData *fd, NotifyType type, gpointer data)
        if (vf->marks_enabled) 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 != -1 || !vf->dir_fd) return;
+       if (!(type & interested) || vf->refresh_idle_id || !vf->dir_fd) return;
        
        refresh = (fd == vf->dir_fd);
 
index afd3fc7..0718412 100644 (file)
@@ -442,7 +442,7 @@ static gboolean tip_schedule_cb(gpointer data)
        ViewFile *vf = data;
        GtkWidget *window;
 
-       if (VFICON(vf)->tip_delay_id == -1) return FALSE;
+       if (!VFICON(vf)->tip_delay_id) return FALSE;
 
        window = gtk_widget_get_toplevel(vf->listview);
 
@@ -452,7 +452,7 @@ static gboolean tip_schedule_cb(gpointer data)
                tip_show(vf);
                }
 
-       VFICON(vf)->tip_delay_id = -1;
+       VFICON(vf)->tip_delay_id = 0;
        return FALSE;
 }
 
@@ -460,10 +460,10 @@ static void tip_schedule(ViewFile *vf)
 {
        tip_hide(vf);
 
-       if (VFICON(vf)->tip_delay_id != -1)
+       if (VFICON(vf)->tip_delay_id)
                {
                g_source_remove(VFICON(vf)->tip_delay_id);
-               VFICON(vf)->tip_delay_id = -1;
+               VFICON(vf)->tip_delay_id = 0;
                }
 
        if (!VFICON(vf)->show_text)
@@ -476,8 +476,11 @@ static void tip_unschedule(ViewFile *vf)
 {
        tip_hide(vf);
 
-       if (VFICON(vf)->tip_delay_id != -1) g_source_remove(VFICON(vf)->tip_delay_id);
-       VFICON(vf)->tip_delay_id = -1;
+       if (VFICON(vf)->tip_delay_id)
+               {
+               g_source_remove(VFICON(vf)->tip_delay_id);
+               VFICON(vf)->tip_delay_id = 0;
+               }
 }
 
 static void tip_update(ViewFile *vf, IconData *id)
@@ -2466,7 +2469,6 @@ ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd)
 
        vf->info = g_new0(ViewFileInfoIcon, 1);
 
-       VFICON(vf)->tip_delay_id = -1;
        VFICON(vf)->show_text = options->show_icon_names;
 
        store = gtk_list_store_new(1, G_TYPE_POINTER);
index 89e9f31..bc9ae82 100644 (file)
@@ -718,7 +718,7 @@ static gboolean vflist_select_idle_cb(gpointer data)
 
        if (!vf->layout)
                {
-               VFLIST(vf)->select_idle_id = -1;
+               VFLIST(vf)->select_idle_id = 0;
                return FALSE;
                }
 
@@ -730,14 +730,17 @@ static gboolean vflist_select_idle_cb(gpointer data)
                VFLIST(vf)->select_fd = NULL;
                }
 
-       VFLIST(vf)->select_idle_id = -1;
+       VFLIST(vf)->select_idle_id = 0;
        return FALSE;
 }
 
 static void vflist_select_idle_cancel(ViewFile *vf)
 {
-       if (VFLIST(vf)->select_idle_id != -1) g_source_remove(VFLIST(vf)->select_idle_id);
-       VFLIST(vf)->select_idle_id = -1;
+       if (VFLIST(vf)->select_idle_id)
+               {
+               g_source_remove(VFLIST(vf)->select_idle_id);
+               VFLIST(vf)->select_idle_id = 0;
+               }
 }
 
 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
@@ -757,7 +760,7 @@ static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *stor
                }
 
        if (vf->layout &&
-           VFLIST(vf)->select_idle_id == -1)
+           !VFLIST(vf)->select_idle_id)
                {
                VFLIST(vf)->select_idle_id = g_idle_add(vflist_select_idle_cb, vf);
                }
@@ -1973,8 +1976,6 @@ ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd)
 
        vf->info = g_new0(ViewFileInfoList, 1);
        
-       VFLIST(vf)->select_idle_id = -1;
-
        flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER;
        flist_types[FILE_COLUMN_VERSION] = G_TYPE_INT;
        flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF;