Sexy new GTK about dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10820 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2006-02-07 00:48:47 +00:00
parent d928a9d0a2
commit 670fc3e2c5
4 changed files with 107 additions and 200 deletions

View File

@ -5,6 +5,7 @@
* GBibtex.[Ch], glade/bibtex.glade: Implement bibtex dialog
* ghelpers.[Ch], GtkLengthEntry.[Ch]: Move some old stuff out of
ghelpers into GtkLengthEntry
* GAboutlyx.[Ch], glade/aboutlyx.glade: Sexy new about dialog
2006-02-05 John Spray <spray@lyx.org>

View File

@ -23,10 +23,14 @@
#include "ghelpers.h"
#include "version.h"
#include "support/filetools.h" // LibFileSearch
#include <libglademm.h>
#include <sstream>
using lyx::support::LibFileSearch;
using std::ostringstream;
using std::string;
@ -157,32 +161,66 @@ void GAboutlyx::doBuild()
{
string const gladeName = findGladeFile("aboutlyx");
xml_ = Gnome::Glade::Xml::create(gladeName);
Gtk::Label * version;
Gtk::Label * credits;
Gtk::Label * license;
xml_->get_widget("version", version);
xml_->get_widget("credits", credits);
xml_->get_widget("license", license);
std::ostringstream vs;
vs << controller().getVersion()
<< std::endl << lyx_version_info;
version->set_text(Glib::locale_to_utf8(vs.str()));
std::ostringstream crs;
controller().getCredits(crs);
credits->set_markup(
translateMarkup(Glib::convert(crs.str(),
"UTF-8",
"ISO8859-1")));
Gtk::AboutDialog *dialog;
xml_->get_widget("dialog", dialog);
dialog->set_version(Glib::ustring(PACKAGE_VERSION));
std::ostringstream ls;
ls << controller().getCopyright() << "\n\n"
<< controller().getLicense() << "\n\n"
<< controller().getDisclaimer();
license->set_text(Glib::locale_to_utf8(ls.str()));
Gtk::Button * btn;
xml_->get_widget("close_button", btn);
setCancel(btn);
//btn->signal_clicked().connect(sigc::mem_fun(*this, &GViewBase::onCancel));
dialog->set_license (ls.str());
string const filename = LibFileSearch("images", "banner", "ppm");
Glib::RefPtr<Gdk::Pixbuf> logo = Gdk::Pixbuf::create_from_file(filename);
Glib::RefPtr<Gdk::Pixbuf> logo_scaled = logo->scale_simple(
logo->get_width() / 2,
logo->get_height() / 2,
Gdk::INTERP_BILINEAR);
dialog->set_logo(logo_scaled);
// Total crack - find and hide the built in Credits button
// that glade helpfully puts there for us.
Glib::List_Iterator<Gtk::Box_Helpers::Child> it =
dialog->get_action_area()->children().begin();
Glib::List_Iterator<Gtk::Box_Helpers::Child> const end =
dialog->get_action_area()->children().end();
for (; it != end; ++it) {
Gtk::Button * button = (Gtk::Button*)(it->get_widget());
// The close button is a stock ID which we can reliably test for
// The license button has no icon
// What's left is the credits button
if (button->get_label() != "gtk-close" && button->get_image())
button->hide();
}
Gtk::Button &authorbutton = *Gtk::manage(
new Gtk::Button(_("C_redits"), true));
authorbutton.set_image(*Gtk::manage(
new Gtk::Image(Gtk::Stock::ABOUT, Gtk::ICON_SIZE_BUTTON)));
dialog->get_action_area()->pack_end(authorbutton);
dialog->get_action_area()->reorder_child(authorbutton, 0);
authorbutton.signal_clicked().connect(
sigc::mem_fun(*this, &GAboutlyx::showAuthors));
authorbutton.show();
xml_->get_widget("AuthorsDialog", authordialog_);
Gtk::Label *authorlabel;
xml_->get_widget("Authors", authorlabel);
std::ostringstream crs;
controller().getCredits(crs);
authorlabel->set_markup(translateMarkup(
Glib::convert(crs.str(), "UTF-8", "ISO-8859-1")));
}
void GAboutlyx::showAuthors()
{
authordialog_->run();
authordialog_->hide();
}
} // namespace frontend
} // namespace lyx

View File

@ -26,6 +26,9 @@ private:
virtual void apply() {}
virtual void update() {}
virtual void doBuild();
void showAuthors();
Gtk::Dialog *authordialog_;
};
} // namespace frontend

View File

@ -3,13 +3,26 @@
<glade-interface>
<widget class="GtkDialog" id="dialog">
<property name="title" translatable="yes">About LyX</property>
<widget class="GtkAboutDialog" id="dialog">
<property name="visible">True</property>
<property name="destroy_with_parent">False</property>
<property name="name" translatable="yes">LyX</property>
<property name="copyright" translatable="yes">Copyright © 1995 Matthias Ettrich
Copyright © 1995-2006 LyX Team</property>
<property name="comments" translatable="yes">The Document Processor</property>
<property name="wrap_license">True</property>
<property name="website">http://www.lyx.org</property>
<property name="website_label" translatable="yes">http://www.lyx.org</property>
<property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
</widget>
<widget class="GtkDialog" id="AuthorsDialog">
<property name="title" translatable="yes">Credits</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">300</property>
<property name="default_height">200</property>
<property name="default_height">300</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -17,7 +30,9 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">True</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
@ -31,7 +46,7 @@
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="close_button">
<widget class="GtkButton" id="closebutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@ -40,7 +55,6 @@
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
</widget>
</child>
</widget>
@ -53,190 +67,41 @@
</child>
<child>
<widget class="GtkNotebook" id="notebook1">
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="width_request">400</property>
<property name="height_request">250</property>
<widget class="GtkViewport" id="viewport5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkViewport" id="viewport3">
<widget class="GtkLabel" id="Authors">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkLabel" id="version">
<property name="visible">True</property>
<property name="label" translatable="yes">version</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<property name="can_focus">True</property>
<property name="label" translatable="yes">label8</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="label" translatable="yes">Version</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow4">
<property name="width_request">400</property>
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport4">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkLabel" id="credits">
<property name="visible">True</property>
<property name="label" translatable="yes">credits</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="label" translatable="yes">Credits</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="width_request">400</property>
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport5">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkLabel" id="license">
<property name="visible">True</property>
<property name="label" translatable="yes">license</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">License</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>