initial changes to get about.cc compiled

git-svn-id: svn://localhost/trunk/ardour2@36 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2005-09-26 02:09:02 +00:00
parent 40a3eab989
commit 1a6c82a171
5 changed files with 44 additions and 337 deletions

View file

@ -25,7 +25,7 @@ gtkardour.Merge ( [libraries['ardour'],
libraries['pbd3'], libraries['pbd3'],
libraries['gtkmm2'], libraries['gtkmm2'],
libraries['sigc2'], libraries['sigc2'],
# libraries['libgnomecanvasmm'], libraries['libgnomecanvasmm'],
libraries['sysmidi'], libraries['sysmidi'],
libraries['sndfile'], libraries['sndfile'],
libraries['lrdf'], libraries['lrdf'],

View file

@ -26,20 +26,12 @@
#include <ctime> #include <ctime>
#include <cstdlib> #include <cstdlib>
#include <gtkmm/label.h>
#include <gtkmm/text.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/notebook.h>
#include <ardour/ardour.h> #include <ardour/ardour.h>
#include <ardour/version.h> #include <ardour/version.h>
#include "utils.h" #include "utils.h"
#include "version.h" #include "version.h"
#include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/doi.h>
#include "about.h" #include "about.h"
#include "rgb_macros.h" #include "rgb_macros.h"
#include "ardour_ui.h" #include "ardour_ui.h"
@ -47,6 +39,7 @@
#include "i18n.h" #include "i18n.h"
using namespace Gtk; using namespace Gtk;
using namespace Gdk;
using namespace std; using namespace std;
using namespace sigc; using namespace sigc;
using namespace ARDOUR; using namespace ARDOUR;
@ -122,15 +115,10 @@ static const gchar * paypal_xpm[] = {
"::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"}; "::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"};
#endif #endif
static gint static const char* authors[] = {
stoppit (GdkEventButton* ev, Gtk::Notebook* notebook) N_("Paul Davis"),
{ N_("Jesse Chappell"),
gtk_signal_emit_stop_by_name (GTK_OBJECT(notebook->gobj()), N_("Taybin Rutkin"),
"button_release_event");
return TRUE;
}
static const char* author_names[] = {
N_("Marcus Andersson"), N_("Marcus Andersson"),
N_("Jeremy Hall"), N_("Jeremy Hall"),
N_("Steve Harris"), N_("Steve Harris"),
@ -165,27 +153,35 @@ static const char* translators[] = {
}; };
About::About (ARDOUR_UI * ui) About::About ()
: Window (GTK_WINDOW_TOPLEVEL), _ui (ui)
#ifdef WITH_PAYMENT_OPTIONS #ifdef WITH_PAYMENT_OPTIONS
, paypal_pixmap (paypal_xpm) : paypal_pixmap (paypal_xpm)
#endif #endif
{ {
using namespace Notebook_Helpers; string path;
string t;
about_index = 0; path = find_data_file ("splash.ppm");
about_cnt = 0;
drawn = false;
Gtk::Label* small_label = manage (new Label (_( Glib::RefPtr<Pixbuf> pixbuf = Gdk::Pixbuf::create_from_file (path);
"Copyright (C) 1999-2005 Paul Davis\n"
"Ardour comes with ABSOLUTELY NO WARRANTY\n" set_logo (Gdk::Pixbuf::create_from_file (path));
set_authors (authors);
for (int n = 0; translators[n]; ++n) {
t += translators[n];
t += ' ';
}
set_translator_credits (t);
set_copyright (_("Copyright (C) 1999-2005 Paul Davis\n"));
set_license (_("Ardour comes with ABSOLUTELY NO WARRANTY\n"
"This is free software, and you are welcome to redistribute it\n" "This is free software, and you are welcome to redistribute it\n"
"under certain conditions; see the file COPYING for details.\n"))); "under certain conditions; see the file COPYING for details.\n"));
set_name (X_("ardour"));
Gtk::Label* version_label = set_website (X_("http://ardour.org/"));
manage (new Label set_website_label (X_("ardour.org"));
(compose(_("Ardour: %1\n(built with ardour/gtk %2.%3.%4 libardour: %5.%6.%7)"), set_version ((compose(_("%1\n(built with ardour/gtk %2.%3.%4 libardour: %5.%6.%7)"),
VERSIONSTRING, VERSIONSTRING,
gtk_ardour_major_version, gtk_ardour_major_version,
gtk_ardour_minor_version, gtk_ardour_minor_version,
@ -194,92 +190,6 @@ About::About (ARDOUR_UI * ui)
libardour_minor_version, libardour_minor_version,
libardour_micro_version))); libardour_micro_version)));
Notebook* notebook = manage (new Notebook);
ScrolledWindow* author_scroller = manage (new ScrolledWindow);
Text* author_text = manage (new Text);
author_text->set_editable (false);
author_text->set_name (X_("AboutText"));
string str = _(
"Primary author:\n\t\
Paul Davis\n\n\
Major developers:\n\t\
Jesse Chappell\n\t\
Taybin Rutkin\n\
Contributors:\n\t");
for (int32_t n = 0; author_names[n] != 0; ++n) {
str += _(author_names[n]);
str += "\n\t";
}
author_text->insert (str);
author_scroller->add (*author_text);
author_scroller->set_size_request (-1, 75);
author_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
ScrolledWindow* translator_scroller = manage (new ScrolledWindow);
Text* translator_text = manage (new Text);
translator_text->set_editable (false);
translator_text->set_name (X_("AboutText"));
str = "";
for (int32_t n = 0; translators[n] != 0; ++n) {
str += _(translators[n]);
str += '\n';
}
translator_text->insert (str);
translator_scroller->add (*translator_text);
translator_scroller->set_size_request (-1, 75);
translator_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
Label* author_tab_label = manage (new Label (_("Authors")));
Label* translator_tab_label = manage (new Label (_("Translators")));
notebook->pages().push_back (TabElem (*author_scroller, *author_tab_label));
notebook->pages().push_back (TabElem (*translator_scroller, *translator_tab_label));
notebook->set_name ("AboutNoteBook");
notebook->button_release_event.connect_after (bind (ptr_fun (stoppit), notebook));
logo_pixmap = 0;
logo_height = 0;
logo_width = 0;
set_name ("AboutWindow");
set_title ("ardour: about");
set_wmclass ("ardour_about", "Ardour");
vbox.set_border_width (5);
vbox.set_spacing (5);
if (load_logo_size ()) {
logo_area.set_size_request (logo_width, logo_height);
load_logo (*this);
vbox.pack_start (logo_area, false, false);
logo_area.expose_event.connect (mem_fun(*this, &About::logo_area_expose));
} else {
expose_event.connect (mem_fun(*this, &About::logo_area_expose));
}
small_label->set_name ("AboutWindowSmallLabel");
version_label->set_name("AboutWindowSmallLabel");
first_label.set_name ("AboutWindowLabel");
third_label.set_name ("AboutWindowPDLabel");
second_label.set_name ("AboutWindowLabel");
subvbox.pack_start (*small_label, false, false);
subvbox.pack_start (*version_label, false, false);
subvbox.pack_start (*notebook, true, true);
#ifdef WITH_PAYMENT_OPTIONS #ifdef WITH_PAYMENT_OPTIONS
paypal_button.add (paypal_pixmap); paypal_button.add (paypal_pixmap);
@ -290,178 +200,12 @@ Contributors:\n\t");
subvbox.pack_start (*payment_box, false, false); subvbox.pack_start (*payment_box, false, false);
#endif #endif
delete_event.connect (bind (ptr_fun (just_hide_it), static_cast<Gtk::Window*> (this)));
add (vbox);
add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
set_position (GTK_WIN_POS_CENTER);
show_all ();
subvbox.hide ();
/* wait for the first logo expose event to complete so that
we know we are fully drawn.
*/
while (!drawn) {
gtk_main_iteration ();
}
} }
About::~About () About::~About ()
{ {
} }
void
About::show_sub (bool yn)
{
if (yn) {
vbox.pack_start (subvbox, true, true);
subvbox.show_all ();
} else {
vbox.remove (subvbox);
subvbox.hide ();
}
}
gint
About::button_release_event_impl (GdkEventButton* ev)
{
hide();
if (!_ui->shown ()) {
/* show it immediately */
_ui->show();
}
return TRUE;
}
void
About::realize_impl ()
{
Window::realize_impl ();
get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
// get_window().set_decorations (GdkWMDecoration (0));
}
bool
About::load_logo_size ()
{
gchar buf[1024];
FILE *fp;
string path = find_data_file ("splash.ppm");
if (path.length() == 0) {
return false;
}
if ((fp = fopen (path.c_str(), "rb")) == 0) {
error << compose (_("cannot open splash image file \"%1\""), path) << endmsg;
return false;
}
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "P6\n") != 0) {
fclose (fp);
return false;
}
fgets (buf, sizeof (buf), fp);
fgets (buf, sizeof (buf), fp);
sscanf (buf, "%d %d", &logo_width, &logo_height);
fclose (fp);
return true;
}
bool
About::load_logo (Gtk::Window& window)
{
GdkGC* gc;
gchar buf[1024];
guchar *pixelrow;
FILE *fp;
gint count;
gint i;
string path;
path = find_data_file ("splash.ppm");
if (path.length() == 0) {
return false;
}
if ((fp = fopen (path.c_str(), "rb")) == 0) {
return false;
}
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "P6\n") != 0) {
fclose (fp);
return false;
}
fgets (buf, sizeof (buf), fp);
fgets (buf, sizeof (buf), fp);
sscanf (buf, "%d %d", &logo_width, &logo_height);
fgets (buf, sizeof (buf), fp);
if (strcmp (buf, "255\n") != 0) {
fclose (fp);
return false;
}
Gtk::Preview preview (GTK_PREVIEW_COLOR);
preview.size (logo_width, logo_height);
pixelrow = new guchar[logo_width * 3];
for (i = 0; i < logo_height; i++) {
count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp);
if (count != (logo_width * 3))
{
delete [] pixelrow;
fclose (fp);
return false;
}
preview.draw_row (pixelrow, 0, i, logo_width);
}
window.realize ();
logo_pixmap = gdk_pixmap_new (GTK_WIDGET(window.gobj())->window, logo_width, logo_height,
gtk_preview_get_visual()->depth);
gc = gdk_gc_new (logo_pixmap);
gtk_preview_put (preview.gobj(), logo_pixmap, gc, 0, 0, 0, 0, logo_width, logo_height);
gdk_gc_destroy (gc);
delete [] pixelrow;
fclose (fp);
return true;
}
gint
About::logo_area_expose (GdkEventExpose* ev)
{
if (!drawn) {
drawn = true;
}
if (logo_pixmap) {
logo_area.get_window().draw_pixmap (logo_area.get_style()->get_black_gc(),
Gdk::Pixmap (logo_pixmap),
0, 0,
((logo_area.width() - logo_width) / 2),
((logo_area.height() - logo_height) / 2),
logo_width, logo_height);
gdk_flush ();
}
return FALSE;
}
#ifdef WITH_PAYMENT_OPTIONS #ifdef WITH_PAYMENT_OPTIONS
void void
About::goto_paypal () About::goto_paypal ()

