Completed the dialer/code entry backspace code and icon update
This commit is contained in:
parent
4856648c16
commit
4ed92602c7
37
src/phone.c
37
src/phone.c
@ -738,9 +738,21 @@ void phone_code_enter(Phone * phone)
|
||||
void phone_code_backspace(Phone * phone)
|
||||
{
|
||||
int pos;
|
||||
#if !GTK_CHECK_VERSION(2, 14, 0)
|
||||
char const * s;
|
||||
#endif
|
||||
|
||||
if((pos = gtk_editable_get_position(GTK_EDITABLE(phone->en_entry)))
|
||||
< 1)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 14, 0)
|
||||
pos = gtk_entry_get_text_length(GTK_ENTRY(phone->en_entry));
|
||||
#else
|
||||
s = gtk_entry_get_text(GTK_ENTRY(phone->en_entry));
|
||||
pos = strlen(s);
|
||||
#endif
|
||||
}
|
||||
if(pos < 1)
|
||||
return;
|
||||
gtk_editable_delete_text(GTK_EDITABLE(phone->en_entry), pos - 1, pos);
|
||||
}
|
||||
@ -934,9 +946,21 @@ int phone_dialer_append(Phone * phone, char character)
|
||||
void phone_dialer_backspace(Phone * phone)
|
||||
{
|
||||
int pos;
|
||||
#if !GTK_CHECK_VERSION(2, 14, 0)
|
||||
char const * s;
|
||||
#endif
|
||||
|
||||
if((pos = gtk_editable_get_position(GTK_EDITABLE(phone->di_entry)))
|
||||
< 1)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 14, 0)
|
||||
pos = gtk_entry_get_text_length(GTK_ENTRY(phone->di_entry));
|
||||
#else
|
||||
s = gtk_entry_get_text(GTK_ENTRY(phone->di_entry));
|
||||
pos = strlen(s);
|
||||
#endif
|
||||
}
|
||||
if(pos < 1)
|
||||
return;
|
||||
gtk_editable_delete_text(GTK_EDITABLE(phone->di_entry), pos - 1, pos);
|
||||
}
|
||||
@ -1910,16 +1934,15 @@ static void _show_code_window(Phone * phone)
|
||||
gtk_widget_modify_font(phone->en_entry, phone->bold);
|
||||
g_signal_connect_swapped(phone->en_entry, "activate", G_CALLBACK(
|
||||
on_phone_code_enter), phone);
|
||||
/* FIXME trigger a backspace instead (and use adequate icon) */
|
||||
#if GTK_CHECK_VERSION(2, 16, 0)
|
||||
gtk_entry_set_icon_from_stock(GTK_ENTRY(phone->en_entry),
|
||||
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
|
||||
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_GO_BACK); /* XXX */
|
||||
g_signal_connect_swapped(phone->en_entry, "icon-press", G_CALLBACK(
|
||||
on_phone_code_backspace), phone);
|
||||
#else
|
||||
widget = gtk_button_new();
|
||||
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name(
|
||||
"edit-undo", GTK_ICON_SIZE_BUTTON));
|
||||
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_stock(
|
||||
GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
|
||||
gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
|
||||
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
|
||||
on_phone_code_backspace), phone);
|
||||
@ -2078,13 +2101,13 @@ static void _show_dialer_window(Phone * phone)
|
||||
on_phone_dialer_changed), phone);
|
||||
#if GTK_CHECK_VERSION(2, 16, 0)
|
||||
gtk_entry_set_icon_from_stock(GTK_ENTRY(phone->di_entry),
|
||||
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
|
||||
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_GO_BACK); /* XXX */
|
||||
g_signal_connect_swapped(phone->di_entry, "icon-press", G_CALLBACK(
|
||||
on_phone_dialer_backspace), phone);
|
||||
#else
|
||||
widget = gtk_button_new();
|
||||
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name(
|
||||
"edit-undo", GTK_ICON_SIZE_BUTTON));
|
||||
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_stock(
|
||||
GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
|
||||
gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
|
||||
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
|
||||
on_phone_dialer_backspace), phone);
|
||||
|
Loading…
Reference in New Issue
Block a user