background_chooser_dialog.cc
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Mon, 07 Jul 2008 14:54:54 +0100
changeset 2 fdb8a163000f
permissions -rw-r--r--
Use libintl.h instead of locale.h.
     1 #include <background_chooser_dialog.h>
     2 #include <gtkmm/stock.h>
     3 #include <mapstorage.h>
     4 
     5 BackgroundChooserDialog::BackgroundChooserDialog(MapStorage* ms) :
     6   mapstorage(ms),
     7   btnClear(Gtk::Stock::CLEAR)
     8 {
     9   set_has_separator(false);
    10 
    11   Gtk::VBox* pVBox = get_vbox();
    12 
    13   lblBackground.set_text("<b>Background image file</b>");
    14   lblBackground.set_use_markup();
    15   lblBackground.set_alignment(Gtk::ALIGN_LEFT);
    16   lblScaling.set_text("<b>Scaling factor</b>");
    17   lblScaling.set_use_markup();
    18   lblScaling.set_alignment(Gtk::ALIGN_LEFT);
    19   fcbBackground.set_width_chars(30);
    20   fcbBackground.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
    21   if (mapstorage->isBackgroundSet())
    22   {
    23     fcbBackground.set_filename(mapstorage->getBackgroundFilename());
    24   }
    25 
    26   fcbBackground.signal_selection_changed().connect(
    27     sigc::mem_fun(*this, &BackgroundChooserDialog::setBackground));
    28 
    29   btnClear.signal_clicked().connect(
    30     sigc::mem_fun(*this, &BackgroundChooserDialog::clearBackground));
    31 
    32   pVBox->pack_start(lblBackground, Gtk::PACK_SHRINK);
    33   pVBox->pack_start(box, Gtk::PACK_SHRINK);
    34   box.pack_start(fcbBackground, Gtk::PACK_EXPAND_WIDGET);
    35   box.pack_start(btnClear, Gtk::PACK_SHRINK);
    36   pVBox->pack_start(lblScaling, Gtk::PACK_SHRINK);
    37   pVBox->pack_start(sbScaling, Gtk::PACK_SHRINK);
    38 
    39   add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
    40 
    41   show_all_children();
    42 }
    43 
    44 void BackgroundChooserDialog::clearBackground()
    45 {
    46   fcbBackground.unselect_all();
    47 }
    48 
    49 void BackgroundChooserDialog::setBackground()
    50 {
    51   mapstorage->setBackground(fcbBackground.get_filename());
    52 }