From 28b7f2e1af6af5c8ec77e3a98b726d26fffa990d Mon Sep 17 00:00:00 2001 From: Stephen Watson Date: Fri, 10 Feb 2006 14:14:42 +0000 Subject: [PATCH] r4351: The monospace font for the list view is now configurable via a ViewDetails::mono-font gtkrc entry (Stephen Watson). --- ROX-Filer/Help/Changes | 5 +++++ ROX-Filer/src/view_details.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index c989767d..1fe15d94 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,11 @@ A RISC OS-like filer for X by Thomas Leonard +10-Feb-2006 +~~~~~~~~~~~ +The monospace font for the list view is now configurable via +a ViewDetails::mono-font gtkrc entry (Stephen Watson). + 29-Jan-2006 ~~~~~~~~~~~ When iconfiying a window, try to find space on the pinboard of the current diff --git a/ROX-Filer/src/view_details.c b/ROX-Filer/src/view_details.c index c84f3c7f..02d9d872 100644 --- a/ROX-Filer/src/view_details.c +++ b/ROX-Filer/src/view_details.c @@ -927,6 +927,25 @@ static void view_details_class_init(gpointer gclass, gpointer data) widget->expose_event = view_details_expose; widget->size_request = view_details_size_request; widget->drag_data_received = view_details_drag_data_received; + + /* + * Add the ViewDetails::mono-font style property. + * To use this add something like + * + * style "details" { + * ViewDetails::mono-font = "Courier 8" + * } + * class "ViewDetails" style "details" + * + * to your ~/.gtkrc-2.0 + */ + gtk_widget_class_install_style_property(widget, + g_param_spec_string("mono-font", + _("Mono font"), + _("Font for displaying mono-spaced text"), + "monospace", + G_PARAM_READABLE)); + } static gboolean block_focus(GtkWidget *button, GtkDirectionType dir, @@ -958,6 +977,21 @@ static void selection_changed(GtkTreeSelection *selection, gtk_get_current_event_time()); } +/* + * Set the font used for a treeview column to that given for the + * "mono-font" style property of a widget. This has to be done _after_ the + * widget has been realized, because that is when the style information is + * set up. This is done by connecting this function to run after the + * "realize" signal. + */ +static void set_column_mono_font(GtkWidget *widget, GObject *object) +{ + const gchar *font_name; + + gtk_widget_style_get(widget, "mono-font", &font_name, NULL); + g_object_set(object, "font", font_name, NULL); +} + #define ADD_TEXT_COLUMN(name, model_column) \ cell = gtk_cell_renderer_text_new(); \ column = gtk_tree_view_column_new_with_attributes(name, cell, \ @@ -1017,12 +1051,18 @@ static void view_details_init(GTypeInstance *object, gpointer gclass) gtk_tree_view_column_set_resizable(column, TRUE); ADD_TEXT_COLUMN(_("_Permissions"), COL_PERM); g_object_set(G_OBJECT(cell), "font", "monospace", NULL); + g_signal_connect_after(object, "realize", + G_CALLBACK(set_column_mono_font), + G_OBJECT(cell)); ADD_TEXT_COLUMN(_("_Owner"), COL_OWNER); gtk_tree_view_column_set_sort_column_id(column, COL_OWNER); ADD_TEXT_COLUMN(_("_Group"), COL_GROUP); gtk_tree_view_column_set_sort_column_id(column, COL_GROUP); ADD_TEXT_COLUMN(_("_Size"), COL_SIZE); g_object_set(G_OBJECT(cell), "xalign", 1.0, "font", "monospace", NULL); + g_signal_connect_after(object, "realize", + G_CALLBACK(set_column_mono_font), + G_OBJECT(cell)); gtk_tree_view_column_set_sort_column_id(column, COL_SIZE); ADD_TEXT_COLUMN(_("Last _Modified"), COL_MTIME); gtk_tree_view_column_set_sort_column_id(column, COL_MTIME); -- 2.11.4.GIT