📄 dccgui.c
字号:
xchat_exec (tmp); free (tmp); } free (mime_prog); } } } }}#endifstatic voidrecv_row_selected (GtkWidget * clist, gint row, gint column, GdkEventButton * even){ if (even && even->type == GDK_2BUTTON_PRESS) accept_clicked (0, 0);}voidfe_dcc_open_recv_win (int passive){ GtkWidget *vbox, *bbox;#ifdef USE_GNOME gchar *titles[] = { _("Status"), _("File"), _("Size"), _("Position"), "%", _("CPS"), _("ETA"), _("From"), _("MIME Type") };#else gchar *titles[] = { _("Status"), _("File"), _("Size"), _("Position"), "%", _("CPS"), _("ETA"), _("From") };#endif if (dccrwin.window) { fe_dcc_update_recv_win (); if (!passive) wins_bring_tofront (dccrwin.window); return; } dccrwin.window = maingui_window ("dccrecv", _("X-Chat: File Receive List"), FALSE, TRUE, close_dcc_recv_window, NULL, 601, 0, &dccrwin.window); vbox = wins_get_vbox (dccrwin.window);#ifdef USE_GNOME dccrwin.list = gtkutil_clist_new (9, titles, vbox, GTK_POLICY_ALWAYS, recv_row_selected, 0, 0, 0, GTK_SELECTION_SINGLE);#else dccrwin.list = gtkutil_clist_new (8, titles, vbox, GTK_POLICY_ALWAYS, recv_row_selected, 0, 0, 0, GTK_SELECTION_SINGLE);#endif gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 0, 65); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 1, 100); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 2, 50); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 3, 50); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 4, 30); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 5, 50); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 6, 60); gtk_clist_set_column_width (GTK_CLIST (dccrwin.list), 7, 60); gtk_clist_set_column_justification (GTK_CLIST (dccrwin.list), 4, GTK_JUSTIFY_CENTER); bbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 2); gtk_widget_show (bbox); gtkutil_button (dccrwin.window, 0, _("Accept"), accept_clicked, 0, bbox); gtkutil_button (dccrwin.window, 0, _("Resume"), resume_clicked, 0, bbox); gtkutil_button (dccrwin.window, 0, _("Abort"), abort_clicked, 0, bbox); gtkutil_button (dccrwin.window, 0, _("Info"), info_clicked, 0, bbox);#ifdef USE_GNOME gtkutil_button (dccrwin.window, 0, _("Open"), open_clicked, 0, bbox);#endif gtk_widget_show (dccrwin.window); fe_dcc_update_recv_win ();}static voidclose_dcc_send_window (void){ dccswin.window = 0;}voidfe_dcc_update_send_win (void){ struct DCC *dcc; GSList *list = dcc_list; gchar *nnew[9]; char size[14]; char pos[14]; char cps[14]; char ack[14]; char perc[14]; char eta[14]; gint row; int selrow; int to_go; float per; if (!dccswin.window) return; selrow = gtkutil_clist_selection (dccswin.list); gtk_clist_clear ((GtkCList *) dccswin.list); nnew[2] = size; nnew[3] = pos; nnew[4] = ack; nnew[5] = perc; nnew[6] = cps; while (list) { nnew[7] = eta; dcc = (struct DCC *) list->data; if (dcc->type == TYPE_SEND) { nnew[0] = _(dccstat[(int) dcc->dccstat].name); nnew[1] = file_part (dcc->file); nnew[8] = dcc->nick; /* percentage ack'ed */ per = (float) ((dcc->ack * 100.00) / dcc->size); snprintf (size, sizeof (size), "%d", dcc->size); snprintf (pos, sizeof (pos), "%d", dcc->pos); snprintf (cps, sizeof (cps), "%d", dcc->cps); snprintf (perc, sizeof (perc), "%.0f%%", per); snprintf (ack, sizeof (ack), "%d", dcc->ack); if (dcc->cps != 0) { to_go = (dcc->size - dcc->ack) / dcc->cps; snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", to_go / 3600, (to_go / 60) % 60, to_go % 60); } else strcpy (eta, "--:--:--"); row = gtk_clist_append (GTK_CLIST (dccswin.list), nnew); gtk_clist_set_row_data (GTK_CLIST (dccswin.list), row, (gpointer) dcc); if (dccstat[(int) dcc->dccstat].color != 1) gtk_clist_set_foreground (GTK_CLIST (dccswin.list), row, colors + dccstat[(int) dcc->dccstat].color); } list = list->next; } if (selrow != -1) gtk_clist_select_row ((GtkCList *) dccswin.list, selrow, 0);}static voidsend_row_selected (GtkWidget * clist, gint row, gint column, GdkEventButton * even){ struct DCC *dcc; if (even && even->type == GDK_2BUTTON_PRESS) { dcc = gtk_clist_get_row_data (GTK_CLIST (clist), row); if (dcc) { switch (dcc->dccstat) { case STAT_FAILED: case STAT_ABORTED: case STAT_DONE: dcc_abort (dcc); } } }}static voidinfo_send_clicked (GtkWidget * wid, gpointer none){ int row; struct DCC *dcc; row = gtkutil_clist_selection (dccswin.list); if (row != -1) { dcc = gtk_clist_get_row_data (GTK_CLIST (dccswin.list), row); if (dcc) dcc_info (dcc); }}static voidabort_send_clicked (GtkWidget * wid, gpointer none){ int row; struct DCC *dcc; row = gtkutil_clist_selection (dccswin.list); if (row != -1) { dcc = gtk_clist_get_row_data (GTK_CLIST (dccswin.list), row); dcc_abort (dcc); }}voidfe_dcc_open_send_win (int passive){ GtkWidget *vbox, *bbox; gchar *titles[] = { _("Status"), _("File"), _("Size"), _("Position"), _("Ack"), "%", _("CPS"), _("ETA"), _("To") }; if (dccswin.window) { fe_dcc_update_send_win (); if (!passive) wins_bring_tofront (dccswin.window); return; } dccswin.window = maingui_window ("dccsend", _("X-Chat: File Send List"), FALSE, TRUE, close_dcc_send_window, NULL, 595, 0, &dccswin.window); vbox = wins_get_vbox (dccswin.window); dccswin.list = gtkutil_clist_new (9, titles, vbox, GTK_POLICY_ALWAYS, send_row_selected, 0, 0, 0, GTK_SELECTION_SINGLE); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 0, 65); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 1, 100); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 2, 50); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 3, 50); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 4, 50); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 5, 30); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 6, 50); gtk_clist_set_column_width (GTK_CLIST (dccswin.list), 7, 50); gtk_clist_set_column_justification (GTK_CLIST (dccswin.list), 5, GTK_JUSTIFY_CENTER); bbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 2); gtk_widget_show (bbox); gtkutil_button (dccswin.window, 0, _("Abort"), abort_send_clicked, 0, bbox); gtkutil_button (dccswin.window, 0, _("Info"), info_send_clicked, 0, bbox); gtk_widget_show (dccswin.window); fe_dcc_update_send_win ();}/* DCC CHAT GUIs BELOW */static voidaccept_chat_clicked (GtkWidget * wid, gpointer none){ int row; struct DCC *dcc; row = gtkutil_clist_selection (dcccwin.list); if (row != -1) { dcc = gtk_clist_get_row_data (GTK_CLIST (dcccwin.list), row); gtk_clist_unselect_row (GTK_CLIST (dcccwin.list), row, 0); dcc_get (dcc); }}static voidabort_chat_clicked (GtkWidget * wid, gpointer none){ int row; struct DCC *dcc; row = gtkutil_clist_selection (dcccwin.list); if (row != -1) { dcc = gtk_clist_get_row_data (GTK_CLIST (dcccwin.list), row); dcc_abort (dcc); }}static voidchat_row_selected (GtkWidget * clist, gint row, gint column, GdkEventButton * even){ if (even && even->type == GDK_2BUTTON_PRESS) accept_chat_clicked (0, 0);}voidfe_dcc_update_chat_win (void){ struct DCC *dcc; GSList *list = dcc_list; gchar *nnew[5]; char pos[14]; char siz[14]; gint row; int selrow; if (!dcccwin.window) return; selrow = gtkutil_clist_selection (dcccwin.list); gtk_clist_clear ((GtkCList *) dcccwin.list); nnew[2] = pos; nnew[3] = siz; while (list) { dcc = (struct DCC *) list->data; if ((dcc->type == TYPE_CHATSEND || dcc->type == TYPE_CHATRECV)) { nnew[0] = _(dccstat[(int) dcc->dccstat].name); nnew[1] = dcc->nick; sprintf (pos, "%d", dcc->pos); sprintf (siz, "%d", dcc->size); nnew[4] = ctime (&dcc->starttime); row = gtk_clist_append (GTK_CLIST (dcccwin.list), nnew); gtk_clist_set_row_data (GTK_CLIST (dcccwin.list), row, (gpointer) dcc); } list = list->next; } if (selrow != -1) gtk_clist_select_row ((GtkCList *) dcccwin.list, selrow, 0);}static voidclose_dcc_chat_window (void){ dcccwin.window = 0;}voidfe_dcc_open_chat_win (int passive){ GtkWidget *vbox, *bbox; gchar *titles[] = { _("Status"), _("To/From"), _("Recv"), _("Sent"), _("StartTime") }; if (dcccwin.window) { fe_dcc_update_chat_win (); if (!passive) wins_bring_tofront (dcccwin.window); return; } dcccwin.window = maingui_window ("dccchat", _("X-Chat: DCC Chat List"), FALSE, TRUE, close_dcc_chat_window, NULL, 550, 0, &dcccwin.window); vbox = wins_get_vbox (dcccwin.window); dcccwin.list = gtkutil_clist_new (5, titles, vbox, GTK_POLICY_ALWAYS, chat_row_selected, 0, 0, 0, GTK_SELECTION_BROWSE); gtk_clist_set_column_width (GTK_CLIST (dcccwin.list), 0, 65); gtk_clist_set_column_width (GTK_CLIST (dcccwin.list), 1, 100); gtk_clist_set_column_width (GTK_CLIST (dcccwin.list), 2, 65); gtk_clist_set_column_width (GTK_CLIST (dcccwin.list), 3, 65); bbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 2); gtk_widget_show (bbox); gtkutil_button (dcccwin.window, 0, _("Accept"), accept_chat_clicked, 0, bbox); gtkutil_button (dcccwin.window, 0, _("Abort"), abort_chat_clicked, 0, bbox); gtk_widget_show (dcccwin.window); fe_dcc_update_chat_win ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -