70 UI::UI (
string namestr,
int *argc,
char ***argv)
76 theMain =
new Main (argc, argv);
110 Glib::set_application_name(namestr);
118 errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
148 static Glib::RefPtr<Style>* fatal_style = 0;
149 static Glib::RefPtr<Style>* error_style = 0;
150 static Glib::RefPtr<Style>* warning_style = 0;
151 static Glib::RefPtr<Style>* info_style = 0;
153 if (path.length() == 0) {
157 if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
158 error <<
"UI: couldn't find rc file \""
165 RC rc (path.c_str());
168 gtk_rc_reset_styles (gtk_settings_get_default());
178 Window temp_window (WINDOW_TOPLEVEL);
179 temp_window.ensure_style ();
184 Label warning_widget;
186 RefPtr<Gtk::Style> style;
187 RefPtr<TextBuffer> buffer (
errors->
text().get_buffer());
189 box.pack_start (fatal_widget);
190 box.pack_start (error_widget);
191 box.pack_start (warning_widget);
192 box.pack_start (info_widget);
203 fatal_widget.set_name (
"FatalMessage");
218 fatal_style =
new Glib::RefPtr<Style> (Glib::wrap (gtk_rc_get_style (reinterpret_cast<GtkWidget*> (fatal_widget.gobj())),
true));
220 fatal_ptag->property_font_desc().set_value((*fatal_style)->get_font());
221 fatal_ptag->property_foreground_gdk().set_value((*fatal_style)->get_fg(STATE_ACTIVE));
222 fatal_ptag->property_background_gdk().set_value((*fatal_style)->get_bg(STATE_ACTIVE));
223 fatal_mtag->property_font_desc().set_value((*fatal_style)->get_font());
224 fatal_mtag->property_foreground_gdk().set_value((*fatal_style)->get_fg(STATE_NORMAL));
225 fatal_mtag->property_background_gdk().set_value((*fatal_style)->get_bg(STATE_NORMAL));
227 error_widget.set_name (
"ErrorMessage");
229 error_style =
new Glib::RefPtr<Style> (Glib::wrap (gtk_rc_get_style (reinterpret_cast<GtkWidget*> (error_widget.gobj())),
true));
231 error_ptag->property_font_desc().set_value((*error_style)->get_font());
232 error_ptag->property_foreground_gdk().set_value((*error_style)->get_fg(STATE_ACTIVE));
233 error_ptag->property_background_gdk().set_value((*error_style)->get_bg(STATE_ACTIVE));
234 error_mtag->property_font_desc().set_value((*error_style)->get_font());
235 error_mtag->property_foreground_gdk().set_value((*error_style)->get_fg(STATE_NORMAL));
236 error_mtag->property_background_gdk().set_value((*error_style)->get_bg(STATE_NORMAL));
238 warning_widget.set_name (
"WarningMessage");
239 delete warning_style;
240 warning_style =
new Glib::RefPtr<Style> (Glib::wrap (gtk_rc_get_style (reinterpret_cast<GtkWidget*> (warning_widget.gobj())),
true));
242 warning_ptag->property_font_desc().set_value((*warning_style)->get_font());
243 warning_ptag->property_foreground_gdk().set_value((*warning_style)->get_fg(STATE_ACTIVE));
244 warning_ptag->property_background_gdk().set_value((*warning_style)->get_bg(STATE_ACTIVE));
245 warning_mtag->property_font_desc().set_value((*warning_style)->get_font());
246 warning_mtag->property_foreground_gdk().set_value((*warning_style)->get_fg(STATE_NORMAL));
247 warning_mtag->property_background_gdk().set_value((*warning_style)->get_bg(STATE_NORMAL));
249 info_widget.set_name (
"InfoMessage");
251 info_style =
new Glib::RefPtr<Style> (Glib::wrap (gtk_rc_get_style (reinterpret_cast<GtkWidget*> (info_widget.gobj())),
true));
253 info_ptag->property_font_desc().set_value((*info_style)->get_font());
254 info_ptag->property_foreground_gdk().set_value((*info_style)->get_fg(STATE_ACTIVE));
255 info_ptag->property_background_gdk().set_value((*info_style)->get_bg(STATE_ACTIVE));
256 info_mtag->property_font_desc().set_value((*info_style)->get_font());
257 info_mtag->property_foreground_gdk().set_value((*info_style)->get_fg(STATE_NORMAL));
258 info_mtag->property_background_gdk().set_value((*info_style)->get_bg(STATE_NORMAL));
273 Glib::signal_idle().connect (bind_return (mem_fun (old_receiver, &
Receiver::hangup),
false));
313 if (getenv (
"ARDOUR_RUNNING_UNDER_VALGRIND")) {
316 Glib::signal_idle().connect (sigc::ptr_fun (
idle_quit));
347 UI::set_tip (Widget *w,
const gchar *tip,
const gchar *hlp)
351 std::string msg(tip);
353 Glib::RefPtr<Gtk::Action> action = w->get_action();
357 if ((activatable = dynamic_cast<Gtkmm2ext::Activatable*>(w))) {
364 ustring ap = action->get_accel_path();
367 if (!shortcut.empty()) {
370 msg.append(
_(
"\n\nShortcut: ")).append (shortcut);
381 req->
msg = msg.c_str();
442 free (const_cast<char*>(req->
msg));
445 }
else if (req->type ==
Quit) {
451 if (getenv (
"DEBUG_THREADED_SIGNALS")) {
452 cerr <<
"call slot for " <<
name() << endl;
468 }
else if (req->type ==
SetTip) {
470 gtk_widget_set_tooltip_markup (req->
widget->gobj(), req->
msg);
474 error <<
"GtkUI: unknown request type "
497 req->
msg = strdup (str);
503 #define OLD_STYLE_ERRORS 1
509 RefPtr<TextBuffer::Tag> ptag;
510 RefPtr<TextBuffer::Tag> mtag;
513 bool fatal_received =
false;
514 #ifndef OLD_STYLE_ERRORS
515 PopUp* popup =
new PopUp (WIN_POS_CENTER, 0,
true);
520 prefix =
"[FATAL]: ";
524 fatal_received =
true;
528 prefix =
"[ERROR]: ";
555 prefix =
"[WARNING]: ";
568 cerr <<
"programmer error in UI::check_error_messages (channel = " << chn <<
")\n";
572 errors->
text().get_buffer()->begin_user_action();
574 if (fatal_received) {
578 if (!ptag || !mtag) {
580 cerr << prefix << str << endl;
586 errors->
text().get_buffer()->end_user_action();
597 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
611 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
613 if (tact->get_active()) {
614 errors->set_position (WIN_POS_MOUSE);
622 UI::display_message (
const char *prefix, gint , RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag,
const char *msg)
624 RefPtr<TextBuffer> buffer (
errors->
text().get_buffer());
626 buffer->insert_with_tag(buffer->end(), prefix, ptag);
627 buffer->insert_with_tag(buffer->end(), msg, mtag);
628 buffer->insert_with_tag(buffer->end(),
"\n", mtag);
637 Label label (message);
638 Button
quit (
_(
"Press To Exit"));
641 win.set_default_size (400, 100);
644 title +=
": Fatal Error";
647 win.set_position (WIN_POS_MOUSE);
648 win.set_border_width (12);
650 win.get_vbox()->pack_start (label,
true,
true);
651 hpacker.pack_start (quit,
true,
false);
652 win.get_vbox()->pack_start (hpacker,
false,
false);
654 quit.signal_clicked().connect(mem_fun(*
this,&
UI::quit));
657 win.set_modal (
true);
668 error <<
"non-UI threads can't use UI::popup_error"
673 MessageDialog msg (text);
674 msg.set_title (
string_compose (
_(
"I'm sorry %1, I can't do that"), g_get_user_name()));
675 msg.set_wmclass (
X_(
"error"),
name());
676 msg.set_position (WIN_POS_MOUSE);
684 error <<
"non-UI threads cannot call UI::flush_pending()"
689 gtk_main_iteration();
691 while (gtk_events_pending()) {
692 gtk_main_iteration();
704 UI::get_color (
const string& prompt,
bool& picked,
const Gdk::Color* initial)
708 ColorSelectionDialog color_dialog (prompt);
710 color_dialog.set_modal (
true);
711 color_dialog.get_cancel_button()->signal_clicked().connect (bind (mem_fun (*
this, &
UI::color_selection_done),
false));
716 color_dialog.get_colorsel()->set_current_color (*initial);
719 color_dialog.show_all ();
725 color_dialog.hide_all ();
728 Gdk::Color f_rgba = color_dialog.get_colorsel()->get_current_color ();
729 color.set_red(f_rgba.get_red());
730 color.set_green(f_rgba.get_green());
731 color.set_blue(f_rgba.get_blue());
void send_request(UIRequest *)
static RequestType new_request_type()
static RequestType CallSlot
LIBPBD_API Transmitter fatal
Glib::RefPtr< Gtk::Action > get_related_action()
virtual void display_message(const char *prefix, gint prefix_len, Glib::RefPtr< Gtk::TextBuffer::Tag > ptag, Glib::RefPtr< Gtk::TextBuffer::Tag > mtag, const char *msg)
PBD::EventLoop::InvalidationRecord * __invalidator(sigc::trackable &trackable, const char *file, int line)
Glib::RefPtr< Gtk::TextBuffer::Tag > info_ptag
UIRequest * get_request(RequestType)
Glib::RefPtr< Gtk::TextBuffer::Tag > warning_ptag
static void set_event_loop_for_thread(EventLoop *ui)
BaseUI::RequestType AddIdle
static Application * instance()
void touch_display(Touchable *)
Gtk::Button & dismiss_button()
BaseUI::RequestType ErrorMessage
Glib::RefPtr< Gtk::TextBuffer::Tag > info_mtag
LIBGTKMM2EXT_API Glib::RefPtr< Gtk::Action > get_action(const char *group, const char *name)
BaseUI::RequestType TouchDisplay
BaseUI::RequestType SetTip
bool color_selection_deleted(GdkEventAny *)
BaseUI::RequestType AddTimeout
LIBPBD_API Transmitter error
LIBPBD_API Transmitter warning
void process_error_message(Transmitter::Channel, const char *)
std::ostream & endmsg(std::ostream &ostr)
BaseUI::RequestType StateChange
LIBPBD_API int replace_all(std::string &str, const std::string &target, const std::string &replacement)
static void * invalidate_request(void *data)
static bool just_hide_it(GdkEventAny *, Gtk::Window *)
Glib::RefPtr< Gtk::TextBuffer::Tag > fatal_mtag
const std::string & get_string()
bool caller_is_ui_thread()
int load_rcfile(std::string, bool themechange=false)
void idle_add(int(*func)(void *), void *arg)
sigc::signal< void > theme_changed
Gdk::Color get_color(const std::string &prompt, bool &picked, const Gdk::Color *initial=0)
UI(std::string name, int *argc, char **argv[])
LIBGTKMM2EXT_API void uncheck_toggleaction(std::string)
virtual void handle_fatal(const char *)
LIBPBD_API void pthread_set_name(const char *name)
LIBPBD_API Transmitter info
void color_selection_done(bool status)
void set_tip(Gtk::Widget &w, const gchar *tip)
Glib::RefPtr< Gtk::TextBuffer::Tag > fatal_ptag
void set_state(Gtk::Widget *w, Gtk::StateType state)
Glib::RefPtr< Gtk::TextBuffer::Tag > error_ptag
void do_request(UIRequest *)
void attach_request_source()
Glib::RefPtr< Gtk::TextBuffer::Tag > error_mtag
LIBGTKMM2EXT_API std::string get_key_representation(const std::string &accel_path, Gtk::AccelKey &key)
void receive(Transmitter::Channel, const char *)
Glib::Threads::Thread * run_loop_thread
bool delete_after_touch() const
void listen_to(Transmitter &)
BaseUI::RequestType NullMessage
Glib::RefPtr< Gtk::TextBuffer::Tag > warning_mtag
std::string string_compose(const std::string &fmt, const T1 &o1)
void popup_error(const std::string &text)
LIBARDOUR_API PBD::PropertyDescriptor< bool > color