Commit 70505287 authored by Ramiro Estrugo's avatar Ramiro Estrugo

Tasks: 1612, 1274, 1511 and 1588.

	* libnautilus-extensions/nautilus-scalable-font.c:
	* libnautilus-extensions/nautilus-scalable-font.h:

	New GtkObject subclass that provdes a simple interface to raph's
	librsvg FreeType2 bases anti aliased text rendering.

	* libnautilus-extensions/nautilus-font-picker.c:
	* libnautilus-extensions/nautilus-font-picker.h:

	New font picker class.  I will soon use it in the preferences
	dialog instead of the current one.

	* libnautilus-extensions/nautilus-buffered-widget.c:
	* libnautilus-extensions/nautilus-buffered-widget.h:

	New virtual widget class that encapsulates the details of finding
	a suitable background for compositing pixbufs.

	* libnautilus-extensions/nautilus-image.c:
	* libnautilus-extensions/nautilus-image.h:

	Rewritten NautilusImage class.  Took out all the label stuff,
	which lives in its own class.  Now subclassed from
	NautilusBufferedWidget so that background the image gets
	composited on is always correct and groks NautilusBackground.

	* libnautilus-extensions/nautilus-label.c:
	* libnautilus-extensions/nautilus-label.h:

	New NautilusLabel widget class.  A label widget that is capable of
	displaying anti aliased text composited over a complex background.

	The background can be installed as NautilusBackground on a
	NautilusLabel widget or any of its ancestors.  The best background
	will automatically be found and used by the widget.

	* services/nautilus-dependant-shared/shared-service-widgets.c,
	* services/nautilus-dependant-shared/shared-service-widgets.h,
	* services/startup/nautilus-view/nautilus-service-startup-view.c:

	Update for changes in the NautilusImage api.  Unfortunately, these
	components are slightly broken now cause of the NautilusImage
	changes.  I will fix them shortly.

	* libnautilus-extensions/nautilus-string-map.c:
	* libnautilus-extensions/nautilus-string-map.h:

	New simple class to map an arbitrary number of strings to a single
	string.

	* libnautilus-extensions/nautilus-lib-self-check-functions.h:
	Add tests for the new string map class.

	* libnautilus-extensions/Makefile.am:

	Build the new widgets.  Also add some depedencies on the static
	libraries we link into this beast.  This way,
	libnautilus-extensions will rebuild of one if its dependency
	static libs is touched.

	* test/.cvsignore,
	* test/Makefile.am,
	* test/test-nautilus-font-picker.c,
	* test/test-nautilus-font.c,
	* test/test-nautilus-image.c,
	* test/test-nautilus-label.c:

	Update test programs for new widgets.
