static int scroll_buttons_callback (SsdWidget widget, const char *new_value) { if (!strcmp(widget->name, "scroll_up")) { scroll_page_up(); return 0; } if (!strcmp( widget->name, "scroll_down")) { scroll_page_down(); return 0; } return 1; }
void msg_list_window::add_msgs_page(const msgs_filter* f, bool if_results _UNUSED_) { m_filter = new msgs_filter(*f); QFont body_font; QFont list_font; QByteArray headerview_setup; msgs_page* current = m_pages->current_page(); // current may be null if we're instantiating the first page if (current) { body_font = m_msgview->font(); list_font = m_qlist->font(); if (m_qlist->sender_recipient_swapped()) m_qlist->swap_sender_recipient(false); headerview_setup = m_qlist->header()->saveState(); } // new splitter QStackedWidget* stackw = m_pages->stacked_widget(); QSplitter* l=new QSplitter(Qt::Vertical, this); stackw->addWidget(l); m_qlist = new mail_listview(l); m_qlist->set_threaded(display_vars.m_threaded); m_qlist->m_msg_window=this; if (current) m_qlist->setFont(list_font); m_qlist->init_columns(); if (current) m_qlist->header()->restoreState(headerview_setup); if (!m_filter->m_fetched) m_filter->fetch(m_qlist); else m_filter->make_list(m_qlist); msg_list_postprocess(); m_msgview = new message_view(l, this); if (current) m_msgview->setFont(body_font); connect(m_msgview, SIGNAL(on_demand_show_request()), this, SLOT(display_msg_contents())); connect(m_msgview, SIGNAL(popup_body_context_menu()), this, SLOT(body_menu())); connect(m_msgview, SIGNAL(page_back()), this, SLOT(move_backward())); connect(m_msgview, SIGNAL(page_forward()), this, SLOT(move_forward())); m_qAttch = new attch_listview(l); connect(m_qAttch, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(attch_selected(QTreeWidgetItem*,int))); connect(m_qAttch, SIGNAL(init_progress(const QString)), this, SLOT(install_progressbar(const QString))); connect(m_qAttch, SIGNAL(progress(int)), this, SLOT(show_progress(int))); connect(m_qAttch, SIGNAL(finish_progress()), this, SLOT(uninstall_progressbar())); connect(this, SIGNAL(abort_progress()), m_qAttch, SLOT(download_aborted())); // splitter for 3 panes: list of messages / body / attachments list static const int splitter_default_sizes[3] = {100,400,25}; QList<int> lsizes; if (current) { lsizes = current->m_page_splitter->sizes(); // don't allow any zero size for panels. This is necessary to avoid having the // attachment list being almost invisible to the user for (int i=0; i<3; i++) { if (lsizes.at(i)==0) { lsizes.replace(i, splitter_default_sizes[i]); } } } else { for (int i=0; i<3; i++) { int sz; QString key; key.sprintf("display/msglist/panel%d_size", i+1); if (get_config().exists(key)) { sz=get_config().get_number(key); if (sz==0) sz=splitter_default_sizes[i]; } else sz=splitter_default_sizes[i]; lsizes.append(sz); } } /* avoid changing the listview's height each time the attachments view is shown or hidden */ l->setStretchFactor(l->indexOf(m_qlist), 0); l->setStretchFactor(l->indexOf(m_msgview), 1); l->setStretchFactor(l->indexOf(m_qAttch), 0); l->setSizes(lsizes); m_qAttch->hide(); m_wSearch=NULL; connect(m_qlist,SIGNAL(selection_changed()), this,SLOT(mails_selected())); connect(m_qlist,SIGNAL(doubleClicked(const QModelIndex&)), this,SLOT(mail_reply_all())); connect(m_qlist, SIGNAL(clicked(const QModelIndex&)), this, SLOT(action_click_msg_list(const QModelIndex&))); connect(m_qlist, SIGNAL(scroll_page_down()), m_msgview, SLOT(page_down())); if (m_pages->next_page()) { // we're in the middle of a page list, and asked to go forward. // let's remove all the pages that are after the current position m_pages->cut_pages(m_pages->next_page()); } int max_pages=get_config().get_number("msg_window_pages"); if (max_pages<2) max_pages=2; if (m_pages->count() >= max_pages) { free_msgs_page(); if (m_pages->count() >= max_pages) { // Still no room for a new page? OK, forget it DBG_PRINTF(5,"not enough pages!"); return; } } // allocate and use a new page msgs_page* page = new msgs_page(); page->m_page_filter = m_filter; page->m_page_msgview = m_msgview; page->m_page_attach = m_qAttch; page->m_page_qlist = m_qlist; page->m_page_current_item = NULL; page->m_page_splitter = l; page->m_msgs_window = this; page->m_query_lvitem_id = m_query_lv->current_id(); m_pages->add_page(page); m_pages->raise_page(page); m_tags_box->reset_tags(); enable_forward_backward(); }
/* Handle a key press. Assumes that a key has been pressed and is * ready to read (will block otherwise). * Return 1 if 'q' (quit). */ static int handle_key() { int c; c = getch(); if (c == 'q') ; /* nothing */ else if (c == 'g') options.debug = 1 - options.debug; else if (c == 'c') options.show_cmdline = 1 - options.show_cmdline; else if ((c == 'd') || (c == 's')) { mvprintw(2, 0, "Change delay from %.2f to: ", options.delay); echo(); nocbreak(); scanw("%f", &options.delay); if (options.delay < 0.01) options.delay = 1.0; tv.tv_sec = options.delay; tv.tv_usec = (options.delay - tv.tv_sec)*1000000.0; cbreak(); noecho(); } else if (c == 'H') { options.show_threads = 1 - options.show_threads; } else if (c == 'i') options.idle = 1 - options.idle; else if (c == 'K') { if (options.show_kernel) { options.show_kernel = 0; message = "Kernel mode Off"; } else { if ((options.euid == 0) || (options.paranoia_level < 2)) { options.show_kernel = 1; message = "Kernel mode On"; } else { message = "Kernel mode not available (not root and paranoia level too high)."; c = ' '; /* do not return the 'K' to the upper level, since it was ignored. */ } } } else if (c == 'k') { /* initialize string to 0s */ char str[10] = { 0 }; int kill_pid, kill_sig, kill_res; mvprintw(2, 0, "PID to kill: "); echo(); nocbreak(); getnstr(str, sizeof(str) - 1); if (!isdigit(str[0])) message = "Not valid"; else { kill_pid = atoi(str); mvprintw(2, 0, "Kill PID %d with signal [15]: ", kill_pid); getnstr(str, sizeof(str) - 1); kill_sig = atoi(str); if (kill_sig == 0) kill_sig = 15; kill_res = kill(kill_pid, kill_sig); if (kill_res == -1) { char tmp_message[100]; snprintf(tmp_message, sizeof(tmp_message), "Kill of PID '%d' with '%d' failed: %s", kill_pid, kill_sig, strerror(errno)); message = tmp_message; } } cbreak(); noecho(); } else if (c == 'p') { char str[100] = { 0 }; /* initialize string to 0s */ mvprintw(2, 0, "Only display process: "); echo(); nocbreak(); getnstr(str, sizeof(str)-1); /* keep final '\0' as string delimiter */ options.only_pid = atoi(str); if (options.only_name) { free(options.only_name); options.only_name = NULL; } if (!options.only_pid && strcmp(str, "")) { options.only_name = strdup(str); } cbreak(); noecho(); } else if (c == 'R') sorting_order = (enum sorting_order) (1 - (int)sorting_order); else if (c == 'S') options.sticky = 1 - options.sticky; else if (c == 'U') options.show_user = 1 - options.show_user; else if (c == 'u') { char str[100] = { 0 }; /* initialize string to 0s */ mvprintw(2, 0, "Which user (blank for all): "); echo(); nocbreak(); getnstr(str, sizeof(str) - 1); /* keep final '\0' as string delimiter */ cbreak(); noecho(); if (str[0] == '\0') /* blank */ options.watch_uid = -1; else if (isdigit(str[0])) options.watch_uid = atoi(str); else { struct passwd* passwd; passwd = getpwnam(str); if (passwd) options.watch_uid = passwd->pw_uid; else message = "User name does not exist."; } } else if (c == 'w') { char str[100] = { 0 }; /* initialize string to 0s */ mvprintw(2, 0, "Watch process: "); echo(); nocbreak(); getnstr(str, sizeof(str)-1); /* keep final '\0' as string delimiter */ options.watch_pid = atoi(str); if (options.watch_name) { free(options.watch_name); options.watch_name = NULL; } if (!options.watch_pid && strcmp(str, "")) { options.watch_name = strdup(str); } cbreak(); noecho(); } else if (c == 'h') options.help = 1 - options.help; else if (c == 'W') { if (export_screens(&options) < 0) message = ".tiptoprc not written: already exists in current directory?"; else message = ".tiptoprc written"; } else if (c == KEY_UP) scroll_up(); else if (c == KEY_PPAGE) scroll_page_up(); else if (c == KEY_DOWN) scroll_down(); else if (c == KEY_NPAGE) scroll_page_down(); else if (c == KEY_HOME) scroll_home(); else if (c == KEY_END) scroll_end(); return c; }