/** * Try to select the bookmark before the current one. * If none is selected the last in the list is picked. * Wraps around. */ void AP_UnixDialog_Goto::_selectPrevBookmark () { UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark ()\n")); GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvBookmarks)); UT_return_if_fail (model != NULL); GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvBookmarks)); GtkTreeIter iter; // try to select prev gboolean haveSelected = gtk_tree_selection_get_selected (selection, &model, &iter); if (haveSelected) { GtkTreePath *path = gtk_tree_model_get_path (model, &iter); gtk_tree_path_prev (path); gboolean havePrev = gtk_tree_model_get_iter (model, &iter, path); if (havePrev) { gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); return; } gtk_tree_path_free (path); } // select last UT_uint32 idx = getExistingBookmarksCount () - 1; GtkTreePath *path = gtk_tree_path_new_from_indices (idx); gtk_tree_selection_select_path (selection, path); UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark () select last '%d'\n", gtk_tree_model_get_iter (model, &iter, path))); gtk_tree_path_free (path); }
/*! * Update dialog's data. */ void AP_UnixDialog_Goto::updateWindow () { UT_DEBUGMSG (("ROB: updateWindow () #bookmarks='%d', mapped='%d'\n", getExistingBookmarksCount(), GTK_WIDGET_MAPPED(m_wDialog))); ConstructWindowName (); gtk_window_set_title (GTK_WINDOW (m_wDialog), m_WindowName); // pages, page increment of 10 is pretty arbitrary (set in the GtkBuilder UI file) UT_uint32 currentPage = getView()->getCurrentPageNumForStatusBar (); gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_sbPage), currentPage); // lines, line increment of 10 is pretty arbitrary (set in the GtkBuilder UI file) UT_uint32 currentLine = 1; /* FIXME get current line */ gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_sbLine), currentLine); // bookmarks, detaching model for faster updates GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvBookmarks)); g_object_ref (G_OBJECT (model)); gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvBookmarks), NULL); gtk_list_store_clear (GTK_LIST_STORE (model)); GtkTreeIter iter; UT_uint32 numBookmarks = getExistingBookmarksCount(); for (UT_uint32 i = 0; i < numBookmarks; i++) { gtk_list_store_append (GTK_LIST_STORE (model), &iter); const gchar *name = getNthExistingBookmark(i); UT_DEBUGMSG ((" ROB: '%s'\n", name)); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NAME, name, /* COLUMN_PAGE, "0", COLUMN_NUMBER, 0, */ -1); } gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvBookmarks), model); g_object_unref (G_OBJECT (model)); updateDocCount (); }
BOOL AP_Win32Dialog_InsertHyperlink::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/) { const XAP_StringSet* pSS = m_pApp->getStringSet(); // Update the caption setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_InsertHyperlink_Title)); /* Localise controls*/ _DSX(INSERTHYPERLINK_BTN_OK, DLG_OK); _DSX(INSERTHYPERLINK_BTN_CANCEL, DLG_Cancel); _DS(INSERTHYPERLINK_LBL_MSG, DLG_InsertHyperlink_Msg); // initial data resetContent(AP_RID_DIALOG_INSERTHYPERLINK_LBX_LINK); UT_uint32 count = getExistingBookmarksCount(); for( UT_uint32 i = 0; i < count; i++) { addItemToList( AP_RID_DIALOG_INSERTHYPERLINK_LBX_LINK, getNthExistingBookmark( i ) ); } SetFocus(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK)); const gchar * hyperlink = getHyperlink(); if(hyperlink) { if(hyperlink[0]=='#') //ignore the anchor for internal bookmarks { setControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, hyperlink+1); } else { setControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, hyperlink); } selectControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, 0, -1); } centerDialog(); return 0; // 0 because we called set focus }
void AP_UnixDialog_InsertHyperlink::_constructWindowContents ( GtkWidget * vbox2 ) { const XAP_StringSet * pSS = m_pApp->getStringSet(); GtkWidget *label1; GtkWidget *label2; std::string s; pSS->getValueUTF8(AP_STRING_ID_DLG_InsertHyperlink_Msg,s); label1 = gtk_label_new (s.c_str()); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 3); m_entry = gtk_entry_new(); gtk_box_pack_start (GTK_BOX (vbox2), m_entry, FALSE, FALSE, 0); gtk_widget_show(m_entry); const gchar * hyperlink = getHyperlink(); if (hyperlink && *hyperlink) { if (*hyperlink == '#') { gtk_entry_set_text ( GTK_ENTRY(m_entry), hyperlink + 1) ; } else { gtk_entry_set_text ( GTK_ENTRY(m_entry), hyperlink ) ; } } // the bookmark list m_swindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_swindow),GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show(m_swindow); gtk_box_pack_start (GTK_BOX (vbox2), m_swindow, TRUE, TRUE, 0); GtkListStore * store = gtk_list_store_new(1, G_TYPE_STRING); GtkTreeView * treeview; m_clist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); treeview = GTK_TREE_VIEW(m_clist); gtk_tree_view_set_headers_visible(treeview, FALSE); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), GTK_SELECTION_BROWSE); GtkCellRenderer *renderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new()); GtkTreeViewColumn *col; col = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col); //gtk_box_pack_start (GTK_BOX (vbox2), m_blist, FALSE, FALSE, 0); m_pBookmarks.clear(); for (int i = 0; i < static_cast<int>(getExistingBookmarksCount()); i++) { m_pBookmarks.push_back(getNthExistingBookmark(i)); } std::sort(m_pBookmarks.begin(), m_pBookmarks.end()); for (int i = 0; i < static_cast<int>(getExistingBookmarksCount()); i++) { GtkTreeIter iter; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, m_pBookmarks[i].c_str(), -1); } gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(m_swindow),m_clist); pSS->getValueUTF8(AP_STRING_ID_DLG_InsertHyperlink_TitleLabel, s); label2 = gtk_label_new(s.c_str()); gtk_widget_show(label2); gtk_box_pack_start(GTK_BOX(vbox2), label2, TRUE, TRUE, 3); m_titleEntry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(vbox2), m_titleEntry, FALSE, FALSE, 0); gtk_widget_show(m_titleEntry); const gchar * hyperlinkTitle = getHyperlinkTitle(); if (hyperlinkTitle && *hyperlinkTitle) { gtk_entry_set_text(GTK_ENTRY(m_titleEntry), hyperlinkTitle); } }