? abi-gtkcombobox-tookbar.diff ? abi-head-apkg-2.diff ? abi-head-apkg-3.diff ? abi-head-apkg.diff ? abi-stable-apkg-2.diff ? abi-stylecombo-2.diff ? abi-stylecombo-domfeedback-nocompile.diff ? abi-stylecombo-refactored-crashing.diff ? abi-stylecombo.diff ? src/Linux_2.6.10-5-386__ ? src/Linux_2.6.8.1-4-386__ ? src/Unbenannt1.abw.SAVED ? src/Untitled1.abw.SAVED ? src/diff ? src/diff.txt ? src/diff2.txt ? src/af/ev/unix/ev_UnixToolbar.cpp-before-box ? src/af/ev/unix/tmp ? src/af/gr/unix/diff.txt ? src/af/util/xp/diff.txt ? src/af/xap/unix/gnome/diff.txt ? src/text/fmt/xp/diff.txt ? src/text/fmt/xp/diff2.txt ? src/text/fmt/xp/diff3.txt ? src/wp/ap/diff.txt ? src/wp/ap/unix/tmp ? src/wp/test/unix/.deps ? src/wp/test/unix/testwrap.sh Index: src/af/ev/unix/ev_UnixToolbar.cpp =================================================================== RCS file: /cvsroot/abi/src/af/ev/unix/ev_UnixToolbar.cpp,v retrieving revision 1.127 diff -u -r1.127 ev_UnixToolbar.cpp --- src/af/ev/unix/ev_UnixToolbar.cpp 9 May 2005 16:19:38 -0000 1.127 +++ src/af/ev/unix/ev_UnixToolbar.cpp 11 May 2005 17:06:18 -0000 @@ -23,6 +23,7 @@ #include "ut_assert.h" #include "ut_debugmsg.h" #include "ut_string.h" +#include "ut_locale.h" #include "ev_UnixToolbar.h" #include "xap_Types.h" #include "xap_UnixApp.h" @@ -38,6 +39,7 @@ #include "xav_View.h" #include "xap_Prefs.h" #include "fv_View.h" +#include "pd_Style.h" #include "xap_EncodingManager.h" #include "xap_UnixDialogHelper.h" #include "xap_UnixFontPreview.h" @@ -62,7 +64,6 @@ #endif // HAVE_GNOME /*****************************************************************/ -#define COMBO_BUF_LEN 256 static const GtkTargetEntry s_AbiTBTargets[] = {{"abi-toolbars",0,0}}; @@ -70,14 +71,19 @@ enum { COLUMN_STRING = 0, - COLUMN_FONTNAME, + COLUMN_FONT, COLUMN_FONTSIZE, NUM_COLUMNS }; -void abi_gtk_combo_box_fill_from_string_vector (_wd *wd, GtkComboBox *combo, const UT_GenericVector *strings); -void abi_gtk_combo_box_text_select_entry(_wd *wd, GtkComboBox *combo, const gchar *text); -const gchar *abi_gtk_combo_box_get_active_text (GtkComboBox *combo); +void abi_gtk_combo_box_fill_from_string_vector (_wd *wd, + EV_Toolbar_Control *pControl, + GtkComboBox *combo, + const UT_GenericVector *strings); +void abi_gtk_combo_box_text_select_entry (_wd *wd, + GtkComboBox *combo, + const gchar *text); +const gchar *abi_gtk_combo_box_get_active_text (GtkComboBox *combo); /** @@ -710,6 +716,7 @@ GtkWidget *combo = gtk_combo_box_new(); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + GtkListStore *store = NULL; if (wd->m_id == AP_TOOLBAR_ID_ZOOM) { // padding @@ -719,6 +726,7 @@ gtk_widget_show(align); // zoom gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", COLUMN_STRING, NULL); + store = gtk_list_store_new(1, G_TYPE_STRING); } else if (wd->m_id == AP_TOOLBAR_ID_FMT_STYLE) { // padding @@ -727,7 +735,11 @@ gtk_container_add(GTK_CONTAINER(align), combo); gtk_widget_show(align); // style preview - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", COLUMN_STRING, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, + "text", COLUMN_STRING, + "font-desc", COLUMN_FONT, + NULL); + store = gtk_list_store_new(2, G_TYPE_STRING, PANGO_TYPE_FONT_DESCRIPTION); } else if (wd->m_id == AP_TOOLBAR_ID_FMT_FONT) { // padding @@ -738,15 +750,16 @@ // font preview gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", COLUMN_STRING, - "font", COLUMN_FONTNAME, + "font", COLUMN_FONT, "size", COLUMN_FONTSIZE, - NULL); + NULL); + store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); } else { gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", COLUMN_STRING, NULL); + store = gtk_list_store_new(1, G_TYPE_STRING); } - GtkListStore *store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); gtk_combo_box_set_model(GTK_COMBO_BOX(combo), GTK_TREE_MODEL(store)); g_object_unref(store); @@ -765,7 +778,7 @@ const UT_GenericVector * v = pControl->getContents(); UT_ASSERT(v); - abi_gtk_combo_box_fill_from_string_vector (wd, GTK_COMBO_BOX(combo), v); + abi_gtk_combo_box_fill_from_string_vector (wd, pControl, GTK_COMBO_BOX(combo), v); } // stick it in the toolbar @@ -1117,20 +1130,11 @@ // const UT_GenericVector * v = pControl->getContents(); UT_ASSERT(v); -// -// Now we must remove and delete the old glist so we can attach the new -// list of styles to the combo box. -// -// Try this.... -// + bool wasBlocked = wd->m_blockSignal; wd->m_blockSignal = true; // block the signal, so we don't try to read the text entry while this is happening.. - -// -// Now make a new one. -// - abi_gtk_combo_box_fill_from_string_vector (wd, item, v); + abi_gtk_combo_box_fill_from_string_vector (wd, pControl, item, v); wd->m_blockSignal = wasBlocked; // @@ -1145,11 +1149,15 @@ /*! * Refill a combo box (list model, one string column) from a string vector. +* \todo this should probably refactored into the combo classes */ void abi_gtk_combo_box_fill_from_string_vector (_wd *wd, + EV_Toolbar_Control *pControl, GtkComboBox *combo, const UT_GenericVector *strings) { + + // font size for font combo static gint size = 0; if (size == 0) { PangoContext *context = gtk_widget_get_pango_context (GTK_WIDGET (combo)); @@ -1159,25 +1167,51 @@ size = (size / PANGO_SCALE + 2) * PANGO_SCALE; } + AP_UnixToolbar_StyleCombo * pStyleCombo = NULL; + if (wd->m_id == AP_TOOLBAR_ID_FMT_STYLE) { + pStyleCombo = reinterpret_cast(pControl); + } + GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (combo)); gtk_list_store_clear (store); int count = strings->size (); for (int i = 0; i < count; i++) { + + if (wd->m_id == AP_TOOLBAR_ID_FMT_STYLE) { + // style preview + const gchar * style = strings->getNthItem(i); + GtkTreeIter iter; + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_STRING, style, + COLUMN_FONT, pStyleCombo->getStyle(style), + -1); + } + else if (wd->m_id == AP_TOOLBAR_ID_FMT_FONT) { + // font preview + const gchar *name = strings->getNthItem(i); + XAP_UnixFont *pFont = XAP_UnixFontManager::pFontManager->getFont (name, XAP_UnixFont::STYLE_NORMAL); + if (pFont && (pFont->isSymbol() || pFont->isDingbat())) { + // "$fontname (Symbols)" + const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet(); + static UT_UTF8String tmpName; + tmpName = UT_UTF8String_sprintf ("%s (%s)", name, pSS->getValue(XAP_STRING_ID_TB_Font_Symbol)); + name = tmpName.utf8_str(); + } - GtkTreeIter iter; - gtk_list_store_append (store, &iter); - - // font preview - if (wd->m_id == AP_TOOLBAR_ID_FMT_FONT) { + GtkTreeIter iter; + gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - COLUMN_STRING, strings->getNthItem (i), - COLUMN_FONTNAME, strings->getNthItem (i), + COLUMN_STRING, name, + COLUMN_FONT, strings->getNthItem(i), COLUMN_FONTSIZE, size, -1); } else { - gtk_list_store_set (store, &iter, COLUMN_STRING, strings->getNthItem (i), -1); + GtkTreeIter iter; + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, COLUMN_STRING, strings->getNthItem(i), -1); } } } Index: src/af/xap/unix/xap_UnixFont.cpp =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixFont.cpp,v retrieving revision 1.110 diff -u -r1.110 xap_UnixFont.cpp --- src/af/xap/unix/xap_UnixFont.cpp 26 Jan 2005 12:48:11 -0000 1.110 +++ src/af/xap/unix/xap_UnixFont.cpp 11 May 2005 17:06:23 -0000 @@ -397,6 +397,24 @@ return m_style; } +PangoStyle XAP_UnixFont::getPangoStyle(void) const +{ + PangoStyle ret = PANGO_STYLE_NORMAL; + if (m_style == STYLE_ITALIC || m_style == STYLE_BOLD_ITALIC) { + ret = PANGO_STYLE_ITALIC; + } + return ret; +} + +PangoWeight XAP_UnixFont::getPangoWeight(void) const +{ + PangoWeight ret = PANGO_WEIGHT_NORMAL; + if (m_style == STYLE_BOLD || m_style == STYLE_BOLD_ITALIC || m_style == STYLE_BOLD_OUTLINE) { + ret = PANGO_WEIGHT_BOLD; + } + return ret; +} + const char *XAP_UnixFont::getFontfile(void) const { return m_fontfile; Index: src/af/xap/unix/xap_UnixFont.h =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixFont.h,v retrieving revision 1.53 diff -u -r1.53 xap_UnixFont.h --- src/af/xap/unix/xap_UnixFont.h 26 Jan 2005 12:48:11 -0000 1.53 +++ src/af/xap/unix/xap_UnixFont.h 11 May 2005 17:06:24 -0000 @@ -68,6 +68,10 @@ { public: + /*! + * \todo ROB: we maybe could move to using pango attributes exclusively here + * since this is unix only. + */ enum style { STYLE_NORMAL = 0, @@ -96,6 +100,9 @@ void setStyle(XAP_UnixFont::style s); XAP_UnixFont::style getStyle(void) const; + PangoStyle getPangoStyle(void) const; + PangoWeight getPangoWeight(void) const; + const char * getFontfile(void) const; const char * getMetricfile(void) const; const encoding_pair* loadEncodingFile(void); @@ -130,6 +137,7 @@ bool doesGlyphExist(UT_UCS4Char g); bool isSymbol(void) const; bool isDingbat(void) const; + private: XAP_UnixFont (); Index: src/af/xap/unix/xap_UnixFrameImpl.cpp =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixFrameImpl.cpp,v retrieving revision 1.91 diff -u -r1.91 xap_UnixFrameImpl.cpp --- src/af/xap/unix/xap_UnixFrameImpl.cpp 12 Apr 2005 04:26:41 -0000 1.91 +++ src/af/xap/unix/xap_UnixFrameImpl.cpp 11 May 2005 17:06:27 -0000 @@ -35,6 +35,7 @@ #include "xap_ViewListener.h" #include "xap_UnixApp.h" #include "xap_UnixFrameImpl.h" +#include "xap_Frame.h" #include "ev_UnixKeyboard.h" #include "ev_UnixMouse.h" #include "ev_UnixMenuBar.h" Index: src/af/xap/xp/xap_String_Id.h =================================================================== RCS file: /cvsroot/abi/src/af/xap/xp/xap_String_Id.h,v retrieving revision 1.150 diff -u -r1.150 xap_String_Id.h --- src/af/xap/xp/xap_String_Id.h 10 May 2005 08:59:24 -0000 1.150 +++ src/af/xap/xp/xap_String_Id.h 11 May 2005 17:06:30 -0000 @@ -192,6 +192,9 @@ dcl(TB_Zoom_WholePage, "Whole Page") dcl(TB_Zoom_Percent, "Other...") +/* Font tool bar*/ +dcl(TB_Font_Symbol, "Symbols") + /* Unix Print dialog */ dcl(DLG_UP_PrintTitle, "Print") dcl(DLG_UP_PrintPreviewTitle, "AbiWord: Print Preview") Index: src/wp/ap/unix/ap_UnixToolbar_StyleCombo.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixToolbar_StyleCombo.cpp,v retrieving revision 1.15 diff -u -r1.15 ap_UnixToolbar_StyleCombo.cpp --- src/wp/ap/unix/ap_UnixToolbar_StyleCombo.cpp 23 Mar 2004 00:13:08 -0000 1.15 +++ src/wp/ap/unix/ap_UnixToolbar_StyleCombo.cpp 11 May 2005 17:06:37 -0000 @@ -19,9 +19,12 @@ #include "ut_assert.h" #include "ut_vector.h" +#include "ut_locale.h" #include "ap_UnixToolbar_StyleCombo.h" #include "ap_Toolbar_Id.h" #include "xap_Frame.h" +#include "xap_UnixFontManager.h" +#include "xap_UnixFont.h" #include "pd_Style.h" #include "xad_Document.h" #include "xap_App.h" @@ -50,6 +53,7 @@ AP_UnixToolbar_StyleCombo::~AP_UnixToolbar_StyleCombo(void) { + freeStyles(); } /*****************************************************************/ @@ -72,13 +76,21 @@ m_vecContents.addItem("Plain Text"); m_vecContents.addItem("Block Text"); #else + + AD_Document * pAD_Doc = m_pFrame->getCurrentDoc(); + if(!pAD_Doc) + { + return false; + } + PD_Document *pDocument = static_cast(pAD_Doc); + // TODO: need a view/doc pointer to get this right // ALSO: will need to repopulate as new styles added // HYP: only call this method from shared code? const char * szName; const PD_Style * pStyle; - for (UT_uint32 k=0; (m_pDocument->enumStyles(k,&szName,&pStyle)); k++) + for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++) { m_vecContents.addItem(szName); } @@ -98,20 +110,91 @@ { return false; } + PD_Document *pDocument = static_cast(pAD_Doc); + // clear anything that's already there m_vecContents.clear(); + freeStyles(); + + // defaults for style combo + static PangoFontDescription *default_desc = NULL; + if (default_desc == NULL) { + XAP_UnixFont *pDefaultFont = XAP_UnixFontManager::pFontManager->getDefaultFont (); + default_desc = pango_font_description_new (); + pango_font_description_set_family (default_desc, pDefaultFont->getName ()); + // TODO hardcoded default size + pango_font_description_set_size (default_desc, 12 * PANGO_SCALE); + pango_font_description_set_style (default_desc, pDefaultFont->getPangoStyle ()); + pango_font_description_set_weight (default_desc, pDefaultFont->getPangoWeight ()); + } - m_pDocument = static_cast(pAD_Doc); const char * szName; - const PD_Style * pStyle; + PD_Style * pStyle; - for (UT_uint32 k=0; (m_pDocument->enumStyles(k,&szName,&pStyle)); k++) + for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,const_cast(&pStyle))); k++) { + if (!pStyle) { + UT_DEBUGMSG(("no style instance for '%s'\n", szName)); + continue; + } + + if (pStyle->isList()) + continue; + m_vecContents.addItem(szName); + PangoFontDescription *desc = pango_font_description_copy (default_desc); + getPangoAttrs(pStyle, desc); + m_mapStyles.insert(szName, desc); } return true; } +const PangoFontDescription* +AP_UnixToolbar_StyleCombo::getStyle (const gchar *name) { + return m_mapStyles.pick(name); +} + +/*! +* \todo ROB parse more attributes like font-color, background-color +*/ +void +AP_UnixToolbar_StyleCombo::getPangoAttrs (PD_Style *pStyle, + PangoFontDescription *desc) { + + UT_LocaleTransactor t (LC_NUMERIC, "C"); + + const XML_Char *value = NULL; + + if (pStyle->getPropertyExpand ("font-family", value)) { + pango_font_description_set_family (desc, value); + } + + if (pStyle->getPropertyExpand ("font-size", value)) { + pango_font_description_set_size (desc, UT_convertToDimension (value, DIM_PT) * PANGO_SCALE); + } + + if (pStyle->getPropertyExpand ("font-style", value)) { + PangoStyle style = PANGO_STYLE_NORMAL; + if (!UT_strcmp (value, "italic")) + style = PANGO_STYLE_ITALIC; + pango_font_description_set_style (desc, style); + } + if (pStyle->getPropertyExpand ("font-weight", value)) { + PangoWeight weight = PANGO_WEIGHT_NORMAL; + if (!UT_strcmp (value, "bold")) + weight = PANGO_WEIGHT_BOLD; + pango_font_description_set_weight (desc, weight); + } +} +void +AP_UnixToolbar_StyleCombo::freeStyles() { + + UT_GenericVector *pVec = m_mapStyles.enumerate(); + for (UT_uint32 i = 0; i < pVec->size(); i++) { + pango_font_description_free(pVec->getNthItem(i)); + } + delete pVec; +} Index: src/wp/ap/unix/ap_UnixToolbar_StyleCombo.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixToolbar_StyleCombo.h,v retrieving revision 1.5 diff -u -r1.5 ap_UnixToolbar_StyleCombo.h --- src/wp/ap/unix/ap_UnixToolbar_StyleCombo.h 22 Nov 2002 04:54:00 -0000 1.5 +++ src/wp/ap/unix/ap_UnixToolbar_StyleCombo.h 11 May 2005 17:06:37 -0000 @@ -20,12 +20,15 @@ #ifndef AP_UNIXTOOLBAR_STYLECOMBO_H #define AP_UNIXTOOLBAR_STYLECOMBO_H +#include +#include "ut_hash.h" #include "xap_Types.h" #include "ev_Toolbar_Control.h" #include "pd_Document.h" #include "ap_UnixFrame.h" class EV_Toolbar; +class PD_Style; /*****************************************************************/ @@ -37,11 +40,18 @@ virtual bool populate(void); bool repopulate(void); + const PangoFontDescription* getStyle (const gchar *name); static EV_Toolbar_Control * static_constructor(EV_Toolbar *, XAP_Toolbar_Id id); protected: - PD_Document * m_pDocument; - AP_UnixFrame * m_pFrame; + AP_UnixFrame * m_pFrame; + +private: + void getPangoAttrs(PD_Style *pStyle, + PangoFontDescription *desc); + void freeStyles (void); + + UT_GenericStringMap m_mapStyles; }; #endif /* AP_UNIXTOOLBAR_STYLECOMBO_H */