Commit 62b18dee authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Dump in a pile of mostly working stuff with a bit of debug spew.

2004-01-22  Jody Goldberg <jody@gnome.org>

	* src/wbc-gtk.c : clean up the border combo and adapt to its new api
parent d39f866e
......@@ -8,6 +8,7 @@ release, and longer term bugs.
Release Critical
----------------
http://bugzilla.gnome.org/show_bug.cgi?id=131588 [-O0 vs -O2 for rangesum]
http://bugzilla.gnome.org/show_bug.cgi?id=97216 [sheet for graph creation]
http://bugzilla.gnome.org/show_bug.cgi?id=127203 [x axis child pos]
: X axis label seperation
......@@ -50,8 +51,10 @@ Pending Patches
5.5.3) Support custom menu item
5.6) GOActionStack (undo/redo)
5.6.1) stub (DONE)
5.6.2) Move to TreeModel to simplify sharing
5.6.3) Support custom menu item
5.6.2) Move to TreeModel to simplify sharing (DONE)
5.6.3) Support custom menu item (DONE)
5.6.4) Emit activate for toolbar
5.6.5) Emit activate for menu (DONE)
5.7) GOActionPixmaps (border)
5.7.1) stub (DONE)
5.7.2) Add some events
......@@ -61,7 +64,7 @@ Pending Patches
5.8.2) Support custom menu item (DONE)
5.8.3) Improve finger feel (DONE)
5.8.4) emit activate for toolbar (DONE)
5.8.5) emit activate for menu
5.8.5) emit activate for menu (DONE)
5.8.6) history buttons in menu
5.8.7) custom button in menu
5.8.8) sync proxies
......
2004-01-22 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c : clean up the border combo and adapt to its new api
2004-01-16 Jody Goldberg <jody@gnome.org>
* configure.in : check for symbolic link support
......
Gnumeric 1.3.0
Andreas:
* Make new strings translatable.
* Use new widget for output page of analysis tools.
* Add display indicating why the okay button is disabled
to selected analysis tools.
http://bugzilla.gnome.org/show_bug.cgi?id=131343
* Use the paper selected in the print dialog [backported]
Emmanuel Pacaud:
* Work on single point formating for charts.
Jody:
* Drop gnome-app-helper in favour of GtkAction
http://bugzilla.gnome.org/show_bug.cgi?id=128524
......@@ -22,14 +33,10 @@ Jody:
* ISNUMBER() should return false for blank references
http://bugzilla.gnome.org/show_bug.cgi?id=130172
* Do not convert blanks to int(0) for string args
Andreas:
* Make new strings translatable.
* Use new widget for output page of analysis tools.
* Add display indicating why the okay button is disabled
to selected analysis tools.
http://bugzilla.gnome.org/show_bug.cgi?id=131343
* Use the paper selected in the print dialog [backported]
* Allow optional args to receive empty even for booleans
* Install the executable as gnumeric-<version>
http://bugzilla.gnome.org/show_bug.cgi?id=132017
* Support double underline when importing from applix
John Gill:
* Tool tips for the sort dialog.
......
2004-01-22 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c : clean up the border combo and adapt to its new api
2004-01-16 Jody Goldberg <jody@gnome.org>
* configure.in : check for symbolic link support
......
......@@ -128,12 +128,15 @@ CFLAGS="$CFLAGS -DGDK_PIXBUF_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DGDK_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DGDK_MULTIHEAD_SAFE"
CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DLIBGLADE_DISABLE_DEPRECATED"
if test "x$gnome_msg" = "xyes"; then
CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
fi
dnl ****************************
dnl prep the pixmap generator
dnl ****************************
......@@ -414,12 +417,12 @@ AC_CHECK_HEADERS(langinfo.h)
dnl iswprint/iswspace are sometimes in wctype.h
AC_CHECK_HEADERS(wctype.h)
AC_C_LONG_DOUBLE
float_msg=double
have_ld=no
AC_ARG_WITH(long_double,
[--{with,without}-long-double Use long double for floating point],
[if test "x$withval" = xyes; then
AC_C_LONG_DOUBLE
if test "x$ac_cv_c_long_double" != "xyes"; then
AC_MSG_ERROR([Long double type is not available.])
fi
......
......@@ -602,7 +602,11 @@ applix_parse_style (ApplixReadState *state, unsigned char **buffer)
++sep;
break;
case 'U' :
mstyle_set_font_uline (style, TRUE);
mstyle_set_font_uline (style, UNDERLINE_SINGLE);
++sep;
break;
case 'D' :
mstyle_set_font_uline (style, UNDERLINE_DOUBLE);
++sep;
break;
case 'f' :
......
2004-01-22 Jody Goldberg <jody@gnome.org>
* gui-utils/go-action-combo-pixmaps.c : rewrite.
2004-01-17 Jody Goldberg <jody@gnome.org>
* gui-utils/go-action-combo-color.c (cb_color_changed) : Use the
supplied color directly.
(go_action_combo_color_create_menu_item) : connect up the activate signal.
2004-01-22 Emmanuel Pacaud <emmanuel.pacaud@univ-poitiers.fr>
* graph/gog-style.c (gog_style_editor) : edit a GogStyle, not
GogStyledObject.
......
......@@ -300,14 +300,14 @@ line_init (StylePrefState *state, gboolean enable)
/************************************************************************/
static void
cb_pattern_type_changed (GtkWidget *cc, int index, StylePrefState const *state)
cb_pattern_type_changed (GtkWidget *cc, int pattern, StylePrefState const *state)
{
GogStyle *style = state->style;
gboolean is_auto = pattern < 0;
g_return_if_fail (style != NULL);
style->fill.u.pattern.pat.pattern =
(index / 10 - 1) * 6 + index % 10 - 1;
if (is_auto)
pattern = -pattern;
style->fill.u.pattern.pat.pattern = pattern;
set_style (state);
}
......@@ -334,7 +334,7 @@ populate_pattern_combo (StylePrefState *state)
if (style->fill.type == GOG_FILL_STYLE_PATTERN)
type = style->fill.u.pattern.pat.pattern;
pixmap_combo_select_pixmap (PIXMAP_COMBO(combo), type);
go_combo_pixmaps_select_id (GO_COMBO_PIXMAPS(combo), type);
g_signal_connect (G_OBJECT (combo),
"changed",
G_CALLBACK (cb_pattern_type_changed), state);
......@@ -409,10 +409,10 @@ fill_pattern_init (StylePrefState *state)
/************************************************************************/
static void
cb_gradient_type_changed (GtkWidget *cc, int dir, StylePrefState const *state)
cb_gradient_type_changed (GtkWidget *cc, int id, StylePrefState const *state)
{
GogStyle *style = state->style;
style->fill.u.gradient.dir = dir; /* pre mapped */
style->fill.u.gradient.dir = id;
set_style (state);
}
......@@ -434,7 +434,8 @@ populate_gradient_combo (StylePrefState *state)
table = glade_xml_get_widget (state->gui, "fill_gradient_table");
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1, 0, 0, 0, 0);
if (style->fill.type == GOG_FILL_STYLE_GRADIENT)
pixmap_combo_select_pixmap (PIXMAP_COMBO (combo), style->fill.u.gradient.dir);
go_combo_pixmaps_select_id (GO_COMBO_PIXMAPS (combo),
style->fill.u.gradient.dir);
g_signal_connect (G_OBJECT (combo),
"changed",
G_CALLBACK (cb_gradient_type_changed), state);
......@@ -693,8 +694,8 @@ cb_fill_type_changed (GtkWidget *menu, StylePrefState *state)
color_combo_get_gocolor (state->fill.pattern.fore, FALSE);
style->fill.u.pattern.pat.back =
color_combo_get_gocolor (state->fill.pattern.back, FALSE);
style->fill.u.pattern.pat.pattern =
((PixmapCombo*)state->fill.pattern.combo)->last_index;
style->fill.u.pattern.pat.pattern = go_combo_pixmaps_get_selected (
(GOComboPixmaps*)state->fill.pattern.combo, NULL);
break;
case GOG_FILL_STYLE_GRADIENT:
......@@ -702,8 +703,8 @@ cb_fill_type_changed (GtkWidget *menu, StylePrefState *state)
color_combo_get_gocolor (state->fill.gradient.start, FALSE);
style->fill.u.gradient.end =
color_combo_get_gocolor (state->fill.gradient.end, FALSE);
style->fill.u.gradient.dir =
((PixmapCombo*)state->fill.gradient.combo)->last_index;
style->fill.u.gradient.dir = go_combo_pixmaps_get_selected (
(GOComboPixmaps*)state->fill.gradient.combo, NULL);
w = glade_xml_get_widget (state->gui, "fill_gradient_type");
if (gtk_option_menu_get_history (GTK_OPTION_MENU (w))) {
w = glade_xml_get_widget (state->gui, "fill_gradient_brightness");
......@@ -790,7 +791,7 @@ populate_marker_combo (StylePrefState *state)
table = glade_xml_get_widget (state->gui, "marker_table");
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1, 0, 0, 0, 0);
pixmap_combo_select_pixmap (PIXMAP_COMBO (combo),
go_combo_pixmaps_select_id (GO_COMBO_PIXMAPS (combo),
go_marker_get_shape (style->marker.mark));
g_signal_connect (G_OBJECT (combo),
"changed",
......
......@@ -99,9 +99,8 @@ cb_color_changed (GtkWidget *cc, GdkColor const *c,
{
if (!by_user)
return;
caction->current_color = (is_default)
? caction->default_val
: color_combo_get_gocolor (cc, is_custom);
caction->current_color = is_default
? caction->default_val : GDK_TO_UINT (*c);
gtk_action_activate (GTK_ACTION (caction));
}
......@@ -111,6 +110,7 @@ go_action_combo_color_create_tool_item (GtkAction *a)
GOActionComboColor *caction = (GOActionComboColor *)a;
GOToolComboColor *tool = g_object_new (GO_TOOL_COMBO_COLOR_TYPE, NULL);
GdkColor gdk_default;
tool->combo = (ColorCombo *)color_combo_new (caction->icon,
caction->default_val_label,
go_color_to_gdk (caction->default_val, &gdk_default),
......@@ -139,6 +139,10 @@ go_action_combo_color_create_menu_item (GtkAction *a)
GtkWidget *item = gtk_image_menu_item_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
gtk_widget_show (submenu);
g_signal_connect (G_OBJECT (submenu),
"color_changed",
G_CALLBACK (cb_color_changed), a);
return item;
}
......
......@@ -26,12 +26,14 @@
#include <gtk/gtkaction.h>
#include <gtk/gtktoolitem.h>
#include <gtk/gtkimagemenuitem.h>
#include <gtk/gtkimage.h>
#include <gsf/gsf-impl-utils.h>
#include <glib/gi18n.h>
typedef struct {
GtkToolItem base;
PixmapCombo *combo; /* container has a ref, not us */
GOComboPixmaps *combo; /* container has a ref, not us */
} GOToolComboPixmaps;
typedef GtkToolItemClass GOToolComboPixmapsClass;
......@@ -46,7 +48,7 @@ go_tool_combo_pixmaps_set_tooltip (GtkToolItem *tool_item, GtkTooltips *tooltips
char const *tip_private)
{
GOToolComboPixmaps *self = (GOToolComboPixmaps *)tool_item;
gtk_tooltips_set_tip (tooltips, self->combo->preview_button,
gtk_tooltips_set_tip (tooltips, go_combo_pixmaps_get_preview (self->combo),
tip_text, tip_private);
gtk_tooltips_set_tip (tooltips, gnm_combo_box_get_arrow (GNM_COMBO_BOX (self->combo)),
tip_text, tip_private);
......@@ -66,42 +68,98 @@ static GSF_CLASS (GOToolComboPixmaps, go_tool_combo_pixmaps,
struct _GOActionComboPixmaps {
GtkAction base;
PixmapComboElement const *elements;
GOActionComboPixmapsElement const *elements;
int ncols, nrows;
gboolean updating_proxies;
int selected_id;
};
typedef struct {
GtkActionClass base;
} GOActionComboPixmapsClass;
typedef GtkActionClass GOActionComboPixmapsClass;
static GObjectClass *combo_pixmaps_parent;
#if 0
static void
go_action_combo_pixmaps_connect_proxy (GtkAction *action, GtkWidget *proxy)
go_action_combo_pixmaps_connect_proxy (GtkAction *a, GtkWidget *proxy)
{
if (GTK_IS_IMAGE_MENU_ITEM (proxy)) { /* set the icon */
GOActionComboPixmaps *paction = (GOActionComboPixmaps *)a;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1,
paction->elements[0].inline_gdkpixbuf, TRUE, NULL);
GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
gtk_widget_show (image);
gtk_image_menu_item_set_image (
GTK_IMAGE_MENU_ITEM (proxy), image);
}
}
static void
go_action_combo_pixmaps_disconnect_proxy (GtkAction *action, GtkWidget *proxy)
cb_selection_changed (GOComboPixmaps *combo, int id, GOActionComboPixmaps *paction)
{
GSList *ptr;
if (paction->updating_proxies)
return;
paction->selected_id = id;
paction->updating_proxies = TRUE;
ptr = gtk_action_get_proxies (GTK_ACTION (paction));
for ( ; ptr != NULL ; ptr = ptr->next)
if (IS_GO_COMBO_PIXMAPS (ptr->data) &&
go_combo_pixmaps_get_selected (ptr->data, NULL) != id)
go_combo_pixmaps_select_id (ptr->data, id);
paction->updating_proxies = FALSE;
gtk_action_activate (GTK_ACTION (paction));
}
#endif
static GtkWidget *
go_action_combo_pixmaps_create_tool_item (GtkAction *a)
{
GOActionComboPixmaps *caction = (GOActionComboPixmaps *)a;
GOActionComboPixmaps *paction = (GOActionComboPixmaps *)a;
GOToolComboPixmaps *tool = g_object_new (GO_TOOL_COMBO_PIXMAPS_TYPE, NULL);
GOActionComboPixmapsElement const *el= paction->elements;
tool->combo = (PixmapCombo *)pixmap_combo_new (caction->elements,
caction->ncols, caction->nrows, TRUE);
tool->combo = go_combo_pixmaps_new (paction->ncols);
for ( ; el->inline_gdkpixbuf != NULL ; el++)
go_combo_pixmaps_add_element (tool->combo,
gdk_pixbuf_new_from_inline (-1, el->inline_gdkpixbuf, TRUE, NULL),
el->id, _(el->untranslated_tooltip));
go_combo_pixmaps_select_id (tool->combo, paction->selected_id);
gnm_widget_disable_focus (GTK_WIDGET (tool->combo));
gtk_container_add (GTK_CONTAINER (tool), GTK_WIDGET (tool->combo));
gtk_widget_show (GTK_WIDGET (tool->combo));
gtk_widget_show (GTK_WIDGET (tool));
g_signal_connect (G_OBJECT (tool->combo),
"changed",
G_CALLBACK (cb_selection_changed), a);
return GTK_WIDGET (tool);
}
static GtkWidget *
go_action_combo_pixmaps_create_menu_item (GtkAction *a)
{
GOActionComboPixmaps *paction = (GOActionComboPixmaps *)a;
GOMenuPixmaps *submenu = go_menu_pixmaps_new (paction->ncols);
GOActionComboPixmapsElement const *el= paction->elements;
GtkWidget *item;
for ( ; el->inline_gdkpixbuf != NULL ; el++)
go_menu_pixmaps_add_element (submenu,
gdk_pixbuf_new_from_inline (-1, el->inline_gdkpixbuf, TRUE, NULL),
el->id);
item = gtk_image_menu_item_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (submenu));
gtk_widget_show (GTK_WIDGET (submenu));
g_signal_connect (G_OBJECT (submenu),
"changed",
G_CALLBACK (cb_selection_changed), a);
return item;
}
static void
go_action_combo_pixmaps_finalize (GObject *obj)
{
......@@ -117,11 +175,8 @@ go_action_combo_pixmaps_class_init (GtkActionClass *gtk_act_klass)
gobject_klass->finalize = go_action_combo_pixmaps_finalize;
gtk_act_klass->create_tool_item = go_action_combo_pixmaps_create_tool_item;
#if 0
gtk_act_klass->create_menu_item = Use the default
gtk_act_klass->create_menu_item = go_action_combo_pixmaps_create_menu_item;
gtk_act_klass->connect_proxy = go_action_combo_pixmaps_connect_proxy;
gtk_act_klass->disconnect_proxy = go_action_combo_pixmaps_disconnect_proxy;
#endif
}
GSF_CLASS (GOActionComboPixmaps, go_action_combo_pixmaps,
......@@ -130,13 +185,30 @@ GSF_CLASS (GOActionComboPixmaps, go_action_combo_pixmaps,
GOActionComboPixmaps *
go_action_combo_pixmaps_new (char const *name,
PixmapComboElement const *elements, int ncols, int nrows)
GOActionComboPixmapsElement const *elements,
int ncols, int nrows)
{
GOActionComboPixmaps *res = g_object_new (go_action_combo_pixmaps_get_type (),
"name", name,
NULL);
res->elements = elements;
res->ncols = ncols;
res->nrows = nrows;
return res;
GOActionComboPixmaps *paction;
g_return_val_if_fail (ncols > 0, NULL);
g_return_val_if_fail (nrows > 0, NULL);
g_return_val_if_fail (elements != NULL, NULL);
paction = g_object_new (go_action_combo_pixmaps_get_type (),
"name", name,
NULL);
paction->elements = elements;
paction->ncols = ncols;
paction->nrows = nrows;
paction->selected_id = elements[0].id;
return paction;
}
int
go_action_combo_pixmaps_get_selection (GOActionComboPixmaps *paction)
{
g_return_val_if_fail (IS_GO_ACTION_COMBO_PIXMAPS (paction), 0);
return paction->selected_id;
}
......@@ -31,12 +31,18 @@ G_BEGIN_DECLS
#define IS_GO_ACTION_COMBO_PIXMAPS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_ACTION_COMBO_PIXMAPS_TYPE))
typedef struct _GOActionComboPixmaps GOActionComboPixmaps;
typedef struct {
char const *untranslated_tooltip;
guint8 const *inline_gdkpixbuf;
int id;
} GOActionComboPixmapsElement;
GType go_action_combo_pixmaps_get_type (void);
GOActionComboPixmaps *
go_action_combo_pixmaps_new (char const *name,
PixmapComboElement const *elements,
GOActionComboPixmapsElement const *elements,
int ncols, int nrows);
int go_action_combo_pixmaps_get_selection (GOActionComboPixmaps *action);
G_END_DECLS
......
......@@ -99,7 +99,6 @@ cb_button_release_event (GtkWidget *list, GdkEventButton *e, gpointer data)
{
GOComboStack *stack = GO_COMBO_STACK (data);
// go_combo_stack_clear_selection (stack);
gnm_combo_box_popup_hide (GNM_COMBO_BOX (stack));
if (stack->bottom > 0) {
......
......@@ -107,14 +107,14 @@ go_action_combo_create_tool_item (GtkAction *act)
if (caction->largest_elem != NULL)
w = gnm_measure_string (
gtk_widget_get_pango_context (GTK_WIDGET (tool->combo)),
tool->combo->entry->style->font_desc,
gnm_combo_text_get_entry (tool->combo)->style->font_desc,
caction->largest_elem);
for (ptr = caction->elements; ptr != NULL ; ptr = ptr->next) {
gnm_combo_text_add_item (tool->combo, ptr->data);
if (caction->largest_elem == NULL) {
tmp = gnm_measure_string (
gtk_widget_get_pango_context (GTK_WIDGET (tool->combo)),
tool->combo->entry->style->font_desc,
gnm_combo_text_get_entry (tool->combo)->style->font_desc,
ptr->data);
if (w < tmp)
w = tmp;
......@@ -123,7 +123,8 @@ go_action_combo_create_tool_item (GtkAction *act)
gnm_combo_box_set_title (GNM_COMBO_BOX (tool->combo),
_(gtk_action_get_name (act)));
gtk_widget_set_size_request (tool->combo->entry, w, -1);
gtk_widget_set_size_request (
gnm_combo_text_get_entry (tool->combo), w, -1);
g_object_set (G_OBJECT (tool), "visible_vertical", FALSE, NULL);
gnm_widget_disable_focus (GTK_WIDGET (tool->combo));
......
......@@ -105,16 +105,16 @@ color_palette_finalize (GObject *object)
}
static void
color_palette_class_init (GObjectClass *object_class)
color_palette_class_init (GObjectClass *gobject_class)
{
object_class->finalize = color_palette_finalize;
((GtkObjectClass *)object_class)->destroy = color_palette_destroy;
gobject_class->finalize = color_palette_finalize;
((GtkObjectClass *)gobject_class)->destroy = color_palette_destroy;
color_palette_parent_class = g_type_class_peek_parent (object_class);
color_palette_parent_class = g_type_class_peek_parent (gobject_class);
color_palette_signals [COLOR_CHANGED] =
g_signal_new ("color_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ColorPaletteClass, color_changed),
NULL, NULL,
......@@ -146,7 +146,6 @@ emit_color_changed (ColorPalette *P, GdkColor const *color,
color, custom, by_user, is_default);
}
/*
* Add the new custom color as the first custom color in the custom color rows
* and shift all of the others 'one step down'
......@@ -287,9 +286,9 @@ color_in_palette (ColorNamePair *set, GdkColor *color)
* Utility function
*/
static GtkWidget *
color_palette_button_new(ColorPalette *P, GtkTable* table,
GtkTooltips *tool_tip, ColorNamePair* color_name,
gint col, gint row, int data)
color_palette_button_new (ColorPalette *P, GtkTable* table,
GtkTooltips *tool_tip, ColorNamePair* color_name,
gint col, gint row, int data)
{
GtkWidget *button, *swatch, *box;
GdkColor c;
......@@ -628,6 +627,34 @@ color_palette_new (char const *no_color_label,
color_group);
}
/***********************************************************************/
typedef GtkMenu GOMenuColor;
typedef struct {
GtkMenuClass base;
void (* color_changed) (GOMenuColor *menu, GdkColor *color,
gboolean custom, gboolean by_user, gboolean is_default);
} GOMenuColorClass;
static guint go_menu_color_signals [LAST_SIGNAL] = { 0, };
static void
go_menu_color_class_init (GObjectClass *gobject_class)
{
go_menu_color_signals [COLOR_CHANGED] =
g_signal_new ("color_changed",
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GOMenuColorClass, color_changed),
NULL, NULL,
gnm__VOID__POINTER_BOOLEAN_BOOLEAN_BOOLEAN,
G_TYPE_NONE, 4, G_TYPE_POINTER,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
}
static GSF_CLASS (GOMenuColor, go_menu_color,
go_menu_color_class_init, NULL,
GTK_TYPE_MENU)
static GtkWidget *
make_colored_menu_item (char const *label, GdkColor const *c)
{
......@@ -641,9 +668,27 @@ make_colored_menu_item (char const *label, GdkColor const *c)
gtk_image_new_from_pixbuf (pixbuf));
g_object_unref (pixbuf);
gtk_widget_show_all (button);
g_object_set_data_full (G_OBJECT (button), "gdk_color",
gdk_color_copy (c), (GDestroyNotify) gdk_color_free);
return button;
}
static void
cb_menu_default_activate (GtkWidget *button, GtkWidget *menu)
{
g_signal_emit (menu, go_menu_color_signals [COLOR_CHANGED], 0,
NULL, FALSE, TRUE, TRUE);
}
static void
cb_menu_color_activate (GtkWidget *button, GtkWidget *menu)
{
GdkColor const *color = g_object_get_data (G_OBJECT (button), "gdk_color");
g_signal_emit (menu, go_menu_color_signals [COLOR_CHANGED], 0,
color, FALSE, TRUE, FALSE);
}
GtkWidget *
color_palette_make_menu (char const *no_color_label,
GdkColor const *default_color,
......@@ -656,13 +701,18 @@ color_palette_make_menu (char const *no_color_label,
GtkWidget *button, *submenu;
GdkColor c;
submenu = gtk_menu_new ();
submenu = g_object_new (go_menu_color_get_type (), NULL);
if (no_color_label != NULL) {
if (default_color != NULL)
button = make_colored_menu_item (no_color_label, default_color);
else
button = gtk_menu_item_new_with_label (no_color_label);
gtk_menu_attach (GTK_MENU (submenu), button, 0, ncols, 0, 1);
g_signal_connect (G_OBJECT (button),
"activate",
G_CALLBACK (cb_menu_default_activate), submenu);
table_row++;
}
for (row = 0; row < nrows; row++, table_row++) {
......@@ -678,6 +728,9 @@ color_palette_make_menu (char const *no_color_label,
button = make_colored_menu_item (" ", &c);
gtk_menu_attach (GTK_MENU (submenu), button,
col, col+1, table_row, table_row+1);
g_signal_connect (G_OBJECT (button),
"activate",
G_CALLBACK (cb_menu_color_activate), submenu);
}
}
gtk_widget_show (submenu);
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* widget-color-combo.c - A color selector combo box
* Copyright 2000, 2001, Ximian, Inc.
* Copyright 2000-2004, Ximian, Inc.
*
* Authors:
* Miguel de Icaza (miguel@kernel.org)
......@@ -12,6 +13,7 @@
*
* And later revised and polished by:
* Almer S. Tigelaar (almer@gnome.org)
* Jody Goldberg (jody@gnome.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -32,10 +34,11 @@
#include "widget-color-combo.h"
#include <gnm-marshalers.h>
#include <gsf/gsf-impl-utils.h>
#include <gui-util.h>
#include <style-color.h>
#include <goffice/utils/go-color.h>
#include <gsf/gsf-impl-utils.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkimage.h>
......@@ -46,12 +49,9 @@ enum {
static guint color_combo_signals [LAST_SIGNAL] = { 0, };
#define PARENT_TYPE GNM_COMBO_BOX_TYPE
static GObjectClass *color_combo_parent_class;
#define make_color(CC,COL) (((COL) != NULL) ? (COL) : ((CC) ? ((CC)->default_color) : NULL))
#define RGBA_TO_UINT(r,g,b,a) ((((guint)(r))<<24)|(((guint)(g))<<16)|(((guint)(b))<<8)|(guint)(a))
#define GDK_TO_UINT(c) RGBA_TO_UINT(((c).red>>8), ((c).green>>8), ((c).blue>>8), 0xff)
#define PREVIEW_SIZE 20
......@@ -117,27 +117,6 @@ cb_screen_changed (ColorCombo *cc, GdkScreen *previous_screen)
}
}
static void
color_combo_class_init (GObjectClass *object_class)
{
color_combo_parent_class = g_type_class_ref (PARENT_TYPE);
color_combo_signals [CHANGED] =
g_signal_new ("color_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ColorComboClass, color_changed),
NULL, NULL,
gnm__VOID__POINTER_BOOLEAN_BOOLEAN_BOOLEAN,
G_TYPE_NONE, 4, G_TYPE_POINTER,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
}
GSF_CLASS(ColorCombo,color_combo,color_combo_class_init,NULL,PARENT_TYPE)
/*
* Fires signal "color_changed" with the current color as its param
*/
static void
emit_color_changed (ColorCombo *cc, GdkColor *color,
gboolean is_custom, gboolean by_user, gboolean is_default)
......@@ -148,15 +127,6 @@ emit_color_changed (ColorCombo *cc, GdkColor *color,
gnm_combo_box_popup_hide (GNM_COMBO_BOX (cc));
}
static void
cb_palette_color_changed (ColorPalette *P, GdkColor *color,
gboolean custom, gboolean by_user, gboolean is_default,