added MRU file list (patch from nuke@bayside.net) Moved document index menu

item into the dialogs submenu

-Yosh
This commit is contained in:
Manish Singh 1998-07-12 05:18:17 +00:00
parent 1cba88aacc
commit 999b2781f4
20 changed files with 716 additions and 53 deletions

View File

@ -1,3 +1,12 @@
Sat Jul 11 22:15:31 PDT 1998 Manish Singh <yosh@gimp.org>
* fileops.c
* gimprc.[ch]
* menus.[ch]
* preferences_dialog.c: added MRU file list (patch from
nuke@bayside.net) Moved document index menu item into the
dialogs submenu
Sat Jul 11 23:57:09 1998 Owen Taylor <otaylor@gtk.org>
* app/ink.c (tools_free_ink): Free last_blob when destroying

View File

@ -201,7 +201,6 @@ devices_rc_update (gchar *name, DeviceValues values,
{
GList *tmp_list;
DeviceInfo *device_info;
GimpBrushP brushp;
/* Find device if we have it */

View File

@ -92,6 +92,7 @@ static int old_stingy_memory_use;
static int old_tile_cache_size;
static int old_install_cmap;
static int old_cycled_marching_ants;
static int old_last_opened_size;
static char * old_temp_path;
static char * old_swap_path;
static char * old_brush_path;
@ -111,6 +112,7 @@ static int edit_stingy_memory_use;
static int edit_tile_cache_size;
static int edit_install_cmap;
static int edit_cycled_marching_ants;
static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
@ -133,6 +135,7 @@ static int mem_size_unit;
tile-cache-size
install-cmap
cycled-marching-ants
last-opened-size
All of these now have variables of the form edit_temp_path, which
are copied from the actual variables (e.g. temp_path) the first time
@ -240,6 +243,7 @@ file_prefs_save_callback (GtkWidget *widget,
int save_tile_cache_size;
int save_install_cmap;
int save_cycled_marching_ants;
int save_last_opened_size;
gchar *save_temp_path;
gchar *save_swap_path;
gchar *save_brush_path;
@ -256,6 +260,7 @@ file_prefs_save_callback (GtkWidget *widget,
save_tile_cache_size = tile_cache_size;
save_install_cmap = install_cmap;
save_cycled_marching_ants = cycled_marching_ants;
save_last_opened_size = last_opened_size;
save_temp_path = temp_path;
save_swap_path = swap_path;
save_brush_path = brush_path;
@ -268,6 +273,8 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "undo-levels");
if (marching_speed != old_marching_speed)
update = g_list_append (update, "marching-ants-speed");
if (last_opened_size != old_last_opened_size)
update = g_list_append (update, "last-opened-size");
if (allow_resize_windows != old_allow_resize_windows)
{
update = g_list_append (update, "allow-resize-windows");
@ -337,6 +344,12 @@ file_prefs_save_callback (GtkWidget *widget,
cycled_marching_ants = edit_cycled_marching_ants;
restart_notification = TRUE;
}
if (edit_last_opened_size != last_opened_size)
{
update = g_list_append (update, "last-opened-size");
last_opened_size = edit_last_opened_size;
restart_notification = TRUE;
}
if (file_prefs_strcmp (temp_path, edit_temp_path))
{
update = g_list_append (update, "temp-path");
@ -386,6 +399,7 @@ file_prefs_save_callback (GtkWidget *widget,
tile_cache_size = save_tile_cache_size;
install_cmap = save_install_cmap;
cycled_marching_ants = save_cycled_marching_ants;
last_opened_size = save_last_opened_size;
temp_path = save_temp_path;
swap_path = save_swap_path;
brush_path = save_brush_path;
@ -454,6 +468,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
edit_tile_cache_size = old_tile_cache_size;
edit_install_cmap = old_install_cmap;
edit_cycled_marching_ants = old_cycled_marching_ants;
edit_last_opened_size = old_last_opened_size;
file_prefs_strset (&edit_temp_path, old_temp_path);
file_prefs_strset (&edit_swap_path, old_swap_path);
file_prefs_strset (&edit_brush_path, old_brush_path);
@ -679,6 +694,7 @@ file_pref_cmd_callback (GtkWidget *widget,
edit_tile_cache_size = tile_cache_size;
edit_install_cmap = install_cmap;
edit_cycled_marching_ants = cycled_marching_ants;
edit_last_opened_size = last_opened_size;
}
old_transparency_type = transparency_type;
old_transparency_size = transparency_size;
@ -700,6 +716,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_tile_cache_size = edit_tile_cache_size;
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1036,6 +1053,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&marching_speed);
gtk_widget_show (spinbutton);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new ("Recent Documents list size:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (last_opened_size, 0.0,
256.0, 1.0, 5.0, 0.0);
spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (spinbutton), "changed",
(GtkSignalFunc) file_prefs_spinbutton_callback,
&last_opened_size);
gtk_widget_show (spinbutton);
label = gtk_label_new ("Interface");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -856,6 +856,7 @@ file_open_ok_callback (GtkWidget *w,
{
file_dialog_hide (client_data);
gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE);
menus_last_opened_add (filename);
return;
}

View File

@ -96,6 +96,7 @@ double gamma_val = 1.0;
int transparency_type = 1; /* Mid-Tone Checks */
int transparency_size = 1; /* Medium sized */
int levels_of_undo = 1; /* 1 level of undo default */
int last_opened_size = 4; /* 4 documents in the MRU list */
int color_cube_shades[4] = {6, 7, 4, 24};
int install_cmap = 0;
int cycled_marching_ants = 0;
@ -194,6 +195,7 @@ static ParseFunc funcs[] =
{ "color-cube", TT_XCOLORCUBE, NULL, NULL },
{ "tile-cache-size", TT_MEMSIZE, &tile_cache_size, NULL },
{ "marching-ants-speed", TT_INT, &marching_speed, NULL },
{ "last-opened-size", TT_INT, &last_opened_size, NULL },
{ "undo-levels", TT_INT, &levels_of_undo, NULL },
{ "transparency-type", TT_INT, &transparency_type, NULL },
{ "transparency-size", TT_INT, &transparency_size, NULL },

View File

@ -36,6 +36,7 @@ extern char * default_gradient;
extern char * pluginrc_path;
extern int tile_cache_size;
extern int marching_speed;
extern int last_opened_size;
extern double gamma_val;
extern int transparency_type;
extern int transparency_size;

View File

@ -201,7 +201,6 @@ devices_rc_update (gchar *name, DeviceValues values,
{
GList *tmp_list;
DeviceInfo *device_info;
GimpBrushP brushp;
/* Find device if we have it */

View File

@ -201,7 +201,6 @@ devices_rc_update (gchar *name, DeviceValues values,
{
GList *tmp_list;
DeviceInfo *device_info;
GimpBrushP brushp;
/* Find device if we have it */

View File

@ -22,6 +22,7 @@
#include "colormaps.h"
#include "commands.h"
#include "fileops.h"
#include "general.h"
#include "gimprc.h"
#include "interface.h"
#include "menus.h"
@ -32,8 +33,14 @@
#include "gdisplay.h"
#include "docindex.h"
#define MRU_MENU_ENTRY_SIZE sizeof ("/File/MRU00")
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_init (void);
static GSList *last_opened_raw_filenames = NULL;
static gint num_entries = 0;
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
@ -50,13 +57,15 @@ static GtkItemFactoryEntry toolbox_entries[] =
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/Dialogs/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry file_menu_separator = { "/File/---", NULL, NULL, 0, "<Separator>" };
static GtkItemFactoryEntry toolbox_end = { "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 };
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
@ -385,6 +394,140 @@ menus_quit ()
}
void
menus_last_opened_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint num)
{
gchar *filename, *raw_filename;
raw_filename = ((GString *) g_slist_nth_data (last_opened_raw_filenames, num))->str;
filename = prune_filename (raw_filename);
if (!file_open(raw_filename, filename))
g_message ("Error opening file: %s\n", raw_filename);
}
void
menus_last_opened_update_labels ()
{
GSList *filename_slist;
GString *entry_filename, *path;
GtkWidget *widget;
gint i;
entry_filename = g_string_new ("");
path = g_string_new ("");
filename_slist = last_opened_raw_filenames;
for (i = 1; i <= num_entries; i++)
{
g_string_sprintf (entry_filename, "%d. %s", i, prune_filename (((GString *) filename_slist->data)->str));
g_string_sprintf (path, "/File/MRU%02d", i);
widget = gtk_item_factory_get_widget (toolbox_factory, path->str);
gtk_widget_show (widget);
gtk_label_set (GTK_LABEL (GTK_BIN (widget)->child), entry_filename->str);
filename_slist = filename_slist->next;
}
g_string_free (entry_filename, TRUE);
g_string_free (path, TRUE);
}
void
menus_last_opened_add (gchar *filename)
{
GString *raw_filename;
GtkWidget *widget;
if (num_entries == last_opened_size)
{
g_slist_free (g_slist_last (last_opened_raw_filenames));
}
raw_filename = g_string_new (filename);
last_opened_raw_filenames = g_slist_prepend (last_opened_raw_filenames, raw_filename);
if (num_entries == 0)
{
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_show (widget);
}
if (num_entries < last_opened_size)
num_entries++;
menus_last_opened_update_labels ();
}
void
menus_init_mru ()
{
gchar *paths, *accelerators;
gint i;
GtkItemFactoryEntry *last_opened_entries;
GtkWidget *widget;
last_opened_entries = g_new (GtkItemFactoryEntry, last_opened_size);
paths = g_new (gchar, last_opened_size * MRU_MENU_ENTRY_SIZE);
accelerators = g_new (gchar, 9 * MRU_MENU_ACCEL_SIZE);
for (i = 0; i < last_opened_size; i++)
{
gchar *path, *accelerator;
path = &paths[i * MRU_MENU_ENTRY_SIZE];
if (i < 9)
accelerator = &accelerators[i * MRU_MENU_ACCEL_SIZE];
else
accelerator = NULL;
last_opened_entries[i].path = path;
last_opened_entries[i].accelerator = accelerator;
last_opened_entries[i].callback = (GtkItemFactoryCallback) menus_last_opened_cmd_callback;
last_opened_entries[i].callback_action = i;
last_opened_entries[i].item_type = NULL;
sprintf (path, "/File/MRU%02d", i + 1);
sprintf (accelerator, "<control>%d", i + 1);
}
gtk_item_factory_create_items_ac (toolbox_factory, last_opened_size,
last_opened_entries, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &file_menu_separator, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &toolbox_end, NULL, 2);
for (i=0; i < last_opened_size; i++)
{
widget = gtk_item_factory_get_widget (toolbox_factory,
last_opened_entries[i].path);
gtk_widget_hide (widget);
}
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_hide (widget);
g_free (paths);
g_free (accelerators);
g_free (last_opened_entries);
}
/* This is separate from menus_init() in case the last_opened_size changes,
or for any other reason we might want to regen just the toolbox menu */
void
menus_init_toolbox ()
{
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory, n_toolbox_entries,
toolbox_entries, NULL, 2);
menus_init_mru ();
}
static void
menus_init ()
@ -397,11 +540,8 @@ menus_init ()
initialize = FALSE;
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
menus_init_toolbox ();
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
@ -428,8 +568,3 @@ menus_init ()
g_free (filename);
}
}

View File

@ -38,6 +38,7 @@ void menus_set_state (char *path,
int state);
void menus_destroy (char *path);
void menus_quit (void);
void menus_last_opened_add (gchar *filename);
#endif /* MENUS_H */

View File

@ -92,6 +92,7 @@ static int old_stingy_memory_use;
static int old_tile_cache_size;
static int old_install_cmap;
static int old_cycled_marching_ants;
static int old_last_opened_size;
static char * old_temp_path;
static char * old_swap_path;
static char * old_brush_path;
@ -111,6 +112,7 @@ static int edit_stingy_memory_use;
static int edit_tile_cache_size;
static int edit_install_cmap;
static int edit_cycled_marching_ants;
static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
@ -133,6 +135,7 @@ static int mem_size_unit;
tile-cache-size
install-cmap
cycled-marching-ants
last-opened-size
All of these now have variables of the form edit_temp_path, which
are copied from the actual variables (e.g. temp_path) the first time
@ -240,6 +243,7 @@ file_prefs_save_callback (GtkWidget *widget,
int save_tile_cache_size;
int save_install_cmap;
int save_cycled_marching_ants;
int save_last_opened_size;
gchar *save_temp_path;
gchar *save_swap_path;
gchar *save_brush_path;
@ -256,6 +260,7 @@ file_prefs_save_callback (GtkWidget *widget,
save_tile_cache_size = tile_cache_size;
save_install_cmap = install_cmap;
save_cycled_marching_ants = cycled_marching_ants;
save_last_opened_size = last_opened_size;
save_temp_path = temp_path;
save_swap_path = swap_path;
save_brush_path = brush_path;
@ -268,6 +273,8 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "undo-levels");
if (marching_speed != old_marching_speed)
update = g_list_append (update, "marching-ants-speed");
if (last_opened_size != old_last_opened_size)
update = g_list_append (update, "last-opened-size");
if (allow_resize_windows != old_allow_resize_windows)
{
update = g_list_append (update, "allow-resize-windows");
@ -337,6 +344,12 @@ file_prefs_save_callback (GtkWidget *widget,
cycled_marching_ants = edit_cycled_marching_ants;
restart_notification = TRUE;
}
if (edit_last_opened_size != last_opened_size)
{
update = g_list_append (update, "last-opened-size");
last_opened_size = edit_last_opened_size;
restart_notification = TRUE;
}
if (file_prefs_strcmp (temp_path, edit_temp_path))
{
update = g_list_append (update, "temp-path");
@ -386,6 +399,7 @@ file_prefs_save_callback (GtkWidget *widget,
tile_cache_size = save_tile_cache_size;
install_cmap = save_install_cmap;
cycled_marching_ants = save_cycled_marching_ants;
last_opened_size = save_last_opened_size;
temp_path = save_temp_path;
swap_path = save_swap_path;
brush_path = save_brush_path;
@ -454,6 +468,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
edit_tile_cache_size = old_tile_cache_size;
edit_install_cmap = old_install_cmap;
edit_cycled_marching_ants = old_cycled_marching_ants;
edit_last_opened_size = old_last_opened_size;
file_prefs_strset (&edit_temp_path, old_temp_path);
file_prefs_strset (&edit_swap_path, old_swap_path);
file_prefs_strset (&edit_brush_path, old_brush_path);
@ -679,6 +694,7 @@ file_pref_cmd_callback (GtkWidget *widget,
edit_tile_cache_size = tile_cache_size;
edit_install_cmap = install_cmap;
edit_cycled_marching_ants = cycled_marching_ants;
edit_last_opened_size = last_opened_size;
}
old_transparency_type = transparency_type;
old_transparency_size = transparency_size;
@ -700,6 +716,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_tile_cache_size = edit_tile_cache_size;
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1036,6 +1053,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&marching_speed);
gtk_widget_show (spinbutton);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new ("Recent Documents list size:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (last_opened_size, 0.0,
256.0, 1.0, 5.0, 0.0);
spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (spinbutton), "changed",
(GtkSignalFunc) file_prefs_spinbutton_callback,
&last_opened_size);
gtk_widget_show (spinbutton);
label = gtk_label_new ("Interface");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -22,6 +22,7 @@
#include "colormaps.h"
#include "commands.h"
#include "fileops.h"
#include "general.h"
#include "gimprc.h"
#include "interface.h"
#include "menus.h"
@ -32,8 +33,14 @@
#include "gdisplay.h"
#include "docindex.h"
#define MRU_MENU_ENTRY_SIZE sizeof ("/File/MRU00")
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_init (void);
static GSList *last_opened_raw_filenames = NULL;
static gint num_entries = 0;
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
@ -50,13 +57,15 @@ static GtkItemFactoryEntry toolbox_entries[] =
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/Dialogs/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry file_menu_separator = { "/File/---", NULL, NULL, 0, "<Separator>" };
static GtkItemFactoryEntry toolbox_end = { "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 };
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
@ -385,6 +394,140 @@ menus_quit ()
}
void
menus_last_opened_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint num)
{
gchar *filename, *raw_filename;
raw_filename = ((GString *) g_slist_nth_data (last_opened_raw_filenames, num))->str;
filename = prune_filename (raw_filename);
if (!file_open(raw_filename, filename))
g_message ("Error opening file: %s\n", raw_filename);
}
void
menus_last_opened_update_labels ()
{
GSList *filename_slist;
GString *entry_filename, *path;
GtkWidget *widget;
gint i;
entry_filename = g_string_new ("");
path = g_string_new ("");
filename_slist = last_opened_raw_filenames;
for (i = 1; i <= num_entries; i++)
{
g_string_sprintf (entry_filename, "%d. %s", i, prune_filename (((GString *) filename_slist->data)->str));
g_string_sprintf (path, "/File/MRU%02d", i);
widget = gtk_item_factory_get_widget (toolbox_factory, path->str);
gtk_widget_show (widget);
gtk_label_set (GTK_LABEL (GTK_BIN (widget)->child), entry_filename->str);
filename_slist = filename_slist->next;
}
g_string_free (entry_filename, TRUE);
g_string_free (path, TRUE);
}
void
menus_last_opened_add (gchar *filename)
{
GString *raw_filename;
GtkWidget *widget;
if (num_entries == last_opened_size)
{
g_slist_free (g_slist_last (last_opened_raw_filenames));
}
raw_filename = g_string_new (filename);
last_opened_raw_filenames = g_slist_prepend (last_opened_raw_filenames, raw_filename);
if (num_entries == 0)
{
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_show (widget);
}
if (num_entries < last_opened_size)
num_entries++;
menus_last_opened_update_labels ();
}
void
menus_init_mru ()
{
gchar *paths, *accelerators;
gint i;
GtkItemFactoryEntry *last_opened_entries;
GtkWidget *widget;
last_opened_entries = g_new (GtkItemFactoryEntry, last_opened_size);
paths = g_new (gchar, last_opened_size * MRU_MENU_ENTRY_SIZE);
accelerators = g_new (gchar, 9 * MRU_MENU_ACCEL_SIZE);
for (i = 0; i < last_opened_size; i++)
{
gchar *path, *accelerator;
path = &paths[i * MRU_MENU_ENTRY_SIZE];
if (i < 9)
accelerator = &accelerators[i * MRU_MENU_ACCEL_SIZE];
else
accelerator = NULL;
last_opened_entries[i].path = path;
last_opened_entries[i].accelerator = accelerator;
last_opened_entries[i].callback = (GtkItemFactoryCallback) menus_last_opened_cmd_callback;
last_opened_entries[i].callback_action = i;
last_opened_entries[i].item_type = NULL;
sprintf (path, "/File/MRU%02d", i + 1);
sprintf (accelerator, "<control>%d", i + 1);
}
gtk_item_factory_create_items_ac (toolbox_factory, last_opened_size,
last_opened_entries, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &file_menu_separator, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &toolbox_end, NULL, 2);
for (i=0; i < last_opened_size; i++)
{
widget = gtk_item_factory_get_widget (toolbox_factory,
last_opened_entries[i].path);
gtk_widget_hide (widget);
}
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_hide (widget);
g_free (paths);
g_free (accelerators);
g_free (last_opened_entries);
}
/* This is separate from menus_init() in case the last_opened_size changes,
or for any other reason we might want to regen just the toolbox menu */
void
menus_init_toolbox ()
{
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory, n_toolbox_entries,
toolbox_entries, NULL, 2);
menus_init_mru ();
}
static void
menus_init ()
@ -397,11 +540,8 @@ menus_init ()
initialize = FALSE;
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
menus_init_toolbox ();
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
@ -428,8 +568,3 @@ menus_init ()
g_free (filename);
}
}

View File

@ -38,6 +38,7 @@ void menus_set_state (char *path,
int state);
void menus_destroy (char *path);
void menus_quit (void);
void menus_last_opened_add (gchar *filename);
#endif /* MENUS_H */

View File

@ -22,6 +22,7 @@
#include "colormaps.h"
#include "commands.h"
#include "fileops.h"
#include "general.h"
#include "gimprc.h"
#include "interface.h"
#include "menus.h"
@ -32,8 +33,14 @@
#include "gdisplay.h"
#include "docindex.h"
#define MRU_MENU_ENTRY_SIZE sizeof ("/File/MRU00")
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_init (void);
static GSList *last_opened_raw_filenames = NULL;
static gint num_entries = 0;
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
@ -50,13 +57,15 @@ static GtkItemFactoryEntry toolbox_entries[] =
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/Dialogs/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry file_menu_separator = { "/File/---", NULL, NULL, 0, "<Separator>" };
static GtkItemFactoryEntry toolbox_end = { "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 };
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
@ -385,6 +394,140 @@ menus_quit ()
}
void
menus_last_opened_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint num)
{
gchar *filename, *raw_filename;
raw_filename = ((GString *) g_slist_nth_data (last_opened_raw_filenames, num))->str;
filename = prune_filename (raw_filename);
if (!file_open(raw_filename, filename))
g_message ("Error opening file: %s\n", raw_filename);
}
void
menus_last_opened_update_labels ()
{
GSList *filename_slist;
GString *entry_filename, *path;
GtkWidget *widget;
gint i;
entry_filename = g_string_new ("");
path = g_string_new ("");
filename_slist = last_opened_raw_filenames;
for (i = 1; i <= num_entries; i++)
{
g_string_sprintf (entry_filename, "%d. %s", i, prune_filename (((GString *) filename_slist->data)->str));
g_string_sprintf (path, "/File/MRU%02d", i);
widget = gtk_item_factory_get_widget (toolbox_factory, path->str);
gtk_widget_show (widget);
gtk_label_set (GTK_LABEL (GTK_BIN (widget)->child), entry_filename->str);
filename_slist = filename_slist->next;
}
g_string_free (entry_filename, TRUE);
g_string_free (path, TRUE);
}
void
menus_last_opened_add (gchar *filename)
{
GString *raw_filename;
GtkWidget *widget;
if (num_entries == last_opened_size)
{
g_slist_free (g_slist_last (last_opened_raw_filenames));
}
raw_filename = g_string_new (filename);
last_opened_raw_filenames = g_slist_prepend (last_opened_raw_filenames, raw_filename);
if (num_entries == 0)
{
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_show (widget);
}
if (num_entries < last_opened_size)
num_entries++;
menus_last_opened_update_labels ();
}
void
menus_init_mru ()
{
gchar *paths, *accelerators;
gint i;
GtkItemFactoryEntry *last_opened_entries;
GtkWidget *widget;
last_opened_entries = g_new (GtkItemFactoryEntry, last_opened_size);
paths = g_new (gchar, last_opened_size * MRU_MENU_ENTRY_SIZE);
accelerators = g_new (gchar, 9 * MRU_MENU_ACCEL_SIZE);
for (i = 0; i < last_opened_size; i++)
{
gchar *path, *accelerator;
path = &paths[i * MRU_MENU_ENTRY_SIZE];
if (i < 9)
accelerator = &accelerators[i * MRU_MENU_ACCEL_SIZE];
else
accelerator = NULL;
last_opened_entries[i].path = path;
last_opened_entries[i].accelerator = accelerator;
last_opened_entries[i].callback = (GtkItemFactoryCallback) menus_last_opened_cmd_callback;
last_opened_entries[i].callback_action = i;
last_opened_entries[i].item_type = NULL;
sprintf (path, "/File/MRU%02d", i + 1);
sprintf (accelerator, "<control>%d", i + 1);
}
gtk_item_factory_create_items_ac (toolbox_factory, last_opened_size,
last_opened_entries, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &file_menu_separator, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &toolbox_end, NULL, 2);
for (i=0; i < last_opened_size; i++)
{
widget = gtk_item_factory_get_widget (toolbox_factory,
last_opened_entries[i].path);
gtk_widget_hide (widget);
}
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_hide (widget);
g_free (paths);
g_free (accelerators);
g_free (last_opened_entries);
}
/* This is separate from menus_init() in case the last_opened_size changes,
or for any other reason we might want to regen just the toolbox menu */
void
menus_init_toolbox ()
{
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory, n_toolbox_entries,
toolbox_entries, NULL, 2);
menus_init_mru ();
}
static void
menus_init ()
@ -397,11 +540,8 @@ menus_init ()
initialize = FALSE;
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
menus_init_toolbox ();
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
@ -428,8 +568,3 @@ menus_init ()
g_free (filename);
}
}

