Commit 9f3c7944 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

libgimpwidgets/Makefile.am libgimpwidgets/gimpwidgets.h

2004-04-20  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets.h
	* libgimpwidgets/gimpwidgetstypes.h
	* libgimpwidgets/gimpintcombobox.[ch]: added new widget
	GimpIntComboBox, a GtkComboBox with a simple list store to hold a
	label and an associated integer value. This is going to replace
	gimp_int_option_menu.

	* plug-ins/common/jpeg.c
	* plug-ins/print/gimp_main_window.c: ported these two plug-ins to
	the newly added widget.

2004-04-20  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/libgimpwidgets-docs.sgml
	* libgimpwidgets/libgimpwidgets-sections.txt
	* libgimpwidgets/libgimpwidgets.types
	* libgimpwidgets/tmpl/gimpintcombobox.sgml: added docs for the new
	GimpIntComboBox widget.
parent c5e41cdf
2004-04-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets.h
* libgimpwidgets/gimpwidgetstypes.h
* libgimpwidgets/gimpintcombobox.[ch]: added new widget
GimpIntComboBox, a GtkComboBox with a simple list store to hold a
label and an associated integer value. This is going to replace
gimp_int_option_menu.
* plug-ins/common/jpeg.c
* plug-ins/print/gimp_main_window.c: ported these two plug-ins to
the newly added widget.
2004-04-20 Sven Neumann <sven@gimp.org>
* plug-ins/gfig/gfig.c: removed unused return locations for menu
......
2004-04-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-docs.sgml
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/libgimpwidgets.types
* libgimpwidgets/tmpl/gimpintcombobox.sgml: added docs for the new
GimpIntComboBox widget.
2004-04-19 Sven Neumann <sven@gimp.org>
* app/app-sections.txt: more updates (everything but the new actions).
......
......@@ -27,6 +27,7 @@
<xi:include href="xml/gimpcolorselection.xml" />
<xi:include href="xml/gimpdialog.xml" />
<xi:include href="xml/gimpfileentry.xml" />
<xi:include href="xml/gimpintcombobox.xml" />
<xi:include href="xml/gimpmemsizeentry.xml" />
<xi:include href="xml/gimpoffsetarea.xml" />
<xi:include href="xml/gimppatheditor.xml" />
......
......@@ -160,6 +160,25 @@ GIMP_IS_PIXMAP_CLASS
GIMP_PIXMAP_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpintcombobox</FILE>
<TITLE>GimpIntComboBox</TITLE>
GimpIntComboBox
gimp_int_combo_box_new
gimp_int_combo_box_new_valist
gimp_int_combo_box_set_active
gimp_int_combo_box_get_active
<SUBSECTION Standard>
GimpIntComboBoxClass
GIMP_INT_COMBO_BOX
GIMP_IS_INT_COMBO_BOX
GIMP_TYPE_INT_COMBO_BOX
gimp_int_combo_box_get_type
GIMP_INT_COMBO_BOX_CLASS
GIMP_IS_INT_COMBO_BOX_CLASS
GIMP_INT_COMBO_BOX_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpmemsizeentry</FILE>
<TITLE>GimpMemsizeEntry</TITLE>
......
......@@ -18,6 +18,7 @@ gimp_color_select_get_type
gimp_color_selection_get_type
gimp_dialog_get_type
gimp_file_entry_get_type
gimp_int_combo_box_get_type
gimp_memsize_entry_get_type
gimp_offset_area_get_type
gimp_path_editor_get_type
......
<!-- ##### SECTION Title ##### -->
GimpIntComboBox
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GimpIntComboBox ##### -->
<para>
</para>
@parent_instance:
<!-- ##### FUNCTION gimp_int_combo_box_new ##### -->
<para>
</para>
@first_label:
@first_value:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_int_combo_box_new_valist ##### -->
<para>
</para>
@first_label:
@first_value:
@values:
@Returns:
<!-- ##### FUNCTION gimp_int_combo_box_set_active ##### -->
<para>
</para>
@combo_box:
@value:
@Returns:
<!-- ##### FUNCTION gimp_int_combo_box_get_active ##### -->
<para>
</para>
@combo_box:
@value:
@Returns:
......@@ -92,6 +92,8 @@ libgimpwidgets_2_0_la_sources = \
gimpfileentry.h \
gimphelpui.c \
gimphelpui.h \
gimpintcombobox.c \
gimpintcombobox.h \
gimpmemsizeentry.c \
gimpmemsizeentry.h \
gimpoffsetarea.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpintcombobox.c
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gimpwidgetstypes.h"
#include "gimpintcombobox.h"
enum
{
GIMP_INT_STORE_VALUE,
GIMP_INT_STORE_LABEL
};
static void gimp_int_combo_box_init (GimpIntComboBox *combo_box);
GType
gimp_int_combo_box_get_type (void)
{
static GType box_type = 0;
if (! box_type)
{
static const GTypeInfo box_info =
{
sizeof (GimpIntComboBoxClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpIntComboBox),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_int_combo_box_init
};
box_type = g_type_register_static (GTK_TYPE_COMBO_BOX,
"GimpIntComboBox",
&box_info, 0);
}
return box_type;
}
static void
gimp_int_combo_box_init (GimpIntComboBox *combo_box)
{
GtkListStore *store;
GtkCellRenderer *cell;
store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
"text", GIMP_INT_STORE_LABEL,
NULL);
}
/**
* gimp_int_combo_box_new:
* @first_label: the label of the first item
* @first_value: the value of the first item
* @...: a %NULL terminated list of more label, value pairs
*
* Creates a GtkComboBox that has integer values associated with each
* item. The items to fill the combo box with are specified as a %NULL
* terminated list of label, value pairs.
*
* Return value: a new #GimpIntComboBox.
*
* Since: 2.2
**/
GtkWidget *
gimp_int_combo_box_new (const gchar *first_label,
gint first_value,
...)
{
GtkWidget *combo_box;
va_list args;
va_start (args, first_value);
combo_box = gimp_int_combo_box_new_valist (first_label, first_value, args);
va_end (args);
return combo_box;
}
/**
* gimp_int_combo_box_new_valist:
* @first_label: the label of the first item
* @first_value: the value of the first item
* @values: a va_list with more values
*
* A variant of gimp_int_combo_box_new() that takes a va_list. Useful
* for language bindings.
*
* Return value: a new #GimpIntComboBox.
*
* Since: 2.2
**/
GtkWidget *
gimp_int_combo_box_new_valist (const gchar *first_label,
gint first_value,
va_list values)
{
GtkWidget *combo_box;
GtkListStore *store;
const gchar *label;
gint value;
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
for (label = first_label, value = first_value;
label;
label = va_arg (values, const gchar *), value = va_arg (values, gint))
{
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
GIMP_INT_STORE_VALUE, value,
GIMP_INT_STORE_LABEL, label,
-1);
}
return combo_box;
}
/**
* gimp_int_combo_box_set_active:
* @combo_box: a #GimpIntComboBox
* @value: an integer value
*
* Looks up the item that belongs to the given @value and makes it the
* selected item in the @combo_box.
*
* Return value: %TRUE on success or %FALSE if there was no item for
* this value.
*
* Since: 2.2
**/
gboolean
gimp_int_combo_box_set_active (GimpIntComboBox *combo_box,
gint value)
{
GtkTreeModel *model;
GtkTreeIter iter;
gboolean iter_valid;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
iter_valid;
iter_valid = gtk_tree_model_iter_next (model, &iter))
{
gint this;
gtk_tree_model_get (model, &iter,
GIMP_INT_STORE_VALUE, &this,
-1);
if (this == value)
break;
}
if (iter_valid)
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
return TRUE;
}
return FALSE;
}
/**
* gimp_int_combo_box_get_active:
* @combo_box: a #GimpIntComboBox
* @value: return location for the integer value
*
* Retrieves the value of the selected (active) item in the @combo_box.
*
* Return value: %TRUE if @value has been set or %FALSE if no item was
* active.
*
* Since: 2.2
**/
gboolean
gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
gint *value)
{
GtkTreeIter iter;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE);
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
{
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)),
&iter,
GIMP_INT_STORE_VALUE, value,
-1);
return TRUE;
}
return FALSE;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpintcombobox.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_INT_COMBO_BOX_H__
#define __GIMP_INT_COMBO_BOX_H__
#include <gtk/gtkcombobox.h>
#define GIMP_TYPE_INT_COMBO_BOX (gimp_int_combo_box_get_type ())
#define GIMP_INT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBox))
#define GIMP_INT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBoxClass))
#define GIMP_IS_INT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_INT_COMBO_BOX))
#define GIMP_IS_INT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_INT_COMBO_BOX))
#define GIMP_INT_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBoxClass))
typedef struct _GimpIntComboBoxClass GimpIntComboBoxClass;
struct _GimpIntComboBoxClass
{
GtkComboBoxClass parent_instance;
};
struct _GimpIntComboBox
{
GtkComboBox parent_instance;
};
GType gimp_int_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_int_combo_box_new (const gchar *first_label,
gint first_value,
...);
GtkWidget * gimp_int_combo_box_new_valist (const gchar *first_label,
gint first_value,
va_list values);
gboolean gimp_int_combo_box_set_active (GimpIntComboBox *combo_box,
gint value);
gboolean gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
gint *value);
#endif /* __GIMP_INT_COMBO_BOX_H__ */
......@@ -41,6 +41,7 @@
#include <libgimpwidgets/gimpdialog.h>
#include <libgimpwidgets/gimpfileentry.h>
#include <libgimpwidgets/gimphelpui.h>
#include <libgimpwidgets/gimpintcombobox.h>
#include <libgimpwidgets/gimpmemsizeentry.h>
#include <libgimpwidgets/gimpoffsetarea.h>
#include <libgimpwidgets/gimppatheditor.h>
......
......@@ -69,6 +69,7 @@ typedef struct _GimpColorSelect GimpColorSelect;
typedef struct _GimpColorSelection GimpColorSelection;
typedef struct _GimpDialog GimpDialog;
typedef struct _GimpFileEntry GimpFileEntry;
typedef struct _GimpIntComboBox GimpIntComboBox;
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
typedef struct _GimpOffsetArea GimpOffsetArea;
typedef struct _GimpPathEditor GimpPathEditor;
......
......@@ -255,7 +255,7 @@ static void save_restart_update (GtkAdjustment *adjustment,
static void make_preview (void);
static void destroy_preview (void);
static void menu_callback (GtkWidget *widget,
static void combo_changed_callback (GtkWidget *widget,
gpointer data);
......@@ -1664,7 +1664,7 @@ save_dialog (void)
GtkWidget *preview;
/* GtkWidget *preview_size; -- global */
GtkWidget *menu;
GtkWidget *combo;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
......@@ -1884,42 +1884,40 @@ save_dialog (void)
#endif
/* Subsampling */
menu =
gimp_int_option_menu_new (FALSE,
G_CALLBACK (menu_callback),
&jsvals.subsmp, jsvals.subsmp,
combo = gimp_int_combo_box_new ("2x2,1x1,1x1", 0,
"2x1,1x1,1x1 (4:2:2)", 1,
"1x1,1x1,1x1", 2,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), jsvals.subsmp);
"2x2,1x1,1x1", 0, NULL,
"2x1,1x1,1x1 (4:2:2)", 1, NULL,
"1x1,1x1,1x1", 2, NULL,
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (combo_changed_callback),
&jsvals.subsmp);
gimp_table_attach_aligned (GTK_TABLE (table), 1, 7,
_("Subsampling:"),
1.0, 0.5,
menu, 1, FALSE);
combo, 1, FALSE);
dtype = gimp_drawable_type (drawable_ID_global);
if (dtype != GIMP_RGB_IMAGE && dtype != GIMP_RGBA_IMAGE)
gtk_widget_set_sensitive (menu, FALSE);
gtk_widget_set_sensitive (combo, FALSE);
/* DCT method */
menu =
gimp_int_option_menu_new (FALSE,
G_CALLBACK (menu_callback),
&jsvals.dct, jsvals.dct,
_("Fast Integer"), 1, NULL,
_("Integer"), 0, NULL,
_("Floating-Point"), 2, NULL,
combo = gimp_int_combo_box_new (_("Fast Integer"), 1,
_("Integer"), 0,
_("Floating-Point"), 2,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), jsvals.dct);
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (combo_changed_callback),
&jsvals.dct);
gimp_table_attach_aligned (GTK_TABLE (table), 1, 8,
_("DCT method (Speed/quality tradeoff):"),
1.0, 0.5,
menu, 1, FALSE);
combo, 1, FALSE);
com_frame = gtk_frame_new (_("Image comments"));
gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0);
......@@ -1990,9 +1988,10 @@ save_restart_update (GtkAdjustment *adjustment,
}
static void
menu_callback (GtkWidget *widget,
gpointer data)
combo_changed_callback (GtkWidget *widget,
gpointer data)
{
gimp_menu_item_update (widget, data);
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) data);
make_preview ();
}
......@@ -255,7 +255,7 @@ static void save_restart_update (GtkAdjustment *adjustment,
static void make_preview (void);
static void destroy_preview (void);
static void menu_callback (GtkWidget *widget,
static void combo_changed_callback (GtkWidget *widget,
gpointer data);
......@@ -1664,7 +1664,7 @@ save_dialog (void)
GtkWidget *preview;
/* GtkWidget *preview_size; -- global */
GtkWidget *menu;
GtkWidget *combo;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
......@@ -1884,42 +1884,40 @@ save_dialog (void)
#endif
/* Subsampling */
menu =
gimp_int_option_menu_new (FALSE,
G_CALLBACK (menu_callback),
&jsvals.subsmp, jsvals.subsmp,
combo = gimp_int_combo_box_new ("2x2,1x1,1x1", 0,
"2x1,1x1,1x1 (4:2:2)", 1,
"1x1,1x1,1x1", 2,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), jsvals.subsmp);
"2x2,1x1,1x1", 0, NULL,
"2x1,1x1,1x1 (4:2:2)", 1, NULL,
"1x1,1x1,1x1", 2, NULL,
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (combo_changed_callback),
&jsvals.subsmp);
gimp_table_attach_aligned (GTK_TABLE (table), 1, 7,
_("Subsampling:"),
1.0, 0.5,
menu, 1, FALSE);