Commit 980b6a03 authored by Jon K Hellan's avatar Jon K Hellan Committed by Jon Kåre Hellan

Set zoom using gtk_combo_text_set_text. (change_zoom_in_current_sheet_cb):

2000-06-08  Jon K Hellan  <hellan@acm.org>

	* src/workbook.c (change_displayed_zoom_cb): Set zoom using
	gtk_combo_text_set_text.
	(change_zoom_in_current_sheet_cb): Check that current sheet is non
	NULL.
	(workbook_zoom_feedback_set): Block callbacks while changing
	displayed zoom.

	* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
	Drop the empty font name - that was needed in the option menu, but
	not now we're using a combo box.  Ignore nameless fonts in
	gnumeric_font_family_list. (We were displaying *two* blank lines
	at the top - now we've got rid of both.)
	(workbook_feedback_set): Set font size and font name using
	gtk_combo_text_set_text, which also selects the item in the combo
	list if present.  Get rid of hack to select font name in list -
	this is now done in the widget.
	(workbook_feedback_set):

	* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.

2000-06-08  Jon K Hellan  <hellan@acm.org>

	* gtk-combo-text.[ch] (gtk_combo_text_set_text): New function. Set
	displayed text, and select it in the list if present.

	* gtk-combo-text.c (cb_remove_from_hash): New function. Remove
	list item widget from hash when item is deleted.
	(gtk_combo_text_add_item): Store list item widget in hash instead
	of list item position. This way, it works even if items are
	deleted.
parent ca016474
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* src/workbook.c (change_displayed_zoom_cb): Set zoom using
gtk_combo_text_set_text.
(change_zoom_in_current_sheet_cb): Check that current sheet is non
NULL.
(workbook_zoom_feedback_set): Block callbacks while changing
displayed zoom.
* src/workbook-format-toolbar.c (workbook_create_format_toolbar):
Drop the empty font name - that was needed in the option menu, but
not now we're using a combo box. Ignore nameless fonts in
gnumeric_font_family_list. (We were displaying *two* blank lines
at the top - now we've got rid of both.)
(workbook_feedback_set): Set font size and font name using
gtk_combo_text_set_text, which also selects the item in the combo
list if present. Get rid of hack to select font name in list -
this is now done in the widget.
(workbook_feedback_set):
* src/sheet.c (sheet_set_zoom_factor): Check that sheet isn't NULL.
2000-06-07 Morten Welinder <terra@diku.dk>
* src/sort.c (sort_contents): Use the C-library's qosrt.
......
......@@ -459,10 +459,13 @@ sheet_set_zoom_factor (Sheet *sheet, double const f)
{
GList *l, *cl;
struct resize_colrow closure;
double factor, diff;
g_return_if_fail (sheet != NULL);
/* Bound zoom between 10% and 500% */
double const factor = (f < .1) ? .1 : ((f > 5.) ? 5. : f);
double const diff = sheet->last_zoom_factor_used - factor;
factor = (f < .1) ? .1 : ((f > 5.) ? 5. : f);
diff = sheet->last_zoom_factor_used - factor;
if (-.0001 < diff && diff < .0001)
return;
......
2000-06-08 Jon K Hellan <hellan@acm.org>
* gtk-combo-text.[ch] (gtk_combo_text_set_text): New function. Set
displayed text, and select it in the list if present.
* gtk-combo-text.c (cb_remove_from_hash): New function. Remove
list item widget from hash when item is deleted.
(gtk_combo_text_add_item): Store list item widget in hash instead
of list item position. This way, it works even if items are
deleted.
2000-05-29 Jody Goldberg <jgoldberg@home.com>
* gtk-combo-stack.c (gtk_combo_stack_construct) : The button can not
......
......@@ -108,6 +108,35 @@ gtk_combo_text_select_item (GtkComboText *ct, int elem)
gtk_list_select_item (GTK_LIST(ct->list), elem);
}
void
gtk_combo_text_set_text (GtkComboText *ct, const gchar *text)
{
GtkWidget *child;
gtk_entry_set_text (GTK_ENTRY (ct->entry), text);
gtk_signal_handler_block_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (list_select_cb),
(gpointer) ct);
gtk_signal_handler_block_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (list_unselect_cb),
(gpointer) ct);
gtk_list_unselect_all (GTK_LIST (ct->list));
child = GTK_WIDGET (g_hash_table_lookup (ct->elements,
(gconstpointer) text));
if (child && GTK_IS_WIDGET (child)) {
gtk_list_select_child (GTK_LIST (ct->list), child);
gtk_widget_grab_focus (child);
}
gtk_signal_handler_unblock_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (list_select_cb),
(gpointer) ct);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (ct->list),
GTK_SIGNAL_FUNC (list_unselect_cb),
(gpointer) ct);
}
/*
* 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
......@@ -156,6 +185,18 @@ cb_pop_down (GtkWidget *w, GtkWidget *pop_down, gpointer dummy)
return FALSE;
}
static void
cb_remove_from_hash (GtkWidget *child, gpointer data)
{
GtkComboText *ct = GTK_COMBO_TEXT (data);
gchar *value;
if (ct->elements) {
value = gtk_object_get_data (GTK_OBJECT (child), "value");
g_hash_table_remove (ct->elements, value);
}
}
void
gtk_combo_text_add_item (GtkComboText *ct,
const gchar *item,
......@@ -170,8 +211,6 @@ gtk_combo_text_add_item (GtkComboText *ct,
value = item;
value_copy = g_strdup (value);
g_hash_table_insert (ct->elements, (gpointer)value_copy,
GINT_TO_POINTER (g_hash_table_size (ct->elements)));
listitem = gtk_list_item_new_with_label (item);
gtk_widget_show (listitem);
......@@ -190,6 +229,13 @@ gtk_combo_text_add_item (GtkComboText *ct,
gtk_container_add (GTK_CONTAINER (ct->list),
listitem);
g_hash_table_insert (ct->elements, (gpointer)value_copy,
(gpointer) listitem);
gtk_signal_connect (GTK_OBJECT (listitem), "destroy",
GTK_SIGNAL_FUNC (cb_remove_from_hash),
(gpointer) ct);
}
static void
......
......@@ -32,6 +32,8 @@ GtkWidget *gtk_combo_text_new(gboolean const is_scrolled);
void gtk_combo_text_select_item (GtkComboText *combo_text,
int elem);
void gtk_combo_text_set_text (GtkComboText *combo_text,
const gchar *text);
void gtk_combo_text_add_item (GtkComboText *combo_text,
const gchar *item,
const gchar *value);
......
......@@ -614,15 +614,16 @@ workbook_create_format_toolbar (Workbook *wb)
gtk_combo_box_set_title (GTK_COMBO_BOX (fontsel), _("Font"));
gtk_container_set_border_width (GTK_CONTAINER (fontsel), 0);
/* An empty item for the case of no font that applies */
gtk_combo_text_add_item (GTK_COMBO_TEXT (fontsel), "", "");
len = 0;
for (l = gnumeric_font_family_list; l; l = l->next){
int tmp = gdk_string_measure (entry->style->font, l->data);
if (tmp > len)
len = tmp;
gtk_combo_text_add_item(GTK_COMBO_TEXT (fontsel), l->data, l->data);
if (l->data) { /* Don't include empty fonts in list. */
int tmp = gdk_string_measure (entry->style->font,
l->data);
if (tmp > len)
len = tmp;
gtk_combo_text_add_item(GTK_COMBO_TEXT (fontsel),
l->data, l->data);
}
}
/* Set a reasonable default width */
......@@ -765,7 +766,6 @@ workbook_feedback_set (Workbook *wb, MStyle *style)
GnumericToolbar *toolbar = GNUMERIC_TOOLBAR (wb->priv->format_toolbar);
GtkComboText *fontsel = GTK_COMBO_TEXT (wb->priv->font_name_selector);
GtkComboText *fontsize= GTK_COMBO_TEXT (wb->priv->font_size_selector);
gboolean font_set;
char size_str [40];
g_return_if_fail (wb != NULL);
......@@ -804,21 +804,13 @@ workbook_feedback_set (Workbook *wb, MStyle *style)
/* Do no update the font when we update the status display */
gtk_signal_handler_block_by_func (GTK_OBJECT (fontsize->entry),
&change_font_size_in_selection_cmd, wb);
gtk_entry_set_text (GTK_ENTRY(fontsize->entry), size_str);
gtk_combo_text_set_text (fontsize, size_str);
/* Restore callback */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (fontsize->entry),
&change_font_size_in_selection_cmd, wb);
/*
* hack: we try to find the key "gnumeric-index" in the
* GnomeFont object, this key represents the index of the
* font name on the Optionmenu we have.
*
* If this is not set, then we compute it
*/
font_set = FALSE;
g_return_if_fail (mstyle_is_element_set (style, MSTYLE_FONT_NAME));
/* Do no update the font when we update the status display */
......@@ -827,38 +819,11 @@ workbook_feedback_set (Workbook *wb, MStyle *style)
{
const char *font_name = mstyle_get_font_name (style);
int np = 0;
wb->priv->current_font_name = font_name;
/*
* We need the cache again sometime for performance on
* systems with lots of fonts.
*/
/* np = gtk_object_get_data ((GtkObject *)font, "gnumeric-idx");
if (np == NULL)*/ {
GList *l;
int idx = 0;
for (l = gnumeric_font_family_list; l; l = l->next, idx++) {
char *f = l->data;
if (strcmp (f, font_name) == 0) {
np = idx;
/* gtk_object_set_data ((GtkObject *) font,
"gnumeric-idx", np);*/
break;
}
}
}
/*
* +1 means, skip over the "undefined font" element
*/
gtk_combo_text_select_item (fontsel, np+1);
font_set = TRUE;
gtk_combo_text_set_text (fontsel, font_name);
}
if (!font_set)
gtk_combo_text_select_item (fontsel, 0);
/* Reenable the status display */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (fontsel->entry),
......
......@@ -2442,8 +2442,7 @@ change_displayed_zoom_cb (GtkObject *unused, Sheet* sheet, gpointer data)
str = g_strdup_printf("%d%%", factor);
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO_TEXT (combo)->entry),
str);
gtk_combo_text_set_text (GTK_COMBO_TEXT (combo), str);
g_free (str);
}
......@@ -2451,8 +2450,13 @@ change_displayed_zoom_cb (GtkObject *unused, Sheet* sheet, gpointer data)
static void
change_zoom_in_current_sheet_cb (GtkWidget *caller, Workbook *wb)
{
int factor = atoi (gtk_entry_get_text (GTK_ENTRY (caller)));
sheet_set_zoom_factor(wb->current_sheet, (double)factor / 100);
int factor;
if (!wb->current_sheet)
return;
factor = atoi (gtk_entry_get_text (GTK_ENTRY (caller)));
sheet_set_zoom_factor (wb->current_sheet, (double) factor / 100);
/* Restore the focus to the sheet */
workbook_focus_current_sheet (wb);
......@@ -2466,7 +2470,17 @@ workbook_zoom_feedback_set (Workbook *wb, double zoom_factor)
{
g_return_if_fail (wb->current_sheet);
/* Do no update the zoom when we update the status display */
gtk_signal_handler_block_by_func
(GTK_OBJECT (GTK_COMBO_TEXT (wb->priv->zoom_entry)->entry),
change_zoom_in_current_sheet_cb, wb);
change_displayed_zoom_cb (NULL, wb->current_sheet, wb);
/* Restore callback */
gtk_signal_handler_unblock_by_func
(GTK_OBJECT (GTK_COMBO_TEXT (wb->priv->zoom_entry)->entry),
change_zoom_in_current_sheet_cb, 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