📄 fsched.cc
字号:
if (flag) what->editor->clear_url(); gtk_window_set_modal (GTK_WINDOW(what->editor->window),TRUE); gtk_window_set_transient_for (GTK_WINDOW (what->editor->window), GTK_WINDOW (editor)); g_signal_connect(G_OBJECT(what->editor->ok_button),"clicked", G_CALLBACK(my_gtk_aeditor_edit_ok), editor);};static void my_gtk_aeditor_browse_ok(GtkWidget *widget,MyGtkAEditor *editor){ text_to_combo(editor->path_entry, gtk_file_selection_get_filename(GTK_FILE_SELECTION(editor->browser))); gtk_widget_destroy(editor->browser);};static void my_gtk_aeditor_browse_cancel(GtkWidget *widget,MyGtkAEditor *editor){ gtk_widget_destroy(editor->browser); };static gint my_gtk_aeditor_browse_delete(GtkWidget *window,GdkEvent *event, MyGtkAEditor *editor) { gtk_widget_destroy(editor->browser); return TRUE;};static void my_gtk_aeditor_browse(GtkWidget *widget,MyGtkAEditor *editor){ GtkWidget *browser=gtk_file_selection_new(_("Select file")); char *tmp=text_from_combo(editor->path_entry); if (tmp && *tmp) gtk_file_selection_set_filename(GTK_FILE_SELECTION(browser),tmp); g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(browser)->ok_button), "clicked",G_CALLBACK(my_gtk_aeditor_browse_ok),editor); g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(browser)->cancel_button), "clicked",G_CALLBACK(my_gtk_aeditor_browse_cancel),editor); g_signal_connect(G_OBJECT(browser), "delete_event",G_CALLBACK(my_gtk_aeditor_browse_delete),editor); d4x_eschandler_init(GTK_WIDGET(browser),editor); editor->browser=browser; gtk_widget_show(browser); gtk_window_set_modal (GTK_WINDOW(browser),TRUE); gtk_window_set_transient_for (GTK_WINDOW (browser), GTK_WINDOW(editor));};static int _is_sa_url_(int type){ if (type==SACT_DELETE_DOWNLOAD || type==SACT_PAUSE_DOWNLOAD || type==SACT_RUN_DOWNLOAD || type==SACT_DEL_IF_COMPLETED) return(1); return(0);};static void aeditor_select_mode_int(MyGtkAEditor *editor,int i){ if (editor->last_action!=i){ switch(editor->last_action){ case SACT_RUN_DOWNLOAD: case SACT_PAUSE_DOWNLOAD: case SACT_DEL_IF_COMPLETED: case SACT_DELETE_DOWNLOAD:{ if (_is_sa_url_(i)){ editor->last_action=i; return; }; }; default: /* these actions have no properties */ if (editor->frame_child){ gtk_widget_destroy(editor->frame_child); }; break; }; switch(i){ case SACT_SET_SPEED:{ GtkWidget *hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(hbox),5); editor->frame_child=hbox; editor->sb_low=gtk_radio_button_new_with_label((GSList *)NULL, _(SPEED_LIMITATIONS_NAMES[1])); gtk_box_pack_start(GTK_BOX(hbox),editor->sb_low, FALSE,FALSE,0); GSList *group1=gtk_radio_button_get_group(GTK_RADIO_BUTTON(editor->sb_low)); editor->sb_middle=gtk_radio_button_new_with_label(group1, _(SPEED_LIMITATIONS_NAMES[2])); gtk_box_pack_start(GTK_BOX(hbox),editor->sb_middle, FALSE,FALSE,0); editor->sb_high=gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(editor->sb_middle)),_(SPEED_LIMITATIONS_NAMES[3])); gtk_box_pack_start(GTK_BOX(hbox), editor->sb_high,FALSE,FALSE,0); gtk_container_add(GTK_CONTAINER(editor->frame),hbox); if (editor->action){ d4xSASpeed *act=(d4xSASpeed *)(editor->action); if (act->speed==1) g_signal_emit_by_name(G_OBJECT(editor->sb_low), "clicked"); else g_signal_emit_by_name(act->speed==2?G_OBJECT(editor->sb_middle):G_OBJECT(editor->sb_high), "clicked"); }; break; }; case SACT_RUN_DOWNLOAD: case SACT_PAUSE_DOWNLOAD: case SACT_DEL_IF_COMPLETED: case SACT_DELETE_DOWNLOAD:{ editor->url_entry=my_gtk_combo_new(ALL_HISTORIES[URL_HISTORY]);//gtk_entry_new(); GtkWidget *hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(hbox),5); editor->frame_child=hbox; gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("URL:"), FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(hbox),editor->url_entry, TRUE,TRUE,0); gtk_container_add(GTK_CONTAINER(editor->frame),hbox); if (editor->action && _is_sa_url_(editor->action->type())){ d4xSAUrl *act=(d4xSAUrl *)(editor->action); if (act->url){ char *url=act->url->url(); text_to_combo(editor->url_entry,url); delete[] url; }; }; break; }; case SACT_ADD_DOWNLOAD:{ editor->url_entry=my_gtk_combo_new(ALL_HISTORIES[URL_HISTORY]);//gtk_entry_new(); GtkWidget *hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(hbox),5); editor->frame_child=hbox; gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("URL:"), FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(hbox),editor->url_entry, TRUE,TRUE,0); if (editor->dwn==NULL && editor->action && editor->action->type()==SACT_ADD_DOWNLOAD){ d4xSAAddDownload *a=(d4xSAAddDownload *)editor->action; editor->dwn=new tDownload; editor->dwn->copy(a->dwn); }; if (editor->dwn){ if (editor->dwn && editor->dwn->info){ char *url=editor->dwn->info->url(); text_to_combo(editor->url_entry,url); delete[] url; }else text_to_combo(editor->url_entry,""); }else text_to_combo(editor->url_entry,""); GtkWidget *button=gtk_button_new_with_label(_("Edit")); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(my_gtk_aeditor_edit_download), editor); gtk_box_pack_start(GTK_BOX(hbox),button, FALSE,FALSE,0); gtk_container_add(GTK_CONTAINER(editor->frame),hbox); break; }; case SACT_EXECUTE:{ editor->path_entry=gtk_entry_new(); GtkWidget *hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(hbox),5); editor->frame_child=hbox; gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Command:")), FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(hbox),editor->path_entry, TRUE,TRUE,0); GtkWidget *button=gtk_button_new_with_label(_("Browse")); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(my_gtk_aeditor_browse),editor); gtk_box_pack_start(GTK_BOX(hbox),button, FALSE,FALSE,0); gtk_container_add(GTK_CONTAINER(editor->frame),hbox); if (editor->action && editor->action->type()==SACT_EXECUTE){ d4xSAExecute *a=(d4xSAExecute *)editor->action; text_to_combo(editor->path_entry,a->command.get()); }else text_to_combo(editor->path_entry,""); break; }; case SACT_SAVE_LIST:{ editor->path_entry=my_gtk_combo_new(ALL_HISTORIES[LOAD_SAVE_HISTORY]);//gtk_entry_new(); GtkWidget *hbox=gtk_hbox_new(FALSE,0); gtk_box_set_spacing(GTK_BOX(hbox),5); editor->frame_child=hbox; gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Path:")), FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(hbox),editor->path_entry, TRUE,TRUE,0); GtkWidget *button=gtk_button_new_with_label(_("Browse")); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(my_gtk_aeditor_browse),editor); gtk_box_pack_start(GTK_BOX(hbox),button, FALSE,FALSE,0); gtk_container_add(GTK_CONTAINER(editor->frame),hbox);// gtk_container_add(GTK_CONTAINER(editor->frame),editor->path_entry); if (editor->action && editor->action->type()==SACT_SAVE_LIST){ d4xSASaveList *a=(d4xSASaveList *)editor->action; text_to_combo(editor->path_entry,a->path.get()); }else text_to_combo(editor->path_entry,""); break; }; default: editor->frame_child=gtk_label_new(_("This action has no properties")); gtk_container_add(GTK_CONTAINER(editor->frame), editor->frame_child); break; }; editor->last_action=i; gtk_widget_show_all(editor->frame_child); };};static void aeditor_select_mode(GtkWidget *widget,MyGtkAEditor *editor){ GSList *group=gtk_radio_menu_item_get_group((GtkRadioMenuItem *)widget); int i=0; while(group && !((GtkCheckMenuItem *)(group->data))->active){ group = group->next; i++; }; i=SACT_LAST-i-1; aeditor_select_mode_int(editor,i);};static GtkWidget *my_option_menu (char *labels[], gint num_items, gint active, gpointer data){ GtkWidget *omenu; GtkWidget *menu; GtkWidget *menu_item; GSList *group; gint i; omenu = gtk_option_menu_new(); menu = gtk_menu_new (); group = (GSList *)NULL; for (i = 0; i < num_items; i++){ menu_item = gtk_radio_menu_item_new_with_label (group, _(labels[i])); g_signal_connect(G_OBJECT (menu_item), "activate", (GtkSignalFunc)aeditor_select_mode, data); group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); if (i == active) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE); gtk_widget_show (menu_item); }; gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active); return omenu;};static void my_gtk_aeditor_destroy(GtkObject *widget){ g_return_if_fail(widget!=NULL); MyGtkAEditor *editor=MY_GTK_AEDITOR(widget); if (editor->dwn) delete(editor->dwn); if (editor->action) editor->action->lock=0; if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (widget);};static void my_gtk_aeditor_class_init(MyGtkAEditorClass *klass){ GtkObjectClass *object_class=(GtkObjectClass *)klass; object_class->destroy=my_gtk_aeditor_destroy; parent_class=(GtkWidgetClass *)gtk_type_class(gtk_window_get_type());};static void my_gtk_aeditor_ok(GtkWidget *widget,MyGtkAEditor *editor){ if (editor->action){ MainScheduler->del_action(editor->action); delete(editor->action); }; time_t start_time; time_t period=0; int retries=0; /* preparing time */ time_t NOW=time((time_t*)NULL); struct tm date; date.tm_isdst=-1; localtime_r(&NOW,&date); sscanf(text_from_combo(editor->hour),"%i",&date.tm_hour); sscanf(text_from_combo(editor->min),"%i",&date.tm_min); sscanf(text_from_combo(editor->sec),"%i",&date.tm_sec); gtk_calendar_get_date(GTK_CALENDAR(editor->calendar), (guint *)&date.tm_year, (guint *)&date.tm_mon, (guint *)&date.tm_mday); date.tm_year-=1900; start_time=mktime(&date); if (GTK_TOGGLE_BUTTON(editor->retry)->active){ int days,hours,mins; sscanf(text_from_combo(editor->retry_times),"%i",&retries); sscanf(text_from_combo(editor->period_days),"%i",&days); sscanf(text_from_combo(editor->period_hours),"%i",&hours); sscanf(text_from_combo(editor->period_mins),"%i",&mins); period=days*24*3600+hours*3600+mins*60; if (period==0) period=60; }else{ retries=0; };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -