Code

abstract use of sodipodi:modified
[inkscape.git] / src / widgets / toolbox.cpp
index 85001866295994233b09c9fdf26607cda7b68afb..56f33bf9677660f79ab2e9b89d5c4a77f03a2aa1 100644 (file)
@@ -630,14 +630,9 @@ sp_aux_toolbox_new()
 {
     GtkWidget *tb = gtk_vbox_new(FALSE, 0);
 
-    GtkWidget *tb_s = gtk_vbox_new(FALSE, 0);
-    GtkWidget *tb_e = gtk_vbox_new(FALSE, 0);
     gtk_box_set_spacing(GTK_BOX(tb), AUX_SPACING);
-    gtk_box_pack_start(GTK_BOX(tb), GTK_WIDGET(tb_s), FALSE, FALSE, 0);
-    gtk_box_pack_end(GTK_BOX(tb), GTK_WIDGET(tb_e), FALSE, FALSE, 0);
 
     g_object_set_data(G_OBJECT(tb), "desktop", NULL);
-    g_object_set_data(G_OBJECT(tb), "top_spacer", tb_s);
 
     gtk_widget_set_sensitive(tb, FALSE);
 
@@ -667,11 +662,7 @@ sp_commands_toolbox_new()
 {
     GtkWidget *tb = gtk_vbox_new(FALSE, 0);
 
-    GtkWidget *tb_s = gtk_vbox_new(FALSE, 0);
-    GtkWidget *tb_e = gtk_vbox_new(FALSE, 0);
     gtk_box_set_spacing(GTK_BOX(tb), AUX_SPACING);
-    gtk_box_pack_start(GTK_BOX(tb), GTK_WIDGET(tb_s), FALSE, FALSE, 0);
-    gtk_box_pack_end(GTK_BOX(tb), GTK_WIDGET(tb_e), FALSE, FALSE, 0);
 
     g_object_set_data(G_OBJECT(tb), "desktop", NULL);
     gtk_widget_set_sensitive(tb, FALSE);
@@ -1439,10 +1430,6 @@ void show_aux_toolbox(GtkWidget *toolbox_toplevel)
     }
     gtk_widget_show(toolbox);
 
-    // need to show the spacer, or the padding will be off
-    GtkWidget *spacer = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbox), "top_spacer"));
-    gtk_widget_show(spacer);
-
     gtk_widget_show_all(shown_toolbox);
 }
 
@@ -4181,9 +4168,21 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
     int result_fontspec =
         sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
     
+    font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+    
     SPCSSAttr *css = sp_repr_css_attr_new ();
     
-    std::string fontSpec = query->text->font_specification.value;
+    
+    // First try to get the font spec from the stored value
+    Glib::ustring fontSpec = query->text->font_specification.set ?  query->text->font_specification.value : "";
+    
+    if (fontSpec.empty()) {
+        // Construct a new font specification if it does not yet exist
+        font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+        fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+        fontFromStyle->Unref();
+    }
+    
     if (!fontSpec.empty()) {
         Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
         if (!newFontSpec.empty() && fontSpec != newFontSpec) {
@@ -4334,12 +4333,29 @@ sp_text_toolbox_style_toggled (GtkToggleButton  *button,
 
     SPStyle *query =
         sp_style_new (SP_ACTIVE_DOCUMENT);
+    
     int result_fontspec =
         sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
-    
-    Glib::ustring fontSpec = query->text->font_specification.value;
-    Glib::ustring newFontSpec;
 
+    int result_family =
+        sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+
+    int result_style =
+        sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+
+    int result_numbers =
+        sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+    
+    Glib::ustring fontSpec = query->text->font_specification.set ?  query->text->font_specification.value : "";
+    Glib::ustring newFontSpec = "";
+    
+    if (fontSpec.empty()) {
+        // Construct a new font specification if it does not yet exist
+        font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+        fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+        fontFromStyle->Unref();
+    }
+    
     switch (prop)
     {
         case 0:
@@ -4348,6 +4364,7 @@ sp_text_toolbox_style_toggled (GtkToggleButton  *button,
                 newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active);
             }
             if (fontSpec != newFontSpec) {
+                // Don't even set the bold if the font didn't exist on the system
                 sp_repr_css_set_property (css, "font-weight", active ? "bold" : "normal" );
             }
             break;
@@ -4359,14 +4376,15 @@ sp_text_toolbox_style_toggled (GtkToggleButton  *button,
                 newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active);
             }
             if (fontSpec != newFontSpec) {
+                // Don't even set the italic if the font didn't exist on the system
                 sp_repr_css_set_property (css, "font-style", active ? "italic" : "normal");
             }
             break;
         }
     }
 
-    if (!fontSpec.empty()) {
-        sp_repr_css_set_property (css, "-inkscape-font-specification", fontSpec.c_str()); 
+    if (!newFontSpec.empty()) {
+        sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str()); 
     }
 
     // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
@@ -5286,3 +5304,4 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
 
 
 
+