Commit 6ab97bf2 authored by daniel_e's avatar daniel_e
Browse files

Remove "regexxer info" page. Split up configuration into "Look'n'feel" and

"File access" pages.  Add UI and class interface for the new menutool_mode
config option.
parent 14e6e01b
2002-11-18 Daniel Elstner <daniel.elstner@gmx.net>
* src/prefdialog.{cc,h}: Remove "regexxer info" page. Split up
configuration into "Look'n'feel" and "File access" pages. Add
UI and class interface for the new menutool_mode config option.
2002-11-18 Daniel Elstner <daniel.elstner@gmx.net>
* src/aboutdialog.{cc,h}: New files, implementing stand-alone
......
......@@ -26,19 +26,10 @@
#include <algorithm>
#include <memory>
#include <config.h>
namespace
{
const char regexxer_icon_filename[] = REGEXXER_DATADIR G_DIR_SEPARATOR_S
"pixmaps" G_DIR_SEPARATOR_S "regexxer.png";
const char regexxer_author_list[] = "Daniel Elstner <daniel.elstner@gmx.net>";
const char regexxer_project_url[] = "http://regexxer.sourceforge.net/";
class ImageLabel : public Gtk::HBox
{
public:
......@@ -51,7 +42,7 @@ ImageLabel::ImageLabel(const Gtk::StockID& stock_id, const Glib::ustring& label)
Gtk::HBox(false, 2)
{
pack_start(*Gtk::manage(new Gtk::Image(stock_id, Gtk::ICON_SIZE_MENU)), Gtk::PACK_SHRINK);
pack_start(*Gtk::manage(new Gtk::Label(label)), Gtk::PACK_SHRINK);
pack_start(*Gtk::manage(new Gtk::Label(label, true)), Gtk::PACK_SHRINK);
show_all_children();
}
......@@ -68,11 +59,17 @@ namespace Regexxer
PrefDialog::PrefDialog(Gtk::Window& parent)
:
Gtk::Dialog ("Preferences", parent),
button_menu_and_tool_ (0),
button_menu_only_ (0),
button_tool_only_ (0),
label_toolbar_ (0),
box_toolbar_ (0),
button_icons_ (0),
button_text_ (0),
button_both_ (0),
button_both_horiz_ (0),
entry_fallback_ (0),
current_menutool_mode_ (MODE_MENU_AND_TOOL),
current_toolbar_style_ (Gtk::TOOLBAR_ICONS)
{
using namespace Gtk;
......@@ -84,14 +81,14 @@ PrefDialog::PrefDialog(Gtk::Window& parent)
box->pack_start(*manage(notebook));
{
std::auto_ptr<Widget> label (new ImageLabel(Stock::PROPERTIES, "Options"));
Widget *const page = create_page_options();
std::auto_ptr<Widget> label (new ImageLabel(Stock::PREFERENCES, "_Look'n'feel"));
Widget *const page = create_page_look();
notebook->append_page(*manage(page), *manage(label.release()));
}
{
std::auto_ptr<Widget> label (new ImageLabel(StockID("regexxer-info"), "Info"));
Widget *const page = create_page_info();
std::auto_ptr<Widget> label (new ImageLabel(Stock::PROPERTIES, "_File access"));
Widget *const page = create_page_file();
notebook->append_page(*manage(page), *manage(label.release()));
}
......@@ -102,6 +99,23 @@ PrefDialog::PrefDialog(Gtk::Window& parent)
PrefDialog::~PrefDialog()
{}
void PrefDialog::set_pref_menutool_mode(MenuToolMode menutool_mode)
{
Gtk::RadioButton* button = 0;
switch(menutool_mode)
{
case MODE_MENU_AND_TOOL: button = button_menu_and_tool_; break;
case MODE_MENU_ONLY: button = button_menu_only_; break;
case MODE_TOOL_ONLY: button = button_tool_only_; break;
}
g_return_if_fail(button != 0);
current_menutool_mode_ = menutool_mode;
button->set_active(true);
}
void PrefDialog::set_pref_toolbar_style(Gtk::ToolbarStyle toolbar_style)
{
Gtk::RadioButton* button = 0;
......@@ -134,125 +148,138 @@ void PrefDialog::on_response(int)
hide();
}
Gtk::Widget* PrefDialog::create_page_options()
Gtk::Widget* PrefDialog::create_page_look()
{
using namespace Gtk;
std::auto_ptr<Box> page (new VBox(false, 0));
std::auto_ptr<Table> page (new Table(2, 2, false));
page->set_border_width(10);
page->set_row_spacings(20);
page->set_col_spacings(10);
{
Box *const box_toolbar = new HBox(false, 10);
page->pack_start(*manage(box_toolbar), PACK_EXPAND_PADDING);
box_toolbar->set_border_width(10);
box_toolbar->pack_start(*manage(new Label("Toolbar style:", 0.0, 0.5)), PACK_SHRINK);
page->attach(*manage(new Label("User interface:", 0.0, 0.5)), 0, 1, 0, 1, FILL, FILL);
Box *const box_radio = new VBox(true, 0);
box_toolbar->pack_start(*manage(box_radio), PACK_SHRINK);
page->attach(*manage(box_radio), 1, 2, 0, 1, FILL, FILL);
RadioButton::Group radio_group;
button_menu_and_tool_ = new RadioButton(radio_group, "Menu bar _and toolbar", true);
box_radio->pack_start(*manage(button_menu_and_tool_), PACK_SHRINK);
button_menu_only_ = new RadioButton(radio_group, "_Menu bar only", true);
box_radio->pack_start(*manage(button_menu_only_), PACK_SHRINK);
button_tool_only_ = new RadioButton(radio_group, "_Toolbar only", true);
box_radio->pack_start(*manage(button_tool_only_), PACK_SHRINK);
const SigC::Slot0<void> slot_toggled
(SigC::slot(*this, &PrefDialog::on_radio_menutool_mode_toggled));
button_menu_and_tool_->signal_toggled().connect(slot_toggled);
button_menu_only_ ->signal_toggled().connect(slot_toggled);
button_tool_only_ ->signal_toggled().connect(slot_toggled);
}
{
label_toolbar_ = new Label("Toolbar style:", 0.0, 0.5);
page->attach(*manage(label_toolbar_), 0, 1, 1, 2, FILL, FILL);
box_toolbar_ = new VBox(true, 0);
page->attach(*manage(box_toolbar_), 1, 2, 1, 2, FILL, FILL);
RadioButton::Group radio_group;
button_icons_ = new RadioButton(radio_group, "_Icons only", true);
box_radio->pack_start(*manage(button_icons_), PACK_SHRINK);
box_toolbar_->pack_start(*manage(button_icons_), PACK_SHRINK);
button_text_ = new RadioButton(radio_group, "_Text only", true);
box_radio->pack_start(*manage(button_text_), PACK_SHRINK);
box_toolbar_->pack_start(*manage(button_text_), PACK_SHRINK);
button_both_ = new RadioButton(radio_group, "Icons _and text", true);
box_radio->pack_start(*manage(button_both_), PACK_SHRINK);
box_toolbar_->pack_start(*manage(button_both_), PACK_SHRINK);
button_both_horiz_ = new RadioButton(radio_group, "Both _horizontal", true);
box_radio->pack_start(*manage(button_both_horiz_), PACK_SHRINK);
box_toolbar_->pack_start(*manage(button_both_horiz_), PACK_SHRINK);
const SigC::Slot0<void> slot_toggled (SigC::slot(*this, &PrefDialog::on_radio_toggled));
const SigC::Slot0<void> slot_toggled
(SigC::slot(*this, &PrefDialog::on_radio_toolbar_style_toggled));
button_icons_ ->signal_toggled().connect(slot_toggled);
button_text_ ->signal_toggled().connect(slot_toggled);
button_both_ ->signal_toggled().connect(slot_toggled);
button_both_horiz_->signal_toggled().connect(slot_toggled);
}
{
Box *const box_encoding = new VBox(false, 10);
page->pack_start(*manage(box_encoding), PACK_EXPAND_PADDING);
box_encoding->set_border_width(10);
Label *const label_info = new Label("regexxer attempts to read a file in the following "
"encodings before giving up:", 0.0, 0.5);
box_encoding->pack_start(*manage(label_info), PACK_SHRINK);
label_info->set_line_wrap(true);
return page.release();
}
Table *const table = new Table(3, 2, false);
box_encoding->pack_start(*manage(table), PACK_SHRINK);
table->set_col_spacings(3);
Gtk::Widget* PrefDialog::create_page_file()
{
using namespace Gtk;
table->attach(*manage(new Label("1.", 1.0, 0.5)), 0, 1, 0, 1, FILL, FILL);
table->attach(*manage(new Label("2.", 1.0, 0.5)), 0, 1, 1, 2, FILL, FILL);
table->attach(*manage(new Label("3.", 1.0, 0.5)), 0, 1, 2, 3, FILL, FILL);
std::auto_ptr<Box> page (new VBox(false, 10));
page->set_border_width(10);
Label *const label_utf8 = new Label("UTF-8", 0.0, 0.5);
table->attach(*manage(label_utf8), 1, 2, 0, 1, FILL, FILL);
Label *const label_info = new Label("regexxer attempts to read a file in the following "
"encodings before giving up:", 0.0, 0.5);
page->pack_start(*manage(label_info), PACK_SHRINK);
label_info->set_line_wrap(true);
Label *const label_locale = new Label("The encoding specified by the current locale", 0.0, 0.5);
table->attach(*manage(label_locale), 1, 2, 1, 2, FILL, FILL);
Table *const table = new Table(3, 2, false);
page->pack_start(*manage(table), PACK_SHRINK);
table->set_col_spacings(3);
Box *const box_fallback = new HBox(false, 5);
table->attach(*manage(box_fallback), 1, 2, 2, 3, EXPAND|FILL, FILL);
table->attach(*manage(new Label("1.", 1.0, 0.5)), 0, 1, 0, 1, FILL, FILL);
table->attach(*manage(new Label("2.", 1.0, 0.5)), 0, 1, 1, 2, FILL, FILL);
table->attach(*manage(new Label("3.", 1.0, 0.5)), 0, 1, 2, 3, FILL, FILL);
Label *const label_fallback = new Label("Fallback _encoding:", 0.0, 0.5, true);
box_fallback->pack_start(*manage(label_fallback), PACK_SHRINK);
Label *const label_utf8 = new Label("UTF-8", 0.0, 0.5);
table->attach(*manage(label_utf8), 1, 2, 0, 1, FILL, FILL);
entry_fallback_ = new Entry();
box_fallback->pack_start(*manage(entry_fallback_), PACK_EXPAND_WIDGET);
Label *const label_locale = new Label("The encoding specified by the current locale", 0.0, 0.5);
table->attach(*manage(label_locale), 1, 2, 1, 2, FILL, FILL);
label_fallback->set_mnemonic_widget(*entry_fallback_);
Box *const box_fallback = new HBox(false, 5);
table->attach(*manage(box_fallback), 1, 2, 2, 3, EXPAND|FILL, FILL);
const Glib::RefPtr<SizeGroup> size_group = SizeGroup::create(SIZE_GROUP_VERTICAL);
size_group->add_widget(*label_utf8);
size_group->add_widget(*label_locale);
size_group->add_widget(*box_fallback);
Label *const label_fallback = new Label("Fallback _encoding:", 0.0, 0.5, true);
box_fallback->pack_start(*manage(label_fallback), PACK_SHRINK);
entry_fallback_->signal_activate().connect(
SigC::slot(*this, &PrefDialog::on_entry_fallback_activate));
}
entry_fallback_ = new Entry();
box_fallback->pack_start(*manage(entry_fallback_), PACK_EXPAND_WIDGET);
return page.release();
}
label_fallback->set_mnemonic_widget(*entry_fallback_);
Gtk::Widget* PrefDialog::create_page_info()
{
using namespace Gtk;
std::auto_ptr<Alignment> page (new Alignment(0.5, 0.33, 0.0, 0.0));
const Glib::RefPtr<SizeGroup> size_group = SizeGroup::create(SIZE_GROUP_VERTICAL);
size_group->add_widget(*label_utf8);
size_group->add_widget(*label_locale);
size_group->add_widget(*box_fallback);
Box *const box = new VBox(false, 10);
page->add(*manage(box));
box->set_border_width(10);
entry_fallback_->signal_activate().connect(
SigC::slot(*this, &PrefDialog::on_entry_fallback_activate));
Box *const box_title = new HBox(false, 10);
box->pack_start(*manage(box_title), PACK_SHRINK);
box_title->set_border_width(10);
Image *const image = new Image(regexxer_icon_filename);
box_title->pack_start(*manage(image), PACK_EXPAND_WIDGET);
image->set_alignment(1.0, 0.5);
Label *const label_title = new Label();
box_title->pack_start(*manage(label_title), PACK_EXPAND_WIDGET);
label_title->set_alignment(0.0, 0.5);
label_title->set_markup("<span size=\"xx-large\" weight=\"heavy\">" PACKAGE_STRING "</span>");
return page.release();
}
Label *const label_mail = new Label(regexxer_author_list);
box->pack_start(*manage(label_mail), PACK_SHRINK);
label_mail->set_selectable(true);
void PrefDialog::on_radio_menutool_mode_toggled()
{
const MenuToolMode menutool_mode =
(button_menu_and_tool_->get_active() ? MODE_MENU_AND_TOOL :
(button_menu_only_ ->get_active() ? MODE_MENU_ONLY : MODE_TOOL_ONLY));
Label *const label_url = new Label(regexxer_project_url);
box->pack_start(*manage(label_url), PACK_SHRINK);
label_url->set_selectable(true);
label_toolbar_->set_sensitive(menutool_mode != MODE_MENU_ONLY);
box_toolbar_ ->set_sensitive(menutool_mode != MODE_MENU_ONLY);
return page.release();
if(menutool_mode != current_menutool_mode_)
{
current_menutool_mode_ = menutool_mode;
signal_pref_menutool_mode_changed(menutool_mode); // emit
}
}
void PrefDialog::on_radio_toggled()
void PrefDialog::on_radio_toolbar_style_toggled()
{
const Gtk::ToolbarStyle toolbar_style =
(button_icons_->get_active() ? Gtk::TOOLBAR_ICONS :
......
......@@ -21,12 +21,16 @@
#ifndef REGEXXER_PREFDIALOG_H_INCLUDED
#define REGEXXER_PREFDIALOG_H_INCLUDED
#include "configdata.h"
#include <gtkmm/dialog.h>
#include <gtkmm/toolbar.h>
namespace Gtk
{
class Box;
class Entry;
class Label;
class RadioButton;
}
......@@ -40,9 +44,11 @@ public:
explicit PrefDialog(Gtk::Window& parent);
virtual ~PrefDialog();
void set_pref_menutool_mode(MenuToolMode menutool_mode);
void set_pref_toolbar_style(Gtk::ToolbarStyle toolbar_style);
void set_pref_fallback_encoding(const std::string& fallback_encoding);
SigC::Signal1<void,MenuToolMode> signal_pref_menutool_mode_changed;
SigC::Signal1<void,Gtk::ToolbarStyle> signal_pref_toolbar_style_changed;
SigC::Signal1<void,const std::string&> signal_pref_fallback_encoding_changed;
......@@ -50,17 +56,28 @@ protected:
virtual void on_response(int response_id);
private:
Gtk::RadioButton* button_menu_and_tool_;
Gtk::RadioButton* button_menu_only_;
Gtk::RadioButton* button_tool_only_;
Gtk::Label* label_toolbar_;
Gtk::Box* box_toolbar_;
Gtk::RadioButton* button_icons_;
Gtk::RadioButton* button_text_;
Gtk::RadioButton* button_both_;
Gtk::RadioButton* button_both_horiz_;
Gtk::Entry* entry_fallback_;
MenuToolMode current_menutool_mode_;
Gtk::ToolbarStyle current_toolbar_style_;
Gtk::Widget* create_page_options();
Gtk::Widget* create_page_info();
Gtk::Widget* create_page_look();
Gtk::Widget* create_page_file();
void on_radio_toggled();
void on_radio_menutool_mode_toggled();
void on_radio_toolbar_style_toggled();
void on_entry_fallback_activate();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment