summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-10-27 23:38:54 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-10-27 23:38:54 +0000
commita8663be9f9ba3e0b3f3d777b024fa60405ba6464 (patch)
treef2fea260b6e3ca36ba42743f7a47a84530281a57 /src
parentFix simbols dialog expand, Fix add symbols to document on global search (diff)
parentProtect against missing "id". (diff)
downloadinkscape-a8663be9f9ba3e0b3f3d777b024fa60405ba6464.tar.gz
inkscape-a8663be9f9ba3e0b3f3d777b024fa60405ba6464.zip
Merge branch 'master' into SymbolsSearch
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp7
-rw-r--r--src/libnrtype/FontFactory.cpp34
-rw-r--r--src/libnrtype/FontFactory.h3
-rw-r--r--src/preferences.cpp6
-rw-r--r--src/sp-style-elem.cpp54
-rw-r--r--src/ui/dialog/prototype.cpp2
-rw-r--r--src/widgets/spw-utilities.cpp113
-rw-r--r--src/widgets/spw-utilities.h16
8 files changed, 104 insertions, 131 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index c56c42267..2d1aa8829 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1935,11 +1935,18 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ("Symbols", "/dialogs/symbols") );
mapVerbPreference.insert(std::make_pair ("ObjectsPanel", "/dialogs/objects") );
mapVerbPreference.insert(std::make_pair ("TagsPanel", "/dialogs/tags") );
+ mapVerbPreference.insert(std::make_pair ("Prototype", "/dialogs/prototype") );
+
for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); ++iter) {
Glib::ustring pref = iter->second;
int visible = prefs->getInt(pref + "/visible", 0);
if (visible) {
+
+ // Try to ensure that the panel is created attached to the correct desktop (bug 1720096).
+ // There must be a better way of handling this problem!
+ INKSCAPE.activate_desktop(this);
+
_dlg_mgr->showDialog(iter->first.c_str(), false); // without grabbing focus, we need focus to remain on the canvas
}
}
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 95537734d..9c62e5483 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -936,7 +936,7 @@ void font_factory::AddFontsDir(char const *utf8dir)
FcConfig *conf = NULL;
# if PANGO_VERSION_CHECK(1,38,0)
- pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
+ conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
# endif
FcBool res = FcConfigAppFontAddDir(conf, (FcChar8 const *)dir);
if (res = FcTrue) {
@@ -949,6 +949,38 @@ void font_factory::AddFontsDir(char const *utf8dir)
#endif
}
+void font_factory::AddFontFile(char const *utf8file)
+{
+#ifdef USE_PANGO_WIN32
+ g_info("Adding additional font only supported for fontconfig backend.");
+#else
+ if (!Inkscape::IO::file_test(utf8file, G_FILE_TEST_IS_REGULAR)) {
+ g_warning("Font file '%s' does not exist and will be ignored.", utf8file);
+ return;
+ }
+
+ gchar *file;
+# ifdef WIN32
+ file = g_win32_locale_filename_from_utf8(utf8file);
+# else
+ file = g_filename_from_utf8(utf8file, -1, NULL, NULL, NULL);
+# endif
+
+ FcConfig *conf = NULL;
+# if PANGO_VERSION_CHECK(1,38,0)
+ conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
+# endif
+ FcBool res = FcConfigAppFontAddFile(conf, (FcChar8 const *)file);
+ if (res = FcTrue) {
+ g_info("Font file '%s' added successfully.", utf8file);
+ } else {
+ g_warning("Could not add font file '%s'.", utf8file);
+ }
+
+ g_free(file);
+#endif
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h
index c273be2f4..12260f99a 100644
--- a/src/libnrtype/FontFactory.h
+++ b/src/libnrtype/FontFactory.h
@@ -139,6 +139,9 @@ public:
/// Add a directory from which to include additional fonts
void AddFontsDir(char const *utf8dir);
+ /// Add a an additional font.
+ void AddFontFile(char const *utf8file);
+
private:
void* loadedPtr;
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 7ebf55a79..b02e71e46 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -393,6 +393,9 @@ std::vector<Glib::ustring> Preferences::getAllDirs(Glib::ustring const &path)
Inkscape::XML::Node *node = _getNode(path, false);
if (node) {
for (Inkscape::XML::NodeSiblingIterator i = node->firstChild(); i; ++i) {
+ if (i->attribute("id") == NULL) {
+ continue;
+ }
temp.push_back(path + '/' + i->attribute("id"));
}
}
@@ -702,6 +705,9 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
}
for (child = node->firstChild(); child; child = child->next()) {
+ if (child->attribute("id") == NULL) {
+ continue;
+ }
if (!strcmp(splits[part_i], child->attribute("id"))) {
break;
}
diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp
index 2deaccad0..da02d4ef1 100644
--- a/src/sp-style-elem.cpp
+++ b/src/sp-style-elem.cpp
@@ -12,6 +12,9 @@
#include <iostream>
#include <fstream>
+// For font-rule
+#include "libnrtype/FontFactory.h"
+
using Inkscape::XML::TEXT_NODE;
SPStyleElem::SPStyleElem() : SPObject() {
@@ -308,12 +311,61 @@ end_font_face_cb(CRDocHandler *a_handler)
unsigned(font_face_rule->type));
}
- std::cout << "end_font_face_cb: font face rule unsupported." << std::endl;
+ std::cout << "end_font_face_cb: font face rule limited support." << std::endl;
cr_declaration_dump (font_face_rule->kind.font_face_rule->decl_list, stdout, 2, TRUE);
printf ("\n");
+ // Get document
+ SPDocument* document = parse_tmp.document;
+ if (!document) {
+ std::cerr << "end_font_face_cb: No document!" << std::endl;
+ return;
+ }
+ if (!document->getURI()) {
+ std::cerr << "end_font_face_cb: Document URI is NULL" << std::endl;
+ return;
+ }
+
+ // Add ttf or otf fonts.
+ CRDeclaration const *cur = NULL;
+ for (cur = font_face_rule->kind.font_face_rule->decl_list; cur; cur = cur->next) {
+ if (cur->property &&
+ cur->property->stryng &&
+ cur->property->stryng->str &&
+ strcmp(cur->property->stryng->str, "src") == 0 ) {
+
+ if (cur->value &&
+ cur->value->content.str &&
+ cur->value->content.str->stryng &&
+ cur->value->content.str->stryng->str) {
+
+ Glib::ustring value = cur->value->content.str->stryng->str;
+ std::size_t found = value.find_last_of("ttf");
+
+ if (value.rfind("ttf") == (value.length() - 3) ||
+ value.rfind("otf") == (value.length() - 3)) {
+
+ // Get file
+ Glib::ustring ttf_file =
+ Inkscape::IO::Resource::get_filename (document->getURI(), value);
+
+ if (!ttf_file.empty()) {
+ font_factory *factory = font_factory::Default();
+ factory->AddFontFile( ttf_file.c_str() );
+ std::cout << "end_font_face_cb: Added font: " << ttf_file << std::endl;
+
+ // FIX ME: Need to refresh font list.
+ } else {
+ std::cout << "end_font_face_cb: Failed to add: " << value << std::endl;
+ }
+ }
+ }
+ }
+ }
+
parse_tmp.currStmt = NULL;
parse_tmp.stmtType = NO_STMT;
+
}
static void
diff --git a/src/ui/dialog/prototype.cpp b/src/ui/dialog/prototype.cpp
index b3bf60aab..b7c9f7abf 100644
--- a/src/ui/dialog/prototype.cpp
+++ b/src/ui/dialog/prototype.cpp
@@ -22,6 +22,8 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
+// Note that in order for a dialog to be restored, it must be listed in SPDesktop::show_dialogs().
+
Prototype::Prototype() :
// UI::Widget::Panel("Prototype Label", "/dialogs/prototype", SP_VERB_DIALOG_PROTOTYPE,
// "Prototype Apply Label", true),
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 29e86b885..992f1f6b7 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -61,31 +61,6 @@ Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int r
return label_widget;
}
-GtkWidget *
-spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
-{
- GtkWidget *label_widget;
-
- label_widget = gtk_label_new (label_text);
- g_assert(label_widget != NULL);
- gtk_widget_set_halign(label_widget, GTK_ALIGN_END);
- gtk_widget_show (label_widget);
-
-#if GTK_CHECK_VERSION(3,12,0)
- gtk_widget_set_margin_start(label_widget, 4);
- gtk_widget_set_margin_end(label_widget, 4);
-#else
- gtk_widget_set_margin_left(label_widget, 4);
- gtk_widget_set_margin_right(label_widget, 4);
-#endif
- gtk_widget_set_hexpand(label_widget, TRUE);
- gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL);
- gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1);
-
- return label_widget;
-}
-
/**
* Creates a horizontal layout manager with 4-pixel spacing between children
* and space for 'width' columns.
@@ -104,94 +79,6 @@ Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row)
return hb;
}
-/**
- * Creates a checkbutton widget and adds it to a vbox.
- * This is a compound widget that includes a label.
- */
-GtkWidget *spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *vbox,
- const gchar *label, const gchar *tip, gchar *key, GCallback cb)
-{
- g_assert (dialog != NULL);
- g_assert (vbox != NULL);
-
- GtkWidget *b = gtk_check_button_new_with_label (label);
- gtk_widget_set_tooltip_text(b, tip);
- g_assert (b != NULL);
- gtk_widget_show (b);
- gtk_box_pack_start (GTK_BOX (vbox), b, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (b), "key", key);
- g_object_set_data (G_OBJECT (dialog), key, b);
- g_signal_connect (G_OBJECT (b), "toggled", cb, dialog);
- return b;
-}
-
-
-/**
- * Creates a checkbutton widget and adds it to a table.
- * This is a compound widget that includes a label.
- */
-GtkWidget *
-spw_checkbutton(GtkWidget * dialog, GtkWidget * table,
- const gchar * label, gchar * key, int /*col*/, int row,
- int insensitive, GCallback cb)
-{
- GtkWidget *b;
-
- g_assert(dialog != NULL);
- g_assert(table != NULL);
-
- GtkWidget *l = gtk_label_new (label);
- gtk_widget_set_halign(l, GTK_ALIGN_END);
- gtk_widget_show (l);
-
- gtk_widget_set_halign(l, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(l, TRUE);
- gtk_widget_set_valign(l, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1);
-
- b = gtk_check_button_new ();
- gtk_widget_show (b);
-
- gtk_widget_set_halign(b, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(b, TRUE);
- gtk_widget_set_valign(b, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1);
-
- g_object_set_data (G_OBJECT (b), "key", key);
- g_object_set_data (G_OBJECT (dialog), key, b);
- g_signal_connect (G_OBJECT (b), "toggled", cb, dialog);
- if (insensitive == 1) {
- gtk_widget_set_sensitive (b, FALSE);
- }
- return b;
-}
-
-/**
- * Creates a dropdown widget. This is a compound widget that includes
- * a label as well as the dropdown.
- */
-GtkWidget *
-spw_dropdown(GtkWidget * dialog, GtkWidget * table,
- const gchar * label_text, gchar * key, int row,
- GtkWidget * selector
- )
-{
- g_assert(dialog != NULL);
- g_assert(table != NULL);
- g_assert(selector != NULL);
-
- spw_label_old(table, label_text, 0, row);
-
- gtk_widget_show (selector);
- gtk_widget_set_halign(selector, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(selector, TRUE);
- gtk_widget_set_valign(selector, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1);
-
- g_object_set_data (G_OBJECT (dialog), key, selector);
- return selector;
-}
-
static void
sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index 71b451631..ea0d55279 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -27,22 +27,6 @@ namespace Gtk {
Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row);
-GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row);
-
-GtkWidget *
-spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *table,
- const gchar *label, const gchar *tip, gchar *key, GCallback cb);
-
-GtkWidget *
-spw_checkbutton(GtkWidget *dialog, GtkWidget *table,
- gchar const *label, gchar *key, int col, int row,
- int sensitive, GCallback cb);
-
-GtkWidget *
-spw_dropdown(GtkWidget *dialog, GtkWidget *table,
- gchar const *label, gchar *key, int row,
- GtkWidget *selector
- );
void sp_set_font_size (GtkWidget *w, guint font);
void sp_set_font_size_smaller (GtkWidget *w);