mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-05 19:15:32 +00:00
call-window: Switch to CallsUiCallData
By connecting to the "ui-call-added" and "ui-call-removed" signals instead of "call-add" and "call-remove". This allows us to shave off a few lines of code.
This commit is contained in:
parent
1d364eafda
commit
fa5969892e
2 changed files with 22 additions and 38 deletions
|
@ -37,7 +37,6 @@ struct _CallsCallSelectorItem
|
||||||
GtkEventBox parent_instance;
|
GtkEventBox parent_instance;
|
||||||
|
|
||||||
CuiCallDisplay *display;
|
CuiCallDisplay *display;
|
||||||
CallsBestMatch *contact;
|
|
||||||
|
|
||||||
GtkBox *main_box;
|
GtkBox *main_box;
|
||||||
GtkLabel *name;
|
GtkLabel *name;
|
||||||
|
@ -56,40 +55,27 @@ static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
static void
|
static void
|
||||||
call_state_changed_cb (CallsCallSelectorItem *self,
|
call_state_changed_cb (CallsCallSelectorItem *self,
|
||||||
CallsCallState state)
|
CuiCallState state)
|
||||||
{
|
{
|
||||||
GString *state_str = g_string_new("");
|
const char * state_str = cui_call_state_to_string (state);
|
||||||
calls_call_state_to_string (state_str, state);
|
|
||||||
gtk_label_set_text (self->status, state_str->str);
|
gtk_label_set_text (self->status, state_str);
|
||||||
g_string_free (state_str, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CallsCall *
|
|
||||||
display_get_call (CuiCallDisplay *display)
|
|
||||||
{
|
|
||||||
CuiCall *call_data;
|
|
||||||
|
|
||||||
g_assert (CUI_IS_CALL_DISPLAY (display));
|
|
||||||
|
|
||||||
call_data = cui_call_display_get_call (display);
|
|
||||||
return calls_ui_call_data_get_call (CALLS_UI_CALL_DATA (call_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_party (CallsCallSelectorItem *self)
|
set_party (CallsCallSelectorItem *self)
|
||||||
{
|
{
|
||||||
CallsCall *call;
|
CuiCall *call;
|
||||||
// FIXME: use HdyAvatar and the contact avatar
|
// FIXME: use HdyAvatar and the contact avatar
|
||||||
GtkWidget *image = gtk_image_new_from_icon_name ("avatar-default-symbolic", GTK_ICON_SIZE_DIALOG);
|
GtkWidget *image = gtk_image_new_from_icon_name ("avatar-default-symbolic", GTK_ICON_SIZE_DIALOG);
|
||||||
|
|
||||||
gtk_box_pack_start (self->main_box, image, TRUE, TRUE, 0);
|
gtk_box_pack_start (self->main_box, image, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (image);
|
gtk_widget_show (image);
|
||||||
|
|
||||||
call = display_get_call (self->display);
|
call = cui_call_display_get_call (self->display);
|
||||||
self->contact = calls_call_get_contact (call);
|
|
||||||
|
|
||||||
g_object_bind_property (self->contact, "name",
|
g_object_bind_property (call, "name",
|
||||||
self->name, "label",
|
self->name, "label",
|
||||||
G_BINDING_SYNC_CREATE);
|
G_BINDING_SYNC_CREATE);
|
||||||
}
|
}
|
||||||
|
@ -98,18 +84,18 @@ set_party (CallsCallSelectorItem *self)
|
||||||
static void
|
static void
|
||||||
set_call_display (CallsCallSelectorItem *self, CuiCallDisplay *display)
|
set_call_display (CallsCallSelectorItem *self, CuiCallDisplay *display)
|
||||||
{
|
{
|
||||||
CallsCall *call;
|
CuiCall *call;
|
||||||
|
|
||||||
g_assert (CALLS_IS_CALL_SELECTOR_ITEM (self));
|
g_assert (CALLS_IS_CALL_SELECTOR_ITEM (self));
|
||||||
g_assert (CUI_IS_CALL_DISPLAY (display));
|
g_assert (CUI_IS_CALL_DISPLAY (display));
|
||||||
|
|
||||||
call = display_get_call (display);
|
call = cui_call_display_get_call (display);
|
||||||
g_signal_connect_object (call, "state-changed",
|
g_signal_connect_object (call, "notify::state",
|
||||||
G_CALLBACK (call_state_changed_cb),
|
G_CALLBACK (call_state_changed_cb),
|
||||||
self,
|
self,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
call_state_changed_cb (self, calls_call_get_state (call));
|
call_state_changed_cb (self, cui_call_get_state (call));
|
||||||
|
|
||||||
g_set_object (&self->display, display);
|
g_set_object (&self->display, display);
|
||||||
set_party (self);
|
set_party (self);
|
||||||
|
@ -150,7 +136,6 @@ dispose (GObject *object)
|
||||||
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
||||||
|
|
||||||
g_clear_object (&self->display);
|
g_clear_object (&self->display);
|
||||||
g_clear_object (&self->contact);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_call_selector_item_parent_class)->dispose (object);
|
G_OBJECT_CLASS (calls_call_selector_item_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,20 +177,19 @@ call_selector_child_activated_cb (GtkFlowBox *box,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_call (CallsCallWindow *self,
|
add_call (CallsCallWindow *self,
|
||||||
CallsCall *call)
|
CallsUiCallData *ui_call_data)
|
||||||
{
|
{
|
||||||
CallsUiCallData *call_data;
|
CuiCall *call = (CuiCall *) ui_call_data;
|
||||||
CuiCallDisplay *display;
|
CuiCallDisplay *display;
|
||||||
CallsCallSelectorItem *item;
|
CallsCallSelectorItem *item;
|
||||||
|
|
||||||
g_assert (CALLS_IS_CALL_WINDOW (self));
|
g_assert (CALLS_IS_CALL_WINDOW (self));
|
||||||
g_assert (CALLS_IS_CALL (call));
|
g_assert (CUI_IS_CALL (call));
|
||||||
|
|
||||||
call_data = calls_ui_call_data_new (call);
|
display = cui_call_display_new (CUI_CALL (ui_call_data));
|
||||||
display = cui_call_display_new (CUI_CALL (call_data));
|
|
||||||
item = calls_call_selector_item_new (display);
|
item = calls_call_selector_item_new (display);
|
||||||
gtk_stack_add_named (self->call_stack, GTK_WIDGET (display),
|
gtk_stack_add_named (self->call_stack, GTK_WIDGET (display),
|
||||||
calls_call_get_id (call));
|
cui_call_get_id (call));
|
||||||
|
|
||||||
g_list_store_append (self->calls, item);
|
g_list_store_append (self->calls, item);
|
||||||
|
|
||||||
|
@ -218,23 +217,23 @@ on_remove_delayed (gpointer user_data)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_call (CallsCallWindow *self,
|
remove_call (CallsCallWindow *self,
|
||||||
CallsCall *call,
|
CallsUiCallData *ui_call_data,
|
||||||
const gchar *reason)
|
const gchar *reason)
|
||||||
{
|
{
|
||||||
guint n_calls;
|
guint n_calls;
|
||||||
|
|
||||||
g_assert (CALLS_IS_CALL_WINDOW (self));
|
g_assert (CALLS_IS_CALL_WINDOW (self));
|
||||||
g_assert (CALLS_IS_CALL (call));
|
g_assert (CALLS_IS_UI_CALL_DATA (ui_call_data));
|
||||||
|
|
||||||
n_calls = g_list_model_get_n_items (G_LIST_MODEL (self->calls));
|
n_calls = g_list_model_get_n_items (G_LIST_MODEL (self->calls));
|
||||||
for (guint i = 0; i < n_calls; i++) {
|
for (guint i = 0; i < n_calls; i++) {
|
||||||
g_autoptr (CallsCallSelectorItem) item =
|
g_autoptr (CallsCallSelectorItem) item =
|
||||||
g_list_model_get_item (G_LIST_MODEL (self->calls), i);
|
g_list_model_get_item (G_LIST_MODEL (self->calls), i);
|
||||||
CuiCallDisplay *display = calls_call_selector_item_get_display (item);
|
CuiCallDisplay *display = calls_call_selector_item_get_display (item);
|
||||||
CallsUiCallData *call_data =
|
CallsUiCallData *display_call_data =
|
||||||
CALLS_UI_CALL_DATA (cui_call_display_get_call (display));
|
CALLS_UI_CALL_DATA (cui_call_display_get_call (display));
|
||||||
|
|
||||||
if (calls_ui_call_data_get_call (call_data) == call) {
|
if (display_call_data == ui_call_data) {
|
||||||
struct DisplayData *display_data = g_new0 (struct DisplayData, 1);
|
struct DisplayData *display_data = g_new0 (struct DisplayData, 1);
|
||||||
|
|
||||||
g_list_store_remove (self->calls, i);
|
g_list_store_remove (self->calls, i);
|
||||||
|
@ -302,12 +301,12 @@ calls_call_window_init (CallsCallWindow *self)
|
||||||
self->in_app_notification);
|
self->in_app_notification);
|
||||||
|
|
||||||
g_signal_connect_swapped (calls_manager_get_default (),
|
g_signal_connect_swapped (calls_manager_get_default (),
|
||||||
"call-add",
|
"ui-call-added",
|
||||||
G_CALLBACK (add_call),
|
G_CALLBACK (add_call),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
g_signal_connect_swapped (calls_manager_get_default (),
|
g_signal_connect_swapped (calls_manager_get_default (),
|
||||||
"call-remove",
|
"ui-call-removed",
|
||||||
G_CALLBACK (remove_call),
|
G_CALLBACK (remove_call),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue