Commit 650e7703 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/color_area.c app/color_notebook.[ch] app/color_panel.c app/gimprc.c

2001-01-16  Michael Natterer  <mitch@gimp.org>

	* app/color_area.c
	* app/color_notebook.[ch]
	* app/color_panel.c
	* app/gimprc.c
	* app/session.c: store the color history in sessionrc.

	* app/channels_dialog.c: tweaked the "new channel" and "channel
	atributes" dialogs a bit.
parent d3093329
2001-01-16 Michael Natterer <mitch@gimp.org>
* app/color_area.c
* app/color_notebook.[ch]
* app/color_panel.c
* app/gimprc.c
* app/session.c: store the color history in sessionrc.
* app/channels_dialog.c: tweaked the "new channel" and "channel
atributes" dialogs a bit.
Mon Jan 15 17:22:30 PST 2001 Manish Singh <yosh@gimp.org>
* app/fileops.c: correct spelling of "lose" in revert dialog
......
......@@ -2583,6 +2583,7 @@ channels_dialog_new_channel_query (GimpImage* gimage)
/* The table */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry hbox, label and entry */
......@@ -2612,7 +2613,6 @@ channels_dialog_new_channel_query (GimpImage* gimage)
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
options->color_panel);
......@@ -2737,6 +2737,7 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
/* The table */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry */
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
......
......@@ -155,6 +155,7 @@ static gint color_notebook_hex_entry_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void color_history_init (void);
static void color_history_color_clicked (GtkWidget *widget,
gpointer data);
static void color_history_color_changed (GtkWidget *widget,
......@@ -225,16 +226,8 @@ color_notebook_new (GimpRGB *color,
g_return_val_if_fail (selector_info != NULL, NULL);
g_return_val_if_fail (color != NULL, NULL);
/* EEK */
if (! color_history_initialized)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
color_history_init ();
cnp = g_new0 (ColorNotebook, 1);
......@@ -496,11 +489,12 @@ color_notebook_new (GimpRGB *color,
color_notebook_update_scales (cnp, -1);
/* The color history */
hbox = gtk_hbox_new (TRUE, 2);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new ();
gtk_widget_set_usize (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button,
_("Add the current color to the color history"),
......@@ -1147,6 +1141,50 @@ color_notebook_hex_entry_events (GtkWidget *widget,
return FALSE;
}
void
color_history_add_color_from_rc (GimpRGB *color)
{
static gint index = 0;
if (! color_history_initialized)
color_history_init ();
if (color && index < COLOR_HISTORY_SIZE)
{
color_history[index++] = *color;
}
}
void
color_history_write (FILE *fp)
{
gint i;
fprintf (fp, "(color-history");
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
}
fprintf (fp, ")\n\n");
}
static void
color_history_init (void)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
static void
color_history_color_clicked (GtkWidget *widget,
gpointer data)
......
......@@ -48,4 +48,8 @@ void color_notebook_set_color (ColorNotebook *cnb,
GimpRGB *color);
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);
#endif /* __COLOR_NOTEBOOK_H__ */
......@@ -18,6 +18,8 @@
#include "config.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include "apptypes.h"
......
......@@ -155,6 +155,7 @@ static gint color_notebook_hex_entry_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void color_history_init (void);
static void color_history_color_clicked (GtkWidget *widget,
gpointer data);
static void color_history_color_changed (GtkWidget *widget,
......@@ -225,16 +226,8 @@ color_notebook_new (GimpRGB *color,
g_return_val_if_fail (selector_info != NULL, NULL);
g_return_val_if_fail (color != NULL, NULL);
/* EEK */
if (! color_history_initialized)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
color_history_init ();
cnp = g_new0 (ColorNotebook, 1);
......@@ -496,11 +489,12 @@ color_notebook_new (GimpRGB *color,
color_notebook_update_scales (cnp, -1);
/* The color history */
hbox = gtk_hbox_new (TRUE, 2);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new ();
gtk_widget_set_usize (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button,
_("Add the current color to the color history"),
......@@ -1147,6 +1141,50 @@ color_notebook_hex_entry_events (GtkWidget *widget,
return FALSE;
}
void
color_history_add_color_from_rc (GimpRGB *color)
{
static gint index = 0;
if (! color_history_initialized)
color_history_init ();
if (color && index < COLOR_HISTORY_SIZE)
{
color_history[index++] = *color;
}
}
void
color_history_write (FILE *fp)
{
gint i;
fprintf (fp, "(color-history");
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
}
fprintf (fp, ")\n\n");
}
static void
color_history_init (void)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
static void
color_history_color_clicked (GtkWidget *widget,
gpointer data)
......
......@@ -48,4 +48,8 @@ void color_notebook_set_color (ColorNotebook *cnb,
GimpRGB *color);
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);
#endif /* __COLOR_NOTEBOOK_H__ */
......@@ -37,6 +37,7 @@
#include "app_procs.h"
#include "appenv.h"
#include "color_notebook.h"
#include "cursorutil.h"
#include "devices.h"
#include "errors.h"
......@@ -83,6 +84,7 @@ typedef enum
TT_XMENUPATH,
TT_XDEVICE,
TT_XSESSIONINFO,
TT_XCOLORHISTORY,
TT_XUNITINFO,
TT_XPARASITE,
TT_XNAVPREVSIZE,
......@@ -207,6 +209,7 @@ static gint parse_unit_info (gpointer val1p, gpointer val2p);
static gint parse_parasite (gpointer val1p, gpointer val2p);
static gint parse_help_browser (gpointer val1p, gpointer val2p);
static gint parse_cursor_mode (gpointer val1p, gpointer val2p);
static gint parse_color_history (gpointer val1p, gpointer val2p);
static gint parse_locale_def (PlugInDef *plug_in_def);
static gint parse_help_def (PlugInDef *plug_in_def);
......@@ -234,17 +237,20 @@ static inline gchar * help_browser_to_str (gpointer val1p, gpointer val2p)
static inline gchar * cursor_mode_to_str (gpointer val1p, gpointer val2p);
static inline gchar * comment_to_str (gpointer val1p, gpointer val2p);
static gchar *transform_path (gchar *path, gboolean destroy);
static void gimprc_set_token (gchar *token, gchar *value);
static void add_gimp_directory_token (gchar *gimp_dir);
static gchar *transform_path (gchar *path,
gboolean destroy);
static void gimprc_set_token (gchar *token,
gchar *value);
static void add_gimp_directory_token (gchar *gimp_dir);
#ifdef __EMX__
static void add_x11root_token (gchar *x11root);
static void add_x11root_token (gchar *x11root);
#endif
static gchar *open_backup_file (gchar *filename,
gchar *secondary_filename,
gchar **name_used,
FILE **fp_new,
FILE **fp_old);
static gchar *open_backup_file (gchar *filename,
gchar *secondary_filename,
gchar **name_used,
FILE **fp_new,
FILE **fp_old);
static ParseInfo parse_info = { NULL };
......@@ -321,6 +327,7 @@ static ParseFunc funcs[] =
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL },
{ "color-history", TT_XCOLORHISTORY, NULL, NULL },
{ "unit-info", TT_XUNITINFO, NULL, NULL },
{ "monitor-xresolution", TT_DOUBLE, &monitor_xres, NULL },
{ "monitor-yresolution", TT_DOUBLE, &monitor_yres, NULL },
......@@ -889,6 +896,8 @@ parse_statement (void)
return parse_device (funcs[i].val1p, funcs[i].val2p);
case TT_XSESSIONINFO:
return parse_session_info (funcs[i].val1p, funcs[i].val2p);
case TT_XCOLORHISTORY:
return parse_color_history (funcs[i].val1p, funcs[i].val2p);
case TT_XUNITINFO:
return parse_unit_info (funcs[i].val1p, funcs[i].val2p);
case TT_XPARASITE:
......@@ -2346,6 +2355,61 @@ parse_session_info (gpointer val1p,
return OK;
}
static gint
parse_color_history (gpointer val1p,
gpointer val2p)
{
gint i;
gint token = 0;
GimpRGB color;
/* Parse one color per line: (r g b a) */
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (!strcmp ("color", token_sym))
{
gdouble col[4];
for (i = 0; i < 4; i++)
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
col[i] = token_num;
}
gimp_rgba_set (&color,
col[0], col[1], col[2], col[3]);
gimp_rgb_clamp (&color);
color_history_add_color_from_rc (&color);
}
else
return ERROR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
}
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_unit_info (gpointer val1p,
gpointer val2p)
......@@ -2660,6 +2724,7 @@ value_to_str (gchar *name)
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONINFO:
case TT_XCOLORHISTORY:
case TT_XUNITINFO:
case TT_XPARASITE:
return NULL;
......
......@@ -2583,6 +2583,7 @@ channels_dialog_new_channel_query (GimpImage* gimage)
/* The table */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry hbox, label and entry */
......@@ -2612,7 +2613,6 @@ channels_dialog_new_channel_query (GimpImage* gimage)
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
options->color_panel);
......@@ -2737,6 +2737,7 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
/* The table */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The name entry */
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
......
......@@ -155,6 +155,7 @@ static gint color_notebook_hex_entry_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void color_history_init (void);
static void color_history_color_clicked (GtkWidget *widget,
gpointer data);
static void color_history_color_changed (GtkWidget *widget,
......@@ -225,16 +226,8 @@ color_notebook_new (GimpRGB *color,
g_return_val_if_fail (selector_info != NULL, NULL);
g_return_val_if_fail (color != NULL, NULL);
/* EEK */
if (! color_history_initialized)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
color_history_init ();
cnp = g_new0 (ColorNotebook, 1);
......@@ -496,11 +489,12 @@ color_notebook_new (GimpRGB *color,
color_notebook_update_scales (cnp, -1);
/* The color history */
hbox = gtk_hbox_new (TRUE, 2);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new ();
gtk_widget_set_usize (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button,
_("Add the current color to the color history"),
......@@ -1147,6 +1141,50 @@ color_notebook_hex_entry_events (GtkWidget *widget,
return FALSE;
}
void
color_history_add_color_from_rc (GimpRGB *color)
{
static gint index = 0;
if (! color_history_initialized)
color_history_init ();
if (color && index < COLOR_HISTORY_SIZE)
{
color_history[index++] = *color;
}
}
void
color_history_write (FILE *fp)
{
gint i;
fprintf (fp, "(color-history");
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
}
fprintf (fp, ")\n\n");
}
static void
color_history_init (void)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
static void
color_history_color_clicked (GtkWidget *widget,
gpointer data)
......
......@@ -48,4 +48,8 @@ void color_notebook_set_color (ColorNotebook *cnb,
GimpRGB *color);
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);
#endif /* __COLOR_NOTEBOOK_H__ */
......@@ -51,22 +51,27 @@
#include "app_procs.h"
#include "appenv.h"
#include "color_notebook.h"
#include "commands.h"
#include "gimprc.h"
#include "session.h"
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *info,
FILE *fp);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_info_updates = NULL;
#define LEFT_OFFSET 60
#define TOP_OFFSET 60
static void sessionrc_write_info (SessionInfo *info,
FILE *fp);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_info_updates = NULL;
/* global session variables */
SessionInfo toolbox_session_info =
{
......@@ -168,7 +173,8 @@ SessionInfo document_index_session_info =
};
/* public functions */
/* public functions */
void
session_get_window_info (GtkWidget *window,
SessionInfo *info)
......@@ -257,7 +263,9 @@ save_sessionrc (void)
g_list_foreach (session_info_updates, (GFunc) sessionrc_write_info, fp);
/* save last tip shown */
fprintf(fp, "(last-tip-shown %d)\n\n", last_tip + 1);
fprintf (fp, "(last-tip-shown %d)\n\n", last_tip + 1);
color_history_write (fp);
fclose (fp);
}
......@@ -302,7 +310,8 @@ session_restore (void)
/* internal function */
static void
sessionrc_write_info (SessionInfo *info, FILE *fp)
sessionrc_write_info (SessionInfo *info,
FILE *fp)
{
if (fp == NULL || info == NULL)
return;
......
......@@ -51,22 +51,27 @@
#include "app_procs.h"
#include "appenv.h"
#include "color_notebook.h"
#include "commands.h"
#include "gimprc.h"
#include "session.h"
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *info,
FILE *fp);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_info_updates = NULL;
#define LEFT_OFFSET 60
#define TOP_OFFSET 60
static void sessionrc_write_info (SessionInfo *info,
FILE *fp);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_info_updates = NULL;
/* global session variables */
SessionInfo toolbox_session_info =
{
......@@ -168,7 +173,8 @@ SessionInfo document_index_session_info =
};
/* public functions */
/* public functions */
void
session_get_window_info (GtkWidget *window,
SessionInfo *info)
......@@ -257,7 +263,9 @@ save_sessionrc (void)
g_list_foreach (session_info_updates, (GFunc) sessionrc_write_info, fp);
/* save last tip shown */
fprintf(fp, "(last-tip-shown %d)\n\n", last_tip + 1);
fprintf (fp, "(last-tip-shown %d)\n\n", last_tip + 1);
color_history_write (fp);
fclose (fp);
}
......@@ -302,7 +310,8 @@ session_restore (void)
/* internal function */
static void
sessionrc_write_info (SessionInfo *info, FILE *fp)
sessionrc_write_info (SessionInfo *info,
FILE *fp)
{
if (fp == NULL || info == NULL)
return;
......
......@@ -155,6 +155,7 @@ static gint color_notebook_hex_entry_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void color_history_init (void);
static void color_history_color_clicked (GtkWidget *widget,
gpointer data);
static void color_history_color_changed (GtkWidget *widget,
......@@ -225,16 +226,8 @@ color_notebook_new (GimpRGB *color,
g_return_val_if_fail (selector_info != NULL, NULL);
g_return_val_if_fail (color != NULL, NULL);
/* EEK */
if (! color_history_initialized)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
color_history_init ();
cnp = g_new0 (ColorNotebook, 1);
......@@ -496,11 +489,12 @@ color_notebook_new (GimpRGB *color,
color_notebook_update_scales (cnp, -1);
/* The color history */
hbox = gtk_hbox_new (TRUE, 2);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new ();
gtk_widget_set_usize (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button,
_("Add the current color to the color history"),
......@@ -1147,6 +1141,50 @@ color_notebook_hex_entry_events (GtkWidget *widget,
return FALSE;
}
void
color_history_add_color_from_rc (GimpRGB *color)
{
static gint index = 0;
if (! color_history_initialized)
color_history_init ();
if (color && index < COLOR_HISTORY_SIZE)
{
color_history[index++] = *color;
}
}
void
color_history_write (FILE *fp)
{
gint i;
fprintf (fp, "(color-history");
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
}
fprintf (fp, ")\n\n");
}
static void
color_history_init (void)
{
gint i;
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
gimp_rgba_set (&color_history[i], 1.0, 1.0, 1.0, 1.0);
color_history_initialized = TRUE;
}
static void
color_history_color_clicked (GtkWidget *widget,
gpointer data)
......