Begin to implement grab_focus() and editable_enters() in order

to improve the UI.  Currently only string types have been updated.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6901 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2002-05-23 22:57:52 +00:00
parent c206acf6fe
commit ee6db584e2
4 changed files with 79 additions and 6 deletions

View File

@ -85,6 +85,7 @@ struct _crit_data {
GtkWidget * elemwidget;
GtkWidget * container;
GtkWidget * button;
GnomeDialog * dialog;
};
static void search_clear_criteria (GNCSearchWindow *sw);
@ -542,8 +543,6 @@ remove_element (GtkWidget *button, GNCSearchWindow *sw)
/* and from the display */
gtk_container_remove (GTK_CONTAINER (sw->criteria_table), element);
gtk_container_remove (GTK_CONTAINER (sw->criteria_table), button);
gtk_object_destroy (GTK_OBJECT (element));
gtk_object_destroy (GTK_OBJECT (button));
}
static void
@ -592,12 +591,17 @@ option_activate (GtkMenuItem *item, struct _crit_data *data)
(gnc_search_param_get_param_type (param));
data->element = newelem;
data->elemwidget = gnc_search_core_type_get_widget (newelem);
if (data->elemwidget)
if (data->elemwidget) {
gtk_box_pack_start (GTK_BOX (data->container), data->elemwidget,
FALSE, FALSE, 0);
}
/* Make sure it's visible */
gtk_widget_show_all (data->container);
/* And grab focus */
gnc_search_core_type_grab_focus (newelem);
gnc_search_core_type_editable_enters (newelem, data->dialog);
}
static void
@ -624,6 +628,7 @@ get_element_widget (GNCSearchWindow *sw, GNCSearchCoreType *element)
data = g_new0 (struct _crit_data, 1);
data->element = element;
data->dialog = GNOME_DIALOG (sw->dialog);
hbox = gtk_hbox_new (FALSE, 0);
/* only set to automaticaly clean up the memory */
@ -691,6 +696,9 @@ gnc_search_dialog_add_criterion (GNCSearchWindow *sw)
rows = GTK_TABLE (sw->criteria_table)->nrows;
gtk_table_resize (GTK_TABLE (sw->criteria_table), rows+1, 2);
attach_element (w, sw, rows);
gnc_search_core_type_grab_focus (new);
gnc_search_core_type_editable_enters (new, GNOME_DIALOG (sw->dialog));
}
}
@ -795,9 +803,6 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw)
box = glade_xml_get_widget (xml, "type_menu_box");
gtk_box_pack_start (GTK_BOX (box), omenu, FALSE, FALSE, 3);
/* add the first criterion */
gnc_search_dialog_add_criterion (sw);
/* if there's no original query, make the narrow, add, delete
* buttons inaccessible */
sw->new_rb = glade_xml_get_widget (xml, "new_search_radiobutton");
@ -820,6 +825,9 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw)
if (!sw->new_item_cb)
gtk_widget_hide_all (new_item_button);
/* add the first criterion */
gnc_search_dialog_add_criterion (sw);
/* Connect XML signals */
glade_xml_signal_connect_data (xml, "gnc_ui_search_type_cb",

View File

@ -36,6 +36,8 @@
#include "search-boolean.h"
#include "search-account.h"
static void grab_focus (GNCSearchCoreType *fe);
static void editable_enters (GNCSearchCoreType *fe, GnomeDialog *dialog);
static gboolean validate (GNCSearchCoreType *fe);
static void gnc_search_core_type_class_init (GNCSearchCoreTypeClass *class);
@ -90,6 +92,8 @@ gnc_search_core_type_class_init (GNCSearchCoreTypeClass *class)
/* override methods */
class->validate = validate;
class->grab_focus = grab_focus;
class->editable_enters = editable_enters;
/* signals */
@ -124,6 +128,19 @@ gnc_search_core_type_new (void)
return o;
}
void
gnc_search_core_type_editable_enters (GNCSearchCoreType *fe,
GnomeDialog *dialog)
{
return ((GNCSearchCoreTypeClass *)((GtkObject *)fe)->klass)->editable_enters (fe, dialog);
}
void
gnc_search_core_type_grab_focus (GNCSearchCoreType *fe)
{
return ((GNCSearchCoreTypeClass *)((GtkObject *)fe)->klass)->grab_focus (fe);
}
gboolean
gnc_search_core_type_validate (GNCSearchCoreType *fe)
{
@ -207,6 +224,18 @@ validate (GNCSearchCoreType *fe)
return TRUE;
}
static void
grab_focus (GNCSearchCoreType *fe)
{
return;
}
static void
editable_enters (GNCSearchCoreType *fe, GnomeDialog *dialog)
{
return;
}
void
gnc_search_core_register_type (const char *type_name, GNCSearchCoreNew fcn)
{

View File

@ -43,6 +43,9 @@ struct _GNCSearchCoreTypeClass {
GtkObjectClass parent_class;
/* virtual methods */
void (*grab_focus) (GNCSearchCoreType *fe);
void (*editable_enters) (GNCSearchCoreType *fe,
GnomeDialog *dialog);
gboolean (*validate) (GNCSearchCoreType *fe);
GNCSearchCoreType * (*clone) (GNCSearchCoreType *fe);
GtkWidget * (*get_widget) (GNCSearchCoreType *);
@ -59,6 +62,9 @@ GNCSearchCoreType * gnc_search_core_type_new (void);
GNCSearchCoreType * gnc_search_core_type_new_type_name (const char *type);
/* methods */
void gnc_search_core_type_grab_focus (GNCSearchCoreType *fe);
void gnc_search_core_type_editable_enters (GNCSearchCoreType *fe,
GnomeDialog *dialog);
gboolean gnc_search_core_type_validate (GNCSearchCoreType *fe);
GNCSearchCoreType * gnc_search_core_type_clone (GNCSearchCoreType *fe);
GtkWidget * gnc_search_core_type_get_widget (GNCSearchCoreType *fe);

View File

@ -32,6 +32,7 @@
#define d(x)
static void grab_focus (GNCSearchCoreType *fe);
static GNCSearchCoreType *clone(GNCSearchCoreType *fe);
static gboolean validate (GNCSearchCoreType *fe);
static GtkWidget *get_widget(GNCSearchCoreType *fe);
@ -44,6 +45,7 @@ static void gnc_search_string_finalise (GtkObject *obj);
#define _PRIVATE(x) (((GNCSearchString *)(x))->priv)
struct _GNCSearchStringPrivate {
GtkWidget *entry;
};
static GNCSearchCoreTypeClass *parent_class;
@ -88,6 +90,7 @@ gnc_search_string_class_init (GNCSearchStringClass *class)
object_class->finalize = gnc_search_string_finalise;
/* override methods */
gnc_search_core_type->grab_focus = grab_focus;
gnc_search_core_type->validate = validate;
gnc_search_core_type->get_widget = get_widget;
gnc_search_core_type->get_predicate = get_predicate;
@ -284,6 +287,32 @@ make_menu (GNCSearchCoreType *fe)
return opmenu;
}
static void
grab_focus (GNCSearchCoreType *fe)
{
GNCSearchString *fi = (GNCSearchString *)fe;
g_return_if_fail (fi);
g_return_if_fail (IS_GNCSEARCH_STRING (fi));
if (fi->priv->entry)
gtk_widget_grab_focus (fi->priv->entry);
}
static void
editable_enters (GNCSearchCoreType *fe, GnomeDialog *dialog)
{
GNCSearchString *fi = (GNCSearchString *)fe;
g_return_if_fail (fi);
g_return_if_fail (IS_GNCSEARCH_STRING (fi));
g_return_if_fail (dialog);
g_return_if_fail (IS_GNOME_DIALOG (dialog));
if (fi->priv->entry)
gnome_dialog_editable_enters (GTK_EDITABLE (fi->priv->entry), dialog);
}
static GtkWidget *
get_widget (GNCSearchCoreType *fe)
{
@ -305,6 +334,7 @@ get_widget (GNCSearchCoreType *fe)
gtk_entry_set_text (GTK_ENTRY (entry), fi->value);
gtk_signal_connect (GTK_OBJECT (entry), "changed", entry_changed, fe);
gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 3);
fi->priv->entry = entry;
/* Build and connect the toggle button */
toggle = gtk_toggle_button_new_with_label (_("Case Insensitive?"));