2014-05-07 20:14:59 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2014-07-29 13:17:45 +02:00
|
|
|
#include <assert.h>
|
2014-05-07 20:14:59 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2015-04-14 11:00:11 +02:00
|
|
|
#include <string>
|
2015-04-14 11:19:27 +02:00
|
|
|
#include <map>
|
2014-05-07 20:14:59 +01:00
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
#include <boost/property_tree/json_parser.hpp>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
2014-05-07 20:14:59 +01:00
|
|
|
|
2014-06-25 09:19:02 +01:00
|
|
|
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
|
2015-02-20 16:21:06 +01:00
|
|
|
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
2014-05-09 14:39:55 +01:00
|
|
|
|
2015-01-26 11:40:33 +01:00
|
|
|
#ifndef g_info
|
|
|
|
#define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2014-05-07 20:14:59 +01:00
|
|
|
static int help()
|
|
|
|
{
|
2015-05-08 10:50:14 +03:00
|
|
|
fprintf( stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document>\n" );
|
2014-05-07 20:14:59 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
static GtkWidget* pDocView;
|
2015-07-07 21:16:45 +05:30
|
|
|
static GtkWidget* pStatusBar;
|
2015-03-10 12:50:59 +01:00
|
|
|
static GtkToolItem* pEnableEditing;
|
2015-03-12 14:59:59 +01:00
|
|
|
static GtkToolItem* pBold;
|
2015-04-14 11:04:42 +02:00
|
|
|
static GtkToolItem* pItalic;
|
2015-04-14 11:33:12 +02:00
|
|
|
static GtkToolItem* pUnderline;
|
|
|
|
static GtkToolItem* pStrikethrough;
|
2015-06-09 16:27:37 +05:30
|
|
|
static GtkWidget* pScrolledWindow;
|
2015-04-14 11:19:27 +02:00
|
|
|
std::map<GtkToolItem*, std::string> g_aToolItemCommandNames;
|
|
|
|
std::map<std::string, GtkToolItem*> g_aCommandNameToolItems;
|
2015-04-14 11:00:11 +02:00
|
|
|
bool g_bToolItemBroadcast = true;
|
2014-07-08 09:53:42 +02:00
|
|
|
static GtkWidget* pVBox;
|
2014-07-30 07:33:54 +02:00
|
|
|
static GtkComboBoxText* pPartSelector;
|
2015-07-06 22:01:30 +05:30
|
|
|
static GtkWidget* pPartModeComboBox;
|
2015-05-27 11:30:04 +02:00
|
|
|
/// Should the part selector avoid calling lok::Document::setPart()?
|
|
|
|
static bool g_bPartSelectorBroadcast = true;
|
2015-04-22 17:56:18 +02:00
|
|
|
GtkWidget* pFindbar;
|
|
|
|
GtkWidget* pFindbarEntry;
|
2015-05-21 13:17:18 +01:00
|
|
|
GtkWidget* pFindbarLabel;
|
2014-07-31 11:26:59 +02:00
|
|
|
|
2015-04-14 11:19:27 +02:00
|
|
|
static void lcl_registerToolItem(GtkToolItem* pItem, const std::string& rName)
|
|
|
|
{
|
|
|
|
g_aToolItemCommandNames[pItem] = rName;
|
|
|
|
g_aCommandNameToolItems[rName] = pItem;
|
|
|
|
}
|
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 };
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
|
2014-06-23 15:13:40 +01:00
|
|
|
{
|
2015-06-10 20:59:18 +05:30
|
|
|
const char *sName = gtk_tool_button_get_icon_name( GTK_TOOL_BUTTON(pButton) );
|
2014-06-23 15:13:40 +01:00
|
|
|
|
|
|
|
float fZoom = 0;
|
2014-07-18 13:51:30 +02:00
|
|
|
float fCurrentZoom = 0;
|
2014-07-08 09:53:42 +02:00
|
|
|
|
|
|
|
if ( pDocView )
|
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
fCurrentZoom = lok_doc_view_get_zoom( LOK_DOC_VIEW(pDocView) );
|
2014-07-08 09:53:42 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
if ( strcmp(sName, "zoom-in-symbolic") == 0)
|
2014-06-23 15:13:40 +01:00
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
|
|
|
|
{
|
|
|
|
if ( fCurrentZoom < fZooms[i] )
|
|
|
|
{
|
|
|
|
fZoom = fZooms[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 20:59:18 +05:30
|
|
|
else if ( strcmp(sName, "zoom-original-symbolic") == 0)
|
2014-06-23 15:13:40 +01:00
|
|
|
{
|
|
|
|
fZoom = 1;
|
|
|
|
}
|
2015-06-10 20:59:18 +05:30
|
|
|
else if ( strcmp(sName, "zoom-out-symbolic") == 0)
|
2014-06-23 15:13:40 +01:00
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
|
|
|
|
{
|
|
|
|
if ( fCurrentZoom > fZooms[i] )
|
|
|
|
{
|
|
|
|
fZoom = fZooms[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( fZoom != 0 )
|
|
|
|
{
|
2014-07-08 09:53:42 +02:00
|
|
|
if ( pDocView )
|
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
lok_doc_view_set_zoom( LOK_DOC_VIEW(pDocView), fZoom );
|
2014-07-08 09:53:42 +02:00
|
|
|
}
|
2014-06-23 15:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-10 12:50:59 +01:00
|
|
|
/// User clicked on the button -> inform LOKDocView.
|
2015-05-08 23:07:52 +05:30
|
|
|
static void toggleEditing(GtkWidget* /*pButton*/, gpointer /*pItem*/)
|
2015-03-10 11:18:25 +01:00
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
|
2015-03-10 12:50:59 +01:00
|
|
|
bool bActive = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing));
|
2015-06-06 02:32:54 +05:30
|
|
|
if (bool(lok_doc_view_get_edit(pLOKDocView)) != bActive)
|
|
|
|
lok_doc_view_set_edit(pLOKDocView, bActive);
|
2015-03-10 12:50:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
/// Toggle the visibility of the findbar.
|
2015-05-08 23:07:52 +05:30
|
|
|
static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
if (gtk_widget_get_visible(pFindbar))
|
|
|
|
{
|
|
|
|
gtk_widget_hide(pFindbar);
|
|
|
|
}
|
|
|
|
else
|
2015-04-23 15:06:30 +02:00
|
|
|
{
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_widget_show_all(pFindbar);
|
2015-04-23 15:06:30 +02:00
|
|
|
gtk_widget_grab_focus(pFindbarEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 09:06:31 +02:00
|
|
|
/// Our GtkClipboardGetFunc implementation for HTML.
|
|
|
|
static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData)
|
|
|
|
{
|
|
|
|
GdkAtom aAtom(gdk_atom_intern("text/html", false));
|
|
|
|
const gchar* pSelection = static_cast<const gchar*>(pUserData);
|
|
|
|
gtk_selection_data_set(pSelectionData, aAtom, 8, reinterpret_cast<const guchar *>(pSelection), strlen(pSelection));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Our GtkClipboardClearFunc implementation for HTML.
|
|
|
|
static void htmlClearFunc(GtkClipboard* /*pClipboard*/, gpointer pData)
|
|
|
|
{
|
|
|
|
g_free(pData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Same as gtk_clipboard_set_text(), but sets HTML.
|
|
|
|
static void clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelection)
|
|
|
|
{
|
|
|
|
GtkTargetList* pList = gtk_target_list_new(0, 0);
|
|
|
|
GdkAtom aAtom(gdk_atom_intern("text/html", false));
|
|
|
|
gtk_target_list_add(pList, aAtom, 0, 0);
|
|
|
|
gint nTargets = 0;
|
|
|
|
GtkTargetEntry* pTargets = gtk_target_table_new_from_list(pList, &nTargets);
|
|
|
|
|
|
|
|
gtk_clipboard_set_with_data(pClipboard, pTargets, nTargets, htmlGetFunc, htmlClearFunc, g_strdup(pSelection));
|
|
|
|
|
|
|
|
gtk_target_table_free(pTargets, nTargets);
|
|
|
|
gtk_target_list_unref(pList);
|
|
|
|
}
|
|
|
|
|
2015-06-18 09:18:18 +02:00
|
|
|
/// Handler for the copy button: write clipboard.
|
|
|
|
static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/)
|
|
|
|
{
|
|
|
|
LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
|
|
|
|
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
|
2015-06-19 18:13:27 +02:00
|
|
|
char* pUsedFormat = 0;
|
2015-06-22 09:06:31 +02:00
|
|
|
char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/html", &pUsedFormat);
|
2015-06-18 09:18:18 +02:00
|
|
|
|
|
|
|
GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(pDocView), GDK_SELECTION_CLIPBOARD);
|
2015-06-22 09:06:31 +02:00
|
|
|
std::string aUsedFormat(pUsedFormat);
|
|
|
|
if (aUsedFormat == "text/plain;charset=utf-8")
|
|
|
|
gtk_clipboard_set_text(pClipboard, pSelection, -1);
|
|
|
|
else
|
|
|
|
clipboardSetHtml(pClipboard, pSelection);
|
2015-06-18 09:18:18 +02:00
|
|
|
|
|
|
|
free(pSelection);
|
2015-06-19 18:13:27 +02:00
|
|
|
free(pUsedFormat);
|
2015-06-18 09:18:18 +02:00
|
|
|
}
|
|
|
|
|
2015-06-09 16:27:37 +05:30
|
|
|
/// Get the visible area of the scrolled window
|
|
|
|
static void getVisibleAreaTwips(GdkRectangle* pArea)
|
|
|
|
{
|
2015-06-12 15:45:16 +02:00
|
|
|
#if GTK_CHECK_VERSION(2,14,0) // we need gtk_adjustment_get_page_size()
|
2015-06-09 16:27:37 +05:30
|
|
|
GtkAdjustment* pHAdjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow));
|
|
|
|
GtkAdjustment* pVAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow));
|
|
|
|
|
|
|
|
pArea->x = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView),
|
|
|
|
gtk_adjustment_get_value(pHAdjustment));
|
|
|
|
pArea->y = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView),
|
|
|
|
gtk_adjustment_get_value(pVAdjustment));
|
|
|
|
pArea->width = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView),
|
|
|
|
gtk_adjustment_get_page_size(pHAdjustment));
|
|
|
|
pArea->height = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView),
|
|
|
|
gtk_adjustment_get_page_size(pVAdjustment));
|
2015-06-12 15:45:16 +02:00
|
|
|
#endif
|
2015-06-09 16:27:37 +05:30
|
|
|
}
|
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
/// Searches for the next or previous text of pFindbarEntry.
|
2015-05-08 23:07:52 +05:30
|
|
|
static void doSearch(bool bBackwards)
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
GtkEntry* pEntry = GTK_ENTRY(pFindbarEntry);
|
|
|
|
const char* pText = gtk_entry_get_text(pEntry);
|
|
|
|
boost::property_tree::ptree aTree;
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/type", '/'), "string");
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/value", '/'), pText);
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/type", '/'), "boolean");
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/value", '/'), bBackwards);
|
2015-05-28 17:21:50 +02:00
|
|
|
|
2015-06-06 02:32:54 +05:30
|
|
|
LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
|
2015-05-28 17:21:50 +02:00
|
|
|
GdkRectangle aArea;
|
2015-06-09 16:27:37 +05:30
|
|
|
getVisibleAreaTwips(&aArea);
|
2015-05-28 17:21:50 +02:00
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointX/type", '/'), "long");
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointX/value", '/'), aArea.x);
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointY/type", '/'), "long");
|
|
|
|
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointY/value", '/'), aArea.y);
|
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
std::stringstream aStream;
|
|
|
|
boost::property_tree::write_json(aStream, aTree);
|
|
|
|
|
2015-06-06 02:32:54 +05:30
|
|
|
lok_doc_view_post_command(pLOKDocView, ".uno:ExecuteSearch", aStream.str().c_str());
|
2015-04-22 17:56:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Click handler for the search next button.
|
2015-05-08 23:07:52 +05:30
|
|
|
static void signalSearchNext(GtkWidget* /*pButton*/, gpointer /*pItem*/)
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
doSearch(/*bBackwards=*/false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Click handler for the search previous button.
|
2015-05-08 23:07:52 +05:30
|
|
|
static void signalSearchPrev(GtkWidget* /*pButton*/, gpointer /*pItem*/)
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
doSearch(/*bBackwards=*/true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Handles the key-press-event of the search entry widget.
|
2015-05-08 23:07:52 +05:30
|
|
|
static gboolean signalFindbar(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/)
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
2015-05-21 13:17:18 +01:00
|
|
|
gtk_label_set_text(GTK_LABEL(pFindbarLabel), "");
|
2015-04-22 17:56:18 +02:00
|
|
|
switch(pEvent->keyval)
|
|
|
|
{
|
2015-06-10 16:18:06 +05:30
|
|
|
case GDK_KEY_Return:
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
// Search forward.
|
|
|
|
doSearch(/*bBackwards=*/false);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-06-10 16:18:06 +05:30
|
|
|
case GDK_KEY_Escape:
|
2015-04-22 17:56:18 +02:00
|
|
|
{
|
|
|
|
// Hide the findbar.
|
|
|
|
gtk_widget_hide(pFindbar);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-03-10 12:50:59 +01:00
|
|
|
/// LOKDocView changed edit state -> inform the tool button.
|
|
|
|
static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pData*/)
|
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
gboolean bEdit = lok_doc_view_get_edit(pLOKDocView);
|
|
|
|
g_info("signalEdit: %d -> %d", bWasEdit, lok_doc_view_get_edit(pLOKDocView));
|
2015-03-10 12:50:59 +01:00
|
|
|
if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing)) != bEdit)
|
|
|
|
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing), bEdit);
|
2015-03-10 11:18:25 +01:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:00:11 +02:00
|
|
|
/// LOKDocView changed command state -> inform the tool button.
|
|
|
|
static void signalCommand(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer /*pData*/)
|
|
|
|
{
|
|
|
|
std::string aPayload(pPayload);
|
|
|
|
size_t nPosition = aPayload.find("=");
|
|
|
|
if (nPosition != std::string::npos)
|
|
|
|
{
|
|
|
|
std::string aKey = aPayload.substr(0, nPosition);
|
|
|
|
std::string aValue = aPayload.substr(nPosition + 1);
|
|
|
|
g_info("signalCommand: '%s' is '%s'", aKey.c_str(), aValue.c_str());
|
|
|
|
|
2015-04-14 11:19:27 +02:00
|
|
|
if (g_aCommandNameToolItems.find(aKey) != g_aCommandNameToolItems.end())
|
2015-04-14 11:00:11 +02:00
|
|
|
{
|
2015-04-14 11:19:27 +02:00
|
|
|
GtkToolItem* pItem = g_aCommandNameToolItems[aKey];
|
2015-04-14 14:03:37 +03:00
|
|
|
gboolean bEdit = aValue == "true";
|
2015-04-14 11:00:11 +02:00
|
|
|
if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pItem)) != bEdit)
|
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
// Avoid invoking lok_doc_view_post_command().
|
2015-04-14 11:00:11 +02:00
|
|
|
g_bToolItemBroadcast = false;
|
|
|
|
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pItem), bEdit);
|
|
|
|
g_bToolItemBroadcast = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 21:16:45 +05:30
|
|
|
static void loadChanged(LOKDocView* /*pLOKDocView*/, gdouble fValue, gpointer pData)
|
|
|
|
{
|
|
|
|
GtkWidget* pProgressBar = GTK_WIDGET (pData);
|
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(pProgressBar), fValue);
|
|
|
|
}
|
|
|
|
|
2015-05-21 13:17:18 +01:00
|
|
|
/// LOKDocView found no search matches -> set the search label accordingly.
|
|
|
|
static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpointer /*pData*/)
|
|
|
|
{
|
|
|
|
gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found");
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:01:30 +05:30
|
|
|
|
2015-05-27 11:30:04 +02:00
|
|
|
static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*/)
|
|
|
|
{
|
|
|
|
g_bPartSelectorBroadcast = false;
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(pPartSelector), nPart);
|
|
|
|
g_bPartSelectorBroadcast = true;
|
|
|
|
}
|
|
|
|
|
2015-06-23 09:58:19 +02:00
|
|
|
/// User clicked on a command button -> inform LOKDocView.
|
2015-06-23 01:52:44 +05:30
|
|
|
static void signalHyperlink(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer /*pData*/)
|
|
|
|
{
|
|
|
|
GError* pError = NULL;
|
|
|
|
gtk_show_uri(NULL, pPayload, GDK_CURRENT_TIME, &pError);
|
|
|
|
if (pError != NULL)
|
|
|
|
{
|
|
|
|
g_warning("Unable to show URI %s : %s", pPayload, pError->message);
|
|
|
|
g_error_free(pError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
|
2015-04-14 11:04:42 +02:00
|
|
|
{
|
|
|
|
if (g_bToolItemBroadcast)
|
2015-04-14 11:19:27 +02:00
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
|
2015-04-14 11:19:27 +02:00
|
|
|
GtkToolItem* pItem = GTK_TOOL_ITEM(pWidget);
|
|
|
|
const std::string& rString = g_aToolItemCommandNames[pItem];
|
2015-06-06 02:32:54 +05:30
|
|
|
g_info("toggleToolItem: lok_doc_view_post_command('%s')", rString.c_str());
|
|
|
|
lok_doc_view_post_command(pLOKDocView, rString.c_str(), 0);
|
2015-04-14 11:19:27 +02:00
|
|
|
}
|
2015-04-14 11:04:42 +02:00
|
|
|
}
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void populatePartSelector()
|
2014-07-08 15:32:46 +02:00
|
|
|
{
|
2014-07-30 07:33:54 +02:00
|
|
|
gtk_list_store_clear( GTK_LIST_STORE(
|
|
|
|
gtk_combo_box_get_model(
|
|
|
|
GTK_COMBO_BOX(pPartSelector) )) );
|
|
|
|
|
|
|
|
if ( !pDocView )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-29 13:17:45 +02:00
|
|
|
const int nMaxLength = 50;
|
|
|
|
char sText[nMaxLength];
|
|
|
|
|
2015-06-06 02:32:54 +05:30
|
|
|
int nParts = lok_doc_view_get_parts( LOK_DOC_VIEW(pDocView) );
|
2014-07-29 13:17:45 +02:00
|
|
|
for ( int i = 0; i < nParts; i++ )
|
2014-07-08 15:32:46 +02:00
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
char* pName = lok_doc_view_get_part_name( LOK_DOC_VIEW(pDocView), i );
|
2014-07-29 13:17:45 +02:00
|
|
|
assert( pName );
|
|
|
|
snprintf( sText, nMaxLength, "%i (%s)", i+1, pName );
|
|
|
|
free( pName );
|
|
|
|
|
2014-07-30 07:33:54 +02:00
|
|
|
gtk_combo_box_text_append_text( pPartSelector, sText );
|
2014-07-08 15:32:46 +02:00
|
|
|
}
|
2014-07-30 07:33:35 +02:00
|
|
|
gtk_combo_box_set_active( GTK_COMBO_BOX(pPartSelector),
|
2015-06-06 02:32:54 +05:30
|
|
|
lok_doc_view_get_part( LOK_DOC_VIEW(pDocView) ) );
|
2014-07-08 15:32:46 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 02:13:47 +02:00
|
|
|
static void signalSize(LOKDocView* /*pLOKDocView*/, gpointer /*pData*/)
|
|
|
|
{
|
|
|
|
g_bPartSelectorBroadcast = false;
|
|
|
|
populatePartSelector();
|
|
|
|
g_bPartSelectorBroadcast = true;
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
|
2014-07-08 15:32:46 +02:00
|
|
|
{
|
|
|
|
int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
|
|
|
|
|
2015-05-27 11:30:04 +02:00
|
|
|
if (g_bPartSelectorBroadcast && pDocView)
|
2014-07-08 15:32:46 +02:00
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
lok_doc_view_set_part( LOK_DOC_VIEW(pDocView), nPart );
|
2015-07-21 18:49:21 +03:00
|
|
|
lok_doc_view_reset_view( LOK_DOC_VIEW(pDocView) );
|
2014-07-08 15:32:46 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-29 17:01:48 +02:00
|
|
|
|
2015-07-11 21:29:53 +05:30
|
|
|
static void removeChildrenFromStatusbar(GtkWidget* children, gpointer)
|
|
|
|
{
|
|
|
|
gtk_container_remove(GTK_CONTAINER(pStatusBar), children);
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void populatePartModeSelector( GtkComboBoxText* pSelector )
|
2014-07-29 17:01:48 +02:00
|
|
|
{
|
2015-05-22 12:14:36 +01:00
|
|
|
gtk_combo_box_text_append_text( pSelector, "Standard" );
|
2014-07-29 17:01:48 +02:00
|
|
|
gtk_combo_box_text_append_text( pSelector, "Notes" );
|
|
|
|
gtk_combo_box_set_active( GTK_COMBO_BOX(pSelector), 0 );
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:07:52 +05:30
|
|
|
static void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
|
2014-07-29 17:01:48 +02:00
|
|
|
{
|
|
|
|
// Just convert directly back to the LibreOfficeKitPartMode enum.
|
|
|
|
// I.e. the ordering above should match the enum member ordering.
|
|
|
|
LibreOfficeKitPartMode ePartMode =
|
|
|
|
LibreOfficeKitPartMode( gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) ) );
|
|
|
|
|
|
|
|
if ( pDocView )
|
|
|
|
{
|
2015-06-06 02:32:54 +05:30
|
|
|
lok_doc_view_set_partmode( LOK_DOC_VIEW(pDocView), ePartMode );
|
2014-07-29 17:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-08 09:53:42 +02:00
|
|
|
|
2015-07-06 22:01:30 +05:30
|
|
|
static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpointer /*userdata*/)
|
|
|
|
{
|
|
|
|
LOKDocView* pDocView1 = LOK_DOC_VIEW (source_object);
|
|
|
|
GError* error = NULL;
|
|
|
|
GList *focusChain = NULL;
|
|
|
|
|
|
|
|
if (!lok_doc_view_open_document_finish(pDocView1, res, &error))
|
|
|
|
{
|
|
|
|
g_warning ("Error occurred while opening the document : %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
populatePartSelector();
|
|
|
|
populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) );
|
|
|
|
// Connect these signals after populating the selectors, to avoid re-rendering on setting the default part/partmode.
|
|
|
|
g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0);
|
|
|
|
g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0);
|
|
|
|
|
|
|
|
focusChain = g_list_append( focusChain, pDocView1 );
|
|
|
|
gtk_container_set_focus_chain ( GTK_CONTAINER (pVBox), focusChain );
|
2015-07-07 21:16:45 +05:30
|
|
|
|
|
|
|
gtk_widget_hide (pStatusBar);
|
2015-07-06 22:01:30 +05:30
|
|
|
}
|
|
|
|
|
2014-05-07 20:14:59 +01:00
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
2014-12-10 12:29:28 +01:00
|
|
|
if( argc < 3 ||
|
2014-05-07 20:14:59 +01:00
|
|
|
( argc > 1 && ( !strcmp( argv[1], "--help" ) || !strcmp( argv[1], "-h" ) ) ) )
|
|
|
|
return help();
|
|
|
|
|
|
|
|
if ( argv[1][0] != '/' )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Absolute path required to libreoffice install\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
2014-05-09 14:39:55 +01:00
|
|
|
GtkWidget *pWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
2015-01-20 13:44:59 +01:00
|
|
|
gtk_window_set_title( GTK_WINDOW(pWindow), "LibreOfficeKit GTK Tiled Viewer" );
|
2015-03-25 15:26:37 +01:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(pWindow), 1024, 768);
|
2014-05-07 20:14:59 +01:00
|
|
|
g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
pVBox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_container_add( GTK_CONTAINER(pWindow), pVBox );
|
2014-05-07 20:14:59 +01:00
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
// Toolbar
|
|
|
|
GtkWidget* pToolbar = gtk_toolbar_new();
|
|
|
|
gtk_toolbar_set_style( GTK_TOOLBAR(pToolbar), GTK_TOOLBAR_ICONS );
|
2014-05-16 09:08:41 +01:00
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
GtkToolItem* pZoomIn = gtk_tool_button_new( NULL, NULL );
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomIn), "zoom-in-symbolic");
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomIn, 0);
|
|
|
|
g_signal_connect( G_OBJECT(pZoomIn), "clicked", G_CALLBACK(changeZoom), NULL );
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
GtkToolItem* pZoom1 = gtk_tool_button_new( NULL, NULL );
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoom1), "zoom-original-symbolic");
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoom1, -1);
|
|
|
|
g_signal_connect( G_OBJECT(pZoom1), "clicked", G_CALLBACK(changeZoom), NULL );
|
2014-05-16 09:08:41 +01:00
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
GtkToolItem* pZoomOut = gtk_tool_button_new( NULL, NULL );
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomOut), "zoom-out-symbolic");
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomOut, -1);
|
|
|
|
g_signal_connect( G_OBJECT(pZoomOut), "clicked", G_CALLBACK(changeZoom), NULL );
|
|
|
|
|
2014-07-08 09:53:42 +02:00
|
|
|
GtkToolItem* pSeparator1 = gtk_separator_tool_item_new();
|
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator1, -1);
|
|
|
|
|
2014-07-08 15:32:46 +02:00
|
|
|
GtkToolItem* pPartSelectorToolItem = gtk_tool_item_new();
|
|
|
|
GtkWidget* pComboBox = gtk_combo_box_text_new();
|
|
|
|
gtk_container_add( GTK_CONTAINER(pPartSelectorToolItem), pComboBox );
|
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartSelectorToolItem, -1 );
|
|
|
|
|
2014-07-30 07:33:54 +02:00
|
|
|
pPartSelector = GTK_COMBO_BOX_TEXT(pComboBox);
|
|
|
|
|
2014-07-08 15:32:46 +02:00
|
|
|
GtkToolItem* pSeparator2 = gtk_separator_tool_item_new();
|
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator2, -1);
|
|
|
|
|
2014-07-29 17:01:48 +02:00
|
|
|
GtkToolItem* pPartModeSelectorToolItem = gtk_tool_item_new();
|
2015-07-06 22:01:30 +05:30
|
|
|
pPartModeComboBox = gtk_combo_box_text_new();
|
2014-07-29 17:01:48 +02:00
|
|
|
gtk_container_add( GTK_CONTAINER(pPartModeSelectorToolItem), pPartModeComboBox );
|
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
|
|
|
|
|
2015-03-10 11:18:25 +01:00
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
|
2015-06-18 09:18:18 +02:00
|
|
|
|
|
|
|
// Cut, copy & paste.
|
|
|
|
GtkToolItem* pCopyButton = gtk_tool_button_new( NULL, NULL);
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(pCopyButton), "edit-copy-symbolic");
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pCopyButton, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pCopyButton), "clicked", G_CALLBACK(doCopy), NULL);
|
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
pEnableEditing = gtk_toggle_tool_button_new();
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pEnableEditing), "insert-text-symbolic");
|
2015-03-10 11:18:25 +01:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pEnableEditing), "toggled", G_CALLBACK(toggleEditing), NULL);
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
GtkToolItem* pFindButton = gtk_tool_button_new( NULL, NULL);
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindButton), "edit-find-symbolic");
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
|
2015-03-10 11:18:25 +01:00
|
|
|
|
2015-03-12 14:59:59 +01:00
|
|
|
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
pBold = gtk_toggle_tool_button_new();
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pBold), "format-text-bold-symbolic");
|
2015-03-12 14:59:59 +01:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pBold, -1);
|
2015-04-14 11:19:27 +02:00
|
|
|
g_signal_connect(G_OBJECT(pBold), "toggled", G_CALLBACK(toggleToolItem), NULL);
|
|
|
|
lcl_registerToolItem(pBold, ".uno:Bold");
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
pItalic = gtk_toggle_tool_button_new();
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pItalic), "format-text-italic-symbolic");
|
2015-04-14 11:04:42 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pItalic, -1);
|
2015-04-14 11:19:27 +02:00
|
|
|
g_signal_connect(G_OBJECT(pItalic), "toggled", G_CALLBACK(toggleToolItem), NULL);
|
|
|
|
lcl_registerToolItem(pItalic, ".uno:Italic");
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
pUnderline = gtk_toggle_tool_button_new();
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pUnderline), "format-text-underline-symbolic");
|
2015-04-14 11:33:12 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pUnderline, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pUnderline), "toggled", G_CALLBACK(toggleToolItem), NULL);
|
|
|
|
lcl_registerToolItem(pUnderline, ".uno:Underline");
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
pStrikethrough = gtk_toggle_tool_button_new ();
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pStrikethrough), "format-text-strikethrough-symbolic");
|
2015-04-14 11:33:12 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pStrikethrough, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pStrikethrough), "toggled", G_CALLBACK(toggleToolItem), NULL);
|
|
|
|
lcl_registerToolItem(pStrikethrough, ".uno:Strikeout");
|
2015-03-12 14:59:59 +01:00
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_box_pack_start( GTK_BOX(pVBox), pToolbar, FALSE, FALSE, 0 ); // Adds to top.
|
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
// Findbar
|
|
|
|
pFindbar = gtk_toolbar_new();
|
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(pFindbar), GTK_TOOLBAR_ICONS);
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
GtkToolItem* pFindbarClose = gtk_tool_button_new( NULL, NULL);
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarClose), "window-close-symbolic");
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarClose, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pFindbarClose), "clicked", G_CALLBACK(toggleFindbar), NULL);
|
|
|
|
|
|
|
|
GtkToolItem* pEntryContainer = gtk_tool_item_new();
|
|
|
|
pFindbarEntry = gtk_entry_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(pEntryContainer), pFindbarEntry);
|
|
|
|
g_signal_connect(pFindbarEntry, "key-press-event", G_CALLBACK(signalFindbar), 0);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pEntryContainer, -1);
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
GtkToolItem* pFindbarNext = gtk_tool_button_new( NULL, NULL);
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarNext), "go-down-symbolic");
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarNext, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pFindbarNext), "clicked", G_CALLBACK(signalSearchNext), NULL);
|
2015-06-10 20:59:18 +05:30
|
|
|
|
|
|
|
GtkToolItem* pFindbarPrev = gtk_tool_button_new( NULL, NULL);
|
|
|
|
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarPrev), "go-up-symbolic");
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarPrev, -1);
|
|
|
|
g_signal_connect(G_OBJECT(pFindbarPrev), "clicked", G_CALLBACK(signalSearchPrev), NULL);
|
|
|
|
|
2015-05-21 13:17:18 +01:00
|
|
|
GtkToolItem* pFindbarLabelContainer = gtk_tool_item_new();
|
|
|
|
pFindbarLabel = gtk_label_new("");
|
|
|
|
gtk_container_add(GTK_CONTAINER(pFindbarLabelContainer), pFindbarLabel);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarLabelContainer, -1);
|
|
|
|
|
2015-04-22 17:56:18 +02:00
|
|
|
gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0);
|
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
// Docview
|
2015-06-18 21:52:22 +05:30
|
|
|
pDocView = lok_doc_view_new (argv[1], NULL, NULL);
|
2015-06-29 13:31:56 +01:00
|
|
|
#if GLIB_CHECK_VERSION(2,40,0)
|
2015-06-29 13:34:24 +05:30
|
|
|
g_assert_nonnull(pDocView);
|
2015-06-29 13:31:56 +01:00
|
|
|
#endif
|
2015-06-29 13:34:24 +05:30
|
|
|
|
2015-03-10 12:50:59 +01:00
|
|
|
g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
|
2015-04-14 11:00:11 +02:00
|
|
|
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
|
2015-05-21 13:17:18 +01:00
|
|
|
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
|
2015-05-27 11:30:04 +02:00
|
|
|
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
|
2015-08-01 02:13:47 +02:00
|
|
|
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
|
2015-06-23 01:52:44 +05:30
|
|
|
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
|
2015-01-07 17:19:40 +01:00
|
|
|
|
2015-07-07 21:16:45 +05:30
|
|
|
|
2015-06-09 16:27:37 +05:30
|
|
|
// Scrolled window for DocView
|
|
|
|
pScrolledWindow = gtk_scrolled_window_new(0, 0);
|
2015-06-10 16:28:45 +05:30
|
|
|
gtk_widget_set_hexpand (pScrolledWindow, TRUE);
|
|
|
|
gtk_widget_set_vexpand (pScrolledWindow, TRUE);
|
2015-06-09 16:27:37 +05:30
|
|
|
gtk_container_add(GTK_CONTAINER(pVBox), pScrolledWindow);
|
|
|
|
|
2015-06-10 20:59:18 +05:30
|
|
|
gtk_container_add(GTK_CONTAINER(pScrolledWindow), pDocView);
|
2014-06-23 15:13:40 +01:00
|
|
|
|
2015-07-07 21:16:45 +05:30
|
|
|
GtkWidget* pProgressBar = gtk_progress_bar_new ();
|
|
|
|
g_signal_connect(pDocView, "load-changed", G_CALLBACK(loadChanged), pProgressBar);
|
|
|
|
|
|
|
|
pStatusBar = gtk_statusbar_new ();
|
2015-07-11 21:29:53 +05:30
|
|
|
gtk_container_forall(GTK_CONTAINER(pStatusBar), removeChildrenFromStatusbar, NULL);
|
2015-07-07 21:16:45 +05:30
|
|
|
gtk_container_add (GTK_CONTAINER(pVBox), pStatusBar);
|
|
|
|
gtk_container_add (GTK_CONTAINER(pStatusBar), pProgressBar);
|
2015-07-11 21:29:53 +05:30
|
|
|
gtk_widget_set_hexpand(pProgressBar, true);
|
2015-07-07 21:16:45 +05:30
|
|
|
|
2014-06-23 15:13:40 +01:00
|
|
|
gtk_widget_show_all( pWindow );
|
2015-04-22 17:56:18 +02:00
|
|
|
// Hide the findbar by default.
|
|
|
|
gtk_widget_hide(pFindbar);
|
2014-06-23 15:13:40 +01:00
|
|
|
|
2015-07-06 22:01:30 +05:30
|
|
|
lok_doc_view_open_document( LOK_DOC_VIEW(pDocView), argv[2], NULL, openDocumentCallback, pDocView );
|
2015-06-23 02:58:38 +05:30
|
|
|
|
2014-05-07 20:14:59 +01:00
|
|
|
gtk_main();
|
|
|
|
|
|
|
|
return 0;
|
2014-07-08 09:53:42 +02:00
|
|
|
}
|
2014-07-21 19:39:49 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|