summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-30 07:33:54 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-30 12:44:05 +0200
commit77d083130948fa35f9f404656b8c170060e78043 (patch)
tree99b60e555a74311b8c1803a9126cf838dd37da61
parentdf438e6ea260c1367fac0c2f195f1aff6311709f (diff)
LokDocView: Update part selector when mode changes.
Change-Id: Ice754a46d07ce2714257c30e1aef27193b614cd3
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx26
1 files changed, 21 insertions, 5 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index c58899384497..9a403259de24 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -27,6 +27,7 @@ static int help()
static GtkWidget* pDocView;
static GtkWidget* pDocViewQuad;
static GtkWidget* pVBox;
+static GtkComboBoxText* pPartSelector;
static LibreOfficeKit* pOffice;
static char* pFileName;
@@ -121,20 +122,29 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ )
// GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
-void populatePartSelector( GtkComboBoxText* pSelector, LOKDocView* pView )
+void populatePartSelector()
{
+ gtk_list_store_clear( GTK_LIST_STORE(
+ gtk_combo_box_get_model(
+ GTK_COMBO_BOX(pPartSelector) )) );
+
+ if ( !pDocView )
+ {
+ return;
+ }
+
const int nMaxLength = 50;
char sText[nMaxLength];
- int nParts = lok_docview_get_parts(pView);
+ int nParts = lok_docview_get_parts( LOK_DOCVIEW(pDocView) );
for ( int i = 0; i < nParts; i++ )
{
- char* pName = lok_docview_get_part_name( pView, i );
+ char* pName = lok_docview_get_part_name( LOK_DOCVIEW(pDocView), i );
assert( pName );
snprintf( sText, nMaxLength, "%i (%s)", i+1, pName );
free( pName );
- gtk_combo_box_text_append_text( pSelector, sText );
+ gtk_combo_box_text_append_text( pPartSelector, sText );
}
gtk_combo_box_set_active( GTK_COMBO_BOX(pPartSelector),
lok_docview_get_part( LOK_DOCVIEW(pDocView) ) );
@@ -174,6 +184,10 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
{
lok_docview_set_partmode( LOK_DOCVIEW(pDocView), ePartMode );
}
+
+ // The number of items could change e.g. if we change from slide
+ // to embeddede obj mode -- hence we should update the part list.
+ populatePartSelector();
}
#endif
@@ -232,6 +246,8 @@ int main( int argc, char* argv[] )
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartSelectorToolItem, -1 );
g_signal_connect( G_OBJECT(pComboBox), "changed", G_CALLBACK(changePart), NULL );
+ pPartSelector = GTK_COMBO_BOX_TEXT(pComboBox);
+
GtkToolItem* pSeparator2 = gtk_separator_tool_item_new();
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator2, -1);
@@ -265,7 +281,7 @@ int main( int argc, char* argv[] )
// 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) );
+ populatePartSelector();
populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) );
#endif