From 1d6b4708c0093256ee67cc4c8ba1982719243b6d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sat, 29 Jul 2017 18:31:48 +0200 Subject: Handle FILE argument in monitor-gui --- src/gui_gtk.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/gui_gtk.cc') diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc index c134e5f..20b23ec 100644 --- a/src/gui_gtk.cc +++ b/src/gui_gtk.cc @@ -682,6 +682,13 @@ public: } } + void notify_open(std::string const& file) { + auto it = observers_.notify(); + while (it.has_next()) { + it.next()->open(this, file); + } + } + void add_to_clipboard(std::string const& data, std::string const& mimetype) override { auto clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); @@ -1814,17 +1821,27 @@ void main_app_activate(GApplication* g_app) { app->main_->sync_split(); } -void main_app_window_open(MainAppWindow*, GFile*) { +bool main_app_window_open(MainApp* app, MainAppWindow*, GFile* file) { + auto path = g_file_get_path(file); + if (!path) return false; + app->main_->notify_open(path); + g_free(path); + return true; } void main_app_open(GApplication* app, GFile** files, gint n_files, gchar const*) { + auto menu = static_cast(MAIN_APP(app)->main_->menu()); + if (menu) { + menu->set_map(G_ACTION_MAP(app)); + gtk_application_set_menubar(GTK_APPLICATION(app), menu->model()); + } auto windows = gtk_application_get_windows(GTK_APPLICATION(app)); auto win = windows ? MAIN_APP_WINDOW(windows->data) : main_app_window_new(MAIN_APP(app)); gtk_window_set_title(GTK_WINDOW(win), MAIN_APP(app)->main_->title().c_str()); - for (auto i = 0; i < n_files; i++) { - main_app_window_open(win, files[i]); + for (gint i = 0; i < n_files; ++i) { + if (main_app_window_open(MAIN_APP(app), win, files[i])) break; } gtk_window_present(GTK_WINDOW(win)); -- cgit v1.2.3-70-g09d2