restrict-applications: Use HdyPreferencesWindow
HdyPreferencesWindow provides a neat API we can use for windows like this.
This commit is contained in:
parent
358cad3a24
commit
c68058f0f3
|
@ -26,6 +26,7 @@
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <libhandy-1/handy.h>
|
||||||
|
|
||||||
#include "restrict-applications-dialog.h"
|
#include "restrict-applications-dialog.h"
|
||||||
#include "restrict-applications-selector.h"
|
#include "restrict-applications-selector.h"
|
||||||
|
@ -53,13 +54,13 @@ struct _MctRestrictApplicationsDialog
|
||||||
GtkDialog parent_instance;
|
GtkDialog parent_instance;
|
||||||
|
|
||||||
MctRestrictApplicationsSelector *selector;
|
MctRestrictApplicationsSelector *selector;
|
||||||
GtkLabel *description;
|
HdyPreferencesGroup *group;
|
||||||
|
|
||||||
MctAppFilter *app_filter; /* (owned) (not nullable) */
|
MctAppFilter *app_filter; /* (owned) (not nullable) */
|
||||||
gchar *user_display_name; /* (owned) (nullable) */
|
gchar *user_display_name; /* (owned) (nullable) */
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (MctRestrictApplicationsDialog, mct_restrict_applications_dialog, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE (MctRestrictApplicationsDialog, mct_restrict_applications_dialog, HDY_TYPE_PREFERENCES_WINDOW)
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -195,7 +196,7 @@ mct_restrict_applications_dialog_class_init (MctRestrictApplicationsDialogClass
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/restrict-applications-dialog.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/restrict-applications-dialog.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, selector);
|
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, selector);
|
||||||
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, description);
|
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -214,15 +215,14 @@ update_description (MctRestrictApplicationsDialog *self)
|
||||||
|
|
||||||
if (self->user_display_name == NULL)
|
if (self->user_display_name == NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_hide (GTK_WIDGET (self->description));
|
hdy_preferences_group_set_description (self->group, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translators: the placeholder is a user’s full name */
|
/* Translators: the placeholder is a user’s full name */
|
||||||
description = g_strdup_printf (_("Restrict %s from using the following installed applications."),
|
description = g_strdup_printf (_("Restrict %s from using the following installed applications."),
|
||||||
self->user_display_name);
|
self->user_display_name);
|
||||||
gtk_label_set_text (self->description, description);
|
hdy_preferences_group_set_description (self->group, description);
|
||||||
gtk_widget_show (GTK_WIDGET (self->description));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,13 +24,14 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <libhandy-1/handy.h>
|
||||||
#include <libmalcontent/manager.h>
|
#include <libmalcontent/manager.h>
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define MCT_TYPE_RESTRICT_APPLICATIONS_DIALOG (mct_restrict_applications_dialog_get_type ())
|
#define MCT_TYPE_RESTRICT_APPLICATIONS_DIALOG (mct_restrict_applications_dialog_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (MctRestrictApplicationsDialog, mct_restrict_applications_dialog, MCT, RESTRICT_APPLICATIONS_DIALOG, GtkDialog)
|
G_DECLARE_FINAL_TYPE (MctRestrictApplicationsDialog, mct_restrict_applications_dialog, MCT, RESTRICT_APPLICATIONS_DIALOG, HdyPreferencesWindow)
|
||||||
|
|
||||||
MctRestrictApplicationsDialog *mct_restrict_applications_dialog_new (MctAppFilter *app_filter,
|
MctRestrictApplicationsDialog *mct_restrict_applications_dialog_new (MctAppFilter *app_filter,
|
||||||
const gchar *user_display_name);
|
const gchar *user_display_name);
|
||||||
|
|
|
@ -2,48 +2,27 @@
|
||||||
<!-- Copyright © 2020 Endless, Inc. -->
|
<!-- Copyright © 2020 Endless, Inc. -->
|
||||||
<interface domain="malcontent">
|
<interface domain="malcontent">
|
||||||
<requires lib="gtk+" version="3.12"/>
|
<requires lib="gtk+" version="3.12"/>
|
||||||
<template class="MctRestrictApplicationsDialog" parent="GtkDialog">
|
<template class="MctRestrictApplicationsDialog" parent="HdyPreferencesWindow">
|
||||||
<property name="title" translatable="yes">Restrict Applications</property>
|
<property name="title" translatable="yes">Restrict Applications</property>
|
||||||
<property name="skip-taskbar-hint">True</property>
|
<property name="skip-taskbar-hint">True</property>
|
||||||
<property name="default-width">300</property>
|
<property name="default-width">500</property>
|
||||||
<property name="default-height">500</property>
|
<property name="default-height">500</property>
|
||||||
<child internal-child="headerbar">
|
<property name="search-enabled">False</property>
|
||||||
<object class="GtkHeaderBar">
|
<child>
|
||||||
<property name="title" translatable="yes">Restrict Applications</property>
|
<object class="HdyPreferencesPage">
|
||||||
<property name="show-close-button">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="margin">18</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="description">
|
<object class="HdyPreferencesGroup" id="group">
|
||||||
|
<property name="visible">True</property>
|
||||||
<!-- Translated dynamically: -->
|
<!-- Translated dynamically: -->
|
||||||
<property name="label">Restrict {username} from using the following installed applications.</property>
|
<property name="description">Restrict {username} from using the following installed applications.</property>
|
||||||
<property name="visible">False</property>
|
<child>
|
||||||
<property name="ellipsize">none</property>
|
<object class="MctRestrictApplicationsSelector" id="selector">
|
||||||
<property name="wrap">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<child internal-child="accessible">
|
|
||||||
<object class="AtkObject">
|
|
||||||
<property name="accessible-role">static</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="MctRestrictApplicationsSelector" id="selector">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,28 +4,20 @@
|
||||||
<requires lib="gtk+" version="3.12"/>
|
<requires lib="gtk+" version="3.12"/>
|
||||||
<template class="MctRestrictApplicationsSelector" parent="GtkBox">
|
<template class="MctRestrictApplicationsSelector" parent="GtkBox">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkListBox" id="listbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="hscrollbar-policy">never</property>
|
|
||||||
<property name="min-content-height">100</property>
|
|
||||||
<property name="max-content-height">400</property>
|
|
||||||
<property name="propagate-natural-height">True</property>
|
|
||||||
<property name="shadow-type">etched-in</property>
|
|
||||||
|
|
||||||
<child>
|
<child type="placeholder">
|
||||||
<object class="GtkListBox" id="listbox">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="selection-mode">none</property>
|
<property name="label" translatable="yes">No applications found to restrict.</property>
|
||||||
|
|
||||||
<child type="placeholder">
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">No applications found to restrict.</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
<class name="content"/>
|
||||||
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -130,10 +130,6 @@ static gboolean on_restrict_applications_dialog_delete_event_cb (GtkWidget *widg
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
static void on_restrict_applications_dialog_response_cb (GtkDialog *dialog,
|
|
||||||
gint response_id,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static void on_set_age_action_activated (GSimpleAction *action,
|
static void on_set_age_action_activated (GSimpleAction *action,
|
||||||
GVariant *param,
|
GVariant *param,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@ -623,16 +619,6 @@ on_restrict_applications_dialog_delete_event_cb (GtkWidget *widget,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
on_restrict_applications_dialog_response_cb (GtkDialog *dialog,
|
|
||||||
gint response_id,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
MctUserControls *self = MCT_USER_CONTROLS (user_data);
|
|
||||||
|
|
||||||
on_restrict_applications_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL, self);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_set_age_action_activated (GSimpleAction *action,
|
on_set_age_action_activated (GSimpleAction *action,
|
||||||
GVariant *param,
|
GVariant *param,
|
||||||
|
@ -1020,7 +1006,6 @@ mct_user_controls_class_init (MctUserControlsClass *klass)
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_restrict_installation_switch_active_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_restrict_installation_switch_active_changed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_restrict_web_browsers_switch_active_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_restrict_web_browsers_switch_active_changed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_restrict_applications_dialog_delete_event_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_restrict_applications_dialog_delete_event_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_restrict_applications_dialog_response_cb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -178,8 +178,6 @@
|
||||||
<property name="visible">False</property>
|
<property name="visible">False</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
<property name="destroy-with-parent">False</property>
|
<property name="destroy-with-parent">False</property>
|
||||||
<property name="use-header-bar">1</property>
|
|
||||||
<signal name="delete-event" handler="on_restrict_applications_dialog_delete_event_cb" />
|
<signal name="delete-event" handler="on_restrict_applications_dialog_delete_event_cb" />
|
||||||
<signal name="response" handler="on_restrict_applications_dialog_response_cb" />
|
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Loading…
Reference in New Issue