? 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-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 09:23:07 -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" @@ -66,19 +68,26 @@ static const GtkTargetEntry s_AbiTBTargets[] = {{"abi-toolbars",0,0}}; +class EV_UnixToolbar; class _wd; 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_UnixToolbar *toolbar, + 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 style_get_pango_attrs (PD_Style *pStyle, + PangoFontDescription *desc); /** * toolbar_append_with_eventbox @@ -710,6 +719,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 +729,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 +738,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 +753,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 +781,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, this, GTK_COMBO_BOX(combo), v); } // stick it in the toolbar @@ -1129,7 +1145,7 @@ // // 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, this, item, v); wd->m_blockSignal = wasBlocked; @@ -1145,11 +1161,27 @@ /*! * 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_UnixToolbar *toolbar, GtkComboBox *combo, const UT_GenericVector *strings) { + + // 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 ()); + } + + // font size for font combo static gint size = 0; if (size == 0) { PangoContext *context = gtk_widget_get_pango_context (GTK_WIDGET (combo)); @@ -1159,25 +1191,83 @@ size = (size / PANGO_SCALE + 2) * PANGO_SCALE; } + AD_Document * pAD_Doc = toolbar->getFrame()->getCurrentDoc(); + PD_Document *pDoc = static_cast(pAD_Doc); + 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 + if (pDoc == NULL) { + // that's ok while starting abi + return; + } + const gchar * style = strings->getNthItem(i); + PD_Style * pStyle = NULL; + bool haveStyle = pDoc->getStyle (style, &pStyle); + UT_return_if_fail (haveStyle && pStyle); + + const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet(); + if (!(pStyle->isUsed () || + /* todo : there is a problem when comparing to the translated style names + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_NORMAL)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_HEADING1)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_HEADING2)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_BULLETLIST)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_NUMBER_LIST)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_BLOCKTEXT)) || + !UT_strcmp (style, pSS->getValue(XAP_STRING_ID_STYLE_PLAIN_TEXT)))) { + */ + !UT_strcmp (style, "Normal") || + !UT_strcmp (style, "Heading 1") || + !UT_strcmp (style, "Heading 2") || + !UT_strcmp (style, "Bullet List") || + !UT_strcmp (style, "Numbered List") || + !UT_strcmp (style, "Plain Text") || + !UT_strcmp (style, "Block Text"))) { - GtkTreeIter iter; - gtk_list_store_append (store, &iter); - - // font preview - if (wd->m_id == AP_TOOLBAR_ID_FMT_FONT) { + continue; + } + + PangoFontDescription *desc = pango_font_description_copy (default_desc); + style_get_pango_attrs (pStyle, desc); + + 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, style, + COLUMN_FONT, desc, + -1); + pango_font_description_free (desc); + } + 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())) { + // show a few symbols and name extra + 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); + gtk_list_store_set (store, &iter, + 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); } } } @@ -1237,3 +1327,37 @@ return value; } + +/*! +* \todo ROB parse more attributes like font-color, background-color +*/ +void +style_get_pango_attrs (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); + } +} 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 09:23:12 -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 09:23:13 -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 09:23:17 -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 09:23:25 -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")