static EditorFlags editor_command_start(const EditorDescription *editor, const gchar *text, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data) { EditorData *ed; EditorFlags flags = editor->flags; if (EDITOR_ERRORS(flags)) return EDITOR_ERRORS(flags); ed = g_new0(EditorData, 1); ed->list = filelist_copy(list); ed->flags = flags; ed->editor = editor; ed->total = (flags & (EDITOR_SINGLE_COMMAND | EDITOR_NO_PARAM)) ? 1 : g_list_length(list); ed->callback = cb; ed->data = data; ed->working_directory = g_strdup(working_directory); if ((flags & EDITOR_VERBOSE_MULTI) && list && list->next) flags |= EDITOR_VERBOSE; if (flags & EDITOR_VERBOSE) editor_verbose_window(ed, text); editor_command_next_start(ed); /* errors from editor_command_next_start will be handled via callback */ return EDITOR_ERRORS(flags); }
static void view_window_set_list(ViewWindow *vw, GList *list) { filelist_free(vw->list); vw->list = NULL; vw->list_pointer = NULL; vw->list = filelist_copy(list); }
static void view_slideshow_start(ViewWindow *vw) { if (!vw->ss) { CollectionData *cd; CollectInfo *info; if (vw->list) { vw->ss = slideshow_start_from_filelist(NULL, view_window_active_image(vw), filelist_copy(vw->list), view_slideshow_stop_func, vw); vw->list_pointer = NULL; return; } cd = image_get_collection(view_window_active_image(vw), &info); if (cd && info) { vw->ss = slideshow_start_from_collection(NULL, view_window_active_image(vw), cd, view_slideshow_stop_func, vw, info); } } }
void op_start (OPERATION_ operation, GList *filelist, char *src, char *dest, panel *p) { int pid; int reportpipe[2]; int actionpipe[2]; int options = 0; char *finaldest = NULL; int flags; int eventid; void *data; char *srcpath; /* inclusion of '/' */ GtkWindow *progress_dialog = NULL; GtkWidget *progress_path_label = NULL; GtkWidget *progress_bar = NULL; char *progress_title = NULL; struct stat fileinfo; mode_t mode; uid_t uid; gid_t gid; // int options; /* Prepare operation */ switch (operation) { case OP_COPY : dialog_enterpath ("Copy", "Copy files to", dest, &finaldest); gtk_main(); progress_title = strdup ("Copy"); break; case OP_MOVE : dialog_enterpath ("Move","Move files to", dest, &finaldest); gtk_main(); progress_title = strdup ("Move"); break; case OP_MKDIR : if (src[strlen(src)] != '/') { srcpath = malloc (sizeof(char) * (strlen(src) + 2)); sprintf (srcpath, "%s/", src); } else { srcpath = strdup(src); } dialog_enterpath ("Make dir","Make directory", srcpath, &finaldest); gtk_main(); progress_title = strdup ("Make Dir"); free (srcpath); break; case OP_DEL : finaldest = strdup (dest); progress_title = strdup ("Delete"); break; case OP_LNK : dialog_enterpath ("Link","Link files in", dest, &finaldest); progress_title = strdup ("Link"); gtk_main(); break; case OP_PERM : srcpath = malloc (sizeof(char) * (strlen(src) + strlen(filelist->data) + 2)); sprintf (srcpath, "%s/%s", src, (char *)filelist->data); stat(srcpath, &fileinfo); mode = fileinfo.st_mode; if (dialog_permissions (mode, &mode, &options) == 0) { finaldest = strdup(src); } else { finaldest = NULL; } break; case OP_OWN : srcpath = malloc (sizeof(char) * (strlen(src) + strlen(filelist->data) + 2)); sprintf (srcpath, "%s/%s", src, (char *)filelist->data); stat(srcpath, &fileinfo); uid = fileinfo.st_uid; gid = fileinfo.st_gid; if (dialog_ownership (uid, gid, &uid, &gid, &options) == 0) { finaldest = strdup(src); } else { finaldest = NULL; } break; default: perror ("op_start: Unknow operation passed\n"); break; } if (finaldest != NULL) { /* FIXME: Comment on the next line is incorrect? */ /* action canceled */ p->operation_busy = 1; p->next->operation_busy = 1; panel_disable (p); panel_disable (p->next); pipe (reportpipe); pipe (actionpipe); progress_path_label = gtk_label_new (""); progress_bar = gtk_progress_bar_new(); progress_dialog = dialog_progress(progress_title, progress_path_label, progress_bar); data = gtk_param_pack ("iipppp", reportpipe[0], actionpipe[1], (void *)p, (void *)progress_path_label, (void *)progress_dialog, (void *)progress_bar); eventid = gtk_timeout_add (100, (GtkFunction) op_progress, (gpointer) data); if ((pid = fork()) == 0) { close (reportpipe[0]); close (actionpipe[1]); switch (operation) { case OP_COPY : filelist_copy (actionpipe[0], reportpipe[1], filelist, src, finaldest, options); break; case OP_MOVE : filelist_move (actionpipe[0], reportpipe[1], filelist, src, finaldest, options); break; case OP_MKDIR : filelist_mkdir (actionpipe[0], reportpipe[1], finaldest, src, options); break; case OP_DEL : filelist_del (actionpipe[0], reportpipe[1], filelist, src, options); break; case OP_LNK : filelist_lnk (actionpipe[0], reportpipe[1], filelist, src, finaldest, options); break; case OP_PERM : filelist_chmod (actionpipe[0], reportpipe[1], filelist, src, mode, options); break; case OP_OWN : filelist_chown (actionpipe[0], reportpipe[1], filelist, src, uid, gid, options); break; default: perror ("op_start: Unknow operation passed"); } close (reportpipe[0]); close (reportpipe[1]); close (actionpipe[0]); close (actionpipe[1]); _exit (0); } /* Set pipe read to non-blocking */ flags = fcntl(reportpipe[0], F_GETFL, 0); fcntl(reportpipe[0], F_SETFL, flags | O_NONBLOCK); } free (progress_title); free (finaldest); }
static gboolean view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { ViewWindow *vw = data; ImageWindow *imd; gint stop_signal; GtkWidget *menu; gint x = 0; gint y = 0; imd = view_window_active_image(vw); stop_signal = TRUE; switch (event->keyval) { case GDK_KEY_Left: case GDK_KEY_KP_Left: x -= 1; break; case GDK_KEY_Right: case GDK_KEY_KP_Right: x += 1; break; case GDK_KEY_Up: case GDK_KEY_KP_Up: y -= 1; break; case GDK_KEY_Down: case GDK_KEY_KP_Down: y += 1; break; default: stop_signal = FALSE; break; } if (x != 0 || y!= 0) { if (event->state & GDK_SHIFT_MASK) { x *= 3; y *= 3; } keyboard_scroll_calc(&x, &y, event); image_scroll(imd, x, y); } if (stop_signal) return stop_signal; if (event->state & GDK_CONTROL_MASK) { stop_signal = TRUE; switch (event->keyval) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': break; case 'C': case 'c': file_util_copy(image_get_fd(imd), NULL, NULL, imd->widget); break; case 'M': case 'm': file_util_move(image_get_fd(imd), NULL, NULL, imd->widget); break; case 'R': case 'r': file_util_rename(image_get_fd(imd), NULL, imd->widget); break; case 'D': case 'd': file_util_delete(image_get_fd(imd), NULL, imd->widget); break; case 'W': case 'w': view_window_close(vw); break; default: stop_signal = FALSE; break; } } else if (event->state & GDK_SHIFT_MASK) { stop_signal = TRUE; switch (event->keyval) { case 'R': case 'r': image_alter_orientation(imd, ALTER_ROTATE_180); break; case 'M': case 'm': image_alter_orientation(imd, ALTER_MIRROR); break; case 'F': case 'f': image_alter_orientation(imd, ALTER_FLIP); break; case 'G': case 'g': image_set_desaturate(imd, !image_get_desaturate(imd)); break; case 'P': case 'p': { FileData *fd; view_fullscreen_toggle(vw, TRUE); imd = view_window_active_image(vw); fd = image_get_fd(imd); print_window_new(fd, fd ? g_list_append(NULL, file_data_ref(fd)) : NULL, filelist_copy(vw->list), vw->window); } break; default: stop_signal = FALSE; break; } } else { stop_signal = TRUE; switch (event->keyval) { case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up: case GDK_KEY_BackSpace: case 'B': case 'b': view_step_prev(vw); break; case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down: case GDK_KEY_space: case 'N': case 'n': view_step_next(vw); break; case GDK_KEY_Home: case GDK_KEY_KP_Home: view_step_to_end(vw, FALSE); break; case GDK_KEY_End: case GDK_KEY_KP_End: view_step_to_end(vw, TRUE); break; case '+': case '=': case GDK_KEY_KP_Add: image_zoom_adjust(imd, get_zoom_increment()); break; case '-': case GDK_KEY_KP_Subtract: image_zoom_adjust(imd, -get_zoom_increment()); break; case 'X': case 'x': case GDK_KEY_KP_Multiply: image_zoom_set(imd, 0.0); break; case 'Z': case 'z': case GDK_KEY_KP_Divide: case '1': image_zoom_set(imd, 1.0); break; case '2': image_zoom_set(imd, 2.0); break; case '3': image_zoom_set(imd, 3.0); break; case '4': image_zoom_set(imd, 4.0); break; case '7': image_zoom_set(imd, -4.0); break; case '8': image_zoom_set(imd, -3.0); break; case '9': image_zoom_set(imd, -2.0); break; case 'W': case 'w': image_zoom_set_fill_geometry(imd, FALSE); break; case 'H': case 'h': image_zoom_set_fill_geometry(imd, TRUE); break; case 'R': case 'r': image_reload(imd); break; case 'S': case 's': if (vw->ss) { view_slideshow_stop(vw); } else { view_slideshow_start(vw); } break; case 'P': case 'p': slideshow_pause_toggle(vw->ss); break; case 'F': case 'f': case 'V': case 'v': case GDK_KEY_F11: view_fullscreen_toggle(vw, FALSE); break; case 'I': case 'i': view_overlay_toggle(vw); break; case ']': image_alter_orientation(imd, ALTER_ROTATE_90); break; case '[': image_alter_orientation(imd, ALTER_ROTATE_90_CC); break; case GDK_KEY_Delete: case GDK_KEY_KP_Delete: if (options->file_ops.enable_delete_key) { file_util_delete(image_get_fd(imd), NULL, imd->widget); } break; case GDK_KEY_Escape: if (vw->fs) { view_fullscreen_toggle(vw, TRUE); } else { view_window_close(vw); } break; case GDK_KEY_Menu: case GDK_KEY_F10: menu = view_popup_menu(vw); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, view_window_menu_pos_cb, vw, 0, GDK_CURRENT_TIME); break; default: stop_signal = FALSE; break; } } return stop_signal; }