diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | components/rpmview/nautilus-rpm-view.c | 37 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-gtk-extensions.c | 34 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-gtk-extensions.h | 9 | ||||
-rw-r--r-- | libnautilus-private/nautilus-gtk-extensions.c | 34 | ||||
-rw-r--r-- | libnautilus-private/nautilus-gtk-extensions.h | 9 |
6 files changed, 95 insertions, 36 deletions
@@ -1,3 +1,11 @@ +2000-04-20 Andy Hertzfeld <andy@eazel.com> + + * libnautilus-extensions/nautilus-gtk-extensions.c,h: + added utility routines (written by Darin on my machine) to set the + font associated with a widget + * components/rpm-view/nautilus-rpmview.c: + used the new routine to set the font of the package title. + 2000-04-20 Andreas Hyden <a.hyden@cyberpoint.se> * configure.in: Added sv to ALL_LINGUAS. diff --git a/components/rpmview/nautilus-rpm-view.c b/components/rpmview/nautilus-rpm-view.c index c1695db1f..e7f3f2411 100644 --- a/components/rpmview/nautilus-rpm-view.c +++ b/components/rpmview/nautilus-rpm-view.c @@ -39,6 +39,7 @@ #include <libnautilus-extensions/nautilus-file.h> #include <libnautilus-extensions/nautilus-file-utilities.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> #include <libnautilus-extensions/nautilus-metadata.h> #include <libnautilus-extensions/nautilus-string.h> @@ -105,8 +106,6 @@ static void nautilus_rpm_view_drag_data_received (GtkWidget * static void nautilus_rpm_view_initialize_class (NautilusRPMViewClass *klass); static void nautilus_rpm_view_initialize (NautilusRPMView *view); static void nautilus_rpm_view_destroy (GtkObject *object); -static void nautilus_rpm_view_realize (GtkWidget *widget); -static void setup_title_font (NautilusRPMView *rpm_view); static void rpm_view_notify_location_change_callback (NautilusContentViewFrame *view, Nautilus_NavigationInfo *navinfo, NautilusRPMView *rpm_view); @@ -125,7 +124,6 @@ nautilus_rpm_view_initialize_class (NautilusRPMViewClass *klass) widget_class = GTK_WIDGET_CLASS (klass); object_class->destroy = nautilus_rpm_view_destroy; - widget_class->realize = nautilus_rpm_view_realize; widget_class->drag_data_received = nautilus_rpm_view_drag_data_received; } @@ -178,6 +176,8 @@ nautilus_rpm_view_initialize (NautilusRPMView *rpm_view) /* allocate the name field */ rpm_view->details->package_title = gtk_label_new ("Package Title"); + nautilus_gtk_widget_set_font_by_name (rpm_view->details->package_title, + "-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*"); gtk_box_pack_start (GTK_BOX (temp_title_box), rpm_view->details->package_title, 0, 0, 0); gtk_widget_show (rpm_view->details->package_title); @@ -362,37 +362,6 @@ nautilus_rpm_view_get_view_frame (NautilusRPMView *rpm_view) return rpm_view->details->view_frame; } -/* utility routine to set up the font for the package title and summary, called after we're realized */ -static void -setup_title_font(NautilusRPMView *rpm_view) -{ - GtkStyle *temp_style; - - temp_style = gtk_style_new(); - - gtk_widget_realize (rpm_view->details->package_title); - temp_style->font = gdk_font_load ("-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*"); ; - gtk_widget_set_style (rpm_view->details->package_title, - gtk_style_attach (temp_style, rpm_view->details->package_title->window)); - -} - -/* set up fonts, colors, etc after we're realized */ -void -nautilus_rpm_view_realize(GtkWidget *widget) -{ - NautilusRPMView *rpm_view; - NautilusBackground *background; - - NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, realize, (widget)); - - rpm_view = NAUTILUS_RPM_VIEW (widget); - - setup_title_font (rpm_view); - - background = nautilus_get_widget_background (widget); - nautilus_background_set_color (background, RPM_VIEW_DEFAULT_BACKGROUND_COLOR); -} /* use the package database to see if the passed-in package is installed or not */ /* return 0 if it's not installed, one if it is, -1 if same package, different version */ diff --git a/libnautilus-extensions/nautilus-gtk-extensions.c b/libnautilus-extensions/nautilus-gtk-extensions.c index b89404644..c6411639b 100644 --- a/libnautilus-extensions/nautilus-gtk-extensions.c +++ b/libnautilus-extensions/nautilus-gtk-extensions.c @@ -420,3 +420,37 @@ nautilus_gtk_object_list_free (GList *list) nautilus_gtk_object_list_unref (list); g_list_free (list); } + +/* utilities for setting the font associated with a widget */ + +static void +nautilus_gtk_style_set_font (GtkStyle *style, GdkFont *font) +{ + gdk_font_ref (font); + gdk_font_unref (style->font); + style->font = font; +} + +void +nautilus_gtk_widget_set_font (GtkWidget *widget, GdkFont *font) +{ + GtkStyle *new_style; + + new_style = gtk_style_copy (gtk_widget_get_style (widget)); + + nautilus_gtk_style_set_font (new_style, font); + + gtk_widget_set_style (widget, new_style); + gtk_style_unref (new_style); +} + + +void +nautilus_gtk_widget_set_font_by_name (GtkWidget *widget, const char *font_name) +{ + GdkFont *font; + + font = gdk_font_load (font_name); + nautilus_gtk_widget_set_font (widget, font); + gdk_font_unref (font); +} diff --git a/libnautilus-extensions/nautilus-gtk-extensions.h b/libnautilus-extensions/nautilus-gtk-extensions.h index 61f1f5187..3aaa6591b 100644 --- a/libnautilus-extensions/nautilus-gtk-extensions.h +++ b/libnautilus-extensions/nautilus-gtk-extensions.h @@ -54,9 +54,16 @@ void nautilus_gtk_object_list_unref void nautilus_gtk_object_list_free (GList *list); /* GtkWidget */ -gboolean nautilus_point_in_allocation (const GtkAllocation *allocation, +gboolean nautilus_point_in_allocation (const GtkAllocation *allocation, int x, int y); + +void nautilus_gtk_widget_set_font (GtkWidget *widget, + GdkFont *font); + +void nautilus_gtk_widget_set_font_by_name (GtkWidget *widget, + const char *font_name); + gboolean nautilus_point_in_widget (GtkWidget *widget, int x, int y); diff --git a/libnautilus-private/nautilus-gtk-extensions.c b/libnautilus-private/nautilus-gtk-extensions.c index b89404644..c6411639b 100644 --- a/libnautilus-private/nautilus-gtk-extensions.c +++ b/libnautilus-private/nautilus-gtk-extensions.c @@ -420,3 +420,37 @@ nautilus_gtk_object_list_free (GList *list) nautilus_gtk_object_list_unref (list); g_list_free (list); } + +/* utilities for setting the font associated with a widget */ + +static void +nautilus_gtk_style_set_font (GtkStyle *style, GdkFont *font) +{ + gdk_font_ref (font); + gdk_font_unref (style->font); + style->font = font; +} + +void +nautilus_gtk_widget_set_font (GtkWidget *widget, GdkFont *font) +{ + GtkStyle *new_style; + + new_style = gtk_style_copy (gtk_widget_get_style (widget)); + + nautilus_gtk_style_set_font (new_style, font); + + gtk_widget_set_style (widget, new_style); + gtk_style_unref (new_style); +} + + +void +nautilus_gtk_widget_set_font_by_name (GtkWidget *widget, const char *font_name) +{ + GdkFont *font; + + font = gdk_font_load (font_name); + nautilus_gtk_widget_set_font (widget, font); + gdk_font_unref (font); +} diff --git a/libnautilus-private/nautilus-gtk-extensions.h b/libnautilus-private/nautilus-gtk-extensions.h index 61f1f5187..3aaa6591b 100644 --- a/libnautilus-private/nautilus-gtk-extensions.h +++ b/libnautilus-private/nautilus-gtk-extensions.h @@ -54,9 +54,16 @@ void nautilus_gtk_object_list_unref void nautilus_gtk_object_list_free (GList *list); /* GtkWidget */ -gboolean nautilus_point_in_allocation (const GtkAllocation *allocation, +gboolean nautilus_point_in_allocation (const GtkAllocation *allocation, int x, int y); + +void nautilus_gtk_widget_set_font (GtkWidget *widget, + GdkFont *font); + +void nautilus_gtk_widget_set_font_by_name (GtkWidget *widget, + const char *font_name); + gboolean nautilus_point_in_widget (GtkWidget *widget, int x, int y); |