fix audio clock field widths, change minsec display to include fractional seconds...
[ardour.git] / gtk2_ardour / utils.cc
index 91cb7ad58b21bf30c595cfbe9d3710b05428d326..76b237713adba8725cd99160f617e6faab8811ea 100644 (file)
@@ -71,8 +71,7 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font
                        break;
                }
                
-               ustr.erase (last);
-               --last;
+               ustr.erase (last--);
        }
 
        return ustr;
@@ -215,7 +214,7 @@ get_font_for_style (string widgetname)
 {
        Gtk::Window window (WINDOW_TOPLEVEL);
        Gtk::Label foobar;
-       Glib::RefPtr<Style> style;
+       Glib::RefPtr<Gtk::Style> style;
 
        window.add (foobar);
        foobar.set_name (widgetname);
@@ -435,12 +434,10 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
                
        if (!special_handling_of_unmodified_accelerators ||
            ev->state & (Gdk::MOD1_MASK|
-                        Gdk::MOD2_MASK|
                         Gdk::MOD3_MASK|
                         Gdk::MOD4_MASK|
                         Gdk::MOD5_MASK|
-                        Gdk::CONTROL_MASK|
-                        Gdk::LOCK_MASK)) {
+                        Gdk::CONTROL_MASK)) {
 
                /* no special handling or modifiers in effect: accelerate first */
 
@@ -471,3 +468,46 @@ get_xpm (std::string name)
        return (xpm_map[name]);
 }
 
+Glib::RefPtr<Gdk::Pixbuf>      
+get_icon (const char* cname)
+{
+       string name = cname;
+       name += X_(".png");
+
+       string path = ARDOUR::find_data_file (name, "icons");
+
+       if (path.empty()) {
+               fatal << string_compose (_("cannot find icon image for %1"), name) << endmsg;
+               /*NOTREACHED*/
+       }
+
+       return Gdk::Pixbuf::create_from_file (path);
+}
+
+string
+longest (vector<string>& strings)
+{
+       if (strings.empty()) {
+               return string ("");
+       }
+
+       vector<string>::iterator longest = strings.begin();
+       string::size_type longest_length = (*longest).length();
+       
+       vector<string>::iterator i = longest;
+       ++i;
+
+       while (i != strings.end()) {
+               
+               string::size_type len = (*i).length();
+               
+               if (len > longest_length) {
+                       longest = i;
+                       longest_length = len;
+               } 
+               
+               ++i;
+       }
+       
+       return *longest;
+}