...
 
Commits (5)
......@@ -97,7 +97,6 @@ activate (GApplication *application)
{
CallsApplication *self = (CallsApplication *)application;
GtkApplication *app = (GtkApplication *)application;
CallsCallWindow *call_window;
GtkWindow *window;
g_assert (GTK_IS_APPLICATION (app));
......@@ -112,12 +111,7 @@ activate (GApplication *application)
* window. In that case, GTK+ frees the resources right.
*/
window = GTK_WINDOW (calls_main_window_new (app, self->provider));
call_window = calls_call_window_new (app);
g_signal_connect_swapped (window, "call-added",
G_CALLBACK (calls_call_window_add_call), call_window);
g_signal_connect_swapped (window, "call-removed",
G_CALLBACK (calls_call_window_remove_call), call_window);
calls_call_window_new (app, self->provider);
}
gtk_window_present (window);
......
......@@ -55,21 +55,15 @@ struct _CallsCallWindow
GtkFlowBox *call_selector;
};
enum {
ORIGIN_STORE_COLUMN_NAME,
ORIGIN_STORE_COLUMN_ORIGIN
};
G_DEFINE_TYPE (CallsCallWindow, calls_call_window, GTK_TYPE_APPLICATION_WINDOW);
CallsCallWindow *
calls_call_window_new (GtkApplication *application)
{
return g_object_new (CALLS_TYPE_CALL_WINDOW,
"application", application,
NULL);
}
enum {
PROP_0,
PROP_PROVIDER,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
static void
......@@ -240,8 +234,8 @@ call_selector_child_activated_cb (GtkFlowBox *box,
void
calls_call_window_add_call (CallsCallWindow *self,
CallsCall *call)
add_call (CallsCallWindow *self,
CallsCall *call)
{
CallsCallHolder *holder;
CallsCallDisplay *display;
......@@ -283,9 +277,9 @@ remove_call_holder (CallsCallWindow *self,
}
void
calls_call_window_remove_call (CallsCallWindow *self,
CallsCall *call,
const gchar *reason)
remove_call (CallsCallWindow *self,
CallsCall *call,
const gchar *reason)
{
guint n_items, position;
CallsCallHolder *holder;
......@@ -300,10 +294,6 @@ calls_call_window_remove_call (CallsCallWindow *self,
remove_call_holder (self, n_items, position, holder);
if (!reason)
{
reason = "Call ended for unknown reason";
}
show_message(self, reason, GTK_MESSAGE_INFO);
}
......@@ -326,6 +316,80 @@ remove_calls (CallsCallWindow *self)
}
static void
add_origin_calls (CallsCallWindow *self, CallsOrigin *origin)
{
GList *calls, *node;
calls = calls_origin_get_calls (origin);
for (node = calls; node; node = node->next)
{
add_call (self, CALLS_CALL (node->data));
}
g_list_free (calls);
}
static void
add_origin (CallsCallWindow *self, CallsOrigin *origin)
{
g_signal_connect_swapped (origin, "call-added",
G_CALLBACK (add_call), self);
g_signal_connect_swapped (origin, "call-removed",
G_CALLBACK (remove_call), self);
add_origin_calls (self, origin);
}
static void
add_provider_origins (CallsCallWindow *self, CallsProvider *provider)
{
GList *origins, *node;
origins = calls_provider_get_origins (provider);
for (node = origins; node; node = node->next)
{
add_origin (self, CALLS_ORIGIN (node->data));
}
g_list_free (origins);
}
static void
set_provider (CallsCallWindow *self, CallsProvider *provider)
{
g_signal_connect_swapped (provider, "origin-added",
G_CALLBACK (add_origin), self);
add_provider_origins (self, provider);
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
CallsCallWindow *self = CALLS_CALL_WINDOW (object);
switch (property_id)
{
case PROP_PROVIDER:
set_provider (self, CALLS_PROVIDER (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
constructed (GObject *object)
{
......@@ -375,9 +439,19 @@ calls_call_window_class_init (CallsCallWindowClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->set_property = set_property;
object_class->constructed = constructed;
object_class->dispose = dispose;
props[PROP_PROVIDER] =
g_param_spec_object ("provider",
_("Provider"),
_("An object implementing low-level call-making functionality"),
CALLS_TYPE_PROVIDER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/call-window.ui");
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, info);
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, info_label);
......@@ -391,3 +465,14 @@ calls_call_window_class_init (CallsCallWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, show_calls_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, new_call_submitted_cb);
}
CallsCallWindow *
calls_call_window_new (GtkApplication *application,
CallsProvider *provider)
{
return g_object_new (CALLS_TYPE_CALL_WINDOW,
"application", application,
"provider", provider,
NULL);
}
......@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include "calls-call.h"
#include "calls-provider.h"
G_BEGIN_DECLS
......@@ -37,9 +38,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsCallWindow, calls_call_window, CALLS, CALL_WINDOW, GtkApplicationWindow);
CallsCallWindow *calls_call_window_new (GtkApplication *application);
void calls_call_window_add_call (CallsCallWindow *self, CallsCall *call);
void calls_call_window_remove_call (CallsCallWindow *self, CallsCall *call, const gchar *reason);
CallsCallWindow *calls_call_window_new (GtkApplication *application,
CallsProvider *provider);
G_END_DECLS
......
......@@ -42,21 +42,12 @@ struct _CallsMainWindow
GtkApplicationWindow parent_instance;
CallsProvider *provider;
GListStore *call_holders;
CallsCallHolder *focus;
GtkInfoBar *info;
GtkLabel *info_label;
GtkStack *main_stack;
GtkStack *header_bar_stack;
GtkListStore *origin_store;
};
enum {
ORIGIN_STORE_COLUMN_NAME,
ORIGIN_STORE_COLUMN_ORIGIN
};
G_DEFINE_TYPE (CallsMainWindow, calls_main_window, GTK_TYPE_APPLICATION_WINDOW);
......@@ -69,14 +60,6 @@ enum {
static GParamSpec *props[PROP_LAST_PROP];
enum {
SIGNAL_CALL_ADDED,
SIGNAL_CALL_REMOVED,
SIGNAL_LAST_SIGNAL,
};
static guint signals [SIGNAL_LAST_SIGNAL];
static void
about_action (GSimpleAction *action,
GVariant *parameter,
......@@ -181,168 +164,24 @@ info_response_cb (GtkInfoBar *infobar,
}
static void
new_call_submitted_cb (CallsMainWindow *self,
CallsOrigin *origin,
const gchar *number,
CallsNewCallBox *new_call_box)
{
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
calls_origin_dial (origin, number);
}
typedef gboolean (*FindCallHolderFunc) (CallsCallHolder *holder,
gpointer user_data);
static gboolean
find_call_holder_by_call (CallsCallHolder *holder,
gpointer user_data)
{
CallsCallData *data = calls_call_holder_get_data (holder);
return calls_call_data_get_call (data) == user_data;
}
/** Search through the list of call holders, returning the total
number of items in the list, the position of the holder within the
list and a pointer to the holder itself. */
static gboolean
find_call_holder (CallsMainWindow *self,
guint *n_itemsp,
guint *positionp,
CallsCallHolder **holderp,
FindCallHolderFunc predicate,
gpointer user_data)
{
GListModel * const model = G_LIST_MODEL (self->call_holders);
const guint n_items = g_list_model_get_n_items (model);
guint position = 0;
CallsCallHolder *holder;
for (position = 0; position < n_items; ++position)
{
holder = CALLS_CALL_HOLDER (g_list_model_get_item (model, position));
if (predicate (holder, user_data))
{
#define out(var) \
if (var##p) \
{ \
*var##p = var ; \
}
out (n_items);
out (position);
out (holder);
#undef out
return TRUE;
}
}
return FALSE;
}
static void
set_focus (CallsMainWindow *self, CallsCallHolder *holder)
{
if (!holder)
{
holder = g_list_model_get_item (G_LIST_MODEL (self->call_holders), 0);
if (!holder)
{
/* No calls */
self->focus = NULL;
return;
}
}
self->focus = holder;
}
static void
add_call (CallsMainWindow *self, CallsCall *call)
{
CallsCallHolder *holder;
g_signal_emit (self, signals[SIGNAL_CALL_ADDED], 0, call);
g_signal_connect_swapped (call, "message",
G_CALLBACK (show_message), self);
holder = calls_call_holder_new (call);
g_list_store_append (self->call_holders, holder);
set_focus (self, holder);
}
static void
remove_call_holder (CallsMainWindow *self,
guint n_items,
guint position,
CallsCallHolder *holder)
{
g_list_store_remove (self->call_holders, position);
if (self->focus == holder)
{
set_focus (self, NULL);
}
}
static void
remove_call (CallsMainWindow *self, CallsCall *call, const gchar *reason)
{
guint n_items, position;
CallsCallHolder *holder;
gboolean found;
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
g_return_if_fail (CALLS_IS_CALL (call));
g_signal_emit (self, signals[SIGNAL_CALL_REMOVED], 0, call, reason);
found = find_call_holder (self, &n_items, &position, &holder,
find_call_holder_by_call, call);
g_return_if_fail (found);
remove_call_holder (self, n_items, position, holder);
if (!reason)
{
reason = "Call ended for unknown reason";
}
show_message(self, reason, GTK_MESSAGE_INFO);
}
static void
remove_calls (CallsMainWindow *self)
{
GListModel * model = G_LIST_MODEL (self->call_holders);
guint n_items = g_list_model_get_n_items (model);
gpointer *item;
CallsCallHolder *holder;
while ( (item = g_list_model_get_item (model, 0)) )
{
holder = CALLS_CALL_HOLDER (item);
remove_call_holder (self, n_items--, 0, holder);
}
}
static void
add_origin_calls (CallsMainWindow *self, CallsOrigin *origin)
{
......@@ -362,15 +201,6 @@ add_origin_calls (CallsMainWindow *self, CallsOrigin *origin)
static void
add_origin (CallsMainWindow *self, CallsOrigin *origin)
{
GtkTreeIter iter;
gtk_list_store_append (self->origin_store, &iter);
gtk_list_store_set (self->origin_store, &iter,
ORIGIN_STORE_COLUMN_NAME, calls_origin_get_name(origin),
ORIGIN_STORE_COLUMN_ORIGIN, G_OBJECT (origin),
-1);
g_signal_connect_swapped (origin, "message",
G_CALLBACK (show_message), self);
g_signal_connect_swapped (origin, "call-added",
......@@ -378,60 +208,7 @@ add_origin (CallsMainWindow *self, CallsOrigin *origin)
g_signal_connect_swapped (origin, "call-removed",
G_CALLBACK (remove_call), self);
add_origin_calls(self, origin);
}
static void
dump_list_store (GtkListStore *store)
{
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL (store);
gboolean ok;
ok = gtk_tree_model_get_iter_first (model, &iter);
if (!ok)
{
return;
}
g_debug ("List store:");
do
{
gchararray name;
gtk_tree_model_get (model, &iter,
ORIGIN_STORE_COLUMN_NAME, &name,
-1);
g_debug (" name: `%s'", name);
}
while (gtk_tree_model_iter_next (model, &iter));
}
static void
remove_origin (CallsMainWindow *self, CallsOrigin *origin)
{
GtkTreeIter iter;
gboolean ok;
ok = calls_list_store_find (self->origin_store, origin,
ORIGIN_STORE_COLUMN_ORIGIN, &iter);
g_return_if_fail (ok);
gtk_list_store_remove (self->origin_store, &iter);
}
static void
remove_origins (CallsMainWindow *self)
{
GtkTreeModel *model = GTK_TREE_MODEL (self->origin_store);
GtkTreeIter iter;
while (gtk_tree_model_get_iter_first (model, &iter))
{
gtk_list_store_remove (self->origin_store, &iter);
}
add_origin_calls (self, origin);
}
......@@ -448,27 +225,9 @@ add_provider_origins (CallsMainWindow *self, CallsProvider *provider)
}
g_list_free (origins);
dump_list_store (self->origin_store);
}
static void
set_provider (CallsMainWindow *self, CallsProvider *provider)
{
g_signal_connect_swapped (provider, "message",
G_CALLBACK (show_message), self);
g_signal_connect_swapped (provider, "origin-added",
G_CALLBACK (add_origin), self);
g_signal_connect_swapped (provider, "origin-removed",
G_CALLBACK (remove_origin), self);
self->provider = provider;
g_object_ref (G_OBJECT (provider));
add_provider_origins (self, provider);
}
static void
set_property (GObject *object,
guint property_id,
......@@ -476,21 +235,10 @@ set_property (GObject *object,
GParamSpec *pspec)
{
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
GObject *val_obj;
switch (property_id) {
case PROP_PROVIDER:
val_obj = g_value_get_object (value);
if (val_obj == NULL)
{
g_warning("Null provider");
self->provider = NULL;
}
else
{
g_return_if_fail (CALLS_IS_PROVIDER (val_obj));
set_provider (self, CALLS_PROVIDER (val_obj));
}
g_set_object (&self->provider, CALLS_PROVIDER (g_value_get_object (value)));
break;
default:
......@@ -506,6 +254,20 @@ constructed (GObject *object)
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_APPLICATION_WINDOW);
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
GSimpleActionGroup *simple_action_group;
CallsNewCallBox *new_call_box;
/* Set up provider */
g_signal_connect_swapped (self->provider, "message",
G_CALLBACK (show_message), self);
g_signal_connect_swapped (self->provider, "origin-added",
G_CALLBACK (add_origin), self);
add_provider_origins (self, self->provider);
/* Add new call box */
new_call_box = calls_new_call_box_new (self->provider);
gtk_stack_add_titled (self->main_stack, GTK_WIDGET (new_call_box),
"new-call", _("New call"));
/* Add actions */
simple_action_group = g_simple_action_group_new ();
......@@ -531,8 +293,6 @@ static void
calls_main_window_init (CallsMainWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
self->call_holders = g_list_store_new (CALLS_TYPE_CALL_HOLDER);
}
......@@ -542,17 +302,6 @@ dispose (GObject *object)
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_APPLICATION_WINDOW);
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
if (self->call_holders)
{
remove_calls (self);
}
if (self->origin_store)
{
remove_origins (self);
}
g_clear_object (&self->call_holders);
g_clear_object (&self->provider);
parent_class->dispose (object);
......@@ -579,34 +328,10 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
signals[SIGNAL_CALL_ADDED] =
g_signal_new ("call-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
1,
CALLS_TYPE_CALL);
signals[SIGNAL_CALL_REMOVED] =
g_signal_new ("call-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
2,
CALLS_TYPE_CALL,
G_TYPE_STRING);
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/main-window.ui");
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info_label);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, main_stack);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, header_bar_stack);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, origin_store);
gtk_widget_class_bind_template_callback (widget_class, info_response_cb);
gtk_widget_class_bind_template_callback (widget_class, new_call_submitted_cb);
}
......@@ -35,12 +35,9 @@ struct _CallsNewCallBox
{
GtkBox parent_instance;
GtkListStore *origin_store;
GtkComboBox *origin_box;
GtkSearchEntry *number_entry;
HdyDialer *dial_pad;
gulong origin_store_row_deleted_id;
gulong origin_store_row_inserted_id;
};
G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
......@@ -48,19 +45,12 @@ G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
enum {
PROP_0,
PROP_ORIGIN_STORE,
PROP_PROVIDER,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
enum {
SIGNAL_SUBMITTED,
SIGNAL_LAST_SIGNAL,
};
static guint signals[SIGNAL_LAST_SIGNAL];
enum {
ORIGIN_STORE_COLUMN_NAME,
ORIGIN_STORE_COLUMN_ORIGIN
......@@ -96,55 +86,50 @@ dial_clicked_cb (CallsNewCallBox *self,
GtkButton *button)
{
GtkTreeIter iter;
GtkTreeModel *origin_store;
gboolean ok;
CallsOrigin *origin;
const gchar *number;
gtk_combo_box_get_active_iter (self->origin_box, &iter);
if (!gtk_combo_box_get_active_iter (self->origin_box, &iter))
ok = gtk_combo_box_get_active_iter (self->origin_box, &iter);
if (!ok)
{
g_debug ("Can't submit call with no origin.");
g_debug ("Can't submit call with no origin");
return;
}
origin_store = gtk_combo_box_get_model (self->origin_box);
gtk_tree_model_get (origin_store, &iter,
gtk_tree_model_get (GTK_TREE_MODEL (self->origin_store), &iter,
ORIGIN_STORE_COLUMN_ORIGIN, &origin,
-1);
g_assert (CALLS_IS_ORIGIN (origin));
number = gtk_entry_get_text (GTK_ENTRY (self->number_entry));
g_signal_emit (self, signals[SIGNAL_SUBMITTED], 0, origin, number);
calls_origin_dial (origin, number);
}
void
update_origin_box (CallsNewCallBox *self)
{
GtkTreeModel *origin_store = gtk_combo_box_get_model (self->origin_box);
GtkTreeModel *origin_store = GTK_TREE_MODEL (self->origin_store);
GtkTreeIter iter;
if (origin_store == NULL ||
!gtk_tree_model_get_iter_first (origin_store, &iter))
if (!gtk_tree_model_get_iter_first (origin_store, &iter))
{
gtk_widget_hide (GTK_WIDGET (self->origin_box));
return;
}
/* We know there is a model and it's not empty. */
/* We know there is at least one origin. */
if (!gtk_tree_model_iter_next (origin_store, &iter))
{
gtk_combo_box_set_active (self->origin_box, 0);
gtk_widget_hide (GTK_WIDGET (self->origin_box));
return;
}
/* We know there are multiple origins in the model. */
/* We know there are multiple origins. */
if (gtk_combo_box_get_active (self->origin_box) < 0)
{
......@@ -158,57 +143,88 @@ update_origin_box (CallsNewCallBox *self)
static void
calls_new_call_box_set_origin_store (CallsNewCallBox *self,
GtkListStore *origin_store)
add_origin (CallsNewCallBox *self, CallsOrigin *origin)
{
g_return_if_fail (CALLS_IS_NEW_CALL_BOX (self));
g_return_if_fail (origin_store == NULL || GTK_IS_LIST_STORE (origin_store));
GtkTreeIter iter;
if (self->origin_store_row_deleted_id != 0)
{
g_signal_handler_disconnect (gtk_combo_box_get_model (self->origin_box),
self->origin_store_row_deleted_id);
g_signal_handler_disconnect (gtk_combo_box_get_model (self->origin_box),
self->origin_store_row_inserted_id);
}
gtk_list_store_append (self->origin_store, &iter);
gtk_list_store_set (self->origin_store, &iter,
ORIGIN_STORE_COLUMN_NAME, calls_origin_get_name (origin),
ORIGIN_STORE_COLUMN_ORIGIN, G_OBJECT (origin),
-1);
gtk_combo_box_set_model (self->origin_box, GTK_TREE_MODEL (origin_store));
update_origin_box (self);
}
if (origin_store != NULL)
static void
remove_origin (CallsNewCallBox *self, CallsOrigin *origin)
{
GtkTreeIter iter;
gboolean ok;
ok = calls_list_store_find (self->origin_store, origin,
ORIGIN_STORE_COLUMN_ORIGIN, &iter);
g_return_if_fail (ok);
gtk_list_store_remove (self->origin_store, &iter);
update_origin_box (self);
}
static void
remove_origins (CallsNewCallBox *self)
{
GtkTreeModel *model = GTK_TREE_MODEL (self->origin_store);
GtkTreeIter iter;
while (gtk_tree_model_get_iter_first (model, &iter))
{
self->origin_store_row_deleted_id = g_signal_connect_swapped (origin_store, "row-deleted", G_CALLBACK (update_origin_box), self);
self->origin_store_row_inserted_id = g_signal_connect_swapped (origin_store, "row-inserted", G_CALLBACK (update_origin_box), self);
gtk_list_store_remove (self->origin_store, &iter);
}
else
}
static void
add_provider_origins (CallsNewCallBox *self, CallsProvider *provider)
{
GList *origins, *node;
origins = calls_provider_get_origins (provider);
for (node = origins; node; node = node->next)
{
self->origin_store_row_deleted_id = 0;
self->origin_store_row_inserted_id = 0;
add_origin (self, CALLS_ORIGIN (node->data));
}
g_list_free (origins);
}
static void
calls_new_call_box_init (CallsNewCallBox *self)
set_provider (CallsNewCallBox *self, CallsProvider *provider)
{
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_swapped (provider, "origin-added",
G_CALLBACK (add_origin), self);
g_signal_connect_swapped (provider, "origin-removed",
G_CALLBACK (remove_origin), self);
update_origin_box (self);
add_provider_origins (self, provider);
}
static void
calls_new_call_box_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
CallsNewCallBox *self = CALLS_NEW_CALL_BOX (object);
switch (property_id)
{
case PROP_ORIGIN_STORE:
calls_new_call_box_set_origin_store (self, g_value_get_object (value));
g_object_notify_by_pspec (object, pspec);
case PROP_PROVIDER:
set_provider (self, CALLS_PROVIDER (g_value_get_object (value)));
break;
default:
......@@ -219,23 +235,26 @@ calls_new_call_box_set_property (GObject *object,
static void
calls_new_call_box_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
calls_new_call_box_init (CallsNewCallBox *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
update_origin_box (self);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_BOX);
CallsNewCallBox *self = CALLS_NEW_CALL_BOX (object);
switch (property_id)
if (self->origin_store)
{
case PROP_ORIGIN_STORE:
g_value_set_object (value, gtk_combo_box_get_model (self->origin_box));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
remove_origins (self);
}
parent_class->dispose (object);
}
......@@ -245,44 +264,34 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->set_property = calls_new_call_box_set_property;
object_class->get_property = calls_new_call_box_get_property;
object_class->set_property = set_property;
object_class->dispose = dispose;
props[PROP_ORIGIN_STORE] =
g_param_spec_object ("origin-store",
_("Origin store"),
_("The storage for origins"),
GTK_TYPE_LIST_STORE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
props[PROP_PROVIDER] =
g_param_spec_object ("provider",
_("Provider"),
_("An object implementing low-level call-making functionality"),
CALLS_TYPE_PROVIDER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
/**
* CallsNewCallBox::submitted:
* @self: The # CallsNewCallBox instance.
* @origin: The origin of the call.
* @number: The number at the time of activation.
*
* This signal is emitted when the dialer's 'dial' button is activated.
* Connect to this signal to perform to get notified when the user
* wants to submit the dialed number for a given call origin.
*/
signals[SIGNAL_SUBMITTED] =
g_signal_new ("submitted",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
2,
CALLS_TYPE_ORIGIN,
G_TYPE_STRING);
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/new-call-box.ui");
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_store);
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_box);
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, number_entry);
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, dial_pad);
gtk_widget_class_bind_template_callback (widget_class, dial_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, dial_pad_deleted_cb);
gtk_widget_class_bind_template_callback (widget_class, dial_pad_symbol_clicked_cb);
}
CallsNewCallBox *
calls_new_call_box_new (CallsProvider *provider)
{
return g_object_new (CALLS_TYPE_NEW_CALL_BOX,
"provider", provider,
NULL);
}
......@@ -25,6 +25,8 @@
#ifndef CALLS_NEW_CALL_BOX_H__
#define CALLS_NEW_CALL_BOX_H__
#include "calls-provider.h"
#include <gtk/gtk.h>
G_BEGIN_DECLS
......@@ -33,6 +35,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsNewCallBox, calls_new_call_box, CALLS, NEW_CALL_BOX, GtkBox);
CallsNewCallBox * calls_new_call_box_new (CallsProvider *provider);
G_END_DECLS
#endif /* CALLS_NEW_CALL_BOX_H__ */
......@@ -3,14 +3,6 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
<object class="GtkListStore" id="origin_store">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name origin -->
<column type="GObject"/>
</columns>
</object>
<template class="CallsMainWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Calls</property>
......@@ -87,18 +79,6 @@
<property name="title" translatable="yes">History</property>
</packing>
</child>
<child>
<object class="CallsNewCallBox" id="new_call_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="origin_store">origin_store</property>
<signal name="submitted" handler="new_call_submitted_cb" swapped="yes"/>
</object>
<packing>
<property name="name">new-call</property>
<property name="title" translatable="yes">New call</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
......@@ -134,4 +114,4 @@
</object>
</child>
</template>
</interface>
\ No newline at end of file
</interface>
......@@ -3,6 +3,14 @@
<interface>
<requires lib="gtk+" version="3.22"/>
<requires lib="libhandy" version="0.0"/>
<object class="GtkListStore" id="origin_store">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name origin -->
<column type="GObject"/>
</columns>
</object>
<template class="CallsNewCallBox" parent="GtkBox">
<property name="can_focus">False</property>
<property name="halign">center</property>
......@@ -16,6 +24,7 @@
<child>
<object class="GtkComboBox" id="origin_box">
<property name="can_focus">False</property>
<property name="model">origin_store</property>
<property name="id_column">0</property>
<property name="margin_bottom">8</property>
<property name="no_show_all">True</property>
......