Commit 53f0b0c0 authored by Jean Brefort's avatar Jean Brefort Committed by Jean Bréfort

removed gnumeric-combo-text.[c,h] moved to goffice. ditto. replaced

2004-05-26  Jean Brefort  <jean.brefort@ac-dijon.fr>

	* Makefile.am: removed gnumeric-combo-text.[c,h]
	* gnumeric-combo-text.c: moved to goffice.
	* gnumeric-combo-text.h: ditto.
	* widget-font-selector.c: (fs_modify_style), (cb_list_adjust),
	(list_init), (font_selected), (fs_fill_font_name_list),
	(style_selected), (fs_fill_font_style_list), (select_row),
	(size_selected), (size_changed), (fs_fill_font_size_list),
	(fs_init), (font_selector_new): replaced GtkList by GtkTreeView
	* widget-format-selector.c: (nfs_init),
	(number_format_selector_set_style_format): replaced GnmComboText by GoComboText.
parent 7f7e78c0
2004-05-26 Jean Brefort <jean.brefort@ac-dijon.fr>
* Makefile.am: removed gnumeric-combo-text.[c,h]
* gnumeric-combo-text.c: moved to goffice.
* gnumeric-combo-text.h: ditto.
* widget-font-selector.c: (fs_modify_style), (cb_list_adjust),
(list_init), (font_selected), (fs_fill_font_name_list),
(style_selected), (fs_fill_font_style_list), (select_row),
(size_selected), (size_changed), (fs_fill_font_size_list),
(fs_init), (font_selector_new): replaced GtkList by GtkTreeView
* widget-format-selector.c: (nfs_init),
(number_format_selector_set_style_format): replaced GnmComboText by GoComboText.
2004-03-28 Jody Goldberg <jody@gnome.org>
* Release 1.3.0
......@@ -1963,4 +1976,3 @@
2000-03-24 Jody Goldberg <jgoldberg@home.com>
* gtk-combo-text.c (gtk_combo_text_select_item) : New function.
......@@ -31,8 +31,6 @@ libwidgets_a_SOURCES = \
gnumeric-dashed-canvas-line.h \
gnumeric-expr-entry.c \
gnumeric-expr-entry.h \
gnumeric-combo-text.c \
gnumeric-combo-text.h \
gnumeric-lazy-list.c \
gnumeric-lazy-list.h \
gnumeric-optionmenu.c \
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gnumeric-combo-text: A combo box for selecting from a list.
*/
#undef GTK_DISABLE_DEPRECATED
#warning "This file uses GTK_DISABLE_DEPRECATED"
#include <gnumeric-config.h>
#include "gnumeric-combo-text.h"
#include <goffice/gui-utils/go-combo-box.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkentry.h>
#include <gtk/gtklist.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkscrolledwindow.h>
#include <gsf/gsf-impl-utils.h>
struct _GnmComboText {
GOComboBox parent;
GCompareFunc cmp_func;
GtkWidget *entry;
GtkWidget *list;
GtkWidget *scroll;
GtkWidget *cached_entry;
GtkStateType cache_mouse_state;
};
typedef struct {
GOComboBoxClass base;
gboolean (* selection_changed) (GnmComboText *ct, GtkWidget *new_item);
gboolean (* entry_changed) (GnmComboText *ct, char const *new_str);
} GnmComboTextClass;
#define GNM_COMBO_TEXT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gnm_combo_text_get_type (), GnmComboTextClass)
enum {
SELECTION_CHANGED,
ENTRY_CHANGED,
LAST_SIGNAL
};
static guint combo_text_signals [LAST_SIGNAL] = { 0 };
/**
* A utility wrapper around g_signal_emitv because it does not initiialize the
* result to FALSE if there is no handler.
*/
static gboolean
gnm_signal_emit (GnmComboText *ct, int signal,
gconstpointer arg, gboolean default_ret)
{
gboolean result;
GValue ret = { 0, };
GValue instance_and_parm [2] = { { 0, }, { 0, } };
g_value_init (instance_and_parm + 0, GNM_TYPE_COMBO_TEXT);
g_value_set_instance (instance_and_parm + 0, G_OBJECT (ct));
g_value_init (instance_and_parm + 1, G_TYPE_POINTER);
g_value_set_pointer (instance_and_parm + 1, (gpointer)arg);
g_value_init (&ret, G_TYPE_BOOLEAN);
g_value_set_boolean (&ret, default_ret);
g_signal_emitv (instance_and_parm, combo_text_signals [signal], 0, &ret);
result = g_value_get_boolean (&ret);
g_value_unset (instance_and_parm + 0);
g_value_unset (instance_and_parm + 1);
return result;
}
static void
cb_entry_activate (GtkWidget *entry, gpointer ct)
{
char const *text = gtk_entry_get_text (GTK_ENTRY (entry));
if (gnm_signal_emit (GNM_COMBO_TEXT (ct), ENTRY_CHANGED, text, TRUE))
gnm_combo_text_set_text (GNM_COMBO_TEXT (ct), text,
GNM_COMBO_TEXT_CURRENT);
}
static gboolean
cb_pop_down (GtkWidget *w, G_GNUC_UNUSED GtkWidget *pop_down,
G_GNUC_UNUSED gpointer dummy)
{
GnmComboText *ct = GNM_COMBO_TEXT (w);
if (ct->cached_entry)
gtk_widget_set_state (ct->cached_entry, ct->cache_mouse_state);
ct->cached_entry = NULL;
return FALSE;
}
static void
cb_list_select (G_GNUC_UNUSED GtkWidget *list,
GtkWidget *child, gpointer data)
{
GnmComboText *ct = GNM_COMBO_TEXT (data);
GtkEntry *entry = GTK_ENTRY (ct->entry);
gboolean accept_change;
char *text = g_strdup ((child != NULL)
? GTK_LABEL (GTK_BIN (child)->child)->label : "");
if (ct->cached_entry == child)
ct->cached_entry = NULL;
accept_change = TRUE;
if (gnm_signal_emit (ct, SELECTION_CHANGED, child, TRUE))
accept_change = gnm_signal_emit (ct, ENTRY_CHANGED, text, TRUE);
if (accept_change)
gtk_entry_set_text (entry, text);
g_free (text);
go_combo_box_popup_hide (GO_COMBO_BOX (data));
}
static void
cb_list_unselect (GtkWidget *list, GtkWidget *child,
G_GNUC_UNUSED gpointer data)
{
if (GTK_WIDGET_VISIBLE (list)) /* Undo interactive unselect */
gtk_list_select_child (GTK_LIST (list), child);
}
static void
cb_toggle (GtkWidget *child, gpointer data)
{
GnmComboText *ct = GNM_COMBO_TEXT (data);
gtk_list_select_child (GTK_LIST (ct->list), child);
}
/*
* We can't just cache the old widget state on entry: If the pointer is
* dragged, we receive two enter-notify-events, and the original cached
* value would be overwritten with the GTK_STATE_ACTIVE we just set.
*
* However, we know that the gtklist only uses GTK_STATE_SELECTED and
* GTK_STATE_NORMAL. We're OK if we only cache those two.
*/
static gboolean
cb_enter (GtkWidget *w, G_GNUC_UNUSED GdkEventCrossing *event,
gpointer user)
{
GnmComboText *ct = user;
GtkStateType state = GTK_WIDGET_STATE (w);
if (state == GTK_STATE_NORMAL || state == GTK_STATE_SELECTED) {
ct->cached_entry = w;
ct->cache_mouse_state = state;
}
if (state != GTK_STATE_SELECTED)
gtk_widget_set_state (w, GTK_STATE_ACTIVE);
return TRUE;
}
static gboolean
cb_exit (GtkWidget *w, G_GNUC_UNUSED GdkEventCrossing *event,
gpointer user)
{
GnmComboText *ct = user;
if (ct->cached_entry == w)
gtk_widget_set_state (w, ct->cache_mouse_state);
return TRUE;
}
static void
cb_list_mapped (GtkWidget *widget, G_GNUC_UNUSED gpointer user_data)
{
GtkList *list = GTK_LIST (widget);
if (g_list_length (list->selection) > 0)
gtk_widget_grab_focus (GTK_WIDGET ((list->selection->data)));
}
static void
cb_scroll_size_request (GtkWidget *widget, GtkRequisition *requisition,
GnmComboText *ct)
{
GtkRequisition list_req;
int mon_width, mon_height;
GdkRectangle rect;
GdkScreen *screen;
/* In a Xinerama setup, use geometry of the actual display unit. */
screen = gtk_widget_get_screen (widget);
if (screen == NULL)
/* Looks like this will happen when
* embedded as a bonobo component */
screen = gdk_screen_get_default ();
gdk_screen_get_monitor_geometry (screen, 0, &rect);
mon_width = rect.width;
mon_height = rect.height;
gtk_widget_size_request (ct->list, &list_req);
if (requisition->height < list_req.height) {
int height = list_req.height;
GtkWidget const *w = GTK_WIDGET
(GTK_LIST (ct->list)->children->data);
if (w != NULL) {
/* Make room for a whole number of items which don't
* overflow the screen, but no more than 20. */
int avail_height, nitems;
avail_height = mon_height - 20
- GTK_CONTAINER (widget)->border_width * 2 + 4;
nitems = MIN (20, avail_height / w->requisition.height);
height = nitems * w->requisition.height;
if (height > list_req.height)
height = list_req.height;
}
/* FIXME : Why do we need 4 ??
* without it things end up scrolling.
*/
requisition->height = height +
GTK_CONTAINER (widget)->border_width * 2 + 4;
}
requisition->width = MAX (requisition->width,
ct->entry->allocation.width +
GTK_CONTAINER (widget)->border_width * 2);
requisition->width = MIN (requisition->width, mon_width - 20);
requisition->height = MIN (requisition->height, mon_height - 20);
}
static void
cb_screen_changed (GnmComboText *ct, GdkScreen *previous_screen)
{
GtkWidget *w = GTK_WIDGET (ct);
GdkScreen *screen = gtk_widget_has_screen (w)
? gtk_widget_get_screen (w)
: NULL;
if (screen) {
GtkWidget *toplevel = gtk_widget_get_toplevel (ct->scroll);
gtk_window_set_screen (GTK_WINDOW (toplevel), screen);
}
}
static void
gnm_combo_text_init (GnmComboText *ct)
{
ct->cached_entry = NULL;
ct->cache_mouse_state = GTK_STATE_NORMAL;
ct->entry = gtk_entry_new ();
ct->list = gtk_list_new ();
ct->scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (ct->scroll),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (
GTK_SCROLLED_WINDOW (ct->scroll), ct->list);
gtk_container_set_focus_hadjustment (
GTK_CONTAINER (ct->list),
gtk_scrolled_window_get_hadjustment (
GTK_SCROLLED_WINDOW (ct->scroll)));
gtk_container_set_focus_vadjustment (
GTK_CONTAINER (ct->list),
gtk_scrolled_window_get_vadjustment (
GTK_SCROLLED_WINDOW (ct->scroll)));
g_signal_connect (G_OBJECT (ct->entry),
"activate",
GTK_SIGNAL_FUNC (cb_entry_activate), (gpointer) ct);
g_signal_connect (G_OBJECT (ct->scroll),
"size_request",
G_CALLBACK (cb_scroll_size_request), (gpointer) ct);
g_signal_connect (G_OBJECT (ct->list),
"select-child",
G_CALLBACK (cb_list_select), (gpointer) ct);
g_signal_connect (G_OBJECT (ct->list),
"unselect-child",
G_CALLBACK (cb_list_unselect), (gpointer) ct);
g_signal_connect (G_OBJECT (ct->list),
"map",
G_CALLBACK (cb_list_mapped), NULL);
gtk_widget_show (ct->entry);
go_combo_box_construct (GO_COMBO_BOX (ct),
ct->entry, ct->scroll, ct->list);
g_signal_connect (G_OBJECT (ct),
"pop_down_done",
G_CALLBACK (cb_pop_down), NULL);
g_signal_connect (G_OBJECT (ct),
"screen-changed", G_CALLBACK (cb_screen_changed),
NULL);
}
static void
gnm_combo_text_destroy (GtkObject *object)
{
GtkObjectClass *parent;
GnmComboText *ct = GNM_COMBO_TEXT (object);
if (ct->list != NULL) {
g_signal_handlers_disconnect_by_func (G_OBJECT (ct),
G_CALLBACK (cb_pop_down), NULL);
g_signal_handlers_disconnect_by_func (G_OBJECT (ct),
G_CALLBACK (cb_screen_changed), NULL);
g_signal_handlers_disconnect_by_func (GTK_OBJECT (ct->list),
G_CALLBACK (cb_list_unselect), ct);
ct->list = NULL;
}
parent = g_type_class_peek (GO_COMBO_BOX_TYPE);
if (parent && parent->destroy)
(*parent->destroy) (object);
}
static void
gnm_combo_text_class_init (GtkObjectClass *klass)
{
klass->destroy = &gnm_combo_text_destroy;
combo_text_signals [SELECTION_CHANGED] = g_signal_new ("selection_changed",
GNM_TYPE_COMBO_TEXT,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GnmComboTextClass, selection_changed),
(GSignalAccumulator) NULL, NULL,
gtk_marshal_BOOL__POINTER,
G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
combo_text_signals [ENTRY_CHANGED] = g_signal_new ("entry_changed",
GNM_TYPE_COMBO_TEXT,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GnmComboTextClass, entry_changed),
(GSignalAccumulator) NULL, NULL,
gtk_marshal_BOOL__POINTER,
G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
}
/**
* gnm_combo_text_new :
* @cmp_func : an optional comparison routine.
*/
GtkWidget*
gnm_combo_text_new (GCompareFunc cmp_func)
{
GnmComboText *ct;
if (cmp_func == NULL)
cmp_func = &g_str_equal;
ct = g_object_new (GNM_TYPE_COMBO_TEXT, NULL);
ct->cmp_func = cmp_func;
return GTK_WIDGET (ct);
}
GtkWidget *
gnm_combo_text_glade_new (void)
{
return gnm_combo_text_new (NULL);
}
GSF_CLASS (GnmComboText, gnm_combo_text,
gnm_combo_text_class_init, gnm_combo_text_init,
GO_COMBO_BOX_TYPE)
GtkWidget *
gnm_combo_text_get_entry (GnmComboText *ct)
{
return ct->entry;
}
/**
* gnm_combo_text_set_text :
* @ct :
* @text : the label for the new item
* @start : where to begin the search in the list.
*
* return TRUE if the item is found in the list.
*/
gboolean
gnm_combo_text_set_text (GnmComboText *ct, const gchar *text,
GnmComboTextSearch start)
{
gboolean found = FALSE;
gpointer candidate = NULL;
GtkWidget *child;
GtkList *list;
GList *ptr, *current;
char const *label = "";
list = GTK_LIST (ct->list);
/* Be careful */
current = (start != GNM_COMBO_TEXT_FROM_TOP && list->selection != NULL)
? g_list_find (list->children, list->selection->data)
: NULL;
if (current != NULL) {
if (start == GNM_COMBO_TEXT_NEXT && current != NULL)
current = current->next;
for (ptr = current ; ptr != NULL ; ptr = ptr->next) {
label = GTK_LABEL (GTK_BIN (ptr->data)->child)->label;
if (ct->cmp_func (label, text)) {
candidate = ptr->data;
break;
}
}
}
if (candidate == NULL)
for (ptr = list->children ; ptr != current ; ptr = ptr->next) {
label = GTK_LABEL (GTK_BIN (ptr->data)->child)->label;
if (ct->cmp_func (label, text)) {
candidate = ptr->data;
break;
}
}
gtk_signal_handler_block_by_func (GTK_OBJECT (ct->list),
G_CALLBACK (cb_list_select),
(gpointer) ct);
gtk_signal_handler_block_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (cb_list_unselect),
(gpointer) ct);
gtk_list_unselect_all (list);
/* Use visible label rather than supplied text just in case */
if (candidate && GTK_IS_WIDGET (candidate)) {
child = GTK_WIDGET (candidate);
gtk_list_select_child (GTK_LIST (ct->list), child);
gtk_widget_grab_focus (child);
gtk_entry_set_text (GTK_ENTRY (ct->entry), label);
found = TRUE;
} else
gtk_entry_set_text (GTK_ENTRY (ct->entry), text);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (cb_list_select),
(gpointer) ct);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (cb_list_unselect),
(gpointer) ct);
return found;
}
/**
* gnm_combo_text_add_item :
* @ct : The text combo that will get the new element.
* @label : the user visible label for the new item
* @key : The unique key to identify this item.
*
* It is ok to have multiple items with the same label, but the key must be
* unique.
*/
void
gnm_combo_text_add_item (GnmComboText *ct, char const *label)
{
GtkWidget *listitem;
g_return_if_fail (label != NULL);
listitem = gtk_list_item_new_with_label (label);
g_signal_connect (G_OBJECT (listitem),
"enter-notify-event",
GTK_SIGNAL_FUNC (cb_enter), (gpointer) ct);
g_signal_connect (G_OBJECT (listitem),
"leave-notify-event",
GTK_SIGNAL_FUNC (cb_exit), (gpointer) ct);
g_signal_connect (G_OBJECT (listitem),
"toggle",
GTK_SIGNAL_FUNC (cb_toggle), (gpointer) ct);
gtk_container_add (GTK_CONTAINER (ct->list), listitem);
gtk_widget_show (listitem);
}
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef _GNM_COMBO_TEXT_H
#define _GNM_COMBO_TEXT_H
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GNM_TYPE_COMBO_TEXT (gnm_combo_text_get_type ())
#define GNM_COMBO_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GNM_TYPE_COMBO_TEXT, GnmComboText))
#define IS_GNM_COMBO_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GNM_TYPE_COMBO_TEXT))
typedef struct _GnmComboText GnmComboText;
typedef enum { /* begin the search from : */
GNM_COMBO_TEXT_FROM_TOP, /* the top of the list */
GNM_COMBO_TEXT_CURRENT, /* the current selection */
GNM_COMBO_TEXT_NEXT /* the next element after current */
} GnmComboTextSearch;
GType gnm_combo_text_get_type (void);
GtkWidget *gnm_combo_text_new (GCompareFunc cmp_func);
GtkWidget *gnm_combo_text_glade_new (void);
GtkWidget *gnm_combo_text_get_entry (GnmComboText *ct);
gboolean gnm_combo_text_set_text (GnmComboText *ct, const gchar *label,
GnmComboTextSearch start);
void gnm_combo_text_add_item (GnmComboText *ct, const gchar *label);
G_END_DECLS
#endif /* _GNM_COMBO_TEXT_H */
......@@ -8,8 +8,6 @@
* Almer S. Tigelaar (almer@gnome.org)
*/
#undef GTK_DISABLE_DEPRECATED
#warning "This file uses GTK_DISABLE_DEPRECATED for CList"
#include <gnumeric-config.h>
#include <glib/gi18n.h>
#include <gnumeric.h>
......@@ -29,7 +27,11 @@
#include <stdio.h>
#include <string.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtktreeview.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkcellrenderertext.h>
#include <glade/glade.h>
struct _FontSelector {
......@@ -39,9 +41,9 @@ struct _FontSelector {
GtkWidget *font_name_entry;
GtkWidget *font_style_entry;
GtkWidget *font_size_entry;
GtkWidget *font_name_list;
GtkWidget *font_style_list;
GtkWidget *font_size_list;
GtkTreeView *font_name_list;
GtkTreeView *font_style_list;
GtkTreeView *font_size_list;
FooCanvas *font_preview_canvas;
FooCanvasItem *font_preview_grid;
......@@ -83,8 +85,8 @@ fs_modify_style (FontSelector *fs, GnmStyle *modification)
g_return_if_fail (modification != NULL);
fs->mstyle = mstyle_copy_merge (original, modification);
gtk_signal_emit (GTK_OBJECT (fs),
fs_signals[FONT_CHANGED], modification);
g_signal_emit (GTK_OBJECT (fs),
fs_signals[FONT_CHANGED], 0, modification);
foo_canvas_item_set (fs->font_preview_grid,
"default-style", fs->mstyle,
NULL);
......@@ -95,7 +97,7 @@ fs_modify_style (FontSelector *fs, GnmStyle *modification)
/*
* We cannot moveto a list element until it is mapped.
*/
static void
/*static void
list_mapped (GtkWidget *widget, G_GNUC_UNUSED gpointer user_data)
{
GtkCList * clist = GTK_CLIST (widget);
......@@ -104,45 +106,93 @@ list_mapped (GtkWidget *widget, G_GNUC_UNUSED gpointer user_data)
row = GPOINTER_TO_UINT (clist->selection->data);
if (!gtk_clist_row_is_visible (clist, row))
gtk_clist_moveto (clist, row, 0, 0.5, 0.0);
}*/
static void
cb_list_adjust (GtkTreeView* view)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreePath *path;
GtkScrolledWindow* scroll;
GdkRectangle rect;
GtkAdjustment *adj;
int pos, height, child_height;
if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (view), &model, &iter)) {
path = gtk_tree_model_get_path (model, &iter);
scroll = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (view)));
height = GTK_WIDGET (view)->allocation.height;
child_height = GTK_WIDGET (view)->requisition.height;
if (height < child_height) {
gtk_tree_view_get_cell_area (view, path, NULL, &rect);
adj = gtk_scrolled_window_get_vadjustment (scroll);
pos = gtk_adjustment_get_value (adj);
if (rect.y < 0)
pos += rect.y;
else if (rect.y + rect.height > height)
pos += rect.y + rect.height - height;
gtk_adjustment_set_value (adj, pos);
gtk_scrolled_window_set_vadjustment (scroll, adj);
}
gtk_tree_path_free (path);
}
}
static void
font_selected (GtkCList *font_list,
G_GNUC_UNUSED int col,
G_GNUC_UNUSED int row,
G_GNUC_UNUSED GdkEvent *event, FontSelector *fs)
list_init (GtkTreeView* view)
{
gchar *text;
GnmStyle *change;
GtkCellRenderer *renderer;
GtkListStore *store;
GtkTreeViewColumn *column;
gtk_tree_view_set_headers_visible (view, FALSE);
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_tree_view_set_model (view, GTK_TREE_MODEL (store));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (
NULL,
renderer, "text", 0, NULL);
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (view, column);
g_signal_connect (view, "realize", G_CALLBACK (cb_list_adjust), NULL);
}
static void
font_selected (GtkTreeSelection *selection,
FontSelector *fs)
{
gchar *text;
GnmStyle *change;
GtkTreeModel *model;
GtkTreeIter iter;
gtk_clist_get_text (font_list, GPOINTER_TO_INT (font_list->selection->data), 0, &text);
gtk_entry_set_text (GTK_ENTRY (fs->font_name_entry), text);
gtk_tree_selection_get_selected (selection, &model, &iter);
gtk_tree_model_get (model, &iter, 0, &text, -1);
gtk_entry_set_text (GTK_ENTRY (fs->font_name_entry), text);
change = mstyle_new ();
mstyle_set_font_name (change, text);
fs_modify_style (fs, change);
change = mstyle_new ();
mstyle_set_font_name (change, text);
fs_modify_style (fs, change);
}
static void
fs_fill_font_name_list (FontSelector *fs)
{
GList *l;
GList *l;
GtkListStore *store;
GtkTreeIter iter;
list_init (fs->font_name_list);
store = GTK_LIST_STORE (gtk_tree_view_get_model (fs->font_name_list));
for (l = gnumeric_font_family_list; l; l = l->next) {
char *name = l->data;
char *array[1];
array[0] = name;
gtk_clist_append (GTK_CLIST (fs->font_name_list), array);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, l->data, -1);
}
g_signal_connect (
G_OBJECT (fs->font_name_list), "select_row",
G_OBJECT (gtk_tree_view_get_selection (fs->font_name_list)), "changed",
GTK_SIGNAL_FUNC (font_selected), fs);
g_signal_connect (
G_OBJECT (fs->font_name_list), "map",
GTK_SIGNAL_FUNC (list_mapped), NULL);
}
static char const *styles[] = {
......@@ -154,75 +204,99 @@ static char const *styles[] = {
};
static void
style_selected (GtkCList *style_list,
G_GNUC_UNUSED int col, int row,
G_GNUC_UNUSED GdkEvent *event, FontSelector *fs)
style_selected (GtkTreeSelection *selection,
FontSelector *fs)
{
GnmStyle *change = mstyle_new ();
row = GPOINTER_TO_INT (style_list->selection->data);
switch (