summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-03-05 21:59:02 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-03-05 21:59:02 +0000
commit58d7a0e0ef39488839985440c6f87a78d112e15f (patch)
treebb4b02b5a787701ee489b2748450ed594548c584 /src
parentBPower for testing. (diff)
parentAdded null check (should fix Bug #1051017 ) (diff)
downloadinkscape-58d7a0e0ef39488839985440c6f87a78d112e15f.tar.gz
inkscape-58d7a0e0ef39488839985440c6f87a78d112e15f.zip
merge from trunk
(bzr r11950.1.46)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/desktop.h10
-rw-r--r--src/file.cpp4
-rw-r--r--src/interface.cpp18
-rw-r--r--src/libnrtype/font-lister.cpp120
-rw-r--r--src/menus-skeleton.h5
-rw-r--r--src/verbs.cpp15
-rw-r--r--src/verbs.h3
-rw-r--r--src/widgets/desktop-widget.cpp5
9 files changed, 88 insertions, 97 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a4e2960c..7d8a9ef50 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,9 +44,6 @@ all_libs = \
$(kdeldadd) \
$(win32ldflags) \
$(CARBON_LDFLAGS) \
- $(PERL_LIBS) \
- $(PYTHON_LIBS) \
- $(INKBOARD_LIBS) \
$(LIBWPG_LIBS) \
$(LIBVISIO_LIBS) \
$(LIBCDR_LIBS) \
@@ -66,13 +63,11 @@ BUILT_SOURCES =
EXTRA_DIST =
AM_CPPFLAGS = \
- $(PERL_CFLAGS) $(PYTHON_CFLAGS) \
$(EXIF_CFLAGS) \
$(FREETYPE_CFLAGS) \
$(GNOME_PRINT_CFLAGS) \
$(GNOME_VFS_CFLAGS) \
$(IMAGEMAGICK_CFLAGS) \
- $(INKBOARD_CFLAGS) \
$(LIBWPG_CFLAGS) \
$(LIBVISIO_CFLAGS) \
$(LIBCDR_CFLAGS) \
diff --git a/src/desktop.h b/src/desktop.h
index 93cf3201c..27176868f 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -214,16 +214,6 @@ public:
return _layer_changed_signal.connect(slot);
}
- // Whiteboard changes
-
-#ifdef WITH_INKBOARD
- Inkscape::Whiteboard::SessionManager* whiteboard_session_manager() {
- return _whiteboard_session_manager;
- }
-
- Inkscape::Whiteboard::SessionManager* _whiteboard_session_manager;
-#endif
-
/**
* Return new desktop object.
* \pre namedview != NULL.
diff --git a/src/file.cpp b/src/file.cpp
index 468d02eba..97087c1a1 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -81,10 +81,6 @@ using Inkscape::DocumentUndo;
#include "extension/dbus/dbus-init.h"
#endif
-//#ifdef WITH_INKBOARD
-//#include "jabber_whiteboard/session-manager.h"
-//#endif
-
#ifdef WIN32
#include <windows.h>
#endif
diff --git a/src/interface.cpp b/src/interface.cpp
index 284368bff..bf497b407 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -1539,14 +1539,16 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name)
//- a GtkHBox, whose first child is a label displaying name if the menu
//item has an accel key
//- a GtkLabel if the menu has no accel key
- if (GTK_IS_LABEL(child)) {
- gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str());
- } else if (GTK_IS_HBOX(child)) {
- gtk_label_set_markup_with_mnemonic(
- GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data),
- name.c_str());
- }//else sp_ui_menu_append_item_from_verb has been modified and can set
- //a menu item in yet another way...
+ if (child != NULL){
+ if (GTK_IS_LABEL(child)) {
+ gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str());
+ } else if (GTK_IS_HBOX(child)) {
+ gtk_label_set_markup_with_mnemonic(
+ GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data),
+ name.c_str());
+ }//else sp_ui_menu_append_item_from_verb has been modified and can set
+ //a menu item in yet another way...
+ }
}
}
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 97d3c66d4..1e3ba01e9 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -449,35 +449,7 @@ namespace Inkscape
// Find best match to the style from the old font-family to the
// styles available with the new font.
// TODO: Maybe check if an exact match exists before using Pango.
- Glib::ustring best_style = current_style;
- if( check_style ) {
- //std::cout << " Trying to match: " << current_fontspec << std::endl;
- PangoFontDescription *desc_old
- = pango_font_description_from_string( current_fontspec.c_str() );
- PangoFontDescription* desc_best = NULL;
-
- for (GList *l=styles; l; l = l->next) {
- Glib::ustring candidate = new_family + ", " + (char*)l->data;
- PangoFontDescription* desc_candidate
- = pango_font_description_from_string( candidate.c_str() );
- //std::cout << " Testing: " << pango_font_description_to_string( desc_candidate ) << std::endl;
- if( pango_font_description_better_match( desc_old, desc_best, desc_candidate ) ) {
- pango_font_description_free( desc_best );
- desc_best = desc_candidate;
- //std::cout << " ... better: " << std::endl;
- } else {
- pango_font_description_free( desc_candidate );
- //std::cout << " ... not better: " << std::endl;
- }
- }
- if( desc_best ) {
- pango_font_description_unset_fields( desc_best, PANGO_FONT_MASK_FAMILY );
- best_style = pango_font_description_to_string( desc_best );
- }
-
- if( desc_old ) pango_font_description_free( desc_old );
- if( desc_best ) pango_font_description_free( desc_best );
- }
+ Glib::ustring best_style = get_best_style_match( new_family, current_style );
#ifdef DEBUG_FONT
std::cout << "FontLister::new_font_family: exit: " << new_family << " " << best_style << std::endl;
@@ -863,6 +835,64 @@ namespace Inkscape
throw STYLE_NOT_FOUND;
}
+ static gint
+ compute_distance (const PangoFontDescription *a,
+ const PangoFontDescription *b ) {
+
+ // Weight: multiples of 100
+ gint distance = abs( pango_font_description_get_weight( a ) -
+ pango_font_description_get_weight( b ) );
+
+ distance += 10000 * abs( pango_font_description_get_stretch( a ) -
+ pango_font_description_get_stretch( b ) );
+
+ PangoStyle style_a = pango_font_description_get_style( a );
+ PangoStyle style_b = pango_font_description_get_style( b );
+ if( style_a != style_b ) {
+ if( (style_a == PANGO_STYLE_OBLIQUE && style_b == PANGO_STYLE_ITALIC) ||
+ (style_b == PANGO_STYLE_OBLIQUE && style_a == PANGO_STYLE_ITALIC) ) {
+ distance += 1000; // Oblique and italic are almost the same
+ } else {
+ distance += 100000; // Normal vs oblique/italic, not so similar
+ }
+ }
+
+ // Normal vs small-caps
+ distance += 1000000 * abs( pango_font_description_get_variant( a ) -
+ pango_font_description_get_variant( b ) );
+ return distance;
+ }
+
+ // This is inspired by pango_font_description_better_match, but that routine
+ // always returns false if variant or stretch are different. This means, for
+ // example, that PT Sans Narrow with style Bold Condensed is never matched
+ // to another font-family with Bold style.
+ gboolean
+ font_description_better_match( PangoFontDescription* target,
+ PangoFontDescription* old_desc,
+ PangoFontDescription* new_desc ) {
+
+ if( old_desc == NULL ) return true;
+ if( new_desc == NULL ) return false;
+
+ int old_distance = compute_distance( target, old_desc );
+ int new_distance = compute_distance( target, new_desc );
+ //std::cout << "font_description_better_match: old: " << old_distance << std::endl;
+ //std::cout << " new: " << new_distance << std::endl;
+
+ return (new_distance < old_distance );
+ }
+
+ // void
+ // font_description_dump( PangoFontDescription* target ) {
+ // std::cout << " Font: " << pango_font_description_to_string( target ) << std::endl;
+ // std::cout << " style: " << pango_font_description_get_style( target ) << std::endl;
+ // std::cout << " weight: " << pango_font_description_get_weight( target ) << std::endl;
+ // std::cout << " variant: " << pango_font_description_get_variant( target ) << std::endl;
+ // std::cout << " stretch: " << pango_font_description_get_stretch( target ) << std::endl;
+ // std::cout << " gravity: " << pango_font_description_get_gravity( target ) << std::endl;
+ // }
+
/* Returns style string */
// TODO: Remove or turn into function to be used by new_font_family.
Glib::ustring
@@ -873,7 +903,7 @@ namespace Inkscape
std::cout << "FontLister::get_best_style_match: " << family << " : " << target_style << std::endl;
#endif
- Glib::ustring font_string = family + " " + target_style;
+ Glib::ustring fontspec = family + ", " + target_style;
Gtk::TreeModel::Row row;
try {
@@ -883,31 +913,37 @@ namespace Inkscape
return (target_style);
}
- PangoFontDescription* target = pango_font_description_from_string( font_string.c_str() );
+ PangoFontDescription* target = pango_font_description_from_string( fontspec.c_str() );
PangoFontDescription* best = NULL;
- //std::cout << " Target: " << pango_font_description_to_string( target ) << std::endl;
+ //font_description_dump( target );
GList* styles = row[FontList.styles];
for (GList *l=styles; l; l = l->next) {
- Glib::ustring font_string_test = family + " " + (char*)l->data;
- PangoFontDescription* candidate = pango_font_description_from_string( font_string_test.c_str() );
- // std::cout << " Testing: " << pango_font_description_to_string( candidate ) << std::endl;
- if( pango_font_description_better_match( target, best, candidate ) ) {
- best = candidate;
+ Glib::ustring fontspec = family + ", " + (char*)l->data;
+ PangoFontDescription* candidate = pango_font_description_from_string( fontspec.c_str() );
+ //font_description_dump( candidate );
+ //std::cout << " " << font_description_better_match( target, best, candidate ) << std::endl;
+ if( font_description_better_match( target, best, candidate ) ) {
+ pango_font_description_free( best );
+ best = candidate;
+ //std::cout << " ... better: " << std::endl;
+ } else {
+ pango_font_description_free( candidate );
+ //std::cout << " ... not better: " << std::endl;
}
}
- Glib::ustring best_style;
+ Glib::ustring best_style = target_style;
if( best ) {
- //std::cout << " Best: " << pango_font_description_to_string( best ) << std::endl;
pango_font_description_unset_fields( best, PANGO_FONT_MASK_FAMILY );
best_style = pango_font_description_to_string( best );
- } else {
- //std::cout << " Failed: " << family << std::endl;
- best_style = target_style;
}
+ if( target ) pango_font_description_free( target );
+ if( best ) pango_font_description_free( best );
+
+
#ifdef DEBUG_FONT
std::cout << " Returning: " << best_style << std::endl;
std::cout << "FontLister::get_best_style_match: exit" << std::endl;
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index fa39dbd3a..868b606a4 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -282,11 +282,6 @@ static char const menus_skeleton[] =
" <separator/>\n"
" <effects-list/>\n"
" </submenu>\n"
-#ifdef WITH_INKBOARD
-" <submenu name=\"" N_("Whiteboa_rd") "\">\n"
-" <verb verb-id=\"DialogXmppClient\" />\n"
-" </submenu>\n"
-#endif
" <submenu name=\"" N_("_Help") "\">\n"
" <verb verb-id=\"org.inkscape.help.manual\" />\n"
" <verb verb-id=\"org.inkscape.help.keys\" />\n"
diff --git a/src/verbs.cpp b/src/verbs.cpp
index bbadb1a25..cdeeab99a 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -89,10 +89,6 @@
using Inkscape::DocumentUndo;
using Inkscape::UI::Dialog::ActionAlign;
-//#ifdef WITH_INKBOARD
-//#include "jabber_whiteboard/session-manager.h"
-//#endif
-
/**
* Return the name without underscores and ellipsis, for use in dialog
* titles, etc. Allocated memory must be freed by caller.
@@ -1972,13 +1968,6 @@ void DialogVerb::perform(SPAction *action, void *data)
//sp_item_dialog();
dt->_dlg_mgr->showDialog("ObjectProperties");
break;
-/*#ifdef WITH_INKBOARD
- case SP_VERB_XMPP_CLIENT:
- {
- Inkscape::Whiteboard::SessionManager::showClient();
- break;
- }
-#endif*/
case SP_VERB_DIALOG_INPUT:
dt->_dlg_mgr->showDialog("InputDevices");
break;
@@ -2796,10 +2785,6 @@ Verb *Verb::_base_verbs[] = {
N_("Edit the object attributes..."), INKSCAPE_ICON("dialog-object-attributes")),
new DialogVerb(SP_VERB_DIALOG_ITEM, "DialogObjectProperties", N_("_Object Properties..."),
N_("Edit the ID, locked and visible status, and other object properties"), INKSCAPE_ICON("dialog-object-properties")),
-/*#ifdef WITH_INKBOARD
- new DialogVerb(SP_VERB_XMPP_CLIENT, "DialogXmppClient",
- N_("_Instant Messaging..."), N_("Jabber Instant Messaging Client"), NULL),
-#endif*/
new DialogVerb(SP_VERB_DIALOG_INPUT, "DialogInput", N_("_Input Devices..."),
N_("Configure extended input devices, such as a graphics tablet"), INKSCAPE_ICON("dialog-input-devices")),
new DialogVerb(SP_VERB_DIALOG_EXTENSIONEDITOR, "org.inkscape.dialogs.extensioneditor", N_("_Extensions..."),
diff --git a/src/verbs.h b/src/verbs.h
index c4a7b67e0..dab524d7a 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -282,9 +282,6 @@ enum {
SP_VERB_DIALOG_CLONETILER,
SP_VERB_DIALOG_ATTR,
SP_VERB_DIALOG_ITEM,
-/*#ifdef WITH_INKBOARD
- SP_VERB_XMPP_CLIENT,
-#endif*/
SP_VERB_DIALOG_INPUT,
SP_VERB_DIALOG_EXTENSIONEDITOR,
SP_VERB_DIALOG_LAYERS,
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 2a816adf4..b0d8d974e 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -82,11 +82,6 @@ using Inkscape::UI::UXManager;
using Inkscape::UI::ToolboxFactory;
using ege::AppearTimeTracker;
-#ifdef WITH_INKBOARD
-#endif
-
-
-
enum {
ACTIVATE,
DEACTIVATE,