⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file_list.cpp

📁 linux pritner GUI
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2001 2002 2003 Chris VineThis program is distributed under the General Public Licence, version 2.For particulars of this and relevant disclaimers see the fileCOPYING distributed with the source files.*/#include <sys/types.h>#include <unistd.h>#include <cstdlib>#include <vector>#include <string>#include <gdkmm/pixbuf.h>#include <gtkmm/image.h>#include <gtkmm/stock.h>#include <gtkmm/label.h>#include <gtkmm/main.h>#include <gtkmm/tooltips.h>#include <glibmm/convert.h>#include <glibmm/timer.h>#include <gtkmm/button.h>#include <gtk/gtktoolbar.h>#include "file_list.h"#include "dialogs.h"#include "file_list_icons.h"#ifdef ENABLE_NLS#include <libintl.h>#endifint FileListDialog::is_file_list = 0;FileListDialog::FileListDialog(const int standard_size_, Gtk::Window& window):                               Gtk::Window(Gtk::WINDOW_TOPLEVEL),			       standard_size(standard_size_), parent(window),			       in_exec_loop(false), file_list_box(false, 0),			       table(5, 2, false), ok_button(Gtk::Stock::OK),			       cancel_button(Gtk::Stock::CANCEL),			       button_box(Gtk::BUTTONBOX_END, standard_size/2) {  // notify the existence of this object in case I later decide to use this dialog as modeless  // by omitting the set_modal() call below  is_file_list++;  file_list_scroll_window.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);  file_list_scroll_window.add(tree_view);  file_list_scroll_window.set_shadow_type(Gtk::SHADOW_IN);  // create the tree model:  list_store_r = Gtk::ListStore::create(model_column);  // connect it to the tree view  tree_view.set_model(list_store_r);  // add the column of the tree model to tree view  tree_view.append_column(gettext("Files to fax"), model_column.file_name);  // single line selection  tree_view.get_selection()->set_mode(Gtk::SELECTION_SINGLE);  // make drag and drop work  tree_view.set_reorderable(true);  // set up the tool bar  tool_bar.set_orientation(Gtk::ORIENTATION_HORIZONTAL);  tool_bar.set_toolbar_style(Gtk::TOOLBAR_ICONS);  // first make the image widgets  Gtk::Image* add_image_p = manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(add_xpm)));  Gtk::Image* view_image_p = manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(view_xpm)));  Gtk::Image* remove_image_p = manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(remove_xpm)));  Gtk::HBox* add_hbox_p = manage(new Gtk::HBox);  Gtk::Label* add_label_p = manage(new Gtk::Label(gettext("Add files to list")));  add_hbox_p->pack_start(*add_image_p, Gtk::PACK_SHRINK, 4);  add_hbox_p->pack_start(*add_label_p, Gtk::PACK_SHRINK, 4);  tool_bar.set_tooltips(true);  // extract the Gtk::Tooltips object from Gtk:Toolbar (this is OK as  // in Gtk-2.4 the 'tooltips' member of struct _GtkToolbar is declared public  // and so is a guaranteed part of the GTK+ interface)  Gtk::Tooltips* tooltips_p = Glib::wrap(tool_bar.gobj()->tooltips);#if GTKMM_VERSION > 20  view_button_p = manage(new Gtk::ToolButton(*view_image_p));  tool_bar.append(*view_button_p, sigc::mem_fun(*this, &FileListDialog::view_file));  view_button_p->set_sensitive(false);  view_button_p->set_tooltip(*tooltips_p, gettext("View selected file"));  remove_button_p = manage(new Gtk::ToolButton(*remove_image_p));  tool_bar.append(*remove_button_p, sigc::mem_fun(*this, &FileListDialog::remove_file));  remove_button_p->set_sensitive(false);  remove_button_p->set_tooltip(*tooltips_p, gettext("Remove selected file from list"));  Gtk::ToolButton* add_button_p = manage(new Gtk::ToolButton(*add_hbox_p));  tool_bar.append(*add_button_p, sigc::mem_fun(*this, &FileListDialog::add_file));  add_button_p->set_tooltip(*tooltips_p, gettext("Add files to the file list for faxing"));#else  {    using namespace Gtk::Toolbar_Helpers;        add_button.add(*add_hbox_p);    ToolList& tool_list = tool_bar.tools();    tool_list.push_back(ButtonElem(*view_image_p, SigC::slot(*this, &FileListDialog::view_file),				   gettext("View selected file")));    view_button_p = static_cast<Gtk::Button*>(tool_list.back().get_widget());    view_button_p->set_relief(Gtk::RELIEF_NONE);    view_button_p->set_sensitive(false);    tool_list.push_back(ButtonElem(*remove_image_p, SigC::slot(*this, &FileListDialog::remove_file_prompt),				   gettext("Remove selected file from list")));    remove_button_p = static_cast<Gtk::Button*>(tool_list.back().get_widget());    remove_button_p->set_relief(Gtk::RELIEF_NONE);    remove_button_p->set_sensitive(false);    tool_list.push_back(Element(add_button, gettext("Add files to the file list for faxing")));    add_button.signal_clicked().connect(SigC::slot(*this, &FileListDialog::add_file));  }#endif  Gtk::Image* image_p;  image_p = manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(up_arrow_xpm)));  up_button.add(*image_p);  image_p = manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(down_arrow_xpm)));  down_button.add(*image_p);  tooltips_p->set_tip(up_button, gettext("Move file up"));  tooltips_p->set_tip(down_button, gettext("Move file down"));  button_box.add(cancel_button);  button_box.add(ok_button);  Gtk::Label* dummy1_p = manage(new Gtk::Label);  Gtk::Label* dummy2_p = manage(new Gtk::Label);  table.attach(*dummy1_p, 0, 1, 0, 1,		    Gtk::SHRINK, Gtk::EXPAND, 0, 0);  table.attach(up_button, 0, 1, 1, 2,		    Gtk::SHRINK, Gtk::SHRINK, standard_size/2, standard_size/3);  table.attach(down_button, 0, 1, 2, 3,		    Gtk::SHRINK, Gtk::SHRINK, standard_size/2, standard_size/3);  table.attach(*dummy2_p, 0, 1, 3, 4,		    Gtk::SHRINK, Gtk::EXPAND, 0, 0);  table.attach(file_list_scroll_window, 1, 2, 0, 4, Gtk::EXPAND | Gtk::FILL,         Gtk::EXPAND | Gtk::FILL, standard_size/3, standard_size/3);  table.attach(button_box, 0, 2, 4, 5, Gtk::EXPAND | Gtk::FILL,	 Gtk::SHRINK, standard_size/3, standard_size/3);  file_list_box.pack_start(tool_bar, false, false);  file_list_box.pack_start(table, true, true);  ok_button.signal_clicked().connect(sigc::mem_fun(*this, &FileListDialog::ok_slot));  cancel_button.signal_clicked().connect(sigc::mem_fun(*this, &FileListDialog::finish));  up_button.signal_clicked().connect(sigc::mem_fun(*this, &FileListDialog::move_up));  down_button.signal_clicked().connect(sigc::mem_fun(*this, &FileListDialog::move_down));  // now connect up the signal which indicates a selection has been made  tree_view.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &FileListDialog::set_buttons_slot));  ok_button.set_flags(Gtk::CAN_DEFAULT);  cancel_button.set_flags(Gtk::CAN_DEFAULT);  up_button.unset_flags(Gtk::CAN_FOCUS);  down_button.unset_flags(Gtk::CAN_FOCUS);  table.set_border_width(standard_size/3);  set_title(gettext("efax-gtk: File list"));  set_position(Gtk::WIN_POS_CENTER_ON_PARENT);  add(file_list_box);  set_transient_for(parent);  set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);  parent.set_sensitive(false);  set_modal(true);  set_default_size(standard_size * 15, standard_size * 12);  set_icon(prog_config.window_icon_r);  show_all();#if GTKMM_VERSION > 20  add_button_p->set_sensitive(true);  tool_bar.set_size_request(add_button_p->get_width() + view_button_p->get_width()			    + remove_button_p->get_width() + 12, add_button_p->get_height());#else  add_button.set_relief(Gtk::RELIEF_NORMAL);  add_button.set_sensitive(true);#endif}FileListDialog::~FileListDialog(void) {  // notify the destruction of this object  is_file_list--;}void FileListDialog::exec(void) {  in_exec_loop = true;  Gtk::Main::run();}void FileListDialog::ok_slot(void) {  accepted(get_files());  finish();}void FileListDialog::finish(void) {  parent.set_sensitive(true);  hide_all();  if (in_exec_loop) Gtk::Main::quit();  // if we have not called exec(), then this dialog is self-owning and it is safe to call `delete this'  else delete this;}bool FileListDialog::on_delete_event(GdkEventAny*) {  finish();  return true; // returning true prevents destroy sig being emitted}Glib::ustring FileListDialog::get_files(void) {  Glib::ustring text;  Gtk::TreeModel::iterator row_iter;  for (row_iter = list_store_r->children().begin();       row_iter != list_store_r->children().end();       ++row_iter) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -