From 0c307ede9ddaf40d33a0428b91e31b730073024a Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 25 Feb 2013 01:46:42 +0100 Subject: [PATCH] Added a secondary icon to a couple Gtk+ entries (to clear the text) --- src/callbacks.c | 11 ++++++++++- src/callbacks.h | 3 ++- src/phone.c | 30 +++++++++++++++++++++++++++--- src/phone.h | 1 + 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/callbacks.c b/src/callbacks.c index 49e32e2..01fca24 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2012 Pierre Pronchery */ +/* Copyright (c) 2010-2013 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Phone */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -219,6 +219,15 @@ void on_phone_dialer_call(gpointer data) } +/* on_phone_dialer_clear */ +void on_phone_dialer_clear(gpointer data) +{ + Phone * phone = data; + + phone_dialer_clear(phone); +} + + /* on_phone_dialer_clicked */ void on_phone_dialer_clicked(GtkWidget * widget, gpointer data) { diff --git a/src/callbacks.h b/src/callbacks.h index 48cc271..a316cb0 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2012 Pierre Pronchery */ +/* Copyright (c) 2010-2013 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Phone */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +50,7 @@ void on_phone_contacts_write(gpointer data); /* dialer */ void on_phone_dialer_call(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); diff --git a/src/phone.c b/src/phone.c index e6369ca..89e7ef0 100644 --- a/src/phone.c +++ b/src/phone.c @@ -1,6 +1,6 @@ /* $Id$ */ static char _copyright[] = -"Copyright (c) 2010-2012 DeforaOS Project "; +"Copyright (c) 2010-2013 DeforaOS Project "; /* This file is part of DeforaOS Desktop Phone */ static char const _license[] = "This program is free software: you can redistribute it and/or modify\n" @@ -903,12 +903,21 @@ void phone_dialer_call(Phone * phone, char const * number) } +/* phone_dialer_clear */ +void phone_dialer_clear(Phone * phone) +{ + if(phone->di_window != NULL) + gtk_entry_set_text(GTK_ENTRY(phone->di_entry), ""); +} + + /* phone_dialer_hangup */ void phone_dialer_hangup(Phone * phone) { phone_call_hangup(phone); - if(phone->di_window != NULL) - gtk_entry_set_text(GTK_ENTRY(phone->di_entry), ""); +#if !GTK_CHECK_VERSION(2, 16, 0) + phone_dialer_clear(phone); +#endif } @@ -1746,7 +1755,14 @@ static void _show_code_window(Phone * phone) gtk_widget_modify_font(phone->en_entry, phone->bold); g_signal_connect_swapped(G_OBJECT(phone->en_entry), "activate", G_CALLBACK(on_phone_code_enter), phone); +#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); + g_signal_connect_swapped(G_OBJECT(phone->en_entry), "icon-press", + G_CALLBACK(on_phone_code_clear), phone); +#endif gtk_box_pack_start(GTK_BOX(hbox), phone->en_entry, TRUE, TRUE, 0); +#if !GTK_CHECK_VERSION(2, 16, 0) widget = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name( "edit-undo", GTK_ICON_SIZE_BUTTON)); @@ -1754,6 +1770,7 @@ static void _show_code_window(Phone * phone) g_signal_connect_swapped(G_OBJECT(widget), "clicked", G_CALLBACK(on_phone_code_clear), phone); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); +#endif gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); widget = _phone_create_dialpad(phone, GTK_STOCK_OK, _("Enter"), G_CALLBACK(on_phone_code_enter), @@ -1895,6 +1912,12 @@ 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); +#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(G_OBJECT(phone->di_entry), "icon-press", + G_CALLBACK(on_phone_dialer_clear), phone); +#endif gtk_box_pack_start(GTK_BOX(hbox), phone->di_entry, TRUE, TRUE, 0); widget = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name( @@ -4114,6 +4137,7 @@ static void _modem_event_call(Phone * phone, ModemEvent * event) case MODEM_CALL_DIRECTION_INCOMING: /* add a log entry */ /* XXX check that calls are not duplicated */ + /* FIXME really log once accepting/missing the call */ phone_logs_append(phone, PHONE_CALL_TYPE_INCOMING, event->call.number); break; diff --git a/src/phone.h b/src/phone.h index ca69381..ce8a640 100644 --- a/src/phone.h +++ b/src/phone.h @@ -67,6 +67,7 @@ void phone_contacts_write_selected(Phone * phone); /* dialer */ int phone_dialer_append(Phone * phone, char character); void phone_dialer_call(Phone * phone, char const * number); +void phone_dialer_clear(Phone * phone); void phone_dialer_hangup(Phone * phone); /* events */