Commit 0c91d38c authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#10304: Move playback buttons from toolbar to seekslider

parent 36bb6a06
......@@ -244,6 +244,7 @@ create_main_window()
seekslider = GTK_WIDGET(sfl_seekslider_new());
if(seekslider == NULL)
WARN("Error could not create widget\n");
gtk_box_pack_start(GTK_BOX(vbox), seekslider, FALSE, TRUE, 0);
/* Add tree views */
......@@ -293,6 +294,7 @@ create_main_window()
gtk_widget_hide(contacts_tab->tree);
/* show playback scale only if a recorded call is selected */
sfl_seekslider_set_display(SFL_SEEKSLIDER(seekslider), SFL_SEEKSLIDER_DISPLAY_PLAY);
gtk_widget_set_sensitive(seekslider, FALSE);
/* don't show waiting layer */
......
......@@ -37,6 +37,8 @@
#include "seekslider.h"
#include "dbus.h"
#include "logger.h"
#include "calltab.h"
// #include "uimanager.h"
/**
* SECTION:sfl-seekslider
......@@ -70,11 +72,17 @@ static gboolean on_playback_scale_pressed_cb(GtkWidget *widget, GdkEventButton *
static gboolean on_playback_scale_released_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
static gboolean on_playback_scale_moved_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data);
static gboolean on_playback_scale_scrolled_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data);
static void sfl_seekslider_play_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data);
static void sfl_seekslider_stop_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data);
struct SFLSeekSliderPrivate
{
GtkWidget *hbox;
GtkWidget *hscale;
GtkWidget *playRecordWidget;
GtkWidget *stopRecordWidget;
GtkWidget *playRecordImage;
GtkWidget *stopRecordImage;
gboolean can_update_scale;
};
......@@ -122,6 +130,18 @@ sfl_seekslider_init (SFLSeekSlider *seekslider)
if(seekslider->priv->hbox == NULL)
WARN("Could not create new horizontal box for seekslider");
seekslider->priv->playRecordImage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
seekslider->priv->playRecordWidget = gtk_button_new();
gtk_button_set_image(GTK_BUTTON(seekslider->priv->playRecordWidget), seekslider->priv->playRecordImage);
if(seekslider->priv->playRecordWidget == NULL)
WARN("Could not create new playback button for seekslider");
seekslider->priv->stopRecordImage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON);
seekslider->priv->stopRecordWidget = gtk_button_new();
gtk_button_set_image(GTK_BUTTON(seekslider->priv->stopRecordWidget), seekslider->priv->stopRecordImage);
if(seekslider->priv->stopRecordWidget == NULL)
WARN("Could not create mew pause button for seekslider");
g_signal_connect(G_OBJECT(seekslider->priv->hscale), "change-value",
G_CALLBACK(on_playback_scale_value_changed_cb), seekslider);
......@@ -139,10 +159,21 @@ sfl_seekslider_init (SFLSeekSlider *seekslider)
g_object_set(G_OBJECT(seekslider->priv->hscale), "draw-value", FALSE, NULL);
g_signal_connect_object (G_OBJECT (seekslider->priv->playRecordWidget), "pressed",
G_CALLBACK(sfl_seekslider_play_playback_record_cb), seekslider, 0);
g_signal_connect_object (G_OBJECT (seekslider->priv->stopRecordWidget), "pressed",
G_CALLBACK(sfl_seekslider_stop_playback_record_cb), seekslider, 0);
gtk_box_pack_start(GTK_BOX(seekslider->priv->hbox), seekslider->priv->playRecordWidget, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(seekslider->priv->hbox), seekslider->priv->stopRecordWidget, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(seekslider->priv->hbox), seekslider->priv->hscale, TRUE, TRUE, 0);
gtk_widget_show (seekslider->priv->hscale);
gtk_widget_show (seekslider->priv->hbox);
gtk_widget_show (seekslider->priv->hscale);
gtk_widget_hide (seekslider->priv->playRecordWidget);
gtk_widget_hide (seekslider->priv->stopRecordWidget);
gtk_box_pack_start(GTK_BOX(&seekslider->parent), seekslider->priv->hbox, TRUE, TRUE, 0);
......@@ -249,6 +280,54 @@ on_playback_scale_scrolled_cb(GtkWidget *widget G_GNUC_UNUSED, GdkEvent *event G
return TRUE;
}
static void sfl_seekslider_play_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data)
{
DEBUG("Start playback button pressed");
SFLSeekSlider *seekslider = (SFLSeekSlider *)user_data;
callable_obj_t *selectedCall = calltab_get_selected_call(history_tab);
if (selectedCall == NULL) {
ERROR("No selected object in playback record callback");
return;
}
DEBUG("Start selected call file playback %s", selectedCall->_recordfile);
selectedCall->_record_is_playing = dbus_start_recorded_file_playback(selectedCall->_recordfile);
// update_actions();
sfl_seekslider_set_display(seekslider, SFL_SEEKSLIDER_DISPLAY_PAUSE);
}
static void sfl_seekslider_stop_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data)
{
DEBUG("Stop playback button pressed");
SFLSeekSlider *seekslider = (SFLSeekSlider *)user_data;
callable_obj_t *selectedCall = calltab_get_selected_call(history_tab);
if (selectedCall == NULL) {
ERROR("No selected object in history treeview");
return;
}
if (selectedCall) {
if (selectedCall->_recordfile == NULL) {
ERROR("Record file is NULL");
return;
}
dbus_stop_recorded_file_playback(selectedCall->_recordfile);
DEBUG("Stop selected call file playback %s", selectedCall->_recordfile);
selectedCall->_record_is_playing = FALSE;
}
// update_actions();
sfl_seekslider_set_display(seekslider, SFL_SEEKSLIDER_DISPLAY_PLAY);
}
void sfl_seekslider_update_scale(SFLSeekSlider *seekslider, guint current, guint size)
{
if (size == 0)
......@@ -262,3 +341,24 @@ void sfl_seekslider_update_scale(SFLSeekSlider *seekslider, guint current, guint
if (seekslider->priv->can_update_scale)
gtk_range_set_value(GTK_RANGE(seekslider->priv->hscale), val);
}
void sfl_seekslider_set_display(SFLSeekSlider *seekslider, SFLSeekSliderDisplay display) {
// g_return_if_fail (SFL_IS_SEEKSLIDER (seekslider));
if(seekslider == NULL)
return;
switch(display) {
case SFL_SEEKSLIDER_DISPLAY_PAUSE:
gtk_widget_hide(seekslider->priv->playRecordWidget);
gtk_widget_show(seekslider->priv->stopRecordWidget);
break;
case SFL_SEEKSLIDER_DISPLAY_PLAY:
gtk_widget_hide(seekslider->priv->stopRecordWidget);
gtk_widget_show(seekslider->priv->playRecordWidget);
break;
default:
WARN("Unknown display option for seekslider");
break;
}
}
......@@ -55,12 +55,19 @@ struct _SFLSeekSliderClass
GtkHBoxClass parent;
};
typedef enum {
SFL_SEEKSLIDER_DISPLAY_PAUSE,
SFL_SEEKSLIDER_DISPLAY_PLAY,
} SFLSeekSliderDisplay;
GType sfl_seekslider_get_type(void);
SFLSeekSlider *sfl_seekslider_new(void);
void sfl_seekslider_update_scale(SFLSeekSlider *seekslider, guint current, guint size);
void sfl_seekslider_set_display(SFLSeekSlider *seekslider, SFLSeekSliderDisplay display);
G_END_DECLS
#endif /* __RB_SEEKSLIDER_H */
......@@ -56,8 +56,6 @@
<toolitem name="VoicemailToolbar" action="Voicemail"/>
<toolitem name="HistoryToolbar" action="History"/>
<toolitem name="StartPlaybackRecordToolbar" action="StartPlaybackRecord"/>
<toolitem name="StopPlaybackRecordToolbar" action="StopPlaybackRecord" />
</toolbar>
<popup name="PopupMenu">
......
......@@ -98,9 +98,6 @@ static GtkWidget * muteWidget_;
static GtkWidget * voicemailToolbar_;
static GtkWidget * imToolbar_;
static GtkWidget * playRecordWidget_;
static GtkWidget * stopRecordWidget_;
static GtkWidget * editable_num_;
static GtkWidget * edit_dialog_;
......@@ -222,10 +219,6 @@ update_toolbar_for_call(callable_obj_t *selectedCall, gboolean instant_messaging
else if (active_calltree_tab == history_tab) {
if (is_non_empty(selectedCall->_recordfile)) {
main_window_show_playback_scale();
if (selectedCall->_record_is_playing)
add_to_toolbar(toolbar_, stopRecordWidget_, pos++);
else
add_to_toolbar(toolbar_, playRecordWidget_, pos++);
}
else {
main_window_hide_playback_scale();
......@@ -369,11 +362,6 @@ update_toolbar_for_conference(conference_obj_t * selectedConf, gboolean instant_
} else if (active_calltree_tab == history_tab) {
if (is_non_empty(selectedConf->_recordfile)) {
main_window_show_playback_scale();
pos = 2;
if (selectedConf->_record_is_playing)
add_to_toolbar(toolbar_, stopRecordWidget_, pos);
else
add_to_toolbar(toolbar_, playRecordWidget_, pos);
}
else {
main_window_hide_playback_scale();
......@@ -476,8 +464,6 @@ update_actions()
remove_from_toolbar(offHoldToolbar_);
remove_from_toolbar(newCallWidget_);
remove_from_toolbar(pickUpWidget_);
remove_from_toolbar(playRecordWidget_);
remove_from_toolbar(stopRecordWidget_);
if (addrbook) {
remove_from_toolbar(contactButton_);
......@@ -1111,11 +1097,12 @@ static const GtkActionEntry menu_entries[] = {
N_("Quit the program"), G_CALLBACK(call_quit)
},
{
"StartPlaybackRecord", GTK_STOCK_MEDIA_PLAY, N_("_Playback record"), NULL,
// "StartPlaybackRecord", GTK_STOCK_MEDIA_PLAY, N_("_Playback record"), NULL,
"StartPlaybackRecord", "OK", N_("_Playback record"), NULL,
N_("Playback recorded file"), G_CALLBACK(start_playback_record_cb)
},
{
"StopPlaybackRecord", GTK_STOCK_MEDIA_PAUSE, N_("_Stop playback"), NULL,
"StopPlaybackRecord", "AH", N_("_Stop playback"), NULL,
N_("Stop recorded file playback"), G_CALLBACK(stop_playback_record_cb)
},
......@@ -1783,8 +1770,6 @@ create_toolbar_actions(GtkUIManager *ui)
muteWidget_ = get_widget(ui, "/ToolbarActions/MuteToolbar");
imToolbar_ = get_widget(ui, "/ToolbarActions/InstantMessagingToolbar");
historyButton_ = get_widget(ui, "/ToolbarActions/HistoryToolbar");
playRecordWidget_ = get_widget(ui, "/ToolbarActions/StartPlaybackRecordToolbar");
stopRecordWidget_ = get_widget(ui, "/ToolbarActions/StopPlaybackRecordToolbar");
if (addrbook)
contactButton_ = get_widget(ui, "/ToolbarActions/AddressbookToolbar");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment