Commit a4572c8f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

fix a warning.

2000-02-12  Michael Natterer  <mitch@gimp.org>

	* app/app_procs.c: fix a warning.

	* app/menus.c: don't allow the help menu item accelerators to be
	changed. Move all ordinary menu items under "<Toolbox>/Xtns"
	before the separator without explicitly naming them.

	* app/session.[ch]: minor cleanups without changing any logic.
parent cfec42a8
2000-02-12 Michael Natterer <mitch@gimp.org>
* app/app_procs.c: fix a warning.
* app/menus.c: don't allow the help menu item accelerators to be
changed. Move all ordinary menu items under "<Toolbox>/Xtns"
before the separator without explicitly naming them.
* app/session.[ch]: minor cleanups without changing any logic.
Sat Feb 12 15:37:29 CET 2000 Sven Neumann <sven@gimp.org>
 
* app/info_dialog.c
* app/info_window.c: cosmetics and i18n fixes
 
2000-02-12 Michael Natterer <mitschel@cs.tu-berlin.de>
2000-02-12 Michael Natterer <mitch@gimp.org>
 
* app/gdisplay_ops.c
* app/gradient.c
......
......@@ -705,7 +705,7 @@ app_exit (gboolean kill_it)
*************************************************/
static void
really_quit_callback (GtkButton *button,
really_quit_callback (GtkWidget *button,
gboolean quit,
gpointer data)
{
......
......@@ -1041,13 +1041,6 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
void
menus_reorder_plugins (void)
{
static gchar *xtns_plugins[] = { "DB Browser...",
"PDB Explorer",
"Plugin Details...",
"Parasite Editor" };
static gint n_xtns_plugins = (sizeof (xtns_plugins) /
sizeof (xtns_plugins[0]));
static gchar *rotate_plugins[] = { "90 degrees",
"180 degrees",
"270 degrees" };
......@@ -1074,20 +1067,31 @@ menus_reorder_plugins (void)
GtkWidget *menu;
GList *list;
gchar *path;
gint i, pos;
gint i, pos;
/* Beautify "<Toolbox>/Xtns" */
pos = 2;
for (i = 0; i < n_xtns_plugins; i++)
/* Move all menu items under "<Toolbox>/Xtns" which are not submenus or
* separators to the top of the menu
*/
pos = 1;
menu_item = gtk_item_factory_get_widget (toolbox_factory,
"/Xtns/Module Browser...");
if (menu_item && menu_item->parent && GTK_IS_MENU (menu_item->parent))
{
path = g_strconcat ("/Xtns/", xtns_plugins[i], NULL);
menu_item = gtk_item_factory_get_widget (toolbox_factory, path);
g_free (path);
menu = menu_item->parent;
if (menu_item && menu_item->parent)
for (list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos); list;
list = g_list_next (list))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent), menu_item, pos);
pos++;
menu_item = GTK_WIDGET (list->data);
if (! GTK_MENU_ITEM (menu_item)->submenu &&
GTK_IS_LABEL (GTK_BIN (menu_item)->child))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, pos);
list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos);
pos++;
}
}
}
......@@ -1486,21 +1490,43 @@ menus_item_key_press (GtkWidget *widget,
gchar *help_path = NULL;
gchar *help_page = NULL;
item_factory = (GtkItemFactory *) data;
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
/* first, check if the user tries to assign a shortcut to the help
* menu items and ignore it...
*/
if (active_menu_item)
{
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (help_page &&
*help_page &&
item_factory == toolbox_factory &&
(strcmp (help_page, "help/dialogs/help.html") == 0 ||
strcmp (help_page, "help/context_help.html") == 0))
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
return TRUE;
}
}
/* ...otherwise, for any key except F1, continue with the standard
* GtkItemFactory callback and assign a new shortcut...
*/
if (kevent->keyval != GDK_F1)
return FALSE;
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget),
"key_press_event");
/* ...finally, if F1 was pressed over any menu, show it's help page...
*/
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
item_factory = (GtkItemFactory *) data;
help_path = (gchar *) gtk_object_get_data (GTK_OBJECT (item_factory),
"help_path");
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
if (active_menu_item)
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (! help_page)
if (! help_page ||
! *help_page)
help_page = "index.html";
if (help_path && help_page)
......
......@@ -55,56 +55,107 @@
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void session_reset_open_state (SessionInfo *);
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 =
{ "toolbox", NULL, 0, 0, 0, 0, FALSE };
SessionInfo lc_dialog_session_info =
{ "lc-dialog", (GtkItemFactoryCallback)dialogs_lc_cmd_callback, 0, 400, 0, 0, FALSE };
SessionInfo info_dialog_session_info =
{ "info-dialog", NULL, 165, 0, 0, 0, FALSE };
SessionInfo tool_options_session_info =
{ "tool-options", (GtkItemFactoryCallback)dialogs_tool_options_cmd_callback, 0, 345, 0, 0, FALSE };
SessionInfo palette_session_info =
{ "palette", (GtkItemFactoryCallback)dialogs_palette_cmd_callback, 140, 180, 0, 0, FALSE };
SessionInfo brush_select_session_info =
{ "brush-select", (GtkItemFactoryCallback)dialogs_brushes_cmd_callback, 150, 180, 0, 0, FALSE };
SessionInfo pattern_select_session_info =
{ "pattern-select", (GtkItemFactoryCallback)dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_select_session_info =
{ "gradient-select", (GtkItemFactoryCallback)dialogs_gradients_cmd_callback, 170, 180, 0, 0, FALSE };
SessionInfo device_status_session_info =
{ "device-status", (GtkItemFactoryCallback)dialogs_device_status_cmd_callback, 0, 600, 0, 0, FALSE };
SessionInfo error_console_session_info =
{ "error-console", (GtkItemFactoryCallback)dialogs_error_console_cmd_callback, 400, 0, 250, 300, FALSE };
SessionInfo toolbox_session_info =
{
"toolbox",
NULL,
0, 0, 0, 0, FALSE
};
SessionInfo lc_dialog_session_info =
{
"lc-dialog",
(GtkItemFactoryCallback) dialogs_lc_cmd_callback,
0, 400, 0, 0, FALSE
};
SessionInfo info_dialog_session_info =
{
"info-dialog",
NULL,
165, 0, 0, 0, FALSE
};
SessionInfo tool_options_session_info =
{
"tool-options",
(GtkItemFactoryCallback) dialogs_tool_options_cmd_callback,
0, 345, 0, 0, FALSE
};
SessionInfo palette_session_info =
{
"palette",
(GtkItemFactoryCallback) dialogs_palette_cmd_callback,
140, 180, 0, 0, FALSE
};
SessionInfo brush_select_session_info =
{
"brush-select",
(GtkItemFactoryCallback) dialogs_brushes_cmd_callback,
150, 180, 0, 0, FALSE
};
SessionInfo pattern_select_session_info =
{
"pattern-select",
(GtkItemFactoryCallback) dialogs_patterns_cmd_callback,
160, 180, 0, 0, FALSE
};
SessionInfo gradient_select_session_info =
{
"gradient-select",
(GtkItemFactoryCallback) dialogs_gradients_cmd_callback,
170, 180, 0, 0, FALSE
};
SessionInfo device_status_session_info =
{
"device-status",
(GtkItemFactoryCallback) dialogs_device_status_cmd_callback,
0, 600, 0, 0, FALSE
};
SessionInfo error_console_session_info =
{
"error-console",
(GtkItemFactoryCallback) dialogs_error_console_cmd_callback,
400, 0, 250, 300, FALSE
};
/* public functions */
void
session_get_window_info (GtkWidget *window,
SessionInfo *info)
{
if ( !save_session_info || info == NULL || window->window == NULL )
if (!save_session_info || info == NULL || window->window == NULL)
return;
gdk_window_get_root_origin (window->window, &info->x, &info->y);
gdk_window_get_size (window->window, &info->width, &info->height);
if ( we_are_exiting )
if (we_are_exiting)
info->open = GTK_WIDGET_VISIBLE (window);
if ( g_list_find (session_info_updates, info) == NULL )
if (g_list_find (session_info_updates, info) == NULL)
session_info_updates = g_list_append (session_info_updates, info);
}
void
session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size)
gboolean set_size)
{
if ( window == NULL || info == NULL)
return;
......@@ -116,16 +167,16 @@ session_set_window_geometry (GtkWidget *window,
#else
gtk_widget_set_uposition (window, info->x, info->y);
#endif
if ( (set_size) && (info->width > 0) && (info->height > 0) )
if ((set_size) && (info->width > 0) && (info->height > 0))
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
}
void
save_sessionrc (void)
{
char *filename;
FILE *fp;
gchar *filename;
FILE *fp;
filename = gimp_personal_rc_file ("sessionrc");
......@@ -134,20 +185,20 @@ save_sessionrc (void)
if (!fp)
return;
fprintf(fp, "# GIMP sessionrc\n"
"# This file takes session-specific info (that is info,\n"
"# you want to keep between two gimp-sessions). You are\n"
"# not supposed to edit it manually, but of course you\n"
"# can do. This file will be entirely rewritten every time\n"
"# you quit the gimp. If this file isn't found, defaults\n"
"# are used.\n\n");
fprintf (fp, ("# GIMP sessionrc\n"
"# This file takes session-specific info (that is info,\n"
"# you want to keep between two gimp-sessions). You are\n"
"# not supposed to edit it manually, but of course you\n"
"# can do. This file will be entirely rewritten every time\n"
"# you quit the gimp. If this file isn't found, defaults\n"
"# are used.\n\n"));
/* save window geometries */
g_list_foreach (session_info_updates, (GFunc)sessionrc_write_info, fp);
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);
fclose (fp);
}
......@@ -212,7 +263,7 @@ session_open_dialog (SessionInfo *info)
static void
session_reset_open_state (SessionInfo *info)
{
if (info == NULL )
if (info == NULL)
return;
info->open = FALSE;
......
......@@ -26,13 +26,13 @@ typedef struct _SessionInfo SessionInfo;
struct _SessionInfo
{
char name[16];
GtkItemFactoryCallback open_callback;
int x;
int y;
int width;
int height;
int open;
gchar *name;
GtkItemFactoryCallback open_callback;
gint x;
gint y;
gint width;
gint height;
gint open;
};
/* global session variables */
......@@ -52,13 +52,13 @@ extern GList *session_info_updates; /* This list holds all session_infos
sessionrc on exit. */
/* function prototypes */
void session_get_window_info (GtkWidget *window,
SessionInfo *info);
void session_get_window_info (GtkWidget *window,
SessionInfo *info);
void session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size);
void session_init (void);
void session_restore (void);
void save_sessionrc (void);
gboolean set_size);
void session_init (void);
void session_restore (void);
void save_sessionrc (void);
#endif /* __SESSION_H__ */
......@@ -1041,13 +1041,6 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
void
menus_reorder_plugins (void)
{
static gchar *xtns_plugins[] = { "DB Browser...",
"PDB Explorer",
"Plugin Details...",
"Parasite Editor" };
static gint n_xtns_plugins = (sizeof (xtns_plugins) /
sizeof (xtns_plugins[0]));
static gchar *rotate_plugins[] = { "90 degrees",
"180 degrees",
"270 degrees" };
......@@ -1074,20 +1067,31 @@ menus_reorder_plugins (void)
GtkWidget *menu;
GList *list;
gchar *path;
gint i, pos;
gint i, pos;
/* Beautify "<Toolbox>/Xtns" */
pos = 2;
for (i = 0; i < n_xtns_plugins; i++)
/* Move all menu items under "<Toolbox>/Xtns" which are not submenus or
* separators to the top of the menu
*/
pos = 1;
menu_item = gtk_item_factory_get_widget (toolbox_factory,
"/Xtns/Module Browser...");
if (menu_item && menu_item->parent && GTK_IS_MENU (menu_item->parent))
{
path = g_strconcat ("/Xtns/", xtns_plugins[i], NULL);
menu_item = gtk_item_factory_get_widget (toolbox_factory, path);
g_free (path);
menu = menu_item->parent;
if (menu_item && menu_item->parent)
for (list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos); list;
list = g_list_next (list))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent), menu_item, pos);
pos++;
menu_item = GTK_WIDGET (list->data);
if (! GTK_MENU_ITEM (menu_item)->submenu &&
GTK_IS_LABEL (GTK_BIN (menu_item)->child))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, pos);
list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos);
pos++;
}
}
}
......@@ -1486,21 +1490,43 @@ menus_item_key_press (GtkWidget *widget,
gchar *help_path = NULL;
gchar *help_page = NULL;
item_factory = (GtkItemFactory *) data;
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
/* first, check if the user tries to assign a shortcut to the help
* menu items and ignore it...
*/
if (active_menu_item)
{
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (help_page &&
*help_page &&
item_factory == toolbox_factory &&
(strcmp (help_page, "help/dialogs/help.html") == 0 ||
strcmp (help_page, "help/context_help.html") == 0))
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
return TRUE;
}
}
/* ...otherwise, for any key except F1, continue with the standard
* GtkItemFactory callback and assign a new shortcut...
*/
if (kevent->keyval != GDK_F1)
return FALSE;
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget),
"key_press_event");
/* ...finally, if F1 was pressed over any menu, show it's help page...
*/
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
item_factory = (GtkItemFactory *) data;
help_path = (gchar *) gtk_object_get_data (GTK_OBJECT (item_factory),
"help_path");
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
if (active_menu_item)
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (! help_page)
if (! help_page ||
! *help_page)
help_page = "index.html";
if (help_path && help_page)
......
......@@ -1041,13 +1041,6 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
void
menus_reorder_plugins (void)
{
static gchar *xtns_plugins[] = { "DB Browser...",
"PDB Explorer",
"Plugin Details...",
"Parasite Editor" };
static gint n_xtns_plugins = (sizeof (xtns_plugins) /
sizeof (xtns_plugins[0]));
static gchar *rotate_plugins[] = { "90 degrees",
"180 degrees",
"270 degrees" };
......@@ -1074,20 +1067,31 @@ menus_reorder_plugins (void)
GtkWidget *menu;
GList *list;
gchar *path;
gint i, pos;
gint i, pos;
/* Beautify "<Toolbox>/Xtns" */
pos = 2;
for (i = 0; i < n_xtns_plugins; i++)
/* Move all menu items under "<Toolbox>/Xtns" which are not submenus or
* separators to the top of the menu
*/
pos = 1;
menu_item = gtk_item_factory_get_widget (toolbox_factory,
"/Xtns/Module Browser...");
if (menu_item && menu_item->parent && GTK_IS_MENU (menu_item->parent))
{
path = g_strconcat ("/Xtns/", xtns_plugins[i], NULL);
menu_item = gtk_item_factory_get_widget (toolbox_factory, path);
g_free (path);
menu = menu_item->parent;
if (menu_item && menu_item->parent)
for (list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos); list;
list = g_list_next (list))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent), menu_item, pos);
pos++;
menu_item = GTK_WIDGET (list->data);
if (! GTK_MENU_ITEM (menu_item)->submenu &&
GTK_IS_LABEL (GTK_BIN (menu_item)->child))
{
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, pos);
list = g_list_nth (GTK_MENU_SHELL (menu)->children, pos);
pos++;
}
}
}
......@@ -1486,21 +1490,43 @@ menus_item_key_press (GtkWidget *widget,
gchar *help_path = NULL;
gchar *help_page = NULL;
item_factory = (GtkItemFactory *) data;
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
/* first, check if the user tries to assign a shortcut to the help
* menu items and ignore it...
*/
if (active_menu_item)
{
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (help_page &&
*help_page &&
item_factory == toolbox_factory &&
(strcmp (help_page, "help/dialogs/help.html") == 0 ||
strcmp (help_page, "help/context_help.html") == 0))
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
return TRUE;
}
}
/* ...otherwise, for any key except F1, continue with the standard
* GtkItemFactory callback and assign a new shortcut...
*/
if (kevent->keyval != GDK_F1)
return FALSE;
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget),
"key_press_event");
/* ...finally, if F1 was pressed over any menu, show it's help page...
*/
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
item_factory = (GtkItemFactory *) data;
help_path = (gchar *) gtk_object_get_data (GTK_OBJECT (item_factory),
"help_path");
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
if (active_menu_item)
help_page = (gchar *) gtk_object_get_data (GTK_OBJECT (active_menu_item),
"help_page");
if (! help_page)
if (! help_page ||
! *help_page)
help_page = "index.html";
if (help_path && help_page)
......
......@@ -55,56 +55,107 @@
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void session_reset_open_state (SessionInfo *);
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 =
{ "toolbox", NULL, 0, 0, 0, 0, FALSE };
SessionInfo lc_dialog_session_info =
{ "lc-dialog", (GtkItemFactoryCallback)dialogs_lc_cmd_callback, 0, 400, 0, 0, FALSE };
SessionInfo info_dialog_session_info =
{ "info-dialog", NULL, 165, 0, 0, 0, FALSE };
SessionInfo tool_options_session_info =
{ "tool-options", (GtkItemFactoryCallback)dialogs_tool_options_cmd_callback, 0, 345, 0, 0, FALSE };
SessionInfo palette_session_info =
{ "palette", (GtkItemFactoryCallback)dialogs_palette_cmd_callback, 140, 180, 0, 0, FALSE };
SessionInfo brush_select_session_info =
{ "brush-select", (GtkItemFactoryCallback)dialogs_brushes_cmd_callback, 150, 180, 0, 0, FALSE };
SessionInfo pattern_select_session_info =
{ "pattern-select", (GtkItemFactoryCallback)dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_select_session_info =
{ "gradient-select", (GtkItemFactoryCallback)dialogs_gradients_cmd_callback, 170, 180, 0, 0, FALSE };
SessionInfo device_status_session_info =