[calls] Switch from CallsCallDisplay to CuiCallDisplay



commit dc454837d66c4ded44a3d4c7590be3caea1dd1d2
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Sat Oct 9 09:02:54 2021 +0200

    Switch from CallsCallDisplay to CuiCallDisplay
    
    Closes #302

 src/calls-call-selector-item.c | 42 ++++++++++++++++++++++++++++--------------
 src/calls-call-selector-item.h |  7 +++----
 src/calls-call-window.c        | 19 ++++++++++++-------
 3 files changed, 43 insertions(+), 25 deletions(-)
---
diff --git a/src/calls-call-selector-item.c b/src/calls-call-selector-item.c
index bc928d2f..b04aa52f 100644
--- a/src/calls-call-selector-item.c
+++ b/src/calls-call-selector-item.c
@@ -23,7 +23,8 @@
  */
 
 #include "calls-call-selector-item.h"
-#include "calls-call-display.h"
+#include "calls-call.h"
+#include "calls-ui-call-data.h"
 #include "util.h"
 
 #include <glib/gi18n.h>
@@ -35,7 +36,7 @@ struct _CallsCallSelectorItem
 {
   GtkEventBox parent_instance;
 
-  CallsCallDisplay *display;
+  CuiCallDisplay *display;
   CallsBestMatch *contact;
 
   GtkBox *main_box;
@@ -65,9 +66,9 @@ call_state_changed_cb (CallsCallSelectorItem *self,
 
 
 CallsCallSelectorItem *
-calls_call_selector_item_new (CallsCallDisplay *display)
+calls_call_selector_item_new (CuiCallDisplay *display)
 {
-  g_return_val_if_fail (CALLS_IS_CALL_DISPLAY (display), NULL);
+  g_return_val_if_fail (CUI_IS_CALL_DISPLAY (display), NULL);
 
   return g_object_new (CALLS_TYPE_CALL_SELECTOR_ITEM,
                        "display", display,
@@ -75,23 +76,36 @@ calls_call_selector_item_new (CallsCallDisplay *display)
 }
 
 
-CallsCallDisplay *
+CuiCallDisplay *
 calls_call_selector_item_get_display (CallsCallSelectorItem *item)
 {
   g_return_val_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (item), NULL);
   return item->display;
 }
 
+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
 set_party (CallsCallSelectorItem *self)
 {
+  CallsCall *call;
   // FIXME: use HdyAvatar and the contact avatar
   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_widget_show (image);
 
-  self->contact = calls_call_get_contact (calls_call_display_get_call (self->display));
+  call = display_get_call (self->display);
+  self->contact = calls_call_get_contact (call);
 
   g_object_bind_property (self->contact, "name",
                           self->name, "label",
@@ -100,14 +114,14 @@ set_party (CallsCallSelectorItem *self)
 
 
 static void
-set_call_display (CallsCallSelectorItem *self, CallsCallDisplay *display)
+set_call_display (CallsCallSelectorItem *self, CuiCallDisplay *display)
 {
-  CallsCall *call = NULL;
+  CallsCall *call;
 
-  g_return_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (self));
-  g_return_if_fail (CALLS_IS_CALL_DISPLAY (display));
+  g_assert (CALLS_IS_CALL_SELECTOR_ITEM (self));
+  g_assert (CUI_IS_CALL_DISPLAY (display));
 
-  call = calls_call_display_get_call (display);
+  call = display_get_call (display);
   g_signal_connect_object (call, "state-changed",
                            G_CALLBACK (call_state_changed_cb),
                            self,
@@ -131,7 +145,7 @@ set_property (GObject      *object,
   switch (property_id) {
   case PROP_DISPLAY:
     set_call_display
-      (self, CALLS_CALL_DISPLAY (g_value_get_object (value)));
+      (self, CUI_CALL_DISPLAY (g_value_get_object (value)));
     break;
 
   default:
@@ -173,9 +187,9 @@ calls_call_selector_item_class_init (CallsCallSelectorItemClass *klass)
     g_param_spec_object ("display",
                          "Call display",
                          "The display for this call",
-                         CALLS_TYPE_CALL_DISPLAY,
+                         CUI_TYPE_CALL_DISPLAY,
                          G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
-   
+
   g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
 
 
diff --git a/src/calls-call-selector-item.h b/src/calls-call-selector-item.h
index 1a5ad350..b70ac509 100644
--- a/src/calls-call-selector-item.h
+++ b/src/calls-call-selector-item.h
@@ -25,8 +25,7 @@
 #ifndef CALLS_CALL_SELECTOR_ITEM_H__
 #define CALLS_CALL_SELECTOR_ITEM_H__
 
-#include "calls-call-display.h"
-
+#include <call-ui.h>
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -36,8 +35,8 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (CallsCallSelectorItem, calls_call_selector_item,
                       CALLS, CALL_SELECTOR_ITEM, GtkEventBox);
 
-CallsCallSelectorItem *calls_call_selector_item_new         (CallsCallDisplay      *display);
-CallsCallDisplay *     calls_call_selector_item_get_display (CallsCallSelectorItem *item);
+CallsCallSelectorItem *calls_call_selector_item_new         (CuiCallDisplay        *display);
+CuiCallDisplay        *calls_call_selector_item_get_display (CallsCallSelectorItem *item);
 
 G_END_DECLS
 
diff --git a/src/calls-call-window.c b/src/calls-call-window.c
index 3e18052e..a0aba54d 100644
--- a/src/calls-call-window.c
+++ b/src/calls-call-window.c
@@ -32,6 +32,7 @@
 #include "calls-new-call-box.h"
 #include "calls-in-app-notification.h"
 #include "calls-manager.h"
+#include "calls-ui-call-data.h"
 #include "util.h"
 
 #include <glib/gi18n.h>
@@ -127,8 +128,8 @@ new_call_submitted_cb (CallsCallWindow *self,
 
 
 static void
-set_focus (CallsCallWindow  *self,
-           CallsCallDisplay *display)
+set_focus (CallsCallWindow *self,
+           CuiCallDisplay  *display)
 {
   gtk_stack_set_visible_child_name (self->main_stack, "active-call");
   gtk_stack_set_visible_child (self->call_stack, GTK_WIDGET (display));
@@ -150,7 +151,7 @@ call_selector_child_activated_cb (GtkFlowBox      *box,
 {
   GtkWidget *widget = gtk_bin_get_child (GTK_BIN (child));
   CallsCallSelectorItem *item = CALLS_CALL_SELECTOR_ITEM (widget);
-  CallsCallDisplay *display = calls_call_selector_item_get_display (item);
+  CuiCallDisplay *display = calls_call_selector_item_get_display (item);
 
   set_focus (self, display);
 }
@@ -160,13 +161,15 @@ static void
 add_call (CallsCallWindow *self,
           CallsCall       *call)
 {
-  CallsCallDisplay *display;
+  CallsUiCallData *call_data;
+  CuiCallDisplay *display;
   CallsCallSelectorItem *item;
 
   g_return_if_fail (CALLS_IS_CALL_WINDOW (self));
   g_return_if_fail (CALLS_IS_CALL (call));
 
-  display = calls_call_display_new (call);
+  call_data = calls_ui_call_data_new (call);
+  display = cui_call_display_new (CUI_CALL (call_data));
   item = calls_call_selector_item_new (display);
   gtk_stack_add_named (self->call_stack, GTK_WIDGET (display),
                        calls_call_get_number (call));
@@ -191,9 +194,11 @@ remove_call (CallsCallWindow *self,
   for (guint i = 0; i < n_calls; i++) {
     g_autoptr (CallsCallSelectorItem) item =
       g_list_model_get_item (G_LIST_MODEL (self->calls), i);
-    CallsCallDisplay *display = calls_call_selector_item_get_display (item);
+    CuiCallDisplay *display = calls_call_selector_item_get_display (item);
+    CallsUiCallData *call_data =
+      CALLS_UI_CALL_DATA (cui_call_display_get_call (display));
 
-    if (calls_call_display_get_call (display) == call) {
+    if (calls_ui_call_data_get_call (call_data) == call) {
       g_list_store_remove (self->calls, i);
       gtk_container_remove (GTK_CONTAINER (self->call_stack),
                             GTK_WIDGET (display));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]