lokdocview: fix not updated part selector when search changes part
Change-Id: I337eed47c56dbbbebda4d7fe716eab6177936dc0
This commit is contained in:
parent
adce9bf3ad
commit
c7ecbbbb6a
@ -40,6 +40,7 @@ struct _LOKDocViewClass
|
||||
void (* edit_changed) (LOKDocView* pView, gboolean was_edit);
|
||||
void (* command_changed) (LOKDocView* pView, char* new_state);
|
||||
void (* search_not_found) (LOKDocView* pView, char* new_state);
|
||||
void (* part_changed) (LOKDocView* pView, int new_part);
|
||||
};
|
||||
|
||||
guint lok_docview_get_type (void);
|
||||
|
@ -45,6 +45,8 @@ static GtkWidget* pVBox;
|
||||
// GtkComboBox requires gtk 2.24 or later
|
||||
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
|
||||
static GtkComboBoxText* pPartSelector;
|
||||
/// Should the part selector avoid calling lok::Document::setPart()?
|
||||
static bool g_bPartSelectorBroadcast = true;
|
||||
#endif
|
||||
GtkWidget* pFindbar;
|
||||
GtkWidget* pFindbarEntry;
|
||||
@ -238,6 +240,15 @@ static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpoint
|
||||
gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found");
|
||||
}
|
||||
|
||||
static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*/)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,24,0)
|
||||
g_bPartSelectorBroadcast = false;
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(pPartSelector), nPart);
|
||||
g_bPartSelectorBroadcast = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// User clicked on a cmmand button -> inform LOKDocView.
|
||||
static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
|
||||
{
|
||||
@ -285,7 +296,7 @@ static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
|
||||
{
|
||||
int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
|
||||
|
||||
if ( pDocView )
|
||||
if (g_bPartSelectorBroadcast && pDocView)
|
||||
{
|
||||
lok_docview_set_part( LOK_DOCVIEW(pDocView), nPart );
|
||||
}
|
||||
@ -436,6 +447,7 @@ int main( int argc, char* argv[] )
|
||||
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);
|
||||
|
||||
// Input handling.
|
||||
g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), pDocView);
|
||||
|
@ -194,6 +194,8 @@ struct LOKDocView_Impl
|
||||
void commandChanged(const std::string& rPayload);
|
||||
/// Search did not find any matches.
|
||||
void searchNotFound(const std::string& rPayload);
|
||||
/// LOK decided to change parts, need to update UI.
|
||||
void setPart(const std::string& rPayload);
|
||||
};
|
||||
|
||||
namespace {
|
||||
@ -1019,7 +1021,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
|
||||
break;
|
||||
case LOK_CALLBACK_SET_PART:
|
||||
{
|
||||
renderDocument(0);
|
||||
setPart(pCallback->m_aPayload);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1066,6 +1068,7 @@ enum
|
||||
EDIT_CHANGED,
|
||||
COMMAND_CHANGED,
|
||||
SEARCH_NOT_FOUND,
|
||||
PART_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -1081,6 +1084,12 @@ void LOKDocView_Impl::searchNotFound(const std::string& rString)
|
||||
g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str());
|
||||
}
|
||||
|
||||
void LOKDocView_Impl::setPart(const std::string& rString)
|
||||
{
|
||||
g_signal_emit(m_pDocView, docview_signals[PART_CHANGED], 0, std::stoi(rString));
|
||||
renderDocument(0);
|
||||
}
|
||||
|
||||
static void lok_docview_class_init( gpointer ptr )
|
||||
{
|
||||
LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr);
|
||||
@ -1115,6 +1124,16 @@ static void lok_docview_class_init( gpointer ptr )
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
pClass->part_changed = 0;
|
||||
docview_signals[PART_CHANGED] =
|
||||
g_signal_new("part-changed",
|
||||
G_TYPE_FROM_CLASS(gobject_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(LOKDocViewClass, part_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__INT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
}
|
||||
|
||||
static void lok_docview_init( GTypeInstance* pInstance, gpointer )
|
||||
|
Loading…
x
Reference in New Issue
Block a user