remove debug output
[ardour.git] / gtk2_ardour / utils.cc
index fcfdbe644cffb33871c4a16526231628e99ba0a2..60498b9fac3e3ceee40c663f01bd1a6ebda0709a 100644 (file)
 #include "gtk2ardour-config.h"
 #endif
 
-#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
-#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
-
 #include <cstdlib>
 #include <clocale>
 #include <cstring>
 #include <cctype>
 #include <cmath>
-#include <fstream>
 #include <list>
 #include <sys/stat.h>
 #include <gtkmm/rc.h>
 #include "pbd/file_utils.h"
 
 #include <gtkmm2ext/utils.h>
-#include "ardour/rc_configuration.h"
+
 #include "ardour/filesystem_paths.h"
 
 #include "canvas/item.h"
 #include "canvas/utils.h"
 
-#include "ardour_ui.h"
 #include "debug.h"
 #include "public_editor.h"
 #include "keyboard.h"
@@ -57,6 +52,8 @@
 #include "i18n.h"
 #include "rgb_macros.h"
 #include "gui_thread.h"
+#include "ui_config.h"
+#include "ardour_dialog.h"
 
 using namespace std;
 using namespace Gtk;
@@ -208,15 +205,15 @@ ARDOUR_UI_UTILS::xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h)
        return (savergb);
 }
 
-/** Returns a Pango::FontDescription given a string describing the font. 
+/** Returns a Pango::FontDescription given a string describing the font.
  *
  * If the returned FontDescription does not specify a family, then
  * the family is set to "Sans". This mirrors GTK's behaviour in
- * gtkstyle.c. 
+ * gtkstyle.c.
  *
  * Some environments will force Pango to specify the family
  * even if it was not specified in the string describing the font.
- * Such environments should be left unaffected by this function, 
+ * Such environments should be left unaffected by this function,
  * since the font family will be left alone.
  *
  * There may be other similar font specification enforcement
@@ -300,13 +297,13 @@ ARDOUR_UI_UTILS::gdk_color_to_rgba (Gdk::Color const& c)
 bool
 ARDOUR_UI_UTILS::relay_key_press (GdkEventKey* ev, Gtk::Window* win)
 {
-       PublicEditor& ed (PublicEditor::instance());
 
        if (!key_press_focus_accelerator_handler (*win, ev)) {
-               if (&ed == 0) {
+               if (!PublicEditor::_instance) {
                        /* early key press in pre-main-window-dialogs, no editor yet */
                        return false;
                }
+               PublicEditor& ed (PublicEditor::instance());
                return ed.on_key_press_event(ev);
        } else {
                return true;
@@ -430,7 +427,7 @@ ARDOUR_UI_UTILS::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEv
            appear to be. if it ever is necessar, figure out if it should apply
            to all platforms.
         */
-#if 0 
+#if 0
        if (Keyboard::some_magic_widget_has_focus ()) {
                 allow_activating = false;
        }
@@ -490,7 +487,7 @@ ARDOUR_UI_UTILS::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEv
                 * automatically sent through the accel groups activation
                 * pathway, which prevents individual widgets & canvas items
                 * from ever seeing it if is used by a key binding.
-                * 
+                *
                 * specifically, this hid Ctrl-down-arrow from MIDI region
                 * views because it is also bound to an action.
                 *
@@ -510,7 +507,7 @@ ARDOUR_UI_UTILS::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEv
                                                                          ev->keyval, fakekey));
 
                        DEBUG_TRACE (DEBUG::Accelerators, string_compose ("\tmodified modifier was %1\n", show_gdk_event_state (modifier)));
-                       
+
                        if (allow_activating && gtk_accel_groups_activate(G_OBJECT(win), fakekey, modifier)) {
                                DEBUG_TRACE (DEBUG::Accelerators, "\taccel group activated by fakekey\n");
                                return true;
@@ -593,7 +590,7 @@ ARDOUR_UI_UTILS::get_icon_sets ()
        Searchpath spath(ARDOUR::ardour_data_search_path());
        spath.add_subdirectory_to_paths ("icons");
        vector<string> r;
-       
+
        r.push_back (_("default"));
 
        for (vector<string>::iterator s = spath.begin(); s != spath.end(); ++s) {
@@ -629,22 +626,22 @@ ARDOUR_UI_UTILS::get_icon_path (const char* cname, string icon_set, bool is_imag
                /* add "icons/icon_set" but .. not allowed to add both of these at once */
                spath.add_subdirectory_to_paths ("icons");
                spath.add_subdirectory_to_paths (icon_set);
-               
+
                find_file (spath, name, data_file_path);
        } else {
                spath.add_subdirectory_to_paths ("icons");
                find_file (spath, name, data_file_path);
        }
-       
+
        if (is_image && data_file_path.empty()) {
-               
+
                if (!icon_set.empty() && icon_set != _("default")) {
                        warning << string_compose (_("icon \"%1\" not found for icon set \"%2\", fallback to default"), cname, icon_set) << endmsg;
                }
-               
+
                Searchpath def (ARDOUR::ardour_data_search_path());
                def.add_subdirectory_to_paths ("icons");
-       
+
                if (!find_file (def, name, data_file_path)) {
                        fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
                        abort(); /*NOTREACHED*/
@@ -717,7 +714,7 @@ ARDOUR_UI_UTILS::longest (vector<string>& strings)
 bool
 ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (guint keyval)
 {
-       /* we assume that this does not change over the life of the process 
+       /* we assume that this does not change over the life of the process
         */
 
        static int comma_decimal = -1;
@@ -799,34 +796,6 @@ ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (guint keyval)
        return false;
 }
 
-void
-ARDOUR_UI_UTILS::set_pango_fontsize ()
-{
-       long val = ARDOUR_UI::config()->get_font_scale();
-
-       /* FT2 rendering - used by GnomeCanvas, sigh */
-
-#ifndef PLATFORM_WINDOWS
-       pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_new(), val/1024, val/1024);
-#endif
-
-       /* Cairo rendering, in case there is any */
-
-       pango_cairo_font_map_set_resolution ((PangoCairoFontMap*) pango_cairo_font_map_get_default(), val/1024);
-}
-
-void
-ARDOUR_UI_UTILS::reset_dpi ()
-{
-       long val = ARDOUR_UI::config()->get_font_scale();
-       set_pango_fontsize ();
-       /* Xft rendering */
-
-       gtk_settings_set_long_property (gtk_settings_get_default(),
-                                       "gtk-xft-dpi", val, "ardour");
-       DPIReset();//Emit Signal
-}
-
 void
 ARDOUR_UI_UTILS::resize_window_to_proportion_of_monitor (Gtk::Window* window, int max_width, int max_height)
 {
@@ -910,7 +879,7 @@ ARDOUR_UI_UTILS::unique_random_color (list<Gdk::Color>& used_colors)
        }
 }
 
-string 
+string
 ARDOUR_UI_UTILS::rate_as_string (float r)
 {
        char buf[32];
@@ -958,3 +927,23 @@ ARDOUR_UI_UTILS::windows_overlap (Gtk::Window *a, Gtk::Window *b)
        }
        return false;
 }
+
+bool
+ARDOUR_UI_UTILS::overwrite_file_dialog (Gtk::Window& parent, string title, string text)
+{
+       ArdourDialog dialog (parent, title, true);
+       Label label (text);
+
+       dialog.get_vbox()->pack_start (label, true, true);
+       dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+       dialog.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
+       dialog.show_all ();
+
+       switch (dialog.run()) {
+       case RESPONSE_ACCEPT:
+               return true;
+       case RESPONSE_CANCEL:
+       default:
+               return false;
+       }
+}