Skip to content

Commit

Permalink
perform internal commands in idle call
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Dec 25, 2008
1 parent 3111499 commit 4bf1446
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/utilops.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ struct _UtilityData {

gint update_idle_id;

gint perform_idle_id;

gboolean with_sidecars; /* operate on grouped or single files; TRUE = use file_data_sc_, FALSE = use file_data_ functions */

/* alternative dialog parts */
Expand Down Expand Up @@ -339,6 +341,7 @@ 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;
ud->external_command = -1;
return ud;
}
Expand All @@ -348,6 +351,7 @@ 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);

file_data_unref(ud->dir_fd);
filelist_free(ud->content_list);
Expand Down Expand Up @@ -464,7 +468,7 @@ static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint fu
}


static void file_util_perform_ci_internal(UtilityData *ud);
static gboolean file_util_perform_ci_internal(gpointer data);
void file_util_dialog_run(UtilityData *ud);
static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data);

Expand Down Expand Up @@ -578,10 +582,16 @@ static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *lis
*/


static void file_util_perform_ci_internal(UtilityData *ud)
static gboolean file_util_perform_ci_internal(gpointer data)
{
UtilityData *ud = data;

/* this is removed when ud is destroyed */
if (ud->perform_idle_id == -1) ud->perform_idle_id = g_idle_add(file_util_perform_ci_internal, ud);

g_assert(ud->flist);

while (ud->flist)
if (ud->flist)
{
gint ret;

Expand All @@ -597,16 +607,16 @@ static void file_util_perform_ci_internal(UtilityData *ud)
ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud);
g_list_free(single_entry);

if (ret == EDITOR_CB_SUSPEND || last) return;
if (ret == EDITOR_CB_SUSPEND || last) return FALSE;

if (ret == EDITOR_CB_SKIP)
{
file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud);
return FALSE;
}

/* FIXME: convert the loop to idle call */

}

return TRUE;
}

static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolean ext_result)
Expand Down

0 comments on commit 4bf1446

Please sign in to comment.