background_chooser_dialog.cc
author alpar
Sat, 03 Feb 2007 12:43:01 +0000
changeset 188 c1c9fcf03e94
child 194 6b2b718420eb
permissions -rw-r--r--
Syncronize glemon repo with the latest version of lemon.
(lemon::Path seems to seriously buggy)
ladanyi@184
     1
#include "background_chooser_dialog.h"
ladanyi@184
     2
#include <gtkmm/stock.h>
ladanyi@184
     3
#include "mapstorage.h"
ladanyi@184
     4
ladanyi@184
     5
BackgroundChooserDialog::BackgroundChooserDialog(MapStorage* ms) :
ladanyi@184
     6
  mapstorage(ms),
ladanyi@184
     7
  btnClear(Gtk::Stock::CLEAR)
ladanyi@184
     8
{
ladanyi@184
     9
  set_has_separator(false);
ladanyi@184
    10
ladanyi@184
    11
  Gtk::VBox* pVBox = get_vbox();
ladanyi@184
    12
ladanyi@184
    13
  lblBackground.set_text("<b>Background image file</b>");
ladanyi@184
    14
  lblBackground.set_use_markup();
ladanyi@184
    15
  lblBackground.set_alignment(Gtk::ALIGN_LEFT);
ladanyi@184
    16
  lblScaling.set_text("<b>Scaling factor</b>");
ladanyi@184
    17
  lblScaling.set_use_markup();
ladanyi@184
    18
  lblScaling.set_alignment(Gtk::ALIGN_LEFT);
ladanyi@184
    19
  fcbBackground.set_width_chars(30);
ladanyi@184
    20
  fcbBackground.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
ladanyi@184
    21
  if (mapstorage->isBackgroundSet())
ladanyi@184
    22
  {
ladanyi@184
    23
    fcbBackground.set_filename(mapstorage->getBackgroundFilename());
ladanyi@184
    24
  }
ladanyi@184
    25
ladanyi@184
    26
  fcbBackground.signal_selection_changed().connect(
ladanyi@184
    27
    sigc::mem_fun(*this, &BackgroundChooserDialog::setBackground));
ladanyi@184
    28
ladanyi@184
    29
  btnClear.signal_clicked().connect(
ladanyi@184
    30
    sigc::mem_fun(*this, &BackgroundChooserDialog::clearBackground));
ladanyi@184
    31
ladanyi@184
    32
  pVBox->pack_start(lblBackground, Gtk::PACK_SHRINK);
ladanyi@184
    33
  pVBox->pack_start(box, Gtk::PACK_SHRINK);
ladanyi@184
    34
  box.pack_start(fcbBackground, Gtk::PACK_EXPAND_WIDGET);
ladanyi@184
    35
  box.pack_start(btnClear, Gtk::PACK_SHRINK);
ladanyi@184
    36
  pVBox->pack_start(lblScaling, Gtk::PACK_SHRINK);
ladanyi@184
    37
  pVBox->pack_start(sbScaling, Gtk::PACK_SHRINK);
ladanyi@184
    38
ladanyi@184
    39
  add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
ladanyi@184
    40
ladanyi@184
    41
  show_all_children();
ladanyi@184
    42
}
ladanyi@184
    43
ladanyi@184
    44
void BackgroundChooserDialog::clearBackground()
ladanyi@184
    45
{
ladanyi@184
    46
  fcbBackground.unselect_all();
ladanyi@184
    47
}
ladanyi@184
    48
ladanyi@184
    49
void BackgroundChooserDialog::setBackground()
ladanyi@184
    50
{
ladanyi@184
    51
  mapstorage->setBackground(fcbBackground.get_filename());
ladanyi@184
    52
}