mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
src: Remove mutual reference between call -holder and -selector-item
This commit is contained in:
parent
6eda18c4b3
commit
400c2fc041
4 changed files with 23 additions and 73 deletions
|
@ -137,14 +137,7 @@ dispose (GObject *object)
|
||||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||||
CallsCallHolder *self = CALLS_CALL_HOLDER (object);
|
CallsCallHolder *self = CALLS_CALL_HOLDER (object);
|
||||||
|
|
||||||
// Mutual reference
|
g_clear_object (&self->selector_item);
|
||||||
if (self->selector_item)
|
|
||||||
{
|
|
||||||
GObject *selector_item = G_OBJECT (self->selector_item);
|
|
||||||
self->selector_item = NULL;
|
|
||||||
g_object_unref (selector_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&self->display);
|
g_clear_object (&self->display);
|
||||||
g_clear_object (&self->data);
|
g_clear_object (&self->data);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct _CallsCallSelectorItem
|
||||||
{
|
{
|
||||||
GtkEventBox parent_instance;
|
GtkEventBox parent_instance;
|
||||||
|
|
||||||
CallsCallHolder *holder;
|
CallsCallDisplay *display;
|
||||||
|
|
||||||
GtkBox *main_box;
|
GtkBox *main_box;
|
||||||
GtkLabel *name;
|
GtkLabel *name;
|
||||||
|
@ -75,31 +75,12 @@ calls_call_selector_item_new (CallsCallHolder *holder)
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallsCallHolder *
|
|
||||||
calls_call_selector_item_get_holder (CallsCallSelectorItem *item)
|
CallsCallDisplay *
|
||||||
|
calls_call_selector_item_get_display (CallsCallSelectorItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (item), NULL);
|
g_return_val_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (item), NULL);
|
||||||
return item->holder;
|
return item->display;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
get_property (GObject *object,
|
|
||||||
guint property_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
|
||||||
|
|
||||||
switch (property_id) {
|
|
||||||
case PROP_HOLDER:
|
|
||||||
g_value_set_object (value, self->holder);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,20 +108,16 @@ set_party (CallsCallSelectorItem *self, CallsParty *party)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_call_data (CallsCallSelectorItem *self, CallsCallData *data)
|
set_call_holder (CallsCallSelectorItem *self, CallsCallHolder *holder)
|
||||||
{
|
{
|
||||||
|
CallsCallData *data = calls_call_holder_get_data (holder);
|
||||||
CallsCall *call = calls_call_data_get_call (data);
|
CallsCall *call = calls_call_data_get_call (data);
|
||||||
|
|
||||||
set_call (self, call);
|
set_call (self, call);
|
||||||
set_party (self, calls_call_data_get_party (data));
|
set_party (self, calls_call_data_get_party (data));
|
||||||
}
|
call_state_changed_cb (self, calls_call_get_state (call));
|
||||||
|
|
||||||
|
g_set_object (&self->display, calls_call_holder_get_display (holder));
|
||||||
static void
|
|
||||||
set_call_holder (CallsCallSelectorItem *self, CallsCallHolder *holder)
|
|
||||||
{
|
|
||||||
set_call_data (self, calls_call_holder_get_data (holder));
|
|
||||||
g_set_object (&self->holder, holder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,19 +148,6 @@ calls_call_selector_item_init (CallsCallSelectorItem *self)
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
constructed (GObject *object)
|
|
||||||
{
|
|
||||||
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_EVENT_BOX);
|
|
||||||
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
|
||||||
CallsCallData *data = calls_call_holder_get_data (self->holder);
|
|
||||||
CallsCall *call = calls_call_data_get_call (data);
|
|
||||||
|
|
||||||
call_state_changed_cb (self, calls_call_get_state (call));
|
|
||||||
|
|
||||||
parent_class->constructed (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dispose (GObject *object)
|
dispose (GObject *object)
|
||||||
|
@ -191,26 +155,19 @@ dispose (GObject *object)
|
||||||
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_EVENT_BOX);
|
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_EVENT_BOX);
|
||||||
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
|
||||||
|
|
||||||
// Mutual reference
|
g_clear_object (&self->display);
|
||||||
if (self->holder)
|
|
||||||
{
|
|
||||||
GObject *holder = G_OBJECT (self->holder);
|
|
||||||
self->holder = NULL;
|
|
||||||
g_object_unref (holder);
|
|
||||||
}
|
|
||||||
|
|
||||||
parent_class->dispose (object);
|
parent_class->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calls_call_selector_item_class_init (CallsCallSelectorItemClass *klass)
|
calls_call_selector_item_class_init (CallsCallSelectorItemClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
object_class->get_property = get_property;
|
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
object_class->constructed = constructed;
|
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
|
|
||||||
props[PROP_HOLDER] =
|
props[PROP_HOLDER] =
|
||||||
|
@ -218,7 +175,7 @@ calls_call_selector_item_class_init (CallsCallSelectorItemClass *klass)
|
||||||
_("Call holder"),
|
_("Call holder"),
|
||||||
_("The holder for this call"),
|
_("The holder for this call"),
|
||||||
CALLS_TYPE_CALL_HOLDER,
|
CALLS_TYPE_CALL_HOLDER,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#ifndef CALLS_CALL_SELECTOR_ITEM_H__
|
#ifndef CALLS_CALL_SELECTOR_ITEM_H__
|
||||||
#define CALLS_CALL_SELECTOR_ITEM_H__
|
#define CALLS_CALL_SELECTOR_ITEM_H__
|
||||||
|
|
||||||
|
#include "calls-call-display.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
typedef struct _CallsCallHolder CallsCallHolder;
|
typedef struct _CallsCallHolder CallsCallHolder;
|
||||||
|
@ -36,8 +38,8 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE (CallsCallSelectorItem, calls_call_selector_item,
|
G_DECLARE_FINAL_TYPE (CallsCallSelectorItem, calls_call_selector_item,
|
||||||
CALLS, CALL_SELECTOR_ITEM, GtkEventBox);
|
CALLS, CALL_SELECTOR_ITEM, GtkEventBox);
|
||||||
|
|
||||||
CallsCallSelectorItem *calls_call_selector_item_new (CallsCallHolder *holder);
|
CallsCallSelectorItem *calls_call_selector_item_new (CallsCallHolder *holder);
|
||||||
CallsCallHolder *calls_call_selector_item_get_holder (CallsCallSelectorItem *item);
|
CallsCallDisplay * calls_call_selector_item_get_display (CallsCallSelectorItem *item);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -188,14 +188,12 @@ find_call_holder (CallsCallWindow *self,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_focus (CallsCallWindow *self,
|
set_focus (CallsCallWindow *self,
|
||||||
CallsCallHolder *holder)
|
CallsCallDisplay *display)
|
||||||
{
|
{
|
||||||
gtk_stack_set_visible_child_name (self->main_stack, "active-call");
|
gtk_stack_set_visible_child_name (self->main_stack, "active-call");
|
||||||
gtk_stack_set_visible_child_name (self->header_bar_stack, "active-call");
|
gtk_stack_set_visible_child_name (self->header_bar_stack, "active-call");
|
||||||
gtk_stack_set_visible_child
|
gtk_stack_set_visible_child (self->call_stack, GTK_WIDGET (display));
|
||||||
(self->call_stack,
|
|
||||||
GTK_WIDGET (calls_call_holder_get_display (holder)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,9 +214,9 @@ call_selector_child_activated_cb (GtkFlowBox *box,
|
||||||
{
|
{
|
||||||
GtkWidget *widget = gtk_bin_get_child (GTK_BIN (child));
|
GtkWidget *widget = gtk_bin_get_child (GTK_BIN (child));
|
||||||
CallsCallSelectorItem *item = CALLS_CALL_SELECTOR_ITEM (widget);
|
CallsCallSelectorItem *item = CALLS_CALL_SELECTOR_ITEM (widget);
|
||||||
CallsCallHolder *holder = calls_call_selector_item_get_holder (item);
|
CallsCallDisplay *display = calls_call_selector_item_get_display (item);
|
||||||
|
|
||||||
set_focus (self, holder);
|
set_focus (self, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,7 +240,7 @@ add_call (CallsCallWindow *self,
|
||||||
g_object_unref (holder);
|
g_object_unref (holder);
|
||||||
|
|
||||||
update_visibility (self);
|
update_visibility (self);
|
||||||
set_focus (self, holder);
|
set_focus (self, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue