Code

add an option for displaying font previews in the text tool's font list; also limit...
authorbuliabyak <>
Tue, 1 Dec 2009 17:49:17 +0000 (13:49 -0400)
committerbuliabyak <>
Tue, 1 Dec 2009 17:49:17 +0000 (13:49 -0400)
1  2 
src/preferences-skeleton.h
src/ui/dialog/inkscape-preferences.cpp
src/widgets/toolbox.cpp

index 80a1bd5eaad1d51ac6e07abe327bcf791885fe09,80a1bd5eaad1d51ac6e07abe327bcf791885fe09..70d1140bab4f9dbc069b76d19fc38fd84dead008
@@@ -111,6 -111,6 +111,7 @@@ static char const preferences_skeleton[
  "    </eventcontext>\n"
  "    <eventcontext id=\"text\"  usecurrent=\"0\" gradientdrag=\"1\"\n"
  "                       font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
++"                       show_sample_in_list=\"1\"\n"
  "                  style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
  "    <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" highlight_color=\"4278190335\" pathflash_enabled=\"1\" pathflash_unselected=\"0\" pathflash_timeout=\"500\" show_handles=\"1\" show_helperpath=\"0\" sculpting_profile=\"1\" />\n"
  "    <eventcontext id=\"tweak\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
index 6e30ef61a39623d53cf5e8f37e3e71d26fe4a3ad,6e30ef61a39623d53cf5e8f37e3e71d26fe4a3ad..b217f8695ce37eeea8e168f6ce4b070baf41273a
@@@ -476,15 -476,15 +476,15 @@@ void InkscapePreferences::initPageTools
      this->AddNewObjectsStyle(_page_3dbox, "/tools/shapes/3dbox");
      this->AddConvertGuidesCheckbox(_page_3dbox, "/tools/shapes/3dbox", true);
  
--    //ellipse
++    //Ellipse
      this->AddPage(_page_ellipse, _("Ellipse"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
      this->AddNewObjectsStyle(_page_ellipse, "/tools/shapes/arc");
  
--    //star
++    //Star
      this->AddPage(_page_star, _("Star"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_STAR);
      this->AddNewObjectsStyle(_page_star, "/tools/shapes/star");
  
--    //spiral
++    //Spiral
      this->AddPage(_page_spiral, _("Spiral"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
      this->AddNewObjectsStyle(_page_spiral, "/tools/shapes/spiral");
  
      this->AddPage(_page_text, _("Text"), iter_tools, PREFS_PAGE_TOOLS_TEXT);
      this->AddSelcueCheckbox(_page_text, "/tools/text", true);
      this->AddGradientCheckbox(_page_text, "/tools/text", true);
++    {
++    PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
++    cb->init ( _("Show font samples in the drop-down list"), "/tools/text/show_sample_in_list", 1);
++    _page_text.add_line( false, "", *cb, "", _("Show font samples alongside font names in the drop-down list in Text bar"));
++    }
      this->AddNewObjectsStyle(_page_text, "/tools/text");
  
      //Gradient
index 41a70f08aad6e01eae5964bd666b83bb5dde406e,41a70f08aad6e01eae5964bd666b83bb5dde406e..5f163d138ce7133253130e0b275ca51108ab3b4e
@@@ -6733,17 -6733,17 +6733,25 @@@ cell_data_func  (GtkCellLayout */*cell_
      gtk_tree_model_get(tree_model, iter, 0, &family, -1);
      gchar *const family_escaped = g_markup_escape_text(family, -1);
  
--    static char const *const sample = _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()");
--    gchar *const sample_escaped = g_markup_escape_text(sample, -1);
++    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
++    int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1);
++    if (show_sample) {
++
++        Glib::ustring sample = prefs->getString("/tools/text/font_sample");
++        gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1);
  
      std::stringstream markup;
      markup << family_escaped << "  <span foreground='darkgray' font_family='"
             << family_escaped << "'>" << sample_escaped << "</span>";
      g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL);
  
++        g_free(sample_escaped);
++    } else {
++        g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL);
++    }
++
      g_free(family);
      g_free(family_escaped);
--    g_free(sample_escaped);
  }
  
  gboolean            text_toolbox_completion_match_selected    (GtkEntryCompletion *widget,
@@@ -6873,7 -6873,7 +6881,7 @@@ sp_text_toolbox_new (SPDesktop *desktop
      // expand the field a bit so as to view more of the previews in the drop-down
      GtkRequisition req;
      gtk_widget_size_request (GTK_WIDGET (font_sel->gobj()), &req);
--    gtk_widget_set_size_request  (GTK_WIDGET (font_sel->gobj()), req.width + 40, -1);
++    gtk_widget_set_size_request  (GTK_WIDGET (font_sel->gobj()), MIN(req.width + 50, 500), -1);
  
      GtkWidget* entry = (GtkWidget*) font_sel->get_entry()->gobj();
      g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (sp_text_toolbox_family_changed), tbl);