workbook-object-toolbar.c 6.12 KB
Newer Older
1 2 3 4 5
/* vim: set sw=8: */

/*
 * workbook-object-toolbar.c: Toolbar for adding objects
 *
Jody Goldberg's avatar
Jody Goldberg committed
6
 * Copyright (C) 2000 Jody Goldberg (jody@gnome.org)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
23 24 25 26
#include <gnumeric-config.h>
#include "gnumeric.h"
#include "workbook-object-toolbar.h"

27
#include "sheet.h"
28
#include "sheet-control-gui.h"
29
#include "workbook-control-gui-priv.h"
30 31 32
#include "workbook.h"
#include "sheet-object-widget.h"
#include "sheet-object-graphic.h"
33
#include "gui-util.h"
34

35
#ifdef WITH_BONOBO
36 37
#include <bonobo.h>
#endif
38
#include <libgnome/gnome-i18n.h>
39

40
static void
41
create_object_command (WorkbookControlGUI *wbcg, SheetObject *so)
42
{
43
	SheetControlGUI *scg = wbcg_cur_scg (wbcg);
44 45
	Sheet *sheet = sc_sheet (SHEET_CONTROL (scg));

46
	scg_mode_create_object (scg, so);
47 48
	workbook_recalc (sheet->workbook);
	sheet_update (sheet);
49 50
}

51
static void
52
cmd_create_label (GtkWidget *ignored, WorkbookControlGUI *wbcg)
53
{
54 55
	create_object_command (wbcg,
		g_object_new (sheet_widget_label_get_type(), NULL));
56 57
}
static void
58
cmd_create_frame (GtkWidget *ignored, WorkbookControlGUI *wbcg)
59
{
60 61
	create_object_command (wbcg,
		g_object_new (sheet_widget_frame_get_type(), NULL));
62 63
}

Jody Goldberg's avatar
Jody Goldberg committed
64
#if 0
65
	/* not useful until we have scripts */
66
static void
67
cmd_create_button (GtkWidget *widget, WorkbookControlGUI *wbcg)
68
{
69 70
	create_object_command (wbcg,
		g_object_new (sheet_widget_button_get_type(), NULL));
71
}
72
#endif
73
static void
Jody Goldberg's avatar
Jody Goldberg committed
74 75
cmd_create_scrollbar (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
76 77
	create_object_command (wbcg,
		g_object_new (sheet_widget_scrollbar_get_type(), NULL));
Jody Goldberg's avatar
Jody Goldberg committed
78 79
}
static void
80
cmd_create_checkbox (GtkWidget *widget, WorkbookControlGUI *wbcg)
81
{
82 83
	create_object_command (wbcg,
		g_object_new (sheet_widget_checkbox_get_type(), NULL));
84
}
85
#if 0
86
static void
87
cmd_create_radiobutton (GtkWidget *widget, WorkbookControlGUI *wbcg)
88
{
89 90
	create_object_command (wbcg,
		g_object_new (sheet_widget_radiobutton_get_type(), NULL));
91
}
92
#endif
93
static void
94
cmd_create_list (GtkWidget *widget, WorkbookControlGUI *wbcg)
95
{
96 97
	create_object_command (wbcg,
		g_object_new (sheet_widget_list_get_type(), NULL));
98 99
}
static void
100
cmd_create_combo (GtkWidget *widget, WorkbookControlGUI *wbcg)
101
{
102 103
	create_object_command (wbcg,
		g_object_new (sheet_widget_combo_get_type(), NULL));
104 105 106
}

static void
107
cmd_create_line (GtkWidget *widget, WorkbookControlGUI *wbcg)
108
{
109
	create_object_command (wbcg, sheet_object_line_new (FALSE));
110 111
}
static void
112
cmd_create_arrow (GtkWidget *widget, WorkbookControlGUI *wbcg)
113
{
114
	create_object_command (wbcg, sheet_object_line_new (TRUE));
115 116
}
static void
117
cmd_create_rectangle (GtkWidget *widget, WorkbookControlGUI *wbcg)
118
{
119
	create_object_command (wbcg, sheet_object_box_new (FALSE));
120 121
}
static void
122
cmd_create_ellipse (GtkWidget *widget, WorkbookControlGUI *wbcg)
123
{
124
	create_object_command (wbcg, sheet_object_box_new (TRUE));
125 126
}

