diff options
author | Alfred E. Heggestad <aeh@db.org> | 2015-11-29 09:47:52 +0100 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2015-11-29 09:47:52 +0100 |
commit | 8497126045f34963b04e79cd900f82049a857f37 (patch) | |
tree | a302352584251a5c7e0335cecd69b25e58aeb9b3 /modules/gtk | |
parent | 2785d452c63528282b0d8ecc397b3ccae5851e43 (diff) |
gtk: cleanup some formatting
Diffstat (limited to 'modules/gtk')
-rw-r--r-- | modules/gtk/call_window.c | 42 | ||||
-rw-r--r-- | modules/gtk/gtk_mod.c | 31 |
2 files changed, 60 insertions, 13 deletions
diff --git a/modules/gtk/call_window.c b/modules/gtk/call_window.c index c520e51..6744510 100644 --- a/modules/gtk/call_window.c +++ b/modules/gtk/call_window.c @@ -9,6 +9,7 @@ #include <gtk/gtk.h> #include "gtk_mod.h" + struct call_window { struct gtk_mod *mod; struct call *call; @@ -49,7 +50,8 @@ static struct vumeter_dec *last_dec = NULL; static struct vumeter_enc *last_enc = NULL; -static void call_window_update_duration(struct call_window *win) { +static void call_window_update_duration(struct call_window *win) +{ gchar buf[32]; const uint32_t dur = call_duration(win->call); @@ -62,7 +64,8 @@ static void call_window_update_duration(struct call_window *win) { } -static void call_window_update_vumeters(struct call_window *win) { +static void call_window_update_vumeters(struct call_window *win) +{ double value; if (win->vu.enc && win->vu.enc->started) { @@ -76,20 +79,24 @@ static void call_window_update_vumeters(struct call_window *win) { } -static gboolean call_timer(gpointer arg) { +static gboolean call_timer(gpointer arg) +{ struct call_window *win = arg; call_window_update_duration(win); return G_SOURCE_CONTINUE; } -static gboolean vumeter_timer(gpointer arg) { +static gboolean vumeter_timer(gpointer arg) +{ struct call_window *win = arg; call_window_update_vumeters(win); return G_SOURCE_CONTINUE; } -static void vumeter_timer_start(struct call_window *win) { + +static void vumeter_timer_start(struct call_window *win) +{ if (!win->vumeter_timer_tag) win->vumeter_timer_tag = g_timeout_add(100, vumeter_timer, win); @@ -99,7 +106,9 @@ static void vumeter_timer_start(struct call_window *win) { win->vu.dec->avg_play = 0; } -static void vumeter_timer_stop(struct call_window *win) { + +static void vumeter_timer_stop(struct call_window *win) +{ if (win->vumeter_timer_tag) { g_source_remove(win->vumeter_timer_tag); win->vumeter_timer_tag = 0; @@ -108,8 +117,9 @@ static void vumeter_timer_stop(struct call_window *win) { gtk_progress_bar_set_fraction(win->progress.dec, 0); } + static void call_window_set_vu_dec(struct call_window *win, - struct vumeter_dec *dec) + struct vumeter_dec *dec) { if (win->vu.dec) mem_deref(win->vu.dec); @@ -117,8 +127,9 @@ static void call_window_set_vu_dec(struct call_window *win, vumeter_timer_start(win); } + static void call_window_set_vu_enc(struct call_window *win, - struct vumeter_enc *enc) + struct vumeter_enc *enc) { if (win->vu.enc) mem_deref(win->vu.enc); @@ -126,6 +137,7 @@ static void call_window_set_vu_enc(struct call_window *win, vumeter_timer_start(win); } + /* This is a hack to associate a call with its vumeters */ void call_window_got_vu_dec(struct vumeter_dec *dec) @@ -136,6 +148,7 @@ void call_window_got_vu_dec(struct vumeter_dec *dec) last_dec = dec; } + void call_window_got_vu_enc(struct vumeter_enc *enc) { if (last_call_win) @@ -144,6 +157,7 @@ void call_window_got_vu_enc(struct vumeter_enc *enc) last_enc = enc; } + static void got_call_window(struct call_window *win) { if (last_enc) @@ -161,6 +175,7 @@ static void call_on_hangup(GtkToggleButton *btn, struct call_window *win) mqueue_push(win->mq, MQ_CLOSE, win); } + static void call_on_hold_toggle(GtkToggleButton *btn, struct call_window *win) { bool hold = gtk_toggle_button_get_active(btn); @@ -171,12 +186,14 @@ static void call_on_hold_toggle(GtkToggleButton *btn, struct call_window *win) mqueue_push(win->mq, MQ_HOLD, (void *)(size_t)hold); } + static void call_on_mute_toggle(GtkToggleButton *btn, struct call_window *win) { bool mute = gtk_toggle_button_get_active(btn); mqueue_push(win->mq, MQ_MUTE, (void *)(size_t)mute); } + static void call_on_transfer(GtkToggleButton *btn, struct call_window *win) { (void)btn; @@ -272,6 +289,7 @@ static void mqueue_handler(int id, void *data, void *arg) } } + static void call_window_destructor(void *arg) { struct call_window *window = arg; @@ -294,6 +312,7 @@ static void call_window_destructor(void *arg) last_call_win = NULL; } + struct call_window *call_window_new(struct call *call, struct gtk_mod *mod) { struct call_window *win; @@ -432,11 +451,13 @@ out: return win; } + void call_window_transfer(struct call_window *win, const char *uri) { mqueue_push(win->mq, MQ_TRANSFER, (char *)uri); } + void call_window_closed(struct call_window *win, const char *reason) { char buf[256]; @@ -463,11 +484,13 @@ void call_window_closed(struct call_window *win, const char *reason) win->closed = true; } + void call_window_ringing(struct call_window *win) { call_window_set_status(win, "ringing"); } + void call_window_progress(struct call_window *win) { win->duration_timer_tag = g_timeout_add_seconds(1, call_timer, win); @@ -475,6 +498,7 @@ void call_window_progress(struct call_window *win) call_window_set_status(win, "progress"); } + void call_window_established(struct call_window *win) { call_window_update_duration(win); @@ -483,6 +507,7 @@ void call_window_established(struct call_window *win) call_window_set_status(win, "established"); } + void call_window_transfer_failed(struct call_window *win, const char *reason) { if (win->transfer_dialog) { @@ -490,6 +515,7 @@ void call_window_transfer_failed(struct call_window *win, const char *reason) } } + bool call_window_is_for_call(struct call_window *win, struct call *call) { return win->call == call; diff --git a/modules/gtk/gtk_mod.c b/modules/gtk/gtk_mod.c index 0bba177..67f40cb 100644 --- a/modules/gtk/gtk_mod.c +++ b/modules/gtk/gtk_mod.c @@ -53,7 +53,7 @@ struct gtk_mod { GSList *incoming_call_menus; }; -struct gtk_mod mod_obj; +static struct gtk_mod mod_obj; enum gtk_mod_events { MQ_POPUP, @@ -107,6 +107,7 @@ static void menu_on_about(GtkMenuItem *menuItem, gpointer arg) NULL); } + static void menu_on_quit(GtkMenuItem *menuItem, gpointer arg) { struct gtk_mod *mod = arg; @@ -119,6 +120,7 @@ static void menu_on_quit(GtkMenuItem *menuItem, gpointer arg) info("quit from gtk\n"); } + static void menu_on_dial(GtkMenuItem *menuItem, gpointer arg) { struct gtk_mod *mod = arg; @@ -128,6 +130,7 @@ static void menu_on_dial(GtkMenuItem *menuItem, gpointer arg) dial_dialog_show(mod->dial_dialog); } + static void menu_on_dial_contact(GtkMenuItem *menuItem, gpointer arg) { struct gtk_mod *mod = arg; @@ -136,6 +139,7 @@ static void menu_on_dial_contact(GtkMenuItem *menuItem, gpointer arg) mqueue_push(mod->mq, MQ_CONNECT, (char *)uri); } + static void init_contacts_menu(struct gtk_mod *mod) { struct le *le; @@ -222,6 +226,7 @@ static GtkMenuItem *accounts_menu_add_item(struct gtk_mod *mod, return GTK_MENU_ITEM(item); } + static GtkMenuItem *accounts_menu_get_item(struct gtk_mod *mod, struct ua *ua) { @@ -411,6 +416,7 @@ static void answer_activated(GSimpleAction *action, GVariant *parameter, } } + static void reject_activated(GSimpleAction *action, GVariant *parameter, gpointer arg) { @@ -424,6 +430,7 @@ static void reject_activated(GSimpleAction *action, GVariant *parameter, } } + static struct call_window *new_call_window(struct gtk_mod *mod, struct call *call) { @@ -461,9 +468,12 @@ static struct call_window *get_create_call_window(struct gtk_mod *mod, void gtk_mod_call_window_closed(struct gtk_mod *mod, struct call_window *win) { + if (!mod) + return; mod->call_windows = g_slist_remove(mod->call_windows, win); } + static void ua_event_handler(struct ua *ua, enum ua_event ev, struct call *call, @@ -606,9 +616,12 @@ static gboolean status_icon_on_button_press(GtkStatusIcon *status_icon, void gtk_mod_connect(struct gtk_mod *mod, const char *uri) { + if (!mod) + return; mqueue_push(mod->mq, MQ_CONNECT, (char *)uri); } + static void warning_dialog(const char *title, const char *fmt, ...) { va_list ap; @@ -704,6 +717,7 @@ static void mqueue_handler(int id, void *data, void *arg) } } + static void *gtk_thread(void *arg) { struct gtk_mod *mod = arg; @@ -973,10 +987,6 @@ static int module_init(void) err = mqueue_alloc(&mod_obj.mq, mqueue_handler, &mod_obj); if (err) return err; - err = pthread_create(&mod_obj.thread, NULL, gtk_thread, - &mod_obj); - if (err) - return err; aufilt_register(&vumeter); #ifdef USE_NOTIFICATIONS @@ -986,10 +996,19 @@ static int module_init(void) #endif err = cmd_register(cmdv, ARRAY_SIZE(cmdv)); + if (err) + return err; + + /* start the thread last */ + err = pthread_create(&mod_obj.thread, NULL, gtk_thread, + &mod_obj); + if (err) + return err; return err; } + static int module_close(void) { cmd_unregister(cmdv); @@ -1012,6 +1031,8 @@ static int module_close(void) g_slist_free(mod_obj.call_windows); g_slist_free(mod_obj.incoming_call_menus); + uag_event_unregister(ua_event_handler); + return 0; } |