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

📄 settings.cpp

📁 linux pritner GUI
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* Copyright (C) 2001 2002 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 <unistd.h>#include <fstream>#include <vector>#include <algorithm>#include <iterator>#include <cstdlib>#include <cstring>#include <gtkmm/main.h>#include <gtkmm/style.h>#include <gdkmm/pixbuf.h>#include <gtkmm/image.h>#include <gtkmm/stock.h>#include "settings.h"#include "settings_icons.h"#include "dialogs.h"#ifdef ENABLE_NLS#include <libintl.h>#endifIdentityTable::IdentityTable(const int standard_size): Gtk::Table(4, 3, false),						       name_label(gettext("Name: ")),						       number_label(gettext("Number: ")) {  name_label.set_justify(Gtk::JUSTIFY_RIGHT);  number_label.set_justify(Gtk::JUSTIFY_RIGHT);  name_entry.set_size_request(standard_size * 7, standard_size);  number_entry.set_size_request(standard_size * 7, standard_size);  Glib::RefPtr<Gdk::Pixbuf> pixbuf_r(Gdk::Pixbuf::create_from_xpm_data(help_xpm));  Gtk::Image* image_p = manage(new Gtk::Image(pixbuf_r));  name_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  number_help_button.add(*image_p);  attach(filler1, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  attach(name_label, 0, 1, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size);  attach(name_entry, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size);  attach(name_help_button, 2, 3, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size);  attach(number_label, 0, 1, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size);  attach(number_entry, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size);  attach(number_help_button, 2, 3, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size);  attach(filler2, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  name_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &IdentityTable::show_help),						       static_cast<int>(IdentityMessages::name)));  number_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &IdentityTable::show_help),							 static_cast<int>(IdentityMessages::number)));  tooltips.set_tip(name_help_button, help_messages.get_message(IdentityMessages::name));  tooltips.set_tip(number_help_button, help_messages.get_message(IdentityMessages::number));  set_border_width(standard_size/3);}void IdentityTable::show_help(int message_index) {  show_help_sig(help_messages.get_message(message_index),		help_messages.get_caption(message_index));}void IdentityTable::clear(void) {  name_entry.set_text("");  number_entry.set_text("");}ModemTable::ModemTable(const int standard_size): Gtk::Table(8, 3, false),				    device_label(gettext("Serial Device: ")),				    lock_label(gettext("Lock File: ")),				    capabilities_label(gettext("Capabilities: ")),                                    rings_label(gettext("Rings (1-9): ")),				    class_label(gettext("Modem Class: ")),                                    dialmode_label(gettext("Dial Mode: ")),				    auto_button(gettext("Auto")),				    class1_button(gettext("Class 1")),                                    class2_button(gettext("Class 2")),				    class20_button(gettext("Class 2.0")),				    tone_button(gettext("Tone")),				    pulse_button(gettext("Pulse")),                                    class_box(false, 2), dialmode_box(false, 2) {  device_label.set_justify(Gtk::JUSTIFY_RIGHT);  lock_label.set_justify(Gtk::JUSTIFY_RIGHT);  class_label.set_justify(Gtk::JUSTIFY_RIGHT);  dialmode_label.set_justify(Gtk::JUSTIFY_RIGHT);  capabilities_label.set_justify(Gtk::JUSTIFY_RIGHT);  rings_label.set_justify(Gtk::JUSTIFY_RIGHT);  device_entry.set_size_request(standard_size * 7, standard_size);  lock_entry.set_size_request(standard_size * 7, standard_size);  capabilities_entry.set_size_request(standard_size * 7, standard_size);  rings_entry.set_size_request(standard_size * 7, standard_size);  Gtk::RadioButton::Group class_group(auto_button.get_group());  class1_button.set_group(class_group);  class2_button.set_group(class_group);  class20_button.set_group(class_group);  auto_button.set_active(true);  class_box.pack_start(auto_button, false, false, 0);  class_box.pack_start(class1_button, false, false, 0);  class_box.pack_start(class2_button, false, false, 0);  class_box.pack_start(class20_button, false, false, 0);  class_box.pack_start(class_box_filler, true, false, 0);  class_frame.add(class_box);  Gtk::RadioButton::Group dialmode_group(tone_button.get_group());  pulse_button.set_group(dialmode_group);  tone_button.set_active(true);  dialmode_box.pack_start(tone_button, false, false, 0);  dialmode_box.pack_start(pulse_button, false, false, 0);  dialmode_box.pack_start(dialmode_box_filler, true, false, 0);  dialmode_frame.add(dialmode_box);  Glib::RefPtr<Gdk::Pixbuf> pixbuf_r(Gdk::Pixbuf::create_from_xpm_data(help_xpm));  Gtk::Image* image_p = manage(new Gtk::Image(pixbuf_r));  device_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  lock_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  class_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  dialmode_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  capabilities_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  rings_help_button.add(*image_p);  attach(filler1, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  attach(device_label, 0, 1, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(device_entry, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(device_help_button, 2, 3, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(lock_label, 0, 1, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(lock_entry, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(lock_help_button, 2, 3, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(capabilities_label, 0, 1, 3, 4, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(capabilities_entry, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(capabilities_help_button, 2, 3, 3, 4, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(rings_label, 0, 1, 4, 5, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(rings_entry, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(rings_help_button, 2, 3, 4, 5, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(class_label, 0, 1, 5, 6, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(class_frame, 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(class_help_button, 2, 3, 5, 6, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(dialmode_label, 0, 1, 6, 7, Gtk::SHRINK,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(dialmode_frame, 1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/5, standard_size/5);  attach(dialmode_help_button, 2, 3, 6, 7, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/5);  attach(filler2, 1, 2, 7, 8, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  device_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),							 static_cast<int>(ModemMessages::device)));  lock_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),						       static_cast<int>(ModemMessages::lock)));  class_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),							static_cast<int>(ModemMessages::modem_class)));  dialmode_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),							   static_cast<int>(ModemMessages::dialmode)));  capabilities_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),							       static_cast<int>(ModemMessages::capabilities)));  rings_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ModemTable::show_help),							static_cast<int>(ModemMessages::rings)));  tooltips.set_tip(device_help_button, help_messages.get_message(ModemMessages::device));  tooltips.set_tip(lock_help_button, help_messages.get_message(ModemMessages::lock));  tooltips.set_tip(class_help_button, help_messages.get_message(ModemMessages::modem_class));  tooltips.set_tip(dialmode_help_button, help_messages.get_message(ModemMessages::dialmode));  tooltips.set_tip(capabilities_help_button, help_messages.get_message(ModemMessages::capabilities));  tooltips.set_tip(rings_help_button, help_messages.get_message(ModemMessages::rings));  set_border_width(standard_size/3);}Glib::ustring ModemTable::get_class(void) const {  Glib::ustring return_val; // an empty string will indicate an "Auto" setting  if (class1_button.get_active()) return_val = "1";  else if (class2_button.get_active()) return_val = "2";  else if (class20_button.get_active()) return_val = "2.0";  return return_val;}void ModemTable::set_class(const Glib::ustring& class_string) {  if (!class_string.compare("1")) class1_button.set_active(true);  else if (!class_string.compare("2")) class2_button.set_active(true);  else if (!class_string.compare("2.0")) class20_button.set_active(true);  else auto_button.set_active(true); // "Auto" setting}Glib::ustring ModemTable::get_dialmode(void) const {    Glib::ustring return_val("tone");  if (pulse_button.get_active()) return_val = "pulse";  return return_val;}void ModemTable::set_dialmode(const Glib::ustring& mode_string) {  std::string temp(mode_string.lowercase());  if (!temp.compare("tone")) tone_button.set_active(true);  else if (!temp.compare("pulse")) pulse_button.set_active(true);}void ModemTable::show_help(int message_index) {  show_help_sig(help_messages.get_message(message_index),		help_messages.get_caption(message_index));}void ModemTable::clear(void) {  device_entry.set_text("");  lock_entry.set_text("");  capabilities_entry.set_text("");  rings_entry.set_text("");  auto_button.set_active(true);  tone_button.set_active(true);}ParmsTable::ParmsTable(const int standard_size): Gtk::Table(5, 3, false),				    init_label(gettext("Initialization Params:")),				    reset_label(gettext("Reset Params: ")),				    parms_label(gettext("Other Params: ")) {  init_label.set_justify(Gtk::JUSTIFY_RIGHT);  reset_label.set_justify(Gtk::JUSTIFY_RIGHT);  parms_label.set_justify(Gtk::JUSTIFY_RIGHT);  init_entry.set_size_request(standard_size * 7, standard_size);  reset_entry.set_size_request(standard_size * 7, standard_size);  parms_entry.set_size_request(standard_size * 7, standard_size);  Glib::RefPtr<Gdk::Pixbuf> pixbuf_r(Gdk::Pixbuf::create_from_xpm_data(help_xpm));  Gtk::Image* image_p = manage(new Gtk::Image(pixbuf_r));  init_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  reset_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  parms_help_button.add(*image_p);  attach(filler1, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  attach(init_label, 0, 1, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(init_entry, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(init_help_button, 2, 3, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(reset_label, 0, 1, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(reset_entry, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(reset_help_button, 2, 3, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(parms_label, 0, 1, 3, 4, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(parms_entry, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(parms_help_button, 2, 3, 3, 4, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(filler2, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  init_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ParmsTable::show_help),					      static_cast<int>(ParmsMessages::init)));  reset_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ParmsTable::show_help),					       static_cast<int>(ParmsMessages::reset)));  parms_help_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &ParmsTable::show_help),					       static_cast<int>(ParmsMessages::extra_parms)));  tooltips.set_tip(init_help_button, help_messages.get_message(ParmsMessages::init));  tooltips.set_tip(reset_help_button, help_messages.get_message(ParmsMessages::reset));  tooltips.set_tip(parms_help_button, help_messages.get_message(ParmsMessages::extra_parms));  set_border_width(standard_size/3);}void ParmsTable::show_help(int message_index) {  show_help_sig(help_messages.get_message(message_index),		help_messages.get_caption(message_index));}void ParmsTable::clear(void) {  init_entry.set_text("");  reset_entry.set_text("");  parms_entry.set_text("");}PrintTable::PrintTable(const int standard_size): Gtk::Table(5, 3, false),			    command_label(gettext("Print Program: ")),			    shrink_label(gettext("Print Shrink (50-100):")),			    popup_label(gettext("Popup confirmation dialog\nbefore printing")) {  command_label.set_justify(Gtk::JUSTIFY_RIGHT);  shrink_label.set_justify(Gtk::JUSTIFY_RIGHT);  popup_label.set_justify(Gtk::JUSTIFY_RIGHT);  command_entry.set_size_request(standard_size * 7, standard_size);  shrink_entry.set_size_request(standard_size * 7, standard_size);  popup_box.pack_start(popup_button, false, false, 0);  popup_box.pack_start(popup_box_filler, true, false, 0);  popup_button.set_active(true);  // this is the default  Glib::RefPtr<Gdk::Pixbuf> pixbuf_r(Gdk::Pixbuf::create_from_xpm_data(help_xpm));  Gtk::Image* image_p = manage(new Gtk::Image(pixbuf_r));  command_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  shrink_help_button.add(*image_p);  image_p = manage(new Gtk::Image(pixbuf_r));  popup_help_button.add(*image_p);  attach(filler1, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL,	 Gtk::EXPAND | Gtk::FILL, 0, 0);  attach(command_label, 0, 1, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(command_entry, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(command_help_button, 2, 3, 1, 2, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(shrink_label, 0, 1, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(shrink_entry, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(shrink_help_button, 2, 3, 2, 3, Gtk::SHRINK,         Gtk::SHRINK, standard_size/3, standard_size/2);  attach(popup_label, 0, 1, 3, 4, Gtk::SHRINK,         Gtk::SHRINK, standard_size/4, standard_size/2);  attach(popup_box, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL,

⌨️ 快捷键说明

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