Extending the print dialog
| Chapter 18. Printing |

## Extending the print dialog

You may add a custom tab to the print dialog:

- Set the title of the tab via `PrintOperation::set_custom_tab_label()`, create a new widget and return it from the `create_custom_widget` signal handler. You'll probably want this to be a container widget, packed with some others.

- Get the data from the widgets in the `custom_widget_apply` signal handler.

Although teh `custom_widget_apply` signal provides the widget you previously created, to simplify things you can keep the widgets you expect to contain some user input as class members. For example, let's say you have a `Gtk::Entry` called `m_Entry` as a member of your `CustomPrintOperation` class:

    Gtk::Widget* CustomPrintOperation::on_create_custom_widget()
    {
      set_custom_tab_label("My custom tab");

      Gtk::HBox* hbox = new Gtk::HBox(false, 8);
      hbox->set_border_width(6);

      Gtk::Label* label = Gtk::manage(new Gtk::Label("Enter some text: "));
      hbox->pack_start(*label, false, false);
      label->show();

      hbox->pack_start(m_Entry, false, false);
      m_Entry.show();

      return hbox;
    }

    void CustomPrintOperation::on_custom_widget_apply(Gtk::Widget* /* widget */)
    {
      Glib::ustring user_input = m_Entry.get_text();
      //...
    }

Export to PDF |  | Preview