fixed size calculation, removed padding and the spacing between the icon
2003-03-13 Michael Natterer <mitch@gimp.org> * app/widgets/gimpcellrenderertoggle.c: fixed size calculation, removed padding and the spacing between the icon and the frame around it. * app/widgets/gimpwidgets-utils.[ch]: added gimp_get_icon_size() which returns the best matching icon size for a given allocation. * app/widgets/gimpcomponenteditor.[ch]: adjust the eye icon's size according to the preview_size. * app/widgets/gimppreviewrenderer.c (gimp_preview_renderer_default_render_stock): use gimp_get_icon_size() * app/widgets/gimpcomponenteditor.c * app/widgets/gimpcontainertreeview.c: iterate the tree model using a for() loop instead of nested if() { do { } while() } stuff.
This commit is contained in:

committed by
Michael Natterer

parent
01745138f9
commit
5f6830341d
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
|||||||
|
2003-03-13 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/widgets/gimpcellrenderertoggle.c: fixed size calculation,
|
||||||
|
removed padding and the spacing between the icon and the frame
|
||||||
|
around it.
|
||||||
|
|
||||||
|
* app/widgets/gimpwidgets-utils.[ch]: added gimp_get_icon_size()
|
||||||
|
which returns the best matching icon size for a given allocation.
|
||||||
|
|
||||||
|
* app/widgets/gimpcomponenteditor.[ch]: adjust the eye icon's
|
||||||
|
size according to the preview_size.
|
||||||
|
|
||||||
|
* app/widgets/gimppreviewrenderer.c
|
||||||
|
(gimp_preview_renderer_default_render_stock): use gimp_get_icon_size()
|
||||||
|
|
||||||
|
* app/widgets/gimpcomponenteditor.c
|
||||||
|
* app/widgets/gimpcontainertreeview.c: iterate the tree model
|
||||||
|
using a for() loop instead of nested if() { do { } while() }
|
||||||
|
stuff.
|
||||||
|
|
||||||
2003-03-13 Sven Neumann <sven@gimp.org>
|
2003-03-13 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/core-enums.h: made the GimpPreviewSize enum values a
|
* app/core/core-enums.h: made the GimpPreviewSize enum values a
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* The GIMP -- an image manipulation program
|
/* The GIMP -- an image manipulation program
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
*
|
*
|
||||||
* gimpcellrenderertoggle.h
|
* gimpcellrenderertoggle.c
|
||||||
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -135,6 +135,9 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
|
|||||||
static void
|
static void
|
||||||
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
|
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
|
||||||
{
|
{
|
||||||
|
GTK_CELL_RENDERER (cell)->xpad = 0;
|
||||||
|
GTK_CELL_RENDERER (cell)->ypad = 0;
|
||||||
|
|
||||||
cell->stock_id = NULL;
|
cell->stock_id = NULL;
|
||||||
cell->stock_size = DEFAULT_ICON_SIZE;
|
cell->stock_size = DEFAULT_ICON_SIZE;
|
||||||
}
|
}
|
||||||
@ -252,9 +255,9 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
|||||||
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
|
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
|
||||||
|
|
||||||
calc_width = (pixbuf_width +
|
calc_width = (pixbuf_width +
|
||||||
(gint) cell->xpad * 2 + widget->style->xthickness * 4);
|
(gint) cell->xpad * 2 + widget->style->xthickness * 2);
|
||||||
calc_height = (pixbuf_height +
|
calc_height = (pixbuf_height +
|
||||||
(gint) cell->ypad * 2 + widget->style->ythickness * 4);
|
(gint) cell->ypad * 2 + widget->style->ythickness * 2);
|
||||||
|
|
||||||
if (x_offset) *x_offset = 0;
|
if (x_offset) *x_offset = 0;
|
||||||
if (y_offset) *y_offset = 0;
|
if (y_offset) *y_offset = 0;
|
||||||
@ -263,15 +266,13 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
|||||||
{
|
{
|
||||||
if (x_offset)
|
if (x_offset)
|
||||||
{
|
{
|
||||||
*x_offset = (cell->xalign *
|
*x_offset = cell->xalign * (cell_area->width - calc_width);
|
||||||
(cell_area->width - calc_width - 2 * cell->xpad));
|
*x_offset = MAX (*x_offset, 0);
|
||||||
*x_offset = (MAX (*x_offset, 0) + cell->xpad);
|
|
||||||
}
|
}
|
||||||
if (y_offset)
|
if (y_offset)
|
||||||
{
|
{
|
||||||
*y_offset = (cell->yalign *
|
*y_offset = cell->yalign * (cell_area->height - calc_height);
|
||||||
(cell_area->height - calc_height - 2 * cell->ypad));
|
*y_offset = MAX (*y_offset, 0);
|
||||||
*y_offset = (MAX (*y_offset, 0) + cell->ypad);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,10 +350,10 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
|||||||
{
|
{
|
||||||
GdkRectangle draw_rect;
|
GdkRectangle draw_rect;
|
||||||
|
|
||||||
toggle_rect.x += widget->style->xthickness * 2;
|
toggle_rect.x += widget->style->xthickness;
|
||||||
toggle_rect.y += widget->style->ythickness * 2;
|
toggle_rect.y += widget->style->ythickness;
|
||||||
toggle_rect.width -= widget->style->xthickness * 4;
|
toggle_rect.width -= widget->style->xthickness * 2;
|
||||||
toggle_rect.height -= widget->style->ythickness * 4;
|
toggle_rect.height -= widget->style->ythickness * 2;
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (cell_area, &toggle_rect, &draw_rect) &&
|
if (gdk_rectangle_intersect (cell_area, &toggle_rect, &draw_rect) &&
|
||||||
gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
|
gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "gimpitemfactory.h"
|
#include "gimpitemfactory.h"
|
||||||
#include "gimpmenufactory.h"
|
#include "gimpmenufactory.h"
|
||||||
#include "gimppreviewrendererimage.h"
|
#include "gimppreviewrendererimage.h"
|
||||||
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
#include "libgimp/gimpintl.h"
|
#include "libgimp/gimpintl.h"
|
||||||
|
|
||||||
@ -157,15 +158,18 @@ gimp_component_editor_init (GimpComponentEditor *editor)
|
|||||||
gtk_tree_view_set_headers_visible (editor->view, FALSE);
|
gtk_tree_view_set_headers_visible (editor->view, FALSE);
|
||||||
|
|
||||||
editor->eye_column = gtk_tree_view_column_new ();
|
editor->eye_column = gtk_tree_view_column_new ();
|
||||||
|
gtk_tree_view_column_set_sizing (editor->eye_column,
|
||||||
|
GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||||
gtk_tree_view_append_column (editor->view, editor->eye_column);
|
gtk_tree_view_append_column (editor->view, editor->eye_column);
|
||||||
|
|
||||||
cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE);
|
editor->eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE);
|
||||||
gtk_tree_view_column_pack_start (editor->eye_column, cell, FALSE);
|
gtk_tree_view_column_pack_start (editor->eye_column, editor->eye_cell,
|
||||||
gtk_tree_view_column_set_attributes (editor->eye_column, cell,
|
FALSE);
|
||||||
|
gtk_tree_view_column_set_attributes (editor->eye_column, editor->eye_cell,
|
||||||
"active", COLUMN_VISIBLE,
|
"active", COLUMN_VISIBLE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_signal_connect (cell, "toggled",
|
g_signal_connect (editor->eye_cell, "toggled",
|
||||||
G_CALLBACK (gimp_component_editor_toggled),
|
G_CALLBACK (gimp_component_editor_toggled),
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
@ -275,7 +279,8 @@ gimp_component_editor_new (gint preview_size,
|
|||||||
|
|
||||||
editor = g_object_new (GIMP_TYPE_COMPONENT_EDITOR, NULL);
|
editor = g_object_new (GIMP_TYPE_COMPONENT_EDITOR, NULL);
|
||||||
|
|
||||||
editor->preview_size = preview_size;
|
gimp_component_editor_set_preview_size (editor, preview_size);
|
||||||
|
|
||||||
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
|
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
|
||||||
"<Channels>",
|
"<Channels>",
|
||||||
GTK_TYPE_MENU,
|
GTK_TYPE_MENU,
|
||||||
@ -289,14 +294,33 @@ void
|
|||||||
gimp_component_editor_set_preview_size (GimpComponentEditor *editor,
|
gimp_component_editor_set_preview_size (GimpComponentEditor *editor,
|
||||||
gint preview_size)
|
gint preview_size)
|
||||||
{
|
{
|
||||||
|
GtkWidget *tree_widget;
|
||||||
|
GtkIconSize icon_size;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gboolean iter_valid;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COMPONENT_EDITOR (editor));
|
g_return_if_fail (GIMP_IS_COMPONENT_EDITOR (editor));
|
||||||
g_return_if_fail (preview_size > 0 && preview_size <= GIMP_PREVIEW_MAX_SIZE);
|
g_return_if_fail (preview_size > 0 && preview_size <= GIMP_PREVIEW_MAX_SIZE);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (editor->model, &iter))
|
tree_widget = GTK_WIDGET (editor->view);
|
||||||
{
|
|
||||||
do
|
icon_size = gimp_get_icon_size (tree_widget,
|
||||||
|
GIMP_STOCK_VISIBLE,
|
||||||
|
GTK_ICON_SIZE_BUTTON,
|
||||||
|
preview_size -
|
||||||
|
2 * tree_widget->style->xthickness,
|
||||||
|
preview_size -
|
||||||
|
2 * tree_widget->style->ythickness);
|
||||||
|
|
||||||
|
g_print ("icon_size = %d\n", icon_size);
|
||||||
|
|
||||||
|
g_object_set (editor->eye_cell,
|
||||||
|
"stock-size", icon_size,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
for (iter_valid = gtk_tree_model_get_iter_first (editor->model, &iter);
|
||||||
|
iter_valid;
|
||||||
|
iter_valid = gtk_tree_model_iter_next (editor->model, &iter))
|
||||||
{
|
{
|
||||||
GimpPreviewRenderer *renderer;
|
GimpPreviewRenderer *renderer;
|
||||||
|
|
||||||
@ -312,8 +336,6 @@ gimp_component_editor_set_preview_size (GimpComponentEditor *editor,
|
|||||||
|
|
||||||
g_object_unref (renderer);
|
g_object_unref (renderer);
|
||||||
}
|
}
|
||||||
while (gtk_tree_model_iter_next (editor->model, &iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
editor->preview_size = preview_size;
|
editor->preview_size = preview_size;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ struct _GimpComponentEditor
|
|||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
GtkTreeViewColumn *eye_column;
|
GtkTreeViewColumn *eye_column;
|
||||||
|
GtkCellRenderer *eye_cell;
|
||||||
|
|
||||||
GimpChannelType clicked_component;
|
GimpChannelType clicked_component;
|
||||||
};
|
};
|
||||||
|
@ -533,13 +533,14 @@ gimp_container_tree_view_set_preview_size (GimpContainerView *view)
|
|||||||
GimpContainerTreeView *tree_view;
|
GimpContainerTreeView *tree_view;
|
||||||
GtkTreeModel *tree_model;
|
GtkTreeModel *tree_model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gboolean iter_valid;
|
||||||
|
|
||||||
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
||||||
tree_model = GTK_TREE_MODEL (tree_view->list);
|
tree_model = GTK_TREE_MODEL (tree_view->list);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (tree_model, &iter))
|
for (iter_valid = gtk_tree_model_get_iter_first (tree_model, &iter);
|
||||||
{
|
iter_valid;
|
||||||
do
|
iter_valid = gtk_tree_model_iter_next (tree_model, &iter))
|
||||||
{
|
{
|
||||||
GimpPreviewRenderer *renderer;
|
GimpPreviewRenderer *renderer;
|
||||||
|
|
||||||
@ -555,8 +556,6 @@ gimp_container_tree_view_set_preview_size (GimpContainerView *view)
|
|||||||
|
|
||||||
g_object_unref (renderer);
|
g_object_unref (renderer);
|
||||||
}
|
}
|
||||||
while (gtk_tree_model_iter_next (tree_model, &iter));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include "gimppreviewrenderer.h"
|
#include "gimppreviewrenderer.h"
|
||||||
#include "gimppreviewrenderer-utils.h"
|
#include "gimppreviewrenderer-utils.h"
|
||||||
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -660,13 +661,7 @@ gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
|
|||||||
const gchar *stock_id)
|
const gchar *stock_id)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkIconSet *icon_set;
|
GtkIconSize icon_size;
|
||||||
GtkIconSize *sizes;
|
|
||||||
gint n_sizes;
|
|
||||||
gint i;
|
|
||||||
gint width_diff = 1024;
|
|
||||||
gint height_diff = 1024;
|
|
||||||
GtkIconSize icon_size = GTK_ICON_SIZE_MENU;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
@ -684,31 +679,8 @@ gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
|
|||||||
renderer->buffer = NULL;
|
renderer->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon_set = gtk_style_lookup_icon_set (widget->style, stock_id);
|
icon_size = gimp_get_icon_size (widget, stock_id, GTK_ICON_SIZE_INVALID,
|
||||||
|
renderer->width, renderer->height);
|
||||||
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
|
||||||
|
|
||||||
for (i = 0; i < n_sizes; i++)
|
|
||||||
{
|
|
||||||
gint icon_width;
|
|
||||||
gint icon_height;
|
|
||||||
|
|
||||||
if (gtk_icon_size_lookup (sizes[i], &icon_width, &icon_height))
|
|
||||||
{
|
|
||||||
if (icon_width <= renderer->width &&
|
|
||||||
icon_height <= renderer->height &&
|
|
||||||
(ABS (icon_width - renderer->width) < width_diff ||
|
|
||||||
ABS (icon_height - renderer->height) < height_diff))
|
|
||||||
{
|
|
||||||
width_diff = ABS (icon_width - renderer->width);
|
|
||||||
height_diff = ABS (icon_height - renderer->height);
|
|
||||||
|
|
||||||
icon_size = sizes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (sizes);
|
|
||||||
|
|
||||||
pixbuf = gtk_widget_render_icon (widget, stock_id, icon_size, NULL);
|
pixbuf = gtk_widget_render_icon (widget, stock_id, icon_size, NULL);
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include "gimppreviewrenderer.h"
|
#include "gimppreviewrenderer.h"
|
||||||
#include "gimppreviewrenderer-utils.h"
|
#include "gimppreviewrenderer-utils.h"
|
||||||
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -660,13 +661,7 @@ gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
|
|||||||
const gchar *stock_id)
|
const gchar *stock_id)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkIconSet *icon_set;
|
GtkIconSize icon_size;
|
||||||
GtkIconSize *sizes;
|
|
||||||
gint n_sizes;
|
|
||||||
gint i;
|
|
||||||
gint width_diff = 1024;
|
|
||||||
gint height_diff = 1024;
|
|
||||||
GtkIconSize icon_size = GTK_ICON_SIZE_MENU;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
@ -684,31 +679,8 @@ gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
|
|||||||
renderer->buffer = NULL;
|
renderer->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon_set = gtk_style_lookup_icon_set (widget->style, stock_id);
|
icon_size = gimp_get_icon_size (widget, stock_id, GTK_ICON_SIZE_INVALID,
|
||||||
|
renderer->width, renderer->height);
|
||||||
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
|
||||||
|
|
||||||
for (i = 0; i < n_sizes; i++)
|
|
||||||
{
|
|
||||||
gint icon_width;
|
|
||||||
gint icon_height;
|
|
||||||
|
|
||||||
if (gtk_icon_size_lookup (sizes[i], &icon_width, &icon_height))
|
|
||||||
{
|
|
||||||
if (icon_width <= renderer->width &&
|
|
||||||
icon_height <= renderer->height &&
|
|
||||||
(ABS (icon_width - renderer->width) < width_diff ||
|
|
||||||
ABS (icon_height - renderer->height) < height_diff))
|
|
||||||
{
|
|
||||||
width_diff = ABS (icon_width - renderer->width);
|
|
||||||
height_diff = ABS (icon_height - renderer->height);
|
|
||||||
|
|
||||||
icon_size = sizes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (sizes);
|
|
||||||
|
|
||||||
pixbuf = gtk_widget_render_icon (widget, stock_id, icon_size, NULL);
|
pixbuf = gtk_widget_render_icon (widget, stock_id, icon_size, NULL);
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* The GIMP -- an image manipulation program
|
/* The GIMP -- an image manipulation program
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
*
|
*
|
||||||
* gimpui.c
|
* gimpwidgets-utils.c
|
||||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -285,6 +285,65 @@ gimp_table_attach_stock (GtkTable *table,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkIconSize
|
||||||
|
gimp_get_icon_size (GtkWidget *widget,
|
||||||
|
const gchar *stock_id,
|
||||||
|
GtkIconSize max_size,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
GtkIconSet *icon_set;
|
||||||
|
GtkIconSize *sizes;
|
||||||
|
gint n_sizes;
|
||||||
|
gint i;
|
||||||
|
gint width_diff = 1024;
|
||||||
|
gint height_diff = 1024;
|
||||||
|
gint max_width;
|
||||||
|
gint max_height;
|
||||||
|
GtkIconSize icon_size = GTK_ICON_SIZE_MENU;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), icon_size);
|
||||||
|
g_return_val_if_fail (stock_id != NULL, icon_size);
|
||||||
|
g_return_val_if_fail (width > 0, icon_size);
|
||||||
|
g_return_val_if_fail (height > 0, icon_size);
|
||||||
|
|
||||||
|
if (! gtk_icon_size_lookup (max_size, &max_width, &max_height))
|
||||||
|
{
|
||||||
|
max_width = 1024;
|
||||||
|
max_height = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon_set = gtk_style_lookup_icon_set (widget->style, stock_id);
|
||||||
|
|
||||||
|
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
||||||
|
|
||||||
|
for (i = 0; i < n_sizes; i++)
|
||||||
|
{
|
||||||
|
gint icon_width;
|
||||||
|
gint icon_height;
|
||||||
|
|
||||||
|
if (gtk_icon_size_lookup (sizes[i], &icon_width, &icon_height))
|
||||||
|
{
|
||||||
|
if (icon_width <= width &&
|
||||||
|
icon_height <= height &&
|
||||||
|
icon_width <= max_width &&
|
||||||
|
icon_height <= max_height &&
|
||||||
|
((width - icon_width) < width_diff ||
|
||||||
|
(height - icon_height) < height_diff))
|
||||||
|
{
|
||||||
|
width_diff = width - icon_width;
|
||||||
|
height_diff = height - icon_height;
|
||||||
|
|
||||||
|
icon_size = sizes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (sizes);
|
||||||
|
|
||||||
|
return icon_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The format string which is used to display modifier names
|
/* The format string which is used to display modifier names
|
||||||
* <Shift>, <Ctrl> and <Alt>
|
* <Shift>, <Ctrl> and <Alt>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* The GIMP -- an image manipulation program
|
/* The GIMP -- an image manipulation program
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
*
|
*
|
||||||
* gimpui.h
|
* gimpwidgets-utils.h
|
||||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,9 +23,6 @@
|
|||||||
#define __GIMP_WIDGETS_UTILS_H__
|
#define __GIMP_WIDGETS_UTILS_H__
|
||||||
|
|
||||||
|
|
||||||
typedef gpointer (* GimpGetAccelContextFunc) (gpointer data);
|
|
||||||
|
|
||||||
|
|
||||||
void gimp_message_box (const gchar *message,
|
void gimp_message_box (const gchar *message,
|
||||||
GtkCallback callback,
|
GtkCallback callback,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
@ -44,6 +41,12 @@ void gimp_table_attach_stock (GtkTable *table,
|
|||||||
gint colspan,
|
gint colspan,
|
||||||
const gchar *stock_id);
|
const gchar *stock_id);
|
||||||
|
|
||||||
|
GtkIconSize gimp_get_icon_size (GtkWidget *widget,
|
||||||
|
const gchar *stock_id,
|
||||||
|
GtkIconSize max_size,
|
||||||
|
gint width,
|
||||||
|
gint height);
|
||||||
|
|
||||||
const gchar * gimp_get_mod_name_shift (void);
|
const gchar * gimp_get_mod_name_shift (void);
|
||||||
const gchar * gimp_get_mod_name_control (void);
|
const gchar * gimp_get_mod_name_control (void);
|
||||||
const gchar * gimp_get_mod_name_alt (void);
|
const gchar * gimp_get_mod_name_alt (void);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* The GIMP -- an image manipulation program
|
/* The GIMP -- an image manipulation program
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
*
|
*
|
||||||
* gimpcellrenderertoggle.h
|
* gimpcellrenderertoggle.c
|
||||||
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -135,6 +135,9 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
|
|||||||
static void
|
static void
|
||||||
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
|
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
|
||||||
{
|
{
|
||||||
|
GTK_CELL_RENDERER (cell)->xpad = 0;
|
||||||
|
GTK_CELL_RENDERER (cell)->ypad = 0;
|
||||||
|
|
||||||
cell->stock_id = NULL;
|
cell->stock_id = NULL;
|
||||||
cell->stock_size = DEFAULT_ICON_SIZE;
|
cell->stock_size = DEFAULT_ICON_SIZE;
|
||||||
}
|
}
|
||||||
@ -252,9 +255,9 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
|||||||
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
|
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
|
||||||
|
|
||||||
calc_width = (pixbuf_width +
|
calc_width = (pixbuf_width +
|
||||||
(gint) cell->xpad * 2 + widget->style->xthickness * 4);
|
(gint) cell->xpad * 2 + widget->style->xthickness * 2);
|
||||||
calc_height = (pixbuf_height +
|
calc_height = (pixbuf_height +
|
||||||
(gint) cell->ypad * 2 + widget->style->ythickness * 4);
|
(gint) cell->ypad * 2 + widget->style->ythickness * 2);
|
||||||
|
|
||||||
if (x_offset) *x_offset = 0;
|
if (x_offset) *x_offset = 0;
|
||||||
if (y_offset) *y_offset = 0;
|
if (y_offset) *y_offset = 0;
|
||||||
@ -263,15 +266,13 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
|||||||
{
|
{
|
||||||
if (x_offset)
|
if (x_offset)
|
||||||
{
|
{
|
||||||
*x_offset = (cell->xalign *
|
*x_offset = cell->xalign * (cell_area->width - calc_width);
|
||||||
(cell_area->width - calc_width - 2 * cell->xpad));
|
*x_offset = MAX (*x_offset, 0);
|
||||||
*x_offset = (MAX (*x_offset, 0) + cell->xpad);
|
|
||||||
}
|
}
|
||||||
if (y_offset)
|
if (y_offset)
|
||||||
{
|
{
|
||||||
*y_offset = (cell->yalign *
|
*y_offset = cell->yalign * (cell_area->height - calc_height);
|
||||||
(cell_area->height - calc_height - 2 * cell->ypad));
|
*y_offset = MAX (*y_offset, 0);
|
||||||
*y_offset = (MAX (*y_offset, 0) + cell->ypad);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,10 +350,10 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
|||||||
{
|
{
|
||||||
GdkRectangle draw_rect;
|
GdkRectangle draw_rect;
|
||||||
|
|
||||||
toggle_rect.x += widget->style->xthickness * 2;
|
toggle_rect.x += widget->style->xthickness;
|
||||||
toggle_rect.y += widget->style->ythickness * 2;
|
toggle_rect.y += widget->style->ythickness;
|
||||||
toggle_rect.width -= widget->style->xthickness * 4;
|
toggle_rect.width -= widget->style->xthickness * 2;
|
||||||
toggle_rect.height -= widget->style->ythickness * 4;
|
toggle_rect.height -= widget->style->ythickness * 2;
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (cell_area, &toggle_rect, &draw_rect) &&
|
if (gdk_rectangle_intersect (cell_area, &toggle_rect, &draw_rect) &&
|
||||||
gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
|
gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
|
||||||
|
Reference in New Issue
Block a user