Commit 3dba5fbc authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

use connect_swapped to get rid of the unused argument


2003-06-05  Jody Goldberg <jody@gnome.org>

	* dialog-plugin-manager.c (cb_pm_button_rescan_directories_clicked) :
	  use connect_swapped to get rid of the unused argument
	(cb_pm_button_directory_add_clicked) : merge in pm_add_dir
	  and clarify the ownership of the lists and manually
	  reload the directories for now.  Eventually we should
	  just monitor the notify signal of something.
	(cb_pm_button_directory_delete_clicked) : merge in pm_delete_dir
	  and clarify the ownership of the lists and manually
	  reload the directories for now.  Eventually we should
	  just monitor the notify signal of something.
	(cb_dir_changed_notification) : delete.

	* dialog-paste-special.c (dialog_paste_special) : begin transition
	  from modal dialog by moving the calls to cmd_paste_to_selection here.

	* dialog-printer-setup.c : remove some deprecation.


2003-06-05  Jody Goldberg <jody@gnome.org>

	* src/plugin.c (gnumeric_extra_plugin_dirs) : clarify the ownership of
	  the lists.
	(plugins_init) : ditto.
	(plugins_shutdown) : ditto.

	* src/application.c (application_history_get_list) : const the output
	  to be clear on the ownership semantics.  Add a 'force_reload'
	  argument to force the list to reload and clip from the underlying
	  gconf source.  Should not be necessary later when we clear up the
	  relationship between application, and the config.
	(application_history_update_list) : deleted.
	(application_history_add) : new.  merge in some of the old
	  application_history_update_list, and some of the history_menu stuff
	  and emit a notifuy even on the newly created file_history_list
	  property of the application.  We should do the same for other
	  properties rather than requiring direct gconf connections.
	(application_history_list_shrink) : delete.
	(application_history_write_config) : delete.
	(gnumeric_application_get_property) : new.
	(gnumeric_application_class_init) : install the property.

	* src/workbook.c (workbook_finalize) : Just call
	  application_history_add directly rather than
	  workbook_history_update that was a pointless layer of indirection.
	  No need to directly call application_history_write_config
	  history_add handles that.

	* src/sheet-object-widget.c (sheet_widget_list_create_widget) : If
	  we're going to throw in a stub widget, it might as well a treeview
	  rather than a deprecated list widget.

	* src/workbook.c (workbook_history_update) : delete the vast majority
	  of this moving what little remained into.

	* src/history.c : delete everything but history_item_label.
	  greatly simplify the logic and move the majority of it into.
	* src/workbook-control-gui.c : here.  While we're at it simplify our
	  lives in preparation for turning the bonobo mess into virtuals on
	  wbcg.  Use a simpler approach to creation and removal that let
	    - monitors the application::notify::file-history-list rather than
	      requiring explicit calls from a non-gui layer.
	    - removes everything even the seperator then reinserts the new
	      entries.
	(wbcg_file_history_setup) : renamed from wbcg_history_setup.
	(change_menu_label) : Use gtk_label_set_text with use_underline
	  set to true in place of the deprecated parse_uline gunk.  While
	  we're in here set the tooltip too.  Its a hack, setting the data
	  directly based on knownledge of the implementation in libgnomeui.
	  However, there aren't many choices other than fixing libgnomeui
	  which is just too long a wait.
	(cb_edit_paste_special) : move call to cmd_paste_to_selection in to
	  the dialog like every other implemntation.
	(wbcg_finalize) :  Use g_signal_handlers_disconnect_by_func in place
	  of the deprecated gtk_signal_disconnect_by_func.
	(workbook_setup_sheets) : Use gtk_notebook_set_show_border (FALSE) in
	  place of the deprecated gtk_notebook_set_tab_border (0).
	(workbook_control_gui_init) : use allow_grow, and allow_shrink
	  properties in place of deprecated gtk_window_set_policy.  And
	  g_idle_add, in place of deprecated gtk_idle_add.

	* src/sheet-control-gui.c (context_menu_handler) :
	  dialog_paste_special now calls cmd_paste_to_selection itself
	  like all the other dialogs.

	* src/gutils.c (g_slist_map) : constify to make life easier.

	* src/gnumeric-pane.c : some minor property renaming in the custom
	  canvas-items when we removed the deprecated gunk.
	* src/item-bar.c : remove deprecated GtkArg gunk in favour of
	  GObject::Param stuff.
	* src/item-grid.c : ditto.

	* src/gnumeric-gconf.h : Make the public GSLists const just to be
	  absolutely clear about who owns what.

	* src/gnumeric-gconf.c (gnm_gconf_set_plugin_extra_dirs) : make list
	  ownership semantics absolutely clear.
	(gnm_gconf_set_plugin_extra_dirs) : ditto.
	(gnm_gconf_set_file_history_files) : ditto.
	(gnm_gconf_add_notification_plugin_directories) : delete unused.
	(gnm_gconf_set_autoformat_extra_dirs) : delete unused.

	* src/gnumeric-gconf-priv.h : no need to publicly include gconf anymore
