Compare commits
126 Commits
message-wi
...
font-choos
Author | SHA1 | Date | |
---|---|---|---|
|
f83b9ff27e | ||
|
06314432f9 | ||
|
8e1bff47fd | ||
|
6e3714b8e1 | ||
|
37db3cb5fd | ||
|
7c7b25244f | ||
|
3b7053fe21 | ||
|
14b5fd9560 | ||
|
647f3dc2c9 | ||
|
21f8714b38 | ||
|
948fa8b9e6 | ||
|
541a2c3efb | ||
|
88096a8a18 | ||
|
c8639c23b3 | ||
|
f4a769d125 | ||
|
c226ab3c9f | ||
|
87ad927167 | ||
|
5cdc9a2ab7 | ||
|
6eb2f4e693 | ||
|
066b5019e9 | ||
|
118ced448b | ||
|
8cdeb75121 | ||
|
c2d1738de4 | ||
|
6658d0d20c | ||
|
935a3e66df | ||
|
b7682cfddb | ||
|
3fb041efb1 | ||
|
1c0d527893 | ||
|
481efc0301 | ||
|
9fcfd6c13e | ||
|
21b6cec5b5 | ||
|
f23f2f9848 | ||
|
33d709f924 | ||
|
b74360964c | ||
|
5449544f3b | ||
|
da7d819988 | ||
|
7fd4f8e16f | ||
|
d5cfd9b834 | ||
|
deebacb9e2 | ||
|
b205dbbaab | ||
|
e3fee235f9 | ||
|
b54298f19c | ||
|
660ae69b4d | ||
|
870d4cbf01 | ||
|
cf2d18747f | ||
|
ed700f6837 | ||
|
48958a5181 | ||
|
ed5494a654 | ||
|
cdc9968777 | ||
|
58b81beeba | ||
|
4d66ae4f4b | ||
|
80be013408 | ||
|
92d9064262 | ||
|
a38ede804c | ||
|
7cd2c0d70e | ||
|
7946d306db | ||
|
dc70a25ec3 | ||
|
2a8a8a7d2e | ||
|
63421eac44 | ||
|
b6b35706dd | ||
|
f8d57aaa6c | ||
|
ebc2d19c7b | ||
|
296b8f8d4c | ||
|
18c87e028b | ||
|
a948585140 | ||
|
3a1c575628 | ||
|
3b44051d5f | ||
|
cbb9486ce4 | ||
|
5b64379acb | ||
|
7058a09701 | ||
|
410a9256ba | ||
|
ddc4aadf68 | ||
|
49dde2ad43 | ||
|
ea8ac647b5 | ||
|
85d66cf37b | ||
|
57c4d55736 | ||
|
3e28775931 | ||
|
92a704284d | ||
|
2bc4391bbf | ||
|
1e7fe46d2f | ||
|
46785d3a57 | ||
|
26388763b6 | ||
|
f3341733e6 | ||
|
de312b55a0 | ||
|
bdb82376e7 | ||
|
9d754d169e | ||
|
49278b053a | ||
|
9e94e59e50 | ||
|
0321e33888 | ||
|
6300c01773 | ||
|
6a50640d2d | ||
|
fd6d1e631e | ||
|
47d02dc2e2 | ||
|
576ccf3885 | ||
|
f70e9727c4 | ||
|
b4bbabc286 | ||
|
9d64d2cce1 | ||
|
91cada6908 | ||
|
27997a64ed | ||
|
b98088495e | ||
|
199dd65f2f | ||
|
01226aeee0 | ||
|
d4d7df93dd | ||
|
bd0685aa9b | ||
|
b893ae4e93 | ||
|
454a5be973 | ||
|
ec6b993391 | ||
|
09f70f0c59 | ||
|
2e74de72df | ||
|
d0160b5815 | ||
|
e12dd430cd | ||
|
d8af8b292b | ||
|
12501f93c9 | ||
|
a77a02ff77 | ||
|
7321b734a8 | ||
|
690e8432f7 | ||
|
972a40c4d6 | ||
|
9a1c2c86b3 | ||
|
3c41785757 | ||
|
5338d4d610 | ||
|
17b425e6ba | ||
|
5f53dc8b83 | ||
|
bc16716250 | ||
|
ad2dcebed7 | ||
|
7199708287 | ||
|
26aa667613 |
@@ -219,6 +219,8 @@
|
||||
<xi:include href="xml/gtkfilechooserwidget.xml" />
|
||||
<xi:include href="xml/gtkfilefilter.xml" />
|
||||
<xi:include href="xml/gtkfontbutton.xml" />
|
||||
<xi:include href="xml/gtkfontchooser.xml" />
|
||||
<xi:include href="xml/gtkfontchooserdlg.xml" />
|
||||
<xi:include href="xml/gtkfontsel.xml" />
|
||||
<xi:include href="xml/gtkfontseldlg.xml" />
|
||||
</chapter>
|
||||
|
@@ -1476,6 +1476,62 @@ GtkFontSelectionDialogPrivate
|
||||
gtk_font_selection_dialog_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfontchooser</FILE>
|
||||
<TITLE>GtkFontChooser</TITLE>
|
||||
GtkFontChooser
|
||||
gtk_font_chooser_new
|
||||
gtk_font_chooser_get_family
|
||||
gtk_font_chooser_get_face
|
||||
gtk_font_chooser_get_size
|
||||
gtk_font_chooser_get_font_name
|
||||
gtk_font_chooser_set_font_name
|
||||
gtk_font_chooser_get_preview_text
|
||||
gtk_font_chooser_set_preview_text
|
||||
gtk_font_chooser_get_show_preview_entry
|
||||
gtk_font_chooser_set_show_preview_entry
|
||||
GtkFontFilterFunc
|
||||
gtk_font_chooser_set_filter_func
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkFontChooserClass
|
||||
GTK_TYPE_FONT_CHOOSER
|
||||
GTK_FONT_CHOOSER
|
||||
GTK_FONT_CHOOSER_CLASS
|
||||
GTK_IS_FONT_CHOOSER
|
||||
GTK_IS_FONT_CHOOSER_CLASS
|
||||
GTK_FONT_CHOOSER_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkFontChooserPrivate
|
||||
gtk_font_chooser_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkfontchooserdlg</FILE>
|
||||
<TITLE>GtkFontChooserDialog</TITLE>
|
||||
GtkFontChooserDialog
|
||||
gtk_font_chooser_dialog_new
|
||||
gtk_font_chooser_dialog_get_font_chooser
|
||||
gtk_font_chooser_dialog_get_font_name
|
||||
gtk_font_chooser_dialog_set_font_name
|
||||
gtk_font_chooser_dialog_get_preview_text
|
||||
gtk_font_chooser_dialog_set_preview_text
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkFontChooserDialogClass
|
||||
GTK_TYPE_FONT_CHOOSER_DIALOG
|
||||
GTK_FONT_CHOOSER_DIALOG
|
||||
GTK_FONT_CHOOSER_DIALOG_CLASS
|
||||
GTK_IS_FONT_CHOOSER_DIALOG
|
||||
GTK_IS_FONT_CHOOSER_DIALOG_CLASS
|
||||
GTK_FONT_CHOOSER_DIALOG_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkFontChooserDialogPrivate
|
||||
gtk_font_chooser_dialog_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkframe</FILE>
|
||||
<TITLE>GtkFrame</TITLE>
|
||||
|
@@ -218,6 +218,8 @@ gtk_public_h_sources = \
|
||||
gtkfixed.h \
|
||||
gtkfontbutton.h \
|
||||
gtkfontsel.h \
|
||||
gtkfontchooser.h \
|
||||
gtkfontchooserdialog.h \
|
||||
gtkframe.h \
|
||||
gtkgradient.h \
|
||||
gtkgrid.h \
|
||||
@@ -548,6 +550,8 @@ gtk_base_c_sources = \
|
||||
gtkfixed.c \
|
||||
gtkfontbutton.c \
|
||||
gtkfontsel.c \
|
||||
gtkfontchooser.c \
|
||||
gtkfontchooserdialog.c \
|
||||
gtkframe.c \
|
||||
gtkgradient.c \
|
||||
gtkgrid.c \
|
||||
|
@@ -101,6 +101,8 @@
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gtk/gtkfontbutton.h>
|
||||
#include <gtk/gtkfontsel.h>
|
||||
#include <gtk/gtkfontchooser.h>
|
||||
#include <gtk/gtkfontchooserdialog.h>
|
||||
#include <gtk/gtkframe.h>
|
||||
#include <gtk/gtkgradient.h>
|
||||
#include <gtk/gtkgrid.h>
|
||||
|
@@ -1034,6 +1034,25 @@ gtk_font_button_set_show_style
|
||||
gtk_font_button_set_title
|
||||
gtk_font_button_set_use_font
|
||||
gtk_font_button_set_use_size
|
||||
gtk_font_chooser_dialog_get_font_chooser
|
||||
gtk_font_chooser_dialog_get_font_name
|
||||
gtk_font_chooser_dialog_get_preview_text
|
||||
gtk_font_chooser_dialog_get_type
|
||||
gtk_font_chooser_dialog_new
|
||||
gtk_font_chooser_dialog_set_font_name
|
||||
gtk_font_chooser_dialog_set_preview_text
|
||||
gtk_font_chooser_get_face
|
||||
gtk_font_chooser_get_family
|
||||
gtk_font_chooser_get_font_name
|
||||
gtk_font_chooser_get_preview_text
|
||||
gtk_font_chooser_get_show_preview_entry
|
||||
gtk_font_chooser_get_size
|
||||
gtk_font_chooser_get_type
|
||||
gtk_font_chooser_new
|
||||
gtk_font_chooser_set_filter_func
|
||||
gtk_font_chooser_set_font_name
|
||||
gtk_font_chooser_set_preview_text
|
||||
gtk_font_chooser_set_show_preview_entry
|
||||
gtk_font_selection_dialog_get_cancel_button
|
||||
gtk_font_selection_dialog_get_font_name
|
||||
gtk_font_selection_dialog_get_font_selection
|
||||
|
@@ -3171,17 +3171,20 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
|
||||
GtkWidget *widget = GTK_WIDGET (entry);
|
||||
GtkAllocation allocation;
|
||||
GtkRequisition requisition;
|
||||
gint req_height;
|
||||
gint frame_height;
|
||||
gint xborder, yborder;
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
_gtk_entry_get_borders (entry, &xborder, &yborder);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
get_frame_size (entry, TRUE, NULL, NULL, NULL, &frame_height);
|
||||
else
|
||||
frame_height = requisition.height;
|
||||
frame_height = req_height;
|
||||
|
||||
if (gtk_widget_has_focus (widget) && !priv->interior_focus)
|
||||
frame_height -= 2 * priv->focus_width;
|
||||
@@ -3190,13 +3193,13 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
|
||||
*x = xborder;
|
||||
|
||||
if (y)
|
||||
*y = frame_height / 2 - (requisition.height - yborder * 2) / 2;
|
||||
*y = frame_height / 2 - (req_height - yborder * 2) / 2;
|
||||
|
||||
if (width)
|
||||
*width = allocation.width - xborder * 2;
|
||||
|
||||
if (height)
|
||||
*height = requisition.height - yborder * 2;
|
||||
*height = req_height - yborder * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3229,8 +3232,12 @@ get_frame_size (GtkEntry *entry,
|
||||
GtkAllocation allocation;
|
||||
GtkRequisition requisition;
|
||||
GtkWidget *widget = GTK_WIDGET (entry);
|
||||
gint req_height;
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
if (x)
|
||||
@@ -3239,9 +3246,9 @@ get_frame_size (GtkEntry *entry,
|
||||
if (y)
|
||||
{
|
||||
if (priv->is_cell_renderer)
|
||||
*y = 0;
|
||||
*y = 0;
|
||||
else
|
||||
*y = (allocation.height - requisition.height) / 2;
|
||||
*y = (allocation.height - req_height) / 2;
|
||||
|
||||
if (relative_to_window)
|
||||
*y += allocation.y;
|
||||
@@ -3253,9 +3260,9 @@ get_frame_size (GtkEntry *entry,
|
||||
if (height)
|
||||
{
|
||||
if (priv->is_cell_renderer)
|
||||
*height = allocation.height;
|
||||
*height = allocation.height;
|
||||
else
|
||||
*height = requisition.height;
|
||||
*height = req_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include "gtkmain.h"
|
||||
#include "gtkhbox.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkfontsel.h"
|
||||
#include "gtkfontchooserdialog.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkseparator.h"
|
||||
@@ -46,12 +46,12 @@
|
||||
|
||||
/**
|
||||
* SECTION:gtkfontbutton
|
||||
* @Short_description: A button to launch a font selection dialog
|
||||
* @Short_description: A button to launch a font chooser dialog
|
||||
* @Title: GtkFontButton
|
||||
* @See_also: #GtkFontSelectionDialog, #GtkColorButton.
|
||||
* @See_also: #GtkFontChooserDialog, #GtkColorButton.
|
||||
*
|
||||
* The #GtkFontButton is a button which displays the currently selected
|
||||
* font an allows to open a font selection dialog to change the font.
|
||||
* font an allows to open a font chooser dialog to change the font.
|
||||
* It is suitable widget for selecting a font in a preference dialog.
|
||||
*/
|
||||
|
||||
@@ -105,9 +105,8 @@ static void gtk_font_button_set_property (GObject *object,
|
||||
static void gtk_font_button_clicked (GtkButton *button);
|
||||
|
||||
/* Dialog response functions */
|
||||
static void dialog_ok_clicked (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void dialog_cancel_clicked (GtkWidget *widget,
|
||||
static void response_cb (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
gpointer data);
|
||||
static void dialog_destroy (GtkWidget *widget,
|
||||
gpointer data);
|
||||
@@ -141,7 +140,7 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
/**
|
||||
* GtkFontButton:title:
|
||||
*
|
||||
* The title of the font selection dialog.
|
||||
* The title of the font chooser dialog.
|
||||
*
|
||||
* Since: 2.4
|
||||
*/
|
||||
@@ -149,7 +148,7 @@ gtk_font_button_class_init (GtkFontButtonClass *klass)
|
||||
PROP_TITLE,
|
||||
g_param_spec_string ("title",
|
||||
P_("Title"),
|
||||
P_("The title of the font selection dialog"),
|
||||
P_("The title of the font chooser dialog"),
|
||||
_("Pick a Font"),
|
||||
(GTK_PARAM_READABLE |
|
||||
GTK_PARAM_WRITABLE)));
|
||||
@@ -387,7 +386,7 @@ gtk_font_button_new (void)
|
||||
|
||||
/**
|
||||
* gtk_font_button_new_with_font:
|
||||
* @fontname: Name of font to display in font selection dialog
|
||||
* @fontname: Name of font to display in font chooser dialog
|
||||
*
|
||||
* Creates a new font picker widget.
|
||||
*
|
||||
@@ -404,9 +403,9 @@ gtk_font_button_new_with_font (const gchar *fontname)
|
||||
/**
|
||||
* gtk_font_button_set_title:
|
||||
* @font_button: a #GtkFontButton
|
||||
* @title: a string containing the font selection dialog title
|
||||
* @title: a string containing the font chooser dialog title
|
||||
*
|
||||
* Sets the title for the font selection dialog.
|
||||
* Sets the title for the font chooser dialog.
|
||||
*
|
||||
* Since: 2.4
|
||||
*/
|
||||
@@ -432,7 +431,7 @@ gtk_font_button_set_title (GtkFontButton *font_button,
|
||||
* gtk_font_button_get_title:
|
||||
* @font_button: a #GtkFontButton
|
||||
*
|
||||
* Retrieves the title of the font selection dialog.
|
||||
* Retrieves the title of the font chooser dialog.
|
||||
*
|
||||
* Returns: an internal copy of the title string which must not be freed.
|
||||
*
|
||||
@@ -524,7 +523,7 @@ gtk_font_button_get_use_size (GtkFontButton *font_button)
|
||||
*/
|
||||
void
|
||||
gtk_font_button_set_use_size (GtkFontButton *font_button,
|
||||
gboolean use_size)
|
||||
gboolean use_size)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
|
||||
|
||||
@@ -661,12 +660,12 @@ gtk_font_button_get_font_name (GtkFontButton *font_button)
|
||||
/**
|
||||
* gtk_font_button_set_font_name:
|
||||
* @font_button: a #GtkFontButton
|
||||
* @fontname: Name of font to display in font selection dialog
|
||||
* @fontname: Name of font to display in font chooser dialog
|
||||
*
|
||||
* Sets or updates the currently-displayed font in font picker dialog.
|
||||
*
|
||||
* Returns: Return value of gtk_font_selection_dialog_set_font_name() if the
|
||||
* font selection dialog exists, otherwise %FALSE.
|
||||
* Returns: Return value of gtk_font_chooser_dialog_set_font_name() if the
|
||||
* font chooser dialog exists, otherwise %FALSE.
|
||||
*
|
||||
* Since: 2.4
|
||||
*/
|
||||
@@ -690,8 +689,8 @@ gtk_font_button_set_font_name (GtkFontButton *font_button,
|
||||
gtk_font_button_update_font_info (font_button);
|
||||
|
||||
if (font_button->priv->font_dialog)
|
||||
result = gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog),
|
||||
font_button->priv->fontname);
|
||||
result = gtk_font_chooser_dialog_set_font_name (GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog),
|
||||
font_button->priv->fontname);
|
||||
else
|
||||
result = FALSE;
|
||||
|
||||
@@ -703,8 +702,8 @@ gtk_font_button_set_font_name (GtkFontButton *font_button,
|
||||
static void
|
||||
gtk_font_button_clicked (GtkButton *button)
|
||||
{
|
||||
GtkFontSelectionDialog *font_dialog;
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
|
||||
GtkFontChooserDialog *font_dialog;
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
|
||||
|
||||
if (!font_button->priv->font_dialog)
|
||||
{
|
||||
@@ -712,48 +711,50 @@ gtk_font_button_clicked (GtkButton *button)
|
||||
|
||||
parent = gtk_widget_get_toplevel (GTK_WIDGET (font_button));
|
||||
|
||||
font_button->priv->font_dialog = gtk_font_selection_dialog_new (font_button->priv->title);
|
||||
font_button->priv->font_dialog = gtk_font_chooser_dialog_new (font_button->priv->title,
|
||||
NULL);
|
||||
|
||||
font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
|
||||
font_dialog = GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog);
|
||||
|
||||
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
|
||||
{
|
||||
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
|
||||
gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (font_dialog),
|
||||
gtk_window_get_modal (GTK_WINDOW (parent)));
|
||||
}
|
||||
gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (font_dialog),
|
||||
gtk_window_get_modal (GTK_WINDOW (parent)));
|
||||
}
|
||||
|
||||
g_signal_connect (font_dialog, "response",
|
||||
G_CALLBACK (response_cb), font_button);
|
||||
|
||||
g_signal_connect (gtk_font_selection_dialog_get_ok_button (font_dialog), "clicked",
|
||||
G_CALLBACK (dialog_ok_clicked), font_button);
|
||||
g_signal_connect (gtk_font_selection_dialog_get_cancel_button (font_dialog), "clicked",
|
||||
G_CALLBACK (dialog_cancel_clicked), font_button);
|
||||
g_signal_connect (font_dialog, "destroy",
|
||||
G_CALLBACK (dialog_destroy), font_button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (font_button->priv->font_dialog))
|
||||
{
|
||||
font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
|
||||
|
||||
gtk_font_selection_dialog_set_font_name (font_dialog, font_button->priv->fontname);
|
||||
|
||||
font_dialog = GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog);
|
||||
gtk_font_chooser_dialog_set_font_name (font_dialog, font_button->priv->fontname);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dialog_ok_clicked (GtkWidget *widget,
|
||||
gpointer data)
|
||||
response_cb (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (data);
|
||||
|
||||
gtk_widget_hide (font_button->priv->font_dialog);
|
||||
|
||||
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
return;
|
||||
|
||||
g_free (font_button->priv->fontname);
|
||||
font_button->priv->fontname = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog));
|
||||
font_button->priv->fontname = gtk_font_chooser_dialog_get_font_name (GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog));
|
||||
|
||||
/* Set label font */
|
||||
gtk_font_button_update_font_info (font_button);
|
||||
@@ -764,19 +765,9 @@ dialog_ok_clicked (GtkWidget *widget,
|
||||
g_signal_emit (font_button, font_button_signals[FONT_SET], 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dialog_cancel_clicked (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (data);
|
||||
|
||||
gtk_widget_hide (font_button->priv->font_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_destroy (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (data);
|
||||
|
||||
@@ -852,7 +843,7 @@ gtk_font_button_update_font_info (GtkFontButton *font_button)
|
||||
family = pango_font_description_get_family (desc);
|
||||
|
||||
#if 0
|
||||
/* This gives the wrong names, e.g. Italic when the font selection
|
||||
/* This gives the wrong names, e.g. Italic when the font chooser
|
||||
* dialog displayed Oblique.
|
||||
*/
|
||||
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE);
|
||||
|
1332
gtk/gtkfontchooser.c
Normal file
1332
gtk/gtkfontchooser.c
Normal file
File diff suppressed because it is too large
Load Diff
106
gtk/gtkfontchooser.h
Normal file
106
gtk/gtkfontchooser.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __GTK_FONT_CHOOSER_H__
|
||||
#define __GTK_FONT_CHOOSER_H__
|
||||
|
||||
#include <gtk/gtkbox.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
|
||||
#define GTK_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
|
||||
#define GTK_FONT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
|
||||
#define GTK_IS_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
|
||||
#define GTK_IS_FONT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER))
|
||||
#define GTK_FONT_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
|
||||
|
||||
typedef struct _GtkFontChooser GtkFontChooser;
|
||||
typedef struct _GtkFontChooserPrivate GtkFontChooserPrivate;
|
||||
typedef struct _GtkFontChooserClass GtkFontChooserClass;
|
||||
|
||||
struct _GtkFontChooser
|
||||
{
|
||||
GtkBox parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GtkFontChooserPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkFontChooserClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* GtkFontChooser functions.
|
||||
* see the comments in the GtkFontChooserDialog functions.
|
||||
*****************************************************************************/
|
||||
|
||||
GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget* gtk_font_chooser_new (void);
|
||||
PangoFontFamily*
|
||||
gtk_font_chooser_get_family (GtkFontChooser *fontchooser);
|
||||
PangoFontFace*
|
||||
gtk_font_chooser_get_face (GtkFontChooser *fontchooser);
|
||||
gint gtk_font_chooser_get_size (GtkFontChooser *fontchooser);
|
||||
gchar* gtk_font_chooser_get_font_name (GtkFontChooser *fontchooser);
|
||||
|
||||
gboolean gtk_font_chooser_set_font_name (GtkFontChooser *fontchooser,
|
||||
const gchar *fontname);
|
||||
const gchar* gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
|
||||
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
||||
const gchar *text);
|
||||
gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
|
||||
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
||||
gboolean show_preview_entry);
|
||||
|
||||
/**
|
||||
* GtkFontFilterFunc:
|
||||
* @family: a #PangoFontFamily
|
||||
* @face: a #PangoFontFace belonging to @family
|
||||
* @data (closure): user data passed to gtk_font_chooser_set_filter_func()
|
||||
*
|
||||
* The type of function that is used for deciding what fonts get
|
||||
* shown in a #GtkFontChooser. See gtk_font_chooser_set_filter_func().
|
||||
*
|
||||
* Returns: %TRUE if the font should be displayed
|
||||
*/
|
||||
typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
|
||||
const PangoFontFace *face,
|
||||
gpointer data);
|
||||
|
||||
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
|
||||
GtkFontFilterFunc filter,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FONT_CHOOSER_H__ */
|
311
gtk/gtkfontchooserdialog.c
Normal file
311
gtk/gtkfontchooserdialog.c
Normal file
@@ -0,0 +1,311 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atk/atk.h>
|
||||
|
||||
#include "gtkfontchooserdialog.h"
|
||||
#include "gtkfontchooser.h"
|
||||
#include "gtkstock.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidget.h"
|
||||
|
||||
struct _GtkFontChooserDialogPrivate
|
||||
{
|
||||
GtkWidget *fontchooser;
|
||||
|
||||
GtkWidget *select_button;
|
||||
GtkWidget *cancel_button;
|
||||
};
|
||||
|
||||
/**
|
||||
* SECTION:gtkfontchooserdlg
|
||||
* @Short_description: A dialog box for selecting fonts
|
||||
* @Title: GtkFontChooserDialog
|
||||
* @See_also: #GtkFontChooser, #GtkDialog
|
||||
*
|
||||
* The #GtkFontChooserDialog widget is a dialog box for selecting a font.
|
||||
*
|
||||
* To set the font which is initially selected, use
|
||||
* gtk_font_chooser_dialog_set_font_name().
|
||||
*
|
||||
* To get the selected font use gtk_font_chooser_dialog_get_font_name().
|
||||
*
|
||||
* To change the text which is shown in the preview area, use
|
||||
* gtk_font_chooser_dialog_set_preview_text().
|
||||
*
|
||||
* <refsect2 id="GtkFontChooserDialog-BUILDER-UI">
|
||||
* <title>GtkFontChooserDialog as GtkBuildable</title>
|
||||
* The GtkFontChooserDialog implementation of the GtkBuildable interface
|
||||
* exposes the embedded #GtkFontChooser as internal child with the
|
||||
* name "font_chooser". It also exposes the buttons with the names
|
||||
* "select_button" and "cancel_button.
|
||||
* </refsect2>
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
|
||||
static void gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface);
|
||||
static GObject *gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
GtkBuilder *builder,
|
||||
const gchar *childname);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkFontChooserDialog, gtk_font_chooser_dialog, GTK_TYPE_DIALOG,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_font_chooser_dialog_buildable_interface_init))
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
|
||||
static void
|
||||
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
||||
{
|
||||
g_type_class_add_private (klass, sizeof (GtkFontChooserDialogPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
GtkDialog *dialog = GTK_DIALOG (fontchooserdiag);
|
||||
GtkWidget *action_area, *content_area;
|
||||
|
||||
fontchooserdiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontchooserdiag,
|
||||
GTK_TYPE_FONT_CHOOSER_DIALOG,
|
||||
GtkFontChooserDialogPrivate);
|
||||
priv = fontchooserdiag->priv;
|
||||
|
||||
content_area = gtk_dialog_get_content_area (dialog);
|
||||
action_area = gtk_dialog_get_action_area (dialog);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
||||
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
|
||||
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
|
||||
gtk_box_set_spacing (GTK_BOX (action_area), 6);
|
||||
|
||||
gtk_widget_push_composite_child ();
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (fontchooserdiag), TRUE);
|
||||
|
||||
/* Create the content area */
|
||||
priv->fontchooser = gtk_font_chooser_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (priv->fontchooser), 5);
|
||||
gtk_widget_show (priv->fontchooser);
|
||||
gtk_box_pack_start (GTK_BOX (content_area),
|
||||
priv->fontchooser, TRUE, TRUE, 0);
|
||||
|
||||
/* Create the action area */
|
||||
priv->cancel_button = gtk_dialog_add_button (dialog,
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
priv->select_button = gtk_dialog_add_button (dialog,
|
||||
_("Select"),
|
||||
GTK_RESPONSE_OK);
|
||||
gtk_widget_grab_default (priv->select_button);
|
||||
|
||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (fontchooserdiag),
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (fontchooserdiag), _("Font Selection"));
|
||||
|
||||
gtk_widget_pop_composite_child ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_new:
|
||||
* @title: (allow-none): Title of the dialog, or %NULL
|
||||
* @parent: (allow-none): Trasient parent of the dialog, or %NULL
|
||||
*
|
||||
* Creates a new #GtkFontChooserDialog.
|
||||
*
|
||||
* Return value: a new #GtkFontChooserDialog
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_font_chooser_dialog_new (const gchar *title,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
GtkFontChooserDialog *dialog;
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_FONT_CHOOSER_DIALOG,
|
||||
"title", title,
|
||||
"transient-for", parent,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_get_font_chooser:
|
||||
* @fcd: a #GtkFontChooserDialog
|
||||
*
|
||||
* Retrieves the #GtkFontChooser widget embedded in the dialog.
|
||||
*
|
||||
* Returns: (transfer none): the embedded #GtkFontChooser
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_font_chooser_dialog_get_font_chooser (GtkFontChooserDialog *fcd)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
|
||||
|
||||
return fcd->priv->fontchooser;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface)
|
||||
{
|
||||
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
||||
iface->get_internal_child = gtk_font_chooser_dialog_buildable_get_internal_child;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
GtkBuilder *builder,
|
||||
const gchar *childname)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
|
||||
priv = GTK_FONT_CHOOSER_DIALOG (buildable)->priv;
|
||||
|
||||
if (g_strcmp0 (childname, "select_button") == 0)
|
||||
return G_OBJECT (priv->select_button);
|
||||
else if (g_strcmp0 (childname, "cancel_button") == 0)
|
||||
return G_OBJECT (priv->cancel_button);
|
||||
else if (g_strcmp0 (childname, "font_chooser") == 0)
|
||||
return G_OBJECT (priv->fontchooser);
|
||||
|
||||
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_get_font_name:
|
||||
* @fcd: a #GtkFontChooserDialog
|
||||
*
|
||||
* Gets the currently-selected font name.
|
||||
*
|
||||
* Note that this can be a different string than what you set with
|
||||
* gtk_font_chooser_dialog_set_font_name(), as the font chooser widget
|
||||
* may normalize font names and thus return a string with a different
|
||||
* structure. For example, "Helvetica Italic Bold 12" could be normalized
|
||||
* to "Helvetica Bold Italic 12".
|
||||
*
|
||||
* Use pango_font_description_equal() if you want to compare two
|
||||
* font descriptions.
|
||||
*
|
||||
* Return value: A string with the name of the current font, or %NULL
|
||||
* if no font is selected. You must free this string with g_free().
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gchar*
|
||||
gtk_font_chooser_dialog_get_font_name (GtkFontChooserDialog *fcd)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
|
||||
|
||||
priv = fcd->priv;
|
||||
|
||||
return gtk_font_chooser_get_font_name (GTK_FONT_CHOOSER (priv->fontchooser));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_set_font_name:
|
||||
* @fcd: a #GtkFontChooserDialog
|
||||
* @fontname: a font name like "Helvetica 12" or "Times Bold 18"
|
||||
*
|
||||
* Sets the currently selected font.
|
||||
*
|
||||
* Return value: %TRUE if the font selected in @fcd is now the
|
||||
* @fontname specified, %FALSE otherwise.
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_chooser_dialog_set_font_name (GtkFontChooserDialog *fcd,
|
||||
const gchar *fontname)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), FALSE);
|
||||
g_return_val_if_fail (fontname, FALSE);
|
||||
|
||||
priv = fcd->priv;
|
||||
|
||||
return gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (priv->fontchooser), fontname);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_get_preview_text:
|
||||
* @fcd: a #GtkFontChooserDialog
|
||||
*
|
||||
* Gets the text displayed in the preview area.
|
||||
*
|
||||
* Return value: the text displayed in the preview area.
|
||||
* This string is owned by the widget and should not be
|
||||
* modified or freed
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
const gchar*
|
||||
gtk_font_chooser_dialog_get_preview_text (GtkFontChooserDialog *fcd)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
|
||||
|
||||
priv = fcd->priv;
|
||||
|
||||
return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (priv->fontchooser));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_font_chooser_dialog_set_preview_text:
|
||||
* @fcd: a #GtkFontChooserDialog
|
||||
* @text: the text to display in the preview area
|
||||
*
|
||||
* Sets the text displayed in the preview area.
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
void
|
||||
gtk_font_chooser_dialog_set_preview_text (GtkFontChooserDialog *fcd,
|
||||
const gchar *text)
|
||||
{
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
priv = fcd->priv;
|
||||
|
||||
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (priv->fontchooser), text);
|
||||
}
|
76
gtk/gtkfontchooserdialog.h
Normal file
76
gtk/gtkfontchooserdialog.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __GTK_FONT_CHOOSER_DIALOG_H__
|
||||
#define __GTK_FONT_CHOOSER_DIALOG_H__
|
||||
|
||||
#include <gtk/gtkdialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FONT_CHOOSER_DIALOG (gtk_font_chooser_dialog_get_type ())
|
||||
#define GTK_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialog))
|
||||
#define GTK_FONT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialogClass))
|
||||
#define GTK_IS_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG))
|
||||
#define GTK_IS_FONT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER_DIALOG))
|
||||
#define GTK_FONT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialogClass))
|
||||
|
||||
typedef struct _GtkFontChooserDialog GtkFontChooserDialog;
|
||||
typedef struct _GtkFontChooserDialogPrivate GtkFontChooserDialogPrivate;
|
||||
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
|
||||
|
||||
struct _GtkFontChooserDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GtkFontChooserDialogPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkFontChooserDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget* gtk_font_chooser_dialog_new (const gchar *title,
|
||||
GtkWindow *window);
|
||||
|
||||
GtkWidget* gtk_font_chooser_dialog_get_font_chooser (GtkFontChooserDialog *fcd);
|
||||
gchar* gtk_font_chooser_dialog_get_font_name (GtkFontChooserDialog *fcd);
|
||||
gboolean gtk_font_chooser_dialog_set_font_name (GtkFontChooserDialog *fcd,
|
||||
const gchar *fontname);
|
||||
const gchar*
|
||||
gtk_font_chooser_dialog_get_preview_text (GtkFontChooserDialog *fcd);
|
||||
void gtk_font_chooser_dialog_set_preview_text (GtkFontChooserDialog *fcd,
|
||||
const gchar *text);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
|
@@ -37,7 +37,10 @@
|
||||
|
||||
#include <atk/atk.h>
|
||||
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include "gtkfontsel.h"
|
||||
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkentry.h"
|
||||
@@ -58,9 +61,9 @@
|
||||
|
||||
/**
|
||||
* SECTION:gtkfontsel
|
||||
* @Short_description: A widget for selecting fonts
|
||||
* @Short_description: Deprecated widget for selecting fonts
|
||||
* @Title: GtkFontSelection
|
||||
* @See_also: #GtkFontSelectionDialog
|
||||
* @See_also: #GtkFontSelectionDialog, #GtkFontChooser
|
||||
*
|
||||
* The #GtkFontSelection widget lists the available fonts, styles and sizes,
|
||||
* allowing the user to select a font.
|
||||
@@ -74,6 +77,9 @@
|
||||
*
|
||||
* To change the text which is shown in the preview area, use
|
||||
* gtk_font_selection_set_preview_text().
|
||||
*
|
||||
* In GTK+ 3.2, #GtkFontSelection has been deprecated in favor of
|
||||
* #GtkFontChooser.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1230,6 +1236,8 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
|
||||
* Return value: (transfer none): A #GtkWidget that is part of @fontsel
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
|
||||
@@ -1249,6 +1257,8 @@ gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
|
||||
* Return value: (transfer none): A #GtkWidget that is part of @fontsel
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
|
||||
@@ -1268,6 +1278,8 @@ gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
|
||||
* Return value: (transfer none): A #GtkWidget that is part of @fontsel
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
|
||||
@@ -1286,6 +1298,8 @@ gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
|
||||
* Return value: (transfer none): A #GtkWidget that is part of @fontsel
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
|
||||
@@ -1304,6 +1318,8 @@ gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
|
||||
* Return value: (transfer none): A #GtkWidget that is part of @fontsel
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
|
||||
@@ -1325,6 +1341,8 @@ gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
|
||||
* be modified or freed.
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
PangoFontFamily *
|
||||
gtk_font_selection_get_family (GtkFontSelection *fontsel)
|
||||
@@ -1346,6 +1364,8 @@ gtk_font_selection_get_family (GtkFontSelection *fontsel)
|
||||
* @fontsel and must not be modified or freed.
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
PangoFontFace *
|
||||
gtk_font_selection_get_face (GtkFontSelection *fontsel)
|
||||
@@ -1365,6 +1385,8 @@ gtk_font_selection_get_face (GtkFontSelection *fontsel)
|
||||
* or -1 if no font size is selected.
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
**/
|
||||
gint
|
||||
gtk_font_selection_get_size (GtkFontSelection *fontsel)
|
||||
@@ -1389,6 +1411,8 @@ gtk_font_selection_get_size (GtkFontSelection *fontsel)
|
||||
*
|
||||
* Return value: A string with the name of the current font, or %NULL if
|
||||
* no font is selected. You must free this string with g_free().
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
gchar *
|
||||
gtk_font_selection_get_font_name (GtkFontSelection *fontsel)
|
||||
@@ -1522,6 +1546,8 @@ gtk_font_selection_select_font_desc (GtkFontSelection *fontsel,
|
||||
* Return value: %TRUE if the font could be set successfully; %FALSE if no
|
||||
* such font exists or if the @fontsel doesn't belong to a particular
|
||||
* screen yet.
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
|
||||
@@ -1565,6 +1591,8 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
|
||||
* Return value: the text displayed in the preview area.
|
||||
* This string is owned by the widget and should not be
|
||||
* modified or freed
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
const gchar*
|
||||
gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
|
||||
@@ -1586,6 +1614,8 @@ gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
|
||||
*
|
||||
* Sets the text displayed in the preview area.
|
||||
* The @text is used to show how the selected font looks.
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooser
|
||||
*/
|
||||
void
|
||||
gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
|
||||
@@ -1606,7 +1636,7 @@ gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
|
||||
* SECTION:gtkfontseldlg
|
||||
* @Short_description: A dialog box for selecting fonts
|
||||
* @Title: GtkFontSelectionDialog
|
||||
* @See_also: #GtkFontSelection, #GtkDialog
|
||||
* @See_also: #GtkFontSelection, #GtkDialog, #GtkFontChooserDialog
|
||||
*
|
||||
* The #GtkFontSelectionDialog widget is a dialog box for selecting a font.
|
||||
*
|
||||
@@ -1618,6 +1648,9 @@ gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
|
||||
* To change the text which is shown in the preview area, use
|
||||
* gtk_font_selection_dialog_set_preview_text().
|
||||
*
|
||||
* In GTK+ 3.2, #GtkFontSelectionDialog has been deprecated in favor of
|
||||
* #GtkFontChooserDialog.
|
||||
*
|
||||
* <refsect2 id="GtkFontSelectionDialog-BUILDER-UI">
|
||||
* <title>GtkFontSelectionDialog as GtkBuildable</title>
|
||||
* The GtkFontSelectionDialog implementation of the GtkBuildable interface
|
||||
@@ -1714,6 +1747,8 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
|
||||
* Creates a new #GtkFontSelectionDialog.
|
||||
*
|
||||
* Return value: a new #GtkFontSelectionDialog
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_font_selection_dialog_new (const gchar *title)
|
||||
@@ -1737,6 +1772,8 @@ gtk_font_selection_dialog_new (const gchar *title)
|
||||
* Returns: (transfer none): the embedded #GtkFontSelection
|
||||
*
|
||||
* Since: 2.22
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
**/
|
||||
GtkWidget*
|
||||
gtk_font_selection_dialog_get_font_selection (GtkFontSelectionDialog *fsd)
|
||||
@@ -1757,6 +1794,8 @@ gtk_font_selection_dialog_get_font_selection (GtkFontSelectionDialog *fsd)
|
||||
* for the 'OK' button.
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
|
||||
@@ -1776,6 +1815,8 @@ gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
|
||||
* for the 'Cancel' button.
|
||||
*
|
||||
* Since: 2.14
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_font_selection_dialog_get_cancel_button (GtkFontSelectionDialog *fsd)
|
||||
@@ -1828,6 +1869,8 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
*
|
||||
* Return value: A string with the name of the current font, or %NULL if no
|
||||
* font is selected. You must free this string with g_free().
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
gchar*
|
||||
gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
|
||||
@@ -1850,6 +1893,8 @@ gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
|
||||
*
|
||||
* Return value: %TRUE if the font selected in @fsd is now the
|
||||
* @fontname specified, %FALSE otherwise.
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
gboolean
|
||||
gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
|
||||
@@ -1874,6 +1919,8 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
|
||||
* Return value: the text displayed in the preview area.
|
||||
* This string is owned by the widget and should not be
|
||||
* modified or freed
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
const gchar*
|
||||
gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
|
||||
@@ -1893,6 +1940,8 @@ gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
|
||||
* @text: the text to display in the preview area
|
||||
*
|
||||
* Sets the text displayed in the preview area.
|
||||
*
|
||||
* Deprecated: 3.2: Use #GtkFontChooserDialog
|
||||
*/
|
||||
void
|
||||
gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
|
||||
|
@@ -42,6 +42,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#define GTK_TYPE_FONT_SELECTION (gtk_font_selection_get_type ())
|
||||
#define GTK_FONT_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_SELECTION, GtkFontSelection))
|
||||
#define GTK_FONT_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_SELECTION, GtkFontSelectionClass))
|
||||
@@ -170,6 +172,8 @@ void gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd
|
||||
const gchar *text);
|
||||
|
||||
|
||||
#endif /* GTK_DISABLE_DEPRECATED */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
|
@@ -703,11 +703,13 @@ gtk_spin_button_realize (GtkWidget *widget)
|
||||
gint attributes_mask;
|
||||
gboolean return_val;
|
||||
gint arrow_size;
|
||||
gint req_height;
|
||||
GtkBorder padding;
|
||||
|
||||
arrow_size = spin_button_get_arrow_size (spin_button);
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
|
||||
@@ -729,9 +731,9 @@ gtk_spin_button_realize (GtkWidget *widget)
|
||||
gtk_style_context_get_padding (context, state, &padding);
|
||||
|
||||
attributes.x = allocation.x + allocation.width - arrow_size - (padding.left + padding.right);
|
||||
attributes.y = allocation.y + (allocation.height - requisition.height) / 2;
|
||||
attributes.y = allocation.y + (allocation.height - req_height) / 2;
|
||||
attributes.width = arrow_size + padding.left + padding.right;
|
||||
attributes.height = requisition.height;
|
||||
attributes.height = req_height;
|
||||
|
||||
priv->panel = gdk_window_new (gtk_widget_get_window (widget),
|
||||
&attributes, attributes_mask);
|
||||
@@ -877,6 +879,7 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
|
||||
GtkBorder padding;
|
||||
gint arrow_size;
|
||||
gint panel_width;
|
||||
gint req_height;
|
||||
|
||||
arrow_size = spin_button_get_arrow_size (spin);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
@@ -886,6 +889,7 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
|
||||
panel_width = arrow_size + padding.left + padding.right;
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
@@ -895,10 +899,10 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
|
||||
panel_allocation.x = allocation->x + allocation->width - panel_width;
|
||||
|
||||
panel_allocation.width = panel_width;
|
||||
panel_allocation.height = MIN (requisition.height, allocation->height);
|
||||
panel_allocation.height = MIN (req_height, allocation->height);
|
||||
|
||||
panel_allocation.y = allocation->y +
|
||||
(allocation->height - requisition.height) / 2;
|
||||
(allocation->height - req_height) / 2;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, allocation);
|
||||
|
||||
@@ -1075,6 +1079,7 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
|
||||
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
|
||||
GtkSpinButtonPrivate *priv = spin->priv;
|
||||
GtkRequisition requisition;
|
||||
gint req_height;
|
||||
|
||||
if (event->window == priv->panel)
|
||||
{
|
||||
@@ -1086,8 +1091,9 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
|
||||
gdk_window_get_device_position (priv->panel, device, &x, &y, NULL);
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
if (y <= requisition.height / 2)
|
||||
if (y <= req_height / 2)
|
||||
priv->in_child = GTK_ARROW_UP;
|
||||
else
|
||||
priv->in_child = GTK_ARROW_DOWN;
|
||||
@@ -1260,6 +1266,7 @@ gtk_spin_button_button_press (GtkWidget *widget,
|
||||
if (event->window == priv->panel)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
gint req_height;
|
||||
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
@@ -1269,8 +1276,9 @@ gtk_spin_button_button_press (GtkWidget *widget,
|
||||
gtk_spin_button_update (spin);
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
if (event->y <= requisition.height / 2)
|
||||
if (event->y <= req_height / 2)
|
||||
{
|
||||
if (event->button == 1)
|
||||
start_spinning (spin, GTK_ARROW_UP, gtk_adjustment_get_step_increment (priv->adjustment));
|
||||
@@ -1315,22 +1323,24 @@ gtk_spin_button_button_release (GtkWidget *widget,
|
||||
if (event->button == 3)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
gint req_height;
|
||||
GtkStyleContext *context;
|
||||
GtkStateFlags state;
|
||||
GtkBorder padding;
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
gtk_style_context_get_padding (context, state, &padding);
|
||||
|
||||
if (event->y >= 0 && event->x >= 0 &&
|
||||
event->y <= requisition.height &&
|
||||
event->y <= req_height &&
|
||||
event->x <= arrow_size + padding.left + padding.right)
|
||||
{
|
||||
if (click_child == GTK_ARROW_UP &&
|
||||
event->y <= requisition.height / 2)
|
||||
event->y <= req_height / 2)
|
||||
{
|
||||
gdouble diff;
|
||||
|
||||
@@ -1339,7 +1349,7 @@ gtk_spin_button_button_release (GtkWidget *widget,
|
||||
gtk_spin_button_real_spin (spin, diff);
|
||||
}
|
||||
else if (click_child == GTK_ARROW_DOWN &&
|
||||
event->y > requisition.height / 2)
|
||||
event->y > req_height / 2)
|
||||
{
|
||||
gdouble diff;
|
||||
|
||||
@@ -1370,19 +1380,21 @@ gtk_spin_button_motion_notify (GtkWidget *widget,
|
||||
if (event->window == priv->panel)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
gint req_height;
|
||||
gint y = event->y;
|
||||
|
||||
gdk_event_request_motions (event);
|
||||
|
||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
||||
|
||||
if (y <= requisition.height / 2 &&
|
||||
if (y <= req_height / 2 &&
|
||||
priv->in_child == GTK_ARROW_DOWN)
|
||||
{
|
||||
priv->in_child = GTK_ARROW_UP;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (spin));
|
||||
}
|
||||
else if (y > requisition.height / 2 &&
|
||||
else if (y > req_height / 2 &&
|
||||
priv->in_child == GTK_ARROW_UP)
|
||||
{
|
||||
priv->in_child = GTK_ARROW_DOWN;
|
||||
|
@@ -50,6 +50,10 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testentryicons \
|
||||
testfilechooser \
|
||||
testfilechooserbutton \
|
||||
testfontselection \
|
||||
testfontselectiondialog \
|
||||
testfontchooser \
|
||||
testfontchooserdialog \
|
||||
testframe \
|
||||
testgeometry \
|
||||
testgiconpixbuf \
|
||||
@@ -161,6 +165,10 @@ testentryicons_DEPENDENCIES = $(TEST_DEPS)
|
||||
testerrors_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfontselection_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfontselectiondialog_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfontchooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfontchooserdialog_DEPENDENCIES = $(TEST_DEPS)
|
||||
testframe_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgeometry_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgiconpixbuf = $(TEST_DEPS)
|
||||
@@ -249,6 +257,10 @@ testentryicons_LDADD = $(LDADDS)
|
||||
testerrors_LDADD = $(LDADDS)
|
||||
testfilechooser_LDADD = $(LDADDS)
|
||||
testfilechooserbutton_LDADD = $(LDADDS)
|
||||
testfontselection_LDADD = $(LDADDS)
|
||||
testfontselectiondialog_LDADD = $(LDADDS)
|
||||
testfontchooser_LDADD = $(LDADDS)
|
||||
testfontchooserdialog_LDADD = $(LDADDS)
|
||||
testframe_LDADD = $(LDADDS)
|
||||
testgeometry_LDADD = $(LDADDS)
|
||||
testgiconpixbuf_LDADD = $(LDADDS)
|
||||
@@ -342,6 +354,18 @@ testfilechooserbutton_SOURCES = \
|
||||
prop-editor.c \
|
||||
testfilechooserbutton.c
|
||||
|
||||
testfontselection_SOURCES = \
|
||||
testfontselection.c
|
||||
|
||||
testfontselectiondialog_SOURCES = \
|
||||
testfontselectiondialog.c
|
||||
|
||||
testfontchooser_SOURCES = \
|
||||
testfontchooser.c
|
||||
|
||||
testfontchooserdialog_SOURCES = \
|
||||
testfontchooserdialog.c
|
||||
|
||||
testgrid_SOURCES = \
|
||||
testgrid.c
|
||||
|
||||
|
67
tests/testfontchooser.c
Normal file
67
tests/testfontchooser.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/* testfontchooser.c
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This 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.
|
||||
*
|
||||
* This 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 this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
notify_font_name_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
g_debug ("Changed font name %s", gtk_font_chooser_get_font_name (GTK_FONT_CHOOSER (fontchooser)));
|
||||
}
|
||||
|
||||
static void
|
||||
notify_preview_text_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
g_debug ("Changed preview text %s", gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (fontchooser)));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *box;
|
||||
GtkWidget *fontchooser;
|
||||
|
||||
gtk_init (NULL, NULL);
|
||||
|
||||
fontchooser = gtk_font_chooser_new ();
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_size_request (window, 600, 600);
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
gtk_container_add (GTK_CONTAINER (box), fontchooser);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
g_signal_connect (window, "delete-event",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
g_signal_connect (fontchooser, "notify::font-name",
|
||||
G_CALLBACK (notify_font_name_cb), NULL);
|
||||
g_signal_connect (fontchooser, "notify::preview-text",
|
||||
G_CALLBACK (notify_preview_text_cb), NULL);
|
||||
|
||||
gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (fontchooser), "Bitstream Vera Sans 45");
|
||||
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ ");
|
||||
gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (fontchooser), FALSE);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
36
tests/testfontchooserdialog.c
Normal file
36
tests/testfontchooserdialog.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* testfontchooserdialog.c
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This 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.
|
||||
*
|
||||
* This 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 this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_add (GTK_CONTAINER (window), gtk_font_button_new ());
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
80
tests/testfontselection.c
Normal file
80
tests/testfontselection.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/* testfontselection.c
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This 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.
|
||||
*
|
||||
* This 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 this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
notify_font_name_cb (GObject *fontsel, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
g_debug ("Changed font name %s", gtk_font_selection_get_font_name (GTK_FONT_SELECTION (fontsel)));
|
||||
}
|
||||
|
||||
static void
|
||||
notify_preview_text_cb (GObject *fontsel, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
g_debug ("Changed preview text %s", gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (fontsel)));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *fontsel;
|
||||
|
||||
gtk_init (NULL, NULL);
|
||||
|
||||
fontsel = gtk_font_selection_new ();
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_size_request (window, 600, 600);
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||
|
||||
#ifndef GTK_DISABLE_DEPRECATED
|
||||
g_object_ref (gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
|
||||
g_object_ref (gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
|
||||
g_object_ref (gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
|
||||
#endif
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (hbox), fontsel);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
|
||||
g_signal_connect (G_OBJECT (fontsel), "notify::font-name", G_CALLBACK(notify_font_name_cb), NULL);
|
||||
g_signal_connect (G_OBJECT (fontsel), "notify::preview-text", G_CALLBACK(notify_preview_text_cb), NULL);
|
||||
|
||||
gtk_font_selection_set_font_name (GTK_FONT_SELECTION (fontsel), "Bitstream Vera Sans 45");
|
||||
gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (fontsel), "[user@host ~]$ ");
|
||||
|
||||
gtk_main ();
|
||||
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return 0;
|
||||
}
|
43
tests/testfontselectiondialog.c
Normal file
43
tests/testfontselectiondialog.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* testfontselectiondialog.c
|
||||
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
||||
*
|
||||
* This 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.
|
||||
*
|
||||
* This 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 this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *ok;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
dialog = gtk_font_selection_dialog_new (NULL);
|
||||
|
||||
ok = gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG (dialog));
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user