Compare commits

...

126 Commits

Author SHA1 Message Date
Matthias Clasen f83b9ff27e Make setting fontname work, independent of a screen 2011-08-14 23:46:14 -04:00
Matthias Clasen 06314432f9 Keep the currently selected font over theme changes
When repopulating the list of fonts, don't loose the current
selection, unless the font is no longer in the list.
2011-08-14 23:16:45 -04:00
Matthias Clasen 8e1bff47fd Deprecate GtkFontSelection and GtkFontSelectionDialog 2011-08-14 22:51:39 -04:00
Matthias Clasen 6e3714b8e1 Trivial formatting fix 2011-08-14 22:50:44 -04:00
Matthias Clasen 37db3cb5fd Add docs 2011-08-14 22:33:23 -04:00
Matthias Clasen 7c7b25244f Add new symbols 2011-08-14 22:33:10 -04:00
Matthias Clasen 3b7053fe21 Add filtering to the font chooser 2011-08-14 22:20:00 -04:00
Matthias Clasen 14b5fd9560 Add 'no matches' functionality
Initial cut at showing a 'no matches' message if the font list
is empty.
2011-08-11 11:23:21 +02:00
Matthias Clasen 647f3dc2c9 Make the fontchooser dialog come up in a reasonable size
This is not a perfect solution; we really just want to set
a nice default size, but GTK+ does not make that easy.
2011-08-09 16:13:58 +02:00
Matthias Clasen 21f8714b38 Fix entry drawing in the presence of margins
Margins need to be taken into account when comparing requisitions
and allocations, which GtkEntry (and subclasses) do for some reason.
2011-08-09 15:08:53 +02:00
Matthias Clasen 948fa8b9e6 Just use a single grid
The subgrid didn't really add anything.
2011-08-09 09:24:39 +02:00
Matthias Clasen 541a2c3efb Clean up error handling 2011-08-09 02:11:38 +02:00
Matthias Clasen 88096a8a18 Rename some statics
gtk_font_chooser_ref_{family,face} -> gtk_font_chooser_set_{family,face}
2011-08-09 02:07:47 +02:00
Matthias Clasen c8639c23b3 Avoid extraneous signals at destroy time
We need to disconnect the cursor-changed handler before the
treeview gets destroyed, to avoid unwanted emissions.
2011-08-09 02:04:22 +02:00
Matthias Clasen f4a769d125 Fix minor issues in the tests 2011-08-09 02:02:55 +02:00
Matthias Clasen c226ab3c9f Simplify a few things
Adwaita seems to misrender focus on entries with margins, so
use spacing instead. Also, don't use entry buffer unnecessarily.
2011-08-09 01:10:39 +02:00
Matthias Clasen 87ad927167 Trivial formatting fixes
Just committing these is easier than writing them up.
2011-08-09 00:10:00 +02:00
Alberto Ruiz 5cdc9a2ab7 GtkFontChooserDialog: GtkFontButton now uses GtkFontChooserDialog instead of GtkFontSelectionDialog 2011-07-28 00:22:22 +01:00
Alberto Ruiz 6eb2f4e693 GtkFontChooser: get_font_name did not return the font size 2011-07-28 00:21:40 +01:00
Alberto Ruiz 066b5019e9 GtkFontChooser: Stub code to handle empty list by search. 2011-07-27 23:24:15 +01:00
Alberto Ruiz 118ced448b GtkFontChooser: font-name property notification wasn't properly propagated during size change from the spinbutton 2011-07-27 14:11:43 +01:00
Alberto Ruiz 8cdeb75121 GtkFontChooser: Missing G_END_DECLS in fontchooser header 2011-07-27 13:04:21 +01:00
Alberto Ruiz c2d1738de4 GtkFontChooser: Using G_N_ELEMENTS instead of a define 2011-07-25 18:37:13 +01:00
Alberto Ruiz 6658d0d20c GtkFontChooser: Using the widget instead of the private struct as signal data in all conects 2011-07-25 18:16:55 +01:00
Alberto Ruiz 935a3e66df GtkFontChooser: Fixed coding style wrt spacing around operators 2011-07-25 17:46:50 +01:00
Alberto Ruiz b7682cfddb GtkFontChooser: Using explicit comparisons for g_strcmp0 2011-07-25 17:41:59 +01:00
Alberto Ruiz 3fb041efb1 GtkFontChooser: Added missing breaks in switch statements 2011-07-25 17:38:54 +01:00
Alberto Ruiz 1c0d527893 GtkFontChooser: Setting all ought to be static functions as static 2011-07-25 17:35:36 +01:00
Alberto Ruiz 481efc0301 GtkFontChooserDialog: Add parent window as a parameter in the constructor 2011-07-25 17:14:49 +01:00
Alberto Ruiz 9fcfd6c13e GtkFontChooserDialog: Fix get_font_chooser public function name 2011-07-25 16:34:02 +01:00
Alberto Ruiz 21b6cec5b5 GtkFontChooser: Set correct margin values between UI elements 2011-07-25 16:30:28 +01:00
Alberto Ruiz f23f2f9848 GtkFontChooserDialog: Use g_object_new to set initial values in the dialog constructor 2011-07-25 16:08:23 +01:00
Alberto Ruiz 33d709f924 GtkFontChooser: Remove outdated Copyright information 2011-07-25 16:04:35 +01:00
Alberto Ruiz b74360964c GtkFontChooser: Fix size synchronization between slider and spin button 2011-07-25 15:16:09 +01:00
Alberto Ruiz 5449544f3b GtkFontChooser: Cleanup comments and fix indentation alignments 2011-07-25 15:11:20 +01:00
Alberto Ruiz da7d819988 GtkFontChooser: Remove default geometry defines 2011-07-25 15:11:19 +01:00
Alberto Ruiz 7fd4f8e16f GtkFontChooser: Fix scroll callback connected to treeview instead of preview 2011-07-25 15:11:19 +01:00
Alberto Ruiz d5cfd9b834 GtkFontChooser: Remove the themed color for the font title 2011-07-25 15:11:19 +01:00
Alberto Ruiz deebacb9e2 GtkFontChooser: Use a nested grid to achieve the right layout in the size controls 2011-07-25 15:11:19 +01:00
Alberto Ruiz b205dbbaab GtkFontChooser: Fix expand and fill properties for the grid layout 2011-07-25 15:11:19 +01:00
Alberto Ruiz e3fee235f9 GtkFontChooser: Use GtkBox instead of GtkVBox as base class. 2011-07-25 15:11:19 +01:00
Alberto Ruiz b54298f19c GtkFontChooser: Use const instead of G_CONST_RETURN 2011-07-25 15:11:19 +01:00
Alberto Ruiz 660ae69b4d GtkFontChooser: Add preview entry to the grid 2011-07-25 15:11:19 +01:00
Alberto Ruiz 870d4cbf01 GtkFontChooser: Initial work to use GtkGrid 2011-07-25 15:11:19 +01:00
Alberto Ruiz cf2d18747f GtkFontChooser: GtkFontChooserDialog: Update documenation to reflect Since: 3.2 2011-07-25 15:11:19 +01:00
Alberto Ruiz ed700f6837 GtkFontChooserDialog: Split the dialog out of gtkfontchooser.[ch] to gtkfontchooserdialog.[ch] 2011-07-25 15:11:19 +01:00
Alberto Ruiz 48958a5181 GtkFontChooser: Use symbolic icons in the filter entry 2011-07-25 15:11:18 +01:00
Alberto Ruiz ed5494a654 GtkFontChooser: Now shearch filters each individual term rather than the whole string at once 2011-07-25 15:11:18 +01:00
Alberto Ruiz cdc9968777 GtkFontChooser: Restore automatic alignment on scroll to selection 2011-07-25 15:11:18 +01:00
Alberto Ruiz 58b81beeba GtkFontChooser: Removed support for deprecated functionality from GtkFontSelector 2011-07-25 15:11:18 +01:00
Alberto Ruiz 4d66ae4f4b GtkFontChooser: Expose the new widget in gtk.h and add test cases 2011-07-25 15:11:18 +01:00
Alberto Ruiz 80be013408 GtkFontChooser: Renaming the class names and fixing the tests 2011-07-25 15:11:18 +01:00
Alberto Ruiz 92d9064262 GtkFontChooser: Remove wrong usage of GTK_DISABLE_DEPRECATED 2011-07-25 15:11:18 +01:00
Alberto Ruiz a38ede804c GtkFontChooser: Check if the deprecated widgets are present before updating the size list 2011-07-25 15:11:18 +01:00
Alberto Ruiz 7cd2c0d70e GtkFontChooser: Update fontlist on style change 2011-07-25 15:11:18 +01:00
Alberto Ruiz 7946d306db GtkFontChooser: Add a property to control whether the preview entry is shown or not 2011-07-25 15:11:18 +01:00
Alberto Ruiz dc70a25ec3 GtkFontChooser: Better test preview text 2011-07-25 15:11:17 +01:00
Alberto Ruiz 2a8a8a7d2e GtkFontChooser: Use GTK_DISABLE_DEPRECATED on the test code 2011-07-25 15:11:17 +01:00
Alberto Ruiz 63421eac44 GtkFontChooser: Add gtk_font_selection_dialog_get_select_button and use GTK_DISABLE_DEPRECATED in gtkfontsel.h 2011-07-25 15:11:17 +01:00
Alberto Ruiz b6b35706dd GtkFontChooser: Changed dialog label from OK to Select, deprecated get_ok_button and internal apply button. 2011-07-25 15:11:17 +01:00
Alberto Ruiz f8d57aaa6c GtkFontChooser: Added test for GtkFontSelectionDialog 2011-07-25 15:11:17 +01:00
Alberto Ruiz ebc2d19c7b GtkFontChooser: implement gtk_font_selection_set/get_preview_text 2011-07-25 15:11:17 +01:00
Alberto Ruiz 296b8f8d4c GtkFontChooser: check if font name is NULL in gtk_font_selection_set_font_name 2011-07-25 15:11:17 +01:00
Alberto Ruiz 18c87e028b GtkFontChooser: gtk_font_selection_set_font_name implementation 2011-07-25 15:11:17 +01:00
Alberto Ruiz a948585140 GtkFontChooser: Setting the font-name property. Test updates. Remove warnings. 2011-07-25 15:11:17 +01:00
Alberto Ruiz 3a1c575628 GtkFontChooser: Improve bootstrapping of the deprecated lists 2011-07-25 15:11:17 +01:00
Alberto Ruiz 3b44051d5f GtkFontChooser: Update selection on deprecated size list selection 2011-07-25 15:11:17 +01:00
Alberto Ruiz cbb9486ce4 GtkFontChooser: Update selection on deprecated face or font list selection 2011-07-25 15:11:16 +01:00
Alberto Ruiz 5b64379acb GtkFontChooser: Update size when selecting an item of the deprecated size list 2011-07-25 15:11:16 +01:00
Alberto Ruiz 7058a09701 GtkFontChooser: Blocking the cursor change callbacks from happening on the deprecated widgets when selecting the font from the fontselector 2011-07-25 15:11:16 +01:00
Alberto Ruiz 410a9256ba GtkFontChooser: Update deprecated font list on slection 2011-07-25 15:11:16 +01:00
Alberto Ruiz ddc4aadf68 GtkFontChooser: Refactoring the default font size, face and family assignment for clarity 2011-07-25 15:11:16 +01:00
Alberto Ruiz 49dde2ad43 GtkFontChooser: Use the theme font as the default font 2011-07-25 15:11:16 +01:00
Alberto Ruiz ea8ac647b5 GtkFontChooser: Add callbacks and improve test to take deprecated widgets into account 2011-07-25 15:11:14 +01:00
Alberto Ruiz 85d66cf37b GtkFontChooser: Use GTK_DISABLE_DEPRECATED to encapsulate the deprecated functionality 2011-07-25 15:11:14 +01:00
Alberto Ruiz 57c4d55736 GtkFontChooser: Unref deprecated widgets on finalize 2011-07-25 15:11:14 +01:00
Alberto Ruiz 3e28775931 GtkFontChooser: Use scrolled windows for the deprecated widgets 2011-07-25 15:11:14 +01:00
Alberto Ruiz 92a704284d GtkFontChooser: Populate face names in the deprecated face list 2011-07-25 15:11:14 +01:00
Alberto Ruiz 2bc4391bbf GtkFontChooser: Populate font family names in the deprecated family list 2011-07-25 15:11:14 +01:00
Alberto Ruiz 1e7fe46d2f GtkFontChooser: Add tree view columns for the deprecated widgets 2011-07-25 15:11:14 +01:00
Alberto Ruiz 46785d3a57 GtkFontChooser: Fix segmentation fault in deprecated size list population 2011-07-25 15:11:14 +01:00
Alberto Ruiz 26388763b6 GtkFontChooser: Add deprecated calls to the test 2011-07-25 15:11:14 +01:00
Alberto Ruiz f3341733e6 GtkFontChooser: update the size model for the deprecated size list 2011-07-25 15:11:14 +01:00
Alberto Ruiz de312b55a0 GtkFontChooser: initialization and destruction of deprecated widgets and data models 2011-07-25 15:11:14 +01:00
Alberto Ruiz bdb82376e7 GtkFontChooser: Initial support for deprecated functions 2011-07-25 15:11:13 +01:00
Alberto Ruiz 9d754d169e GtkFontChooser: Filter also by font face 2011-07-25 15:11:13 +01:00
Alberto Ruiz 49278b053a GtkFontChooser: Layout improvements, spacing between elements and default widget size. 2011-07-25 15:11:13 +01:00
Alberto Ruiz 9e94e59e50 GtkFontChooser: Layout improvements. Adding shadow to scrolled windows. Font+Face text is now bold. 2011-07-25 15:11:13 +01:00
Alberto Ruiz 0321e33888 GtkFontChooser: Improvements on the size setting signals between the preview, scale and spinbutton. Adding more string fields to the model to allow for backwards compatibility. 2011-07-25 15:11:13 +01:00
Alberto Ruiz 6300c01773 GtkFontChooser: Fixing mouse scroll zooming behaviour for the preview and the size controls 2011-07-25 15:11:13 +01:00
Alberto Ruiz 6a50640d2d GtkFontChooser: Setting a minimum width andfix the markup for the rows 2011-07-25 15:11:13 +01:00
Alberto Ruiz fd6d1e631e GtkFontChooser: Ellipsize cell renderer and set a better size list 2011-07-25 15:11:13 +01:00
Alberto Ruiz 47d02dc2e2 GtkFontChooser: Keep reference to the face and the family objects 2011-07-25 15:11:13 +01:00
Alberto Ruiz 576ccf3885 GtkFontChooser: Better cursor selection and model leak fixes 2011-07-25 15:11:13 +01:00
Alberto Ruiz f70e9727c4 GtkFontChooser: Added a test program 2011-07-25 15:11:13 +01:00
Alberto Ruiz b4bbabc286 GtkFontChooser: Enable font selection 2011-07-25 15:11:12 +01:00
Alberto Ruiz 9d64d2cce1 GtkFontChooser: Setting a default vertical size 2011-07-25 15:11:12 +01:00
Alberto Ruiz 91cada6908 GtkFontChooser: Layout enhancements, using a scrolled window for the preview entry. 2011-07-25 15:11:12 +01:00
Alberto Ruiz 27997a64ed GtkFontChooser: Fixed size updating in the preview 2011-07-25 15:11:12 +01:00
Alberto Ruiz b98088495e GtkFontChooser: Improvements on the spin/slider interaction 2011-07-25 15:11:12 +01:00
Alberto Ruiz 199dd65f2f GtkFontChooser: The spinner now updates the slider size if it is within the range 2011-07-25 15:11:12 +01:00
Alberto Ruiz 01226aeee0 GtkFontChooser: Getting the refiltering right for the clear icon. Filter function speedups. 2011-07-25 15:11:12 +01:00
Alberto Ruiz d4d7df93dd GtkFontChooser: Search entry icon is now dynamic depending on the content 2011-07-25 15:11:12 +01:00
Alberto Ruiz bd0685aa9b GtkFontChooser: Set the initial size to the slider, initial callbacks for size change 2011-07-25 15:11:12 +01:00
Alberto Ruiz b893ae4e93 GtkFontChooser: Live search implemented 2011-07-25 15:11:12 +01:00
Alberto Ruiz 454a5be973 GtkFontChooser: Inserted and deleted text callbacks 2011-07-25 15:11:12 +01:00
Alberto Ruiz ec6b993391 GtkFontChooser: Adding a tree model filter for the search functionality 2011-07-25 15:11:11 +01:00
Alberto Ruiz 09f70f0c59 GtkFontChooser: Setting the default preview text and the default font size 2011-07-25 15:11:11 +01:00
Alberto Ruiz 2e74de72df GtkFontChooser: Compilation warning cleanups 2011-07-25 15:11:11 +01:00
Alberto Ruiz d0160b5815 GtkFontChooser: Iterate over faces as well as families to list them 2011-07-25 15:11:11 +01:00
Alberto Ruiz e12dd430cd GtkFontChooser: Improvements in the font face listing 2011-07-25 15:11:11 +01:00
Alberto Ruiz d8af8b292b GtkFontChooser: Set rules hint to TRUE in the main tree view 2011-07-25 15:11:11 +01:00
Alberto Ruiz 12501f93c9 GtkFontChooser: Populated font list model 2011-07-25 15:11:11 +01:00
Alberto Ruiz a77a02ff77 GtkFontChooser: Add column and cell renderer 2011-07-25 15:11:11 +01:00
Alberto Ruiz 7321b734a8 GtkFontChooser: Create functions to bootstrap the treeview column and settings and update the font list 2011-07-25 15:11:11 +01:00
Alberto Ruiz 690e8432f7 GtkFontChooser: Set vbox to no homogeneus 2011-07-25 15:11:11 +01:00
Alberto Ruiz 972a40c4d6 GtkFontChooser: Setting the height of the preview and have a define for the top padding 2011-07-25 15:11:11 +01:00
Alberto Ruiz 9a1c2c86b3 GtkFontChooser: Added slider and spin button 2011-07-25 15:11:11 +01:00
Alberto Ruiz 3c41785757 GtkFontChooser: Adding the preview 2011-07-25 15:11:10 +01:00
Alberto Ruiz 5338d4d610 GtkFontChooser: Adding the alignment to the selection 2011-07-25 15:11:10 +01:00
Alberto Ruiz 17b425e6ba GtkFontChooser: Create alignment for the preview entry 2011-07-25 15:11:10 +01:00
Alberto Ruiz 5f53dc8b83 GtkFontChooser: Added main treeview 2011-07-25 15:11:10 +01:00
Alberto Ruiz bc16716250 GtkFontChooser: Avoid using show_all explicitely 2011-07-25 15:11:10 +01:00
Alberto Ruiz ad2dcebed7 GtkFontChooser: Create fundamental widgets for the new GtkFontSelection 2011-07-25 15:11:10 +01:00
Alberto Ruiz 7199708287 GtkFontChooser: Add private members to GtkFontSelectionPrivate 2011-07-25 15:11:10 +01:00
Alberto Ruiz 26aa667613 GtkFontChooser: Remove all cruft from the current GtkFontSelection implementation and start a new widget 2011-07-25 15:11:10 +01:00
19 changed files with 2295 additions and 74 deletions
+2
View File
@@ -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>
+56
View File
@@ -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>
+4
View File
@@ -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 \
+2
View File
@@ -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>
+19
View File
@@ -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
+14 -7
View File
@@ -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;
}
}
+44 -53
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+106
View 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
View 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
View 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__ */
+52 -3
View File
@@ -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,
+4
View File
@@ -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
+23 -11
View File
@@ -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;
+24
View File
@@ -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
View 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
View 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
View 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
View 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;
}