Commit a9bd1eba authored by Julian Sparber's avatar Julian Sparber Committed by Julian Sparber
Browse files

MainWindow: show error message when making calls isn't possible

parent f63936d7
......@@ -56,6 +56,9 @@ struct _CallsMainWindow
HdyViewSwitcherBar *switcher_bar;
GtkStack *main_stack;
GtkRevealer *permanent_error_revealer;
GtkLabel *permanent_error_label;
CallsNewCallBox *new_call;
};
......@@ -158,6 +161,36 @@ set_property (GObject *object,
}
static void
state_changed_cb (CallsMainWindow *self,
GParamSpec *pspec,
CallsManager *manager)
{
const gchar *error = NULL;
switch (calls_manager_get_state (manager))
{
case CALLS_MANAGER_STATE_READY:
break;
case CALLS_MANAGER_STATE_NO_ORIGIN:
error = _("Can't place calls: No SIM card");
break;
case CALLS_MANAGER_STATE_UNKNOWN:
case CALLS_MANAGER_STATE_NO_PROVIDER:
error = _("Can't place calls: No backend service");
break;
case CALLS_MANAGER_STATE_NO_PLUGIN:
error = _("Can't place calls: No plugin");
break;
}
gtk_label_set_text (self->permanent_error_label, error);
gtk_revealer_set_reveal_child (self->permanent_error_revealer, error != NULL);
}
static void
constructed (GObject *object)
{
......@@ -218,6 +251,13 @@ constructed (GObject *object)
self->title_label,
NULL);
g_signal_connect_swapped (calls_manager_get_default (),
"notify::state",
G_CALLBACK (state_changed_cb),
self);
state_changed_cb (self, NULL, calls_manager_get_default ());
G_OBJECT_CLASS (calls_main_window_parent_class)->constructed (object);
}
......@@ -289,6 +329,8 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, narrow_switcher);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, switcher_bar);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, main_stack);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_revealer);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_label);
}
......
......@@ -14,3 +14,10 @@ hdykeypad > button, .dial-button, .delete-button {
.phone-number-entry {
font-size: 24px;
}
.error-state-message {
background-color: @error_color;
border-bottom: 1px solid darker(@error_color);
color: @theme_base_color;
padding: 6px;
}
......@@ -24,6 +24,23 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRevealer" id="permanent_error_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="reveal_child">True</property>
<child>
<object class="GtkLabel" id="permanent_error_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No modem found</property>
<style>
<class name="error-state-message"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment