* #28144: gnome: set seekslider path through GObject property

This makes seekslider independent of calls.
This commit is contained in:
Tristan Matthews
2013-08-07 13:36:46 -04:00
parent 7da731cb39
commit 3af0d3f511
4 changed files with 70 additions and 23 deletions

View File

@ -101,6 +101,12 @@ is_conference(GtkTreeModel *model, GtkTreeIter *iter)
return result;
}
static void
update_ringtone_seekslider_path(callable_obj_t *call)
{
main_window_update_seekslider(call->_recordfile);
}
/* Call back when the user click on a call in the list */
static void
call_selected_cb(GtkTreeSelection *sel, SFLPhoneClient *client)
@ -132,8 +138,11 @@ call_selected_cb(GtkTreeSelection *sel, SFLPhoneClient *client)
callable_obj_t *selected_call = calllist_get_call(active_calltree_tab, id);
g_free(id);
if (selected_call)
if (selected_call) {
calltab_select_call(active_calltree_tab, selected_call);
if (calltab_has_name(active_calltree_tab, HISTORY))
update_ringtone_seekslider_path(selected_call);
}
}
update_actions(client);

View File

@ -589,3 +589,9 @@ main_window_pause_keygrabber(gboolean value)
{
pause_grabber = value;
}
void
main_window_update_seekslider(const gchar *recordfile)
{
g_object_set(G_OBJECT(seekslider), "file-path", recordfile, NULL);
}

View File

@ -131,4 +131,7 @@ void main_window_pause_keygrabber(gboolean value);
void main_window_reset_playback_scale();
void main_window_bring_to_front(SFLPhoneClient *client, guint32 timestamp);
void main_window_update_seekslider(const gchar *recordfile);
#endif

View File

@ -36,7 +36,6 @@
#include <string.h>
#include "seekslider.h"
#include "dbus.h"
#include "calltab.h"
/**
* SECTION:sfl-seekslider
@ -89,13 +88,18 @@ struct SFLSeekSliderPrivate
gboolean is_dragging;
gboolean can_update_scale;
gboolean is_playing;
gchar *file_path;
};
enum
{
PROP_0,
PROP_FILE_PATH,
N_PROPERTIES
};
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
G_DEFINE_TYPE(SFLSeekSlider, sfl_seekslider, GTK_TYPE_HBOX)
static void
@ -108,6 +112,10 @@ sfl_seekslider_class_init(SFLSeekSliderClass *klass)
object_class->set_property = sfl_seekslider_set_property;
object_class->get_property = sfl_seekslider_get_property;
obj_properties[PROP_FILE_PATH] = g_param_spec_string("file-path", "File path",
"Set file path for playback", "" /* default value */, G_PARAM_READWRITE);
g_object_class_install_properties(object_class, N_PROPERTIES, obj_properties);
g_type_class_add_private(klass, sizeof(SFLSeekSliderPrivate));
}
@ -186,6 +194,7 @@ sfl_seekslider_init(SFLSeekSlider *seekslider)
seekslider->priv->current = 0;
seekslider->priv->size = 0;
seekslider->priv->is_playing = FALSE;
seekslider->priv->file_path = NULL;
}
static void
@ -206,15 +215,42 @@ sfl_seekslider_finalize(GObject *object)
static void
sfl_seekslider_set_property (GObject *object, guint prop_id, const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
{
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
SFLSeekSlider *self = SFL_SEEKSLIDER(object);
switch (prop_id)
{
case PROP_FILE_PATH:
g_free(self->priv->file_path);
self->priv->file_path = g_value_dup_string(value);
g_debug("filepath: %s\n", self->priv->file_path);
break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
sfl_seekslider_get_property (GObject *object, guint prop_id, GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
{
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
SFLSeekSlider *self = SFL_SEEKSLIDER(object);
switch (prop_id)
{
case PROP_FILE_PATH:
g_value_set_string(value, self->priv->file_path);
break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
/**
* sfl_seekslider_new:
* @shell_player: the #RBShellPlayer instance
@ -298,37 +334,30 @@ on_playback_scale_scrolled_cb(GtkWidget *widget G_GNUC_UNUSED, GdkEvent *event G
static void sfl_seekslider_play_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data)
{
SFLSeekSlider *seekslider = SFL_SEEKSLIDER(user_data);
SFLSeekSlider *self = SFL_SEEKSLIDER(user_data);
callable_obj_t *selectedCall = calltab_get_selected_call(history_tab);
if (selectedCall == NULL)
if (self->priv->file_path == NULL || (*self->priv->file_path == 0))
return;
g_debug("Start selected call file playback %s", selectedCall->_recordfile);
seekslider->priv->is_playing = selectedCall->_record_is_playing =
dbus_start_recorded_file_playback(selectedCall->_recordfile);
g_debug("Start file playback %s", self->priv->file_path);
self->priv->is_playing = dbus_start_recorded_file_playback(self->priv->file_path);
if (seekslider->priv->is_playing)
sfl_seekslider_set_display(seekslider, SFL_SEEKSLIDER_DISPLAY_PAUSE);
if (self->priv->is_playing)
sfl_seekslider_set_display(self, SFL_SEEKSLIDER_DISPLAY_PAUSE);
}
static void sfl_seekslider_stop_playback_record_cb (GtkButton *button G_GNUC_UNUSED, gpointer user_data)
{
SFLSeekSlider *seekslider = SFL_SEEKSLIDER(user_data);
SFLSeekSlider *self = SFL_SEEKSLIDER(user_data);
callable_obj_t *selectedCall = calltab_get_selected_call(history_tab);
if (selectedCall == NULL)
if (self->priv->file_path == NULL || (*self->priv->file_path == 0))
return;
if (selectedCall->_recordfile == NULL ||
strlen(selectedCall->_recordfile) == 0)
return;
dbus_stop_recorded_file_playback(self->priv->file_path);
g_debug("Stop file playback %s", self->priv->file_path);
self->priv->is_playing = FALSE;
dbus_stop_recorded_file_playback(selectedCall->_recordfile);
g_debug("Stop selected call file playback %s", selectedCall->_recordfile);
seekslider->priv->is_playing = selectedCall->_record_is_playing = FALSE;
sfl_seekslider_set_display(seekslider, SFL_SEEKSLIDER_DISPLAY_PLAY);
sfl_seekslider_set_display(self, SFL_SEEKSLIDER_DISPLAY_PLAY);
}
void sfl_seekslider_update_timelabel(SFLSeekSlider *seekslider, guint current, guint size)