From 519947c2abd58c2e9680ec0febd0f22674b13228 Mon Sep 17 00:00:00 2001 From: hwangcc23 Date: Tue, 21 Mar 2017 23:12:48 +0800 Subject: [PATCH] Allow specifing the host from the command line --- src/mainframe.cpp | 6 +++++- src/mainframe.h | 2 +- src/pcmanx_gtk2.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mainframe.cpp b/src/mainframe.cpp index 77a7570b..de9efd19 100644 --- a/src/mainframe.cpp +++ b/src/mainframe.cpp @@ -170,7 +170,7 @@ gboolean CMainFrame::OnSize( GtkWidget* widget, GdkEventConfigure* evt, } -CMainFrame::CMainFrame() +CMainFrame::CMainFrame(string url) { char* desktop = getenv("XDG_CURRENT_DESKTOP"); @@ -293,6 +293,10 @@ CMainFrame::CMainFrame() }else{ gtk_window_unmaximize((GtkWindow*) m_Widget); } + + if( !url.empty() ) { + NewCon( url, url ); + } } diff --git a/src/mainframe.h b/src/mainframe.h index c272b546..80ae8c99 100644 --- a/src/mainframe.h +++ b/src/mainframe.h @@ -55,7 +55,7 @@ class CSite; class CMainFrame : public CWidget { public: - CMainFrame(); + CMainFrame(string url); CTelnetCon* NewCon( string title, string url, CSite* site = NULL ); CNotebook* GetNotebook(){ return m_pNotebook; } diff --git a/src/pcmanx_gtk2.cpp b/src/pcmanx_gtk2.cpp index 67819ff9..3fc50cbf 100644 --- a/src/pcmanx_gtk2.cpp +++ b/src/pcmanx_gtk2.cpp @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; - context = g_option_context_new ("Runtime options"); + context = g_option_context_new ("[url]"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); } @@ -160,7 +160,11 @@ int main(int argc, char *argv[]) CTelnetCon::Init(); CTelnetCon::SetSocketTimeout( AppConfig.SocketTimeout ); - CMainFrame* main_frm = new CMainFrame; + string cmdline_url; + if( argc >= 2) { + cmdline_url = argv[1]; + } + CMainFrame* main_frm = new CMainFrame( cmdline_url ); gtk_window_move(GTK_WINDOW(main_frm->m_Widget), AppConfig.MainWndX, AppConfig.MainWndY); gtk_window_resize(GTK_WINDOW(main_frm->m_Widget), AppConfig.MainWndW, AppConfig.MainWndH); main_frm->Show();