Example #1
0
         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();
         }
Example #2
0
    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);
      }
    }
Example #3
0
void GuidelinePropertiesDialog::_setup() {
    set_title(_("Guideline"));
    add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    add_button(Gtk::Stock::DELETE, -12);
    add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);

    Gtk::VBox *mainVBox = get_vbox();

    _layout_table.set_spacings(4);
    _layout_table.resize (3, 4);

    mainVBox->pack_start(_layout_table, false, false, 0);

    _label_name.set_label("foo0");
    _layout_table.attach(_label_name,
                         0, 3, 0, 1, Gtk::FILL, Gtk::FILL);
    _label_name.set_alignment(0, 0.5);

    _label_descr.set_label("foo1");
    _layout_table.attach(_label_descr,
                         0, 3, 1, 2, Gtk::FILL, Gtk::FILL);
    _label_descr.set_alignment(0, 0.5);

    // indent
    _layout_table.attach(*manage(new Gtk::Label(" ")),
                         0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10);

    // mode radio button
    _layout_table.attach(_relative_toggle,
                         1, 3, 9, 10, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged));

    // unitmenu
    /* fixme: We should allow percents here too, as percents of the canvas size */
    GtkWidget *unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
    sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unit_selector), _desktop->namedview->doc_units);
    _unit_selector = Gtk::manage(Glib::wrap(unit_selector));

    // position spinbuttons
    sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj()));
    sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj()));
    _spin_button_x.configure(_adjustment_x, 1.0 , 3);
    _spin_button_x.set_numeric();
    _spin_button_y.configure(_adjustment_y, 1.0 , 3);
    _spin_button_y.set_numeric();
    _layout_table.attach(_label_X,
                         1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _layout_table.attach(_spin_button_x,
                         2, 3, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _layout_table.attach(_label_Y,
                         1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _layout_table.attach(_spin_button_y,
                         2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate",
                              GTK_SIGNAL_FUNC(gtk_window_activate_default),
                              gobj());

    _layout_table.attach(_label_units,
                         1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _layout_table.attach(*_unit_selector,
                         2, 3, 6, 7, Gtk::FILL, Gtk::FILL);

    // angle spinbutton
    _spin_angle.configure(_adj_angle, 5.0 , 3);
    _spin_angle.set_numeric();
    _spin_angle.show();
    _layout_table.attach(_label_degrees,
                         1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
    _layout_table.attach(_spin_angle,
                         2, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);


    // dialog
    set_default_response(Gtk::RESPONSE_OK);
    signal_response().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_response));

    // initialize dialog
    _oldpos = _guide->point_on_line;
    if (_guide->is_vertical()) {
        _oldangle = 90;
    } else if (_guide->is_horizontal()) {
        _oldangle = 0;
    } else {
        _oldangle = Geom::rad_to_deg( std::atan2( - _guide->normal_to_line[Geom::X], _guide->normal_to_line[Geom::Y] ) );
    }

    {
        Inkscape::XML::Node *repr = SP_OBJECT_REPR (_guide);
        const gchar *guide_id = repr->attribute("id");
        gchar *label = g_strdup_printf(_("Guideline ID: %s"), guide_id);
        _label_name.set_label(label);
        g_free(label);
    }
    {
        gchar *guide_description = sp_guide_description(_guide, false);
        gchar *label = g_strdup_printf(_("Current: %s"), guide_description);
        g_free(guide_description);
        _label_descr.set_markup(label);
        g_free(label);
    }

    _modeChanged(); // sets values of spinboxes.

    if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) {
        _spin_button_x.grab_focus();
        _spin_button_x.select_region(0, 20);
    } else if ( _oldangle == 0. || _oldangle == 180. || _oldangle == -180.) {
        _spin_button_y.grab_focus();
        _spin_button_y.select_region(0, 20);
    } else {
        _spin_angle.grab_focus();
        _spin_angle.select_region(0, 20);
    }

    set_position(Gtk::WIN_POS_MOUSE);

    show_all_children();
    set_modal(true);
    _desktop->setWindowTransient (gobj());
    property_destroy_with_parent() = true;
}