📄 edit.cc
字号:
/* WebDownloader for X-Window * Copyright (C) 1999-2002 Koshelev Maxim * This Program is free but not GPL!!! You can't modify it * without agreement with author. You can't distribute modified * program but you can distribute unmodified program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */#include <stdio.h>#include <string.h>#include <strings.h>#include "edit.h"#include "list.h"#include "misc.h"#include "mywidget.h"#include "addd.h"#include "passface.h"#include "../history.h"#include "../var.h"#include "../locstr.h"#include "../main.h"#include "../ntlocale.h"#include "../filter.h"#include "../recode.h"#include <gdk/gdkkeysyms.h>enum EDIT_OPTIONS_ENUM{ EDIT_OPT_USERPASS=0, EDIT_OPT_SAVEPATH, EDIT_OPT_FROMBEGIN, EDIT_OPT_TIMEOUT, EDIT_OPT_SPEED, EDIT_OPT_ATTEMPTS, EDIT_OPT_SLEEPTIME, EDIT_OPT_ROLLBACK, EDIT_OPT_DATE, EDIT_OPT_IFNOREGET, EDIT_OPT_SPLIT, EDIT_OPT_PASSIVEFTP, EDIT_OPT_PERMISSIONS, EDIT_OPT_DONT_SEND_QUIT, EDIT_OPT_DIRONTOP, EDIT_OPT_CHECK_TIME, EDIT_OPT_SLEEP_BEFORE_COMPLETE, EDIT_OPT_FOLLOWLINK, EDIT_OPT_RECURSEDEPTHFTP, EDIT_OPT_RECURSEDEPTHHTTP, EDIT_OPT_LEAVEDIR, EDIT_OPT_LEAVESERVER, EDIT_OPT_CHANGE_LINKS, EDIT_OPT_IHATEETAG, EDIT_OPT_QUEST_SIGN, EDIT_OPT_USERAGENT, EDIT_OPT_REFERER, EDIT_OPT_COOKIE, EDIT_OPT_PROXY, EDIT_OPT_TIME, EDIT_OPT_LASTOPTION};char *edit_fields_labels[]={ N_("Use password for this site"), N_("Save download to folder"), N_("Restart this download from begining"), N_("Timeout for reading from socket"), N_("Speed limitation"), N_("Maximum attempts"), N_("Timeout before reconnection"), N_("Rollback after reconnecting"), N_("Get date from the server"), N_("Retry if resuming is not supported"), N_("Number of parts for spliting this download"), N_("Use passive mode for FTP"), N_("Get permissions of the file from server (FTP only)"), N_("Don't send QUIT command (FTP)"), N_("Put directories on the top of queue during recursion"), N_("Compare date/time of remote file with local one"), N_("Sleep before completing"), N_("Follow symbolic links"), N_("Depth of recursing for FTP"), N_("Depth of recursing for HTTP"), N_("Only subdirs"), N_("Allow leave this server while recursing via HTTP"), N_("Change links in HTML file to local"), N_("Ignore ETag field in reply"), N_("Use '_' instead of '?' in stored filenames"), N_("User-Agent"), N_("Referer"), N_("Cookie"), N_("Proxy"), N_("Time")};extern tMain aa;void edit_window_cancel(GtkWidget *parent,tDEdit *where);gint edit_window_delete(GtkObject *parent);void edit_window_ok(GtkWidget *which,tDEdit *where);GList *make_glist_from_mylist(tHistory *parent) { GList *rvalue=NULL; tString *tmp=parent->last(); while (tmp) { rvalue = g_list_append (rvalue, tmp->body); tmp=parent->next(); }; return rvalue;};GtkWidget *my_gtk_combo_new(tHistory *history) { GtkWidget *combo=gtk_combo_new(); GList *list=make_glist_from_mylist(history); if (list){ gtk_combo_set_popdown_strings (GTK_COMBO (combo), list); g_list_free(list); }; gtk_combo_set_case_sensitive(GTK_COMBO(combo),TRUE); return combo;};GtkWidget *my_gtk_combo_new(int from,int to) { GList *rvalue=NULL; for (int i=from;i<=to;i++) { char data[MAX_LEN]; sprintf(data,"%i",i); char *tmp=copy_string(data); rvalue = g_list_append (rvalue,tmp); }; GtkWidget *combo=gtk_combo_new(); if (rvalue){ gtk_combo_set_popdown_strings (GTK_COMBO (combo), rvalue); GList *tmplist=rvalue; while(tmplist){ char *a=(char *)(tmplist->data); delete[] a; tmplist=tmplist->next; }; g_list_free(rvalue); }; gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry),FALSE); gtk_combo_set_case_sensitive(GTK_COMBO(combo),TRUE); return combo;};GtkWidget *my_gtk_combo_new_month() { GList *rvalue=NULL; char *tmp=copy_string("Jan"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Feb"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Mar"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Apr"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("May"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Jun"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Jul"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Aug"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Sep"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Oct"); rvalue = g_list_append (rvalue,tmp); tmp=copy_string("Nov"); rvalue = g_list_append (rvalue,tmp); GtkWidget *combo=gtk_combo_new(); if (rvalue) gtk_combo_set_popdown_strings (GTK_COMBO (combo), rvalue); gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry),FALSE); return combo;};/******************************************************/void init_edit_window(tDownload *what) { if (!what) return; if (what->editor) { what->editor->popup(); return; }; if (what->config==NULL){ what->config=new tCfg; what->set_default_cfg(); }; what->editor=new tDEdit; what->editor->init(what); what->editor->parent_in_db=1; if (what->owner()==DL_RUN || what->owner()==DL_STOPWAIT) what->editor->disable_ok_button(); gtk_window_set_title(GTK_WINDOW(what->editor->window),_("Edit download")); g_signal_connect(G_OBJECT(what->editor->cancel_button),"clicked",G_CALLBACK(edit_window_cancel),what->editor); g_signal_connect(G_OBJECT(what->editor->ok_button),"clicked",G_CALLBACK(edit_window_ok),what->editor); g_signal_connect(G_OBJECT(what->editor->window),"delete_event",G_CALLBACK(edit_window_delete), what->editor); d4x_eschandler_init(what->editor->window,what->editor);};void init_edit_window_without_ok(tDownload *what,int flag) { if (!what) return; if (what->editor) { what->editor->popup(); return; }; what->editor=new tDEdit; if (flag) what->editor->add_or_edit=flag; what->editor->init(what); if (what->owner()==DL_RUN || what->owner()==DL_STOPWAIT) what->editor->disable_ok_button(); gtk_window_set_title(GTK_WINDOW(what->editor->window),_("Edit download")); g_signal_connect(G_OBJECT(what->editor->cancel_button),"clicked",G_CALLBACK(edit_window_cancel),what->editor); g_signal_connect(G_OBJECT(what->editor->window),"delete_event",G_CALLBACK(edit_window_delete), what->editor); d4x_eschandler_init(what->editor->window,what->editor);};void edit_window_cancel(GtkWidget *parent,tDEdit *where) { delete where;};gint edit_window_delete(GtkObject *parent) { tDEdit *tmp=(tDEdit *)g_object_get_data(G_OBJECT(parent),"d4x_user_data"); delete tmp; return TRUE;};void edit_window_url_activate(GtkWidget *which,tDEdit *where){ if (GTK_WIDGET_SENSITIVE(where->ok_button)) g_signal_emit_by_name(G_OBJECT(where->ok_button), "clicked",where);};void edit_window_ok(GtkWidget *which,tDEdit *where) { if (where->apply_changes()) return; tDownload *dwn=where->get_parent(); if (dwn->config->isdefault){ delete(dwn->config); dwn->config=NULL; }; if (where->parent_in_db){ DQV(dwn).update(dwn); if (!where->get_pause_check()) aa.continue_download(dwn); }; delete where;};static void edit_browser_path_set_as_default(GtkWidget *parent,tDEdit *where){ where->set_path_as_default();};static void edit_window_password(GtkWidget *parent,tDEdit *where) { where->setup_entries();};static void edit_isdefault_check_clicked(GtkWidget *parent,tDEdit *where) { where->toggle_isdefault();};static void edit_time_check_clicked(GtkWidget *parent,tDEdit *where) { where->toggle_time();};static void edit_auto_log_clicked(GtkWidget *parent,tDEdit *where){ where->auto_fill_log();};static void edit_filter_sel_clicked(GtkWidget *parent,tDEdit *where){ where->init_filter_sel();};static void edit_filter_sel_ok(GtkWidget *parent,tDEdit *where){ where->filter_ok();};static gboolean edit_filter_sel_select(GtkTreeView *view,GdkEventButton *event, tDEdit *where) { if (event && event->type==GDK_2BUTTON_PRESS && event->button==1){ where->filter_ok(); return TRUE; }; return FALSE;};static void edit_filter_sel_cancel(GtkWidget *parent,tDEdit *where){ where->filter_cancel();};static void edit_filter_sel_delete(GtkWidget *parent, GdkEvent *event, tDEdit *where){ where->filter_cancel();};/******************************************************/tDEdit::tDEdit() { parent=NULL; window=NULL; proxy=NULL; filter_sel=NULL; parent_in_db=0; add_or_edit=dnd=limit=not_url_history=0;};void tDEdit::popup() { if (window) gdk_window_show(window->window);};tDownload *tDEdit::get_parent(){ return parent;};void tDEdit::set_parent(tDownload *what){ if (parent) parent->editor=NULL; if (what) what->editor=this; parent=what; };void tDEdit::set_path_as_default(){ if (CFG.GLOBAL_SAVE_PATH) delete[] CFG.GLOBAL_SAVE_PATH; CFG.GLOBAL_SAVE_PATH=normalize_path_full(text_from_combo(MY_GTK_FILESEL(path_entry)->combo));};void tDEdit::file_from_url(){ char *a=text_from_combo(url_entry); char *b=text_from_combo(MY_GTK_FILESEL(file_entry)->combo); if (a && *a && (b==NULL || *b==0)){ tAddr *adr=new tAddr(a); text_to_combo(MY_GTK_FILESEL(file_entry)->combo,adr->file.get()); delete(adr); };};void tDEdit::file_check(){ char *a=text_from_combo(MY_GTK_FILESEL(file_entry)->combo); char *b; if (a){ b=rindex(a,'/'); if (b){ a=copy_string(b+1); text_to_combo(MY_GTK_FILESEL(file_entry)->combo,a); delete[] a; }; }; b=text_from_combo(url_entry);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -