widget-factory: Add a lock button
This commit is contained in:
@ -1271,6 +1271,108 @@ tab_close_cb (GtkWidget *page)
|
|||||||
g_timeout_add (2500, show_page_again, page);
|
g_timeout_add (2500, show_page_again, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct _GTestPermission GTestPermission;
|
||||||
|
typedef struct _GTestPermissionClass GTestPermissionClass;
|
||||||
|
|
||||||
|
struct _GTestPermission
|
||||||
|
{
|
||||||
|
GPermission parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GTestPermissionClass
|
||||||
|
{
|
||||||
|
GPermissionClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GTestPermission, g_test_permission, G_TYPE_PERMISSION)
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_test_permission_init (GTestPermission *test)
|
||||||
|
{
|
||||||
|
g_permission_impl_update (G_PERMISSION (test), TRUE, TRUE, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_allowed (GPermission *permission,
|
||||||
|
gboolean allowed)
|
||||||
|
{
|
||||||
|
g_permission_impl_update (permission, allowed, TRUE, TRUE);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
acquire (GPermission *permission,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return update_allowed (permission, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
acquire_async (GPermission *permission,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
task = g_task_new ((GObject*)permission, NULL, callback, user_data);
|
||||||
|
g_task_return_boolean (task, update_allowed (permission, TRUE));
|
||||||
|
g_object_unref (task);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
acquire_finish (GPermission *permission,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return g_task_propagate_boolean (G_TASK (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
release (GPermission *permission,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return update_allowed (permission, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
release_async (GPermission *permission,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
task = g_task_new ((GObject*)permission, NULL, callback, user_data);
|
||||||
|
g_task_return_boolean (task, update_allowed (permission, FALSE));
|
||||||
|
g_object_unref (task);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
release_finish (GPermission *permission,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return g_task_propagate_boolean (G_TASK (result), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_test_permission_class_init (GTestPermissionClass *class)
|
||||||
|
{
|
||||||
|
GPermissionClass *permission_class = G_PERMISSION_CLASS (class);
|
||||||
|
|
||||||
|
permission_class->acquire = acquire;
|
||||||
|
permission_class->acquire_async = acquire_async;
|
||||||
|
permission_class->acquire_finish = acquire_finish;
|
||||||
|
|
||||||
|
permission_class->release = release;
|
||||||
|
permission_class->release_async = release_async;
|
||||||
|
permission_class->release_finish = release_finish;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activate (GApplication *app)
|
activate (GApplication *app)
|
||||||
{
|
{
|
||||||
@ -1301,6 +1403,7 @@ activate (GApplication *app)
|
|||||||
{ "win.delete", { "Delete", NULL } }
|
{ "win.delete", { "Delete", NULL } }
|
||||||
};
|
};
|
||||||
gint i;
|
gint i;
|
||||||
|
GPermission *permission;
|
||||||
|
|
||||||
g_type_ensure (my_text_view_get_type ());
|
g_type_ensure (my_text_view_get_type ());
|
||||||
|
|
||||||
@ -1489,6 +1592,15 @@ activate (GApplication *app)
|
|||||||
g_signal_connect (widget2, "notify::text", G_CALLBACK (open_popover_text_changed), widget3);
|
g_signal_connect (widget2, "notify::text", G_CALLBACK (open_popover_text_changed), widget3);
|
||||||
g_signal_connect_swapped (widget3, "clicked", G_CALLBACK (gtk_widget_hide), widget);
|
g_signal_connect_swapped (widget3, "clicked", G_CALLBACK (gtk_widget_hide), widget);
|
||||||
|
|
||||||
|
widget = (GtkWidget *)gtk_builder_get_object (builder, "lockbox");
|
||||||
|
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton");
|
||||||
|
permission = g_object_new (g_test_permission_get_type (), NULL);
|
||||||
|
g_object_bind_property (permission, "allowed",
|
||||||
|
widget, "sensitive",
|
||||||
|
G_BINDING_SYNC_CREATE);
|
||||||
|
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget2), permission);
|
||||||
|
g_object_unref (permission);
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (window));
|
gtk_widget_show_all (GTK_WIDGET (window));
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
@ -2897,105 +2897,128 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkMenuButton">
|
<object class="GtkBox" id="lockbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="halign">center</property>
|
<property name="halign">start</property>
|
||||||
<property name="popover">open_popover</property>
|
<property name="spacing">6</property>
|
||||||
<style>
|
|
||||||
<class name="text-button"/>
|
|
||||||
<class name="image-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkMenuButton">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="popover">open_popover</property>
|
||||||
|
<style>
|
||||||
|
<class name="text-button"/>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">6</property>
|
||||||
<property name="label">Open</property>
|
<child>
|
||||||
</object>
|
<object class="GtkLabel">
|
||||||
</child>
|
<property name="visible">True</property>
|
||||||
<child>
|
<property name="valign">baseline</property>
|
||||||
<object class="GtkImage">
|
<property name="label">Open</property>
|
||||||
<property name="visible">True</property>
|
</object>
|
||||||
<property name="valign">baseline</property>
|
</child>
|
||||||
<property name="icon_name">pan-down-symbolic</property>
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
<property name="icon_name">pan-down-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkToggleButton" id="record_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="halign">center</property>
|
|
||||||
<signal name="toggled" handler="on_record_button_toggled"/>
|
|
||||||
<style>
|
|
||||||
<class name="text-button"/>
|
|
||||||
<class name="image-button"/>
|
|
||||||
<class name="destructive-action"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkToggleButton" id="record_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="halign">center</property>
|
||||||
|
<signal name="toggled" handler="on_record_button_toggled"/>
|
||||||
|
<style>
|
||||||
|
<class name="text-button"/>
|
||||||
|
<class name="image-button"/>
|
||||||
|
<class name="destructive-action"/>
|
||||||
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">6</property>
|
||||||
<property name="icon_name">media-record-symbolic</property>
|
<child>
|
||||||
</object>
|
<object class="GtkImage">
|
||||||
</child>
|
<property name="visible">True</property>
|
||||||
<child>
|
<property name="valign">baseline</property>
|
||||||
<object class="GtkLabel">
|
<property name="icon_name">media-record-symbolic</property>
|
||||||
<property name="visible">True</property>
|
</object>
|
||||||
<property name="valign">baseline</property>
|
</child>
|
||||||
<property name="label">Record</property>
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
<property name="label">Record</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<style>
|
|
||||||
<class name="linked"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkRadioButton" id="grid_button">
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="linked"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="grid_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="draw-indicator">False</property>
|
||||||
|
<property name="active">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-size">1</property>
|
||||||
|
<property name="icon-name">view-grid-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="list_button">
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="draw-indicator">False</property>
|
||||||
|
<property name="group">grid_button</property>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-size">1</property>
|
||||||
|
<property name="icon-name">view-list-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="circular_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="draw-indicator">False</property>
|
|
||||||
<property name="active">True</property>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="image-button"/>
|
<class name="image-button"/>
|
||||||
|
<class name="circular-button"/>
|
||||||
</style>
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="icon-size">1</property>
|
<property name="icon-size">1</property>
|
||||||
<property name="icon-name">view-grid-symbolic</property>
|
<property name="icon-name">emblem-system-symbolic</property>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkRadioButton" id="list_button">
|
|
||||||
<property name="active">True</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="draw-indicator">False</property>
|
|
||||||
<property name="group">grid_button</property>
|
|
||||||
<style>
|
|
||||||
<class name="image-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon-size">1</property>
|
|
||||||
<property name="icon-name">view-list-symbolic</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -3003,19 +3026,8 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="circular_button">
|
<object class="GtkLockButton" id="lockbutton">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<style>
|
|
||||||
<class name="image-button"/>
|
|
||||||
<class name="circular-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon-size">1</property>
|
|
||||||
<property name="icon-name">emblem-system-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -3602,7 +3614,6 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry">
|
<object class="GtkEntry">
|
||||||
@ -3610,11 +3621,6 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="placeholder_text" translatable="yes">Name…</property>
|
<property name="placeholder_text" translatable="yes">Name…</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry">
|
<object class="GtkEntry">
|
||||||
@ -3623,8 +3629,6 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
<property name="placeholder_text" translatable="yes">Age…</property>
|
<property name="placeholder_text" translatable="yes">Age…</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@ -3928,7 +3932,6 @@ bad things might happen.</property>
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="shadow-type">in</property>
|
<property name="shadow-type">in</property>
|
||||||
<property name="hscrollbar-policy">never</property>
|
<property name="hscrollbar-policy">never</property>
|
||||||
<property name="vscrollbar-policy">automatic</property>
|
|
||||||
<property name="min-content-height">70</property>
|
<property name="min-content-height">70</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTextView" id="open_popover_textview">
|
<object class="GtkTextView" id="open_popover_textview">
|
||||||
|
Reference in New Issue
Block a user