Commit a0e845c8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

libgimpwidgets/gimpmemsizeentry.c ported to GimpIntComboBox.

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

	* libgimpwidgets/gimpmemsizeentry.c
	* modules/cdisplay_proof.c: ported to GimpIntComboBox.

	* libgimpwidgets/gimpwidgets.[ch]: declared the gimp option_menu
	API as deprecated and removed the code here.

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpoldwidgets.[ch]: new files with deprecated
	code, guarded with #ifndef GIMP_DISABLE_DEPRECATED ... #endif.

	* libgimpwidgets/gimpintcombobox.h: added G_BEGIN_DECLS, G_END_DECLS.

	* configure.in (CPP_FLAGS): added -DGIMP_DISABLE_DEPRECATED.

	* app/widgets/gimpwidgets-constructors.c: added a #warning and
	#undef GIMP_DISABLE_DEPRECATED. The paint mode menu is the last
	remaining user of gimp_int_option_menu_new().
parent c8efb903
2004-04-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpmemsizeentry.c
* modules/cdisplay_proof.c: ported to GimpIntComboBox.
* libgimpwidgets/gimpwidgets.[ch]: declared the gimp option_menu
API as deprecated and removed the code here.
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpoldwidgets.[ch]: new files with deprecated
code, guarded with #ifndef GIMP_DISABLE_DEPRECATED ... #endif.
* libgimpwidgets/gimpintcombobox.h: added G_BEGIN_DECLS, G_END_DECLS.
* configure.in (CPP_FLAGS): added -DGIMP_DISABLE_DEPRECATED.
* app/widgets/gimpwidgets-constructors.c: added a #warning and
#undef GIMP_DISABLE_DEPRECATED. The paint mode menu is the last
remaining user of gimp_int_option_menu_new().
2004-04-20 Michael Natterer <mitch@gimp.org>
* app/gui/convert-dialog.[ch]: renamed convert_to_indexed()
......
......@@ -20,6 +20,11 @@
#include <gtk/gtk.h>
#ifdef __GNUC__
#warning GIMP_DISABLE_DEPRECATED
#endif
#undef GIMP_DISABLE_DEPRECATED
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
......
......@@ -1406,6 +1406,12 @@ GIMP_MKENUMS="\$(top_srcdir)/tools/gimp-mkenums"
AC_SUBST(GIMP_MKENUMS)
#############################
# Disable deprecated GIMP API
#############################
CPPFLAGS="${CPPFLAGS} -DGIMP_DISABLE_DEPRECATED"
####################################################
# Default to disable deprecated GTK+ stuff for 2.2.x
####################################################
......@@ -1417,6 +1423,7 @@ fi
############################
# Require multihead safe API
############################
CPPFLAGS="${CPPFLAGS} -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE"
......
2004-04-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-docs.sgml
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/tmpl/gimpoldwidgets.sgml
* libgimpwidgets/tmpl/gimpwidgets.sgml
2004-04-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-docs.sgml
......
......@@ -59,4 +59,9 @@
<xi:include href="xml/gimpwidgets.xml" />
</part>
<part id="libgimpwidgets-deprecated">
<title>Deprecated API</title>
<xi:include href="xml/gimpoldwidgets.xml" />
</part>
</book>
......@@ -514,15 +514,6 @@ GIMP_STOCK_PATTERN
<SECTION>
<FILE>gimpwidgets</FILE>
<TITLE>GimpWidgets</TITLE>
gimp_option_menu_new
gimp_option_menu_new2
gimp_option_menu_set_history
gimp_option_menu_set_sensitive
GimpOptionMenuSensitivityCallback
gimp_int_option_menu_new
gimp_int_option_menu_set_history
gimp_int_option_menu_set_sensitive
GimpIntOptionMenuSensitivityCallback
gimp_radio_group_new
gimp_radio_group_new2
gimp_radio_group_set_active
......@@ -547,7 +538,6 @@ gimp_pixmap_button_new
gimp_toggle_button_sensitive_update
gimp_toggle_button_update
gimp_radio_button_update
gimp_menu_item_update
gimp_int_adjustment_update
gimp_uint_adjustment_update
gimp_float_adjustment_update
......@@ -683,3 +673,17 @@ GIMP_PICK_BUTTON_CLASS
GIMP_IS_PICK_BUTTON_CLASS
GIMP_PICK_BUTTON_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpoldwidgets</FILE>
gimp_int_option_menu_new
gimp_int_option_menu_set_history
GimpIntOptionMenuSensitivityCallback
gimp_int_option_menu_set_sensitive
gimp_option_menu_new
gimp_option_menu_new2
gimp_option_menu_set_history
GimpOptionMenuSensitivityCallback
gimp_option_menu_set_sensitive
gimp_menu_item_update
</SECTION>
<!-- ##### SECTION Title ##### -->
gimpoldwidgets
<!-- ##### SECTION Short_Description ##### -->
Old API that is still available but declared as deprecated.
<!-- ##### SECTION Long_Description ##### -->
<para>
These functions are not defined if you #define GIMP_DISABLE_DEPRECATED.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
GimpIntComboBox
</para>
<!-- ##### FUNCTION gimp_int_option_menu_new ##### -->
<para>
</para>
@menu_only:
@menu_item_callback:
@menu_item_callback_data:
@initial:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_int_option_menu_set_history ##### -->
<para>
</para>
@option_menu:
@item_data:
<!-- ##### USER_FUNCTION GimpIntOptionMenuSensitivityCallback ##### -->
<para>
</para>
@item_data:
@callback_data:
@Returns:
<!-- ##### FUNCTION gimp_int_option_menu_set_sensitive ##### -->
<para>
</para>
@option_menu:
@callback:
@callback_data:
<!-- ##### FUNCTION gimp_option_menu_new ##### -->
<para>
</para>
@menu_only:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_option_menu_new2 ##### -->
<para>
</para>
@menu_only:
@menu_item_callback:
@menu_item_callback_data:
@initial:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_option_menu_set_history ##### -->
<para>
</para>
@option_menu:
@item_data:
<!-- ##### USER_FUNCTION GimpOptionMenuSensitivityCallback ##### -->
<para>
</para>
@item_data:
@callback_data:
@Returns:
<!-- ##### FUNCTION gimp_option_menu_set_sensitive ##### -->
<para>
</para>
@option_menu:
@callback:
@callback_data:
<!-- ##### FUNCTION gimp_menu_item_update ##### -->
<para>
</para>
@widget:
@data:
......@@ -15,100 +15,6 @@ helper functions.
</para>
<!-- ##### FUNCTION gimp_option_menu_new ##### -->
<para>
</para>
@menu_only:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_option_menu_new2 ##### -->
<para>
</para>
@menu_only:
@menu_item_callback:
@menu_item_callback_data:
@initial:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_option_menu_set_history ##### -->
<para>
</para>
@option_menu:
@item_data:
<!-- ##### FUNCTION gimp_option_menu_set_sensitive ##### -->
<para>
</para>
@option_menu:
@callback:
@callback_data:
<!-- ##### USER_FUNCTION GimpOptionMenuSensitivityCallback ##### -->
<para>
</para>
@item_data:
@callback_data:
@Returns:
<!-- ##### FUNCTION gimp_int_option_menu_new ##### -->
<para>
</para>
@menu_only:
@menu_item_callback:
@menu_item_callback_data:
@initial:
@Varargs:
@Returns:
<!-- ##### FUNCTION gimp_int_option_menu_set_history ##### -->
<para>
</para>
@option_menu:
@item_data:
<!-- ##### FUNCTION gimp_int_option_menu_set_sensitive ##### -->
<para>
</para>
@option_menu:
@callback:
@callback_data:
<!-- ##### USER_FUNCTION GimpIntOptionMenuSensitivityCallback ##### -->
<para>
</para>
@item_data:
@callback_data:
@Returns:
<!-- ##### FUNCTION gimp_radio_group_new ##### -->
<para>
......@@ -387,15 +293,6 @@ Returns the #GimpChainButton which is attached to the #GimpSizeEntry.
@data:
<!-- ##### FUNCTION gimp_menu_item_update ##### -->
<para>
</para>
@widget:
@data:
<!-- ##### FUNCTION gimp_int_adjustment_update ##### -->
<para>
......
......@@ -96,6 +96,8 @@ libgimpwidgets_2_0_la_sources = \
gimpintcombobox.h \
gimpmemsizeentry.c \
gimpmemsizeentry.h \
gimpoldwidgets.c \
gimpoldwidgets.h \
gimpoffsetarea.c \
gimpoffsetarea.h \
gimppatheditor.c \
......@@ -148,7 +150,9 @@ libgimpwidgetsinclude_HEADERS = \
gimpdialog.h \
gimpfileentry.h \
gimphelpui.h \
gimpintcombobox.h \
gimpmemsizeentry.h \
gimpoldwidgets.h \
gimpoffsetarea.h \
gimppatheditor.h \
gimppickbutton.h \
......
......@@ -24,6 +24,8 @@
#include <gtk/gtkcombobox.h>
G_BEGIN_DECLS
#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))
......@@ -63,4 +65,6 @@ gboolean gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
gint *value);
G_END_DECLS
#endif /* __GIMP_INT_COMBO_BOX_H__ */
......@@ -144,8 +144,9 @@ static void
gimp_memsize_entry_unit_callback (GtkWidget *widget,
GimpMemsizeEntry *entry)
{
guint shift = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
guint shift;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) &shift);
#if _MSC_VER < 1200
# define CAST (gint64)
......@@ -212,7 +213,8 @@ gimp_memsize_entry_new (guint64 value,
entry->spinbutton = gimp_spin_button_new ((GtkObject **) &entry->adjustment,
CAST (value >> shift),
CAST (lower >> shift),
CAST (upper >> shift), 1, 8, 0, 1, 0);
CAST (upper >> shift),
1, 8, 0, 1, 0);
#undef CAST
......@@ -227,14 +229,16 @@ gimp_memsize_entry_new (guint64 value,
G_CALLBACK (gimp_memsize_entry_adj_callback),
entry);
entry->menu =
gimp_int_option_menu_new (FALSE,
G_CALLBACK (gimp_memsize_entry_unit_callback),
entry, shift,
_("KiloBytes"), 10, NULL,
_("MegaBytes"), 20, NULL,
_("GigaBytes"), 30, NULL,
NULL);
entry->menu = gimp_int_combo_box_new (_("KiloBytes"), 10,
_("MegaBytes"), 20,
_("GigaBytes"), 30,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (entry->menu), shift);
g_signal_connect (entry->menu, "changed",
G_CALLBACK (gimp_memsize_entry_unit_callback),
entry);
gtk_box_pack_start (GTK_BOX (entry), entry->menu, FALSE, FALSE, 0);
gtk_widget_show (entry->menu);
......@@ -271,7 +275,7 @@ gimp_memsize_entry_set_value (GimpMemsizeEntry *entry,
entry->shift = shift;
entry->value = value;
gimp_int_option_menu_set_history (GTK_OPTION_MENU (entry->menu), shift);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (entry->menu), shift);
}
#if _MSC_VER < 1200
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpoldwidgets.c
* Copyright (C) 2000 Michael Natterer <mitch@gimp.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
* Library 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 <string.h>
#include <gtk/gtk.h>
#include "gimpwidgetstypes.h"
#undef GIMP_DISABLE_DEPRECATED
#include "gimpoldwidgets.h"
/*
* Widget Constructors
*/
/**
* gimp_option_menu_new:
* @menu_only: %TRUE if the function should return a #GtkMenu only.
* @...: A %NULL-terminated @va_list describing the menu items.
*
* Convenience function to create a #GtkOptionMenu or a #GtkMenu.
*
* Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only).
**/
GtkWidget *
gimp_option_menu_new (gboolean menu_only,
/* specify menu items as va_list:
* const gchar *label,
* GCallback callback,
* gpointer callback_data,
* gpointer item_data,
* GtkWidget **widget_ptr,
* gboolean active
*/
...)
{
GtkWidget *menu;
GtkWidget *menuitem;
/* menu item variables */
const gchar *label;
GCallback callback;
gpointer callback_data;
gpointer item_data;
GtkWidget **widget_ptr;
gboolean active;
va_list args;
gint i;
gint initial_index;
menu = gtk_menu_new ();
/* create the menu items */
initial_index = 0;
va_start (args, menu_only);
label = va_arg (args, const gchar *);
for (i = 0; label; i++)
{
callback = va_arg (args, GCallback);
callback_data = va_arg (args, gpointer);
item_data = va_arg (args, gpointer);
widget_ptr = va_arg (args, GtkWidget **);
active = va_arg (args, gboolean);
if (strcmp (label, "---"))
{
menuitem = gtk_menu_item_new_with_label (label);
g_signal_connect (menuitem, "activate",
callback,
callback_data);
if (item_data)
{
g_object_set_data (G_OBJECT (menuitem), "gimp-item-data",
item_data);
/* backward compat */
g_object_set_data (G_OBJECT (menuitem), "user_data", item_data);
}
}
else
{
menuitem = gtk_menu_item_new ();
gtk_widget_set_sensitive (menuitem, FALSE);
}
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
if (widget_ptr)
*widget_ptr = menuitem;
gtk_widget_show (menuitem);
/* remember the initial menu item */
if (active)
initial_index = i;
label = va_arg (args, const gchar *);
}
va_end (args);
if (! menu_only)
{
GtkWidget *optionmenu;
optionmenu = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
/* select the initial menu item */
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index);
return optionmenu;
}
return menu;
}
/**
* gimp_option_menu_new2:
* @menu_only: %TRUE if the function should return a #GtkMenu only.
* @menu_item_callback: The callback each menu item's "activate" signal will
* be connected with.
* @menu_item_callback_data:
* The data which will be passed to g_signal_connect().
* @initial: The @item_data of the initially selected menu item.
* @...: A %NULL-terminated @va_list describing the menu items.
*
* Convenience function to create a #GtkOptionMenu or a #GtkMenu.
*
* Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only).
**/
GtkWidget *
gimp_option_menu_new2 (gboolean menu_only,
GCallback menu_item_callback,
gpointer callback_data,
gpointer initial, /* item_data */
/* specify menu items as va_list:
* const gchar *label,
* gpointer item_data,
* GtkWidget **widget_ptr,
*/
...)
{
GtkWidget *menu;
GtkWidget *menuitem;
/* menu item variables */
const gchar *label;
gpointer item_data;
GtkWidget **widget_ptr;
va_list args;