View File

@ -38,6 +38,7 @@ void menus_set_state (char *path,
int state);
void menus_destroy (char *path);
void menus_quit (void);
void menus_last_opened_add (gchar *filename);
#endif /* MENUS_H */

View File

@ -92,6 +92,7 @@ static int old_stingy_memory_use;
static int old_tile_cache_size;
static int old_install_cmap;
static int old_cycled_marching_ants;
static int old_last_opened_size;
static char * old_temp_path;
static char * old_swap_path;
static char * old_brush_path;
@ -111,6 +112,7 @@ static int edit_stingy_memory_use;
static int edit_tile_cache_size;
static int edit_install_cmap;
static int edit_cycled_marching_ants;
static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
@ -133,6 +135,7 @@ static int mem_size_unit;
tile-cache-size
install-cmap
cycled-marching-ants
last-opened-size
All of these now have variables of the form edit_temp_path, which
are copied from the actual variables (e.g. temp_path) the first time
@ -240,6 +243,7 @@ file_prefs_save_callback (GtkWidget *widget,
int save_tile_cache_size;
int save_install_cmap;
int save_cycled_marching_ants;
int save_last_opened_size;
gchar *save_temp_path;
gchar *save_swap_path;
gchar *save_brush_path;
@ -256,6 +260,7 @@ file_prefs_save_callback (GtkWidget *widget,
save_tile_cache_size = tile_cache_size;
save_install_cmap = install_cmap;
save_cycled_marching_ants = cycled_marching_ants;
save_last_opened_size = last_opened_size;
save_temp_path = temp_path;
save_swap_path = swap_path;
save_brush_path = brush_path;
@ -268,6 +273,8 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "undo-levels");
if (marching_speed != old_marching_speed)
update = g_list_append (update, "marching-ants-speed");
if (last_opened_size != old_last_opened_size)
update = g_list_append (update, "last-opened-size");
if (allow_resize_windows != old_allow_resize_windows)
{
update = g_list_append (update, "allow-resize-windows");
@ -337,6 +344,12 @@ file_prefs_save_callback (GtkWidget *widget,
cycled_marching_ants = edit_cycled_marching_ants;
restart_notification = TRUE;
}
if (edit_last_opened_size != last_opened_size)
{
update = g_list_append (update, "last-opened-size");
last_opened_size = edit_last_opened_size;
restart_notification = TRUE;
}
if (file_prefs_strcmp (temp_path, edit_temp_path))
{
update = g_list_append (update, "temp-path");
@ -386,6 +399,7 @@ file_prefs_save_callback (GtkWidget *widget,
tile_cache_size = save_tile_cache_size;
install_cmap = save_install_cmap;
cycled_marching_ants = save_cycled_marching_ants;
last_opened_size = save_last_opened_size;
temp_path = save_temp_path;
swap_path = save_swap_path;
brush_path = save_brush_path;
@ -454,6 +468,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
edit_tile_cache_size = old_tile_cache_size;
edit_install_cmap = old_install_cmap;
edit_cycled_marching_ants = old_cycled_marching_ants;
edit_last_opened_size = old_last_opened_size;
file_prefs_strset (&edit_temp_path, old_temp_path);
file_prefs_strset (&edit_swap_path, old_swap_path);
file_prefs_strset (&edit_brush_path, old_brush_path);
@ -679,6 +694,7 @@ file_pref_cmd_callback (GtkWidget *widget,
edit_tile_cache_size = tile_cache_size;
edit_install_cmap = install_cmap;
edit_cycled_marching_ants = cycled_marching_ants;
edit_last_opened_size = last_opened_size;
}
old_transparency_type = transparency_type;
old_transparency_size = transparency_size;
@ -700,6 +716,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_tile_cache_size = edit_tile_cache_size;
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1036,6 +1053,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&marching_speed);
gtk_widget_show (spinbutton);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new ("Recent Documents list size:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (last_opened_size, 0.0,
256.0, 1.0, 5.0, 0.0);
spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (spinbutton), "changed",
(GtkSignalFunc) file_prefs_spinbutton_callback,
&last_opened_size);
gtk_widget_show (spinbutton);
label = gtk_label_new ("Interface");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -201,7 +201,6 @@ devices_rc_update (gchar *name, DeviceValues values,
{
GList *tmp_list;
DeviceInfo *device_info;
GimpBrushP brushp;
/* Find device if we have it */

View File

@ -201,7 +201,6 @@ devices_rc_update (gchar *name, DeviceValues values,
{
GList *tmp_list;
DeviceInfo *device_info;
GimpBrushP brushp;
/* Find device if we have it */

View File

@ -22,6 +22,7 @@
#include "colormaps.h"
#include "commands.h"
#include "fileops.h"
#include "general.h"
#include "gimprc.h"
#include "interface.h"
#include "menus.h"
@ -32,8 +33,14 @@
#include "gdisplay.h"
#include "docindex.h"
#define MRU_MENU_ENTRY_SIZE sizeof ("/File/MRU00")
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_init (void);
static GSList *last_opened_raw_filenames = NULL;
static gint num_entries = 0;
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
@ -50,13 +57,15 @@ static GtkItemFactoryEntry toolbox_entries[] =
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/Dialogs/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Document Index...", NULL, raise_idea_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry file_menu_separator = { "/File/---", NULL, NULL, 0, "<Separator>" };
static GtkItemFactoryEntry toolbox_end = { "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 };
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
@ -385,6 +394,140 @@ menus_quit ()
}
void
menus_last_opened_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint num)
{
gchar *filename, *raw_filename;
raw_filename = ((GString *) g_slist_nth_data (last_opened_raw_filenames, num))->str;
filename = prune_filename (raw_filename);
if (!file_open(raw_filename, filename))
g_message ("Error opening file: %s\n", raw_filename);
}
void
menus_last_opened_update_labels ()
{
GSList *filename_slist;
GString *entry_filename, *path;
GtkWidget *widget;
gint i;
entry_filename = g_string_new ("");
path = g_string_new ("");
filename_slist = last_opened_raw_filenames;
for (i = 1; i <= num_entries; i++)
{
g_string_sprintf (entry_filename, "%d. %s", i, prune_filename (((GString *) filename_slist->data)->str));
g_string_sprintf (path, "/File/MRU%02d", i);
widget = gtk_item_factory_get_widget (toolbox_factory, path->str);
gtk_widget_show (widget);
gtk_label_set (GTK_LABEL (GTK_BIN (widget)->child), entry_filename->str);
filename_slist = filename_slist->next;
}
g_string_free (entry_filename, TRUE);
g_string_free (path, TRUE);
}
void
menus_last_opened_add (gchar *filename)
{
GString *raw_filename;
GtkWidget *widget;
if (num_entries == last_opened_size)
{
g_slist_free (g_slist_last (last_opened_raw_filenames));
}
raw_filename = g_string_new (filename);
last_opened_raw_filenames = g_slist_prepend (last_opened_raw_filenames, raw_filename);
if (num_entries == 0)
{
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_show (widget);
}
if (num_entries < last_opened_size)
num_entries++;
menus_last_opened_update_labels ();
}
void
menus_init_mru ()
{
gchar *paths, *accelerators;
gint i;
GtkItemFactoryEntry *last_opened_entries;
GtkWidget *widget;
last_opened_entries = g_new (GtkItemFactoryEntry, last_opened_size);
paths = g_new (gchar, last_opened_size * MRU_MENU_ENTRY_SIZE);
accelerators = g_new (gchar, 9 * MRU_MENU_ACCEL_SIZE);
for (i = 0; i < last_opened_size; i++)
{
gchar *path, *accelerator;
path = &paths[i * MRU_MENU_ENTRY_SIZE];
if (i < 9)
accelerator = &accelerators[i * MRU_MENU_ACCEL_SIZE];
else
accelerator = NULL;
last_opened_entries[i].path = path;
last_opened_entries[i].accelerator = accelerator;
last_opened_entries[i].callback = (GtkItemFactoryCallback) menus_last_opened_cmd_callback;
last_opened_entries[i].callback_action = i;
last_opened_entries[i].item_type = NULL;
sprintf (path, "/File/MRU%02d", i + 1);
sprintf (accelerator, "<control>%d", i + 1);
}
gtk_item_factory_create_items_ac (toolbox_factory, last_opened_size,
last_opened_entries, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &file_menu_separator, NULL, 2);
gtk_item_factory_create_item (toolbox_factory, &toolbox_end, NULL, 2);
for (i=0; i < last_opened_size; i++)
{
widget = gtk_item_factory_get_widget (toolbox_factory,
last_opened_entries[i].path);
gtk_widget_hide (widget);
}
widget = gtk_item_factory_get_widget (toolbox_factory, file_menu_separator.path);
gtk_widget_hide (widget);
g_free (paths);
g_free (accelerators);
g_free (last_opened_entries);
}
/* This is separate from menus_init() in case the last_opened_size changes,
or for any other reason we might want to regen just the toolbox menu */
void
menus_init_toolbox ()
{
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory, n_toolbox_entries,
toolbox_entries, NULL, 2);
menus_init_mru ();
}
static void
menus_init ()
@ -397,11 +540,8 @@ menus_init ()
initialize = FALSE;
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
menus_init_toolbox ();
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
@ -428,8 +568,3 @@ menus_init ()
g_free (filename);
}
}

View File

@ -38,6 +38,7 @@ void menus_set_state (char *path,
int state);
void menus_destroy (char *path);
void menus_quit (void);
void menus_last_opened_add (gchar *filename);
#endif /* MENUS_H */