Commit 62954f98 authored by Arturo Espinosa's avatar Arturo Espinosa

Stuff for today

parent 46e3e660
......@@ -23,7 +23,7 @@ typedef struct {
} v;
} Value;
typedef {
typedef struct {
int ref_count;
GdkColor color;
} CellColor;
......
......@@ -11,9 +11,15 @@ enum {
GNUMERIC_SHEET_LAST_SIGNAL
};
enum {
ITEM_SHEET_LAST_SIGNAL
};
static guint sheet_signals [GNUMERIC_SHEET_LAST_SIGNAL] = { 0 };
static guint item_signals [ITEM_SHEET_LAST_SIGNAL] = { 0 };
static GnomeCanvasClass *sheet_parent_class;
static GtkObjectClass *item_parent_class;
static void
gnumeric_sheet_destroy (GtkObject *object)
......@@ -21,11 +27,50 @@ gnumeric_sheet_destroy (GtkObject *object)
GnumericSheet *gsheet;
/* Add shutdown code here */
gsheet = GNUMERIC_SHEET (object);
if (GTK_OBJECT_CLASS (sheet_parent_class)->destroy)
(*GTK_OBJECT_CLASS (sheet_parent_class)->destroy)(object);
}
GtkWidget *
gnumeric_sheet_new (Sheet *sheet)
{
GnumericSheet *gsheet;
GnomeCanvas *canvas;
gsheet = gtk_type_new (gnumeric_sheet_get_type ());
canvas = GNOME_CANVAS (gsheet);
canvas->visual = gtk_widget_get_default_visual ();
canvas->colormap = gtk_widget_get_default_colormap ();
canvas->cc = gdk_color_context_new (canvas->visual, canvas->colormap);
canvas->root = gnome_canvas_group_new (canvas);
gsheet->sheet = sheet;
gsheet->top_col = 0;
gsheet->top_row = 0;
return GTK_WIDGET (gsheet);
}
static void
gnumeric_sheet_class_init (GnumericSheetClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GnomeCanvasClass *canvas_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
canvas_class = (GnomeCanvasClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
}
GtkType
gnumeric_sheet_get_type (void)
{
......@@ -43,24 +88,9 @@ gnumeric_sheet_get_type (void)
(GtkClassInitFunc) NULL
};
gnumeric_sheet_type = gtk_type_unique (gtk_object_get_type (), &gnumeric_sheet_info);
gnumeric_sheet_type = gtk_type_unique (gnome_canvas_get_type (), &gnumeric_sheet_info);
}
return gnumeric_sheet_type;
}
static void
gnumeric_sheet_class_init (GnumericSheetClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GnomeCanvasClass *canvas_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
}
......@@ -3,7 +3,7 @@
#define GNUMERIC_TYPE_SHEET (gnumeric_sheet_get_type ())
#define GNUMERIC_SHEET(obj) (GTK_CHECK_CAST((obj), GNUMERIC_TYPE_SHEET, GnumericSheet))
#define GNUMERIC_SHEET_CLASS(k) (GTK_CHECK_CLASS_CAST (k), GNUMERIC_TYPE_SHEET)
#define GNUMERIC_SHEET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), GNUMERIC_TYPE_SHEET))
#define GNUMERIC_IS_SHEET(o) (GTK_CHECK_TYPE((o), GNUMERIC_TYPE_SHEET))
typedef struct {
......@@ -19,7 +19,7 @@ typedef struct {
GtkType gnumeric_sheet_get_type (void);
GnumericSheet *gnumeric_sheet_new (Sheet *sheet);
GtkWidget *gnumeric_sheet_new (Sheet *sheet);
typedef struct {
GnomeCanvasClass parent_class;
......
......@@ -11,9 +11,15 @@ enum {
GNUMERIC_SHEET_LAST_SIGNAL
};
enum {
ITEM_SHEET_LAST_SIGNAL
};
static guint sheet_signals [GNUMERIC_SHEET_LAST_SIGNAL] = { 0 };
static guint item_signals [ITEM_SHEET_LAST_SIGNAL] = { 0 };
static GnomeCanvasClass *sheet_parent_class;
static GtkObjectClass *item_parent_class;
static void
gnumeric_sheet_destroy (GtkObject *object)
......@@ -21,11 +27,50 @@ gnumeric_sheet_destroy (GtkObject *object)
GnumericSheet *gsheet;
/* Add shutdown code here */
gsheet = GNUMERIC_SHEET (object);
if (GTK_OBJECT_CLASS (sheet_parent_class)->destroy)
(*GTK_OBJECT_CLASS (sheet_parent_class)->destroy)(object);
}
GtkWidget *
gnumeric_sheet_new (Sheet *sheet)
{
GnumericSheet *gsheet;
GnomeCanvas *canvas;
gsheet = gtk_type_new (gnumeric_sheet_get_type ());
canvas = GNOME_CANVAS (gsheet);
canvas->visual = gtk_widget_get_default_visual ();
canvas->colormap = gtk_widget_get_default_colormap ();
canvas->cc = gdk_color_context_new (canvas->visual, canvas->colormap);
canvas->root = gnome_canvas_group_new (canvas);
gsheet->sheet = sheet;
gsheet->top_col = 0;
gsheet->top_row = 0;
return GTK_WIDGET (gsheet);
}
static void
gnumeric_sheet_class_init (GnumericSheetClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GnomeCanvasClass *canvas_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
canvas_class = (GnomeCanvasClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
}
GtkType
gnumeric_sheet_get_type (void)
{
......@@ -43,24 +88,9 @@ gnumeric_sheet_get_type (void)
(GtkClassInitFunc) NULL
};
gnumeric_sheet_type = gtk_type_unique (gtk_object_get_type (), &gnumeric_sheet_info);
gnumeric_sheet_type = gtk_type_unique (gnome_canvas_get_type (), &gnumeric_sheet_info);
}
return gnumeric_sheet_type;
}
static void
gnumeric_sheet_class_init (GnumericSheetClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GnomeCanvasClass *canvas_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
}
......@@ -3,7 +3,7 @@
#define GNUMERIC_TYPE_SHEET (gnumeric_sheet_get_type ())
#define GNUMERIC_SHEET(obj) (GTK_CHECK_CAST((obj), GNUMERIC_TYPE_SHEET, GnumericSheet))
#define GNUMERIC_SHEET_CLASS(k) (GTK_CHECK_CLASS_CAST (k), GNUMERIC_TYPE_SHEET)
#define GNUMERIC_SHEET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), GNUMERIC_TYPE_SHEET))
#define GNUMERIC_IS_SHEET(o) (GTK_CHECK_TYPE((o), GNUMERIC_TYPE_SHEET))
typedef struct {
......@@ -19,7 +19,7 @@ typedef struct {
GtkType gnumeric_sheet_get_type (void);
GnumericSheet *gnumeric_sheet_new (Sheet *sheet);
GtkWidget *gnumeric_sheet_new (Sheet *sheet);
typedef struct {
GnomeCanvasClass parent_class;
......
#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
Sheet *
sheet_new (Workbook *wb, char *name)
{
Sheet *sheet;
sheet = g_new0 (Sheet, 1);
sheet->parent_workbook = wb;
sheet->name = g_strdup (name);
sheet->sheet_view = gnumeric_sheet_new (sheet);
gtk_widget_show (sheet->sheet_view);
return sheet;
}
#ifndef GNUMERIC_SHEET_H
#define GNUMERIC_SHEET_H
#ifndef SHEET_H
#define SHEET_H
typedef GList ColStyleList;
......@@ -18,7 +18,16 @@ typedef struct {
} ColInfo;
typedef struct {
struct Workbook *parent_workbook;
GtkWidget *toplevel;
GtkWidget *notebook;
Style style;
GHashTable *sheets; /* keeps a list of the Sheets on this workbook */
} Workbook;
typedef struct {
Workbook *parent_workbook;
GtkWidget *sheet_view;
char *name;
Style style;
......@@ -27,8 +36,10 @@ typedef struct {
void *contents;
} Sheet;
typedef struct {
Style style;
GHashTable *sheets; /* keeps a list of the sheets on this workbook */
} Workbook;
Sheet *sheet_new (Workbook *wb, char *name);
Workbook *workbook_new (void);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_attach_sheet (Workbook *, Sheet *);
#endif
#include <gnome.h>
#include "gnumeric.h"
static void
quit_cmd (void)
{
gtk_main_quit ();
}
static GnomeUIInfo workbook_menu_file [] = {
{ GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
GNOMEUIINFO_END
};
static GnomeUIInfo workbook_menu [] = {
{ GNOME_APP_UI_SUBTREE, N_("File"), NULL, &workbook_menu_file },
GNOMEUIINFO_END
};
/*
* Sets up the workbook.
* Right now it is adding some decorations to the window,
* this is for testing purposes.
*/
Workbook *
workbook_new (void)
{
Workbook *wb;
wb = g_new0 (Workbook, 1);
wb->toplevel = gnome_app_new ("Gnumeric", "Gnumeric");
wb->sheets = g_hash_table_new (g_str_hash, g_str_equal);
wb->notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (wb->notebook), GTK_POS_BOTTOM);
gnome_app_set_contents (GNOME_APP (wb->toplevel), wb->notebook);
gnome_app_create_menus (GNOME_APP (wb->toplevel), workbook_menu);
gtk_widget_show (wb->notebook);
return wb;
}
void
workbook_attach_sheet (Workbook *wb, Sheet *sheet)
{
g_hash_table_insert (wb->sheets, sheet->name, sheet);
gtk_notebook_append_page (GTK_NOTEBOOK (wb->notebook),
sheet->sheet_view,
gtk_label_new (sheet->name));
}
Workbook *
workbook_new_with_sheets (int sheet_count)
{
Workbook *wb;
int i;
wb = workbook_new ();
for (i = 0; i < sheet_count; i++){
Sheet *sheet;
char name [80];
snprintf (name, sizeof (name), "Sheet %d", i);
sheet = sheet_new (wb, name);
workbook_attach_sheet (wb, sheet);
}
return wb;
}
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