summaryrefslogtreecommitdiff
path: root/src/gui_gtk.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-29 18:31:48 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-29 18:31:48 +0200
commit1d6b4708c0093256ee67cc4c8ba1982719243b6d (patch)
tree1544c5c70d07ab8dfad209b501f84c581fc42e37 /src/gui_gtk.cc
parent8d58ffb022649fd8a28d2f74845fc8ca5c934029 (diff)
Handle FILE argument in monitor-gui
Diffstat (limited to 'src/gui_gtk.cc')
-rw-r--r--src/gui_gtk.cc23
1 files changed, 20 insertions, 3 deletions
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<GtkGuiMenu*>(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));