summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew rugby471@gmail.com <>2011-03-18 17:13:34 +0000
committerAndrew rugby471@gmail.com <>2011-03-18 17:13:34 +0000
commit31c699b8be09102d194e7468f4305ae6353c8e1f (patch)
tree83b358897425868e81e859f7707289c1c064efe9 /src
parentRemove SearchEntry hinting ability (not appropriate/useful in this scenario) (diff)
downloadinkscape-31c699b8be09102d194e7468f4305ae6353c8e1f.tar.gz
inkscape-31c699b8be09102d194e7468f4305ae6353c8e1f.zip
Get the OCAL logo form a proper path
Degrade gracefully if the logo can't be found (bzr r10092.1.13)
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/ocaldialogs.cpp51
-rw-r--r--src/ui/dialog/ocaldialogs.h1
2 files changed, 32 insertions, 20 deletions
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index 0294c5baa..e4a7a6ac8 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -20,6 +20,7 @@
#include <errno.h> // errno
#include <string.h> // strerror()
+#include "path-prefix.h"
#include "ocaldialogs.h"
#include "filedialogimpl-gtkmm.h"
#include "interface.h"
@@ -313,7 +314,15 @@ void SearchEntry::_on_changed()
LogoDrawingArea::LogoDrawingArea() : Gtk::DrawingArea()
{
- logo_mask = Cairo::ImageSurface::create_from_png("/home/andrew/Software/Launchpad/inkscape/ocal-dialog/share/icons/OCAL.png");
+ // Try to load the OCAL logo, but if the file is not found, degrade gracefully
+ try {
+ std::string logo_path = Glib::build_filename(INKSCAPE_PIXMAPDIR, "OCAL.png");
+ logo_mask = Cairo::ImageSurface::create_from_png(logo_path);
+ draw_logo = true;
+ } catch( Cairo::logic_error ) {
+ logo_mask = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 1,1);
+ draw_logo = false;
+ }
signal_expose_event().connect(sigc::mem_fun(*this, &LogoDrawingArea::_on_expose_event));
signal_style_changed().connect(sigc::mem_fun(*this, &LogoDrawingArea::_on_style_set));
}
@@ -345,25 +354,27 @@ bool LogoDrawingArea::_on_expose_event(GdkEventExpose* event)
Gdk::Rectangle(0, 0, width, height),
*this, Glib::ustring::ustring("viewport"), 0, 0, width, height);
- // Draw logo, we mask [read fill] it with the mid colour from the
- // user's GTK theme
- Gdk::Color logo_fill = get_style()->get_mid(get_state());
- int x_logo = width - 12 - 127;
- int y_logo = height - 12 - 44;
-
- Gdk::Cairo::set_source_color(cr, logo_fill);
- cr->mask(logo_mask, x_logo, y_logo);
-
- // Draw text
- Pango::Rectangle extents = layout->get_pixel_logical_extents();
- int text_width = extents.get_width();
- int text_height = extents.get_height();
-
- int x_text = x_logo - text_width - 12;
- int y_text = height - text_height - 12;
-
- get_style()->paint_layout(get_window(), get_state(), true,
- Gdk::Rectangle(0, 0, width, height), *this, "", x_text, y_text, layout);
+ if (draw_logo) {
+ // Draw logo, we mask [read fill] it with the mid colour from the
+ // user's GTK theme
+ Gdk::Color logo_fill = get_style()->get_mid(get_state());
+ int x_logo = width - 12 - 127;
+ int y_logo = height - 12 - 44;
+
+ Gdk::Cairo::set_source_color(cr, logo_fill);
+ cr->mask(logo_mask, x_logo, y_logo);
+
+ // Draw text
+ Pango::Rectangle extents = layout->get_pixel_logical_extents();
+ int text_width = extents.get_width();
+ int text_height = extents.get_height();
+
+ int x_text = x_logo - text_width - 12;
+ int y_text = height - text_height - 12;
+
+ get_style()->paint_layout(get_window(), get_state(), true,
+ Gdk::Rectangle(0, 0, width, height), *this, "", x_text, y_text, layout);
+ }
return false;
}
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
index 89da69357..5bcee4a3c 100644
--- a/src/ui/dialog/ocaldialogs.h
+++ b/src/ui/dialog/ocaldialogs.h
@@ -282,6 +282,7 @@ public:
private:
bool _on_expose_event(GdkEventExpose* event);
void _on_style_set(const Glib::RefPtr<Gtk::Style>& previous_style);
+ bool draw_logo;
Cairo::RefPtr<Cairo::ImageSurface> logo_mask;
Glib::RefPtr<Pango::Layout> layout;
};