summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-29 13:17:45 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-30 12:44:02 +0200
commit36e5f73637194afdb9ff0e320f6086be35c94a61 (patch)
treea48bcd3b87a9bb7938319d29bf7cddf8e11ad044
parent366d8fb4dbe829653a4996acc8e9bae512ed0155 (diff)
gtktiledviewer: show part names in selector.
Change-Id: I02ae5b729f96e36b3f226218b32495907cb63cf3
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx20
1 files changed, 15 insertions, 5 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 21cb179d4ecf..d74eb962e01b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <assert.h>
#include <stdio.h>
#include <string.h>
@@ -122,10 +123,17 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ )
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
void populatePartSelector( GtkComboBoxText* pSelector, LOKDocView* pView )
{
- char sText[10];
- for ( int i = 0; i < lok_docview_get_parts(pView); i++ )
+ const int nMaxLength = 50;
+ char sText[nMaxLength];
+
+ int nParts = lok_docview_get_parts(pView);
+ for ( int i = 0; i < nParts; i++ )
{
- sprintf( sText, "%i", i+1 );
+ char* pName = lok_docview_get_part_name( pView, i );
+ assert( pName );
+ snprintf( sText, nMaxLength, "%i (%s)", i+1, pName );
+ free( pName );
+
gtk_combo_box_text_append_text( pSelector, sText );
}
gtk_combo_box_set_active( GTK_COMBO_BOX(pSelector), 0 );
@@ -219,8 +227,10 @@ int main( int argc, char* argv[] )
gtk_widget_show_all( pWindow );
pFileName = argv[2];
- lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
-// GtkComboBox requires gtk 2.24 or later
+ assert( lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ) );
+ assert( LOK_DOCVIEW(pDocView)->pDocument );
+
+ // GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
populatePartSelector( GTK_COMBO_BOX_TEXT(pComboBox), LOK_DOCVIEW(pDocView) );
#endif