waf build works on OS X ; new bindings file and processing system in place for mnemon...
[ardour.git] / gtk2_ardour / utils.cc
index 85bb46c6c81ffa6db8e13a2e12957781c8d656af..7a1c9c696841861c56bdc6cf995899b335cb41f8 100644 (file)
@@ -113,6 +113,13 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font
        return txt;
 }
 
+/** Try to fit a string into a given horizontal space by ellipsizing it.
+ *  @param cr Cairo context in which the text will be plotted.
+ *  @param name Text.
+ *  @param avail Available horizontal space.
+ *  @return (Text, possibly ellipsized) and (horizontal size of text)
+ */
+
 std::pair<std::string, double>
 fit_to_pixels (cairo_t* cr, std::string name, double avail)
 {
@@ -142,8 +149,23 @@ fit_to_pixels (cairo_t* cr, std::string name, double avail)
 }
 
 
+/** Add an element to a menu, settings its sensitivity.
+ * @param m Menu to add to.
+ * @param e Element to add.
+ * @param s true to make sensitive, false to make insensitive
+ */
+void
+add_item_with_sensitivity (Menu_Helpers::MenuList& m, Menu_Helpers::MenuElem e, bool s)
+{
+       m.push_back (e);
+       if (!s) {
+               m.back().set_sensitive (false);
+       }
+}
+
+
 gint
-just_hide_it (GdkEventAny *ev, Gtk::Window *win)
+just_hide_it (GdkEventAny */*ev*/, Gtk::Window *win)
 {
        win->hide ();
        return 0;
@@ -263,7 +285,7 @@ xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h)
 }
 
 ArdourCanvas::Points*
-get_canvas_points (string who, uint32_t npoints)
+get_canvas_points (string /*who*/, uint32_t npoints)
 {
        // cerr << who << ": wants " << npoints << " canvas points" << endl;
 #ifdef TRAP_EXCESSIVE_POINT_REQUESTS
@@ -683,9 +705,8 @@ get_xpm (std::string name)
        return xpm_map[name];
 }
 
-
-Glib::RefPtr<Gdk::Pixbuf>      
-get_icon (const char* cname)
+Glib::ustring
+get_icon_path (const char* cname)
 {
        string name = cname;
        name += X_(".png");
@@ -701,9 +722,15 @@ get_icon (const char* cname)
                fatal << string_compose (_("cannot find icon image for %1"), name) << endmsg;
        }
 
+       return data_file_path.to_string();
+}
+
+Glib::RefPtr<Gdk::Pixbuf>      
+get_icon (const char* cname)
+{
        Glib::RefPtr<Gdk::Pixbuf> img;
        try {
-               img = Gdk::Pixbuf::create_from_file (data_file_path.to_string());
+               img = Gdk::Pixbuf::create_from_file (get_icon_path (cname));
        } catch (const Gdk::PixbufError &e) {
                cerr << "Caught PixbufError: " << e.what() << endl;
        } catch (...) {