/** \brief Create a label for the description */ Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { if (_gui_hidden) { return NULL; } Glib::ustring newguitext; if (_context != NULL) { newguitext = g_dpgettext2(NULL, _context, _value); } else { newguitext = _(_value); } Gtk::Label * label; int padding = 12 + _indent; if (_mode == HEADER) { label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_START)); label->set_padding(0,5); label->set_use_markup(true); padding = _indent; } else { label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_START)); } label->set_line_wrap(); label->show(); Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); hbox->pack_start(*label, true, true, padding); hbox->show(); return hbox; }
void AwesomeBar::populate_results(const std::vector<unicode>& to_add) { Pango::FontDescription desc("sans-serif 12"); displayed_files_.clear(); for(auto file: to_add) { auto to_display = file.slice(window_.project_path().length() + 1, nullptr); Gtk::Label* label = Gtk::manage(new Gtk::Label(to_display.encode())); label->set_margin_top(10); label->set_margin_bottom(10); label->set_margin_left(10); label->set_margin_right(10); label->set_alignment(0, 0.5); label->set_hexpand(false); label->set_line_wrap_mode(Pango::WRAP_CHAR); label->set_ellipsize(Pango::ELLIPSIZE_MIDDLE); label->set_line_wrap(true); label->override_font(desc); list_.append(*label); displayed_files_.push_back(file); } list_.show_all(); if(!list_.get_children().empty()) { list_revealer_.set_reveal_child(true); about_to_focus = true; list_.select_row(*list_.get_row_at_index(0)); } }
void WarningListDialog::add_warning(const Glib::ustring& warning) { Gtk::HBox* hb = Gtk::manage(new Gtk::HBox); Gtk::Label* l = Gtk::manage(new Gtk::Label); hb->show(); hb->set_spacing(LENGTH_BORDER_WIDTH*2); if(warning_icon) { Gtk::Image* img = Gtk::manage(new Gtk::Image(warning_icon)); hb->pack_start(*img, false, false); } l->set_markup(warning); l->set_alignment(0., 0.5); l->set_line_wrap(true); hb->pack_start(*l); if(warnings.get_children().size()) { Gtk::HSeparator* s = Gtk::manage(new Gtk::HSeparator); s->show(); warnings.pack_start(*s, false, false, LENGTH_SMALLSPACE); } hb->show_all_children(); warnings.pack_start(*hb, false, false); }
void BuilderHomeButton::setLabelText(std::string LabelText) { Gtk::Label * Label = Gtk::manage(new Gtk::Label(LabelText, Gtk::ALIGN_LEFT)); Label->set_line_wrap(true); Label->set_visible(true); mp_InnerBox ->pack_end(*Label); }
SelectDialog::SelectDialog ( ButtonID buttons, const char* title, const char* message, bool needSelection ) : DialogBox(buttons, title) , sw_(0) , list_(0) , selectBtn_(0) , deselectBtn_(0) , needSelection_(needSelection) { get_vbox()->set_border_width(2); if (message) { Gtk::Box* hbox = manage(new Gtk::HBox); get_vbox()->pack_start(*hbox, false, false); Gtk::Frame* frame = manage(new Gtk::Frame); hbox->pack_start(*frame); hbox->set_border_width(3); Gtk::Label* label = manage(new Gtk::Label(message, .0)); frame->add(*label); label->set_padding(3, 5); Gtk_set_size(label, 570, -1); label->set_justify(Gtk_FLAG(JUSTIFY_LEFT)); label->set_line_wrap(true); } sw_ = manage(new Gtk::ScrolledWindow); get_vbox()->pack_start(*sw_); sw_->set_policy(Gtk_FLAG(POLICY_AUTOMATIC), Gtk_FLAG(POLICY_AUTOMATIC)); Gtk_set_size(sw_, 580, 300); list_ = manage(new Gtk::List); Gtk_add_with_viewport(sw_, *list_); list_->set_selection_mode(Gtk_FLAG(SELECTION_MULTIPLE)); add_select_button("Select _All", true); add_select_button("_Deselect All", false); Gtk_set_resizable(this, true); if (needSelection) { if (Gtk::Button* btn = get_ok_button()) { btn->set_sensitive(false); } } selConn_ = Gtk_CONNECT_0(list_, selection_changed, this, &SelectDialog::on_selection_changed); get_vbox()->show_all(); }
ModelFctDetailInfoTableRow(Glib::ustring LabelText, Glib::ustring ValueText = "", bool WithBottomSeparator = false) { m_ColumnCount = 2; mp_Label = Gtk::manage(new Gtk::Label(LabelText, Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP)); m_RowWidgets.push_back(mp_Label); mp_Value = Gtk::manage(new Gtk::Label(ValueText, Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP)); mp_Value->set_line_wrap(true); m_RowWidgets.push_back(mp_Value); if (WithBottomSeparator) { mp_LabelSeparator = Gtk::manage(new Gtk::HSeparator()); m_RowWidgets.push_back(mp_LabelSeparator); mp_ValueSeparator = Gtk::manage(new Gtk::HSeparator()); m_RowWidgets.push_back(mp_ValueSeparator); } setVisible(true); }
int NetLogGuiGtkWindow::on_service_added(fawkes::NetworkService *service) { if ( ntb_logviewers.get_n_pages() == 0 ) { lab_no_connection->hide(); //Gtk::Container *thiscon = this; //thiscon->remove(lab_no_connection); //add(ntb_logviewers); ntb_logviewers.show(); } Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Button *button = Gtk::manage(new Gtk::Button()); Gtk::Image *image = Gtk::manage(new Gtk::Image(Gtk::Stock::CONNECT, Gtk::ICON_SIZE_BUTTON)); button->add(*image); button->set_relief(Gtk::RELIEF_NONE); Gtk::Label *label = Gtk::manage(new Gtk::Label()); label->set_markup(Glib::ustring("<b>") + service->host() + "</b>\n" + service->addr_string()); label->set_line_wrap(); Gtk::Label *invisible = Gtk::manage(new Gtk::Label(Glib::ustring(service->name()) + "::" + service->type() + "::" + service->domain())); Gtk::ScrolledWindow *scrolled = Gtk::manage(new Gtk::ScrolledWindow()); scrolled->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); LogView *logview = Gtk::manage(new LogView(service->addr_string().c_str(), service->port())); //scrolled->add(*logview); hbox->pack_start(*button); hbox->pack_start(*label); hbox->pack_start(*invisible); button->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &NetLogGuiGtkWindow::on_connbut_clicked), image, logview)); logview->get_connection_dispatcher()->signal_connected().connect(sigc::bind(sigc::mem_fun(*this, &NetLogGuiGtkWindow::on_connected), image)); logview->get_connection_dispatcher()->signal_disconnected().connect(sigc::bind(sigc::mem_fun(*this, &NetLogGuiGtkWindow::on_disconnected), image)); scrolled->show(); label->show(); image->show(); button->show(); logview->show(); hbox->show(); int rv = ntb_logviewers.append_page(*logview, *hbox); return rv; }
Gtk::VBox * Extension::get_help_widget(void) { Gtk::VBox * retval = Gtk::manage(new Gtk::VBox()); if (_help == NULL) { Gtk::Label * content = Gtk::manage(new Gtk::Label(_("Currently there is no help available for this Extension. Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension."))); retval->pack_start(*content, true, true, 5); content->set_line_wrap(true); content->show(); } else { } retval->show(); return retval; }
App2::EnergiesGrid::EnergiesGrid(App2::Assistant *assistant) : assistant(assistant) { Gtk::Label *label = new Gtk::Label("Select at least one XMI-MSIM input-file that describes the excitation conditions that the samples and pure element standards were exposed to. All input-files require non-matching excitation energies."); attach(*label, 0, 0, 2, 1); set_column_spacing(5); set_row_spacing(5); set_row_homogeneous(false); set_column_homogeneous(false); label->set_hexpand(); label->set_margin_bottom(10); label->set_margin_top(10); label->set_line_wrap(); label->set_justify(Gtk::JUSTIFY_LEFT); open_button.set_image_from_icon_name("document-open"); open_button.set_vexpand(false); open_button.set_hexpand(false); open_button.set_valign(Gtk::ALIGN_CENTER); attach(open_button, 0, 1, 1, 1); model = Gtk::ListStore::create(columns); model->set_sort_column(3, Gtk::SORT_ASCENDING); tv.set_model(model); tv.append_column("Filename", columns.col_filename_base); tv.append_column_numeric("Energy (keV)", columns.col_bam_file_xmsi_energy, "%g"); //alignment tv.get_column_cell_renderer(1)->set_alignment(0.5, 0.5); tv.get_column(0)->set_expand(); sw.add(tv); sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); attach(sw, 1, 1, 1, 1); sw.set_vexpand(); sw.set_hexpand(); open_button.signal_clicked().connect(sigc::mem_fun(*this, &App2::EnergiesGrid::on_open_button_clicked)); tv.signal_key_press_event().connect(sigc::mem_fun(*this, &App2::EnergiesGrid::on_backspace_clicked)); tv.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); show_all_children(); }
limitDialog::limitDialog(const char * _szUploadLabel, const char * _szDownloadLabel, const char * _szParam3Label, const char * _szParam4Label) : Gtk::Dialog(GPD->sGUI_CLIENT() + " " + GPD->sFULLVERSION() + " / Limit", true /* modal */, true /* use_separator aka set_has_separator() */ ), limit_interval(5), limit_selected(false), selected_upload_disable(false), selected_download_disable(false), selected_param3_disable(false), selected_param4_disable(false), uploadCombo(0), downloadCombo(0), param3Spin(0), param4Spin(0), selected_upload_limit(-1), selected_download_limit(-1) { Gtk::Label *uploadLabel = Gtk::manage(new class Gtk::Label( _szUploadLabel ? _szUploadLabel : "Upload" )); Gtk::Label *downloadLabel = Gtk::manage(new class Gtk::Label( _szDownloadLabel ? _szDownloadLabel : "Download" )); uploadCombo = Gtk::manage(new class Gtk::ComboBoxText()); downloadCombo = Gtk::manage(new class Gtk::ComboBoxText()); Gtk::Label *seedPercentLabel = Gtk::manage(new class Gtk::Label( _szParam3Label ? _szParam3Label : "Seed %" )); Gtk::Label *seedTimeLabel = Gtk::manage(new class Gtk::Label( _szParam4Label ? _szParam4Label : "Seed Time" )); Gtk::Adjustment *seedPercentAdjustment = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10)); param3Spin = Gtk::manage(new class Gtk::SpinButton(*seedPercentAdjustment, 1, 0)); Gtk::Adjustment *seedTimeAdjustment = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10)); param4Spin = Gtk::manage(new class Gtk::SpinButton(*seedTimeAdjustment, 1, 0)); Gtk::Table *settingsTable = Gtk::manage(new class Gtk::Table(4, 2, false)); Gtk::VBox *limitVbox = Gtk::manage(new class Gtk::VBox(false, 10)); uploadLabel->set_alignment(0,0.5); uploadLabel->set_padding(5,0); uploadLabel->set_justify(Gtk::JUSTIFY_LEFT); uploadLabel->set_line_wrap(false); uploadLabel->set_use_markup(false); uploadLabel->set_selectable(false); downloadLabel->set_alignment(0,0.5); downloadLabel->set_padding(5,0); downloadLabel->set_justify(Gtk::JUSTIFY_LEFT); downloadLabel->set_line_wrap(false); downloadLabel->set_use_markup(false); downloadLabel->set_selectable(false); seedPercentLabel->set_alignment(0,0.5); seedPercentLabel->set_padding(5,0); seedPercentLabel->set_justify(Gtk::JUSTIFY_LEFT); seedPercentLabel->set_line_wrap(false); seedPercentLabel->set_use_markup(false); seedPercentLabel->set_selectable(false); seedTimeLabel->set_alignment(0,0.5); seedTimeLabel->set_padding(5,0); seedTimeLabel->set_justify(Gtk::JUSTIFY_LEFT); seedTimeLabel->set_line_wrap(false); seedTimeLabel->set_use_markup(false); seedTimeLabel->set_selectable(false); param3Spin->set_flags(Gtk::CAN_FOCUS); param3Spin->set_update_policy(Gtk::UPDATE_ALWAYS); param3Spin->set_numeric(false); param3Spin->set_digits(0); param3Spin->set_wrap(false); param3Spin->set_range(0, MaxParam3Value); param4Spin->set_flags(Gtk::CAN_FOCUS); param4Spin->set_update_policy(Gtk::UPDATE_ALWAYS); param4Spin->set_numeric(false); param4Spin->set_digits(0); param4Spin->set_wrap(false); param4Spin->set_range(0, MaxParam4Value); uploadCombo->append_text("disable"); downloadCombo->append_text("disable"); for (t_int i=limit_interval; i<=200; i+=limit_interval) { using namespace btg::core; std::string s = convertToString<int>(i) + " KiB/sec"; uploadCombo->append_text(s); downloadCombo->append_text(s); } uploadCombo->set_active(0); downloadCombo->set_active(0); settingsTable->set_border_width(10); settingsTable->set_row_spacings(20); settingsTable->set_col_spacings(5); /* */ settingsTable->attach(*uploadLabel, 0, 1, 0, 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*downloadLabel, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*seedPercentLabel, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*seedTimeLabel, 0, 1, 3, 4, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*param3Spin, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*param4Spin, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*uploadCombo, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*downloadCombo, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); limitVbox->pack_start(*settingsTable, Gtk::PACK_SHRINK, 0); property_window_position().set_value(Gtk::WIN_POS_CENTER); set_resizable(true); property_destroy_with_parent().set_value(false); get_vbox()->pack_start(*limitVbox); set_default_size(300, 200); // Create buttons and connect their signals. add_button("Set", 1); add_button("Cancel", 2); signal_response().connect(sigc::mem_fun(*this, &limitDialog::on_button_pressed)); show_all(); // flag all inner elements as visible hide(); // hide toplevel window }
Example_ScrolledViewport::Example_ScrolledViewport() { Gtk::HBox* hbox; Gtk::VBox* vbox; set_title("ScrolledViewport Example"); Papyrus::Gtk::Viewport& viewport = m_ScrolledViewport.viewport(); m_Zoomer = Papyrus::Zoomer::create( ); viewport.add_controller( m_Zoomer ); viewport.set_size_request( 300, 200 ); // Create some shapes to add to the group Papyrus::Group::pointer g = Papyrus::example_group( ); viewport.canvas()->add( g ); m_Zoomer->add( g ); vbox = Gtk::manage( new Gtk::VBox() ); vbox->pack_start( m_ScrolledViewport ); vbox->pack_start( *Gtk::manage( new Gtk::HSeparator() ) ); Gtk::RadioButton* rb; Gtk::VBox* vbox2; Gtk::Frame* frame; Gtk::Label* label; label = Gtk::manage( new Gtk::Label("Use the mouse wheel to zoom in and out.\n\nThe scrollbars are set to automatic in this example so you will need to zoom in before they show up.") ); label->set_use_markup(); label->set_line_wrap(); vbox->pack_start(*label, Gtk::PACK_SHRINK, 10); vbox->pack_start( *Gtk::manage( new Gtk::HSeparator() ) ); vbox2 = Gtk::manage( new Gtk::VBox() ); frame = Gtk::manage( new Gtk::Frame("Viewport Scroll Placement") ); frame->add(*vbox2); vbox->pack_start(*frame, Gtk::PACK_SHRINK, 10); label = Gtk::manage( new Gtk::Label("<i>Placement refers to the corner where the viewport will be placed</i>") ); label->set_use_markup(); label->set_line_wrap(); vbox2->pack_start(*label, Gtk::PACK_SHRINK); Gtk::RadioButtonGroup scroll_placement_group; rb = Gtk::manage( new Gtk::RadioButton( scroll_placement_group, "Top Left" ) ); rb->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &Example_ScrolledViewport::on_scroll_placement_changed), Gtk::CORNER_TOP_LEFT) ); vbox2->pack_start( *rb ); rb = Gtk::manage( new Gtk::RadioButton( scroll_placement_group, "Bottom Left" ) ); rb->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &Example_ScrolledViewport::on_scroll_placement_changed), Gtk::CORNER_BOTTOM_LEFT) ); vbox2->pack_start( *rb ); rb = Gtk::manage( new Gtk::RadioButton( scroll_placement_group, "Top Right" ) ); rb->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &Example_ScrolledViewport::on_scroll_placement_changed), Gtk::CORNER_TOP_RIGHT) ); vbox2->pack_start( *rb ); rb = Gtk::manage( new Gtk::RadioButton( scroll_placement_group, "Bottom Right" ) ); rb->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &Example_ScrolledViewport::on_scroll_placement_changed), Gtk::CORNER_BOTTOM_RIGHT) ); vbox2->pack_start( *rb ); this->add( *vbox ); show_all(); }
sessionSelectionDialog::sessionSelectionDialog(std::string const& _title, t_longList const& _sessionIDs, t_strList const& _sessionsNames, bool const _disableSelection) : disableSelection_(_disableSelection), selected(false), session(Command::INVALID_SESSION), cbt(0) { Gtk::Button* cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); Gtk::Button* okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); Gtk::Label* label = Gtk::manage(new class Gtk::Label(_title)); cbt = Gtk::manage(new class Gtk::ComboBoxText()); Gtk::VBox* vbox = Gtk::manage(new class Gtk::VBox(false, 0)); cancelbutton->set_flags(Gtk::CAN_FOCUS); cancelbutton->set_relief(Gtk::RELIEF_NORMAL); okbutton->set_flags(Gtk::CAN_FOCUS); okbutton->set_relief(Gtk::RELIEF_NORMAL); get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); label->set_alignment(0.5,0.5); label->set_padding(0,0); label->set_justify(Gtk::JUSTIFY_LEFT); label->set_line_wrap(false); label->set_use_markup(false); label->set_selectable(false); vbox->pack_start(*label, Gtk::PACK_SHRINK, 0); vbox->pack_start(*cbt); get_vbox()->set_homogeneous(false); get_vbox()->set_spacing(0); get_vbox()->pack_start(*vbox); set_title(_title); set_modal(true); property_window_position().set_value(Gtk::WIN_POS_NONE); set_resizable(true); property_destroy_with_parent().set_value(false); set_has_separator(true); add_action_widget(*cancelbutton, -6); add_action_widget(*okbutton, -5); /// Fill the combobox with session ids. t_strListCI sessionNameIter = _sessionsNames.begin(); for (t_longListCI sessionIter = _sessionIDs.begin(); sessionIter != _sessionIDs.end(); sessionIter++) { std::string session_descr = convertToString<t_long>(*sessionIter); session_descr += " ("; session_descr += *sessionNameIter; session_descr += ")"; cbt->append_text(session_descr); sessionNameIter++; } // Select the first session id. cbt->set_active(0); if (!disableSelection_) { cancelbutton->show(); } okbutton->show(); label->show(); cbt->show(); vbox->show(); show(); // Connect buttons to handlers. okbutton->signal_clicked().connect(sigc::mem_fun(*this, &sessionSelectionDialog::on_ok_clicked)); if (!disableSelection_) { cancelbutton->signal_clicked().connect(sigc::mem_fun(*this, &sessionSelectionDialog::on_cancel_clicked)); } }
HIGMessageDialog::HIGMessageDialog(Gtk::Window *parent, GtkDialogFlags flags, Gtk::MessageType msg_type, Gtk::ButtonsType btn_type, const Glib::ustring & header, const Glib::ustring & msg) : Gtk::Dialog() , m_extra_widget(NULL) { set_border_width(5); set_resizable(false); set_title(""); get_vbox()->set_spacing(12); get_action_area()->set_layout(Gtk::BUTTONBOX_END); m_accel_group = Glib::RefPtr<Gtk::AccelGroup>(Gtk::AccelGroup::create()); add_accel_group(m_accel_group); Gtk::HBox *hbox = manage(new Gtk::HBox (false, 12)); hbox->set_border_width(5); hbox->show(); get_vbox()->pack_start(*hbox, false, false, 0); switch (msg_type) { case Gtk::MESSAGE_ERROR: m_image = new Gtk::Image (Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG); break; case Gtk::MESSAGE_QUESTION: m_image = new Gtk::Image (Gtk::Stock::DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); break; case Gtk::MESSAGE_INFO: m_image = new Gtk::Image (Gtk::Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG); break; case Gtk::MESSAGE_WARNING: m_image = new Gtk::Image (Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG); break; default: m_image = new Gtk::Image (); break; } if (m_image) { Gtk::manage(m_image); m_image->show(); m_image->property_yalign().set_value(0); hbox->pack_start(*m_image, false, false, 0); } Gtk::VBox *label_vbox = manage(new Gtk::VBox (false, 0)); label_vbox->show(); hbox->pack_start(*label_vbox, true, true, 0); std::string title = str(boost::format("<span weight='bold' size='larger'>%1%" "</span>\n") % header.c_str()); Gtk::Label *label; label = manage(new Gtk::Label (title)); label->set_use_markup(true); label->set_justify(Gtk::JUSTIFY_LEFT); label->set_line_wrap(true); label->set_alignment (0.0f, 0.5f); label->show(); label_vbox->pack_start(*label, false, false, 0); label = manage(new Gtk::Label(msg)); label->set_use_markup(true); label->set_justify(Gtk::JUSTIFY_LEFT); label->set_line_wrap(true); label->set_alignment (0.0f, 0.5f); label->show(); label_vbox->pack_start(*label, false, false, 0); m_extra_widget_vbox = manage(new Gtk::VBox (false, 0)); m_extra_widget_vbox->show(); label_vbox->pack_start(*m_extra_widget_vbox, true, true, 12); switch (btn_type) { case Gtk::BUTTONS_NONE: break; case Gtk::BUTTONS_OK: add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK, true); break; case Gtk::BUTTONS_CLOSE: add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE, true); break; case Gtk::BUTTONS_CANCEL: add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, true); break; case Gtk::BUTTONS_YES_NO: add_button (Gtk::Stock::NO, Gtk::RESPONSE_NO, false); add_button (Gtk::Stock::YES, Gtk::RESPONSE_YES, true); break; case Gtk::BUTTONS_OK_CANCEL: add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, false); add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK, true); break; } if (parent){ set_transient_for(*parent); } if ((flags & GTK_DIALOG_MODAL) != 0) { set_modal(true); } if ((flags & GTK_DIALOG_DESTROY_WITH_PARENT) != 0) { property_destroy_with_parent().set_value(true); } }
aboutDialog::aboutDialog() { Gtk::Dialog *ad = this; Gtk::Button *okbutton = Gtk::manage(new class Gtk::Button("ok")); Gtk::Label *aboutLabel = Gtk::manage(new class Gtk::Label( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + ", build " + GPD->sBUILD() )); Gtk::TextView *textview = Gtk::manage(new class Gtk::TextView()); Gtk::ScrolledWindow *scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow()); Gtk::VBox *vbox = Gtk::manage(new class Gtk::VBox(false, 0)); okbutton->set_flags(Gtk::CAN_FOCUS); okbutton->set_relief(Gtk::RELIEF_NORMAL); ad->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); ad->set_default_size(300, 200); aboutLabel->set_alignment(0.5,0.5); aboutLabel->set_padding(0,0); aboutLabel->set_justify(Gtk::JUSTIFY_LEFT); aboutLabel->set_line_wrap(false); aboutLabel->set_use_markup(false); aboutLabel->set_selectable(false); textview->set_flags(Gtk::CAN_FOCUS); textview->set_editable(true); textview->set_cursor_visible(true); textview->set_pixels_above_lines(0); textview->set_pixels_below_lines(0); textview->set_pixels_inside_wrap(0); textview->set_left_margin(0); textview->set_right_margin(0); textview->set_indent(0); textview->set_wrap_mode(Gtk::WRAP_NONE); textview->set_justification(Gtk::JUSTIFY_LEFT); using namespace std; string text; text += "btg Copyright (C) 2005 Michael Wojciechowski."; text += GPD->sNEWLINE(); text += "This program is free software; you can redistribute it and/or modify"; text += GPD->sNEWLINE(); text += "it under the terms of the GNU General Public License as published by "; text += GPD->sNEWLINE(); text += "the Free Software Foundation; either version 2 of the License, or "; text += GPD->sNEWLINE(); text += "(at your option) any later version."; text += GPD->sNEWLINE(); text += "This program is distributed in the hope that it will be useful, "; text += GPD->sNEWLINE(); text += "but WITHOUT ANY WARRANTY; without even the implied warranty of "; text += GPD->sNEWLINE(); text += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "; text += GPD->sNEWLINE(); text += "GNU General Public License for more details."; text += GPD->sNEWLINE(); text += "You should have received a copy of the GNU General Public License "; text += GPD->sNEWLINE(); text += "along with this program; if not, write to the Free Software "; text += GPD->sNEWLINE(); text += "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"; text += GPD->sNEWLINE(); textview->get_buffer()->set_text(text); scrolledwindow->set_flags(Gtk::CAN_FOCUS); scrolledwindow->set_shadow_type(Gtk::SHADOW_IN); scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT); scrolledwindow->add(*textview); vbox->pack_start(*aboutLabel, Gtk::PACK_SHRINK, 0); vbox->pack_start(*scrolledwindow); ad->get_vbox()->set_homogeneous(false); ad->get_vbox()->set_spacing(0); ad->get_vbox()->pack_start(*vbox); //ad->set_title( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() ); ad->set_title( GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + " / About" ); ad->set_modal(true); ad->property_window_position().set_value(Gtk::WIN_POS_CENTER); ad->set_resizable(true); ad->property_destroy_with_parent().set_value(false); ad->set_has_separator(true); ad->add_action_widget(*okbutton, -5); okbutton->show(); aboutLabel->show(); textview->show(); scrolledwindow->show(); vbox->show(); okbutton->signal_clicked().connect(sigc::mem_fun(*this, &aboutDialog::on_ok_clicked)); // ad->show(); }
preferencesDialog::preferencesDialog(int const _min_port, int const _max_port) : portrange_begin(0), beginPortRangeSpinbuttonAdj(0), portrange_end(0), endPortRangeSpinbuttonAdj(0), workPathEntry(0), outputPathEntry(0), leechModeCheckbutton(0), min_port(_max_port), max_port(_min_port), workPath(), outputPath(), leechmode(false), portrange_begin_intial_value(0), portrange_end_intial_value(0), workPath_initial_value(""), outputPath_initial_value(""), leechmode_initial_value(false), portrange_begin_signal(), portrange_end_signal(), save_btn_pressed(false) { Gtk::Label* workLabel = Gtk::manage(new class Gtk::Label("Working directory")); Gtk::Label* outputLabel = Gtk::manage(new class Gtk::Label("Output directory")); Gtk::Label* portRangeLabel = Gtk::manage(new class Gtk::Label("Port range")); Gtk::Label* leechModeLabel = Gtk::manage(new class Gtk::Label("Leech mode")); outputPathEntry = Gtk::manage(new class Gtk::Entry()); workPathEntry = Gtk::manage(new class Gtk::Entry()); leechModeCheckbutton = Gtk::manage(new class Gtk::CheckButton("enabled")); Gtk::Table* settingsTable = Gtk::manage(new class Gtk::Table(2, 2, false)); // Ports: Gtk::Table* portTable = Gtk::manage(new class Gtk::Table(2, 2, false));; Gtk::Label* beginPortLabel = Gtk::manage(new class Gtk::Label("Begin Port")); Gtk::Label* endPortLabel = Gtk::manage(new class Gtk::Label("End Port")); beginPortRangeSpinbuttonAdj = Gtk::manage(new class Gtk::Adjustment(_min_port, _min_port, _max_port, 1, 100, 10)); portrange_begin = Gtk::manage(new class Gtk::SpinButton(*beginPortRangeSpinbuttonAdj, 1, 0)); endPortRangeSpinbuttonAdj = Gtk::manage(new class Gtk::Adjustment(_min_port, _min_port, _max_port, 1, 100, 10)); portrange_end = Gtk::manage(new class Gtk::SpinButton(*endPortRangeSpinbuttonAdj, 1, 0)); beginPortLabel->set_alignment(0,0.5); beginPortLabel->set_padding(5,5); beginPortLabel->set_justify(Gtk::JUSTIFY_LEFT); beginPortLabel->set_line_wrap(false); beginPortLabel->set_use_markup(false); beginPortLabel->set_selectable(false); endPortLabel->set_alignment(0,0.5); endPortLabel->set_padding(5,5); endPortLabel->set_justify(Gtk::JUSTIFY_LEFT); endPortLabel->set_line_wrap(false); endPortLabel->set_use_markup(false); endPortLabel->set_selectable(false); portrange_end->set_flags(Gtk::CAN_FOCUS); portrange_end->set_update_policy(Gtk::UPDATE_ALWAYS); portrange_end->set_numeric(false); portrange_end->set_digits(0); portrange_end->set_wrap(false); portrange_end->set_flags(Gtk::CAN_FOCUS); portrange_end->set_update_policy(Gtk::UPDATE_ALWAYS); portrange_end->set_numeric(true); portrange_end->set_digits(0); portrange_end->set_wrap(false); portrange_begin->set_flags(Gtk::CAN_FOCUS); portrange_begin->set_update_policy(Gtk::UPDATE_ALWAYS); portrange_begin->set_numeric(false); portrange_begin->set_digits(0); portrange_begin->set_wrap(false); portrange_begin->set_flags(Gtk::CAN_FOCUS); portrange_begin->set_update_policy(Gtk::UPDATE_ALWAYS); portrange_begin->set_numeric(true); portrange_begin->set_digits(0); portrange_begin->set_wrap(false); portTable->set_border_width(10); portTable->set_row_spacings(5); portTable->set_col_spacings(5); portTable->attach(*beginPortLabel, 0, 1, 0, 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); portTable->attach(*endPortLabel, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0); portTable->attach(*portrange_end, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); portTable->attach(*portrange_begin, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); beginPortLabel->show(); endPortLabel->show(); portrange_begin->show(); portrange_end->show(); portTable->show(); Gtk::VBox *preferencesVbox = Gtk::manage(new class Gtk::VBox(false, 10)); outputLabel->set_alignment(0,0.5); outputLabel->set_padding(5,0); outputLabel->set_justify(Gtk::JUSTIFY_LEFT); outputLabel->set_line_wrap(false); outputLabel->set_use_markup(false); outputLabel->set_selectable(false); workLabel->set_alignment(0,0.5); workLabel->set_padding(5,0); workLabel->set_justify(Gtk::JUSTIFY_LEFT); workLabel->set_line_wrap(false); workLabel->set_use_markup(false); workLabel->set_selectable(false); portRangeLabel->set_alignment(0,0.5); portRangeLabel->set_padding(5,0); portRangeLabel->set_justify(Gtk::JUSTIFY_LEFT); portRangeLabel->set_line_wrap(false); portRangeLabel->set_use_markup(false); portRangeLabel->set_selectable(false); leechModeLabel->set_alignment(0,0.5); leechModeLabel->set_padding(5,0); leechModeLabel->set_justify(Gtk::JUSTIFY_LEFT); leechModeLabel->set_line_wrap(false); leechModeLabel->set_use_markup(false); leechModeLabel->set_selectable(false); Gtk::HBox* pathHbox = Gtk::manage(new class Gtk::HBox(false, 10)); Gtk::HBox* workPathHbox = Gtk::manage(new class Gtk::HBox(false, 10)); outputPathEntry->set_flags(Gtk::CAN_FOCUS); outputPathEntry->set_visibility(true); outputPathEntry->set_editable(false); outputPathEntry->set_max_length(0); outputPathEntry->set_text(""); outputPathEntry->set_has_frame(true); outputPathEntry->set_activates_default(false); workPathEntry->set_flags(Gtk::CAN_FOCUS); workPathEntry->set_visibility(true); workPathEntry->set_editable(false); workPathEntry->set_max_length(0); workPathEntry->set_text(""); workPathEntry->set_has_frame(true); workPathEntry->set_activates_default(false); Gtk::Button* pathButton = Gtk::manage(new class Gtk::Button("Change Path")); Gtk::Button* workPathButton = Gtk::manage(new class Gtk::Button("Change Path")); pathHbox->pack_start(*outputPathEntry); pathHbox->pack_start(*pathButton, Gtk::PACK_SHRINK, 0); workPathHbox->pack_start(*workPathEntry); workPathHbox->pack_start(*workPathButton, Gtk::PACK_SHRINK, 0); leechModeCheckbutton->set_flags(Gtk::CAN_FOCUS); leechModeCheckbutton->set_relief(Gtk::RELIEF_NORMAL); leechModeCheckbutton->set_mode(true); leechModeCheckbutton->set_active(false); settingsTable->set_border_width(10); settingsTable->set_row_spacings(20); settingsTable->set_col_spacings(5); // left rigth top bottom /* table1->attach(*label1, 0, 1, 0, 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*label2, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*label3, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*label4, 0, 1, 3, 4, Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*entry1, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*entry2, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*entry3, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); table1->attach(*entry4, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); */ settingsTable->attach(*workLabel, 0, 1, 0, 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*outputLabel, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*portRangeLabel, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*leechModeLabel, 0, 1, 3, 4, Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*workPathHbox, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*pathHbox, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0); settingsTable->attach(*portTable, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0); settingsTable->attach(*leechModeCheckbutton, 1, 2, 3, 4, Gtk::FILL, Gtk::AttachOptions(), 0, 0); preferencesVbox->pack_start(*settingsTable, Gtk::PACK_SHRINK, 0); set_title( GPD->sGUI_CLIENT() + " " + GPD->sFULLVERSION() + " / Preferences" ); set_modal(true); property_window_position().set_value(Gtk::WIN_POS_CENTER); set_resizable(true); property_destroy_with_parent().set_value(false); set_has_separator(true); get_vbox()->pack_start(*preferencesVbox); set_default_size(300, 200); outputLabel->show(); workLabel->show(); portRangeLabel->show(); leechModeLabel->show(); outputPathEntry->show(); pathButton->show(); pathHbox->show(); workPathEntry->show(); workPathButton->show(); workPathHbox->show(); leechModeCheckbutton->show(); settingsTable->show(); preferencesVbox->show(); // Create buttons and connect their signals. add_button("Save", 1); add_button("Cancel", 2); signal_response().connect(sigc::mem_fun(*this, &preferencesDialog::on_dialog_button_pressed)); pathButton->signal_clicked().connect(sigc::mem_fun(*this, &preferencesDialog::on_path_select_button_pressed)); workPathButton->signal_clicked().connect(sigc::mem_fun(*this, &preferencesDialog::on_work_path_select_button_pressed)); get_vbox()->show(); }