View file

@ -21,55 +21,16 @@
#ifndef __ardour_gtk_about_h__ #ifndef __ardour_gtk_about_h__
#define __ardour_gtk_about_h__ #define __ardour_gtk_about_h__
#include <gtkmm/window.h> #include <gtkmm/aboutdialog.h>
#include <gtkmm/pixmap.h>
#include <libgnomecanvas/libgnomecanvas.h>
class ARDOUR_UI; class ARDOUR_UI;
class About : public Gtk::Window class About : public Gtk::AboutDialog
{ {
public: public:
About (ARDOUR_UI *); About ();
~About (); ~About ();
void show_sub (bool yn);
protected:
void realize_impl ();
private:
Gtk::DrawingArea logo_area;
GdkPixmap* logo_pixmap;
Gtk::Label first_label;
Gtk::Label second_label;
Gtk::Label third_label;
Gtk::VBox vbox;
Gtk::VBox subvbox;
vector<string> authors;
vector<string> supporters;
uint32_t about_index;
uint32_t about_cnt;
int logo_height;
int logo_width;
bool drawn;
bool support;
ARDOUR_UI * _ui;
sigc::connection timeout_connection;
bool load_logo_size ();
bool load_logo (Gtk::Window&);
gint logo_area_expose (GdkEventExpose*);
gint button_release_event_impl (GdkEventButton*);
gint start_animating ();
void stop_animating ();
void gone_hidden ();
#ifdef WITH_PAYMENT_OPTIONS #ifdef WITH_PAYMENT_OPTIONS
Gtk::Image paypal_pixmap; Gtk::Image paypal_pixmap;
Gtk::Button paypal_button; Gtk::Button paypal_button;

View file

@ -35,6 +35,8 @@
#include <cmath> #include <cmath>
#include <libgnomecanvasmm/canvas.h>
#include <pbd/xml++.h> #include <pbd/xml++.h>
#include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/pix.h> #include <gtkmm2ext/pix.h>
@ -446,13 +448,13 @@ class ARDOUR_UI : public Gtkmm2ext::UI
static void rate_printer (char buf[32], Gtk::Adjustment &, void *); static void rate_printer (char buf[32], Gtk::Adjustment &, void *);
Gtk::Menu* session_popup_menu; Gtk::Menu* session_popup_menu;
Gtk::CTree session_selector; Gtkmm2ext::Selector session_selector;
ArdourDialog* session_selector_window; ArdourDialog* session_selector_window;
Gtk::FileSelection* open_session_selector; Gtk::FileSelection* open_session_selector;
void build_session_selector(); void build_session_selector();
void session_selection (Gtk::CTree::Row, gint col); void session_selection (Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection>);
struct RecentSessionsSorter { struct RecentSessionsSorter {
bool operator() (std::pair<string,string> a, std::pair<string,string> b) const { bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
return cmp_nocase(a.first, b.first) == -1; return cmp_nocase(a.first, b.first) == -1;
@ -538,7 +540,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
string template_name; string template_name;
void new_session_ok_clicked (); void new_session_ok_clicked ();
void new_session_template_choice (Gtkmm2ext::Selector *, Gtkmm2ext::SelectionResult*); void new_session_template_choice (Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection>);
void hide_dialog (ArdourDialog *dialog); void hide_dialog (ArdourDialog *dialog);
void fs_cancel_clicked (Gtk::FileSelection*); void fs_cancel_clicked (Gtk::FileSelection*);

View file

@ -25,7 +25,7 @@
#include <vector> #include <vector>
#include <cmath> #include <cmath>
#include <ardour/types.h> #include <ardour/types.h>
#include <libgnomecanvas/libgnomecanvas.h> #include <libgnomecanvasmm/line.h>
#include <gdkmm/types.h> #include <gdkmm/types.h>
namespace Gtk { namespace Gtk {
@ -51,7 +51,7 @@ slider_position_to_gain (double pos)
} }
std::string short_version (std::string, std::string::size_type target_length); std::string short_version (std::string, std::string::size_type target_length);
std::string fit_to_pixels (std::string, int32_t pixel_width, Gdk_Font&); std::string fit_to_pixels (std::string, int32_t pixel_width, Gdk::Font&);
int atoi (const std::string&); int atoi (const std::string&);
double atof (const std::string&); double atof (const std::string&);