Re: gnome-font-picker patch
- From: shunter bigsky net
- To: gnome-devel-list gnome org
- Cc: baulig suse de, odaf next es
- Subject: Re: gnome-font-picker patch
- Date: Tue, 5 Sep 2000 09:36:49 -0600
Doh...
Here's the patch.
> Here's the gnome-font-picker patch I mentioned on gnome-1.4-list.
>
> From the brief discussion there, I gather its not appropriate
> for gnome 1.4 since the plan is complete compatibility.
>
> I'm posting this anyway. Perhaps it can be applied for gnome 2.0.
Sorry, Sam
--- gnome-libs-1.2.4.orig/libgnomeui/gnome-font-picker.c Sun Aug 20 19:30:04 2000
+++ gnome-libs-1.2.4/libgnomeui/gnome-font-picker.c Mon Aug 21 18:20:32 2000
@@ -31,6 +31,7 @@
#include "libgnomeui/gnome-window-icon.h"
#include "gnome-font-picker.h"
#include <libgnome/gnome-i18n.h>
+#include <glib.h>
#include <string.h>
#include <stdio.h>
@@ -87,7 +88,7 @@
void gnome_font_picker_label_use_font_in_label (GnomeFontPicker *gfs);
void gnome_font_picker_update_font_info(GnomeFontPicker *gfs);
-
+static char **copy_strv (char **vec);
static guint font_picker_signals[LAST_SIGNAL] = { 0 };
@@ -95,6 +96,19 @@
static GtkButtonClass *parent_class;
+typedef struct GnomeFontPickerFilter
+{
+ GtkFontFilterType filter_type;
+ GtkFontType font_type;
+ gchar** foundries;
+ gchar** weights;
+ gchar** slants;
+ gchar** setwidths;
+ gchar** spacings;
+ gchar** charsets;
+} GnomeFontPickerFilter;
+
+
GtkType
gnome_font_picker_get_type (void)
{
@@ -562,6 +576,80 @@
} /* gnome_font_picker_set_preview_text */
+/**
+ * gnome_font_picker_set_filter
+ * @gfp: Pointer to GNOME font picker widget.
+ * @filter_type: which of the two font filters to set, either
+ * GTK_FONT_FILTER_BASE or GTK_FONT_FILTER_USER. The user filter
+ * can be changed by the user, but the base filter is permanent.
+ * @font_type: the types of font to be shown. This is a bitwise
+ * combination of GTK_FONT_BITMAP, GTK_FONT_SCALABLE and
+ * GTK_FONT_SCALABLE_BITMAP, or GTK_FONT_ALL to show all three
+ * font types.
+ * @foundries: a NULL-terminated array of strings containing foundry
+ * names which will be shown, or NULL to show all foundries.
+ * @weights: a NULL-terminated array of strings containing weight
+ * names which will be shown, or NULL to show all weights.
+ * @slants: a NULL-terminated array of strings containing slant
+ * names which will be shown, or NULL to show all slants.
+ * @setwidths: a NULL-terminated array of strings containing setwidth
+ * names which will be shown, or NULL to show all setwidths.
+ * @spacings: a NULL-terminated array of strings containing spacings
+ * which will be shown, or NULL to show all spacings.
+ * @charsets: a NULL-terminated array of strings containing charset
+ * names which will be shown, or NULL to show all charsets.
+ *
+ * Description:
+ * Sets filter for font selection dialog if one is being displayed,
+ * and stores filter options in dialog has not yet been displayed.
+ */
+void gnome_font_picker_set_filter (GnomeFontPicker *gfp,
+ GtkFontFilterType filter_type,
+ GtkFontType font_type,
+ gchar **foundries,
+ gchar **weights,
+ gchar **slants,
+ gchar **setwidths,
+ gchar **spacings,
+ gchar **charsets)
+{
+ GtkFontSelectionDialog *font_dialog = NULL;
+ GnomeFontPickerFilter *filter =
+ g_new0 (GnomeFontPickerFilter, 1);
+
+ filter->filter_type = filter_type;
+ filter->font_type = font_type;
+ filter->foundries = copy_strv (foundries);
+ filter->weights = copy_strv (weights);
+ filter->slants = copy_strv (slants);
+ filter->setwidths = copy_strv (setwidths);
+ filter->spacings = copy_strv (spacings);
+ filter->charsets = copy_strv (charsets);
+
+ gtk_object_set_data_full (GTK_OBJECT (gfp),
+ "FONT_DIALOG_FILTER",
+ filter,
+ g_free);
+
+ /* quash warning about NULL cast */
+ if (GNOME_FONT_PICKER (gfp)->font_dialog) {
+ font_dialog = GTK_FONT_SELECTION_DIALOG (
+ GNOME_FONT_PICKER (gfp)->font_dialog);
+ }
+
+ if ( font_dialog ) {
+ gtk_font_selection_dialog_set_filter (font_dialog,
+ filter_type,
+ font_type,
+ foundries,
+ weights,
+ slants,
+ setwidths,
+ spacings,
+ charsets);
+ }
+} /* gnome_font_picker_set_filter */
+
/* ************************************************************************
Internal functions
**************************************************************************/
@@ -582,7 +670,8 @@
{
GnomeFontPicker *gfp;
GtkFontSelectionDialog *fsd;
-
+ GnomeFontPickerFilter *filter;
+
gfp = GNOME_FONT_PICKER(button);
if (!gfp->font_dialog) {
@@ -607,6 +696,21 @@
(GtkSignalFunc) gnome_font_picker_dialog_destroy,
gfp);
+ filter = (GnomeFontPickerFilter*)
+ gtk_object_get_data (GTK_OBJECT (button),
+ "FONT_DIALOG_FILTER");
+
+ if (filter) {
+ gtk_font_selection_dialog_set_filter (fsd,
+ filter->filter_type,
+ filter->font_type,
+ filter->foundries,
+ filter->weights,
+ filter->slants,
+ filter->setwidths,
+ filter->spacings,
+ filter->charsets);
+ }
} /* if */
if (!GTK_WIDGET_VISIBLE(gfp->font_dialog)) {
@@ -842,3 +946,13 @@
g_free(pTmp);
} /* gnome_font_picker_update_font_info */
+
+
+static char **copy_strv (char **vec)
+{
+ if (!vec) {
+ return NULL;
+ }
+
+ return g_copy_vector (vec);
+}
--- gnome-libs-1.2.4.orig/libgnomeui/gnome-font-picker.h Sun Aug 20 19:30:04 2000
+++ gnome-libs-1.2.4/libgnomeui/gnome-font-picker.h Sun Aug 20 19:34:35 2000
@@ -116,6 +116,15 @@
void gnome_font_picker_set_preview_text (GnomeFontPicker *gfp,
const gchar *text);
+void gnome_font_picker_set_filter (GnomeFontPicker *gfp,
+ GtkFontFilterType filter_type,
+ GtkFontType font_type,
+ gchar **foundries,
+ gchar **weights,
+ gchar **slants,
+ gchar **setwidths,
+ gchar **spacings,
+ gchar **charsets);
END_GNOME_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]