Commit 3d0adbf1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

removed GimpZoomWidgetType.

2005-09-25  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpwidgetsenums.[ch]: removed GimpZoomWidgetType.

	* libgimpwidgets/gimpzoommodel.[ch]: removed gimp_zoom_widget_new()
	in favor of gimp_zoom_button_new().

	* libgimp/gimpzoompreview.c: changed accordingly.

	* libgimpwidgets/gimpwidgets.def: updated.

	* plug-ins/MapObject/mapobject_main.[ch]
	* plug-ins/MapObject/mapobject_preview.c
	* plug-ins/MapObject/mapobject_ui.c: use a GimpZoomModel and let
	it create the zoom buttons.

	* plug-ins/MapObject/mapobject_apply.c
	* plug-ins/MapObject/mapobject_image.c
	* plug-ins/MapObject/mapobject_shade.c: include "gimp/gimpui.h".
parent d4776ce0
2005-09-25 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpwidgetsenums.[ch]: removed GimpZoomWidgetType.
* libgimpwidgets/gimpzoommodel.[ch]: removed gimp_zoom_widget_new()
in favor of gimp_zoom_button_new().
* libgimp/gimpzoompreview.c: changed accordingly.
* libgimpwidgets/gimpwidgets.def: updated.
* plug-ins/MapObject/mapobject_main.[ch]
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_ui.c: use a GimpZoomModel and let
it create the zoom buttons.
* plug-ins/MapObject/mapobject_apply.c
* plug-ins/MapObject/mapobject_image.c
* plug-ins/MapObject/mapobject_shade.c: include "gimp/gimpui.h".
2005-09-25 Michael Natterer <mitch@gimp.org>
* plug-ins/help/Makefile.am (gimp_help_lookup_LDADD): link
......
2005-09-25 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/tmpl/gimpstock.sgml
* libgimpwidgets/tmpl/gimpzoommodel.sgml: updated.
2005-09-25 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-sections.txt
......
......@@ -569,8 +569,8 @@ GIMP_STOCK_PASTE_AS_NEW
GIMP_STOCK_PASTE_INTO
GIMP_STOCK_PATH_STROKE
GIMP_STOCK_PLUGIN
GIMP_STOCK_QMASK_OFF
GIMP_STOCK_QMASK_ON
GIMP_STOCK_QUICK_MASK_OFF
GIMP_STOCK_QUICK_MASK_ON
GIMP_STOCK_HISTOGRAM
GIMP_STOCK_HISTOGRAM_LINEAR
GIMP_STOCK_HISTOGRAM_LOGARITHMIC
......@@ -694,6 +694,7 @@ GIMP_STOCK_TOOL_DODGE
GIMP_STOCK_TOOL_ELLIPSE_SELECT
GIMP_STOCK_TOOL_ERASER
GIMP_STOCK_TOOL_FLIP
GIMP_STOCK_TOOL_FOREGROUND_SELECT
GIMP_STOCK_TOOL_FREE_SELECT
GIMP_STOCK_TOOL_FUZZY_SELECT
GIMP_STOCK_TOOL_HUE_SATURATION
......@@ -1018,11 +1019,13 @@ GIMP_SCROLLED_PREVIEW_GET_CLASS
<FILE>gimpzoommodel</FILE>
<TITLE>GimpZoomModel</TITLE>
GimpZoomModel
GimpZoomType
gimp_zoom_model_new
gimp_zoom_model_set_range
gimp_zoom_model_zoom
gimp_zoom_model_get_factor
gimp_zoom_model_get_fraction
gimp_zoom_widget_new
gimp_zoom_button_new
gimp_zoom_model_zoom_step
<SUBSECTION Standard>
GimpZoomModelClass
......@@ -1033,6 +1036,8 @@ gimp_zoom_model_get_type
GIMP_ZOOM_MODEL_CLASS
GIMP_IS_ZOOM_MODEL_CLASS
GIMP_ZOOM_MODEL_GET_CLASS
GIMP_TYPE_ZOOM_TYPE
gimp_zoom_type_get_type
</SECTION>
<SECTION>
......
......@@ -156,16 +156,16 @@ RTL variant
<!-- ##### MACRO GIMP_STOCK_QMASK_OFF ##### -->
<!-- ##### MACRO GIMP_STOCK_QUICK_MASK_OFF ##### -->
<para xml:base="../../gimpstock.xml">
<inlinegraphic fileref="stock-qmask-off-16.png" format="png"></inlinegraphic>
<inlinegraphic fileref="stock-quick-mask-off-16.png" format="png"></inlinegraphic>
</para>
<!-- ##### MACRO GIMP_STOCK_QMASK_ON ##### -->
<!-- ##### MACRO GIMP_STOCK_QUICK_MASK_ON ##### -->
<para xml:base="../../gimpstock.xml">
<inlinegraphic fileref="stock-qmask-on-16.png" format="png"></inlinegraphic>
<inlinegraphic fileref="stock-quick-mask-on-16.png" format="png"></inlinegraphic>
</para>
......@@ -1102,6 +1102,14 @@ RTL variant
<!-- ##### MACRO GIMP_STOCK_TOOL_FOREGROUND_SELECT ##### -->
<para xml:base="../../gimpstock.xml">
<inlinegraphic fileref="stock-tool-foreground-select-22.png" format="png"></inlinegraphic>
<inlinegraphic fileref="stock-tool-foreground-select-16.png" format="png"></inlinegraphic>
</para>
<!-- ##### MACRO GIMP_STOCK_TOOL_FREE_SELECT ##### -->
<para xml:base="../../gimpstock.xml">
<inlinegraphic fileref="stock-tool-free-select-22.png" format="png"></inlinegraphic>
......
......@@ -48,6 +48,19 @@ GimpZoomModel
</para>
<!-- ##### ENUM GimpZoomType ##### -->
<para>
</para>
@GIMP_ZOOM_IN:
@GIMP_ZOOM_OUT:
@GIMP_ZOOM_IN_MORE:
@GIMP_ZOOM_OUT_MORE:
@GIMP_ZOOM_IN_MAX:
@GIMP_ZOOM_OUT_MAX:
@GIMP_ZOOM_TO:
<!-- ##### FUNCTION gimp_zoom_model_new ##### -->
<para>
......@@ -66,6 +79,16 @@ GimpZoomModel
@max:
<!-- ##### FUNCTION gimp_zoom_model_zoom ##### -->
<para>
</para>
@model:
@zoom_type:
@scale:
<!-- ##### FUNCTION gimp_zoom_model_get_factor ##### -->
<para>
......@@ -80,18 +103,19 @@ GimpZoomModel
</para>
@zoom_factor:
@model:
@numerator:
@denominator:
<!-- ##### FUNCTION gimp_zoom_widget_new ##### -->
<!-- ##### FUNCTION gimp_zoom_button_new ##### -->
<para>
</para>
@model:
@type:
@zoom_type:
@icon_size:
@Returns:
......
......@@ -108,15 +108,15 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
gtk_widget_show (button_bar);
/* zoom out */
button = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_OUT_BUTTON);
gtk_box_pack_start (GTK_BOX (button_bar), button,
FALSE, FALSE, 0);
button = gimp_zoom_button_new (priv->zoom,
GIMP_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_box_pack_start (GTK_BOX (button_bar), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* zoom in */
button = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_IN_BUTTON);
gtk_box_pack_start (GTK_BOX (button_bar), button,
FALSE, FALSE, 0);
button = gimp_zoom_button_new (priv->zoom,
GIMP_ZOOM_IN, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_box_pack_start (GTK_BOX (button_bar), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* label */
......
......@@ -328,6 +328,7 @@ EXPORTS
gimp_unit_menu_set_unit
gimp_unit_menu_update
gimp_widgets_init
gimp_zoom_button_new
gimp_zoom_model_get_factor
gimp_zoom_model_get_fraction
gimp_zoom_model_get_type
......@@ -335,6 +336,5 @@ EXPORTS
gimp_zoom_model_set_range
gimp_zoom_model_zoom
gimp_zoom_model_zoom_step
gimp_zoom_widget_new
gimp_zoom_type_get_type
......@@ -171,35 +171,6 @@ gimp_size_entry_update_policy_get_type (void)
return type;
}
GType
gimp_zoom_widget_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_ZOOM_IN_BUTTON, "GIMP_ZOOM_IN_BUTTON", "in-button" },
{ GIMP_ZOOM_OUT_BUTTON, "GIMP_ZOOM_OUT_BUTTON", "out-button" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_ZOOM_IN_BUTTON, "GIMP_ZOOM_IN_BUTTON", NULL },
{ GIMP_ZOOM_OUT_BUTTON, "GIMP_ZOOM_OUT_BUTTON", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpZoomWidgetType", values);
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_zoom_type_get_type (void)
{
......
......@@ -90,16 +90,6 @@ typedef enum
} GimpSizeEntryUpdatePolicy;
#define GIMP_TYPE_ZOOM_WIDGET_TYPE (gimp_zoom_model_widget_type_get_type ())
GType gimp_zoom_widget_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_ZOOM_IN_BUTTON,
GIMP_ZOOM_OUT_BUTTON
} GimpZoomWidgetType;
#define GIMP_TYPE_ZOOM_TYPE (gimp_zoom_type_get_type ())
GType gimp_zoom_type_get_type (void) G_GNUC_CONST;
......
......@@ -409,52 +409,70 @@ gimp_zoom_model_get_fraction (GimpZoomModel *model,
}
}
static GtkWidget *
zoom_button_new (const gchar *stock_id,
GtkIconSize icon_size)
{
GtkWidget *button;
if (icon_size > 0)
{
GtkWidget *image;
button = gtk_button_new ();
image = gtk_image_new_from_stock (stock_id, icon_size);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
}
else
{
button = gtk_button_new_from_stock (stock_id);
}
return button;
}
/**
* gimp_zoom_widget_new:
* gimp_zoom_button_new:
* @model: a #GimpZoomModel
* @type: the type of widget to create
*
* Creates a new widget to interact with the #GimpZoomModel.
* @zoom_type:
* @icon_size: use 0 for a button with text labels
*
* Return value: a new #GtkWidget.
* Return value: a newly created GtkButton
*
* Since GIMP 2.4
**/
GtkWidget *
gimp_zoom_widget_new (GimpZoomModel *model,
GimpZoomWidgetType type)
gimp_zoom_button_new (GimpZoomModel *model,
GimpZoomType zoom_type,
GtkIconSize icon_size)
{
GtkWidget *button;
GtkWidget *image;
GtkWidget *button = NULL;
g_return_val_if_fail (GIMP_IS_ZOOM_MODEL (model), NULL);
switch (type)
switch (zoom_type)
{
case GIMP_ZOOM_IN_BUTTON:
button = gtk_button_new ();
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_IN,
GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
case GIMP_ZOOM_IN:
button = zoom_button_new (GTK_STOCK_ZOOM_IN, icon_size);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gimp_zoom_model_zoom_in),
model);
return button;
break;
case GIMP_ZOOM_OUT_BUTTON:
button = gtk_button_new ();
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT,
GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
case GIMP_ZOOM_OUT:
button = zoom_button_new (GTK_STOCK_ZOOM_OUT, icon_size);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gimp_zoom_model_zoom_out),
model);
return button;
break;
default:
g_warning ("sorry, no button for this zoom type (%d)", zoom_type);
break;
}
return NULL;
return button;
}
/**
......
......@@ -67,8 +67,9 @@ void gimp_zoom_model_get_fraction (GimpZoomModel *model,
gint *numerator,
gint *denominator);
GtkWidget * gimp_zoom_widget_new (GimpZoomModel *model,
GimpZoomWidgetType type);
GtkWidget * gimp_zoom_button_new (GimpZoomModel *model,
GimpZoomType zoom_type,
GtkIconSize icon_size);
gdouble gimp_zoom_model_zoom_step (GimpZoomType zoom_type,
gdouble scale);
......
......@@ -9,6 +9,7 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "mapobject_main.h"
#include "mapobject_image.h"
......
......@@ -14,6 +14,7 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "mapobject_main.h"
#include "mapobject_preview.h"
......
......@@ -74,7 +74,8 @@ set_default_settings (void)
mapvals.cylinder_radius = 0.25;
mapvals.cylinder_length = 1.0;
mapvals.preview_zoom_factor = 0;
mapvals.zoom_model = gimp_zoom_model_new ();
gimp_zoom_model_set_range (mapvals.zoom_model, 0.25, 1.0);
mapvals.lightsource.type = POINT_LIGHT;
......
......@@ -63,7 +63,7 @@ typedef struct
gint showgrid;
gint showcaps;
glong preview_zoom_factor;
GimpZoomModel *zoom_model;
gdouble alpha,beta,gamma;
gdouble maxdepth;
......
......@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "mapobject_main.h"
#include "mapobject_ui.h"
......@@ -395,11 +396,12 @@ update_light (gint xpos,
gint ypos)
{
gint startx, starty, pw, ph;
gdouble zoom = gimp_zoom_model_get_factor (mapvals.zoom_model);
pw = PREVIEW_WIDTH >> mapvals.preview_zoom_factor;
ph = PREVIEW_HEIGHT >> mapvals.preview_zoom_factor;
startx = (PREVIEW_WIDTH - pw) >> 1;
starty = (PREVIEW_HEIGHT - ph) >> 1;
pw = PREVIEW_WIDTH * zoom;
ph = PREVIEW_HEIGHT * zoom;
startx = (PREVIEW_WIDTH - pw) / 2;
starty = (PREVIEW_HEIGHT - ph) / 2;
gimp_vector_2d_to_3d (startx, starty, pw, ph, xpos, ypos,
&mapvals.viewpoint, &mapvals.lightsource.position);
......@@ -414,6 +416,7 @@ void
draw_preview_image (gint docompute)
{
gint startx, starty, pw, ph;
gdouble zoom;
GdkColor color;
color.red = 0x0;
......@@ -429,10 +432,12 @@ draw_preview_image (gint docompute)
gdk_gc_set_function (gc, GDK_COPY);
linetab[0].x1 = -1;
pw = PREVIEW_WIDTH >> mapvals.preview_zoom_factor;
ph = PREVIEW_HEIGHT >> mapvals.preview_zoom_factor;
startx = (PREVIEW_WIDTH - pw) >> 1;
starty = (PREVIEW_HEIGHT - ph) >> 1;
zoom = gimp_zoom_model_get_factor (mapvals.zoom_model);
pw = PREVIEW_WIDTH * zoom;
ph = PREVIEW_HEIGHT * zoom;
startx = (PREVIEW_WIDTH - pw) / 2;
starty = (PREVIEW_HEIGHT - ph) / 2;
if (docompute == TRUE)
{
......@@ -471,6 +476,7 @@ void
draw_preview_wireframe (void)
{
gint startx, starty, pw, ph;
gdouble zoom;
GdkColor color;
color.red = 0x0;
......@@ -485,10 +491,12 @@ draw_preview_wireframe (void)
gdk_gc_set_function (gc, GDK_INVERT);
pw = PREVIEW_WIDTH >> mapvals.preview_zoom_factor;
ph = PREVIEW_HEIGHT >> mapvals.preview_zoom_factor;
startx = (PREVIEW_WIDTH - pw) >> 1;
starty = (PREVIEW_HEIGHT - ph) >> 1;
zoom = gimp_zoom_model_get_factor (mapvals.zoom_model);
pw = PREVIEW_WIDTH * zoom;
ph = PREVIEW_HEIGHT * zoom;
startx = (PREVIEW_WIDTH - pw) / 2;
starty = (PREVIEW_HEIGHT - ph) / 2;
clear_wireframe ();
draw_wireframe (startx, starty, pw, ph);
......
......@@ -7,6 +7,7 @@
#include <string.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "mapobject_apply.h"
#include "mapobject_main.h"
......
......@@ -299,38 +299,12 @@ preview_callback (GtkWidget *widget,
linetab[0].x1 = -1;
}
/*********************************************/
/* Main window "-" (zoom in) button callback */
/*********************************************/
static void
zoomout_callback (GtkWidget *widget,
gpointer data)
zoom_notify_callback (GObject *model)
{
if (mapvals.preview_zoom_factor < 2)
{
mapvals.preview_zoom_factor++;
if (linetab[0].x1 != -1)
clear_wireframe ();
draw_preview_image (TRUE);
}
}
/**********************************************/
/* Main window "+" (zoom out) button callback */
/**********************************************/
static void
zoomin_callback (GtkWidget *widget,
gpointer data)
{
if (mapvals.preview_zoom_factor > 0)
{
mapvals.preview_zoom_factor--;
if (linetab[0].x1 != -1)
clear_wireframe ();
draw_preview_image (TRUE);
}
}
/**********************************************/
......@@ -1361,7 +1335,6 @@ main_dialog (GimpDrawable *drawable)
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *image;
GtkWidget *toggle;
gboolean run = FALSE;
......@@ -1431,34 +1404,20 @@ main_dialog (GimpDrawable *drawable)
gimp_help_set_help_data (button, _("Recompute preview image"), NULL);
button = gtk_button_new ();
button = gimp_zoom_button_new (mapvals.zoom_model,
GIMP_ZOOM_IN, GTK_ICON_SIZE_MENU);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
g_signal_connect (button, "clicked",
G_CALLBACK (zoomout_callback),
NULL);
gimp_help_set_help_data (button, _("Zoom out (make image smaller)"), NULL);
button = gtk_button_new ();
button = gimp_zoom_button_new (mapvals.zoom_model,
GIMP_ZOOM_OUT, GTK_ICON_SIZE_MENU);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
g_signal_connect (button, "clicked",
G_CALLBACK (zoomin_callback),
g_signal_connect (mapvals.zoom_model, "notify::value",
G_CALLBACK (zoom_notify_callback),
NULL);
gimp_help_set_help_data (button, _("Zoom in (make image bigger)"), NULL);
toggle = gtk_check_button_new_with_mnemonic (_("Show preview _wireframe"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), mapvals.showgrid);
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
......@@ -1468,8 +1427,6 @@ main_dialog (GimpDrawable *drawable)
G_CALLBACK (togglegrid_update),
&mapvals.showgrid);
gimp_help_set_help_data (toggle, _("Show/hide preview wireframe"), NULL);
create_main_notebook (main_hbox);
/* Endmarkers for line table */
......
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