Commit 2c626c19 authored by Fabien Parent's avatar Fabien Parent
Browse files

Remove dependencies libglade and gmodule. Using of GtkBuilder instead.

parent 6bd92a0e
......@@ -75,11 +75,9 @@ rxlocaledir = $(prefix)/$(DATADIRNAME)/locale
global_defs = -DREGEXXER_LOCALEDIR=\""$(rxlocaledir)"\" -DREGEXXER_PKGDATADIR=\""$(pkgdatadir)"\"
AM_CPPFLAGS = $(global_defs) -I$(top_builddir) $(REGEXXER_MODULES_CFLAGS) $(REGEXXER_WARNING_FLAGS)
src_regexxer_DEPENDENCIES = src/exported-symbols
src_regexxer_LDFLAGS = $(REGEXXER_VERSION_SCRIPT)
src_regexxer_LDADD = $(REGEXXER_MODULES_LIBS) $(INTLLIBS)
dist_pkgdata_DATA = ui/mainwindow.glade ui/prefdialog.glade
dist_pkgdata_DATA = ui/mainwindow.ui ui/prefdialog.ui
iconthemedir = $(datadir)/icons/hicolor
appicondir = $(iconthemedir)/48x48/apps
......@@ -96,8 +94,7 @@ desktop_DATA = ui/regexxer.desktop
dist_intltool = intltool-extract.in intltool-merge.in intltool-update.in
stockimages = ui/stock_save_all_16.png ui/stock_save_all_24.png
dist_noinst_DATA = src/exported-symbols $(stockimages) $(dist_intltool) \
$(desktop_in_files) $(schemas_in_files)
dist_noinst_DATA = $(stockimages) $(dist_intltool) $(desktop_in_files) $(schemas_in_files)
dist_noinst_SCRIPTS = autogen.sh
BUILT_SOURCES = $(nodist_src_regexxer_SOURCES)
......
......@@ -38,8 +38,7 @@ AM_GLIB_GNU_GETTEXT
# gmodule-export-2.0 adds -Wl,--export-dynamic to the linker flags
# so that libglade can get at the custom widget creation functions.
PKG_CHECK_MODULES([REGEXXER_MODULES],
[gmodule-export-2.0 >= 2.6.1 gtkmm-2.4 >= 2.6.0 libglademm-2.4 >= 2.4.0
gconfmm-2.6 >= 2.6.1 libpcre >= 5.0])
[gtkmm-2.4 >= 2.12.0 gconfmm-2.6 >= 2.6.1 libpcre >= 5.0])
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])
......@@ -49,10 +48,6 @@ AM_GCONF_SOURCE_2
AC_LANG([C++])
# If the linker supports it, use a version script to limit the effect
# of --export-dynamic to the functions which need to be exported.
DK_LINK_VERSION_SCRIPT([REGEXXER_VERSION_SCRIPT], [src/exported-symbols])
# Disabling -Wnon-virtual-dtor is nasty, but unfortunately required due to
# a bug in gconfmm that triggers this warning. Not disabling this warning
# would make --enable-warnings=fatal unusable.
......
......@@ -23,7 +23,7 @@
#include <gtkmm/button.h>
#include <gtkmm/menu.h>
#include <gtkmm/toolbutton.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
#include <config.h>
......@@ -64,7 +64,7 @@ void ControlItem::add_widget(Gtk::Widget& widget)
widget.set_sensitive(enabled_ && group_enabled_);
}
void ControlItem::add_widgets(const Glib::RefPtr<Gnome::Glade::Xml>& xml,
void ControlItem::add_widgets(const Glib::RefPtr<Gtk::Builder>& xml,
const char* menuitem_name, const char* button_name)
{
const sigc::slot<void> slot_activate = slot();
......@@ -72,13 +72,19 @@ void ControlItem::add_widgets(const Glib::RefPtr<Gnome::Glade::Xml>& xml,
Gtk::MenuItem* menuitem = 0;
Gtk::Widget* widget = 0;
if (menuitem_name && xml->get_widget(menuitem_name, menuitem))
if (menuitem_name)
xml->get_widget(menuitem_name, menuitem);
if (button_name)
xml->get_widget(button_name, widget);
if (menuitem_name)
{
menuitem->signal_activate().connect(slot_activate);
add_widget(*menuitem);
}
if (button_name && xml->get_widget(button_name, widget))
if (button_name)
{
if (Gtk::ToolButton *const button = dynamic_cast<Gtk::ToolButton*>(widget))
button->signal_clicked().connect(slot_activate);
......@@ -190,7 +196,7 @@ Controller::Controller()
Controller::~Controller()
{}
void Controller::load_xml(const Glib::RefPtr<Gnome::Glade::Xml>& xml)
void Controller::load_xml(const Glib::RefPtr<Gtk::Builder>& xml)
{
save_file .add_widgets(xml, "menuitem_save", "button_save");
save_all .add_widgets(xml, "menuitem_save_all", "button_save_all");
......
......@@ -30,11 +30,9 @@ namespace Gtk
class MenuBar;
class Toolbar;
class Widget;
class Builder;
}
namespace Gnome { namespace Glade { class Xml; } }
namespace Regexxer
{
......@@ -50,7 +48,7 @@ public:
void connect(const sigc::slot<void>& slot_activated);
void add_widget(Gtk::Widget& widget);
void add_widgets(const Glib::RefPtr<Gnome::Glade::Xml>& xml,
void add_widgets(const Glib::RefPtr<Gtk::Builder>& xml,
const char* menuitem_name, const char* button_name);
void set_enabled(bool enable);
......@@ -121,7 +119,7 @@ public:
ControlItem paste;
ControlItem erase;
void load_xml(const Glib::RefPtr<Gnome::Glade::Xml>& xml);
void load_xml(const Glib::RefPtr<Gtk::Builder>& xml);
private:
Controller(const Controller&);
......
/*
* List of dynamically exported symbols for libglade.
*/
{
global: regexxer_create_*;
local: *;
};
......@@ -25,31 +25,12 @@
#include "stringutils.h"
#include "translation.h"
#include <gmodule.h>
#include <glibmm.h>
#include <gconfmm/client.h>
#include <gtkmm/stock.h>
#include <config.h>
/*
* Custom widget creation function for libglade.
*/
extern "C" G_MODULE_EXPORT
GtkWidget* regexxer_create_file_tree(char*, char*, char*, int, int)
{
try
{
Gtk::Widget *const widget = new Regexxer::FileTree();
widget->show();
return Gtk::manage(widget)->gobj();
}
catch (...)
{
g_return_val_if_reached(0);
}
}
namespace Regexxer
{
......
......@@ -39,10 +39,10 @@ const char *const conf_key_current_match_color = "/apps/regexxer/current_match_c
const char *const conf_key_toolbar_style = "/apps/regexxer/toolbar_style";
const char *const conf_key_fallback_encoding = "/apps/regexxer/fallback_encoding";
const char *const glade_mainwindow_filename = REGEXXER_PKGDATADIR G_DIR_SEPARATOR_S
"mainwindow.glade";
const char *const glade_prefdialog_filename = REGEXXER_PKGDATADIR G_DIR_SEPARATOR_S
"prefdialog.glade";
const char *const ui_mainwindow_filename = REGEXXER_PKGDATADIR G_DIR_SEPARATOR_S
"mainwindow.ui";
const char *const ui_prefdialog_filename = REGEXXER_PKGDATADIR G_DIR_SEPARATOR_S
"prefdialog.ui";
} // namespace Regexxer
......
......@@ -30,7 +30,6 @@
#include <glib.h>
#include <gtkmm.h>
#include <gconfmm/client.h>
#include <libglademm/xml.h>
#include <algorithm>
#include <functional>
#include <iostream>
......@@ -180,18 +179,20 @@ public:
MainWindow::MainWindow()
:
toolbar_ (0),
table_file_ (0),
button_folder_ (0),
entry_pattern_ (0),
combo_entry_pattern_ (Gtk::manage(new Gtk::ComboBoxEntryText())),
button_recursive_ (0),
button_hidden_ (0),
entry_regex_ (0),
entry_substitution_ (0),
button_multiple_ (0),
button_caseless_ (0),
filetree_ (0),
filetree_ (Gtk::manage(new FileTree())),
scrollwin_filetree_ (0),
textview_ (0),
entry_preview_ (0),
statusline_ (0),
statusline_ (Gtk::manage(new StatusLine())),
busy_action_running_ (false),
busy_action_cancel_ (false),
busy_action_iteration_ (0),
......@@ -202,6 +203,14 @@ MainWindow::MainWindow()
textview_->set_buffer(FileBuffer::create());
window_->set_title(PACKAGE_NAME);
vbox_main_->pack_start(*statusline_, Gtk::PACK_SHRINK);
scrollwin_filetree_->add(*filetree_);
table_file_->attach(*combo_entry_pattern_, 1, 2, 1, 2);
statusline_->show_all();
filetree_->show_all();
combo_entry_pattern_->show_all();
connect_signals();
}
......@@ -219,10 +228,21 @@ void MainWindow::initialize(const InitState& init)
const bool folder_exists = button_folder_->set_current_folder(folder);
entry_pattern_->set_text((init.pattern.empty()) ? Glib::ustring(1, '*') : init.pattern);
combo_entry_pattern_->get_entry()->set_text((init.pattern.empty()) ? Glib::ustring(1, '*') : init.pattern);
entry_regex_ ->set_text(init.regex);
entry_substitution_->set_text(init.substitution);
combo_entry_pattern_->append_text("*.[ch]");
combo_entry_pattern_->append_text("*.{c,cc,cpp,cxx,c++,C,h,hh,hpp,hxx,h++}");
combo_entry_pattern_->append_text("*.{ccg,hg}");
combo_entry_pattern_->append_text("*.idl");
combo_entry_pattern_->append_text("*.{java,jsp}");
combo_entry_pattern_->append_text("*.{pl,pm,cgi}");
combo_entry_pattern_->append_text("*.py");
combo_entry_pattern_->append_text("*.php[0-9]?");
combo_entry_pattern_->append_text("*.{html,htm,shtml,js,wml}");
combo_entry_pattern_->append_text("*.{xml,xsl,css,dtd,xsd}");
button_recursive_->set_active(!init.no_recursive);
button_hidden_ ->set_active(init.hidden);
button_multiple_ ->set_active(!init.no_global);
......@@ -247,12 +267,11 @@ void MainWindow::initialize(const InitState& init)
void MainWindow::load_xml()
{
using Gnome::Glade::Xml;
const Glib::RefPtr<Xml> xml = Xml::create(glade_mainwindow_filename);
const Glib::RefPtr<Gtk::Builder> xml = Gtk::Builder::create_from_file(ui_mainwindow_filename);
Gtk::Window* mainwindow = 0;
window_.reset(xml->get_widget("mainwindow", mainwindow));
xml->get_widget("mainwindow", mainwindow);
window_.reset(mainwindow);
xml->get_widget("toolbar", toolbar_);
xml->get_widget("button_folder", button_folder_);
......@@ -262,11 +281,11 @@ void MainWindow::load_xml()
xml->get_widget("entry_substitution", entry_substitution_);
xml->get_widget("button_multiple", button_multiple_);
xml->get_widget("button_caseless", button_caseless_);
xml->get_widget("filetree", filetree_);
xml->get_widget("textview", textview_);
xml->get_widget("entry_preview", entry_preview_);
xml->get_widget("statusline", statusline_);
xml->get_widget("combo_pattern_entry", entry_pattern_);
xml->get_widget("vbox_main", vbox_main_);
xml->get_widget("scrollwin_filetree", scrollwin_filetree_);
xml->get_widget("table_file", table_file_);
controller_.load_xml(xml);
}
......@@ -280,8 +299,8 @@ void MainWindow::connect_signals()
window_->signal_style_changed().connect(mem_fun(*this, &MainWindow::on_style_changed));
window_->signal_delete_event ().connect(mem_fun(*this, &MainWindow::on_delete_event));
entry_pattern_->signal_activate().connect(controller_.find_files.slot());
entry_pattern_->signal_changed ().connect(mem_fun(*this, &MainWindow::on_entry_pattern_changed));
combo_entry_pattern_->get_entry()->signal_activate().connect(controller_.find_files.slot());
combo_entry_pattern_->signal_changed ().connect(mem_fun(*this, &MainWindow::on_entry_pattern_changed));
entry_regex_ ->signal_activate().connect(controller_.find_matches.slot());
entry_substitution_->signal_activate().connect(controller_.find_matches.slot());
......@@ -383,7 +402,7 @@ void MainWindow::on_cut()
else
{
const int noEntries = 3;
Gtk::Entry *entries[noEntries] = { entry_pattern_, entry_regex_,
Gtk::Entry *entries[noEntries] = { combo_entry_pattern_->get_entry(), entry_regex_,
entry_substitution_ };
for (int i = 0; i < 3; i++)
{
......@@ -406,7 +425,7 @@ void MainWindow::on_copy()
else
{
const int noEntries = 3;
Gtk::Entry *entries[noEntries] = { entry_pattern_, entry_regex_,
Gtk::Entry *entries[noEntries] = { combo_entry_pattern_->get_entry(), entry_regex_,
entry_substitution_ };
for (int i = 0; i < 3; i++)
{
......@@ -430,7 +449,7 @@ void MainWindow::on_paste()
else
{
const int noEntries = 3;
Gtk::Entry *entries[noEntries] = { entry_pattern_, entry_regex_,
Gtk::Entry *entries[noEntries] = { combo_entry_pattern_->get_entry(), entry_regex_,
entry_substitution_ };
for (int i = 0; i < 3; i++)
{
......@@ -495,7 +514,7 @@ void MainWindow::on_find_files()
try
{
Pcre::Pattern pattern (Util::shell_pattern_to_regex(entry_pattern_->get_text()), Pcre::DOTALL);
Pcre::Pattern pattern (Util::shell_pattern_to_regex(combo_entry_pattern_->get_entry()->get_text()), Pcre::DOTALL);
filetree_->find_files(folder, pattern,
button_recursive_->get_active(),
......@@ -786,7 +805,7 @@ void MainWindow::undo_stack_clear()
void MainWindow::on_entry_pattern_changed()
{
controller_.find_files.set_enabled(entry_pattern_->get_text_length() > 0);
controller_.find_files.set_enabled(combo_entry_pattern_->get_entry()->get_text_length() > 0);
}
void MainWindow::update_preview()
......
......@@ -42,6 +42,10 @@ class FileChooser;
class TextView;
class Toolbar;
class Window;
class ComboBoxEntryText;
class VBox;
class ScrolledWindow;
class Table;
}
namespace Gnome { namespace Conf { class Value; } }
......@@ -85,11 +89,14 @@ private:
std::auto_ptr<Gtk::Window> window_;
Controller controller_;
Gtk::VBox* vbox_main_;
Gtk::Toolbar* toolbar_;
Gtk::Table* table_file_;
Gtk::FileChooser* button_folder_;
Gtk::Entry* entry_pattern_;
Gtk::ComboBoxEntryText* combo_entry_pattern_;
Gtk::CheckButton* button_recursive_;
Gtk::CheckButton* button_hidden_;
......@@ -99,6 +106,7 @@ private:
Gtk::CheckButton* button_caseless_;
FileTree* filetree_;
Gtk::ScrolledWindow* scrollwin_filetree_;
Gtk::TextView* textview_;
Gtk::Entry* entry_preview_;
......
......@@ -26,7 +26,6 @@
#include <glib.h>
#include <gtkmm.h>
#include <gconfmm/client.h>
#include <libglademm/xml.h>
#include <list>
#include <config.h>
......@@ -87,12 +86,12 @@ PrefDialog::~PrefDialog()
void PrefDialog::load_xml()
{
using namespace Gtk;
using Gnome::Glade::Xml;
const Glib::RefPtr<Xml> xml = Xml::create(glade_prefdialog_filename);
const Glib::RefPtr<Builder> xml = Builder::create_from_file(ui_prefdialog_filename);
Dialog* prefdialog = 0;
dialog_.reset(xml->get_widget("prefdialog", prefdialog));
xml->get_widget("prefdialog", prefdialog);
dialog_.reset(prefdialog);
xml->get_widget("button_textview_font", button_textview_font_);
xml->get_widget("button_match_color", button_match_color_);
......@@ -102,9 +101,16 @@ void PrefDialog::load_xml()
const Glib::RefPtr<SizeGroup> size_group = SizeGroup::create(SIZE_GROUP_VERTICAL);
size_group->add_widget(*xml->get_widget("label_utf8"));
size_group->add_widget(*xml->get_widget("label_locale"));
size_group->add_widget(*xml->get_widget("box_fallback"));
Label* label_utf8 = 0, *label_locale = 0;
Box* box_fallback = 0;
xml->get_widget("label_utf8", label_utf8);
xml->get_widget("label_locale", label_locale);
xml->get_widget("box_fallback", box_fallback);
size_group->add_widget(*label_utf8);
size_group->add_widget(*label_locale);
size_group->add_widget(*box_fallback);
}
void PrefDialog::connect_signals()
......
......@@ -22,31 +22,12 @@
#include "stringutils.h"
#include "translation.h"
#include <gmodule.h>
#include <gdk/gdkkeysyms.h>
#include <gtkmm.h>
#include <locale>
#include <sstream>
#include <stdexcept>
/*
* Custom widget creation function for libglade.
*/
extern "C" G_MODULE_EXPORT
GtkWidget* regexxer_create_status_line(char*, char*, char*, int, int)
{
try
{
Gtk::Widget *const widget = new Regexxer::StatusLine();
widget->show();
return Gtk::manage(widget)->gobj();
}
catch (...)
{
g_return_val_if_reached(0);
}
}
namespace Regexxer
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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