From 1615436543169f305d1df4d830ed8f5ec5dc75ed Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 19:33:04 +0000 Subject: More GObject boilerplate reduction (bzr r12065) --- src/widgets/button.cpp | 45 +++++++++++++++------------------------------ src/widgets/icon.cpp | 44 ++++++++++---------------------------------- src/widgets/icon.h | 6 +++--- 3 files changed, 28 insertions(+), 67 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index d7be6c9f0..467f0d70e 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,8 +25,6 @@ #include "button.h" -static void sp_button_class_init (SPButtonClass *klass); -static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); #if GTK_CHECK_VERSION(3,0,0) @@ -50,28 +48,7 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action static void sp_button_action_set_active (SPButton *button, bool active); static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); -static GtkToggleButtonClass *parent_class; - -GType sp_button_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPButtonClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_button_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPButton), - 0, // n_preallocs - (GInstanceInitFunc)sp_button_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TOGGLE_BUTTON, "SPButton", &info, static_cast(0)); - } - return type; -} +G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); static void sp_button_class_init (SPButtonClass *klass) @@ -80,8 +57,6 @@ sp_button_class_init (SPButtonClass *klass) GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - parent_class = GTK_TOGGLE_BUTTON_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_button_get_preferred_width; @@ -120,10 +95,10 @@ static void sp_button_dispose(GObject *object) sp_button_set_doubleclick_action (button, NULL); } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } @@ -185,7 +160,7 @@ sp_button_clicked (GtkButton *button) SPButton *sp_button=SP_BUTTON (button); if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(parent_class))->clicked (button); + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); } } @@ -340,3 +315,13 @@ sp_button_new_from_data( Inkscape::IconSize size, return button; } +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7866989b1..8470e93db 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -41,9 +41,6 @@ #include "icon.h" struct IconImpl { - static void classInit(SPIconClass *klass); - static void init(SPIcon *icon); - static GtkWidget *newFull( Inkscape::IconSize lsize, gchar const *name ); static void dispose(GObject *object); @@ -104,12 +101,10 @@ struct IconImpl { private: static const std::string magicNumber; - static GtkWidgetClass *parent_class; static std::map legacyNames; }; const std::string IconImpl::magicNumber = "1.0"; -GtkWidgetClass *IconImpl::parent_class = 0; std::map IconImpl::legacyNames; @@ -141,34 +136,14 @@ public: static std::map > iconSetCache; static std::set internalNames; -GType SPIcon::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPIconClass), - NULL, - NULL, - reinterpret_cast(IconImpl::classInit), - NULL, - NULL, - sizeof(SPIcon), - 0, - reinterpret_cast(IconImpl::init), - NULL - }; - type = g_type_register_static(GTK_TYPE_WIDGET, "SPIcon", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPIcon, sp_icon, GTK_TYPE_WIDGET); -void IconImpl::classInit(SPIconClass *klass) +static void +sp_icon_class_init(SPIconClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = IconImpl::dispose; #if GTK_CHECK_VERSION(3,0,0) @@ -184,7 +159,8 @@ void IconImpl::classInit(SPIconClass *klass) widget_class->style_set = IconImpl::styleSet; } -void IconImpl::init(SPIcon *icon) +static void +sp_icon_init(SPIcon *icon) { gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE); icon->lsize = Inkscape::ICON_SIZE_BUTTON; @@ -202,7 +178,7 @@ void IconImpl::dispose(GObject *object) icon->name = 0; } - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_icon_parent_class))->dispose(object); } void IconImpl::reset( SPIcon *icon ) @@ -375,8 +351,8 @@ GdkPixbuf* IconImpl::renderup( gchar const* name, Inkscape::IconSize lsize, unsi void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) { - if ( GTK_WIDGET_CLASS( parent_class )->screen_changed ) { - GTK_WIDGET_CLASS( parent_class )->screen_changed( widget, previous_screen ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed( widget, previous_screen ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); @@ -384,8 +360,8 @@ void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) void IconImpl::styleSet( GtkWidget *widget, GtkStyle *previous_style ) { - if ( GTK_WIDGET_CLASS( parent_class )->style_set ) { - GTK_WIDGET_CLASS( parent_class )->style_set( widget, previous_style ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set( widget, previous_style ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 3f6aa2455..6bce2e330 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -17,7 +17,7 @@ #include #include "icon-size.h" -#define SP_TYPE_ICON SPIcon::getType() +#define SP_TYPE_ICON sp_icon_get_type() #define SP_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_ICON, SPIcon)) #define SP_IS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_ICON)) @@ -29,6 +29,8 @@ struct SPIconClass { GtkWidgetClass parent_class; }; +GType sp_icon_get_type() G_GNUC_CONST; + struct SPIcon { GtkWidget widget; @@ -38,8 +40,6 @@ struct SPIcon { GdkPixbuf *pb; - static GType getType(void); - friend class SPIconImpl; }; -- cgit v1.2.3 From 5ebf0c12c2b1be530bf4742236768a55e549494b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 27 Jan 2013 14:19:11 +0000 Subject: Migrate ruler position tracking to new track_widget API Fixed bugs: - https://launchpad.net/bugs/1105504 (bzr r12067) --- src/widgets/desktop-widget.cpp | 10 +++------- src/widgets/desktop-widget.h | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index a7432c32a..8a47b345e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -520,6 +520,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE); + sp_ruler_add_track_widget (SP_RULER(dtw->hruler), GTK_WIDGET(dtw->canvas)); + sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas)); + #if GTK_CHECK_VERSION(3,0,0) GdkRGBA white = {1,1,1,1}; gtk_widget_override_background_color(GTK_WIDGET(dtw->canvas), @@ -1685,13 +1688,6 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) return dtw; } -void -SPDesktopWidget::viewSetPosition (Geom::Point p) -{ - Geom::Point const origin = ( p - ruler_origin ); - sp_ruler_set_position(SP_RULER(hruler), origin[Geom::X]); - sp_ruler_set_position(SP_RULER(vruler), origin[Geom::Y]); -} void sp_desktop_widget_update_rulers (SPDesktopWidget *dtw) diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 73194304f..dedda7123 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -168,8 +168,6 @@ struct SPDesktopWidget { { sp_dtw_desktop_activate (_dtw); } virtual void deactivateDesktop() { sp_dtw_desktop_deactivate (_dtw); } - virtual void viewSetPosition (Geom::Point p) - { _dtw->viewSetPosition (p); } virtual void updateRulers() { sp_desktop_widget_update_rulers (_dtw); } virtual void updateScrollbars (double scale) -- cgit v1.2.3 From aca87f3d80cf0f83414918cf013ea4eb20336576 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 27 Jan 2013 15:28:36 +0000 Subject: desktop-widget: Add callback to ensure that ruler ranges are correctly updated when canvas table resizes Fixed bugs: - https://launchpad.net/bugs/950552 (bzr r12068) --- src/widgets/desktop-widget.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 8a47b345e..e6fabd50b 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -312,6 +312,22 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) widget_class->realize = sp_desktop_widget_realize; } +/** + * Callback for changes in size of the canvas table (i.e. the container for + * the canvas, the rulers etc). + * + * This adjusts the range of the rulers when the dock container is adjusted + * (fixes lp:950552) + */ +static void +canvas_tbl_size_allocate(GtkWidget *widget, + GdkRectangle *allocation, + gpointer data) +{ + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); + sp_desktop_widget_update_rulers (dtw); +} + /** * Callback for SPDesktopWidget object initialization. */ @@ -743,6 +759,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } overallTimer = 0; } + + // Ensure that ruler ranges are updated correctly whenever the canvas table + // is resized + g_signal_connect (G_OBJECT (canvas_tbl), + "size-allocate", + G_CALLBACK (canvas_tbl_size_allocate), + dtw); } /** -- cgit v1.2.3 From 1b96d99480729ccc54d4f5292c305dd4bfa34655 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 30 Jan 2013 23:11:40 +0000 Subject: Disconnect size_allocation signal handler before disposing desktop widget Fixed bugs: - https://launchpad.net/bugs/1108930 (bzr r12078) --- src/widgets/desktop-widget.cpp | 46 ++++++++++++++++++++++-------------------- src/widgets/desktop-widget.h | 6 +++++- 2 files changed, 29 insertions(+), 23 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index e6fabd50b..95ac7f949 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -324,8 +324,8 @@ canvas_tbl_size_allocate(GtkWidget *widget, GdkRectangle *allocation, gpointer data) { - SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); - sp_desktop_widget_update_rulers (dtw); + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); + sp_desktop_widget_update_rulers (dtw); } /** @@ -401,14 +401,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) GtkWidget *tbl = gtk_grid_new(); - GtkWidget *canvas_tbl = gtk_grid_new(); + dtw->canvas_tbl = gtk_grid_new(); - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1); #else GtkWidget *tbl = gtk_table_new(2, 3, FALSE); - GtkWidget *canvas_tbl = gtk_table_new(3, 3, FALSE); + dtw->canvas_tbl = gtk_table_new(3, 3, FALSE); - gtk_table_attach(GTK_TABLE(canvas_tbl), + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), eventbox, 1, 2, 0, 1, GTK_FILL, GTK_FILL, @@ -426,9 +426,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 0, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 0, 1, 1, 1); #else - gtk_table_attach(GTK_TABLE (canvas_tbl), + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), eventbox, 0, 1, 1, 2, GTK_FILL, GTK_FILL, @@ -444,11 +444,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); - gtk_table_attach(GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0); dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0); @@ -476,9 +476,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); #else - gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, GTK_SHRINK, GTK_FILL, 0, 0); #endif @@ -514,9 +514,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach( GTK_GRID(canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); + gtk_grid_attach( GTK_GRID(dtw->canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); #else - gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, + gtk_table_attach( GTK_TABLE(dtw->canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0); @@ -560,9 +560,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); - gtk_grid_attach(GTK_GRID(canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); + gtk_table_attach (GTK_TABLE (dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); #endif /* Dock */ @@ -579,7 +579,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Gtk::HPaned *paned = new Gtk::HPaned(); #endif - paned->pack1(*Glib::wrap(canvas_tbl)); + paned->pack1(*Glib::wrap(dtw->canvas_tbl)); paned->pack2(dtw->dock->getWidget(), Gtk::FILL); /* Prevent the paned from catching F6 and F8 by unsetting the default callbacks */ @@ -599,11 +599,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } else { #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_widget_set_vexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (canvas_tbl), 1, 1, 1, 1); + gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); #endif } @@ -762,7 +762,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) // Ensure that ruler ranges are updated correctly whenever the canvas table // is resized - g_signal_connect (G_OBJECT (canvas_tbl), + g_signal_connect (G_OBJECT (dtw->canvas_tbl), "size-allocate", G_CALLBACK (canvas_tbl_size_allocate), dtw); @@ -787,6 +787,8 @@ static void sp_desktop_widget_dispose(GObject *object) g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); + g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw); + dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index dedda7123..0ffedd112 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -105,7 +105,11 @@ struct SPDesktopWidget { unsigned int _interaction_disabled_counter; - SPCanvas *canvas; + SPCanvas *canvas; + + /** A table for displaying the canvas, rulers etc */ + GtkWidget *canvas_tbl; + Geom::Point ruler_origin; double dt2r; -- cgit v1.2.3 From 6a597dc85342abf8c88a5b4f1ba99d50589f64ef Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 31 Jan 2013 19:35:26 +0100 Subject: Text toolbar will display style options for the first font in a font-family list. Also, fix mem leak. (bzr r12082) --- src/widgets/text-toolbar.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6c22c81e3..1f60c6214 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -178,6 +178,11 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) return; } + // If font list, take only first font in list + gchar** tokens = g_strsplit( current_font, ",", 0 ); + g_strstrip( tokens[0] ); + current_font = tokens[0]; + // Get an iter to the selected font from the model data // We cant get it from the combo, cause it might not have been created yet gboolean found = false; @@ -197,6 +202,8 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) valid = gtk_tree_model_iter_next( model, &iter ); } + g_strfreev( tokens ); + if (!found) { return; } -- cgit v1.2.3 From 71b23adf38b7d0cdc586327214ddb363f60af994 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 31 Jan 2013 21:55:46 +0000 Subject: Clean up Cairo rendering in a couple of widgets (bzr r12083) --- src/widgets/sp-color-slider.cpp | 59 +++++++++++++---------------------------- 1 file changed, 18 insertions(+), 41 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 37cccda9f..471ee3852 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -642,49 +642,26 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr) gint x = (int)(slider->value * (carea.width - 1) - ARROW_SIZE / 2 + carea.x); gint y1 = carea.y; gint y2 = carea.y + carea.height - 1; - gint w = ARROW_SIZE; cairo_set_line_width(cr, 1.0); -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA white = {1,1,1,1}; - GdkRGBA black = {0,0,0,1}; -#else - GdkColor white, black; - gdk_color_parse("#fff", &white); - gdk_color_parse("#000", &black); -#endif - - while ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &white); -#else - gdk_cairo_set_source_color(cr, &white); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - w -=2; - x++; - if ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &black); -#else - gdk_cairo_set_source_color(cr, &black); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - } - y1++; - y2--; - } - + // Define top arrow + cairo_move_to(cr, x - 0.5, y1 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y1 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y1 + ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y1 + 0.5); + + // Define bottom arrow + cairo_move_to(cr, x - 0.5, y2 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y2 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y2 - ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y2 + 0.5); + + // Render both arrows + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_stroke_preserve(cr); + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_fill(cr); + return FALSE; } -- cgit v1.2.3 From bc5979b0e1e7ab3b9279e8f9ef58255f139937be Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 2 Feb 2013 16:18:34 +0900 Subject: Fix for 1091582 : Problem with key release when pressing space with cursor off canvas. (bzr r12088) --- src/widgets/desktop-widget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 95ac7f949..9e078cabb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -998,12 +998,13 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt if (GTK_WIDGET_CLASS (dtw_parent_class)->event) { return (* GTK_WIDGET_CLASS (dtw_parent_class)->event) (widget, event); } else { - // The keypress events need to be passed to desktop handler explicitly, - // because otherwise the event contexts only receive keypresses when the mouse cursor - // is over the canvas. This redirection is only done for keypresses and only if there's no + // The key press/release events need to be passed to desktop handler explicitly, + // because otherwise the event contexts only receive key events when the mouse cursor + // is over the canvas. This redirection is only done for key events and only if there's no // current item on the canvas, because item events and all mouse events are caught // and passed on by the canvas acetate (I think). --bb - if (event->type == GDK_KEY_PRESS && !dtw->canvas->current_item) { + if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) + && !dtw->canvas->current_item) { return sp_desktop_root_handler (NULL, event, dtw->desktop); } } -- cgit v1.2.3 From c84cc8045be0f7374f0668df62b4f34ef8b9df9c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 2 Feb 2013 13:15:56 +0100 Subject: Allow simple font style changes even if first font-family in font list is not on users system. (bzr r12093) --- src/widgets/text-toolbar.cpp | 53 ++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 1f60c6214..9fdc1ea7b 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -204,14 +204,6 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) g_strfreev( tokens ); - if (!found) { - return; - } - - // Get the list of styles from the selected font - GList *list = NULL; - gtk_tree_model_get (model, &iter, 1, &list, -1); - Ink_ComboBoxEntry_Action* fontStyleAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) ); gchar *current_style = ink_comboboxentry_action_get_active_text( fontStyleAction ); @@ -219,11 +211,30 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) GtkListStore *store = GTK_LIST_STORE( ink_comboboxentry_action_get_model( fontStyleAction ) ); gtk_list_store_clear ( store ); - // Add list of styles to the style combo - for (GList *l=list; l; l = l->next) - { + // Get the list of styles from the selected font + GList *list = NULL; + + if (found) { + + // Add list of styles to the style combo + gtk_tree_model_get (model, &iter, 1, &list, -1); + for (GList *l=list; l; l = l->next) + { + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, (char*)l->data, -1); + } + + } else { + + // Create generic list if selected font-family not available on system + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, "Normal", -1); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, "Italic", -1); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, "Bold", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, (char*)l->data, -1); + gtk_list_store_set (store, &iter, 0, "Bold Italic", -1); } // Select the style in the combo that best matches font @@ -526,7 +537,7 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj SPCSSAttr *css = sp_repr_css_attr_new (); - gchar *current_style = ink_comboboxentry_action_get_active_text( act ); + Glib::ustring current_style = ink_comboboxentry_action_get_active_text( act ); Glib::ustring fontFamily = ""; if (query->text->font_family.set) { @@ -537,9 +548,10 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj fontFamily = ink_comboboxentry_action_get_active_text( act ); } - font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style); + font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style.c_str()); if (font) { + gchar c[256]; font->Attribute( "weight", c, 256); @@ -556,6 +568,19 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj font->Unref(); font = NULL; + + } else { + + // Font not found on system, blindly update style + // Options match choices in sp_text_fontstyle_populate + sp_repr_css_set_property (css, "font-weight", "normal"); + sp_repr_css_set_property (css, "font-style", "normal" ); + if( current_style.find("Bold") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-weight", "bold"); + } + if( current_style.find("Italic") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-style", "italic"); + } } // If querying returned nothing, update default style. -- cgit v1.2.3 From c37431c37889fed55de3b8c76a0dc0569f0fe42d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 3 Feb 2013 19:37:58 +0100 Subject: fix crash Fixed bugs: - https://launchpad.net/bugs/1114243 (bzr r12094) --- src/widgets/font-selector.cpp | 4 ++++ src/widgets/text-toolbar.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index b17dcf470..0f0e27746 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -442,6 +442,10 @@ GtkWidget *sp_font_selector_new() */ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) { + if ( !font || !list) { + return 0; + } + font_instance *tempFont = NULL; unsigned int currentStyleNumber = 0; unsigned int bestStyleNumber = 0; diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 9fdc1ea7b..f9921864c 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -238,7 +238,7 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) } // Select the style in the combo that best matches font - if (font) { + if (font && list) { unsigned int index = sp_font_selector_get_best_style(font, list); -- cgit v1.2.3 From 61eb37a18f652117804d6e3a890ebde5959be214 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 3 Feb 2013 19:40:00 +0100 Subject: add todo comment for fixing fontstyle fall-back behaviour (bzr r12095) --- src/widgets/text-toolbar.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index f9921864c..060bb4a80 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -235,6 +235,8 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) gtk_list_store_set (store, &iter, 0, "Bold", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, "Bold Italic", -1); + + /// \todo \c list should be initialized here with "Normal", "Italic", etc too } // Select the style in the combo that best matches font -- cgit v1.2.3 From 2c7d2b2cd8f2571cc65d2ba7ac628bb8b43e5c7a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 4 Feb 2013 10:47:19 +0100 Subject: Better fix for 1114243, crash on launch with default prefs from stable (bzr r12097) --- src/widgets/text-toolbar.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 060bb4a80..dc4a6be27 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -211,32 +211,31 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) GtkListStore *store = GTK_LIST_STORE( ink_comboboxentry_action_get_model( fontStyleAction ) ); gtk_list_store_clear ( store ); - // Get the list of styles from the selected font + // Get the list of styles from the selected font. GList *list = NULL; if (found) { - // Add list of styles to the style combo + // Use precompiled list if font-family on system. gtk_tree_model_get (model, &iter, 1, &list, -1); - for (GList *l=list; l; l = l->next) - { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, (char*)l->data, -1); - } } else { - // Create generic list if selected font-family not available on system - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "Normal", -1); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "Italic", -1); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "Bold", -1); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "Bold Italic", -1); + // Use generic list if font-family not on system. + static GList *glist = NULL; + if( glist == NULL ) { + glist = g_list_append (glist, (void*)"Normal"); + glist = g_list_append (glist, (void*)"Italic"); + glist = g_list_append (glist, (void*)"Bold"); + glist = g_list_append (glist, (void*)"Bold Italic"); + } + list = glist; + } - /// \todo \c list should be initialized here with "Normal", "Italic", etc too + for (GList *l=list; l; l = l->next) + { + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, (char*)l->data, -1); } // Select the style in the combo that best matches font -- cgit v1.2.3 From 048beb0d69537f56f6b662830356553e469a4259 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 4 Feb 2013 19:54:53 +0100 Subject: Only set up text-tool bar if has actually been created. Ensures proper initialization after creation. (bzr r12099) --- src/widgets/text-toolbar.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index dc4a6be27..6adff8bfb 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1173,6 +1173,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ std::cout << selected_text << std::endl; #endif + // Check if the toolbar has been created; quit if it has not. + Ink_ComboBoxEntry_Action* fontFamilyAction = + INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); + if( fontFamilyAction->combobox == NULL ) { + return; + } + // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { #ifdef DEBUG_TEXT -- cgit v1.2.3 From f7810c8932b5097aebb9c1b11e346d1a56b4a11e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 5 Feb 2013 19:45:34 +0100 Subject: Second try at getting text toolbar properly initialized when there is no prefs file. (bzr r12101) --- src/widgets/text-toolbar.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6adff8bfb..3eccf1d2f 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1173,13 +1173,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ std::cout << selected_text << std::endl; #endif - // Check if the toolbar has been created; quit if it has not. - Ink_ComboBoxEntry_Action* fontFamilyAction = - INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); - if( fontFamilyAction->combobox == NULL ) { - return; - } - // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { #ifdef DEBUG_TEXT @@ -1243,7 +1236,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ return; } - g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + // To ensure the value of the combobox is properly set on start-up, only mark + // the prefs set if the combobox has already been constructed. + Ink_ComboBoxEntry_Action* fontFamilyAction = + INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); + if( fontFamilyAction->combobox != NULL ) { + g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + } } else { g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE)); } -- cgit v1.2.3 From 39e5510c9bed6a057db554fbcfd2e4b77aea1d76 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 5 Feb 2013 21:50:41 +0100 Subject: Supress Pango error message. (bzr r12103) --- src/widgets/font-selector.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 0f0e27746..b0b4b5504 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -466,7 +466,9 @@ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) tempFont = NULL; } - pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + if( bestMatchForFont != NULL ) { + pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + } list = list->next; -- cgit v1.2.3 From aeabdef63219b5369907c767f692e929013c3507 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 6 Feb 2013 10:07:00 +0100 Subject: Add fonts (and font-lists) used in document to top of Text tool-bar font-family drop-down menu. If font is not on system, draws strikethrough on top of font name. (bzr r12104) --- src/widgets/text-toolbar.cpp | 213 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 195 insertions(+), 18 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 3eccf1d2f..8b3612db4 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -18,7 +18,7 @@ * * Copyright (C) 2004 David Turner * Copyright (C) 2003 MenTaLguY - * Copyright (C) 1999-2011 authors + * Copyright (C) 1999-2013 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -39,6 +39,7 @@ #include "../desktop-handles.h" #include "../desktop-style.h" #include "document-undo.h" +#include "../sp-root.h" #include "../verbs.h" #include "../inkscape.h" #include "../connection-pool.h" @@ -105,6 +106,10 @@ static void sp_print_font( SPStyle *query ) { << " FontSpec: " << (query->text->font_specification.value ? query->text->font_specification.value : "No value") << std::endl; + std::cout << " LineHeight: " << query->line_height.computed + << " WordSpacing: " << query->word_spacing.computed + << " LetterSpacing: " << query->letter_spacing.computed + << std::endl; } static void sp_print_fontweight( SPStyle *query ) { @@ -128,40 +133,88 @@ static void sp_print_fontstyle( SPStyle *query ) { } #endif +void sp_text_toolbox_get_font_list_in_doc (SPObject *r, std::list *l); +void sp_text_toolbox_update_font_list( GtkListStore* model ); + // Format family drop-down menu. static void cell_data_func(GtkCellLayout * /*cell_layout*/, GtkCellRenderer *cell, - GtkTreeModel *tree_model, + GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/) { gchar *family; - gtk_tree_model_get(tree_model, iter, 0, &family, -1); - gchar *const family_escaped = g_markup_escape_text(family, -1); + gboolean onSystem = false; + gtk_tree_model_get(model, iter, 0, &family, 2, &onSystem, -1); + Glib::ustring family_escaped = g_markup_escape_text(family, -1); + g_free(family); + Glib::ustring markup; + + if( !onSystem ) { + markup = ""; + + /* See if font-family on system */ + std::vector tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped ); + for( size_t i=0; i < tokens.size(); ++i ) { + + Glib::ustring token = tokens[i]; + + GtkTreeIter iter; + gboolean valid; + gchar *family = 0; + gboolean onSystem = true; + gboolean found = false; + for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); + valid; + valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ) ) { + + gtk_tree_model_get(model, &iter, 0, &family, 2, &onSystem, -1); + if( onSystem && token.compare( family ) == 0 ) { + found = true; + break; + } + } + if( found ) { + markup += g_markup_escape_text(token.c_str(), -1); + markup += ", "; + } else { + markup += ""; + markup += g_markup_escape_text(token.c_str(), -1); + markup += ""; + markup += ", "; + } + } + // Remove extra comma and space from end. + if( markup.size() >= 2 ) { + markup.resize( markup.size()-2 ); + } + markup += ""; + // std::cout << markup << std::endl; + } else { + markup = family_escaped; + } 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 << " " << sample_escaped << ""; - g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL); + Glib::ustring sample_escaped = g_markup_escape_text(sample.data(), -1); - g_free(sample_escaped); - } else { - g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL); + markup += " "; + markup += sample_escaped; + markup += ""; } + + g_object_set (G_OBJECT (cell), "markup", markup.c_str(), NULL); + // This doesn't work for two reasons... it set both selected and not selected backgrounds // to white.. which means that white foreground text is invisible. It also only effects // the text region, leaving the padding untouched. // g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL); - g_free(family); - g_free(family_escaped); } /* @@ -256,7 +309,6 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) } else if (current_style) { ink_comboboxentry_action_set_active_text( fontStyleAction, current_style ); } - } // Font family @@ -1184,6 +1236,14 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); + // Update font list, but only if widget already created. + Ink_ComboBoxEntry_Action* fontFamilyAction = + INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); + if( fontFamilyAction->combobox != NULL ) { + sp_text_toolbox_update_font_list( GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontFamilyAction)) ); + } + + // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; @@ -1238,8 +1298,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // To ensure the value of the combobox is properly set on start-up, only mark // the prefs set if the combobox has already been constructed. - Ink_ComboBoxEntry_Action* fontFamilyAction = - INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); if( fontFamilyAction->combobox != NULL ) { g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); } @@ -1482,6 +1540,124 @@ sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl) sp_text_toolbox_selection_changed (NULL, tbl); } + +/* Recursively extract all "font-family" attributes from a document. */ +void +sp_text_toolbox_get_font_list_in_doc_recursive (SPObject *r, std::list *l) +{ + if (!r) { + return; + } + + const gchar *style = r->getRepr()->attribute("style"); + if( style != NULL ) { + //std::cout << style << std::endl; + std::vector tokens = Glib::Regex::split_simple(";", style ); + for( size_t i=0; i < tokens.size(); ++i ) { + Glib::ustring token = tokens[i]; + size_t found = token.find("font-family:"); + if( found != Glib::ustring::npos ) { + // Remove "font-family:" + token.erase(found,12); + // Remove any leading single or double quote + if( token[0] == '\'' || token[0] == '"' ) { + token.erase(0,1); + } + // Remove any trailing single or double quote + if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) { + token.erase(token.length()-1); + } + l->push_back( token ); + } + } + } + + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + sp_text_toolbox_get_font_list_in_doc_recursive( child, l ); + } +} + +/* Extract all unique "font-family" attributes (including font-family fallbacks) + * from a document in a reverse sorted list. + */ +void +sp_text_toolbox_get_font_list_in_doc (SPObject *r, std::list *l) { + + sp_text_toolbox_get_font_list_in_doc_recursive (r, l); + + l->sort(); + l->unique(); + l->reverse(); + + // for(std::list::iterator i = l->begin(); i != l->end(); ++i) { + // std::cout << " font_family in doc: " << *i << std::endl; + // } +} + +/* Update font-family list with "font-family" attributes used in a document. */ +void +sp_text_toolbox_update_font_list( GtkListStore* model ) { + + /* Create default styles for use when font-family is unknown on system. */ + static GList *default_styles = NULL; + if( default_styles == NULL ) { + default_styles = g_list_append( default_styles, g_strdup("Normal") ); + default_styles = g_list_append( default_styles, g_strdup("Italic") ); + default_styles = g_list_append( default_styles, g_strdup("Bold") ); + default_styles = g_list_append( default_styles, g_strdup("Bold Italic") ); + } + + /* Get "font-family" attributes used in document */ + std::list fontfamilies; + sp_text_toolbox_get_font_list_in_doc( (sp_desktop_document(SP_ACTIVE_DESKTOP))->getRoot(), &fontfamilies ); + + /* Delete all old doc font-family entries */ + GtkTreeIter iter; + gboolean valid; + for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); valid; ) { + gchar *family = 0; + gboolean onSystem = true; + gtk_tree_model_get( GTK_TREE_MODEL(model), &iter, 0, &family, 2, &onSystem, -1 ); + //std::cout << "List: " << family << ": " << (onSystem ? "Yes" : "No") << std::endl; + if( !onSystem ) { + valid = gtk_list_store_remove( model, &iter ); + } else { + valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ); + } + } + + /* Insert doc font-family entries, list is already reverse sorted with duplicates removed. */ + std::list::iterator i; + for(i=fontfamilies.begin(); i != fontfamilies.end(); ++i) { + + GList *styles = default_styles; + gtk_list_store_insert( model, &iter, 0 ); // iter points to new row + + /* See if font-family (or first in fallback list) is on system. If so, get styles. */ + std::vector tokens = Glib::Regex::split_simple(",", *i ); + if( !tokens[0].empty() ) { + + GtkTreeIter iter2; + gboolean valid2; + for( valid2 = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter2 ); + valid2; + valid2 = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter2 ) ) { + + gchar* family = 0; + gboolean onSystem = true; + gtk_tree_model_get( GTK_TREE_MODEL(model), &iter2, 0, &family, 2, &onSystem, -1 ); + if( onSystem && tokens[0].compare( family ) == 0 ) { + gtk_tree_model_get( GTK_TREE_MODEL(model), &iter2, 1, &styles, -1 ); + break; + } + } + + } + + gtk_list_store_set( model, &iter, 0, (*i).c_str(), 1, styles, 2, false, -1 ); + } +} + // Define all the "widgets" in the toolbar. void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { @@ -1498,6 +1674,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje // Font list Glib::RefPtr store = Inkscape::FontLister::get_instance()->get_font_list(); GtkListStore* model = store->gobj(); + sp_text_toolbox_update_font_list( model ); Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction", _("Font Family"), -- cgit v1.2.3 From a3d3d3df4c67f666083e7c4c2ea56bb94705bbbf Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 7 Feb 2013 12:47:37 +0100 Subject: Add separator between fonts in document and fonts on sytem in font-family drop-down menu. Separator style depends on GTK theme (may be invisible). (bzr r12105) --- src/widgets/text-toolbar.cpp | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 8b3612db4..42d309994 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -217,6 +217,16 @@ static void cell_data_func(GtkCellLayout * /*cell_layout*/, } +// Separator function (if true, a separator will be drawn) +static gboolean separator_func(GtkTreeModel *model, + GtkTreeIter *iter, + gpointer /*data*/) +{ + gchar* text = 0; + gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0 + return (text && strcmp(text,"separatoR") == 0); +} + /* * Fill the font style combobox with the available font styles for the selected font family * Set the selected style to that in font @@ -1626,6 +1636,13 @@ sp_text_toolbox_update_font_list( GtkListStore* model ) { } } + /* Insert separator */ + if( !fontfamilies.empty() ) { + gtk_list_store_insert( model, &iter, 0 ); // iter points to new row + gtk_list_store_set( model, &iter, 0, "separatoR", -1 ); + } + + /* Insert doc font-family entries, list is already reverse sorted with duplicates removed. */ std::list::iterator i; for(i=fontfamilies.begin(); i != fontfamilies.end(); ++i) { @@ -1676,15 +1693,17 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje GtkListStore* model = store->gobj(); sp_text_toolbox_update_font_list( model ); - Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction", - _("Font Family"), - _("Select Font Family (Alt-X to access)"), - NULL, - GTK_TREE_MODEL(model), - -1, // Entry width - 50, // Extra list width - (gpointer)cell_data_func,// Cell layout - GTK_WIDGET(desktop->canvas)); // Focus widget + Ink_ComboBoxEntry_Action* act = + ink_comboboxentry_action_new( "TextFontFamilyAction", + _("Font Family"), + _("Select Font Family (Alt-X to access)"), + NULL, + GTK_TREE_MODEL(model), + -1, // Entry width + 50, // Extra list width + (gpointer)cell_data_func, // Cell layout + (gpointer)separator_func, + GTK_WIDGET(desktop->canvas)); // Focus widget ink_comboboxentry_action_popup_enable( act ); // Enable entry completion gchar *const warning = _("Font not found on system"); ink_comboboxentry_action_set_warning( act, warning ); // Show icon with tooltip if missing font @@ -1721,6 +1740,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 4, // Width in characters 0, // Extra list width NULL, // Cell layout + NULL, // Separator GTK_WIDGET(desktop->canvas)); // Focus widget g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontsize_value_changed), holder ); @@ -1740,6 +1760,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 12, // Width in characters 0, // Extra list width NULL, // Cell layout + NULL, // Separator GTK_WIDGET(desktop->canvas)); // Focus widget g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontstyle_value_changed), holder ); -- cgit v1.2.3 From 55e21b98d8eda49df5d2c2d8ea940dd2d0802bc5 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 7 Feb 2013 15:14:00 +0100 Subject: Widen the separator in font-family drop-down so it is visible in more themes. (bzr r12106) --- src/widgets/text-toolbar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 42d309994..8d37891ac 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1718,7 +1718,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "{\n" " GtkComboBox::appears-as-list = 1\n" "}\n" - "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\""); + "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\"" + "style \"fontfamily-separator-style\"\n" + "{\n" + " GtkWidget::wide-separators = 1\n" + " GtkWidget::separator-height = 6\n" + "}\n" + "class \"GtkTreeView\" style \"fontfamily-separator-style\""); } /* Font size */ -- cgit v1.2.3 From 1db4e9f22c0412532f0c3fb9798cd1983a74c9de Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 8 Feb 2013 09:08:06 +0100 Subject: Better rc matching for text-toolbar font-family drop-down separator. From John Smith. (bzr r12107) --- src/widgets/text-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 8d37891ac..f19ee7cee 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1724,7 +1724,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje " GtkWidget::wide-separators = 1\n" " GtkWidget::separator-height = 6\n" "}\n" - "class \"GtkTreeView\" style \"fontfamily-separator-style\""); + "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\""); } /* Font size */ -- cgit v1.2.3 From 83ae846627474ee5aad75c1f4816a3faa7240a47 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 9 Feb 2013 13:52:04 +0100 Subject: Use update_font_list() in font-lister.cpp. Remove equivalent code in text-toolbar.cpp. Change separator "tag" from "separatoR" to "#" in attempt to speed up start up. (bzr r12112) --- src/widgets/text-toolbar.cpp | 100 +++---------------------------------------- 1 file changed, 6 insertions(+), 94 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index f19ee7cee..5ba2065b9 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -133,9 +133,6 @@ static void sp_print_fontstyle( SPStyle *query ) { } #endif -void sp_text_toolbox_get_font_list_in_doc (SPObject *r, std::list *l); -void sp_text_toolbox_update_font_list( GtkListStore* model ); - // Format family drop-down menu. static void cell_data_func(GtkCellLayout * /*cell_layout*/, GtkCellRenderer *cell, @@ -224,7 +221,7 @@ static gboolean separator_func(GtkTreeModel *model, { gchar* text = 0; gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0 - return (text && strcmp(text,"separatoR") == 0); + return (text && strcmp(text,"#") == 0); } /* @@ -1250,7 +1247,8 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ Ink_ComboBoxEntry_Action* fontFamilyAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); if( fontFamilyAction->combobox != NULL ) { - sp_text_toolbox_update_font_list( GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontFamilyAction)) ); + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); + fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); } @@ -1587,93 +1585,6 @@ sp_text_toolbox_get_font_list_in_doc_recursive (SPObject *r, std::list *l) { - - sp_text_toolbox_get_font_list_in_doc_recursive (r, l); - - l->sort(); - l->unique(); - l->reverse(); - - // for(std::list::iterator i = l->begin(); i != l->end(); ++i) { - // std::cout << " font_family in doc: " << *i << std::endl; - // } -} - -/* Update font-family list with "font-family" attributes used in a document. */ -void -sp_text_toolbox_update_font_list( GtkListStore* model ) { - - /* Create default styles for use when font-family is unknown on system. */ - static GList *default_styles = NULL; - if( default_styles == NULL ) { - default_styles = g_list_append( default_styles, g_strdup("Normal") ); - default_styles = g_list_append( default_styles, g_strdup("Italic") ); - default_styles = g_list_append( default_styles, g_strdup("Bold") ); - default_styles = g_list_append( default_styles, g_strdup("Bold Italic") ); - } - - /* Get "font-family" attributes used in document */ - std::list fontfamilies; - sp_text_toolbox_get_font_list_in_doc( (sp_desktop_document(SP_ACTIVE_DESKTOP))->getRoot(), &fontfamilies ); - - /* Delete all old doc font-family entries */ - GtkTreeIter iter; - gboolean valid; - for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); valid; ) { - gchar *family = 0; - gboolean onSystem = true; - gtk_tree_model_get( GTK_TREE_MODEL(model), &iter, 0, &family, 2, &onSystem, -1 ); - //std::cout << "List: " << family << ": " << (onSystem ? "Yes" : "No") << std::endl; - if( !onSystem ) { - valid = gtk_list_store_remove( model, &iter ); - } else { - valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ); - } - } - - /* Insert separator */ - if( !fontfamilies.empty() ) { - gtk_list_store_insert( model, &iter, 0 ); // iter points to new row - gtk_list_store_set( model, &iter, 0, "separatoR", -1 ); - } - - - /* Insert doc font-family entries, list is already reverse sorted with duplicates removed. */ - std::list::iterator i; - for(i=fontfamilies.begin(); i != fontfamilies.end(); ++i) { - - GList *styles = default_styles; - gtk_list_store_insert( model, &iter, 0 ); // iter points to new row - - /* See if font-family (or first in fallback list) is on system. If so, get styles. */ - std::vector tokens = Glib::Regex::split_simple(",", *i ); - if( !tokens[0].empty() ) { - - GtkTreeIter iter2; - gboolean valid2; - for( valid2 = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter2 ); - valid2; - valid2 = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter2 ) ) { - - gchar* family = 0; - gboolean onSystem = true; - gtk_tree_model_get( GTK_TREE_MODEL(model), &iter2, 0, &family, 2, &onSystem, -1 ); - if( onSystem && tokens[0].compare( family ) == 0 ) { - gtk_tree_model_get( GTK_TREE_MODEL(model), &iter2, 1, &styles, -1 ); - break; - } - } - - } - - gtk_list_store_set( model, &iter, 0, (*i).c_str(), 1, styles, 2, false, -1 ); - } -} // Define all the "widgets" in the toolbar. void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) @@ -1689,9 +1600,10 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Font family */ { // Font list - Glib::RefPtr store = Inkscape::FontLister::get_instance()->get_font_list(); + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); + fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + Glib::RefPtr store = fontlister->get_font_list(); GtkListStore* model = store->gobj(); - sp_text_toolbox_update_font_list( model ); Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction", -- cgit v1.2.3 From cb07768f46fef63b0e0f48e3b12be97467d46a9c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 11 Feb 2013 16:35:47 +0100 Subject: Move cell_data_func and separator_func from text-toolbar to font-lister. Use functions with font-selector (in Text dialog). (bzr r12116) --- src/widgets/font-selector.cpp | 13 ++++++ src/widgets/text-toolbar.cpp | 95 +------------------------------------------ 2 files changed, 15 insertions(+), 93 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index b0b4b5504..013ad9e94 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -162,8 +162,21 @@ static void sp_font_selector_init(SPFontSelector *fsel) GtkCellRenderer *cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, "text", 0, NULL); + gtk_tree_view_column_set_cell_data_func (column, cell, + GtkTreeCellDataFunc (font_lister_cell_data_func), + NULL, NULL ); gtk_tree_view_append_column (GTK_TREE_VIEW(fsel->family_treeview), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->family_treeview), FALSE); + gtk_tree_view_set_row_separator_func( GTK_TREE_VIEW(fsel->family_treeview), + GtkTreeViewRowSeparatorFunc ((gpointer)font_lister_separator_func), + NULL, NULL ); + + /* Muck with style, see text-toolbar.cpp */ + gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" ); + gtk_rc_parse_string ( + "widget \"*font_selector_family\" style \"fontfamily-separator-style\""); + + Glib::RefPtr store = fontlister->get_font_list(); gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store))); gtk_container_add(GTK_CONTAINER(sw), fsel->family_treeview); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 5ba2065b9..a01f950a6 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -133,97 +133,6 @@ static void sp_print_fontstyle( SPStyle *query ) { } #endif -// Format family drop-down menu. -static void cell_data_func(GtkCellLayout * /*cell_layout*/, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/) -{ - gchar *family; - gboolean onSystem = false; - gtk_tree_model_get(model, iter, 0, &family, 2, &onSystem, -1); - Glib::ustring family_escaped = g_markup_escape_text(family, -1); - g_free(family); - Glib::ustring markup; - - if( !onSystem ) { - markup = ""; - - /* See if font-family on system */ - std::vector tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped ); - for( size_t i=0; i < tokens.size(); ++i ) { - - Glib::ustring token = tokens[i]; - - GtkTreeIter iter; - gboolean valid; - gchar *family = 0; - gboolean onSystem = true; - gboolean found = false; - for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); - valid; - valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ) ) { - - gtk_tree_model_get(model, &iter, 0, &family, 2, &onSystem, -1); - if( onSystem && token.compare( family ) == 0 ) { - found = true; - break; - } - } - if( found ) { - markup += g_markup_escape_text(token.c_str(), -1); - markup += ", "; - } else { - markup += ""; - markup += g_markup_escape_text(token.c_str(), -1); - markup += ""; - markup += ", "; - } - } - // Remove extra comma and space from end. - if( markup.size() >= 2 ) { - markup.resize( markup.size()-2 ); - } - markup += ""; - // std::cout << markup << std::endl; - } else { - markup = family_escaped; - } - - 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"); - Glib::ustring sample_escaped = g_markup_escape_text(sample.data(), -1); - - markup += " "; - markup += sample_escaped; - markup += ""; - } - - g_object_set (G_OBJECT (cell), "markup", markup.c_str(), NULL); - - // This doesn't work for two reasons... it set both selected and not selected backgrounds - // to white.. which means that white foreground text is invisible. It also only effects - // the text region, leaving the padding untouched. - // g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL); - -} - -// Separator function (if true, a separator will be drawn) -static gboolean separator_func(GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/) -{ - gchar* text = 0; - gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0 - return (text && strcmp(text,"#") == 0); -} - /* * Fill the font style combobox with the available font styles for the selected font family * Set the selected style to that in font @@ -1613,8 +1522,8 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje GTK_TREE_MODEL(model), -1, // Entry width 50, // Extra list width - (gpointer)cell_data_func, // Cell layout - (gpointer)separator_func, + (gpointer)font_lister_cell_data_func, // Cell layout + (gpointer)font_lister_separator_func, GTK_WIDGET(desktop->canvas)); // Focus widget ink_comboboxentry_action_popup_enable( act ); // Enable entry completion gchar *const warning = _("Font not found on system"); -- cgit v1.2.3