📄 edit.cc
字号:
gtk_box_set_spacing(GTK_BOX(http_hbox),5); other_label=gtk_label_new(_("Filter")); GtkWidget *button=gtk_button_new_with_label(_("Select")); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(edit_filter_sel_clicked),this); gtk_box_pack_start(GTK_BOX(http_hbox),other_label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(http_hbox),filter,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(http_hbox),button,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(http_vbox),http_hbox,FALSE,FALSE,0); GtkWidget *user_agent_label=gtk_label_new(_("User-Agent")); GtkWidget *user_agent_box=gtk_vbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(user_agent_box),5); user_agent_entry=my_gtk_combo_new(ALL_HISTORIES[USER_AGENT_HISTORY]); if (who->config->user_agent.get()) text_to_combo(user_agent_entry,who->config->user_agent.get()); gtk_box_pack_start(GTK_BOX(user_agent_box),user_agent_label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(user_agent_box),user_agent_entry,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(http_vbox),user_agent_box,FALSE,FALSE,0); GtkWidget *label=gtk_label_new(_("Referer")); GtkWidget *vbox=gtk_vbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(user_agent_box),5); referer_entry=my_gtk_combo_new(ALL_HISTORIES[REFERER_HISTORY]); if (who->config->referer.get()) text_to_combo(referer_entry,who->config->referer.get()); else text_to_combo(referer_entry,""); gtk_box_pack_start(GTK_BOX(vbox),label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(vbox),referer_entry,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(http_vbox),vbox,FALSE,FALSE,0); label=gtk_label_new(_("Cookie")); vbox=gtk_vbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(user_agent_box),5); cookie_entry=my_gtk_combo_new(ALL_HISTORIES[COOKIE_HISTORY]); if (who->config->cookie.get()) text_to_combo(cookie_entry,who->config->cookie.get()); else text_to_combo(cookie_entry,""); gtk_box_pack_start(GTK_BOX(vbox),label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(vbox),cookie_entry,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(http_vbox),vbox,FALSE,FALSE,0); http_frame=gtk_frame_new("HTTP"); gtk_container_set_border_width(GTK_CONTAINER(http_frame),5); gtk_container_add(GTK_CONTAINER(http_frame),http_vbox); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),http_frame,gtk_label_new("HTTP")); };void tDEdit::init_time(tDownload *who){ /* Init time */ GtkWidget *time_frame=gtk_frame_new(_("Time")); GtkWidget *time_hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(time_hbox),5); GtkWidget *time_label,*time_vbox; gtk_container_set_border_width(GTK_CONTAINER(time_frame),5); calendar=gtk_calendar_new(); gtk_calendar_display_options(GTK_CALENDAR(calendar), GtkCalendarDisplayOptions( GTK_CALENDAR_WEEK_START_MONDAY | GTK_CALENDAR_SHOW_DAY_NAMES| GTK_CALENDAR_SHOW_HEADING)); gtk_box_pack_start(GTK_BOX(time_hbox),calendar,FALSE,FALSE,0); hour_entry=my_gtk_combo_new(0,23); time_label=gtk_label_new(_("Hours")); time_vbox=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),time_label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),hour_entry,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),gtk_vbox_new(FALSE,0),TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(time_hbox),time_vbox,FALSE,FALSE,0); minute_entry=my_gtk_combo_new(0,59); time_label=gtk_label_new(_("Minutes")); time_vbox=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),time_label,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),minute_entry,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),gtk_vbox_new(FALSE,0),TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(time_hbox),time_vbox,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_hbox),gtk_hbox_new(FALSE,0),TRUE,TRUE,0); gtk_widget_set_size_request(hour_entry,60,-1); gtk_widget_set_size_request(minute_entry,60,-1); time_vbox=gtk_vbox_new(FALSE,0); time_check=gtk_check_button_new_with_label(_("Start this downloading at:")); g_signal_connect(G_OBJECT(time_check),"clicked",G_CALLBACK(edit_time_check_clicked),this); gtk_box_pack_start(GTK_BOX(time_vbox),time_check,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),time_hbox,FALSE,FALSE,0); time_hbox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(time_vbox),time_hbox,TRUE,TRUE,0); gtk_container_add(GTK_CONTAINER(time_frame),time_vbox); setup_time(who->ScheduleTime); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),time_frame,gtk_label_new(_("Time")));};void tDEdit::init(tDownload *who) { if (!who) return; parent=who; window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass(GTK_WINDOW(window), "D4X_Download","D4X"); gtk_container_set_border_width(GTK_CONTAINER(window),5); gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); // gtk_widget_set_size_request(window,470,255); g_object_set_data(G_OBJECT(window),"d4x_user_data",this); notebook=gtk_notebook_new(); init_main(who); init_other(who); init_ftp(who); init_http(who); /* init proxies */ proxy=new tProxyWidget; proxy->init(); proxy->init_state(); switch(who->info->proto){ case D_PROTO_FTP:{ proxy->init_state(who->config,1); break; }; case D_PROTO_HTTP:{ proxy->init_state(who->config,0); break; }; }; /* initing window */ GtkWidget *vbox2=gtk_vbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(vbox2),5); GtkWidget *proxy_frame=gtk_frame_new(_("Proxy")); gtk_container_set_border_width(GTK_CONTAINER(proxy_frame),5); gtk_container_add(GTK_CONTAINER(proxy_frame),proxy->frame); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),proxy_frame,gtk_label_new(_("Proxy"))); init_time(who); gtk_box_pack_start(GTK_BOX(vbox2),notebook,FALSE,FALSE,0); /* initing buttons */ GtkWidget *buttons_hbox=gtk_hbutton_box_new(); gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons_hbox),GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(buttons_hbox),5); isdefault_check=gtk_check_button_new_with_label(_("Use default settings")); g_signal_connect(G_OBJECT(isdefault_check),"clicked", G_CALLBACK(edit_isdefault_check_clicked),this); GTK_TOGGLE_BUTTON(isdefault_check)->active=who->config->isdefault; toggle_isdefault(); ok_button=gtk_button_new_with_label(_("Ok")); cancel_button=gtk_button_new_with_label(_("Cancel")); GTK_WIDGET_SET_FLAGS(ok_button,GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(cancel_button,GTK_CAN_DEFAULT); GtkWidget *hbox_temp=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(hbox_temp),isdefault_check,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(buttons_hbox),ok_button,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(buttons_hbox),cancel_button,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(hbox_temp),buttons_hbox,FALSE,FALSE,0); gtk_box_pack_end(GTK_BOX(vbox2),hbox_temp,FALSE,FALSE,0); gtk_container_add(GTK_CONTAINER(window),vbox2); gtk_window_set_default(GTK_WINDOW(window),ok_button); gtk_widget_show_all(window); gtk_widget_grab_focus(GTK_COMBO(url_entry)->entry); setup_entries();};void tDEdit::init_filter_sel(){ if (filter_sel){ gdk_window_show(GTK_WIDGET(filter_sel)->window); return; }; filter_sel=(d4xFilterSel*)d4x_filter_sel_new(); g_signal_connect(G_OBJECT(filter_sel->view), "event", G_CALLBACK(edit_filter_sel_select), this); g_signal_connect(G_OBJECT(filter_sel->ok), "clicked", G_CALLBACK(edit_filter_sel_ok), this); g_signal_connect(G_OBJECT(filter_sel->cancel), "clicked", G_CALLBACK(edit_filter_sel_cancel), this); g_signal_connect(G_OBJECT(filter_sel), "delete_event", G_CALLBACK(edit_filter_sel_delete), this); d4x_eschandler_init(GTK_WIDGET(filter_sel),this);};void tDEdit::filter_ok(){ d4x_filter_sel_to_combo(filter_sel,filter); filter_cancel();};void tDEdit::filter_cancel(){ gtk_widget_destroy(GTK_WIDGET(filter_sel)); filter_sel=NULL;};void tDEdit::auto_fill_log(){ tAddr *tmp=new tAddr(text_from_combo(url_entry)); char *filename=tmp->file.get(); char *savepath=text_from_combo(MY_GTK_FILESEL(path_entry)->combo); if (filename && *filename && savepath && *savepath){ filename=sum_strings(savepath,"/",filename,"_log",NULL); normalize_path(filename); text_to_combo(MY_GTK_FILESEL(log_save_entry)->combo,filename); delete[] filename; }; delete(tmp);};int tDEdit::get_pause_check(){ return(GTK_TOGGLE_BUTTON(pause_check)->active);};int tDEdit::get_to_top_check(){ if (to_top_check) return(GTK_TOGGLE_BUTTON(to_top_check)->active); return(0);};void tDEdit::disable_ok_button() { if (window) gtk_widget_set_sensitive(ok_button,FALSE);};void tDEdit::enable_ok_button() { if (window) gtk_widget_set_sensitive(ok_button,TRUE);};int tDEdit::apply_changes() { CFG.USE_DEFAULT_CFG=parent->config->isdefault=GTK_TOGGLE_BUTTON(isdefault_check)->active; char *temp=copy_string(text_from_combo(url_entry)); del_crlf(temp); tAddr *addr=new tAddr(temp); delete[] temp; if (!addr) return 1; if (parent_in_db) ALL_DOWNLOADS->del(parent); delete (parent->info); parent->info=addr; if (parent_in_db) ALL_DOWNLOADS->insert(parent); if (parent->ALTS) parent->ALTS->check(addr->file.get()); FaceForPasswords->stop_matched(parent); switch(parent->info->proto){ case D_PROTO_FTP:{ proxy->apply_changes(parent->config,1); break; }; case D_PROTO_HTTP:{ proxy->apply_changes(parent->config,0); break; }; }; char *pass_string=text_from_combo(pass_entry); if (GTK_TOGGLE_BUTTON(use_pass_check)->active) { if (strlen(text_from_combo(user_entry))) { parent->info->username.set(text_from_combo(user_entry)); ALL_HISTORIES[USER_HISTORY]->add(parent->info->username.get()); parent->info->pass.set(pass_string); if (CFG.REMEMBER_PASS) ALL_HISTORIES[PASS_HISTORY]->add(pass_string); }; }; char *sp=normalize_path_full(text_from_combo(MY_GTK_FILESEL(path_entry)->combo)); parent->config->save_path.set(sp); parent->Name2Save.set(NULL); if (strlen(text_from_combo(MY_GTK_FILESEL(file_entry)->combo))) parent->Name2Save.set(text_from_combo(MY_GTK_FILESEL(file_entry)->combo)); if (parent->Name2Save.get()) ALL_HISTORIES[FILE_HISTORY]->add(parent->Name2Save.get()); normalize_path(parent->config->save_path.get()); ALL_HISTORIES[PATH_HISTORY]->add(sp); delete[] sp; parent->status=0; if (strlen(parent->info->file.get())==0) { parent->finfo.type=T_DIR; parent->finfo.size=0; } else { parent->finfo.type=0; parent->finfo.size=-1; }; /* change histories */ parent->config->user_agent.set(text_from_combo(user_agent_entry)); char *URL=parent->info->url_parsed(); if (!not_url_history) ALL_HISTORIES[URL_HISTORY]->add(URL); ALL_HISTORIES[USER_AGENT_HISTORY]->add(parent->config->user_agent.get()); char *referer=text_from_combo(referer_entry); if (referer && *referer){ parent->config->referer.set(referer); ALL_HISTORIES[REFERER_HISTORY]->add(referer); }else parent->config->referer.set(NULL); referer=text_from_combo(cookie_entry); if (referer && *referer){ parent->config->cookie.set(referer); ALL_HISTORIES[COOKIE_HISTORY]->add(referer); }else parent->config->cookie.set(NULL); char *save_log=text_from_combo(MY_GTK_FILESEL(log_save_entry)->combo); if (save_log && *save_log){ char *t=normalize_path_full(save_log); ALL_HISTORIES[LOG_SAVE_HISTORY]->add(t); parent->config->log_save_path.set(t); delete[] t; }else parent->config->log_save_path.set(NULL); char *desc=text_from_combo(desc_entry); if (desc && *desc){ ALL_HISTORIES[DESC_HISTORY]->add(desc); parent->Description.set(desc); }else parent->Description.set(NULL); desc=text_from_combo(filter); if (desc && *desc){ parent->config->Filter.set(desc); }else parent->config->Filter.set(NULL); /*change data in list if available */ if (parent_in_db){ D4X_QUEUE->qv.change_data(parent->list_iter,URL_COL,URL); D4X_QUEUE->qv.set_filename(parent); for (int i=FILE_TYPE_COL;i<URL_COL;i++) if (i!=PERCENT_COL) D4X_QUEUE->qv.change_data(parent->list_iter,i,""); }; delete[] URL; int temp1=0; sscanf(gtk_entry_get_text(GTK_ENTRY(timeout_entry)),"%u",&temp1); if (temp1>0 && temp1<1000) parent->config->timeout=temp1; sscanf(gtk_entry_get_text(GTK_ENTRY(sleep_entry)),"%u",&temp1); if (temp1>=0 && temp1<1000) parent->config->time_for_sleep=temp1; sscanf(gtk_entry_get_text(GTK_ENTRY(attempts_entry)),"%u",&temp1); if (temp1>=0) parent->config->number_of_attempts=temp1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -