Commit 1191bd1b authored by Fabien Parent's avatar Fabien Parent
Browse files

Port to Gtkmm 3.0 and gtksourceviewmm 3.0

parent df37aa7d
......@@ -36,8 +36,8 @@ AM_GNU_GETTEXT_VERSION([0.11])
AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES([REGEXXER_MODULES],
[gtk+-2.0 >= 2.16.0 gtkmm-2.4 >= 2.12.0 glibmm-2.4 >= 2.27.4.1
gtksourceviewmm-2.0 >= 2.9.0])
[gtkmm-3.0 >= 2.99.5 glibmm-2.4 >= 2.27.94
gtksourceviewmm-3.0 >= 2.91.5])
DK_PKG_PATH_PROG([GDK_PIXBUF_CSOURCE], [gdk-pixbuf-2.0], [gdk-pixbuf-csource])
DK_PKG_PATH_PROG([GTK_UPDATE_ICON_CACHE], [gtk+-2.0], [gtk-update-icon-cache])
......
......@@ -29,6 +29,7 @@
#include <glib.h>
#include <algorithm>
#include <list>
#include <vector>
#include <config.h>
......@@ -79,8 +80,8 @@ RegexxerTags::RegexxerTags()
Glib::RefPtr<Gio::Settings> settings = Regexxer::Settings::instance();
settings->signal_changed().connect(sigc::mem_fun(*this, &RegexxerTags::on_conf_value_changed));
std::vector<std::string> keys = settings->list_keys();
for (std::vector<std::string>::iterator i = keys.begin(); i != keys.end(); ++i)
std::vector<Glib::ustring> keys = settings->list_keys();
for (std::vector<Glib::ustring>::iterator i = keys.begin(); i != keys.end(); ++i)
on_conf_value_changed(*i);
}
......@@ -159,7 +160,7 @@ public:
FileBuffer::FileBuffer()
:
gtksourceview::SourceBuffer(Glib::RefPtr<Gtk::TextTagTable>(RegexxerTags::instance())),
Gsv::SourceBuffer(Glib::RefPtr<Gtk::TextTagTable>(RegexxerTags::instance())),
match_set_ (),
current_match_ (match_set_.end()),
user_action_stack_ (),
......@@ -641,7 +642,7 @@ void FileBuffer::on_erase(const FileBuffer::iterator& rbegin, const FileBuffer::
++backward_chars;
--pos;
typedef std::list< Glib::RefPtr<Mark> > MarkList;
typedef std::vector< Glib::RefPtr<Mark> > MarkList;
const MarkList marks (const_cast<iterator&>(pos).get_marks()); // XXX
for (MarkList::const_iterator pmark = marks.begin(); pmark != marks.end(); ++pmark)
......@@ -787,7 +788,7 @@ void FileBuffer::replace_match(MatchSet::const_iterator pos, const Glib::ustring
*/
void FileBuffer::remove_match_at_iter(const FileBuffer::iterator& start)
{
typedef std::list< Glib::RefPtr<Mark> > MarkList;
typedef std::vector< Glib::RefPtr<Mark> > MarkList;
const MarkList marks (const_cast<iterator&>(start).get_marks()); // XXX
for (MarkList::const_iterator pmark = marks.begin(); pmark != marks.end(); ++pmark)
......@@ -883,7 +884,7 @@ void FileBuffer::apply_tag_current()
// static
bool FileBuffer::is_match_start(const iterator& where)
{
typedef std::list< Glib::RefPtr<Mark> > MarkList;
typedef std::vector< Glib::RefPtr<Mark> > MarkList;
const MarkList marks (const_cast<iterator&>(where).get_marks()); // XXX
return (std::find_if(marks.begin(), marks.end(), &MatchData::is_match_mark) != marks.end());
......
......@@ -36,7 +36,7 @@ namespace Regexxer
class FileBufferActionRemoveMatch;
class FileBuffer : public gtksourceview::SourceBuffer
class FileBuffer : public Gsv::SourceBuffer
{
public:
static Glib::RefPtr<FileBuffer> create();
......
......@@ -29,8 +29,6 @@
#include <gtksourceviewmm.h>
#include <cstring>
namespace Gsv=gtksourceview;
namespace
{
......
......@@ -279,17 +279,16 @@ int FileTree::get_modified_count() const
/**** Regexxer::FileTree -- protected **************************************/
void FileTree::on_style_changed(const Glib::RefPtr<Gtk::Style>& previous_style)
void FileTree::on_style_updated()
{
const Glib::ustring detail = "regexxer-filetree";
pixbuf_directory_ = render_icon_pixbuf(Gtk::Stock::DIRECTORY, Gtk::ICON_SIZE_MENU);
pixbuf_file_ = render_icon_pixbuf(Gtk::Stock::FILE, Gtk::ICON_SIZE_MENU);
pixbuf_load_failed_ = render_icon_pixbuf(Gtk::Stock::MISSING_IMAGE, Gtk::ICON_SIZE_MENU);
pixbuf_directory_ = render_icon(Gtk::Stock::DIRECTORY, Gtk::ICON_SIZE_MENU, detail);
pixbuf_file_ = render_icon(Gtk::Stock::FILE, Gtk::ICON_SIZE_MENU, detail);
pixbuf_load_failed_ = render_icon(Gtk::Stock::MISSING_IMAGE, Gtk::ICON_SIZE_MENU, detail);
Gdk::RGBA rgba = get_style_context()->get_color(Gtk::STATE_FLAG_INSENSITIVE);
color_load_failed_.set_rgb_p(rgba.get_red(), rgba.get_green(), rgba.get_blue());
color_load_failed_ = get_style()->get_text(Gtk::STATE_INSENSITIVE);
Gtk::TreeView::on_style_changed(previous_style);
Gtk::TreeView::on_style_updated();
}
/**** Regexxer::FileTree -- private ****************************************/
......@@ -914,14 +913,14 @@ void FileTree::load_file_with_fallback(const Gtk::TreeModel::iterator& iter,
catch (const Glib::Error& error)
{
fileinfo->buffer = FileBuffer::create_with_error_message(
render_icon(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG), error.what());
render_icon_pixbuf(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG), error.what());
}
catch (const ErrorBinaryFile&)
{
const Glib::ustring filename = (*iter)[FileTreeColumns::instance().filename];
fileinfo->buffer = FileBuffer::create_with_error_message(
render_icon(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG),
render_icon_pixbuf(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG),
Util::compose(_("\342\200\234%1\342\200\235 seems to be a binary file."), filename));
}
......
......@@ -77,7 +77,7 @@ public:
sigc::signal<void, int, const Glib::ustring&, FileInfoPtr> signal_feedback;
protected:
virtual void on_style_changed(const Glib::RefPtr<Gtk::Style>& previous_style);
virtual void on_style_updated();
private:
class TreeRowRef;
......
......@@ -24,7 +24,7 @@
#include "translation.h"
#include <glib.h>
#include <gtk/gtkwindow.h> /* for gtk_window_set_default_icon_name() */
#include <gtk/gtk.h> /* for gtk_window_set_default_icon_name() */
#include <glibmm.h>
#include <gtkmm/iconfactory.h>
#include <gtkmm/iconset.h>
......@@ -168,7 +168,7 @@ void register_stock_items()
for (unsigned int item = 0; item < G_N_ELEMENTS(regexxer_stock_items); ++item)
{
const StockItemData& stock = regexxer_stock_items[item];
Gtk::IconSet icon_set;
Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
for (int icon = 0; icon < stock.n_icons; ++icon)
{
......@@ -181,7 +181,7 @@ void register_stock_items()
// Unset wildcarded for all but the the last icon.
source.set_size_wildcarded(icon == stock.n_icons - 1);
icon_set.add_source(source);
icon_set->add_source(source);
}
const Gtk::StockID stock_id (stock.id);
......@@ -203,7 +203,7 @@ int main(int argc, char** argv)
std::auto_ptr<RegexxerOptions> options = RegexxerOptions::create();
Gtk::Main main_instance (argc, argv, options->context());
gtksourceview::init();
Gsv::init();
Gio::init();
Glib::set_application_name(PACKAGE_NAME);
......
......@@ -181,7 +181,7 @@ MainWindow::MainWindow()
toolbar_ (0),
table_file_ (0),
button_folder_ (0),
combo_entry_pattern_ (Gtk::manage(new Gtk::ComboBoxEntryText())),
combo_entry_pattern_ (Gtk::manage(new Gtk::ComboBoxText(true))),
button_recursive_ (0),
button_hidden_ (0),
entry_regex_ (0),
......@@ -195,7 +195,7 @@ MainWindow::MainWindow()
filetree_ (Gtk::manage(new FileTree())),
scrollwin_filetree_ (0),
scrollwin_textview_ (0),
textview_ (Gtk::manage(new gtksourceview::SourceView())),
textview_ (Gtk::manage(new Gsv::SourceView())),
entry_preview_ (0),
statusline_ (Gtk::manage(new StatusLine())),
busy_action_running_ (false),
......@@ -213,7 +213,7 @@ MainWindow::MainWindow()
vbox_main_->pack_start(*statusline_, Gtk::PACK_SHRINK);
scrollwin_filetree_->add(*filetree_);
table_file_->attach(*combo_entry_pattern_, 1, 2, 1, 2);
table_file_->attach(*combo_entry_pattern_, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
scrollwin_textview_->add(*textview_);
......@@ -254,17 +254,16 @@ void MainWindow::initialize(const InitState& init)
const bool folder_exists = button_folder_->set_current_folder(folder);
combo_entry_pattern_->get_entry()->set_text((init.pattern.empty()) ? Glib::ustring(1, '*') : init.pattern);
entry_regex_ ->set_text(init.regex);
entry_regex_->set_text(init.regex);
entry_regex_->set_completion(entry_regex_completion_);
entry_substitution_->set_text(init.substitution);
entry_substitution_->set_completion(entry_substitution_completion_);
comboboxentry_regex_->set_model(entry_regex_completion_stack_.get_completion_model());
comboboxentry_regex_->set_text_column(entry_regex_completion_stack_.get_completion_column());
comboboxentry_regex_->set_entry_text_column(entry_regex_completion_stack_.get_completion_column());
comboboxentry_substitution_->set_model(entry_substitution_completion_stack_.get_completion_model());
comboboxentry_substitution_->set_text_column(entry_substitution_completion_stack_.get_completion_column());
comboboxentry_substitution_->set_entry_text_column(entry_substitution_completion_stack_.get_completion_column());
entry_regex_completion_->set_model(entry_regex_completion_stack_.get_completion_model());
entry_regex_completion_->set_text_column(entry_regex_completion_stack_.get_completion_column());
......@@ -281,13 +280,14 @@ void MainWindow::initialize(const InitState& init)
button_multiple_ ->set_active(!init.no_global);
button_caseless_ ->set_active(init.ignorecase);
combo_entry_pattern_->set_entry_text_column(0);
const std::list<Glib::ustring> patterns =
settings->get_string_array(conf_key_files_patterns);
for (std::list<Glib::ustring>::const_iterator pattern = patterns.begin();
pattern != patterns.end();
++pattern)
{
combo_entry_pattern_->append_text(*pattern);
combo_entry_pattern_->append(*pattern);
}
if (init.feedback)
......@@ -338,7 +338,7 @@ void MainWindow::connect_signals()
using sigc::mem_fun;
window_->signal_hide ().connect(mem_fun(*this, &MainWindow::on_hide));
window_->signal_style_changed().connect(mem_fun(*this, &MainWindow::on_style_changed));
window_->signal_style_updated().connect(mem_fun(*this, &MainWindow::on_style_updated));
window_->signal_delete_event ().connect(mem_fun(*this, &MainWindow::on_delete_event));
combo_entry_pattern_->get_entry()->signal_activate().connect(controller_.find_files.slot());
......@@ -422,7 +422,7 @@ void MainWindow::on_hide()
}
}
void MainWindow::on_style_changed(const Glib::RefPtr<Gtk::Style>&)
void MainWindow::on_style_updated()
{
FileBuffer::pango_context_changed(window_->get_pango_context());
}
......@@ -995,6 +995,9 @@ void MainWindow::on_about()
else
{
std::auto_ptr<Gtk::AboutDialog> dialog (new Gtk::AboutDialog());
std::vector<Glib::ustring> authors;
for (int i = 0; program_authors[i]; i++)
authors.push_back(program_authors[i]);
dialog->set_version(PACKAGE_VERSION);
dialog->set_logo_icon_name(PACKAGE_TARNAME);
......@@ -1002,7 +1005,7 @@ void MainWindow::on_about()
dialog->set_copyright("Copyright \302\251 2002-2007 Daniel Elstner");
dialog->set_website("http://regexxer.sourceforge.net/");
dialog->set_authors(program_authors);
dialog->set_authors(authors);
dialog->set_translator_credits(_("translator-credits"));
dialog->set_license(program_license);
dialog->set_wrap_license(true);
......@@ -1049,9 +1052,14 @@ void MainWindow::on_conf_value_changed(const Glib::ustring& key)
{
if (key == conf_key_textview_font)
{
const Pango::FontDescription font (Settings::instance()->get_string(key));
textview_ ->modify_font(font);
entry_preview_->modify_font(font);
std::string style = "GtkTextView { font: ";
style += Settings::instance()->get_string(key);
style += "}";
Glib::RefPtr<Gtk::CssProvider> css = Gtk::CssProvider::create();
css->load_from_data(style, style.size());
textview_ ->get_style_context()->add_provider(css, 1);
entry_preview_->get_style_context()->add_provider(css, 1);
}
}
......
......@@ -42,15 +42,15 @@ class Entry;
class FileChooser;
class Toolbar;
class Window;
class ComboBoxEntry;
class ComboBoxEntryText;
class ComboBox;
class ComboBoxText;
class VBox;
class ScrolledWindow;
class Table;
class EntryCompletion;
}
namespace gtksourceview
namespace Gsv
{
class SourceView;
}
......@@ -102,17 +102,17 @@ private:
Gtk::Table* table_file_;
Gtk::FileChooser* button_folder_;
Gtk::ComboBoxEntryText* combo_entry_pattern_;
Gtk::ComboBoxText* combo_entry_pattern_;
Gtk::CheckButton* button_recursive_;
Gtk::CheckButton* button_hidden_;
Gtk::ComboBoxEntry* comboboxentry_regex_;
Gtk::ComboBoxText* comboboxentry_regex_;
Gtk::Entry* entry_regex_;
CompletionStack entry_regex_completion_stack_;
Glib::RefPtr<Gtk::EntryCompletion> entry_regex_completion_;
Gtk::ComboBoxEntry* comboboxentry_substitution_;
Gtk::ComboBoxText* comboboxentry_substitution_;
Gtk::Entry* entry_substitution_;
CompletionStack entry_substitution_completion_stack_;
Glib::RefPtr<Gtk::EntryCompletion> entry_substitution_completion_;
......@@ -123,7 +123,7 @@ private:
FileTree* filetree_;
Gtk::ScrolledWindow* scrollwin_filetree_;
Gtk::ScrolledWindow* scrollwin_textview_;
gtksourceview::SourceView* textview_;
Gsv::SourceView* textview_;
Gtk::Entry* entry_preview_;
StatusLine* statusline_;
......@@ -145,7 +145,7 @@ private:
void save_window_state();
void on_hide();
void on_style_changed(const Glib::RefPtr<Gtk::Style>& previous_style);
void on_style_updated();
bool on_delete_event(GdkEventAny* event);
void on_cut();
......
......@@ -26,7 +26,7 @@
#include <glib.h>
#include <gtkmm.h>
#include <list>
#include <vector>
#include <config.h>
......@@ -138,9 +138,9 @@ void PrefDialog::on_conf_value_changed(const Glib::ustring& key)
void PrefDialog::initialize_configuration()
{
Glib::RefPtr<Gio::Settings> settings = Settings::instance();
const std::list<Glib::ustring> entries = settings->list_keys();
const std::vector<Glib::ustring> entries = settings->list_keys();
for (std::list<Glib::ustring>::const_iterator p = entries.begin(); p != entries.end(); ++p)
for (std::vector<Glib::ustring>::const_iterator p = entries.begin(); p != entries.end(); ++p)
on_conf_value_changed(*p);
settings->bind(conf_key_textview_font, button_textview_font_, "font_name");
......
......@@ -55,7 +55,7 @@ private:
Glib::ustring number_to_string(int number);
void recalculate_label_width();
void on_label_style_changed(const Glib::RefPtr<Gtk::Style>& previous_style);
void on_label_style_updated();
};
CounterBox::CounterBox(const Glib::ustring& label)
......@@ -89,8 +89,8 @@ CounterBox::CounterBox(const Glib::ustring& label)
label_index_->set_single_line_mode(true);
label_count_->set_single_line_mode(true);
label_index_->signal_style_changed().connect(
sigc::mem_fun(*this, &CounterBox::on_label_style_changed));
label_index_->signal_style_updated().connect(
sigc::mem_fun(*this, &CounterBox::on_label_style_updated));
try // don't abort if the user-specified locale doesn't exist
{
......@@ -184,7 +184,7 @@ void CounterBox::recalculate_label_width()
* The code relies on both labels having the same style.
* I think that's a quite safe assumption to make ;)
*/
void CounterBox::on_label_style_changed(const Glib::RefPtr<Gtk::Style>&)
void CounterBox::on_label_style_updated()
{
const Glib::RefPtr<Pango::Layout> layout = label_index_->create_pango_layout("");
......@@ -233,17 +233,19 @@ StatusLine::StatusLine()
// The statusbar looks ugly if the stop button gets its default size,
// so let's reduce the button's size request to a reasonable amount.
RC::parse_string("style \"regexxer-stop-button-style\"\n"
"{\n"
" ythickness = 0\n"
" GtkWidget::interior_focus = 0\n"
" GtkWidget::focus_padding = 0\n"
"}\n"
"widget \"*.regexxer-stop-button\" style \"regexxer-stop-button-style\"\n");
std::string style = "GtkButton#regexxer-stop-button\n"
"{\n"
" padding-left: 0;"
" -GtkWidget-interior-focus: 0;\n"
" -GtkWidget-focus-padding: 0;\n"
"}";
Glib::RefPtr<Gtk::CssProvider> css = Gtk::CssProvider::create();
css->load_from_data(style, style.size());
stop_button_ = new Button(_("Stop"));
pack_start(*manage(stop_button_), PACK_SHRINK);
stop_button_->set_name("regexxer-stop-button");
stop_button_->get_style_context()->add_provider(css, 1);
progressbar_ = new ProgressBar();
pack_start(*manage(progressbar_), PACK_SHRINK);
......@@ -326,7 +328,7 @@ void StatusLine::on_hierarchy_changed(Gtk::Widget* previous_toplevel)
if (Gtk::Window *const window = dynamic_cast<Gtk::Window*>(previous_toplevel))
{
stop_button_->remove_accelerator(
window->get_accel_group(), GDK_Escape, Gdk::ModifierType(0));
window->get_accel_group(), GDK_KEY_Escape, Gdk::ModifierType(0));
}
Gtk::HBox::on_hierarchy_changed(previous_toplevel);
......@@ -335,7 +337,7 @@ void StatusLine::on_hierarchy_changed(Gtk::Widget* previous_toplevel)
{
stop_button_->add_accelerator(
"activate", window->get_accel_group(),
GDK_Escape, Gdk::ModifierType(0), Gtk::AccelFlags(0));
GDK_KEY_Escape, Gdk::ModifierType(0), Gtk::AccelFlags(0));
}
}
......
This diff is collapsed.
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