parent 0198de15
2000-08-21 Ramiro Estrugo <ramiro@eazel.com>
Tasks: 1612, 1274, 1511 and 1588.
* libnautilus-extensions/nautilus-scalable-font.c:
* libnautilus-extensions/nautilus-scalable-font.h:
New GtkObject subclass that provdes a simple interface to raph's
librsvg FreeType2 bases anti aliased text rendering.
* libnautilus-extensions/nautilus-font-picker.c:
* libnautilus-extensions/nautilus-font-picker.h:
New font picker class. I will soon use it in the preferences
dialog instead of the current one.
* libnautilus-extensions/nautilus-buffered-widget.c:
* libnautilus-extensions/nautilus-buffered-widget.h:
New virtual widget class that encapsulates the details of finding
a suitable background for compositing pixbufs.
* libnautilus-extensions/nautilus-image.c:
* libnautilus-extensions/nautilus-image.h:
Rewritten NautilusImage class. Took out all the label stuff,
which lives in its own class. Now subclassed from
NautilusBufferedWidget so that background the image gets
composited on is always correct and groks NautilusBackground.
* libnautilus-extensions/nautilus-label.c:
* libnautilus-extensions/nautilus-label.h:
New NautilusLabel widget class. A label widget that is capable of
displaying anti aliased text composited over a complex background.
The background can be installed as NautilusBackground on a
NautilusLabel widget or any of its ancestors. The best background
will automatically be found and used by the widget.
* services/nautilus-dependant-shared/shared-service-widgets.c,
* services/nautilus-dependant-shared/shared-service-widgets.h,
* services/startup/nautilus-view/nautilus-service-startup-view.c:
Update for changes in the NautilusImage api. Unfortunately, these
components are slightly broken now cause of the NautilusImage
changes. I will fix them shortly.
* libnautilus-extensions/nautilus-string-map.c:
* libnautilus-extensions/nautilus-string-map.h:
New simple class to map an arbitrary number of strings to a single
string.
* libnautilus-extensions/nautilus-lib-self-check-functions.h:
Add tests for the new string map class.
* libnautilus-extensions/Makefile.am:
Build the new widgets. Also add some depedencies on the static
libraries we link into this beast. This way,
libnautilus-extensions will rebuild of one if its dependency
static libs is touched.
* test/.cvsignore,
* test/Makefile.am,
* test/test-nautilus-font-picker.c,
* test/test-nautilus-font.c,
* test/test-nautilus-image.c,
* test/test-nautilus-label.c:
Update test programs for new widgets.
2000-08-21 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-background.c:
......
......@@ -41,13 +41,12 @@
/* Ramiro's very cool generic image widget */
GtkWidget*
create_image_widget (const char *icon_name,
const char *background_color_spec,
NautilusImagePlacementType placement) {
const char *background_color_spec)
{
char *path;
GtkWidget *image;
GdkPixbuf *pixbuf;
guint32 background_rgb;
/* guint32 background_rgb;*/
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (background_color_spec != NULL, NULL);
......@@ -67,15 +66,13 @@ create_image_widget (const char *icon_name,
g_warning ("Could not find the requested icon.");
}
nautilus_image_set_background_type (NAUTILUS_IMAGE (image),
NAUTILUS_IMAGE_BACKGROUND_SOLID);
background_rgb = nautilus_parse_rgb_with_white_default (background_color_spec);
/* nautilus_image_set_background_type (NAUTILUS_IMAGE (image),*/
/* NAUTILUS_IMAGE_BACKGROUND_SOLID);*/
nautilus_image_set_background_color (NAUTILUS_IMAGE (image),
background_rgb);
/* background_rgb = nautilus_parse_rgb_with_white_default (background_color_spec);*/
nautilus_image_set_placement_type (NAUTILUS_IMAGE (image), placement);
/* nautilus_image_set_background_color (NAUTILUS_IMAGE (image),*/
/* background_rgb);*/
return image;
......@@ -90,33 +87,30 @@ create_services_title_widget (const char *title_text) {
GtkWidget *logo_image;
GtkWidget *filler_image;
GtkWidget *text_image;
GdkFont *font;
/* GdkFont *font;*/
g_assert (title_text != NULL);
title_hbox = gtk_hbox_new (FALSE, 0);
logo_image = create_image_widget ("eazel-services-logo.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_CENTER);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
filler_image = create_image_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_TILE);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
text_image = create_image_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_TILE);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
font = nautilus_font_factory_get_font_by_family ("helvetica", 20);
/* font = nautilus_font_factory_get_font_by_family ("helvetica", 20);*/
nautilus_image_set_label_text (NAUTILUS_IMAGE (text_image), title_text);
nautilus_image_set_label_font (NAUTILUS_IMAGE (text_image), font);
nautilus_image_set_extra_width (NAUTILUS_IMAGE (text_image), 8);
nautilus_image_set_right_offset (NAUTILUS_IMAGE (text_image), 8);
nautilus_image_set_top_offset (NAUTILUS_IMAGE (text_image), 3);
/* nautilus_image_set_label_text (NAUTILUS_IMAGE (text_image), title_text); */
/* nautilus_image_set_label_font (NAUTILUS_IMAGE (text_image), font); */
/* nautilus_image_set_extra_width (NAUTILUS_IMAGE (text_image), 8);*/
/* nautilus_image_set_right_offset (NAUTILUS_IMAGE (text_image), 8);*/
/* nautilus_image_set_top_offset (NAUTILUS_IMAGE (text_image), 3);*/
gdk_font_unref (font);
/* gdk_font_unref (font);*/
gtk_widget_show (logo_image);
gtk_widget_show (filler_image);
......@@ -140,7 +134,7 @@ create_services_header_widget (const char *left_text,
GtkWidget *left_image;
GtkWidget *right_image;
GtkWidget *filler_image;
GdkFont *font;
/* GdkFont *font;*/
g_assert (left_text != NULL);
g_assert (right_text != NULL);
......@@ -148,34 +142,31 @@ create_services_header_widget (const char *left_text,
title_hbox = gtk_hbox_new (FALSE, 0);
left_image = create_image_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_TILE);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
filler_image = create_image_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_TILE);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
right_image = create_image_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_TILE);
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
font = nautilus_font_factory_get_font_by_family ("helvetica", 18);
/* font = nautilus_font_factory_get_font_by_family ("helvetica", 18);*/
nautilus_image_set_label_text (NAUTILUS_IMAGE (left_image), left_text);
nautilus_image_set_label_font (NAUTILUS_IMAGE (left_image), font);
/* nautilus_image_set_label_text (NAUTILUS_IMAGE (left_image), left_text); */
/* nautilus_image_set_label_font (NAUTILUS_IMAGE (left_image), font); */
nautilus_image_set_extra_width (NAUTILUS_IMAGE (left_image), 8);
nautilus_image_set_left_offset (NAUTILUS_IMAGE (left_image), 8);
nautilus_image_set_top_offset (NAUTILUS_IMAGE (left_image), 1);
/* nautilus_image_set_extra_width (NAUTILUS_IMAGE (left_image), 8);*/
/* nautilus_image_set_left_offset (NAUTILUS_IMAGE (left_image), 8);*/
/* nautilus_image_set_top_offset (NAUTILUS_IMAGE (left_image), 1);*/
nautilus_image_set_label_text (NAUTILUS_IMAGE (right_image), right_text);
nautilus_image_set_label_font (NAUTILUS_IMAGE (right_image), font);
/* nautilus_image_set_label_text (NAUTILUS_IMAGE (right_image), right_text); */
/* nautilus_image_set_label_font (NAUTILUS_IMAGE (right_image), font); */
nautilus_image_set_extra_width (NAUTILUS_IMAGE (right_image), 8);
nautilus_image_set_right_offset (NAUTILUS_IMAGE (right_image), 8);
nautilus_image_set_top_offset (NAUTILUS_IMAGE (right_image), 1);
/* nautilus_image_set_extra_width (NAUTILUS_IMAGE (right_image), 8);*/
/* nautilus_image_set_right_offset (NAUTILUS_IMAGE (right_image), 8);*/
/* nautilus_image_set_top_offset (NAUTILUS_IMAGE (right_image), 1);*/
gdk_font_unref (font);
/* gdk_font_unref (font);*/
gtk_widget_show (left_image);
gtk_widget_show (filler_image);
......
......@@ -33,8 +33,7 @@
#define SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF"
GtkWidget* create_image_widget (const char *icon_name,
const char *background_color_spec,
NautilusImagePlacementType placement);
const char *background_color_spec);
GtkWidget* create_services_title_widget (const char *title_text);
GtkWidget* create_services_header_widget (const char *left_text,
const char *right_text);
......
......@@ -106,8 +106,7 @@ generate_startup_form (NautilusServiceStartupView *view)
gtk_widget_show (temp_box);
temp_widget = create_image_widget ("service-watch.png",
STARTUP_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_CENTER);
STARTUP_VIEW_DEFAULT_BACKGROUND_COLOR);
g_assert (temp_widget != NULL);
gtk_box_pack_start (GTK_BOX (temp_box), temp_widget, 0, 0, 8);
......@@ -174,8 +173,7 @@ generate_form_logo (NautilusServiceStartupView *view) {
gtk_box_pack_start (GTK_BOX (view->details->form), logo_container, 0, 0, 4);
logo_widget = create_image_widget ("startup-logo.png",
STARTUP_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_IMAGE_PLACEMENT_CENTER);
STARTUP_VIEW_DEFAULT_BACKGROUND_COLOR);
g_assert (logo_widget != NULL);
......
......@@ -21,11 +21,15 @@ INCLUDES = \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
$(NULL)
libnautilus_extensions_la_LDFLAGS= \
dependency_static_libs =\
$(top_builddir)/cut-n-paste-code/widgets/e-paned/libe-paned.la \
$(top_builddir)/cut-n-paste-code/widgets/nautilus-druid/libnautilus-druid.la \
$(top_builddir)/librsvg/librsvg.la \
$(top_builddir)/cut-n-paste-code/freetype/libfreetype2.la \
$(NULL)
libnautilus_extensions_la_LDFLAGS= \
$(dependency_static_libs) \
$(GNOME_LIBS) \
$(GNOMECANVASPIXBUF_LIBS) \
$(OAF_LIBS) \
......@@ -44,6 +48,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-background.c \
nautilus-bonobo-extensions.c \
nautilus-bookmark.c \
nautilus-buffered-widget.c \
nautilus-caption-table.c \
nautilus-caption.c \
nautilus-debug.c \
......@@ -58,6 +63,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-file-utilities.c \
nautilus-file.c \
nautilus-font-factory.c \
nautilus-font-picker.c \
nautilus-gdk-extensions.c \
nautilus-gdk-pixbuf-extensions.c \
nautilus-generous-bin.c \
......@@ -74,6 +80,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-icon-text-item.c \
nautilus-image.c \
nautilus-keep-last-vertical-box.c \
nautilus-label.c \
nautilus-lib-self-check-functions.c \
nautilus-link-set.c \
nautilus-link.c \
......@@ -91,23 +98,25 @@ libnautilus_extensions_la_SOURCES = \
nautilus-program-chooser.c \
nautilus-program-choosing.c \
nautilus-radio-button-group.c \
nautilus-scalable-font.c \
nautilus-search-bar-criterion.c \
nautilus-search-uri.c \
nautilus-self-checks.c \
nautilus-stock-dialogs.c \
nautilus-string-list.c \
nautilus-string-map.c \
nautilus-string-picker.c \
nautilus-string.c \
nautilus-text-caption.c \
nautilus-trash-directory.c \
nautilus-theme.c \
nautilus-trash-directory.c \
nautilus-undo-context.c \
nautilus-undo-manager.c \
nautilus-undo-signal-handlers.c \
nautilus-user-level-manager.c \
nautilus-vfs-directory.c \
nautilus-view-identifier.c \
nautilus-volume-monitor.c \
nautilus-vfs-directory.c \
nautilus-xml-extensions.c \
$(NULL)
......@@ -118,24 +127,26 @@ noinst_HEADERS = \
nautilus-background.h \
nautilus-bonobo-extensions.h \
nautilus-bookmark.h \
nautilus-caption.h \
nautilus-buffered-widget.h \
nautilus-caption-table.h \
nautilus-caption.h \
nautilus-cdrom-extensions.h \
nautilus-debug.h \
nautilus-default-file-icon.h \
nautilus-directory-background.h \
nautilus-directory.h \
nautilus-directory-metafile.h \
nautilus-directory-notify.h \
nautilus-directory-private.h \
nautilus-directory.h \
nautilus-drag.h \
nautilus-entry.h \
nautilus-file-attributes.h \
nautilus-file-changes-queue.h \
nautilus-file.h \
nautilus-file-private.h \
nautilus-file-utilities.h \
nautilus-file.h \
nautilus-font-factory.h \
nautilus-font-picker.h \
nautilus-gdk-extensions.h \
nautilus-gdk-pixbuf-extensions.h \
nautilus-generous-bin.h \
......@@ -155,9 +166,10 @@ noinst_HEADERS = \
nautilus-image.h \
nautilus-iso9660.h \
nautilus-keep-last-vertical-box.h \
nautilus-label.h \
nautilus-lib-self-check-functions.h \
nautilus-link.h \
nautilus-link-set.h \
nautilus-link.h \
nautilus-list-column-title.h \
nautilus-list.h \
nautilus-metadata.h \
......@@ -167,20 +179,22 @@ noinst_HEADERS = \
nautilus-preferences-box.h \
nautilus-preferences-dialog.h \
nautilus-preferences-group.h \
nautilus-preferences.h \
nautilus-preferences-item.h \
nautilus-preferences-pane.h \
nautilus-preferences.h \
nautilus-program-chooser.h \
nautilus-program-choosing.h \
nautilus-radio-button-group.h \
nautilus-scalable-font.h \
nautilus-search-bar-criterion-private.h \
nautilus-search-bar-criterion.h \
nautilus-search-uri.h \
nautilus-search-bar-criterion-private.h \
nautilus-self-checks.h \
nautilus-stock-dialogs.h \
nautilus-string.h \
nautilus-string-list.h \
nautilus-string-map.h \
nautilus-string-picker.h \
nautilus-string.h \
nautilus-text-caption.h \
nautilus-theme.h \
nautilus-trash-directory.h \
......@@ -193,3 +207,5 @@ noinst_HEADERS = \
nautilus-volume-monitor.h \
nautilus-xml-extensions.h \
$(NULL)
$(lib_LTLIBRARIES): $(dependency_static_libs)
This diff is collapsed.
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-buffered-widget.h - A buffered widget for alpha compositing.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: Ramiro Estrugo <ramiro@eazel.com>
*/
/* NautilusBufferedWidget is a virtual widget class that encapsulates the
* details of finding a suitable background for compositing pixbufs.
* The background can be installed as NautilusBackground on a NautilusImage
* widget or any of its ancestors.
*
* The background can also be that provided by the GtkStyle attatched to the
* widget.
*
* The best background will automatically be found and used by the widget.
*
* Also, a tile_pixbuf can be installed to create tiling effects on top of
* the default background.
*/
#ifndef NAUTILUS_BUFFERED_WIDGET_H
#define NAUTILUS_BUFFERED_WIDGET_H
#include <gtk/gtkmisc.h>
#include <libgnome/gnome-defs.h>
#include <libnautilus-extensions/nautilus-scalable-font.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
BEGIN_GNOME_DECLS
#define NAUTILUS_TYPE_BUFFERED_WIDGET (nautilus_buffered_widget_get_type ())
#define NAUTILUS_BUFFERED_WIDGET(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BUFFERED_WIDGET, NautilusBufferedWidget))
#define NAUTILUS_BUFFERED_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BUFFERED_WIDGET, NautilusBufferedWidgetClass))
#define NAUTILUS_IS_BUFFERED_WIDGET(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BUFFERED_WIDGET))
#define NAUTILUS_IS_BUFFERED_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BUFFERED_WIDGET))
typedef struct _NautilusBufferedWidget NautilusBufferedWidget;
typedef struct _NautilusBufferedWidgetClass NautilusBufferedWidgetClass;
typedef struct _NautilusBufferedWidgetDetail NautilusBufferedWidgetDetail;
struct _NautilusBufferedWidget
{
/* Superclass */
GtkMisc misc;
/* Private things */
NautilusBufferedWidgetDetail *detail;
};
struct _NautilusBufferedWidgetClass
{
GtkMiscClass parent_class;
void (*render_buffer_pixbuf) (NautilusBufferedWidget *buffered_widget, GdkPixbuf *buffer);
};
GtkType nautilus_buffered_widget_get_type (void);
void nautilus_buffered_widget_clear_buffer (NautilusBufferedWidget *buffered_widget);
void nautilus_buffered_widget_set_tile_pixbuf (NautilusBufferedWidget *image,
GdkPixbuf *pixbuf);
GdkPixbuf* nautilus_buffered_widget_get_tile_pixbuf (const NautilusBufferedWidget *image);
END_GNOME_DECLS
#endif /* NAUTILUS_BUFFERED_WIDGET_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-font-picker.c - A simple widget to select scalable fonts.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: Ramiro Estrugo <ramiro@eazel.com>
*/
#include <config.h>
#include "nautilus-font-picker.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-string-picker.h"
#include "nautilus-string.h"
#include <gtk/gtklabel.h>
#include <gtk/gtkentry.h>
static const gint FONT_PICKER_SPACING = 10;
/* Signals */
typedef enum
{
SELECTED_FONT_CHANGED,
LAST_SIGNAL
} FontPickerSignals;
struct _NautilusFontPickerDetail
{
GtkWidget *family_picker;
GtkWidget *weight_picker;
GtkWidget *slant_picker;
GtkWidget *set_width_picker;
NautilusStringList *weight_list;
NautilusStringList *slant_list;
NautilusStringList *set_width_list;
};
/* NautilusFontPickerClass methods */
static void nautilus_font_picker_initialize_class (NautilusFontPickerClass *klass);
static void nautilus_font_picker_initialize (NautilusFontPicker *font_picker);
/* GtkObjectClass methods */
static void nautilus_font_picker_destroy (GtkObject *object);
static void family_picker_changed_callback (GtkWidget *string_picker,
gpointer user_data);
static void weight_picker_changed_callback (GtkWidget *string_picker,
gpointer user_data);
static void slant_picker_changed_callback (GtkWidget *string_picker,
gpointer user_data);
static void set_width_picker_changed_callback (GtkWidget *string_picker,
gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFontPicker, nautilus_font_picker, GTK_TYPE_HBOX)
static guint font_picker_signals[LAST_SIGNAL] = { 0 };
/*
* NautilusFontPickerClass methods
*/
static void
nautilus_font_picker_initialize_class (NautilusFontPickerClass *font_picker_class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (font_picker_class);
widget_class = GTK_WIDGET_CLASS (font_picker_class);
/* GtkObjectClass */
object_class->destroy = nautilus_font_picker_destroy;
/* Signals */
font_picker_signals[SELECTED_FONT_CHANGED] = gtk_signal_new ("selected_font_changed",
GTK_RUN_LAST,
object_class->type,
0,
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE,
0);
gtk_object_class_add_signals (object_class, font_picker_signals, LAST_SIGNAL);
}
static void
nautilus_font_picker_initialize (NautilusFontPicker *font_picker)
{
NautilusStringList *family_list;
font_picker->detail = g_new (NautilusFontPickerDetail, 1);
font_picker->detail->weight_list = NULL;
font_picker->detail->slant_list = NULL;
font_picker->detail->set_width_list = NULL;
gtk_box_set_homogeneous (GTK_BOX (font_picker), FALSE);
gtk_box_set_spacing (GTK_BOX (font_picker), FONT_PICKER_SPACING);
font_picker->detail->family_picker = nautilus_string_picker_new ();
font_picker->detail->weight_picker = nautilus_string_picker_new ();
font_picker->detail->slant_picker = nautilus_string_picker_new ();
font_picker->detail->set_width_picker = nautilus_string_picker_new ();
gtk_box_pack_start (GTK_BOX (font_picker), font_picker->detail->family_picker, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (font_picker), font_picker->detail->weight_picker, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (font_picker), font_picker->detail->slant_picker, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (font_picker), font_picker->detail->set_width_picker, TRUE, TRUE, 0);
nautilus_caption_set_title_label (NAUTILUS_CAPTION (font_picker->detail->family_picker), _("Font"));
nautilus_caption_set_show_title (NAUTILUS_CAPTION (font_picker->detail->family_picker), FALSE);
nautilus_caption_set_show_title (NAUTILUS_CAPTION (font_picker->detail->weight_picker), FALSE);
nautilus_caption_set_show_title (NAUTILUS_CAPTION (font_picker->detail->slant_picker), FALSE);
nautilus_caption_set_show_title (NAUTILUS_CAPTION (font_picker->detail->set_width_picker), FALSE);
family_list = nautilus_scalable_font_get_font_family_list ();
nautilus_string_list_sort (family_list);
/* FIXME: Need to deal with possiblity of there being no fonts */
g_assert (family_list != NULL);
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (font_picker->detail->family_picker),
family_list);
nautilus_string_list_free (family_list);
gtk_signal_connect (GTK_OBJECT (font_picker->detail->family_picker),
"changed",
GTK_SIGNAL_FUNC (family_picker_changed_callback),
font_picker);
gtk_signal_connect (GTK_OBJECT (font_picker->detail->weight_picker),
"changed",
GTK_SIGNAL_FUNC (weight_picker_changed_callback),
font_picker);
gtk_signal_connect (GTK_OBJECT (font_picker->detail->slant_picker),
"changed",
GTK_SIGNAL_FUNC (slant_picker_changed_callback),
font_picker);
gtk_signal_connect (GTK_OBJECT (font_picker->detail->set_width_picker),
"changed",
GTK_SIGNAL_FUNC (set_width_picker_changed_callback),
font_picker);
gtk_widget_show (font_picker->detail->family_picker);
gtk_widget_show (font_picker->detail->weight_picker);
gtk_widget_show (font_picker->detail->slant_picker);
gtk_widget_show (font_picker->detail->set_width_picker);
family_picker_changed_callback (font_picker->detail->family_picker, font_picker);
}
/* GtkObjectClass methods */
static void
nautilus_font_picker_destroy (GtkObject* object)
{
NautilusFontPicker * font_picker;
g_return_if_fail (object != NULL);
g_return_if_fail (NAUTILUS_IS_FONT_PICKER (object));
font_picker = NAUTILUS_FONT_PICKER (object);
nautilus_string_list_free (font_picker->detail->weight_list);
nautilus_string_list_free (font_picker->detail->slant_list);
nautilus_string_list_free (font_picker->detail->set_width_list);
g_free (font_picker->detail);
/* Chain */
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
static void
font_picker_update_weight_picker (NautilusFontPicker *font_picker)
{
NautilusStringList *unique_weight_list;
char *family;
g_return_if_fail (NAUTILUS_IS_FONT_PICKER (font_picker));
family = nautilus_string_picker_get_selected_string (NAUTILUS_STRING_PICKER (font_picker->detail->family_picker));
unique_weight_list = nautilus_string_list_new_from_string_list (font_picker->detail->weight_list);
nautilus_string_list_sort (unique_weight_list);
nautilus_string_list_remove_duplicates (unique_weight_list);
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (font_picker->detail->weight_picker),
unique_weight_list);
nautilus_string_list_free (unique_weight_list);
g_free (family);
}
static void
font_picker_update_slant_picker (NautilusFontPicker *font_picker)
{
NautilusStringList *unique_slant_list;
char *current_family;
char *current_weight;
guint i;
g_return_if_fail (NAUTILUS_IS_FONT_PICKER (font_picker));
current_family = nautilus_string_picker_get_selected_string (NAUTILUS_STRING_PICKER (font_picker->detail->family_picker));
current_weight = nautilus_string_picker_get_selected_string (NAUTILUS_STRING_PICKER (font_picker->detail->weight_picker));
g_assert (nautilus_string_list_get_length (font_picker->detail->slant_list) ==
nautilus_string_list_get_length (font_picker->detail->weight_list));
unique_slant_list = nautilus_string_list_new ();