Commit 794931f0 authored by Sven Neumann's avatar Sven Neumann

applied gimp-alt-980812-0.patch


--Sven
parent d27db074
Thu Aug 13 11:32:04 MEST 1998 Sven Neumann <sven@gimp.org>
* app/app_procs.c
* app/color_area.c
* app/devices.[ch]
* app/gimprc.[ch]
* app/preferences_dialog.c: applied gimp-alt-980812-0.patch:
Device status is now restored on startup.
Tooltips added to items in device status dialog box.
Fixed problem with multiple input devices & new dialog.
Added option to preferences (under session) that allows user to
always store device status on exit from gimp (default off).
Fixed problem in color area of toolbar to do the possibility of GC not
existing when the dialog is refreshed.
* app/commands.c: include errorconsole.h
Tue Aug 11 23:17:20 CST 1998 Seth Burgess <sjburges@gimp.org>
* app/transform_core.c: Fixed the flip tool so it would operate
......
......@@ -36,6 +36,7 @@
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
#include "errorconsole.h"
#include "fileops.h"
#include "floating_sel.h"
#include "gdisplay_ops.h"
......
......@@ -545,7 +545,12 @@ app_init (void)
paint_funcs_setup ();
if (no_interface == FALSE)
session_restore();
{
devices_restore(); /* Must be done AFTER get_active_{brush|pattern}
* because these functions set the brush/pattern.
*/
session_restore();
}
}
int
......@@ -564,6 +569,7 @@ app_exit_finish (void)
message_handler = CONSOLE;
we_are_exiting = TRUE;
device_status_free ();
lc_dialog_free ();
gdisplays_delete ();
global_edit_free ();
......@@ -583,7 +589,6 @@ app_exit_finish (void)
paint_funcs_free ();
plug_in_kill ();
procedural_db_free ();
device_status_free ();
error_console_free ();
menus_quit ();
tile_swap_exit ();
......
......@@ -83,8 +83,9 @@ color_area_draw (void)
int def_width, def_height;
int swap_width, swap_height;
if (!color_area_pixmap) /* we haven't gotten initial expose yet,
* no point in drawing anything */
/* Check we haven't gotten initial expose yet,
* no point in drawing anything */
if (!color_area_pixmap || !color_area_gc)
return;
gdk_window_get_size (color_area_pixmap, &width, &height);
......
......@@ -36,6 +36,7 @@
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
#include "errorconsole.h"
#include "fileops.h"
#include "floating_sel.h"
#include "gdisplay_ops.h"
......
......@@ -17,6 +17,7 @@
*/
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -78,6 +79,7 @@ struct _DeviceInfoDialog {
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **eventboxes;
};
......@@ -168,8 +170,6 @@ void
devices_init (void)
{
GList *tmp_list;
char *gimp_dir;
char filename[512];
/* Create device info structures for present devices */
......@@ -201,7 +201,16 @@ devices_init (void)
tmp_list = tmp_list->next;
}
}
void
devices_restore()
{
char *gimp_dir;
char filename[MAXPATHLEN];
GList *tmp_list;
DeviceInfo *device_info;
/* Augment with information from rc file */
gimp_dir = gimp_directory ();
......@@ -211,6 +220,36 @@ devices_init (void)
sprintf (filename, "%s/devicerc", gimp_dir);
parse_gimprc_file (filename);
}
tmp_list = devices_info;
device_info = NULL;
while (tmp_list)
{
if (((DeviceInfo *)tmp_list->data)->device == current_device)
{
device_info = (DeviceInfo *)tmp_list->data;
break;
}
tmp_list = tmp_list->next;
}
suppress_update = TRUE;
if (device_info->is_init)
{
if (device_info->brush)
select_brush (device_info->brush);
gtk_widget_activate (tool_info[(int) device_info->tool].tool_widget);
palette_set_foreground (device_info->foreground[0],
device_info->foreground[1],
device_info->foreground[2]);
if (device_info->pattern)
select_pattern(device_info->pattern);
}
suppress_update = FALSE;
}
void
......@@ -634,6 +673,7 @@ create_device_status (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
tmp_list = devices_info;
i=0;
......@@ -662,14 +702,20 @@ create_device_status (void)
gtk_container_add (GTK_CONTAINER(deviceD->frames[i]), label);
gtk_widget_show(label);
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] = gtk_pixmap_new (create_tool_pixmap(deviceD->table,
RECT_SELECT),
NULL);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->tools[i],
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),deviceD->tools[i]);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_widget_set_events (deviceD->colors[i], PREVIEW_EVENT_MASK);
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
2, 3, i, i+1,
......@@ -734,6 +780,7 @@ device_status_destroy_callback (void)
g_free(deviceD->ids);
g_free(deviceD->frames);
g_free(deviceD->tools);
g_free(deviceD->eventboxes);
g_free(deviceD->colors);
g_free(deviceD->brushes);
g_free(deviceD->patterns);
......@@ -752,6 +799,10 @@ devices_close_callback (GtkWidget *w,
void
device_status_free (void)
{
/* Save device status on exit */
if(save_device_status)
devices_write_rc();
if (deviceD)
{
session_get_window_info (deviceD->shell, &device_status_session_info);
......@@ -985,7 +1036,7 @@ device_preview_events (GtkWidget *widget,
{
pattern = device_info->pattern;
/* Show the brush popup window if the brush is too large */
/* Show the pattern popup window if the pattern is too large */
if (pattern->mask->width > CELL_SIZE ||
pattern->mask->height > CELL_SIZE)
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
......@@ -1165,6 +1216,7 @@ device_status_update (guint32 deviceid)
{
int i, j;
guchar buffer[CELL_SIZE*3];
gchar ttbuf[20]; /* [xxx,xxx,xxx] + null */
GList *tmp_list;
DeviceInfo *device_info;
GdkDeviceInfo *gdk_info;
......@@ -1214,6 +1266,7 @@ device_status_update (guint32 deviceid)
{
gtk_widget_hide (deviceD->frames[i]);
gtk_widget_hide (deviceD->tools[i]);
gtk_widget_hide (deviceD->eventboxes[i]);
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
......@@ -1226,9 +1279,18 @@ device_status_update (guint32 deviceid)
create_tool_pixmap (deviceD->table,
device_info->tool),
NULL);
gtk_widget_draw (deviceD->tools[i], NULL);
gtk_widget_show (deviceD->tools[i]);
gtk_widget_show (deviceD->eventboxes[i]);
gtk_tooltips_set_tip(tool_tips,deviceD->eventboxes[i],
tool_info[(int) device_info->tool].tool_desc,
NULL);
if(!device_info->is_init)
return; /* None of the entries have been set */
for (j=0;j<CELL_SIZE*3;j+=3)
{
buffer[j] = device_info->foreground[0];
......@@ -1242,6 +1304,15 @@ device_status_update (guint32 deviceid)
gtk_widget_draw (deviceD->colors[i], NULL);
gtk_widget_show (deviceD->colors[i]);
/* Set the tip to be the RGB value */
sprintf(ttbuf,"[%3d,%3d,%3d]",
device_info->foreground[0],
device_info->foreground[1],
device_info->foreground[2]);
gtk_tooltips_set_tip(tool_tips,deviceD->colors[i],ttbuf,NULL);
device_update_brush(device_info->brush,i);
gtk_widget_draw (deviceD->brushes[i],NULL);
gtk_widget_show (deviceD->brushes[i]);
......
......@@ -59,6 +59,9 @@ void devices_rc_update (gchar *name, DeviceValues values,
/* Free device status (only for session-managment) */
void device_status_free (void);
/* Restores device settings from rc file */
void devices_restore();
/* Current device id */
extern int current_device;
......
......@@ -87,6 +87,7 @@ static int old_show_statusbar;
static int old_cubic_interpolation;
static int old_confirm_on_close;
static int old_save_session_info;
static int old_save_device_status;
static int old_always_restore_session;
static int old_default_width;
static int old_default_height;
......@@ -320,6 +321,11 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "save-session-info");
remove = g_list_append (remove, "dont-save-session-info");
}
if (save_device_status!= old_save_device_status)
{
update = g_list_append (update, "save-device-status");
remove = g_list_append (remove, "dont-save-device-status");
}
if (always_restore_session != old_always_restore_session)
update = g_list_append (update, "always-restore-session");
if (default_width != old_default_width ||
......@@ -460,6 +466,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
cubic_interpolation = old_cubic_interpolation;
confirm_on_close = old_confirm_on_close;
save_session_info = old_save_session_info;
save_device_status = old_save_device_status;
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
......@@ -523,6 +530,8 @@ file_prefs_toggle_callback (GtkWidget *widget,
confirm_on_close = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_session_info)
save_session_info = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_device_status)
save_device_status = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &always_restore_session)
always_restore_session = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &edit_stingy_memory_use)
......@@ -736,6 +745,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_cubic_interpolation = cubic_interpolation;
old_confirm_on_close = confirm_on_close;
old_save_session_info = save_session_info;
old_save_device_status = save_device_status;
old_always_restore_session = always_restore_session;
old_default_width = default_width;
old_default_height = default_height;
......@@ -1256,6 +1266,15 @@ file_pref_cmd_callback (GtkWidget *widget,
(GtkSignalFunc) file_prefs_toggle_callback,
&always_restore_session);
gtk_widget_show (button);
button = gtk_check_button_new_with_label ("Save device status on exit");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
save_device_status);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&save_device_status);
gtk_widget_show (button);
label = gtk_label_new ("Session");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
......
......@@ -113,6 +113,7 @@ int auto_save = TRUE;
int cubic_interpolation = FALSE;
int confirm_on_close = TRUE;
int save_session_info = TRUE;
int save_device_status = FALSE;
int always_restore_session = FALSE;
int default_width = 256;
int default_height = 256;
......@@ -224,6 +225,8 @@ static ParseFunc funcs[] =
{ "dont-confirm-on-close", TT_BOOLEAN, NULL, &confirm_on_close },
{ "save-session-info", TT_BOOLEAN, &save_session_info, NULL },
{ "dont-save-session-info", TT_BOOLEAN, NULL, &save_session_info},
{ "save-device-status", TT_BOOLEAN, &save_device_status, NULL },
{ "dont-save-device-status", TT_BOOLEAN, NULL, &save_device_status},
{ "always-restore-session", TT_BOOLEAN, &always_restore_session, NULL },
{ "show-tips", TT_BOOLEAN, &show_tips, NULL },
{ "dont-show-tips", TT_BOOLEAN, NULL, &show_tips },
......
......@@ -61,6 +61,7 @@ extern int default_type;
extern int default_resolution;
extern int default_resolution_units;
extern int save_session_info;
extern int save_device_status;
extern int always_restore_session;
extern int show_tips;
extern int last_tip;
......
......@@ -83,8 +83,9 @@ color_area_draw (void)
int def_width, def_height;
int swap_width, swap_height;
if (!color_area_pixmap) /* we haven't gotten initial expose yet,
* no point in drawing anything */
/* Check we haven't gotten initial expose yet,
* no point in drawing anything */
if (!color_area_pixmap || !color_area_gc)
return;
gdk_window_get_size (color_area_pixmap, &width, &height);
......
......@@ -36,6 +36,7 @@
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
#include "errorconsole.h"
#include "fileops.h"
#include "floating_sel.h"
#include "gdisplay_ops.h"
......
......@@ -17,6 +17,7 @@
*/
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -78,6 +79,7 @@ struct _DeviceInfoDialog {
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **eventboxes;
};
......@@ -168,8 +170,6 @@ void
devices_init (void)
{
GList *tmp_list;
char *gimp_dir;
char filename[512];
/* Create device info structures for present devices */
......@@ -201,7 +201,16 @@ devices_init (void)
tmp_list = tmp_list->next;
}
}
void
devices_restore()
{
char *gimp_dir;
char filename[MAXPATHLEN];
GList *tmp_list;
DeviceInfo *device_info;
/* Augment with information from rc file */
gimp_dir = gimp_directory ();
......@@ -211,6 +220,36 @@ devices_init (void)
sprintf (filename, "%s/devicerc", gimp_dir);
parse_gimprc_file (filename);
}
tmp_list = devices_info;
device_info = NULL;
while (tmp_list)
{
if (((DeviceInfo *)tmp_list->data)->device == current_device)
{
device_info = (DeviceInfo *)tmp_list->data;
break;
}
tmp_list = tmp_list->next;
}
suppress_update = TRUE;
if (device_info->is_init)
{
if (device_info->brush)
select_brush (device_info->brush);
gtk_widget_activate (tool_info[(int) device_info->tool].tool_widget);
palette_set_foreground (device_info->foreground[0],
device_info->foreground[1],
device_info->foreground[2]);
if (device_info->pattern)
select_pattern(device_info->pattern);
}
suppress_update = FALSE;
}
void
......@@ -634,6 +673,7 @@ create_device_status (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
tmp_list = devices_info;
i=0;
......@@ -662,14 +702,20 @@ create_device_status (void)
gtk_container_add (GTK_CONTAINER(deviceD->frames[i]), label);
gtk_widget_show(label);
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] = gtk_pixmap_new (create_tool_pixmap(deviceD->table,
RECT_SELECT),
NULL);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->tools[i],
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),deviceD->tools[i]);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_widget_set_events (deviceD->colors[i], PREVIEW_EVENT_MASK);
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
2, 3, i, i+1,
......@@ -734,6 +780,7 @@ device_status_destroy_callback (void)
g_free(deviceD->ids);
g_free(deviceD->frames);
g_free(deviceD->tools);
g_free(deviceD->eventboxes);
g_free(deviceD->colors);
g_free(deviceD->brushes);
g_free(deviceD->patterns);
......@@ -752,6 +799,10 @@ devices_close_callback (GtkWidget *w,
void
device_status_free (void)
{
/* Save device status on exit */
if(save_device_status)
devices_write_rc();
if (deviceD)
{
session_get_window_info (deviceD->shell, &device_status_session_info);
......@@ -985,7 +1036,7 @@ device_preview_events (GtkWidget *widget,
{
pattern = device_info->pattern;
/* Show the brush popup window if the brush is too large */
/* Show the pattern popup window if the pattern is too large */
if (pattern->mask->width > CELL_SIZE ||
pattern->mask->height > CELL_SIZE)
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
......@@ -1165,6 +1216,7 @@ device_status_update (guint32 deviceid)
{
int i, j;
guchar buffer[CELL_SIZE*3];
gchar ttbuf[20]; /* [xxx,xxx,xxx] + null */
GList *tmp_list;
DeviceInfo *device_info;
GdkDeviceInfo *gdk_info;
......@@ -1214,6 +1266,7 @@ device_status_update (guint32 deviceid)
{
gtk_widget_hide (deviceD->frames[i]);
gtk_widget_hide (deviceD->tools[i]);
gtk_widget_hide (deviceD->eventboxes[i]);
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
......@@ -1226,9 +1279,18 @@ device_status_update (guint32 deviceid)
create_tool_pixmap (deviceD->table,
device_info->tool),
NULL);
gtk_widget_draw (deviceD->tools[i], NULL);
gtk_widget_show (deviceD->tools[i]);
gtk_widget_show (deviceD->eventboxes[i]);
gtk_tooltips_set_tip(tool_tips,deviceD->eventboxes[i],
tool_info[(int) device_info->tool].tool_desc,
NULL);
if(!device_info->is_init)
return; /* None of the entries have been set */
for (j=0;j<CELL_SIZE*3;j+=3)
{
buffer[j] = device_info->foreground[0];
......@@ -1242,6 +1304,15 @@ device_status_update (guint32 deviceid)
gtk_widget_draw (deviceD->colors[i], NULL);
gtk_widget_show (deviceD->colors[i]);
/* Set the tip to be the RGB value */
sprintf(ttbuf,"[%3d,%3d,%3d]",
device_info->foreground[0],
device_info->foreground[1],
device_info->foreground[2]);
gtk_tooltips_set_tip(tool_tips,deviceD->colors[i],ttbuf,NULL);
device_update_brush(device_info->brush,i);
gtk_widget_draw (deviceD->brushes[i],NULL);
gtk_widget_show (deviceD->brushes[i]);
......
......@@ -36,6 +36,7 @@
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
#include "errorconsole.h"
#include "fileops.h"
#include "floating_sel.h"
#include "gdisplay_ops.h"
......
......@@ -17,6 +17,7 @@
*/
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
#include "appenv.h"
#include "actionarea.h"
......@@ -78,6 +79,7 @@ struct _DeviceInfoDialog {
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **eventboxes;
};
......@@ -168,8 +170,6 @@ void
devices_init (void)
{
GList *tmp_list;
char *gimp_dir;
char filename[512];
/* Create device info structures for present devices */
......@@ -201,7 +201,16 @@ devices_init (void)
tmp_list = tmp_list->next;
}
}
void
devices_restore()
{
char *gimp_dir;
char filename[MAXPATHLEN];
GList *tmp_list;
DeviceInfo *device_info;
/* Augment with information from rc file */
gimp_dir = gimp_directory ();
......@@ -211,6 +220,36 @@ devices_init (void)
sprintf (filename, "%s/devicerc", gimp_dir);
parse_gimprc_file (filename);
}
tmp_list = devices_info;
device_info = NULL;
while (tmp_list)
{
if (((DeviceInfo *)tmp_list->data)->device == current_device)
{
device_info = (DeviceInfo *)tmp_list->data;
break;
}
tmp_list = tmp_list->next;
}