Commit 6d333702 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin

Volume sliders & Cleanup of warnings

parent d36eb371
......@@ -15,7 +15,7 @@ AC_ARG_WITH(debug,
[with_debug=no]
)
if test "x$with_debug" = "xfull" -o "x$with_debug" = "xyes"; then
CFLAGS="$CFLAGS -g -DDEBUG"
CFLAGS="$CFLAGS -g -DDEBUG -Wall -Werror "
fi
AC_PROG_CC
......
pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA = sflphone.png accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg
pixmaps_DATA = sflphone.png accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg mic.svg speaker.svg
EXTRA_DIST = $(pixmaps_DATA)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,11 +13,12 @@ sflphone_gtk_SOURCES = \
configwindow.c \
accountlist.c \
accountwindow.c \
marshaller.c
marshaller.c \
sliders.c
noinst_HEADERS = actions.h dbus.h mainwindow.h calllist.h dialpad.h \
callmanager-glue.h menus.h calltree.h screen.h configwindow.h \
accountlist.h accountwindow.h marshaller.h
accountlist.h accountwindow.h marshaller.h sliders.h
EXTRA_DIST = marshaller.list
sflphone_gtk_LDADD = $(DEPS_LIBS)
......
......@@ -18,6 +18,7 @@
*/
#include <accountlist.h>
#include <string.h>
GQueue * accountQueue;
......
......@@ -20,6 +20,8 @@
#include <config.h>
#include <mainwindow.h>
#include <accountlist.h>
#include <string.h>
#include <dbus.h>
#include <gtk/gtk.h>
/** Local variables */
......
......@@ -21,6 +21,10 @@
#include <string.h>
#include <actions.h>
#include <mainwindow.h>
#include <calltree.h>
#include <screen.h>
#include <dbus.h>
#include <accountlist.h>
/**
......@@ -311,7 +315,7 @@ sflphone_place_call ( call_t * c )
void
sflphone_remove_account ( account_t * a )
{
dbus_remove_account (a);
dbus_remove_account (a->accountID);
}
......@@ -21,6 +21,7 @@
#define __ACTIONS_H__
#include <calllist.h>
#include <accountlist.h>
/**
* Initialize lists and configurations
......@@ -42,6 +43,10 @@ void sflphone_hold ( call_t * c);
void sflphone_ringing(call_t * c );
void sflphone_current ( call_t * c);
void sflphone_remove_account ( account_t * a );
void sflphone_unhold ( call_t * c);
/* signals */
......
......@@ -19,6 +19,8 @@
#include <calllist.h>
#include <string.h>
GQueue * callQueue;
/* GCompareFunc to compare a callID (gchar* and a call_t) */
......
......@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <calltree.h>
#include <calllist.h>
#include <dbus.h>
GtkListStore * store;
GtkWidget *view;
......@@ -48,6 +49,9 @@ call_button( GtkWidget *widget, gpointer data )
case CALL_STATE_INCOMING:
dbus_accept (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
......@@ -71,6 +75,9 @@ hang_up( GtkWidget *widget, gpointer data )
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
......@@ -88,6 +95,9 @@ hold( GtkWidget *widget, gpointer data )
case CALL_STATE_CURRENT:
dbus_hold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
......@@ -105,18 +115,6 @@ transfert( GtkWidget *widget, gpointer data )
}
}
/**
* Refuse incoming call
*/
static void
refuse( GtkWidget *widget, gpointer data )
{
if(selectedCall)
{
dbus_refuse(selectedCall);
}
}
/**
* Unhold call
*/
......@@ -130,6 +128,9 @@ unhold( GtkWidget *widget, gpointer data )
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
......@@ -197,19 +198,6 @@ selected(GtkTreeSelection *sel, GtkTreeModel *model)
update_buttons();
}
/**
* Accept incoming call
*/
static void
accept( GtkWidget *widget, gpointer data )
{
if(selectedCall)
{
dbus_accept(selectedCall);
}
}
GtkWidget *
create_call_tree (){
......@@ -217,17 +205,15 @@ create_call_tree (){
GtkWidget *sw;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *bbox;
GtkCellRenderer *rend;
GtkTreeViewColumn *col;
GtkTreeSelection *sel;
GtkTargetEntry te[2] = {{"text/uri-list", 0, 1},{"STRING", 0, 2}};
ret = gtk_vbox_new(FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (ret), 0);
sw = gtk_scrolled_window_new( NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
store = gtk_list_store_new (3,
......
......@@ -21,9 +21,12 @@
#define __CALLTREE_H__
#include <gtk/gtk.h>
#include <calllist.h>
GtkWidget * create_call_tree();
void update_call_tree ();
void update_call_tree_add (call_t * c);
void update_call_tree (call_t * c);
void update_call_tree_remove (call_t * c);
#endif
......@@ -20,6 +20,9 @@
#include <config.h>
#include <mainwindow.h>
#include <accountlist.h>
#include <accountwindow.h>
#include <actions.h>
#include <gtk/gtk.h>
/** Local variables */
......@@ -110,7 +113,7 @@ select_account(GtkTreeSelection *sel, GtkTreeModel *model)
/*TODO Set to TRUE when removeAccount is implemented */
gtk_widget_set_sensitive( GTK_WIDGET(deleteButton), FALSE);
}
g_printf("select");
g_print("select");
}
......@@ -123,13 +126,10 @@ create_accounts_tab()
GtkWidget *sw;
GtkWidget *view;
GtkWidget *bbox;
GtkWidget *button;
GtkCellRenderer *rend;
GtkTreeViewColumn *col;
GtkTreeSelection *sel;
GtkTreeRowReference *rowref;
GtkWidget *label;
GtkTargetEntry te[3] = {{"text/plain", 0, 0},{"text/plain", 0, 1},{"text/plain", 0, 2}};
selectedAccount = NULL;
......
......@@ -23,7 +23,11 @@
#include <accountlist.h>
#include <marshaller.h>
#include <mainwindow.h>
#include <sliders.h>
#include <dbus.h>
#include <actions.h>
#include <string.h>
#include <dbus/dbus-glib.h>
DBusGConnection * connection;
......@@ -47,6 +51,17 @@ incoming_call_cb (DBusGProxy *proxy,
sflphone_incoming_call (c);
}
static void
volume_changed_cb (DBusGProxy *proxy,
const gchar* device,
const gdouble value,
void * foo )
{
g_print ("Volume of %s changed to %f. \n",device, value);
set_slider(device, value);
}
static void
voice_mail_cb (DBusGProxy *proxy,
const gchar* accountID,
......@@ -152,8 +167,8 @@ dbus_connect ()
/* Register a marshaller for STRING,STRING */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal (callManagerProxy, "callStateChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal (callManagerProxy,
"callStateChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (callManagerProxy,
"callStateChanged", G_CALLBACK(call_state_cb), NULL, NULL);
......@@ -169,6 +184,12 @@ dbus_connect ()
dbus_g_proxy_connect_signal (callManagerProxy,
"incomingMessage", G_CALLBACK(incoming_message_cb), NULL, NULL);
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_DOUBLE,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID);
dbus_g_proxy_add_signal (callManagerProxy,
"volumeChanged", G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (callManagerProxy,
"volumeChanged", G_CALLBACK(volume_changed_cb), NULL, NULL);
configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection,
"org.sflphone.SFLPhone",
......@@ -377,7 +398,6 @@ void
dbus_remove_account(gchar * accountID)
{
GError *error = NULL;
char ** array;
org_sflphone_SFLPhone_ConfigurationManager_remove_account (
configurationManagerProxy,
accountID,
......@@ -416,3 +436,53 @@ dbus_set_account_details(account_t *a)
}
}
void
dbus_set_volume(const gchar * device, gdouble value)
{
GError *error = NULL;
org_sflphone_SFLPhone_CallManager_set_volume(
callManagerProxy,
device,
value,
&error);
if (error)
{
g_printerr ("Failed to call set_volume() on callManagerProxy: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called set_volume() on callManagerProxy\n");
}
}
gdouble
dbus_get_volume(const gchar * device)
{
gdouble value;
GError *error = NULL;
org_sflphone_SFLPhone_CallManager_get_volume(
callManagerProxy,
device,
&value,
&error);
if (error)
{
g_printerr ("Failed to call get_volume() on callManagerProxy: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called get_volume(%s) on callManagerProxy, got %f\n", device, value);
}
return value;
}
......@@ -25,7 +25,7 @@
#include <calllist.h>
/** @return TRUE if connection succeeded, FALSE otherwise */
void dbus_connect ();
gboolean dbus_connect ();
void dbus_clean ();
/* CallManager */
......@@ -42,5 +42,7 @@ gchar ** dbus_account_list();
GHashTable * dbus_account_details(gchar * accountID);
void dbus_set_account_details(account_t *a);
void dbus_remove_account(gchar * accountID);
void dbus_set_volume(const gchar * device, gdouble value);
gdouble dbus_get_volume(const gchar * device);
#endif
......@@ -18,6 +18,7 @@
*/
#include <dialpad.h>
#include <actions.h>
/**
* button pressed event
......
......@@ -21,6 +21,7 @@
#include <calllist.h>
#include <dbus.h>
#include <mainwindow.h>
#include <actions.h>
#include <gtk/gtk.h>
......
......@@ -20,20 +20,22 @@
#include <config.h>
#include <actions.h>
#include <calllist.h>
#include <calltree.h>
#include <dialpad.h>
#include <menus.h>
#include <screen.h>
#include <calltree.h>
#include <sliders.h>
#include <gtk/gtk.h>
/** Local variables */
GtkAccelGroup * accelGroup = NULL;
GtkWidget * window = NULL;
GtkWidget *subvbox = NULL;
GtkWidget * dialpad = NULL;
GtkWidget * window = NULL;
GtkWidget * subvbox = NULL;
GtkWidget * dialpad = NULL;
gboolean showDialpad = FALSE; // true if the dialpad have been showned
/**
* Terminate the main loop.
*/
......@@ -92,7 +94,10 @@ on_key_released (GtkWidget *widget,
// If a modifier key is pressed, it's a shortcut, pass along
if(event->state & GDK_CONTROL_MASK ||
event->state & GDK_SHIFT_MASK ||
event->state & GDK_MOD1_MASK )
event->state & GDK_MOD1_MASK ||
event->keyval == 65361 || // left arrow
event->keyval == 65363 // right arrow
)
return FALSE;
sflphone_keypad(event->keyval, event->string);
return TRUE;
......@@ -102,13 +107,12 @@ void
create_main_window ()
{
GtkWidget *button;
GtkWidget *hbox;
GtkWidget *vbox;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_window_set_title (GTK_WINDOW (window), PACKAGE);
gtk_window_set_default_size (GTK_WINDOW (window), 250, 250);
//gtk_window_set_default_size (GTK_WINDOW (window), 250, 250);
gtk_window_set_default_icon_from_file (PIXMAPS_DIR "/sflphone.png",
NULL);
......@@ -140,15 +144,15 @@ create_main_window ()
button = create_screen();
gtk_box_pack_start (GTK_BOX (subvbox), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
button = gtk_hscale_new_with_range(0, 100, 2);
gtk_scale_set_draw_value(button, FALSE);
gtk_box_pack_start (GTK_BOX (subvbox), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
button = gtk_hscale_new_with_range(0, 100, 2);
gtk_scale_set_draw_value(button, FALSE);
gtk_box_pack_start (GTK_BOX (subvbox), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_box_pack_start (GTK_BOX (subvbox), create_call_tree(), TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
button = create_slider("speaker");
gtk_box_pack_start (GTK_BOX (subvbox), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
button = create_slider("mic");
gtk_box_pack_start (GTK_BOX (subvbox), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
/* Status bar */
gtk_box_pack_start (GTK_BOX (vbox), gtk_statusbar_new(), FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
......@@ -216,8 +220,3 @@ main_window_dialpad(gboolean show){
}
......@@ -27,7 +27,7 @@ GtkWidget * get_main_window();
void create_main_window ( );
void main_window_ask_quit() ;
gboolean main_window_ask_quit() ;
/**
* Shows the dialpad on the mainwindow
* @param show TRUE if you want to show the dialpad, FALSE to hide it
......
......@@ -160,3 +160,40 @@ g_cclosure_user_marshal_VOID__STRING_INT (GClosure *closure,
data2);
}
/* VOID:STRING,DOUBLE (marshaller.list:4) */
void
g_cclosure_user_marshal_VOID__STRING_DOUBLE (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
typedef void (*GMarshalFunc_VOID__STRING_DOUBLE) (gpointer data1,
gpointer arg_1,
gdouble arg_2,
gpointer data2);
register GMarshalFunc_VOID__STRING_DOUBLE callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3);
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__STRING_DOUBLE) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_string (param_values + 1),
g_marshal_value_peek_double (param_values + 2),
data2);
}
......@@ -30,6 +30,14 @@ extern void g_cclosure_user_marshal_VOID__STRING_INT (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:STRING,DOUBLE (marshaller.list:4) */
extern void g_cclosure_user_marshal_VOID__STRING_DOUBLE (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
G_END_DECLS
#endif /* __g_cclosure_user_marshal_MARSHAL_H__ */
......
VOID:STRING,STRING,STRING
VOID:STRING,STRING
VOID:STRING,INT
VOID:STRING,DOUBLE
......@@ -20,6 +20,7 @@
#include <menus.h>
#include <config.h>
#include <calllist.h>
#include <actions.h>
#include <mainwindow.h>
#include <configwindow.h>
/* ----------------------------------------------------------------- */
......@@ -183,7 +184,7 @@ create_view_menu()
menu = gtk_menu_new ();
menu_items = gtk_check_menu_item_new_with_mnemonic ("Show _Dialpad");
menu_items = gtk_check_menu_item_new_with_mnemonic ("_Dialpad");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect(G_OBJECT (menu_items), "toggled",
G_CALLBACK (view_dial_pad),
......
......@@ -32,7 +32,6 @@ create_screen()
GtkWidget * event;
GtkWidget * sw;
GtkWidget *subvbox;
GtkWidget *image;
GdkColor color;
gdk_color_parse ("white", &color);
......
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sliders.h>
#include <dbus.h>
#include <string.h>
gdouble speakerValue;
gdouble micValue;
GtkWidget * speakerSlider;
GtkWidget * micSlider;
GtkWidget * micMuteButton;
GtkWidget * speakerMuteButton;
guint speakerToggledConnId; //The button toggled signal connection ID
guint micToggledConnId; //The button toggled signal connection ID
guint speakerMovedConnId; //The slider_moved signal connection ID
guint micMovedConnId; //The slider_moved signal connection ID
void slider_moved(GtkRange *range,
gchar * device){
gdouble value = gtk_range_get_value(range);
g_print("Volume changed for %s: %f\n ",device, value);
dbus_set_volume(device, value);
}
static void
mute_cb( GtkWidget *widget, gchar* device )
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
{ // Save value
g_print("Save");
if(strcmp(device, "speaker") == 0)
{
speakerValue = gtk_range_get_value(GTK_RANGE(speakerSlider));
}
else if (strcmp(device, "mic")== 0)
{
micValue = gtk_range_get_value(GTK_RANGE(micSlider));
}
dbus_set_volume(device, 0);
}
else
{ //Restore value
g_print("Restore");
if(strcmp(device, "speaker") == 0)
{
dbus_set_volume(device, speakerValue);
}
else if (strcmp(device, "mic")== 0)
{
dbus_set_volume(device, micValue);
}
}
}
/** This function updates the sliders without sending the value to the server.
* This behavior prevents an infinite loop when receiving an updated volume from
* the server.
* @param device The device slider to update {speaker, mic}
* @param value The value to set [0, 1.0]
*/
void
set_slider(const gchar * device, gdouble value)
{
GtkWidget * slider;
GtkWidget * mute;
guint * movedConnId;
guint * toggledConnId;
if(strcmp(device, "speaker") == 0)
{
slider = speakerSlider;
mute = speakerMuteButton;
movedConnId = &speakerMovedConnId;
toggledConnId = &speakerToggledConnId;
}
else if (strcmp(device, "mic")== 0)
{
slider = micSlider;
mute = micMuteButton;
movedConnId = &micMovedConnId;
toggledConnId = &micToggledConnId;
}
gtk_signal_handler_block(GTK_OBJECT(slider),*movedConnId);
gtk_range_set_value(GTK_RANGE(slider), value);
gtk_signal_handler_unblock(slider, *movedConnId);
gtk_signal_handler_block(GTK_OBJECT(mute),*toggledConnId);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute), (value == 0 ? TRUE: FALSE));
gtk_signal_handler_unblock(mute, *toggledConnId);
}
/** Generates the speaker slider and mute button */
GtkWidget *
create_slider(const gchar * device)
{
GtkWidget * ret;
GtkWidget * slider;
GtkWidget * button;
GtkWidget * image;
//GtkIconTheme * icon_theme;
//GdkPixbuf * pixbuf = NULL;
//GError * error = NULL;
guint * movedConnId = NULL;
guint * toggledConnId = NULL;
if(strcmp(device, "speaker") == 0)
{
movedConnId = &speakerMovedConnId;
toggledConnId = &speakerToggledConnId;
image = gtk_image_new_from_file( PIXMAPS_DIR "/speaker.svg");
//icon_theme = gtk_icon_theme_get_default ();
//pixbuf = gtk_icon_theme_load_icon (icon_theme,
// "audio-volume-muted", /* icon name */
// 16, /* size */
// 0, /* flags */
// &error);
//image = gtk_image_new_from_pixbuf(pixbuf);
}
else if (strcmp(device, "mic") == 0)
{
movedConnId = &micMovedConnId;
toggledConnId = &micToggledConnId;
image = gtk_image_new_from_file( PIXMAPS_DIR "/mic.svg");
}
ret = gtk_hbox_new ( FALSE /*homogeneous*/, 5 /*spacing*/);
button = gtk_toggle_button_new();
gtk_box_pack_start (GTK_BOX (ret), button, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
*toggledConnId = g_signal_connect (G_OBJECT (button), "toggled",
G_CALLBACK (mute_cb), (gpointer)device);
if (image)
{
gtk_button_set_image(GTK_BUTTON(button), image);
}
else
{
g_warning ("Couldn't load icon");
}
slider = gtk_hscale_new_with_range(0, 1, 0.05);
gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);