[goffice] GoComboText: gone.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GoComboText: gone.
- Date: Sun, 18 Mar 2012 17:15:12 +0000 (UTC)
commit 2e953b6af7c324a44ba180089620ecef0c2309bb
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 18 13:14:08 2012 -0400
GoComboText: gone.
NEWS | 1 +
docs/reference/goffice-0.8-sections.txt | 16 --
goffice/gtk/Makefile.am | 2 -
goffice/gtk/go-action-combo-text.c | 104 +++++----
goffice/gtk/go-combo-text.c | 412 -------------------------------
goffice/gtk/go-combo-text.h | 32 ---
goffice/gtk/go-format-sel.c | 39 ++--
goffice/gtk/goffice-gtk.h | 1 -
po/POTFILES.in | 2 -
9 files changed, 83 insertions(+), 526 deletions(-)
---
diff --git a/NEWS b/NEWS
index aef58eb..f8bcabb 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Morten:
* Fix GOImage fallback for non-GUI case.
* Tweak bold attribute for rich text.
* Fix minor multihead issue with help buttons in dialogs.
+ * Eliminate GoComboText -- use GtkComboBoxText instead.
--------------------------------------------------------------------------
goffice 0.9.2:
diff --git a/docs/reference/goffice-0.8-sections.txt b/docs/reference/goffice-0.8-sections.txt
index 14c8ef6..77686d5 100644
--- a/docs/reference/goffice-0.8-sections.txt
+++ b/docs/reference/goffice-0.8-sections.txt
@@ -968,22 +968,6 @@ go_menu_pixmaps_add_element
</SECTION>
<SECTION>
-<FILE>go-combo-text</FILE>
-<TITLE>GOComboText</TITLE>
-GO_TYPE_COMBO_TEXT
-GO_COMBO_TEXT
-GO_IS_COMBO_TEXT
-GOComboText
-GOComboTextSearch
-go_combo_text_get_type
-go_combo_text_new
-go_combo_text_new_default
-go_combo_text_get_entry
-go_combo_text_set_text
-go_combo_text_add_item
-</SECTION>
-
-<SECTION>
<FILE>go-charmap-sel</FILE>
<TITLE>GOCharmapSel</TITLE>
GO_TYPE_CHARMAP_SEL
diff --git a/goffice/gtk/Makefile.am b/goffice/gtk/Makefile.am
index 5b51f41..f23a03c 100644
--- a/goffice/gtk/Makefile.am
+++ b/goffice/gtk/Makefile.am
@@ -16,7 +16,6 @@ libgoffice_gtk_la_SOURCES = \
go-color-palette.c \
go-combo-color.c \
go-combo-pixmaps.c \
- go-combo-text.c \
\
go-action-combo-color.c \
go-action-combo-pixmaps.c \
@@ -52,7 +51,6 @@ libgoffice_gtk_la_HEADERS = \
go-color-palette.h \
go-combo-color.h \
go-combo-pixmaps.h \
- go-combo-text.h \
\
go-action-combo-color.h \
go-action-combo-pixmaps.h \
diff --git a/goffice/gtk/go-action-combo-text.c b/goffice/gtk/go-action-combo-text.c
index 80b82e4..1fd9256 100644
--- a/goffice/gtk/go-action-combo-text.c
+++ b/goffice/gtk/go-action-combo-text.c
@@ -20,36 +20,18 @@
*/
#include <goffice/goffice-config.h>
#include "go-action-combo-text.h"
-#include "go-combo-box.h"
-#include "go-combo-text.h"
#include "goffice-gtk.h"
#include <goffice/utils/go-glib-extras.h>
#include <gsf/gsf-impl-utils.h>
#include <glib/gi18n-lib.h>
-typedef struct {
- GtkToolItem base;
- GOComboText *combo; /* container has a ref, not us */
-} GOToolComboText;
-typedef GtkToolItemClass GOToolComboTextClass;
-
-#define GO_TYPE_TOOL_COMBO_TEXT (go_tool_combo_text_get_type ())
-#define GO_TOOL_COMBO_TEXT(o) (G_TYPE_CHECK_INSTANCE_CAST (o, GO_TYPE_TOOL_COMBO_TEXT, GOToolComboText))
-#define GO_IS_TOOL_COMBO_TEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE (o, GO_TYPE_TOOL_COMBO_TEXT))
-
-static GType go_tool_combo_text_get_type (void);
-
-static GSF_CLASS (GOToolComboText, go_tool_combo_text,
- NULL, NULL,
- GTK_TYPE_TOOL_ITEM)
-
/*****************************************************************************/
struct _GOActionComboText {
GtkAction base;
GSList *elements;
- char const *largest_elem;
+ char *largest_elem;
char *entry_val;
gboolean case_sensitive;
};
@@ -73,53 +55,70 @@ set_entry_val (GOActionComboText *taction, char const *text)
}
}
-static gint
-g_strcase_equal (gconstpointer s1, gconstpointer s2)
-{
- return !go_utf8_collate_casefold ((const gchar*) s1, (const gchar*) s2);
-}
-
static gboolean
-cb_entry_changed (GOComboText *ct, char const *text, GOActionComboText *taction)
+cb_entry_acticated (GtkEntry *entry, GOActionComboText *taction)
{
+ const char *text = gtk_entry_get_text (entry);
set_entry_val (taction, text);
gtk_action_activate (GTK_ACTION (taction));
return TRUE;
}
+static void
+cb_combo_changed (GtkComboBoxText *combo, GOActionComboText *taction)
+{
+ GtkWidget *entry = gtk_bin_get_child (GTK_BIN (combo));
+ /*
+ * We get the changed signal also when someone is typing in the
+ * entry. We don't want that, so if the entry has focus, ignore
+ * the signal. The entry will send the activate signal itself
+ * when Enter is pressed.
+ */
+ if (entry && !gtk_widget_has_focus (entry))
+ cb_entry_acticated (GTK_ENTRY (entry), taction);
+}
+
static GtkWidget *
go_action_combo_text_create_tool_item (GtkAction *act)
{
GOActionComboText *taction = GO_ACTION_COMBO_TEXT (act);
- GOToolComboText *tool = g_object_new (GO_TYPE_TOOL_COMBO_TEXT, NULL);
+ GtkToolItem *tool = g_object_new
+ (GTK_TYPE_TOOL_ITEM,
+ "visible-vertical", FALSE,
+ NULL);
+ GtkComboBoxText *combo = (GtkComboBoxText *)
+ gtk_combo_box_text_new_with_entry ();
+ GtkEntry *entry;
GSList *ptr;
int w = -1;
- tool->combo = (GOComboText *)go_combo_text_new (taction->case_sensitive ? NULL : g_strcase_equal);
if (taction->largest_elem != NULL)
w = g_utf8_strlen (taction->largest_elem, -1);
for (ptr = taction->elements; ptr != NULL ; ptr = ptr->next) {
- go_combo_text_add_item (tool->combo, ptr->data);
+ const char *s = ptr->data;
+ gtk_combo_box_text_append_text (combo, s);
if (taction->largest_elem == NULL) {
- int tmp = g_utf8_strlen (ptr->data, -1);
+ int tmp = g_utf8_strlen (s, -1);
if (w < tmp)
w = tmp;
}
}
- go_combo_box_set_title (GO_COMBO_BOX (tool->combo),
- _(gtk_action_get_name (act)));
- gtk_entry_set_width_chars (GTK_ENTRY (go_combo_text_get_entry (tool->combo)), w);
- g_object_set (G_OBJECT (tool), "visible-vertical", FALSE, NULL);
-
- go_combo_box_set_relief (GO_COMBO_BOX (tool->combo), GTK_RELIEF_NONE);
- 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 (tool->combo,
- "entry_changed",
- G_CALLBACK (cb_entry_changed), taction);
+ gtk_combo_box_set_title (GTK_COMBO_BOX (combo),
+ _(gtk_action_get_name (act)));
+ entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo)));
+ gtk_entry_set_width_chars (entry, w);
+ gtk_container_add (GTK_CONTAINER (tool), GTK_WIDGET (combo));
+ gtk_widget_show_all (GTK_WIDGET (tool));
+ g_signal_connect_object (entry,
+ "activate",
+ G_CALLBACK (cb_entry_acticated), taction, 0);
+
+ g_signal_connect_object (combo,
+ "changed",
+ G_CALLBACK (cb_combo_changed), taction, 0);
+
return GTK_WIDGET (tool);
}
@@ -159,6 +158,7 @@ static void
go_action_combo_text_finalize (GObject *obj)
{
GOActionComboText *taction = GO_ACTION_COMBO_TEXT (obj);
+ g_free (taction->largest_elem);
g_free (taction->entry_val);
g_slist_free_full (taction->elements, (GDestroyNotify)g_free);
combo_text_parent->finalize (obj);
@@ -234,7 +234,8 @@ go_action_combo_text_add_item (GOActionComboText *taction, char const *item)
void
go_action_combo_text_set_width (GOActionComboText *taction, char const *largest_elem)
{
- taction->largest_elem = largest_elem;
+ g_free (taction->largest_elem);
+ taction->largest_elem = g_strdup (largest_elem);
}
char const *
@@ -259,7 +260,18 @@ go_action_combo_text_set_entry (GOActionComboText *taction, char const *text,
GSList *ptr = gtk_action_get_proxies (GTK_ACTION (taction));
set_entry_val (taction, text);
- for ( ; ptr != NULL ; ptr = ptr->next)
- if (GO_IS_TOOL_COMBO_TEXT (ptr->data))
- go_combo_text_set_text (GO_TOOL_COMBO_TEXT (ptr->data)->combo, text, dir);
+ for ( ; ptr != NULL ; ptr = ptr->next) {
+ GObject *proxy = ptr->data;
+ GtkWidget *combo = GTK_IS_TOOL_ITEM (proxy)
+ ? gtk_bin_get_child (GTK_BIN (proxy))
+ : NULL;
+ GtkWidget *entry = combo && GTK_IS_COMBO_BOX_TEXT (combo)
+ ? gtk_bin_get_child (GTK_BIN (combo))
+ : NULL;
+ if (entry && GTK_IS_ENTRY (entry)) {
+ gtk_action_block_activate (GTK_ACTION (taction));
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
+ gtk_action_unblock_activate (GTK_ACTION (taction));
+ }
+ }
}
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index a6a6ee1..061b9c3 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -1218,14 +1218,15 @@ cb_format_list_select (GtkTreeSelection *selection, GOFormatSel *gfs)
}
static gboolean
-cb_format_currency_select (G_GNUC_UNUSED GtkWidget *ct,
- char * new_text, GOFormatSel *gfs)
+cb_format_currency_select (GtkComboBoxText *combo, GOFormatSel *gfs)
{
int i;
+ char *new_text = gtk_combo_box_text_get_active_text (combo);
- /* ignore the clear while assigning a new value */
- if (!gfs->enable_edit || new_text == NULL || *new_text == '\0')
+ if (!gfs->enable_edit) {
+ g_free (new_text);
return FALSE;
+ }
for (i = 0; _go_format_currencies[i].symbol != NULL ; ++i) {
GOFormatCurrency const *ci = _go_format_currencies + i;
@@ -1240,6 +1241,8 @@ cb_format_currency_select (G_GNUC_UNUSED GtkWidget *ct,
draw_format_preview (gfs, TRUE);
+ g_free (new_text);
+
return TRUE;
}
@@ -1448,7 +1451,7 @@ nfs_init (GOFormatSel *gfs)
GtkWidget *tmp;
GtkTreeViewColumn *column;
- GOComboText *combo;
+ GtkComboBoxText *combo;
char const *name;
int i;
GOFormatFamily page;
@@ -1517,7 +1520,7 @@ nfs_init (GOFormatSel *gfs)
gfs->format.widget[i] = tmp;
}
- gfs->format.widget[F_SYMBOL] = go_combo_text_new (NULL);
+ gfs->format.widget[F_SYMBOL] = gtk_combo_box_text_new_with_entry ();
gtk_widget_hide (gfs->format.widget[F_SYMBOL]);
/* set minimum heights */
@@ -1618,17 +1621,19 @@ nfs_init (GOFormatSel *gfs)
G_CALLBACK (cb_format_list_select), gfs);
/* Setup handler Currency & Accounting currency symbols */
- combo = GO_COMBO_TEXT (gfs->format.widget[F_SYMBOL]);
+ combo = GTK_COMBO_BOX_TEXT (gfs->format.widget[F_SYMBOL]);
if (combo != NULL) {
GSList *ptr, *l = NULL;
const char *desc;
+ GtkEntry *entry =
+ GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo)));
for (i = 0; _go_format_currencies[i].symbol != NULL ; ++i)
l = g_slist_prepend (l, _((gchar *)_go_format_currencies[i].description));
l = g_slist_sort (l, funny_currency_order);
for (ptr = l; ptr != NULL ; ptr = ptr->next)
- go_combo_text_add_item (combo, ptr->data);
+ gtk_combo_box_text_append_text (combo, ptr->data);
g_slist_free (l);
desc = gfs->format.details.currency
@@ -1636,9 +1641,12 @@ nfs_init (GOFormatSel *gfs)
: NULL;
if (!desc)
desc = N_("None");
- go_combo_text_set_text (combo, _(desc),
- GO_COMBO_TEXT_FROM_TOP);
- g_signal_connect (G_OBJECT (combo), "entry_changed",
+ gtk_entry_set_text (entry, _(desc));
+ g_object_set (entry,
+ "editable", FALSE,
+ "can-focus", FALSE,
+ NULL);
+ g_signal_connect (G_OBJECT (combo), "changed",
G_CALLBACK (cb_format_currency_select), gfs);
gtk_label_set_mnemonic_widget (
GTK_LABEL (gtk_builder_get_object (gfs->gui, "format_symbol_label")),
@@ -1787,7 +1795,7 @@ void
go_format_sel_set_style_format (GOFormatSel *gfs,
GOFormat const *style_format)
{
- GOComboText *combo;
+ GtkComboBoxText *combo;
g_return_if_fail (GO_IS_FORMAT_SEL (gfs));
g_return_if_fail (style_format != NULL);
@@ -1799,15 +1807,16 @@ go_format_sel_set_style_format (GOFormatSel *gfs,
study_format (gfs->format.spec, &gfs->format.details);
- combo = GO_COMBO_TEXT (gfs->format.widget[F_SYMBOL]);
+ combo = GTK_COMBO_BOX_TEXT (gfs->format.widget[F_SYMBOL]);
if (gfs->format.details.currency) {
const char *desc = gfs->format.details.currency
? gfs->format.details.currency->description
: NULL;
+ GtkEntry *entry =
+ GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo)));
if (!desc)
desc = N_("None");
- go_combo_text_set_text (combo, _(desc),
- GO_COMBO_TEXT_FROM_TOP);
+ gtk_entry_set_text (entry, _(desc));
}
set_format_category_menu_from_style (gfs);
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index e9a91ae..6012f29 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -38,7 +38,6 @@
#include <goffice/gtk/go-combo-box.h>
#include <goffice/gtk/go-combo-color.h>
#include <goffice/gtk/go-combo-pixmaps.h>
-#include <goffice/gtk/go-combo-text.h>
#include <goffice/gtk/go-font-sel.h>
#include <goffice/gtk/go-format-sel.h>
#include <goffice/gtk/go-gradient-selector.h>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bda1dfe..5767d3b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -153,8 +153,6 @@ goffice/gtk/go-combo-color.c
goffice/gtk/go-combo-color.h
goffice/gtk/go-combo-pixmaps.c
goffice/gtk/go-combo-pixmaps.h
-goffice/gtk/go-combo-text.c
-goffice/gtk/go-combo-text.h
goffice/gtk/go-font-sel.c
[type: gettext/glade]goffice/gtk/go-font-sel.ui
goffice/gtk/go-font-sel.h
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]