Kaydet (Commit) 8d8a8e1a authored tarafından Miklos Vajna's avatar Miklos Vajna

gtktiledviewer: factor out setupDocView() from main()

Change-Id: Iac803f03267859c11f0f9090346b09b90c115b76
üst 2b69ce33
...@@ -717,6 +717,21 @@ static GtkWidget* createWindow(TiledWindow& rWindow) ...@@ -717,6 +717,21 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
return pWindow; return pWindow;
} }
/// Common setup for DocView (regardless if it's just a new view or a document to be loaded).
static void setupDocView(GtkWidget* pDocView)
{
#if GLIB_CHECK_VERSION(2,40,0)
g_assert_nonnull(pDocView);
#endif
g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), NULL);
}
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
if( argc < 3 || if( argc < 3 ||
...@@ -731,19 +746,8 @@ int main( int argc, char* argv[] ) ...@@ -731,19 +746,8 @@ int main( int argc, char* argv[] )
gtk_init( &argc, &argv ); gtk_init( &argc, &argv );
// Docview GtkWidget* pDocView = lok_doc_view_new(argv[1], NULL, NULL);
GtkWidget* pDocView = lok_doc_view_new (argv[1], NULL, NULL); setupDocView(pDocView);
#if GLIB_CHECK_VERSION(2,40,0)
g_assert_nonnull(pDocView);
#endif
g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), NULL);
TiledWindow aWindow; TiledWindow aWindow;
aWindow.m_pDocView = pDocView; aWindow.m_pDocView = pDocView;
createWindow(aWindow); createWindow(aWindow);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment