diff --git a/src/callbacks.c b/src/callbacks.c index 97ab28b..3e91c05 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -219,6 +219,22 @@ void on_phone_dialer_call(gpointer data) } +/* on_phone_dialer_changed */ +void on_phone_dialer_changed(GtkWidget * widget, gpointer data) +{ + Phone * phone = data; + gchar * text; + + text = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1); + if(strcmp(text, "*#06#") == 0) + { + phone_event_trigger(phone, MODEM_EVENT_TYPE_MODEL); + phone_dialer_clear(phone); + } + g_free(text); +} + + /* on_phone_dialer_clear */ void on_phone_dialer_clear(gpointer data) { @@ -249,34 +265,6 @@ void on_phone_dialer_hangup(gpointer data) } -#if GTK_CHECK_VERSION(2, 18, 0) -/* on_phone_dialer_text_deleted */ -void on_phone_dialer_text_deleted(GtkEntryBuffer * buffer, guint position, - guint n_chars, gpointer data) -{ - Phone * phone = data; - - on_phone_dialer_text_inserted(buffer, 0, NULL, 0, phone); -} - - -/* on_phone_dialer_text_inserted */ -void on_phone_dialer_text_inserted(GtkEntryBuffer * buffer, guint position, - gchar * chars, guint n_chars, gpointer data) -{ - Phone * phone = data; - char const * text; - - text = gtk_entry_buffer_get_text(buffer); - if(strcmp(text, "*#06#") == 0) - { - phone_event_trigger(phone, MODEM_EVENT_TYPE_MODEL); - phone_dialer_clear(phone); - } -} -#endif - - /* logs */ /* on_phone_logs_activated */ void on_phone_logs_activated(gpointer data) diff --git a/src/callbacks.h b/src/callbacks.h index 6d68c3b..56185f4 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -50,15 +50,10 @@ void on_phone_contacts_write(gpointer data); /* dialer */ void on_phone_dialer_call(gpointer data); +void on_phone_dialer_changed(GtkWidget * widget, gpointer data); void on_phone_dialer_clear(gpointer data); void on_phone_dialer_clicked(GtkWidget * widget, gpointer data); void on_phone_dialer_hangup(gpointer data); -#if GTK_CHECK_VERSION(2, 18, 0) -void on_phone_dialer_text_deleted(GtkEntryBuffer * buffer, guint position, - guint n_chars, gpointer data); -void on_phone_dialer_text_inserted(GtkEntryBuffer * buffer, guint position, - gchar * chars, guint n_chars, gpointer data); -#endif /* logs */ void on_phone_logs_activated(gpointer data); diff --git a/src/phone.c b/src/phone.c index ebe64e5..4fcea2a 100644 --- a/src/phone.c +++ b/src/phone.c @@ -1953,9 +1953,6 @@ static void _show_dialer_window(Phone * phone) GtkWidget * vbox; GtkWidget * hbox; GtkWidget * widget; -#if GTK_CHECK_VERSION(2, 18, 0) - GtkEntryBuffer * buf; -#endif phone->di_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); #if GTK_CHECK_VERSION(2, 6, 0) @@ -1972,18 +1969,13 @@ static void _show_dialer_window(Phone * phone) gtk_widget_modify_font(phone->di_entry, phone->bold); g_signal_connect_swapped(G_OBJECT(phone->di_entry), "activate", G_CALLBACK(on_phone_dialer_call), phone); + g_signal_connect(phone->di_entry, "changed", G_CALLBACK( + 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); g_signal_connect_swapped(phone->di_entry, "icon-press", G_CALLBACK( on_phone_dialer_clear), phone); -# if GTK_CHECK_VERSION(2, 18, 0) - buf = gtk_entry_get_buffer(GTK_ENTRY(phone->di_entry)); - g_signal_connect(buf, "deleted-text", G_CALLBACK( - on_phone_dialer_text_deleted), phone); - g_signal_connect(buf, "inserted-text", G_CALLBACK( - on_phone_dialer_text_inserted), phone); -# endif #endif gtk_box_pack_start(GTK_BOX(hbox), phone->di_entry, TRUE, TRUE, 0); widget = gtk_button_new();