127
#ifndef WITH_BONOBO
128
static GnomeUIInfo workbook_object_toolbar [] = {
129
	GNOMEUIINFO_ITEM_STOCK (
130
		N_("Label"), N_("Creates a label"),
131
		&cmd_create_label, "Gnumeric_ObjectLabel"),
132
	GNOMEUIINFO_ITEM_STOCK (
133
		N_("Frame"), N_("Creates a frame"),
134
		&cmd_create_frame, "Gnumeric_ObjectFrame"),
135 136
#if 0
	/* not useful until we have scripts */
137
	GNOMEUIINFO_ITEM_STOCK (
138
		N_("Button"), N_("Creates a button"),
139
		&cmd_create_button, "Gnumeric_ObjectButton"),
140
#endif
Jody Goldberg's avatar
Jody Goldberg committed
141 142
	GNOMEUIINFO_ITEM_STOCK (
		N_("Scrollbar"), N_("Creates a scrollbar"),
143
		&cmd_create_scrollbar, "Gnumeric_ObjectScrollbar"),
144
	GNOMEUIINFO_ITEM_STOCK (
145
		N_("Checkbox"), N_("Creates a checkbox"),
146
		&cmd_create_checkbox, "Gnumeric_ObjectCheckbox"),
147 148
#if 0
	/* need to think about how to manage groups */
149
	GNOMEUIINFO_ITEM_STOCK (
150
		N_("RadioButton"), N_("Creates a radio button"),
151
		&cmd_create_radiobutton, "Gnumeric_ObjectRadiobutton"),
152
#endif
153
	GNOMEUIINFO_ITEM_STOCK (
154
		N_("List"), N_("Creates a list"),
155
		&cmd_create_list, "Gnumeric_ObjectList"),
156
	GNOMEUIINFO_ITEM_STOCK (
157
		N_("Combo"), N_("Creates a combo box"),
158
		&cmd_create_combo, "Gnumeric_ObjectCombo"),
159
	GNOMEUIINFO_ITEM_STOCK (
160
		N_("Line"), N_("Creates a line object"),
161
		cmd_create_line, "Gnumeric_ObjectLine"),
162
	GNOMEUIINFO_ITEM_STOCK (
163
		N_("Arrow"), N_("Creates an arrow object"),
164
		cmd_create_arrow, "Gnumeric_ObjectArrow"),
165
	GNOMEUIINFO_ITEM_STOCK (
166
		N_("Rectangle"), N_("Creates a rectangle object"),
167
		cmd_create_rectangle, "Gnumeric_ObjectRectangle"),
168
	GNOMEUIINFO_ITEM_STOCK (
169
		N_("Ellipse"), N_("Creates an ellipse object"),
170
		cmd_create_ellipse, "Gnumeric_ObjectEllipse"),
171 172 173 174

	GNOMEUIINFO_END
};

175 176
void
workbook_create_object_toolbar (WorkbookControlGUI *wbcg)
177
{
178 179 180
	wbcg->object_toolbar = gnumeric_toolbar_new (wbcg,
		workbook_object_toolbar, "ObjectToolbar", 3, 0, 0);
	gtk_widget_show (wbcg->object_toolbar);
181
}
182
#else
183 184 185
static BonoboUIVerb verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("CreateLabel", cmd_create_label),
	BONOBO_UI_UNSAFE_VERB ("CreateFrame", cmd_create_frame),
186
	/* BONOBO_UI_UNSAFE_VERB ("CreateButton", cmd_create_button), */
Jody Goldberg's avatar
Jody Goldberg committed
187
	BONOBO_UI_UNSAFE_VERB ("CreateScrollbar", cmd_create_scrollbar),
188
	BONOBO_UI_UNSAFE_VERB ("CreateCheckbox", cmd_create_checkbox),
189
	/* BONOBO_UI_UNSAFE_VERB ("CreateRadiobutton", cmd_create_radiobutton), */
190
	BONOBO_UI_UNSAFE_VERB ("CreateList", cmd_create_list),
191
	BONOBO_UI_UNSAFE_VERB ("CreateCombo", cmd_create_combo),
192 193 194 195 196 197
	BONOBO_UI_UNSAFE_VERB ("CreateLine", cmd_create_line),
	BONOBO_UI_UNSAFE_VERB ("CreateArrow", cmd_create_arrow),
	BONOBO_UI_UNSAFE_VERB ("CreateRectangle", cmd_create_rectangle),
	BONOBO_UI_UNSAFE_VERB ("CreateEllipse", cmd_create_ellipse),
	BONOBO_UI_VERB_END
};
198

199 200 201 202
void
workbook_create_object_toolbar (WorkbookControlGUI *wbcg)
{
	bonobo_ui_component_add_verb_list_with_data (wbcg->uic, verbs, wbcg);
203
}
204
#endif