parent 0878c77a
......@@ -19,6 +19,7 @@
#include "sheet-view.h"
#include "sheet-private.h"
#include "auto-correct.h"
#include "gutils.h"
#include "pixmaps/gnumeric-stock-pixbufs.h"
#include "gnm-marshalers.h"
......@@ -26,6 +27,10 @@
#include <gsf/gsf-impl-utils.h>
#include <gtk/gtk.h>
enum {
APPLICATION_PROP_0,
APPLICATION_PROP_FILE_HISTORY_LIST
};
/* Signals */
enum {
WORKBOOK_ADDED,
......@@ -54,8 +59,7 @@ struct _GnumericApplication {
GList *workbook_list;
};
typedef struct
{
typedef struct {
GObjectClass parent;
void (*workbook_added) (GnumericApplication *gnm_app, Workbook *wb);
......@@ -357,129 +361,89 @@ application_dpi_to_pixels (void)
/**
* application_history_get_list:
*
* This function returns a pointer to the history list,
* creating it if necessary.
*
* Return value: the list./
**/
GSList*
application_history_get_list (void)
GSList const *
application_history_get_list (gboolean force_reload)
{
gint max_entries;
/* If the list is already populated, return it. */
if (app->history_list)
return app->history_list;
max_entries = gnm_app_prefs->file_history_max;
app->history_list = gnm_app_prefs->file_history_files;
while (g_slist_length (app->history_list) > (guint)max_entries) {
GSList *last = g_slist_last (app->history_list);
g_free (last->data);
app->history_list = g_slist_delete_link (app->history_list,
last);
GSList const *ptr;
GSList *res = NULL;
if (app->history_list != NULL) {
if (force_reload) {
GSList *tmp = app->history_list;
app->history_list = NULL;
g_slist_free_custom (tmp, g_free);
} else
return app->history_list;
}
return app->history_list;
max_entries = gnm_app_prefs->file_history_max;
for (ptr = gnm_app_prefs->file_history_files;
ptr != NULL && max_entries-- > 0 ; ptr = ptr->next)
res = g_slist_prepend (res, g_strdup (ptr->data));
return app->history_list = g_slist_reverse (res);;
}
/**
* application_history_update_list:
* @filename:
*
* This function updates the history list. The return value is a
* pointer to the filename that was removed, if the list was already full
* or NULL if no items were removed.
*
* Return value:
* Adds @filename to the application's history of files.
**/
gchar *
application_history_update_list (const gchar *filename)
void
application_history_add (char const *filename)
{
gchar *name, *old_name = NULL;
GSList *l = NULL;
gint max_entries;
g_return_val_if_fail (filename != NULL, NULL);
/* Get maximum list length from config */
max_entries = gnm_app_prefs->file_history_max;
/* Shorten the list in case max_entries has changed. */
while (g_slist_length (app->history_list) > (guint) max_entries) {
GSList *last = g_slist_last (app->history_list);
g_free (last->data);
app->history_list = g_slist_delete_link (app->history_list,
last);
}
/* Check if this filename already exists in the list */
for (l = app->history_list; l ; l = l->next) {
if (!strcmp ((gchar *)l->data, filename)) {
old_name = (gchar *)l->data;
break;
char *canonical_name;
gint max_entries;
GSList *exists;
GSList **ptr;
g_return_if_fail (filename != NULL);
/* Rudimentary filename canonicalization. */
if (!g_path_is_absolute (filename)) {
char *cwd = g_get_current_dir ();
canonical_name = g_strconcat (cwd, "/", filename, NULL);
g_free (cwd);
} else
canonical_name = g_strdup (filename);
/* force a reload in case max_entries has changed */
application_history_get_list (TRUE);
exists = g_slist_find_custom (app->history_list,
canonical_name, g_str_compare);
if (exists != NULL) {
/* its already the top of the stack no need to do anything */
if (exists == app->history_list) {
g_free (canonical_name);
return;
}
/* remove the other instance */
g_free (exists->data);
app->history_list = g_slist_remove (app->history_list, exists->data);
}
/* Insert the new filename to the new list and free up the old list */
name = g_strdup (filename);
app->history_list = g_slist_prepend (app->history_list, name);
if (l)
app->history_list = g_slist_delete_link (app->history_list, l);
if (g_slist_length (app->history_list) > (guint)max_entries) {
GSList *last = g_slist_last (app->history_list);
old_name = (gchar *)last->data;
app->history_list = g_slist_delete_link (app->history_list,
last);
}
gnm_gconf_set_file_history_files (app->history_list);
gnm_conf_sync ();
return old_name;
}
/* Remove the last item from the history list and return it. */
gchar *
application_history_list_shrink (void)
{
gchar *name;
GSList *l;
if (app->history_list == NULL)
return NULL;
l = g_slist_last (app->history_list);
name = (gchar *)l->data;
app->history_list = g_slist_delete_link (app->history_list, l);
return name;
}
/* Write contents of the history list to the configuration file. */
void
application_history_write_config (void)
{
gint max_entries;
if (app->history_list == NULL) return;
app->history_list = g_slist_prepend (app->history_list, canonical_name);
/* clip the list if it is too long */
max_entries = gnm_app_prefs->file_history_max;
/* Shorten the list in case max_entries has changed. */
while (g_slist_length (app->history_list) > (guint) max_entries) {
GSList *last = g_slist_last (app->history_list);
g_free (last->data);
app->history_list = g_slist_delete_link (app->history_list,
last);
ptr = &(app->history_list);
while (*ptr != NULL && max_entries-- > 0)
ptr = &((*ptr)->next);
if (*ptr != NULL) {
g_slist_free_custom (*ptr, g_free);
*ptr = NULL;
}
gnm_gconf_set_file_history_files (app->history_list);
g_object_notify (G_OBJECT (app), "file_history_list");
gnm_gconf_set_file_history_files (
g_string_slist_copy (app->history_list));
gnm_conf_sync ();
g_slist_foreach (app->history_list, (GFunc)g_free, NULL);
g_slist_free (app->history_list);
app->history_list = NULL;
}
gboolean application_use_auto_complete (void) { return gnm_app_prefs->auto_complete; }
......@@ -623,12 +587,31 @@ gnumeric_application_finalize (GObject *object)
}
static void
gnumeric_application_class_init (GObjectClass *klass)
gnumeric_application_get_property (GObject *obj, guint param_id,
GValue *value, GParamSpec *pspec)
{
GnumericApplication *application = GNUMERIC_APPLICATION (obj);
switch (param_id) {
case APPLICATION_PROP_FILE_HISTORY_LIST:
g_value_set_pointer (value, application->history_list);
break;
default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
break;
}
}
static void
gnumeric_application_class_init (GObjectClass *gobject_klass)
{
parent_klass = g_type_class_peek_parent (klass);
parent_klass = g_type_class_peek_parent (gobject_klass);
/* Object class method overrides */
klass->finalize = gnumeric_application_finalize;
gobject_klass->finalize = gnumeric_application_finalize;
gobject_klass->get_property = gnumeric_application_get_property;
g_object_class_install_property (gobject_klass, APPLICATION_PROP_FILE_HISTORY_LIST,
g_param_spec_pointer ("file_history_list", "File History List",
"A GSlist of filenames that have been read recently",
G_PARAM_READABLE));
signals [WORKBOOK_ADDED] = g_signal_new ("workbook_added",
GNUMERIC_APPLICATION_TYPE,
......
......@@ -47,11 +47,8 @@ SheetView * application_clipboard_sheet_view_get (void);
CellRegion * application_clipboard_contents_get (void);
Range const* application_clipboard_area_get (void);
GSList * application_history_get_list (void);
gchar * application_history_update_list (const gchar *);
gchar * application_history_list_shrink (void);
void application_history_write_config (void);
GSList const*application_history_get_list (gboolean force_reload);
void application_history_add (char const *filename);
double application_display_dpi_get (gboolean horizontal);
double application_dpi_to_pixels (void);
......
......@@ -193,7 +193,8 @@ category_group_list_get (void)
dir_list = g_create_slist (gnm_app_prefs->autoformat.sys_dir,
gnm_app_prefs->autoformat.usr_dir,
NULL);
dir_list = g_slist_concat (dir_list, g_slist_copy (gnm_app_prefs->autoformat.extra_dirs));
dir_list = g_slist_concat (dir_list,
g_slist_copy ((GSList *)gnm_app_prefs->autoformat.extra_dirs));
categories = category_list_get_from_dir_list (dir_list);
categories = g_list_sort (categories, category_compare_orig_name_and_dir);
......
......@@ -81,6 +81,4 @@
#define GNUMERIC_GCONF_CUTANDPASTE_DIRECTORY "/apps/gnumeric/cut-and-paste"
#define GNUMERIC_GCONF_CUTANDPASTE_PREFER_CLIPBOARD GNUMERIC_GCONF_CUTANDPASTE_DIRECTORY "/prefer-clipboard"
#include <gconf/gconf-client.h>
#endif /* GNUMERIC_GRAPH_H */
#endif /* GNUMERIC_GCONF_PRIV_H */
......@@ -172,6 +172,14 @@ gnm_gconf_rm_notification (guint id)
void
gnm_gconf_set_plugin_file_states (GSList *list)
{
g_return_if_fail (prefs.plugin_file_states != list);
/* the const_casts are ok, the const in the header is just to keep
* people for doing stupid things */
g_slist_foreach ((GSList *)prefs.plugin_file_states, (GFunc)g_free, NULL);
g_slist_free ((GSList *)prefs.plugin_file_states);
prefs.plugin_file_states = list;
gconf_client_set_list (application_get_gconf_client (),
PLUGIN_GCONF_FILE_STATES,
GCONF_VALUE_STRING, list, NULL);
......@@ -180,18 +188,19 @@ gnm_gconf_set_plugin_file_states (GSList *list)
void
gnm_gconf_set_plugin_extra_dirs (GSList *list)
{
g_return_if_fail (prefs.plugin_extra_dirs != list);
/* the const_casts are ok, the const in the header is just to keep
* people for doing stupid things */
g_slist_foreach ((GSList *)prefs.plugin_extra_dirs, (GFunc)g_free, NULL);
g_slist_free ((GSList *)prefs.plugin_extra_dirs);
prefs.plugin_extra_dirs = list;
gconf_client_set_list (application_get_gconf_client (),
PLUGIN_GCONF_EXTRA_DIRS,
GCONF_VALUE_STRING, list, NULL);
}
guint
gnm_gconf_add_notification_plugin_directories (GConfClientNotifyFunc func, gpointer data)
{
return gconf_client_notify_add (application_get_gconf_client (), PLUGIN_GCONF_EXTRA_DIRS,
func, data, NULL, NULL);
}
void
gnm_gconf_set_active_plugins (GSList *list)
{
......@@ -276,6 +285,13 @@ gnm_gconf_set_file_history_max (gint val)
void
gnm_gconf_set_file_history_files (GSList *list)
{
g_return_if_fail (prefs.file_history_files != list);
/* the const_casts are ok, the const in the header is just to keep
* people for doing stupid things */
g_slist_foreach ((GSList *)prefs.file_history_files, (GFunc)g_free, NULL);
g_slist_free ((GSList *)prefs.file_history_files);
prefs.file_history_files = list;
gconf_client_set_list (application_get_gconf_client (),
GNUMERIC_GCONF_FILE_HISTORY_FILES,
GCONF_VALUE_STRING, list, NULL);
......@@ -326,14 +342,6 @@ gnm_gconf_set_undo_max_number (gint val)
val, NULL);
}
void
gnm_gconf_set_autoformat_extra_dirs (GSList *list)
{
gconf_client_set_list (application_get_gconf_client (),
AUTOFORMAT_GCONF_EXTRA_DIRS,
GCONF_VALUE_STRING, list, NULL);
}
void
gnm_gconf_set_autoformat_sys_dirs (char const * string)
{
......
#ifndef GNUMERIC_GCONF_H
#define GNUMERIC_GCONF_H
#include <gconf/gconf-client.h>
#include <numbers.h>
typedef struct {
struct {
GSList *extra_dirs;
GSList const *extra_dirs;
char *sys_dir;
char *usr_dir;
} autoformat;
gint file_history_max;
GSList *file_history_files;
GSList const *file_history_files;
guint num_of_recent_funcs;
GSList *recent_funcs;
GSList const *recent_funcs;
GSList *plugin_file_states;
GSList *plugin_extra_dirs;
GSList *active_plugins;
GSList const *plugin_file_states;
GSList const *plugin_extra_dirs;
GSList const *active_plugins;
gboolean activate_new_plugins;
gboolean show_sheet_name;
......@@ -59,16 +58,12 @@ void gnm_conf_sync (void);
guint gnm_gconf_rm_notification (guint id);
/* autocorrect */
guint gnm_gconf_add_notification_autocorrect (GConfClientNotifyFunc func);
void gnm_gconf_set_autocorrect_init_caps (gboolean val);
void gnm_gconf_set_autocorrect_first_letter (gboolean val);
void gnm_gconf_set_autocorrect_names_of_days (gboolean val);
void gnm_gconf_set_autocorrect_replace (gboolean val);
void gnm_gconf_set_autocorrect_init_caps_exceptions (GSList *list);
void gnm_gconf_set_autocorrect_first_letter_exceptions (GSList *list);
/* autoformat */
void gnm_gconf_set_autoformat_extra_dirs (GSList *list);
void gnm_gconf_set_autoformat_sys_dirs (char const * string);
void gnm_gconf_set_autoformat_usr_dirs (char const * string);
......@@ -77,7 +72,6 @@ void gnm_gconf_set_file_history_max (gint val);
void gnm_gconf_set_file_history_files (GSList *list);
/* plugins */
guint gnm_gconf_add_notification_plugin_directories (GConfClientNotifyFunc func, gpointer data);
void gnm_gconf_set_plugin_file_states (GSList *list);
void gnm_gconf_set_plugin_extra_dirs (GSList *list);
void gnm_gconf_set_active_plugins (GSList *list);
......
......@@ -47,8 +47,8 @@ gnumeric_pane_header_init (GnumericPane *pane, SheetControlGUI *scg,
FooCanvasGroup *group = FOO_CANVAS_GROUP (canvas->root);
FooCanvasItem *item = foo_canvas_item_new (group,
item_bar_get_type (),
"ItemBar::GnumericCanvas", pane->gcanvas,
"ItemBar::IsColHeader", is_col_header,
"GnumericCanvas", pane->gcanvas,
"IsColHeader", is_col_header,
NULL);
/* give a non-constraining default in case something scrolls before we
......@@ -103,7 +103,7 @@ gnm_pane_init (GnumericPane *pane, SheetControlGUI *scg,
gcanvas_group = FOO_CANVAS_GROUP (FOO_CANVAS (pane->gcanvas)->root);
item = foo_canvas_item_new (gcanvas_group,
item_grid_get_type (),
"ItemGrid::SheetControlGUI", scg,
"SheetControlGUI", scg,
NULL);
pane->grid = ITEM_GRID (item);
......@@ -193,7 +193,7 @@ gnm_pane_bound_set (GnumericPane *pane,
range_init (&r, start_col, start_row, end_col, end_row);
foo_canvas_item_set (FOO_CANVAS_ITEM (pane->grid),
"ItemGrid::Bound", &r,
"bound", &r,
NULL);
}
......
......@@ -166,7 +166,7 @@ g_list_free_custom (GList *list, GFreeFunc free_func)
* @map_func : mapping function
*/
GSList *
g_slist_map (GSList *list, GnmMapFunc map_func)
g_slist_map (GSList const *list, GnmMapFunc map_func)
{
GSList *list_copy = NULL;
......
......@@ -37,14 +37,14 @@ G_STMT_START { \
#define GNM_LIST_SORT(list,cmp_func) \
(list = g_list_sort (list, cmp_func))
GSList *g_slist_map (GSList *list, GnmMapFunc map_func);
GSList *g_slist_map (GSList const *list, GnmMapFunc map_func);
GSList *g_create_slist (gpointer item1, ...);
void g_slist_free_custom (GSList *list, GFreeFunc free_func);
#define g_string_slist_copy(list) g_slist_map (list, (GnmMapFunc) g_strdup)
GSList *g_strsplit_to_slist (const gchar *string, const gchar *delimiter);
#define GNM_SLIST_FOREACH(list,valtype,val,stmnt) \
G_STMT_START { \
GSList *gnm_l; \
GSList const *gnm_l; \
for (gnm_l = (list); gnm_l != NULL; gnm_l = gnm_l->next) { \
valtype *val = gnm_l->data; \
stmnt \
......
......@@ -10,51 +10,12 @@
#include "gnumeric.h"
#include "history.h"
#include "application.h"
#include "gui-file.h"
#include "workbook-control-gui-priv.h"
#include "workbook-view.h"
#include "workbook-priv.h"
#include <gtk/gtkmenuitem.h>
#include <libgnomeui/gnome-app-helper.h>
#ifdef WITH_BONOBO
#include <bonobo.h>
#endif
#include <string.h>
/* Command callback called on activation of a file history menu item. */
#ifndef WITH_BONOBO
#define UGLY_GNOME_UI_KEY "HistoryFilename"
static void
file_history_cmd (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
char *filename = g_object_get_data (G_OBJECT (widget), UGLY_GNOME_UI_KEY);
gui_file_read (wbcg, filename, NULL, NULL);
}
#else
static void
file_history_cmd (BonoboUIComponent *uic, WorkbookControlGUI *wbcg, const char *path)
{
char *fullpath = g_strconcat ("/menu/File/FileHistory/", path, NULL);
char *filename = bonobo_ui_component_get_prop (wbcg->uic, fullpath,
"tip", NULL);
gui_file_read (wbcg, filename, NULL, NULL);
g_free (filename);
g_free (fullpath);
}
#endif
/*
* Returns a newly allocated string containing the base name of the file
* with any .gnumeric extension stripped off.
*/
static gchar*
history_item_label (const gchar *name, const gint accel_number)
gchar *
history_item_label (gchar const *name, int accel_number)
{
int i;
char *label, *menuname, *tmp;
......@@ -76,281 +37,3 @@ history_item_label (const gchar *name, const gint accel_number)
return label;
}
/*
* Create a history menu item in a menu at a given position.
*/
#ifndef WITH_BONOBO
static void
history_menu_item_create (WorkbookControlGUI *wbcg, gchar *name, gint accel_number,
GtkWidget *menu, gint pos)
{
char *label;
GnomeUIInfo info[] = {
{ GNOME_APP_UI_ITEM, NULL, NULL, file_history_cmd, NULL },
GNOMEUIINFO_END
};
info [0].hint = name;
info [0].label = label = history_item_label (name, accel_number);
info [0].user_data = wbcg;
gnome_app_fill_menu (GTK_MENU_SHELL (menu), info,
GNOME_APP (wbcg->toplevel)->accel_group, TRUE,
pos);
g_object_set_data (G_OBJECT (info[0].widget), UGLY_GNOME_UI_KEY, name);
gnome_app_install_menu_hints (GNOME_APP (wbcg->toplevel), info);
g_free (label);
}
#endif
#ifndef WITH_BONOBO
typedef struct {
GtkWidget *menu;
gint pos;
} MenuPos;
/*
* Locate the menu and position of history separator. They may not yet exist.
*
* NOTE:
* gnome_app_find_menu_pos returns the position *after* the menu item given.
* bonobo_ui_handler_menu_get_pos returns the position *of* the menu item.
*/
static void
history_menu_locate_separator (WorkbookControlGUI *wbcg, MenuPos *res)
{
/*
* xgettext:
* This string must translate to exactly the same strings as the
* 'Preferences...' item in the
* 'File' menu
*/
char const *menu_name = _("_File/Preferen_ces...");
res->menu = gnome_app_find_menu_pos (GNOME_APP (wbcg->toplevel)->menubar,
menu_name, &res->pos);
if (res->menu == NULL)
g_warning ("Probable mis-translation. '%s' : was not found. "
"Does this match the '_File/Preferen_ces...' menu exactly ?",
menu_name);
}
/* Insert the history separator. Return its position. */
static void
history_menu_insert_separator (WorkbookControlGUI *wbcg, MenuPos *res)
{
GtkWidget *item;
history_menu_locate_separator (wbcg, res);
if (res->menu != NULL) {
item = gtk_menu_item_new ();
gtk_widget_show (item);
gtk_menu_shell_insert (GTK_MENU_SHELL (res->menu), item, res->pos);
gtk_widget_set_sensitive(item, FALSE);
}
}
/*
* Add the history items list to the file menu for the workbook specified.
*/
static void
history_menu_insert_items (WorkbookControlGUI *wbcg, GSList *name_list, MenuPos *mp)
{
gint accel_number;
GSList *l;
g_return_if_fail (name_list != NULL);
/* Add a new menu item for each item in the history list */
accel_number = 1;
for (l = name_list; l; l = l->next)
history_menu_item_create (wbcg, (gchar *)l->data, accel_number++,
mp->menu, (mp->pos)++);
}
#else
static void
history_menu_insert_items (WorkbookControlGUI *wbcg, GSList *name_list)
{
CORBA_Environment ev;
gint accel_number;
GSList *l;
g_return_if_fail (name_list != NULL);
CORBA_exception_init (&ev);
/* Add a new menu item for each item in the history list */
accel_number = 1;
bonobo_ui_component_freeze (wbcg->uic, &ev);
for (l = name_list; l; l = l->next) {
char *id, *str, *label, *filename;
id = g_strdup_printf ("FileHistory%d", accel_number);
str = history_item_label (l->data, accel_number);
label = bonobo_ui_util_encode_str (str);
g_free (str);
filename = bonobo_ui_util_encode_str ((char *) l->data);
str = g_strdup_printf ("<menuitem name=\"%s\" "
"verb=\"%s\" "
"label=\"%s\" "
"tip=\"%s\"/>\n",
id, id, label, filename);
bonobo_ui_component_set (wbcg->uic,
"/menu/File/FileHistory", str, &ev);
bonobo_ui_component_add_verb (
wbcg->uic, id, (BonoboUIVerbFn) file_history_cmd, wbcg);
g_free (id);
g_free (str);
g_free (filename);
g_free (label);
accel_number++;
}
bonobo_ui_component_thaw (wbcg->uic, &ev);
CORBA_exception_free (&ev);
}
#endif
#ifndef WITH_BONOBO
/*
* Remove the history list items from the file menu of the workbook
* specified.
*/
static void
history_menu_remove_items (WorkbookControlGUI *wbcg, GSList *name_list)
{
gint accel_number = 1;
if (name_list) {
char *label, *path;
label = history_item_label ((gchar *)name_list->data, accel_number);
path = g_strconcat (_("File/"), label, NULL);
gnome_app_remove_menus (GNOME_APP (wbcg->toplevel), path,
g_slist_length (name_list));
g_free (label);
g_free (path);
}
}
#else
/*
* Remove the history list items from the file menu of the workbook
* specified.
*/
static void
history_menu_remove_items (WorkbookControlGUI *wbcg, GSList *name_list)
{
gint accel_number = 1;
GSList *l;
CORBA_Environment ev;
CORBA_exception_init (&ev);
bonobo_ui_component_freeze (wbcg->uic, &ev);
for (l = name_list; l; l = l->next) {
#warning "FIXME: this doesn't even look at ->data"
char *path;
path = g_strdup_printf ("/menu/File/FileHistory/FileHistory%d",
accel_number++);
bonobo_ui_component_rm (wbcg->uic, path, &ev);
g_free (path);
}
bonobo_ui_component_thaw (wbcg->uic, &ev);
CORBA_exception_free (&ev);
}
#endif
/*
* Remove the history list items from the file menus of all workbooks.
*
* All changes require that the list is removed and a new one built, because we
* add a digit in front of the file name.
*/
void
history_menu_flush (GList *wl, GSList *name_list)
{
GList *l;
/* Update the menus in all open workbooks */
for (l = wl; l; l = g_list_next (l)) {
Workbook *wb = WORKBOOK (l->data);
WORKBOOK_FOREACH_CONTROL (wb, view, control, {