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

app/devices.[ch] app/gui/about-dialog.[ch] app/gui/preferences-dialog.[ch]

2001-04-18  Michael Natterer  <mitch@gimp.org>

	* app/devices.[ch]
	* app/gui/about-dialog.[ch]
	* app/gui/preferences-dialog.[ch]
	* app/gui/tips-dialog.[ch]: return a GtkWidget from the constructor.

	* app/gui/dialogs.c
	* app/gui/dialogs-constructors.[ch]: register them with the dialog
	factory.

	* app/gui/commands.[ch]
	* app/gui/menus.c: removed their old callbacks.

	* app/gui/brush-select.c
	* app/gui/gradient-select.c
	* app/gui/palette-editor.[ch]: no need to show or raise the shell
	(that's done by the dialog factory now).

	* app/widgets/gimpdialogfactory.c: actually do what the
	"singleton" and "session_managed" flags say.
parent d25f8933
2001-04-18 Michael Natterer <mitch@gimp.org>
* app/devices.[ch]
* app/gui/about-dialog.[ch]
* app/gui/preferences-dialog.[ch]
* app/gui/tips-dialog.[ch]: return a GtkWidget from the constructor.
* app/gui/dialogs.c
* app/gui/dialogs-constructors.[ch]: register them with the dialog
factory.
* app/gui/commands.[ch]
* app/gui/menus.c: removed their old callbacks.
* app/gui/brush-select.c
* app/gui/gradient-select.c
* app/gui/palette-editor.[ch]: no need to show or raise the shell
(that's done by the dialog factory now).
* app/widgets/gimpdialogfactory.c: actually do what the
"singleton" and "session_managed" flags say.
2001-04-18 Michael Natterer <mitch@gimp.org>
* app/Makefile.am: commented the sections of the file list.
......
......@@ -33,22 +33,16 @@
#include "tools/gimptoolinfo.h"
#include "tools/tool_manager.h"
#include "about-dialog.h"
#include "color-area.h"
#include "colormap-dialog.h"
#include "errorconsole.h"
#include "info-dialog.h"
#include "info-window.h"
#include "layer-select.h"
#include "preferences-dialog.h"
#include "tips-dialog.h"
#include "app_procs.h"
#include "commands.h"
#include "context_manager.h"
#include "convert.h"
#include "desaturate.h"
#include "devices.h"
#include "channel_ops.h"
#include "equalize.h"
#include "file-open.h"
......@@ -70,18 +64,11 @@
#include "invert.h"
#include "lc_dialog.h"
#include "layers_dialogP.h"
#include "module_db.h"
#include "plug_in.h"
#include "resize.h"
#include "scale.h"
#include "selection.h"
#include "toolbox.h"
#include "undo.h"
#include "undo_history.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
#include "libgimp/gimpintl.h"
......@@ -1095,13 +1082,6 @@ layers_resize_to_image_cmd_callback (GtkWidget *widget,
/***** Tools *****/
void
tools_toolbox_raise_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
toolbox_raise ();
}
void
tools_default_colors_cmd_callback (GtkWidget *widget,
gpointer client_data)
......@@ -1192,118 +1172,6 @@ filters_repeat_cmd_callback (GtkWidget *widget,
plug_in_repeat (callback_action);
}
/***** Dialogs ******/
void
dialogs_preferences_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
preferences_dialog_create ();
}
static void
dialogs_indexed_palette_select_callback (GimpColormapDialog *dialog,
gpointer data)
{
GimpImage *image;
GimpRGB color;
gint index;
image = gimp_colormap_dialog_image (dialog);
index = gimp_colormap_dialog_col_index (dialog);
gimp_rgba_set_uchar (&color,
image->cmap[index * 3],
image->cmap[index * 3 + 1],
image->cmap[index * 3 + 2],
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (gimp_context_get_user (), &color);
}
void
dialogs_indexed_palette_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
static GimpColormapDialog *cmap_dlg;
if (!cmap_dlg)
{
cmap_dlg = gimp_colormap_dialog_create (image_context);
gtk_signal_connect
(GTK_OBJECT (cmap_dlg), "selected",
GTK_SIGNAL_FUNC (dialogs_indexed_palette_select_callback),
NULL);
}
if (! GTK_WIDGET_VISIBLE (cmap_dlg))
gtk_widget_show (GTK_WIDGET (cmap_dlg));
else
gdk_window_raise (GTK_WIDGET (cmap_dlg)->window);
}
void
dialogs_input_devices_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
input_dialog_create ();
}
#ifdef DISPLAY_FILTERS
void
dialogs_display_filters_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
gdisp = gdisplay_active ();
if (!gdisp)
gdisp = color_area_gdisp;
if (!gdisp->cd_ui)
gdisplay_color_ui_new (gdisp);
if (!GTK_WIDGET_VISIBLE (gdisp->cd_ui))
gtk_widget_show (gdisp->cd_ui);
else
gdk_window_raise (gdisp->cd_ui->window);
}
#endif /* DISPLAY_FILTERS */
void
dialogs_undo_history_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
GimpImage *gimage;
return_if_no_display (gdisp);
gimage = gdisp->gimage;
if (!gimage->undo_history)
gimage->undo_history = undo_history_new (gimage);
if (!GTK_WIDGET_VISIBLE (gimage->undo_history))
gtk_widget_show (gimage->undo_history);
else
gdk_window_raise (gimage->undo_history->window);
}
void
dialogs_module_browser_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GtkWidget *module_browser;
module_browser = module_db_browser_new ();
gtk_widget_show (module_browser);
}
/***** Help *****/
void
......@@ -1320,20 +1188,6 @@ help_context_help_cmd_callback (GtkWidget *widget,
gimp_context_help ();
}
void
help_tips_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
tips_dialog_create ();
}
void
help_about_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
about_dialog_create ();
}
/*****************************/
/***** Local functions *****/
......
......@@ -104,7 +104,6 @@ void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void layers_alpha_select_cmd_callback (GtkWidget *, gpointer);
void layers_resize_to_image_cmd_callback (GtkWidget *, gpointer);
void tools_toolbox_raise_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_contexts_cmd_callback (GtkWidget *, gpointer);
......@@ -116,20 +115,8 @@ void filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void dialogs_preferences_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_input_devices_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
#ifdef DISPLAY_FILTERS
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
#endif /* DISPLAY_FILTERS */
void help_help_cmd_callback (GtkWidget *, gpointer);
void help_context_help_cmd_callback (GtkWidget *, gpointer);
void help_tips_cmd_callback (GtkWidget *, gpointer);
void help_about_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */
......@@ -209,73 +209,66 @@ device_info_get_by_name (gchar *name)
/* the gtk input dialog */
void
GtkWidget *
input_dialog_create (void)
{
static GtkWidget *inputd = NULL;
GtkWidget *hbbox;
if (!inputd)
{
inputd = gtk_input_dialog_new ();
/* register this one only */
dialog_register (inputd);
gtk_container_set_border_width
(GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2);
gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area),
FALSE);
hbbox = gtk_hbutton_box_new ();
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox);
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button,
GTK_CAN_DEFAULT);
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->close_button, hbbox);
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button,
GTK_CAN_DEFAULT);
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox,
FALSE, FALSE, 0);
gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button);
gtk_widget_show(hbbox);
gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button),
"clicked",
GTK_SIGNAL_FUNC (devices_write_rc),
NULL);
gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button),
"clicked",
GTK_SIGNAL_FUNC (devices_close_callback),
inputd);
gtk_signal_connect (GTK_OBJECT (inputd), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&inputd);
gtk_signal_connect (GTK_OBJECT (inputd), "enable_device",
GTK_SIGNAL_FUNC (input_dialog_able_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (inputd), "disable_device",
GTK_SIGNAL_FUNC (input_dialog_able_callback),
NULL);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (inputd,
gimp_standard_help_func,
"dialogs/input_devices.html");
if (inputd)
return inputd;
gtk_widget_show (inputd);
}
else
{
if (!GTK_WIDGET_MAPPED (inputd))
gtk_widget_show (inputd);
else
gdk_window_raise (inputd->window);
}
inputd = gtk_input_dialog_new ();
/* register this one only */
dialog_register (inputd);
gtk_container_set_border_width
(GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2);
gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area),
FALSE);
hbbox = gtk_hbutton_box_new ();
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox);
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button,
GTK_CAN_DEFAULT);
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->close_button, hbbox);
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button,
GTK_CAN_DEFAULT);
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox,
FALSE, FALSE, 0);
gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button);
gtk_widget_show(hbbox);
gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button),
"clicked",
GTK_SIGNAL_FUNC (devices_write_rc),
NULL);
gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button),
"clicked",
GTK_SIGNAL_FUNC (devices_close_callback),
inputd);
gtk_signal_connect (GTK_OBJECT (inputd), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&inputd);
gtk_signal_connect (GTK_OBJECT (inputd), "enable_device",
GTK_SIGNAL_FUNC (input_dialog_able_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (inputd), "disable_device",
GTK_SIGNAL_FUNC (input_dialog_able_callback),
NULL);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (inputd,
gimp_standard_help_func,
"dialogs/input_devices.html");
return inputd;
}
static void
......@@ -747,14 +740,7 @@ device_status_create (void)
gint i;
if (deviceD)
{
if (! GTK_WIDGET_MAPPED (deviceD->shell))
gtk_widget_show (deviceD->shell);
else
gdk_window_raise (deviceD->shell->window);
return deviceD->shell;
}
return deviceD->shell;
deviceD = g_new (DeviceInfoDialog, 1);
......@@ -955,8 +941,6 @@ device_status_create (void)
GTK_SIGNAL_FUNC (device_status_destroy_callback),
NULL);
gtk_widget_show (deviceD->shell);
return deviceD->shell;
}
......
......@@ -40,13 +40,13 @@ void devices_init (void);
void devices_restore (void);
/* Create device info dialog */
void input_dialog_create (void);
GtkWidget * input_dialog_create (void);
/* Create the device status dialog */
GtkWidget * device_status_create (void);
/* Returns TRUE, and makes necessary global changes
* event is not for current_device
* if event is not for current_device
*/
gint devices_check_change (GdkEvent *event);
......
......@@ -114,7 +114,7 @@ static gchar *hadja_text[] =
#endif
};
void
GtkWidget *
about_dialog_create (void)
{
GtkWidget *vbox;
......@@ -127,7 +127,7 @@ about_dialog_create (void)
gint i;
gchar *label_text;
if (!about_dialog)
if (! about_dialog)
{
about_dialog = gtk_window_new (GTK_WINDOW_DIALOG);
gtk_window_set_wmclass (GTK_WINDOW (about_dialog), "about_dialog", "Gimp");
......@@ -167,7 +167,7 @@ about_dialog_create (void)
{
gtk_widget_destroy (about_dialog);
about_dialog = NULL;
return;
return NULL;
}
vbox = gtk_vbox_new (FALSE, 1);
......@@ -264,18 +264,18 @@ about_dialog_create (void)
&scroll_area->style->white);
}
if (!GTK_WIDGET_VISIBLE (about_dialog))
if (! GTK_WIDGET_VISIBLE (about_dialog))
{
gtk_widget_show (about_dialog);
do_animation = TRUE;
do_scrolling = FALSE;
scroll_state = 0;
frame = 0;
offset = 0;
do_animation = TRUE;
do_scrolling = FALSE;
scroll_state = 0;
frame = 0;
offset = 0;
cur_scroll_text = 0;
if (!double_speed && hadja_state != 7)
if (! double_speed && hadja_state != 7)
{
for (i = 0; i < nscroll_texts; i++)
{
......@@ -303,6 +303,8 @@ about_dialog_create (void)
{
gdk_window_raise (about_dialog->window);
}
return about_dialog;
}
static gboolean
......@@ -521,10 +523,10 @@ about_dialog_key (GtkWidget *widget,
scroll_text[i]);
}
scroll_state = 0;
scroll_state = 0;
cur_scroll_index = 0;
cur_scroll_text = 0;
offset = 0;
cur_scroll_text = 0;
offset = 0;
}
return FALSE;
......@@ -537,9 +539,9 @@ about_dialog_tool_drop (GtkWidget *widget,
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gint width = 0;
gint height = 0;
gint i;
gint width = 0;
gint height = 0;
gint i;
if (do_animation)
return;
......@@ -549,7 +551,7 @@ about_dialog_tool_drop (GtkWidget *widget,
timer = gtk_timeout_add (75, about_dialog_timer, NULL);
frame = 0;
frame = 0;
do_animation = TRUE;
do_scrolling = FALSE;
......@@ -560,11 +562,10 @@ about_dialog_tool_drop (GtkWidget *widget,
logo_area->allocation.width,
logo_area->allocation.height);
pixmap =
gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
NULL,
wilber2_xpm);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
NULL,
wilber2_xpm);
gdk_window_get_size (pixmap, &width, &height);
......@@ -602,10 +603,10 @@ about_dialog_tool_drop (GtkWidget *widget,
scroll_text[i]);
}
scroll_state = 0;
scroll_state = 0;
cur_scroll_index = 0;
cur_scroll_text = 0;
offset = 0;
cur_scroll_text = 0;
offset = 0;
double_speed = TRUE;
}
......@@ -640,7 +641,7 @@ about_dialog_timer (gpointer data)
{
do_animation = FALSE;
do_scrolling = TRUE;
frame = 0;
frame = 0;
timer = gtk_timeout_add (75, about_dialog_timer, NULL);
......@@ -651,7 +652,7 @@ about_dialog_timer (gpointer data)
if (do_scrolling)
{
if (!scroll_pixmap)
if (! scroll_pixmap)
scroll_pixmap = gdk_pixmap_new (scroll_area->window,
scroll_area->allocation.width,
scroll_area->allocation.height,
......@@ -678,7 +679,7 @@ about_dialog_timer (gpointer data)
cur_scroll_index += 1;
if (cur_scroll_index == nscroll_texts)
cur_scroll_index = 0;
cur_scroll_text = shuffle_array[cur_scroll_index];
offset = 0;
......
......@@ -19,6 +19,8 @@
#ifndef __ABOUT_DIALOG_H__
#define __ABOUT_DIALOG_H__
void about_dialog_create (void);
GtkWidget * about_dialog_create (void);
#endif /* __ABOUT_DIALOG_H__ */
......@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
......@@ -36,7 +37,10 @@
#include "widgets/gimpdockbook.h"
#include "widgets/gimppreview.h"
#include "about-dialog.h"
#include "brush-select.h"
#include "color-area.h"
#include "colormap-dialog.h"
#include "devices.h"
#include "dialogs-constructors.h"
#include "docindex.h"
......@@ -45,38 +49,49 @@
#include "gradient-editor.h"
#include "gradient-select.h"
#include "lc_dialog.h"
#include "palette-editor.h"
#include "pattern-select.h"
#include "preferences-dialog.h"
#include "tips-dialog.h"
#include "toolbox.h"
#include "context_manager.h"
#include "gdisplay.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpdatafactory.h"
#include "gimpimage.h"
#include "gimprc.h"
#include "module_db.h"
#include "undo_history.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */
#include "libgimp/gimpintl.h"
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static void dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
GimpContext *context);
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
/* public functions */
......@@ -145,6 +160,89 @@ dialogs_document_index_get (GimpDialogFactory *factory)
return document_index_create ();
}
GtkWidget *
dialogs_preferences_get (GimpDialogFactory *factory)
{
return preferences_dialog_create ();
}
GtkWidget *
dialogs_input_devices_get (GimpDialogFactory *factory)
{
return input_dialog_create ();
}
GtkWidget *
dialogs_module_browser_get (GimpDialogFactory *factory)
{
return module_db_browser_new ();
}
GtkWidget *
dialogs_indexed_palette_get (GimpDialogFactory *factory)
{
GimpColormapDialog *cmap_dlg;
cmap_dlg = gimp_colormap_dialog_create (image_context);
gtk_signal_connect (GTK_OBJECT (cmap_dlg), "selected",
GTK_SIGNAL_FUNC (dialogs_indexed_palette_selected),
factory->context);
return GTK_WIDGET (cmap_dlg);
}
GtkWidget *
dialogs_undo_history_get (GimpDialogFactory *factory)
{
GDisplay *gdisp;
GimpImage *gimage;
gdisp = gimp_context_get_display (factory->context);
if (! gdisp)
return NULL;
gimage = gdisp->gimage;
if (! gimage->undo_history)
gimage->undo_history = undo_history_new (gimage);
return gimage->undo_history;
}
GtkWidget *
dialogs_display_filters_get (GimpDialogFactory *factory)
{
#ifdef DISPLAY_FILTERS
GDisplay *gdisp;
gdisp = gimp_context_get_display (factory->context);
if (! gdisp)
gdisp = color_area_gdisp;
if (! gdisp->cd_ui)
gdisplay_color_ui_new (gdisp);
return gdisp->cd_ui;
#else
return NULL;
#endif /* DISPLAY_FILTERS */
}
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory)
{