Show correct title bar in the main system window when the program starts

This commit is contained in:
David Capello 2014-09-03 00:39:15 -03:00
parent 10eddb0d9e
commit 9e8cf5de90
5 changed files with 35 additions and 16 deletions

View File

@ -51,6 +51,7 @@
#include "app/shell.h"
#include "app/tools/tool_box.h"
#include "app/ui/color_bar.h"
#include "app/ui/document_view.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_view.h"
#include "app/ui/main_window.h"
@ -71,7 +72,9 @@
#include "raster/palette.h"
#include "raster/sprite.h"
#include "scripting/engine.h"
#include "she/display.h"
#include "she/error.h"
#include "she/system.h"
#include "ui/intern.h"
#include "ui/ui.h"
@ -177,6 +180,8 @@ App::App(int argc, const char* argv[])
int App::run()
{
UIContext* context = UIContext::instance();
// Initialize GUI interface
if (isGui()) {
PRINTF("GUI mode\n");
@ -184,7 +189,7 @@ int App::run()
// Setup the GUI cursor and redraw screen
ui::set_use_native_cursors(
UIContext::instance()->settings()->experimental()->useNativeCursor());
context->settings()->experimental()->useNativeCursor());
jmouse_set_cursor(kArrowCursor);
@ -197,21 +202,19 @@ int App::run()
app_rebuild_documents_tabs();
app_default_statusbar_message();
// Default window title bar.
updateDisplayTitleBar();
m_mainWindow->openWindow();
// Redraw the whole screen.
ui::Manager::getDefault()->invalidate();
// 2013-11-19 - JRM - Force setting active view to NULL, workaround for setting
// window title to proper devault value. (Issue #285)
UIContext::instance()->setActiveView(NULL);
}
// Procress options
PRINTF("Processing options...\n");
{
UIContext* context = UIContext::instance();
Console console;
for (const std::string& filename : m_files) {
// Load the sprite
@ -365,6 +368,22 @@ void App::showNotification(INotificationDelegate* del)
m_mainWindow->showNotification(del);
}
void App::updateDisplayTitleBar()
{
std::string defaultTitle = PACKAGE " v" VERSION;
std::string title;
DocumentView* docView = UIContext::instance()->activeView();
if (docView) {
// Prepend the document's filename.
title += docView->getDocument()->name();
title += " - ";
}
title += defaultTitle;
she::instance()->defaultDisplay()->setTitleBar(title);
}
// Updates palette and redraw the screen.
void app_refresh_screen()
{

View File

@ -77,6 +77,7 @@ namespace app {
MainWindow* getMainWindow() const { return m_mainWindow; }
void showNotification(INotificationDelegate* del);
void updateDisplayTitleBar();
// App Signals
Signal0<void> Exit;

View File

@ -102,16 +102,7 @@ void UIContext::setActiveView(DocumentView* docView)
app_refresh_screen();
// Change the main frame title.
std::string defaultTitle = PACKAGE " v" VERSION;
std::string title;
if (docView) {
// Prepend the document's filename.
title += docView->getDocument()->name();
title += " - ";
}
title += defaultTitle;
set_window_title(title.c_str());
App::instance()->updateDisplayTitleBar();
m_lastSelectedView = docView;
}

View File

@ -563,6 +563,10 @@ public:
#endif
}
void setTitleBar(const std::string& title) override {
set_window_title(title.c_str());
}
EventQueue* getEventQueue() override {
return m_queue;
}

View File

@ -11,6 +11,8 @@
#include "gfx/point.h"
#include "she/native_cursor.h"
#include <string>
namespace she {
class EventQueue;
@ -50,6 +52,8 @@ namespace she {
virtual void maximize() = 0;
virtual bool isMaximized() const = 0;
virtual void setTitleBar(const std::string& title) = 0;
virtual EventQueue* getEventQueue() = 0;
virtual bool setNativeMouseCursor(NativeCursor cursor) = 0;