Commit c2a22d5d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added gimp_font_list_restore() which loads the fonts (not yet).

2003-03-25  Michael Natterer  <mitch@gimp.org>

	* app/text/gimpfontlist.[ch]: added gimp_font_list_restore()
	which loads the fonts (not yet).

	* app/core/gimp.c: call it.

	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs-menu.c
	* app/gui/dialogs.c
	* app/gui/image-menu.c
	* app/gui/toolbox-menu.c: added font list and grid views.

	* app/gui/menus.c: cosmetic.
parent b4dc1579
2003-03-25 Michael Natterer <mitch@gimp.org>
* app/text/gimpfontlist.[ch]: added gimp_font_list_restore()
which loads the fonts (not yet).
* app/core/gimp.c: call it.
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs-menu.c
* app/gui/dialogs.c
* app/gui/image-menu.c
* app/gui/toolbox-menu.c: added font list and grid views.
* app/gui/menus.c: cosmetic.
2003-03-25 Sven Neumann <sven@gimp.org>
* app/text/gimpfont.c: made the PangoContext an object property of
......@@ -228,7 +228,7 @@ gimp_init (Gimp *gimp)
GIMP_CONTAINER_POLICY_STRONG);
gimp_object_set_name (GIMP_OBJECT (gimp->named_buffers), "named buffers");
gimp->fonts = gimp_font_list_new ();
gimp->fonts = gimp_font_list_new (72.0, 72.0);
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
gimp->brush_factory = NULL;
......@@ -746,21 +746,27 @@ gimp_restore (Gimp *gimp,
gimp_parasiterc_load (gimp);
/* initialize the list of gimp brushes */
(* status_callback) (NULL, _("Brushes"), 0.18);
(* status_callback) (NULL, _("Brushes"), 0.15);
gimp_data_factory_data_init (gimp->brush_factory, no_data);
/* initialize the list of gimp patterns */
(* status_callback) (NULL, _("Patterns"), 0.36);
(* status_callback) (NULL, _("Patterns"), 0.30);
gimp_data_factory_data_init (gimp->pattern_factory, no_data);
/* initialize the list of gimp palettes */
(* status_callback) (NULL, _("Palettes"), 0.54);
(* status_callback) (NULL, _("Palettes"), 0.45);
gimp_data_factory_data_init (gimp->palette_factory, no_data);
/* initialize the list of gimp gradients */
(* status_callback) (NULL, _("Gradients"), 0.72);
(* status_callback) (NULL, _("Gradients"), 0.60);
gimp_data_factory_data_init (gimp->gradient_factory, no_data);
/* initialize the list of gimp fonts */
(* status_callback) (NULL, _("Fonts"), 0.75);
gimp_container_freeze (gimp->fonts);
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
gimp_container_thaw (gimp->fonts);
/* initialize the document history */
(* status_callback) (NULL, _("Documents"), 0.90);
gimp_documents_load (gimp);
......
......@@ -103,6 +103,9 @@ static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static GtkWidget * dialogs_font_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
......@@ -398,6 +401,25 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_font_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_tree_view_new (context->gimp->fonts,
context,
preview_size,
FALSE,
5, 3);
return dialogs_dockable_new (view,
_("Font List"), _("Fonts"), NULL,
dialogs_font_tab_func,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
......@@ -546,6 +568,25 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_font_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_grid_view_new (context->gimp->fonts,
context,
preview_size,
FALSE,
5, 3);
return dialogs_dockable_new (view,
_("Font Grid"), _("Fonts"), NULL,
dialogs_font_tab_func,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
......@@ -1113,6 +1154,33 @@ dialogs_palette_tab_func (GimpDockable *dockable,
return preview;
}
static GtkWidget *
dialogs_font_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size)
{
GimpContext *context;
GtkWidget *preview;
gint width;
gint height;
context = dockbook->dock->context;
gtk_icon_size_lookup (size, &width, &height);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_font (context)),
width, height, 1,
FALSE, FALSE, FALSE);
g_signal_connect_object (context, "font_changed",
G_CALLBACK (gimp_preview_set_viewable),
preview,
G_CONNECT_SWAPPED);
return preview;
}
static void
dialogs_tool_tab_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
......
......@@ -76,6 +76,9 @@ GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_font_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......@@ -98,6 +101,9 @@ GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_font_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......
......@@ -71,6 +71,8 @@ static const GimpDialogFactoryEntry dock_entries[] =
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-palette-list", dialogs_palette_list_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-font-list", dialogs_font_list_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-tool-list", dialogs_tool_list_view_new,
GIMP_PREVIEW_SIZE_SMALL, FALSE, FALSE, FALSE, TRUE },
{ "gimp-buffer-list", dialogs_buffer_list_view_new,
......@@ -86,6 +88,8 @@ static const GimpDialogFactoryEntry dock_entries[] =
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-palette-grid", dialogs_palette_grid_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-font-grid", dialogs_font_grid_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-tool-grid", dialogs_tool_grid_view_new,
GIMP_PREVIEW_SIZE_SMALL, FALSE, FALSE, FALSE, TRUE },
{ "gimp-buffer-grid", dialogs_buffer_grid_view_new,
......
......@@ -103,6 +103,9 @@ static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static GtkWidget * dialogs_font_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size);
......@@ -398,6 +401,25 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_font_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_tree_view_new (context->gimp->fonts,
context,
preview_size,
FALSE,
5, 3);
return dialogs_dockable_new (view,
_("Font List"), _("Fonts"), NULL,
dialogs_font_tab_func,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
......@@ -546,6 +568,25 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
dialogs_set_editor_context_func);
}
GtkWidget *
dialogs_font_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_grid_view_new (context->gimp->fonts,
context,
preview_size,
FALSE,
5, 3);
return dialogs_dockable_new (view,
_("Font Grid"), _("Fonts"), NULL,
dialogs_font_tab_func,
dialogs_set_view_context_func);
}
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
......@@ -1113,6 +1154,33 @@ dialogs_palette_tab_func (GimpDockable *dockable,
return preview;
}
static GtkWidget *
dialogs_font_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
GtkIconSize size)
{
GimpContext *context;
GtkWidget *preview;
gint width;
gint height;
context = dockbook->dock->context;
gtk_icon_size_lookup (size, &width, &height);
preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_font (context)),
width, height, 1,
FALSE, FALSE, FALSE);
g_signal_connect_object (context, "font_changed",
G_CALLBACK (gimp_preview_set_viewable),
preview,
G_CONNECT_SWAPPED);
return preview;
}
static void
dialogs_tool_tab_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
......
......@@ -76,6 +76,9 @@ GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_font_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......@@ -98,6 +101,9 @@ GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_font_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......
......@@ -85,6 +85,8 @@ GimpItemFactoryEntry dialogs_menu_entries[] =
"<StockItem>", GIMP_STOCK_TOOL_BLEND),
ADD_TAB (N_("/Add Tab/Palettes..."), "gimp-palette-list",
"<StockItem>", GTK_STOCK_SELECT_COLOR),
ADD_TAB (N_("/Add Tab/Fonts..."), "gimp-font-list",
"<StockItem>", GTK_STOCK_SELECT_FONT),
ADD_TAB (N_("/Add Tab/Buffers..."), "gimp-buffer-list",
"<StockItem>", GTK_STOCK_PASTE),
......
......@@ -71,6 +71,8 @@ static const GimpDialogFactoryEntry dock_entries[] =
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-palette-list", dialogs_palette_list_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-font-list", dialogs_font_list_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-tool-list", dialogs_tool_list_view_new,
GIMP_PREVIEW_SIZE_SMALL, FALSE, FALSE, FALSE, TRUE },
{ "gimp-buffer-list", dialogs_buffer_list_view_new,
......@@ -86,6 +88,8 @@ static const GimpDialogFactoryEntry dock_entries[] =
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-palette-grid", dialogs_palette_grid_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-font-grid", dialogs_font_grid_view_new,
GIMP_PREVIEW_SIZE_MEDIUM, FALSE, FALSE, FALSE, TRUE },
{ "gimp-tool-grid", dialogs_tool_grid_view_new,
GIMP_PREVIEW_SIZE_SMALL, FALSE, FALSE, FALSE, TRUE },
{ "gimp-buffer-grid", dialogs_buffer_grid_view_new,
......
......@@ -754,6 +754,11 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GTK_STOCK_SELECT_COLOR },
"gimp-palette-list",
"dialogs/palette_selection.html", NULL },
{ { N_("/Dialogs/Fonts..."), "<control>P",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_SELECT_FONT },
"gimp-font-list",
"dialogs/font_selection.html", NULL },
{ { N_("/Dialogs/Buffers..."), "foo",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_PASTE },
......
......@@ -273,11 +273,9 @@ menus_last_opened_add (GimpItemFactory *item_factory,
gimp, 2, TRUE, FALSE);
for (i = 0; i < n; i++)
{
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (item_factory),
last_opened_entries[i].entry.path,
FALSE);
}
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (item_factory),
last_opened_entries[i].entry.path,
FALSE);
gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (item_factory),
"/File/Open Recent/(None)",
......
......@@ -162,6 +162,11 @@ GimpItemFactoryEntry toolbox_menu_entries[] =
"<StockItem>", GTK_STOCK_SELECT_COLOR },
"gimp-palette-list",
"file/dialogs/palette_selection.html", NULL },
{ { N_("/File/Dialogs/Fonts..."), "<control>P",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_SELECT_FONT },
"gimp-font-list",
"file/dialogs/font_selection.html", NULL },
{ { N_("/File/Dialogs/Buffers..."), "foo",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_PASTE },
......
......@@ -754,6 +754,11 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GTK_STOCK_SELECT_COLOR },
"gimp-palette-list",
"dialogs/palette_selection.html", NULL },
{ { N_("/Dialogs/Fonts..."), "<control>P",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_SELECT_FONT },
"gimp-font-list",
"dialogs/font_selection.html", NULL },
{ { N_("/Dialogs/Buffers..."), "foo",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_PASTE },
......
......@@ -273,11 +273,9 @@ menus_last_opened_add (GimpItemFactory *item_factory,
gimp, 2, TRUE, FALSE);
for (i = 0; i < n; i++)
{
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (item_factory),
last_opened_entries[i].entry.path,
FALSE);
}
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (item_factory),
last_opened_entries[i].entry.path,
FALSE);
gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (item_factory),
"/File/Open Recent/(None)",
......
......@@ -162,6 +162,11 @@ GimpItemFactoryEntry toolbox_menu_entries[] =
"<StockItem>", GTK_STOCK_SELECT_COLOR },
"gimp-palette-list",
"file/dialogs/palette_selection.html", NULL },
{ { N_("/File/Dialogs/Fonts..."), "<control>P",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_SELECT_FONT },
"gimp-font-list",
"file/dialogs/font_selection.html", NULL },
{ { N_("/File/Dialogs/Buffers..."), "foo",
dialogs_create_dockable_cmd_callback, 0,
"<StockItem>", GTK_STOCK_PASTE },
......
......@@ -25,6 +25,7 @@
#include <string.h>
#include <glib-object.h>
#include <pango/pangoft2.h>
#include "text-types.h"
......@@ -104,18 +105,55 @@ gimp_font_list_add (GimpContainer *container,
}
GimpContainer *
gimp_font_list_new (void)
gimp_font_list_new (gdouble xresolution,
gdouble yresolution)
{
GimpFontList *list;
PangoContext *pango_context;
g_return_val_if_fail (xresolution > 0.0, NULL);
g_return_val_if_fail (yresolution > 0.0, NULL);
list = g_object_new (GIMP_TYPE_FONT_LIST,
"children_type", GIMP_TYPE_FONT,
"policy", GIMP_CONTAINER_POLICY_STRONG,
NULL);
list->xresolution = xresolution;
list->yresolution = yresolution;
pango_context = pango_ft2_get_context (xresolution, yresolution);
g_object_set_data_full (G_OBJECT (list), "pango-context", pango_context,
(GDestroyNotify) g_object_unref);
return GIMP_CONTAINER (list);
}
void
gimp_font_list_restore (GimpFontList *list)
{
PangoContext *pango_context;
const gchar *fonts[] = { "Sans", "Serif", "Monospace" };
gint i;
g_return_if_fail (GIMP_IS_FONT_LIST (list));
pango_context = g_object_get_data (G_OBJECT (list), "pango-context");
for (i = 0; i < G_N_ELEMENTS (fonts); i++)
{
GimpFont *font;
font = g_object_new (GIMP_TYPE_FONT,
"name", fonts[i],
"pango-context", pango_context,
NULL);
gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font));
g_object_unref (font);
}
}
static gint
gimp_font_list_font_compare_func (gconstpointer first,
gconstpointer second)
......
......@@ -40,6 +40,9 @@ typedef struct _GimpFontListClass GimpFontListClass;
struct _GimpFontList
{
GimpList parent_instance;
gdouble xresolution;
gdouble yresolution;
};
struct _GimpFontListClass
......@@ -50,7 +53,9 @@ struct _GimpFontListClass
GType gimp_font_list_get_type (void) G_GNUC_CONST;
GimpContainer * gimp_font_list_new (void);
GimpContainer * gimp_font_list_new (gdouble xresolution,
gdouble yresolution);
void gimp_font_list_restore (GimpFontList *list);
#endif /* __GIMP_FONT_LIST_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment