1. === modified file 'src/libnrtype/font-lister.cpp'
  2. --- src/libnrtype/font-lister.cpp 2015-05-09 15:39:31 +0000
  3. +++ src/libnrtype/font-lister.cpp 2015-11-08 10:18:34 +0000
  4. @@ -4,7 +4,7 @@
  5. #include <gtkmm/liststore.h>
  6. #include <gtkmm/treemodel.h>
  7. -
  8. +#include "libnrtype/FontFactory.h"
  9. #include <libnrtype/font-instance.h>
  10. #include <libnrtype/TextWrapper.h>
  11. #include <libnrtype/one-glyph.h>
  12. @@ -59,8 +59,8 @@
  13. // Get sorted font families from Pango
  14. std::vector<PangoFontFamily *> familyVector;
  15. +
  16. font_factory::Default()->GetUIFamilies(familyVector);
  17. -
  18. // Traverse through the family names and set up the list store
  19. for (size_t i = 0; i < familyVector.size(); ++i) {
  20. const char* displayName = sp_font_family_get_name(familyVector[i]);
  21. @@ -122,10 +122,21 @@
  22. ++iter;
  23. }
  24. }
  25. -
  26. -FontLister *FontLister::get_instance()
  27. +//Añadimos un parametro a la función para que refresque/actualize la variable estatica (+- global) de la instancia de font lister
  28. +//Si no durante el transcurso de Inkscape, FontLister seria siempre igual
  29. +FontLister *FontLister::get_instance(bool refresh)
  30. {
  31. static Inkscape::FontLister *instance = new Inkscape::FontLister();
  32. + if(refresh){
  33. + //la sifuiente linea provoca que cuando llamemos despues a el constructor de
  34. + //font lister, este llame a font_factory::Default() generando un nuevo fontfactory
  35. + //con las nuevas fuentes. Estudiatelo para entender como funciona, tienes que seguir el hilo de los procesos
  36. + font_factory::lUsine = NULL;
  37. + //Creamos un nuevo valor de retorno para la variable instance
  38. + //que se queda guardado globalmente, asi que solo hay que llamar a get_instance(true) cuando
  39. + //queramos refrescar la lista de fuentes
  40. + instance = new Inkscape::FontLister();
  41. + }
  42. return instance;
  43. }
  44. === modified file 'src/libnrtype/font-lister.h'
  45. --- src/libnrtype/font-lister.h 2014-10-17 20:03:14 +0000
  46. +++ src/libnrtype/font-lister.h 2015-11-08 10:18:34 +0000
  47. @@ -150,7 +150,12 @@
  48. void update_font_list(SPDocument *document);
  49. public:
  50. - static Inkscape::FontLister *get_instance();
  51. + //a la cabecera de la función le hemos puesto un valor por defecto que en este caso
  52. + //hace que se pueda llamar a la función oviandolo, tal y como hacia inksape antes, es decir
  53. + //puedes llamarlo como originalmente get_instance() y actual normal, dandole el valor a refresh = false
  54. + //o puedes llamarlo get_instance(true)
  55. + //esto nos permite modificar la función y no tener que modificar todas las llamadas a esta dentro de inkscape
  56. + static Inkscape::FontLister *get_instance(bool refresh = false);
  57. /**
  58. * Takes a hand written font spec and returns a Pango generated one in
  59. === modified file 'src/ui/dialog/text-edit.h'
  60. --- src/ui/dialog/text-edit.h 2015-06-25 11:46:43 +0000
  61. +++ src/ui/dialog/text-edit.h 2015-11-08 10:18:34 +0000
  62. @@ -56,7 +56,6 @@
  63. public:
  64. TextEdit();
  65. virtual ~TextEdit();
  66. -
  67. /**
  68. * Helper function which returns a new instance of the dialog.
  69. * getInstance is needed by the dialog manager (Inkscape::UI::Dialog::DialogManager).
  70. === modified file 'src/widgets/font-selector.cpp'
  71. --- src/widgets/font-selector.cpp 2014-10-17 20:03:14 +0000
  72. +++ src/widgets/font-selector.cpp 2015-11-08 10:27:46 +0000
  73. @@ -27,7 +27,7 @@
  74. #include <gtk/gtk.h>
  75. #include <glibmm/i18n.h>
  76. -
  77. +#include "inkscape.h"
  78. #include "desktop.h"
  79. #include "widgets/font-selector.h"
  80. #include "preferences.h"
  81. @@ -121,6 +121,30 @@
  82. gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str()));
  83. }
  84. +static void sp_gtk_fontconfig_timestamp_changed(SPFontSelector * fsel)
  85. +{
  86. + //Creamos una instancia de fonlister con overwrite a true, lo explico en otro lado
  87. + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(true);
  88. + //Generamos el nuevo tree model con las todas, incluidas las nuevas tipografias
  89. + fontlister->update_font_list( SP_ACTIVE_DESKTOP->getDocument());
  90. + Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
  91. + GtkListStore* model = store->gobj();
  92. + //actualizamos el model de la clase contenedora
  93. + gtk_tree_view_set_model(GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL(model));
  94. + gtk_tree_view_set_row_separator_func( GTK_TREE_VIEW(fsel->family_treeview),
  95. + GtkTreeViewRowSeparatorFunc ((gpointer)font_lister_separator_func),
  96. + NULL, NULL );
  97. + gtk_widget_show_all(GTK_WIDGET (fsel->family_treeview));
  98. + GtkTreeViewColumn *column = gtk_tree_view_column_new ();
  99. + GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
  100. + gtk_tree_view_column_pack_start (column, cell, FALSE);
  101. + gtk_tree_view_column_set_attributes (column, cell, "text", 0, NULL);
  102. + gtk_tree_view_column_set_cell_data_func (column, cell,
  103. + GtkTreeCellDataFunc (font_lister_cell_data_func),
  104. + NULL, NULL );
  105. + gtk_tree_view_append_column (GTK_TREE_VIEW(fsel->family_treeview), column);
  106. + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->family_treeview), FALSE);
  107. +}
  108. /*
  109. * Create a widget with children for selecting font-family, font-style, and font-size.
  110. @@ -174,6 +198,9 @@
  111. g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_family_select_row), fsel);
  112. g_object_set_data (G_OBJECT(fsel), "family-treeview", fsel->family_treeview);
  113. + //font update
  114. + GtkSettings *settings = gtk_widget_get_settings(fsel->family_treeview);
  115. + g_signal_connect_object (settings, "notify::gtk-fontconfig-timestamp", G_CALLBACK (sp_gtk_fontconfig_timestamp_changed), fsel, G_CONNECT_SWAPPED);
  116. /* Style frame */
  117. f = gtk_frame_new(C_("Font selector", "Style"));
  118. @@ -220,6 +247,7 @@
  119. selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview));
  120. g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel);
  121. +
  122. #if GTK_CHECK_VERSION(3,0,0)
  123. GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
  124. gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
  125. === modified file 'src/widgets/text-toolbar.cpp'
  126. --- src/widgets/text-toolbar.cpp 2015-04-29 20:51:23 +0000
  127. +++ src/widgets/text-toolbar.cpp 2015-11-08 11:02:20 +0000
  128. @@ -29,7 +29,6 @@
  129. #endif
  130. #include "libnrtype/font-lister.h"
  131. -#include <glibmm/i18n.h>
  132. #include "text-toolbar.h"
  133. #include "desktop-style.h"
  134. @@ -56,6 +55,7 @@
  135. #include "ui/tools/tool-base.h"
  136. #include "verbs.h"
  137. #include "xml/repr.h"
  138. +#include <glibmm/i18n.h>
  139. using Inkscape::DocumentUndo;
  140. using Inkscape::UI::ToolboxFactory;
  141. @@ -113,6 +113,25 @@
  142. }
  143. #endif
  144. +//Función de callback
  145. +//Refresca la lista de fuentes
  146. +static void sp_refresh_combobox(GtkSettings *settings, Ink_ComboBoxEntry_Action *act)
  147. +{
  148. + std::cout << "refresh\n";
  149. + //Conseguimos el widget del combo de fuentes
  150. + GtkComboBox *fontCombo = act->combobox;
  151. + //Creamos una instancia de fonlister con overwrite a true, lo explico en otro lado
  152. + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(true);
  153. + //Generamos el nuevo tree model con las todas, incluidas las nuevas tipografias
  154. + fontlister->update_font_list( SP_ACTIVE_DESKTOP->getDocument());
  155. + Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
  156. + GtkListStore* model = store->gobj();
  157. + //actualizamos el model de la clase contenedora
  158. + act->model = GTK_TREE_MODEL(model);
  159. + //actualizamos el combo con el nuevo modelo
  160. + gtk_combo_box_set_model(fontCombo, GTK_TREE_MODEL(model));
  161. + gtk_combo_box_set_active( fontCombo, fontlister->get_font_family_row());
  162. +}
  163. // Font family
  164. static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GObject *tbl )
  165. @@ -122,7 +141,6 @@
  166. std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
  167. std::cout << "sp_text_fontfamily_value_changed: " << std::endl;
  168. #endif
  169. -
  170. // quit if run by the _changed callbacks
  171. if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
  172. #ifdef DEBUG_TEXT
  173. @@ -1235,9 +1253,9 @@
  174. //ink_comboboxentry_action_set_warning_callback( act, sp_text_fontfamily_select_all );
  175. ink_comboboxentry_action_set_altx_name( act, "altx-text" ); // Set Alt-X keyboard shortcut
  176. g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontfamily_value_changed), holder );
  177. +
  178. gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
  179. - g_object_set_data( holder, "TextFontFamilyAction", act );
  180. -
  181. + g_object_set_data( holder, "TextFontFamilyAction", act );
  182. // Change style of drop-down from menu to list
  183. gtk_rc_parse_string (
  184. "style \"dropdown-as-list-style\"\n"
  185. @@ -1251,6 +1269,8 @@
  186. " GtkWidget::separator-height = 6\n"
  187. "}\n"
  188. "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\"");
  189. + GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(act->combobox));
  190. + g_signal_connect_object (settings, "notify::gtk-fontconfig-timestamp", G_CALLBACK (sp_refresh_combobox), act, G_CONNECT_SWAPPED);
  191. }
  192. /* Font size */
 
 

34

 

948

Pasted Text #1008

-

PasteBin

Lines
213
Words
903
Size
9.4 KB
Created
Type
text/plain
Public Domain (PD)
Please log in to leave a comment!