summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-28 23:30:21 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-28 23:30:21 +0200
commiteecae6af6e99ac341ca9c3aa4b179a2280c07e5b (patch)
treef21f9176a3b0452b8567f12c8e9312da66f65c83
parentf38d9ebb38620d1085951c2827d0d4b4c9d34bc6 (diff)
Add GuiWindow::title() and make sure app window has title from start
-rw-r--r--src/gui_gtk.cc19
-rw-r--r--src/gui_qt.cc13
-rw-r--r--src/gui_window.hh1
3 files changed, 32 insertions, 1 deletions
diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc
index 2a37306..2af33e2 100644
--- a/src/gui_gtk.cc
+++ b/src/gui_gtk.cc
@@ -639,6 +639,9 @@ public:
bool exit() override;
void set_title(std::string const& title) override;
+ std::string const& title() const override {
+ return title_;
+ }
void show(GuiWindow* window) override;
@@ -882,7 +885,7 @@ class GtkGuiAbout : public virtual GuiAbout, public GtkGuiWindow {
public:
GtkGuiAbout(std::string const& title, std::string const& version,
std::vector<std::string> const& authors)
- : about_(GTK_ABOUT_DIALOG(gtk_about_dialog_new())) {
+ : title_(title), about_(GTK_ABOUT_DIALOG(gtk_about_dialog_new())) {
gtk_about_dialog_set_program_name(about_, title.c_str());
gtk_about_dialog_set_version(about_, version.c_str());
std::vector<std::string> tmp;
@@ -915,8 +918,12 @@ public:
}
void set_title(std::string const& title) override {
+ title_ = title;
GtkGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
void add_listener(GuiAbout::Listener* listener) override {
observers_.insert(listener);
@@ -927,6 +934,7 @@ public:
}
private:
+ std::string title_;
GtkAboutDialog* about_;
Observers<GuiAbout::Listener*> observers_;
};
@@ -946,6 +954,10 @@ public:
GtkGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
+
void* impl() const override {
return dialog_;
}
@@ -1508,6 +1520,9 @@ public:
title_ = title;
GtkGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
void set_text(AttributedText const* text) override {
if (!text) {
@@ -1734,6 +1749,7 @@ void main_app_activate(GApplication* g_app) {
gtk_application_set_menubar(GTK_APPLICATION(app), menu->model());
}
auto win = main_app_window_new(app);
+ gtk_window_set_title(GTK_WINDOW(win), app->main_->title().c_str());
gtk_window_present(GTK_WINDOW(win));
app->main_->sync_split();
@@ -1747,6 +1763,7 @@ void main_app_open(GApplication* app, GFile** files, gint n_files,
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]);
}
diff --git a/src/gui_qt.cc b/src/gui_qt.cc
index c032c87..17eda8f 100644
--- a/src/gui_qt.cc
+++ b/src/gui_qt.cc
@@ -471,6 +471,9 @@ public:
title_ = title;
QtGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
void* impl() const override {
return QtGuiWindow::impl();
@@ -791,6 +794,9 @@ public:
void set_title(std::string const& title) override {
title_ = title;
}
+ std::string const& title() const override {
+ return title_;
+ }
void* impl() const override {
return QtGuiWindow::impl();
@@ -860,6 +866,9 @@ public:
title_ = title;
QtGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
QWidget* widget() const override {
return dialog_;
@@ -1408,6 +1417,9 @@ public:
title_ = title;
QtGuiWindow::set_title(title);
}
+ std::string const& title() const override {
+ return title_;
+ }
QWidget* widget() const override {
return widget_.get();
@@ -1504,6 +1516,7 @@ bool QtGuiMain::run(int argc, char** argv) {
QApplication app(argc, argv);
app.setStyleSheet("QStatusBar::item { border: 0px }");
main_.reset(new QMainWindow());
+ main_->setWindowTitle(QString::fromStdString(title_));
center_.reset(new QWidget());
layout_.reset(new SizeHintLayout(center_.get(), QSize(width_, height_)));
splitter_ = new QSplitter(Qt::Vertical, main_.get());
diff --git a/src/gui_window.hh b/src/gui_window.hh
index 1573cb8..6d1cf31 100644
--- a/src/gui_window.hh
+++ b/src/gui_window.hh
@@ -18,6 +18,7 @@ public:
virtual ~GuiWindow() {}
virtual void set_title(std::string const& title) = 0;
+ virtual std::string const& title() const = 0;
// Can be used by implementation if needed
virtual void* impl() const {