Commit 12939a6d authored by Jody Goldberg's avatar Jody Goldberg

Just in case

parent 6093fca1
This diff is collapsed.
......@@ -13,9 +13,11 @@
typedef struct _WorkbookControlGUI WorkbookControlGUI;
GtkType workbook_control_gui_get_type (void);
WorkbookControl *workbook_control_gui_new (WorkbookView *);
WorkbookControl *workbook_control_gui_new (WorkbookView *optional_view,
Workbook *optional_wb);
void workbook_control_gui_init (WorkbookControlGUI *wbcg,
WorkbookView *optional_view);
WorkbookView *optional_view,
Workbook *optional_wb);
GtkWindow *wb_control_gui_toplevel (WorkbookControlGUI *wbcg);
Sheet * wb_control_gui_focus_cur_sheet (WorkbookControlGUI *wbcg);
......@@ -23,6 +23,7 @@
#include <config.h>
#include "workbook-control.h"
#include "workbook-view.h"
#include "workbook.h"
#include "gnumeric-type-util.h"
#include "parse-util.h"
#include "sheet.h"
......@@ -43,6 +44,19 @@ void wb_control_ ## func arglist \
#define WBC_VIRTUAL(func, arglist, call) WBC_VIRTUAL_FULL(func, func, arglist, call)
WorkbookControl *
wb_control_wrapper_new (WorkbookControl *wbc, WorkbookView *wbv, Workbook *wb)
WorkbookControlClass *wbc_class;
g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), NULL);
wbc_class = WBC_CLASS (wbc);
if (wbc_class != NULL && wbc_class->control_new != NULL)
return wbc_class->control_new (wbc, wbv, wb);
return NULL;
WBC_VIRTUAL (title_set,
(WorkbookControl *wbc, char const * title), (wbc, title))
WBC_VIRTUAL (size_pixels_set,
......@@ -53,20 +67,23 @@ WBC_VIRTUAL (progress_set,
(WorkbookControl *wbc, gfloat val), (wbc, val))
WBC_VIRTUAL (format_feedback,
(WorkbookControl *wbc, MStyle *style), (wbc, style))
WBC_VIRTUAL (zoom_feedback,
(WorkbookControl *wbc), (wbc))
WBC_VIRTUAL (edit_line_set,
(WorkbookControl *wbc, char const *text), (wbc, text))
WBC_VIRTUAL (auto_expr_value,
(WorkbookControl *wbc, char const *value), (wbc, value))
WBC_VIRTUAL_FULL (sheet_add, sheet.add,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_remove, sheet.remove,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (auto_expr_name,,
(WorkbookControl *wbc, char const *name), (wbc, name))
WBC_VIRTUAL_FULL (auto_expr_value, auto_expr.value,
(WorkbookControl *wbc, char const *value), (wbc, value))
WBC_VIRTUAL_FULL (sheet_rename, sheet.rename,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_focus, sheet.focus,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_move, sheet.move,
(WorkbookControl *wbc, Sheet *sheet, int dir), (wbc, sheet, dir))
WBC_VIRTUAL_FULL (undo_redo_clear, undo_redo.clear,
(WorkbookControl *wbc, gboolean is_undo), (wbc, is_undo))
......@@ -97,12 +114,70 @@ WBC_VIRTUAL_FULL (invalid_err, error.invalid,
(WorkbookControl *wbc, char const *msg, char const *val),
(wbc, msg, val))
* wb_control_push_err_template
* @str: printf template to display message
* Push a printf template to the stack. The template is used to provide
* context for error messages. E.g.: "Could not read file: %s"
wb_control_push_err_template (WorkbookControl *wbc, const char *str)
wbc->template_list = g_slist_prepend (wbc->template_list,
g_strdup (str));
* wb_control_pop_err_template:
* Call this routine to remove the current template from the stack.
wb_control_pop_err_template (WorkbookControl *wbc)
if (wbc->template_list) {
GSList *tlist = wbc->template_list;
g_free (wbc->template_list->data);
wbc->template_list = wbc->template_list->next;
* format_message:
* Format a message using the template on the stack (if any).
* The caller must free the returned message.
* FIXME: Make it accept varargs.
static char *
format_message (WorkbookControl *context, char const *message)
#warning Use this
GSList *tlist = context->template_list;
char const * const msg = message ? message : "";
if (tlist)
return g_strdup_printf ((char *) (tlist->data), msg);
return g_strdup (msg);
wb_control_splits_array (WorkbookControl *wbc, char const *cmd)
wb_control_splits_array_err (WorkbookControl *wbc, char const *cmd)
wb_control_invalid_err (wbc, cmd, _("Would split an array."));
WorkbookView *
wb_control_view (WorkbookControl *wbc)
g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), NULL);
return wbc->wb_view;
Workbook *
wb_control_workbook (WorkbookControl *wbc)
......@@ -133,21 +208,50 @@ workbook_parse_and_jump (WorkbookControl *wbc, const char *text)
return TRUE;
gnumeric_invalid_err (wbc, _("Address"), text);
wb_control_invalid_err (wbc, _("Address"), text);
return FALSE;
static GtkObjectClass *parent_class;
static void
wbc_destroy (GtkObject *obj)
WorkbookControl *wbc = WORKBOOK_CONTROL (obj);
wb_view_detach_control (wbc);
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
static void
workbook_control_ctor_class (GtkObjectClass *object_class)
parent_class = gtk_type_class (gtk_object_get_type ());
object_class->destroy = wbc_destroy;
GNUMERIC_MAKE_TYPE(workbook_control, "WorkbookControl", WorkbookControl,
NULL, NULL, gtk_object_get_type ())
workbook_control_ctor_class, NULL, gtk_object_get_type ())
workbook_control_init (WorkbookControl *wbc, WorkbookView *optional_view)
workbook_control_init (WorkbookControl *wbc,
WorkbookView *optional_view, Workbook *optional_wb)
g_return_if_fail (IS_WORKBOOK_CONTROL (wbc));
g_return_if_fail (wbc->wb_view == NULL);
wbc->wb_view = (optional_view != NULL) ? optional_view : workbook_view_new (NULL);
wbc->sheet_controls = g_ptr_array_new ();
wbc->wb_view = (optional_view != NULL) ? optional_view : workbook_view_new (optional_wb);
wb_view_attach_control (wbc);
workbook_control_sheets_init (WorkbookControl *wbc)
GList *sheets, *ptr;
/* Add views all all existing sheets */
sheets = workbook_sheets (wb_control_workbook (wbc));
for (ptr = sheets; ptr != NULL ; ptr = ptr->next)
wb_control_sheet_add (wbc, ptr->data);
g_list_free (sheets);
......@@ -8,11 +8,14 @@ struct _WorkbookControl {
GtkObject gtk_object;
WorkbookView *wb_view;
GPtrArray *sheet_controls; /* FIXME : these are views for now */
GSList *template_list;
typedef struct {
GtkObjectClass gtk_object_class;
/* Create a new control of the same form */
WorkbookControl *(*control_new) (WorkbookControl *wbc, WorkbookView *wbv, Workbook *wb);
/* Actions on the workbook UI */
void (*title_set) (WorkbookControl *wbc, char const *title);
void (*size_pixels_set) (WorkbookControl *wbc, int width, int height);
......@@ -21,14 +24,14 @@ typedef struct {
void (*format_feedback) (WorkbookControl *wbc, MStyle *style);
void (*zoom_feedback) (WorkbookControl *wbc);
void (*edit_line_set) (WorkbookControl *wbc, char const *text);
void (*auto_expr_value) (WorkbookControl *wbc, char const *value);
struct {
void (*add) (WorkbookControl *wbc, Sheet *sheet);
void (*remove) (WorkbookControl *wbc, Sheet *sheet);
void (*rename) (WorkbookControl *wbc, Sheet *sheet);
void (*focus) (WorkbookControl *wbc, Sheet *sheet);
void (*move) (WorkbookControl *wbc, Sheet *sheet, int dir);
} sheet;
struct {
void (*name) (WorkbookControl *wbc, char const *name);
void (*value) (WorkbookControl *wbc, char const *value);
} auto_expr;
struct {
void (*clear) (WorkbookControl *wbc, gboolean is_undo);
void (*pop) (WorkbookControl *wbc, gboolean is_undo);
......@@ -59,7 +62,13 @@ typedef struct {
GtkType workbook_control_get_type (void);
void workbook_control_init (WorkbookControl *wbc,
WorkbookView *optional_view);
WorkbookView *optional_view,
Workbook *optional_wb);
void workbook_control_sheets_init (WorkbookControl *wbc);
/* Create a new control of the same form */
WorkbookControl *wb_control_wrapper_new (WorkbookControl *wbc,
WorkbookView *wbv, Workbook *wb);
void wb_control_title_set (WorkbookControl *wbc, char const *title);
void wb_control_size_pixels_set (WorkbookControl *wbc, int w, int h);
......@@ -67,10 +76,13 @@ void wb_control_prefs_update (WorkbookControl *wbc);
void wb_control_format_feedback (WorkbookControl *wbc, MStyle *style);
void wb_control_zoom_feedback (WorkbookControl *wbc);
void wb_control_edit_line_set (WorkbookControl *wbc, char const *text);
void wb_control_sheet_add (WorkbookControl *wbc, Sheet *sheet);
void wb_control_sheet_remove (WorkbookControl *wbc, Sheet *sheet);
void wb_control_sheet_rename (WorkbookControl *wbc, Sheet *sheet);
void wb_control_sheet_focus (WorkbookControl *wbc, Sheet *sheet);
void wb_control_sheet_move (WorkbookControl *wbc, Sheet *sheet, int dir);
void wb_control_auto_expr_name (WorkbookControl *wbc, char const *name);
void wb_control_auto_expr_value (WorkbookControl *wbc, char const *value);
void wb_control_undo_redo_clear (WorkbookControl *wbc, gboolean is_undo);
......@@ -88,22 +100,20 @@ void wb_control_paste_from_selection (WorkbookControl *wbc,
* NOTE : The selection is quite limited by IDL's intentional non-support for
* inheritance (single or multiple).
void gnumeric_system_err (WorkbookControl *wbc, char const *msg);
void gnumeric_plugin_err (WorkbookControl *wbc, char const *msg);
void gnumeric_read_err (WorkbookControl *wbc, char const *msg);
void gnumeric_save_err (WorkbookControl *wbc, char const *msg);
void gnumeric_splits_array_err (WorkbookControl *wbc, char const *cmd);
void gnumeric_invalid_err (WorkbookControl *wbc, char const *msg,
char const *val);
WorkbookView *wb_control_workbook_view (WorkbookControl *wbc);
void wb_control_system_err (WorkbookControl *wbc, char const *msg);
void wb_control_plugin_err (WorkbookControl *wbc, char const *msg);
void wb_control_read_err (WorkbookControl *wbc, char const *msg);
void wb_control_save_err (WorkbookControl *wbc, char const *msg);
void wb_control_splits_array_err (WorkbookControl *wbc, char const *cmd);
void wb_control_invalid_err (WorkbookControl *wbc, char const *msg,
char const *val);
void wb_control_push_err_template (WorkbookControl *wbc, const char *str);
void wb_control_pop_err_template (WorkbookControl *wbc);
WorkbookView *wb_control_view (WorkbookControl *wbc);
Workbook *wb_control_workbook (WorkbookControl *wbc);
Sheet *wb_control_cur_sheet (WorkbookControl *wbc);
/* TODO */
gboolean workbook_parse_and_jump (WorkbookControl *wb, const char *text);
void wb_control_history_setup (WorkbookControl *wbc);
void wb_control_history_update (GList *wl, gchar *filename);
void wb_control_history_shrink (GList *wl, gint new_max);
gboolean workbook_parse_and_jump (WorkbookControl *wbc, const char *text);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment