cc-permission-infobar: Support customisable titles
Some panels may want to provide more specific context than ‘Change Settings’. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
1619d30780
commit
cef9a23e6a
3 changed files with 32 additions and 2 deletions
|
@ -27,12 +27,15 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "cc-permission-infobar.h"
|
#include "cc-permission-infobar.h"
|
||||||
|
|
||||||
struct _CcPermissionInfobar
|
struct _CcPermissionInfobar
|
||||||
{
|
{
|
||||||
GtkRevealer parent_instance;
|
GtkRevealer parent_instance;
|
||||||
|
|
||||||
|
GtkLabel *title;
|
||||||
GtkLockButton *lock_button;
|
GtkLockButton *lock_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ cc_permission_infobar_class_init (CcPermissionInfobarClass *klass)
|
||||||
"/org/gnome/control-center/"
|
"/org/gnome/control-center/"
|
||||||
"common/cc-permission-infobar.ui");
|
"common/cc-permission-infobar.ui");
|
||||||
|
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, CcPermissionInfobar, title);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcPermissionInfobar, lock_button);
|
gtk_widget_class_bind_template_child (widget_class, CcPermissionInfobar, lock_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +70,9 @@ static void
|
||||||
cc_permission_infobar_init (CcPermissionInfobar *self)
|
cc_permission_infobar_init (CcPermissionInfobar *self)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
/* Set the default title. */
|
||||||
|
cc_permission_infobar_set_title (self, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -82,3 +89,22 @@ cc_permission_infobar_set_permission (CcPermissionInfobar *self,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
on_permission_changed (self);
|
on_permission_changed (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cc_permission_infobar_set_title:
|
||||||
|
* @self: a #CcPermissionInfobar
|
||||||
|
* @title: (nullable): title to display in the infobar, or %NULL for the default
|
||||||
|
*
|
||||||
|
* Set the title text to display in the infobar.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cc_permission_infobar_set_title (CcPermissionInfobar *self,
|
||||||
|
const gchar *title)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CC_IS_PERMISSION_INFOBAR (self));
|
||||||
|
|
||||||
|
if (title == NULL)
|
||||||
|
title = _("Unlock to Change Settings");
|
||||||
|
|
||||||
|
gtk_label_set_text (self->title, title);
|
||||||
|
}
|
||||||
|
|
|
@ -31,4 +31,7 @@ G_DECLARE_FINAL_TYPE (CcPermissionInfobar, cc_permission_infobar, CC, PERMISSION
|
||||||
void cc_permission_infobar_set_permission (CcPermissionInfobar *self,
|
void cc_permission_infobar_set_permission (CcPermissionInfobar *self,
|
||||||
GPermission *permission);
|
GPermission *permission);
|
||||||
|
|
||||||
|
void cc_permission_infobar_set_title (CcPermissionInfobar *self,
|
||||||
|
const gchar *title);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -39,10 +39,11 @@
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel" id="title">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="label" translatable="yes">Unlock to Change Settings</property>
|
<!-- Actual string set in code -->
|
||||||
|
<property name="label"></property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="weight" value="bold"/>
|
<attribute name="weight" value="bold"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue