malcontent-control: Reformat and rename code from gnome-control-center
Make it fit in with the surrounding code style, and rename the classes to `MctCarousel` and `MctUserControls`. List them in `meson.build` and `POTFILES.in`. No other changes. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
aa6ece8a91
commit
2c043a6bd5
|
@ -5,7 +5,7 @@ before_script:
|
||||||
libxml2-devel dbus-daemon
|
libxml2-devel dbus-daemon
|
||||||
glib2-devel dbus-devel gobject-introspection-devel
|
glib2-devel dbus-devel gobject-introspection-devel
|
||||||
gettext-devel polkit-devel polkit-gnome git
|
gettext-devel polkit-devel polkit-gnome git
|
||||||
lcov pam-devel gtk3-devel
|
lcov pam-devel gtk3-devel accountsservice-devel flatpak-devel
|
||||||
- export LANG=C.UTF-8
|
- export LANG=C.UTF-8
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
*
|
*
|
||||||
* Copyright 2016 (c) Red Hat, Inc,
|
* Copyright © 2016 Red Hat, Inc.
|
||||||
|
* Copyright © 2019 Endless Mobile, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -15,49 +16,52 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Author: Felipe Borges <felipeborges@gnome.org>
|
* Authors:
|
||||||
|
* - Felipe Borges <felipeborges@gnome.org>
|
||||||
|
* - Philip Withnall <withnall@endlessm.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cc-carousel.h"
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "carousel.h"
|
||||||
|
|
||||||
|
|
||||||
#define ARROW_SIZE 20
|
#define ARROW_SIZE 20
|
||||||
|
|
||||||
struct _CcCarouselItem {
|
struct _MctCarouselItem {
|
||||||
GtkRadioButton parent;
|
GtkRadioButton parent;
|
||||||
|
|
||||||
gint page;
|
gint page;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcCarouselItem, cc_carousel_item, GTK_TYPE_RADIO_BUTTON)
|
G_DEFINE_TYPE (MctCarouselItem, mct_carousel_item, GTK_TYPE_RADIO_BUTTON)
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
cc_carousel_item_new (void)
|
mct_carousel_item_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (CC_TYPE_CAROUSEL_ITEM, NULL);
|
return g_object_new (MCT_TYPE_CAROUSEL_ITEM, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_item_class_init (CcCarouselItemClass *klass)
|
mct_carousel_item_class_init (MctCarouselItemClass *klass)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_item_init (CcCarouselItem *self)
|
mct_carousel_item_init (MctCarouselItem *self)
|
||||||
{
|
{
|
||||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (self), FALSE);
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (self), FALSE);
|
||||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
|
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
|
||||||
"carousel-item");
|
"carousel-item");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _CcCarousel {
|
struct _MctCarousel {
|
||||||
GtkRevealer parent;
|
GtkRevealer parent;
|
||||||
|
|
||||||
GList *children;
|
GList *children;
|
||||||
gint visible_page;
|
gint visible_page;
|
||||||
CcCarouselItem *selected_item;
|
MctCarouselItem *selected_item;
|
||||||
GtkWidget *last_box;
|
GtkWidget *last_box;
|
||||||
GtkWidget *arrow;
|
GtkWidget *arrow;
|
||||||
gint arrow_start_x;
|
gint arrow_start_x;
|
||||||
|
@ -70,7 +74,7 @@ struct _CcCarousel {
|
||||||
GtkStyleProvider *provider;
|
GtkStyleProvider *provider;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcCarousel, cc_carousel, GTK_TYPE_REVEALER)
|
G_DEFINE_TYPE (MctCarousel, mct_carousel, GTK_TYPE_REVEALER)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ITEM_ACTIVATED,
|
ITEM_ACTIVATED,
|
||||||
|
@ -82,8 +86,8 @@ static guint signals[NUM_SIGNALS] = { 0, };
|
||||||
#define ITEMS_PER_PAGE 3
|
#define ITEMS_PER_PAGE 3
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
cc_carousel_item_get_x (CcCarouselItem *item,
|
mct_carousel_item_get_x (MctCarouselItem *item,
|
||||||
CcCarousel *carousel)
|
MctCarousel *carousel)
|
||||||
{
|
{
|
||||||
GtkWidget *widget, *parent;
|
GtkWidget *widget, *parent;
|
||||||
gint width;
|
gint width;
|
||||||
|
@ -106,7 +110,7 @@ cc_carousel_item_get_x (CcCarouselItem *item,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_move_arrow (CcCarousel *self)
|
mct_carousel_move_arrow (MctCarousel *self)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
gchar *css;
|
gchar *css;
|
||||||
|
@ -117,7 +121,7 @@ cc_carousel_move_arrow (CcCarousel *self)
|
||||||
if (!self->selected_item)
|
if (!self->selected_item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
end_x = cc_carousel_item_get_x (self->selected_item, self);
|
end_x = mct_carousel_item_get_x (self->selected_item, self);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (self->arrow);
|
context = gtk_widget_get_style_context (self->arrow);
|
||||||
if (self->provider)
|
if (self->provider)
|
||||||
|
@ -155,7 +159,7 @@ cc_carousel_move_arrow (CcCarousel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
get_last_page_number (CcCarousel *self)
|
get_last_page_number (MctCarousel *self)
|
||||||
{
|
{
|
||||||
if (g_list_length (self->children) == 0)
|
if (g_list_length (self->children) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -164,28 +168,28 @@ get_last_page_number (CcCarousel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_buttons_visibility (CcCarousel *self)
|
update_buttons_visibility (MctCarousel *self)
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (self->go_back_button, (self->visible_page > 0));
|
gtk_widget_set_visible (self->go_back_button, (self->visible_page > 0));
|
||||||
gtk_widget_set_visible (self->go_next_button, (self->visible_page < get_last_page_number (self)));
|
gtk_widget_set_visible (self->go_next_button, (self->visible_page < get_last_page_number (self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cc_carousel_find_item:
|
* mct_carousel_find_item:
|
||||||
* @carousel: an CcCarousel instance
|
* @carousel: an MctCarousel instance
|
||||||
* @data: user data passed to the comparation function
|
* @data: user data passed to the comparation function
|
||||||
* @func: the function to call for each element.
|
* @func: the function to call for each element.
|
||||||
* It should return 0 when the desired element is found
|
* It should return 0 when the desired element is found
|
||||||
*
|
*
|
||||||
* Finds an CcCarousel item using the supplied function to find the
|
* Finds an MctCarousel item using the supplied function to find the
|
||||||
* desired element.
|
* desired element.
|
||||||
* Ideally useful for matching a model object and its correspondent
|
* Ideally useful for matching a model object and its correspondent
|
||||||
* widget.
|
* widget.
|
||||||
*
|
*
|
||||||
* Returns: the found CcCarouselItem, or %NULL if it is not found
|
* Returns: the found MctCarouselItem, or %NULL if it is not found
|
||||||
*/
|
*/
|
||||||
CcCarouselItem *
|
MctCarouselItem *
|
||||||
cc_carousel_find_item (CcCarousel *self,
|
mct_carousel_find_item (MctCarousel *self,
|
||||||
gconstpointer data,
|
gconstpointer data,
|
||||||
GCompareFunc func)
|
GCompareFunc func)
|
||||||
{
|
{
|
||||||
|
@ -203,18 +207,18 @@ cc_carousel_find_item (CcCarousel *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_item_toggled (CcCarouselItem *item,
|
on_item_toggled (MctCarouselItem *item,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcCarousel *self = CC_CAROUSEL (user_data);
|
MctCarousel *self = MCT_CAROUSEL (user_data);
|
||||||
|
|
||||||
cc_carousel_select_item (self, item);
|
mct_carousel_select_item (self, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_carousel_select_item (CcCarousel *self,
|
mct_carousel_select_item (MctCarousel *self,
|
||||||
CcCarouselItem *item)
|
MctCarouselItem *item)
|
||||||
{
|
{
|
||||||
gchar *page_name;
|
gchar *page_name;
|
||||||
gboolean page_changed = TRUE;
|
gboolean page_changed = TRUE;
|
||||||
|
@ -231,7 +235,7 @@ cc_carousel_select_item (CcCarousel *self,
|
||||||
if (self->selected_item != NULL)
|
if (self->selected_item != NULL)
|
||||||
{
|
{
|
||||||
page_changed = (self->selected_item->page != item->page);
|
page_changed = (self->selected_item->page != item->page);
|
||||||
self->arrow_start_x = cc_carousel_item_get_x (self->selected_item, self);
|
self->arrow_start_x = mct_carousel_item_get_x (self->selected_item, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->selected_item = item;
|
self->selected_item = item;
|
||||||
|
@ -240,7 +244,7 @@ cc_carousel_select_item (CcCarousel *self,
|
||||||
|
|
||||||
if (!page_changed)
|
if (!page_changed)
|
||||||
{
|
{
|
||||||
cc_carousel_move_arrow (self);
|
mct_carousel_move_arrow (self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,38 +255,38 @@ cc_carousel_select_item (CcCarousel *self,
|
||||||
|
|
||||||
update_buttons_visibility (self);
|
update_buttons_visibility (self);
|
||||||
|
|
||||||
/* cc_carousel_move_arrow is called from on_transition_running */
|
/* mct_carousel_move_arrow is called from on_transition_running */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_select_item_at_index (CcCarousel *self,
|
mct_carousel_select_item_at_index (MctCarousel *self,
|
||||||
gint index)
|
gint index)
|
||||||
{
|
{
|
||||||
GList *l = NULL;
|
GList *l = NULL;
|
||||||
|
|
||||||
l = g_list_nth (self->children, index);
|
l = g_list_nth (self->children, index);
|
||||||
cc_carousel_select_item (self, l->data);
|
mct_carousel_select_item (self, l->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_goto_previous_page (GtkWidget *button,
|
mct_carousel_goto_previous_page (GtkWidget *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcCarousel *self = CC_CAROUSEL (user_data);
|
MctCarousel *self = MCT_CAROUSEL (user_data);
|
||||||
|
|
||||||
self->visible_page--;
|
self->visible_page--;
|
||||||
if (self->visible_page < 0)
|
if (self->visible_page < 0)
|
||||||
self->visible_page = 0;
|
self->visible_page = 0;
|
||||||
|
|
||||||
/* Select first item of the page */
|
/* Select first item of the page */
|
||||||
cc_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
mct_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_goto_next_page (GtkWidget *button,
|
mct_carousel_goto_next_page (GtkWidget *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcCarousel *self = CC_CAROUSEL (user_data);
|
MctCarousel *self = MCT_CAROUSEL (user_data);
|
||||||
gint last_page;
|
gint last_page;
|
||||||
|
|
||||||
last_page = get_last_page_number (self);
|
last_page = get_last_page_number (self);
|
||||||
|
@ -292,18 +296,19 @@ cc_carousel_goto_next_page (GtkWidget *button,
|
||||||
self->visible_page = last_page;
|
self->visible_page = last_page;
|
||||||
|
|
||||||
/* Select first item of the page */
|
/* Select first item of the page */
|
||||||
cc_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
mct_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_add (GtkContainer *container,
|
mct_carousel_add (GtkContainer *container,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
CcCarousel *self = CC_CAROUSEL (container);
|
MctCarousel *self = MCT_CAROUSEL (container);
|
||||||
gboolean last_box_is_full;
|
gboolean last_box_is_full;
|
||||||
|
|
||||||
if (!CC_IS_CAROUSEL_ITEM (widget)) {
|
if (!MCT_IS_CAROUSEL_ITEM (widget))
|
||||||
GTK_CONTAINER_CLASS (cc_carousel_parent_class)->add (container, widget);
|
{
|
||||||
|
GTK_CONTAINER_CLASS (mct_carousel_parent_class)->add (container, widget);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,16 +316,17 @@ cc_carousel_add (GtkContainer *container,
|
||||||
gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
|
gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
|
||||||
|
|
||||||
self->children = g_list_append (self->children, widget);
|
self->children = g_list_append (self->children, widget);
|
||||||
CC_CAROUSEL_ITEM (widget)->page = get_last_page_number (self);
|
MCT_CAROUSEL_ITEM (widget)->page = get_last_page_number (self);
|
||||||
if (self->selected_item != NULL)
|
if (self->selected_item != NULL)
|
||||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (widget), GTK_RADIO_BUTTON (self->selected_item));
|
gtk_radio_button_join_group (GTK_RADIO_BUTTON (widget), GTK_RADIO_BUTTON (self->selected_item));
|
||||||
g_signal_connect (widget, "button-press-event", G_CALLBACK (on_item_toggled), self);
|
g_signal_connect (widget, "button-press-event", G_CALLBACK (on_item_toggled), self);
|
||||||
|
|
||||||
last_box_is_full = ((g_list_length (self->children) - 1) % ITEMS_PER_PAGE == 0);
|
last_box_is_full = ((g_list_length (self->children) - 1) % ITEMS_PER_PAGE == 0);
|
||||||
if (last_box_is_full) {
|
if (last_box_is_full)
|
||||||
|
{
|
||||||
gchar *page;
|
gchar *page;
|
||||||
|
|
||||||
page = g_strdup_printf ("%d", CC_CAROUSEL_ITEM (widget)->page);
|
page = g_strdup_printf ("%d", MCT_CAROUSEL_ITEM (widget)->page);
|
||||||
self->last_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
self->last_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
gtk_widget_show (self->last_box);
|
gtk_widget_show (self->last_box);
|
||||||
gtk_widget_set_valign (self->last_box, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (self->last_box, GTK_ALIGN_CENTER);
|
||||||
|
@ -333,11 +339,18 @@ cc_carousel_add (GtkContainer *container,
|
||||||
update_buttons_visibility (self);
|
update_buttons_visibility (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
destroy_widget_cb (GtkWidget *widget,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (widget);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_carousel_purge_items (CcCarousel *self)
|
mct_carousel_purge_items (MctCarousel *self)
|
||||||
{
|
{
|
||||||
gtk_container_forall (GTK_CONTAINER (self->stack),
|
gtk_container_forall (GTK_CONTAINER (self->stack),
|
||||||
(GtkCallback) gtk_widget_destroy,
|
destroy_widget_cb,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_list_free (self->children);
|
g_list_free (self->children);
|
||||||
|
@ -346,43 +359,44 @@ cc_carousel_purge_items (CcCarousel *self)
|
||||||
self->selected_item = NULL;
|
self->selected_item = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CcCarousel *
|
MctCarousel *
|
||||||
cc_carousel_new (void)
|
mct_carousel_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (CC_TYPE_CAROUSEL, NULL);
|
return g_object_new (MCT_TYPE_CAROUSEL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_class_init (CcCarouselClass *klass)
|
mct_carousel_class_init (MctCarouselClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
|
||||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (wclass,
|
gtk_widget_class_set_template_from_resource (wclass,
|
||||||
"/org/gnome/control-center/user-accounts/cc-carousel.ui");
|
"/org/freedesktop/MalcontentControl/ui/carousel.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child (wclass, CcCarousel, stack);
|
gtk_widget_class_bind_template_child (wclass, MctCarousel, stack);
|
||||||
gtk_widget_class_bind_template_child (wclass, CcCarousel, go_back_button);
|
gtk_widget_class_bind_template_child (wclass, MctCarousel, go_back_button);
|
||||||
gtk_widget_class_bind_template_child (wclass, CcCarousel, go_next_button);
|
gtk_widget_class_bind_template_child (wclass, MctCarousel, go_next_button);
|
||||||
gtk_widget_class_bind_template_child (wclass, CcCarousel, arrow);
|
gtk_widget_class_bind_template_child (wclass, MctCarousel, arrow);
|
||||||
|
|
||||||
gtk_widget_class_bind_template_callback (wclass, cc_carousel_goto_previous_page);
|
gtk_widget_class_bind_template_callback (wclass, mct_carousel_goto_previous_page);
|
||||||
gtk_widget_class_bind_template_callback (wclass, cc_carousel_goto_next_page);
|
gtk_widget_class_bind_template_callback (wclass, mct_carousel_goto_next_page);
|
||||||
|
|
||||||
container_class->add = cc_carousel_add;
|
container_class->add = mct_carousel_add;
|
||||||
|
|
||||||
signals[ITEM_ACTIVATED] = g_signal_new ("item-activated",
|
signals[ITEM_ACTIVATED] =
|
||||||
CC_TYPE_CAROUSEL,
|
g_signal_new ("item-activated",
|
||||||
|
MCT_TYPE_CAROUSEL,
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
0,
|
0,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__OBJECT,
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
CC_TYPE_CAROUSEL_ITEM);
|
MCT_TYPE_CAROUSEL_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_size_allocate (CcCarousel *self)
|
on_size_allocate (MctCarousel *self)
|
||||||
{
|
{
|
||||||
if (self->selected_item == NULL)
|
if (self->selected_item == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -390,19 +404,19 @@ on_size_allocate (CcCarousel *self)
|
||||||
if (gtk_stack_get_transition_running (self->stack))
|
if (gtk_stack_get_transition_running (self->stack))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self->arrow_start_x = cc_carousel_item_get_x (self->selected_item, self);
|
self->arrow_start_x = mct_carousel_item_get_x (self->selected_item, self);
|
||||||
cc_carousel_move_arrow (self);
|
mct_carousel_move_arrow (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_transition_running (CcCarousel *self)
|
on_transition_running (MctCarousel *self)
|
||||||
{
|
{
|
||||||
if (!gtk_stack_get_transition_running (self->stack))
|
if (!gtk_stack_get_transition_running (self->stack))
|
||||||
cc_carousel_move_arrow (self);
|
mct_carousel_move_arrow (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_carousel_init (CcCarousel *self)
|
mct_carousel_init (MctCarousel *self)
|
||||||
{
|
{
|
||||||
GtkStyleProvider *provider;
|
GtkStyleProvider *provider;
|
||||||
|
|
||||||
|
@ -410,7 +424,7 @@ cc_carousel_init (CcCarousel *self)
|
||||||
|
|
||||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||||
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
|
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
|
||||||
"/org/gnome/control-center/user-accounts/carousel.css");
|
"/org/freedesktop/MalcontentControl/ui/carousel.css");
|
||||||
|
|
||||||
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||||
provider,
|
provider,
|
||||||
|
@ -423,7 +437,7 @@ cc_carousel_init (CcCarousel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
cc_carousel_get_item_count (CcCarousel *self)
|
mct_carousel_get_item_count (MctCarousel *self)
|
||||||
{
|
{
|
||||||
return g_list_length (self->children);
|
return g_list_length (self->children);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
*
|
*
|
||||||
* Copyright 2016 (c) Red Hat, Inc,
|
* Copyright © 2016 Red Hat, Inc.
|
||||||
|
* Copyright © 2019 Endless Mobile, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -15,36 +16,37 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Author: Felipe Borges <felipeborges@gnome.org>
|
* Authors:
|
||||||
|
* - Felipe Borges <felipeborges@gnome.org>
|
||||||
|
* - Philip Withnall <withnall@endlessm.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_CAROUSEL_ITEM (cc_carousel_item_get_type ())
|
#define MCT_TYPE_CAROUSEL_ITEM (mct_carousel_item_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (MctCarouselItem, mct_carousel_item, MCT, CAROUSEL_ITEM, GtkRadioButton)
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CcCarouselItem, cc_carousel_item, CC, CAROUSEL_ITEM, GtkRadioButton)
|
#define MCT_TYPE_CAROUSEL (mct_carousel_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (MctCarousel, mct_carousel, MCT, CAROUSEL, GtkRevealer)
|
||||||
|
|
||||||
#define CC_TYPE_CAROUSEL (cc_carousel_get_type ())
|
GtkWidget *mct_carousel_item_new (void);
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CcCarousel, cc_carousel, CC, CAROUSEL, GtkRevealer)
|
MctCarousel *mct_carousel_new (void);
|
||||||
|
|
||||||
GtkWidget *cc_carousel_item_new (void);
|
void mct_carousel_purge_items (MctCarousel *self);
|
||||||
|
|
||||||
CcCarousel *cc_carousel_new (void);
|
MctCarouselItem *mct_carousel_find_item (MctCarousel *self,
|
||||||
|
|
||||||
void cc_carousel_purge_items (CcCarousel *self);
|
|
||||||
|
|
||||||
CcCarouselItem *cc_carousel_find_item (CcCarousel *self,
|
|
||||||
gconstpointer data,
|
gconstpointer data,
|
||||||
GCompareFunc func);
|
GCompareFunc func);
|
||||||
|
|
||||||
void cc_carousel_select_item (CcCarousel *self,
|
void mct_carousel_select_item (MctCarousel *self,
|
||||||
CcCarouselItem *item);
|
MctCarouselItem *item);
|
||||||
|
|
||||||
guint cc_carousel_get_item_count (CcCarousel *self);
|
guint mct_carousel_get_item_count (MctCarousel *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright © 2016 Red Hat, Inc. -->
|
||||||
|
<!-- Copyright © 2020 Endless, Inc. -->
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.8 -->
|
<requires lib="gtk+" version="3.12"/>
|
||||||
<template class="CcCarousel" parent="GtkRevealer">
|
<template class="MctCarousel" parent="GtkRevealer">
|
||||||
<property name="transition_duration">400</property>
|
<property name="transition_duration">400</property>
|
||||||
<property name="reveal-child">True</property>
|
<property name="reveal-child">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -43,7 +45,7 @@
|
||||||
<property name="icon_name">go-previous-symbolic</property>
|
<property name="icon_name">go-previous-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<signal name="clicked" handler="cc_carousel_goto_previous_page" object="CcCarousel" swapped="no"/>
|
<signal name="clicked" handler="mct_carousel_goto_previous_page" object="MctCarousel" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="pack_type">GTK_PACK_START</property>
|
<property name="pack_type">GTK_PACK_START</property>
|
||||||
|
@ -64,7 +66,7 @@
|
||||||
<property name="icon_name">go-next-symbolic</property>
|
<property name="icon_name">go-next-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<signal name="clicked" handler="cc_carousel_goto_next_page" object="CcCarousel" swapped="no"/>
|
<signal name="clicked" handler="mct_carousel_goto_next_page" object="MctCarousel" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="pack_type">GTK_PACK_END</property>
|
<property name="pack_type">GTK_PACK_END</property>
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<!-- Copyright © 2019 Endless Mobile, Inc. -->
|
<!-- Copyright © 2019 Endless Mobile, Inc. -->
|
||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/org/freedesktop/MalcontentControl/ui">
|
<gresource prefix="/org/freedesktop/MalcontentControl/ui">
|
||||||
|
<file>carousel.css</file>
|
||||||
|
<file preprocess="xml-stripblanks">carousel.ui</file>
|
||||||
<file preprocess="xml-stripblanks">main.ui</file>
|
<file preprocess="xml-stripblanks">main.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">user-controls.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
|
@ -14,13 +14,23 @@ malcontent_control = executable('malcontent-control',
|
||||||
[
|
[
|
||||||
'application.c',
|
'application.c',
|
||||||
'application.h',
|
'application.h',
|
||||||
|
'carousel.c',
|
||||||
|
'carousel.h',
|
||||||
|
'gs-content-rating.c',
|
||||||
|
'gs-content-rating.h',
|
||||||
'main.c',
|
'main.c',
|
||||||
|
'user-controls.c',
|
||||||
|
'user-controls.h',
|
||||||
|
'user-image.c',
|
||||||
|
'user-image.h',
|
||||||
] + resources,
|
] + resources,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
|
dependency('accountsservice'),
|
||||||
dependency('gio-2.0', version: '>= 2.44'),
|
dependency('gio-2.0', version: '>= 2.44'),
|
||||||
dependency('glib-2.0', version: '>= 2.54.2'),
|
dependency('glib-2.0', version: '>= 2.54.2'),
|
||||||
dependency('gobject-2.0', version: '>= 2.54'),
|
dependency('gobject-2.0', version: '>= 2.54'),
|
||||||
dependency('gtk+-3.0'),
|
dependency('gtk+-3.0'),
|
||||||
|
dependency('flatpak'),
|
||||||
libmalcontent_dep,
|
libmalcontent_dep,
|
||||||
],
|
],
|
||||||
include_directories: root_inc,
|
include_directories: root_inc,
|
||||||
|
@ -75,7 +85,11 @@ if xmllint.found()
|
||||||
args: [
|
args: [
|
||||||
'--nonet', '--noblanks', '--noout',
|
'--nonet', '--noblanks', '--noout',
|
||||||
'--relaxng', join_paths(gtk_prefix, 'share', 'gtk-3.0', 'gtkbuilder.rng'),
|
'--relaxng', join_paths(gtk_prefix, 'share', 'gtk-3.0', 'gtkbuilder.rng'),
|
||||||
files('main.ui'),
|
files(
|
||||||
|
'carousel.ui',
|
||||||
|
'main.ui',
|
||||||
|
'user-controls.ui',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
suite: ['malcontent-control'],
|
suite: ['malcontent-control'],
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* cc-app-permissions.c
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
*
|
*
|
||||||
* Copyright 2018, 2019 Endless, Inc.
|
* Copyright © 2018, 2019, 2020 Endless Mobile, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -13,9 +13,11 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* Authors:
|
||||||
|
* - Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||||
|
* - Philip Withnall <withnall@endlessm.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libmalcontent/malcontent.h>
|
#include <libmalcontent/malcontent.h>
|
||||||
|
@ -26,15 +28,15 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include "gs-content-rating.h"
|
#include "gs-content-rating.h"
|
||||||
|
#include "user-controls.h"
|
||||||
|
|
||||||
#include "cc-app-permissions.h"
|
|
||||||
|
|
||||||
#define WEB_BROWSERS_CONTENT_TYPE "x-scheme-handler/http"
|
#define WEB_BROWSERS_CONTENT_TYPE "x-scheme-handler/http"
|
||||||
|
|
||||||
/* The value which we store as an age to indicate that OARS filtering is disabled. */
|
/* The value which we store as an age to indicate that OARS filtering is disabled. */
|
||||||
static const guint32 oars_disabled_age = (guint32) -1;
|
static const guint32 oars_disabled_age = (guint32) -1;
|
||||||
|
|
||||||
struct _CcAppPermissions
|
struct _MctUserControls
|
||||||
{
|
{
|
||||||
GtkGrid parent_instance;
|
GtkGrid parent_instance;
|
||||||
|
|
||||||
|
@ -79,11 +81,11 @@ static gint compare_app_info_cb (gconstpointer a,
|
||||||
|
|
||||||
static void on_allow_installation_switch_active_changed_cb (GtkSwitch *s,
|
static void on_allow_installation_switch_active_changed_cb (GtkSwitch *s,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CcAppPermissions *self);
|
MctUserControls *self);
|
||||||
|
|
||||||
static void on_allow_web_browsers_switch_active_changed_cb (GtkSwitch *s,
|
static void on_allow_web_browsers_switch_active_changed_cb (GtkSwitch *s,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CcAppPermissions *self);
|
MctUserControls *self);
|
||||||
|
|
||||||
static void on_set_age_action_activated (GSimpleAction *action,
|
static void on_set_age_action_activated (GSimpleAction *action,
|
||||||
GVariant *param,
|
GVariant *param,
|
||||||
|
@ -93,7 +95,7 @@ static void on_permission_allowed_cb (GObject *obj,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcAppPermissions, cc_app_permissions, GTK_TYPE_GRID)
|
G_DEFINE_TYPE (MctUserControls, mct_user_controls, GTK_TYPE_GRID)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -165,7 +167,7 @@ app_compare_id_length_cb (gconstpointer a,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reload_apps (CcAppPermissions *self)
|
reload_apps (MctUserControls *self)
|
||||||
{
|
{
|
||||||
GList *iter, *apps;
|
GList *iter, *apps;
|
||||||
g_autoptr(GHashTable) seen_flatpak_ids = NULL;
|
g_autoptr(GHashTable) seen_flatpak_ids = NULL;
|
||||||
|
@ -272,7 +274,7 @@ static void
|
||||||
app_info_changed_cb (GAppInfoMonitor *monitor,
|
app_info_changed_cb (GAppInfoMonitor *monitor,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = CC_APP_PERMISSIONS (user_data);
|
MctUserControls *self = MCT_USER_CONTROLS (user_data);
|
||||||
|
|
||||||
reload_apps (self);
|
reload_apps (self);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +290,7 @@ get_content_rating_system (ActUser *user)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
schedule_update_blacklisted_apps (CcAppPermissions *self)
|
schedule_update_blacklisted_apps (MctUserControls *self)
|
||||||
{
|
{
|
||||||
if (self->blacklist_apps_source_id > 0)
|
if (self->blacklist_apps_source_id > 0)
|
||||||
return;
|
return;
|
||||||
|
@ -299,7 +301,7 @@ schedule_update_blacklisted_apps (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flush_update_blacklisted_apps (CcAppPermissions *self)
|
flush_update_blacklisted_apps (MctUserControls *self)
|
||||||
{
|
{
|
||||||
if (self->blacklist_apps_source_id > 0)
|
if (self->blacklist_apps_source_id > 0)
|
||||||
{
|
{
|
||||||
|
@ -310,7 +312,7 @@ flush_update_blacklisted_apps (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_app_filter (CcAppPermissions *self)
|
update_app_filter (MctUserControls *self)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
@ -335,7 +337,7 @@ update_app_filter (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_categories_from_language (CcAppPermissions *self)
|
update_categories_from_language (MctUserControls *self)
|
||||||
{
|
{
|
||||||
GsContentRatingSystem rating_system;
|
GsContentRatingSystem rating_system;
|
||||||
const gchar * const * entries;
|
const gchar * const * entries;
|
||||||
|
@ -387,12 +389,13 @@ oars_value_to_string (MctAppFilterOarsValue oars_value)
|
||||||
return "moderate";
|
return "moderate";
|
||||||
case MCT_APP_FILTER_OARS_VALUE_INTENSE:
|
case MCT_APP_FILTER_OARS_VALUE_INTENSE:
|
||||||
return "intense";
|
return "intense";
|
||||||
}
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_oars_level (CcAppPermissions *self)
|
update_oars_level (MctUserControls *self)
|
||||||
{
|
{
|
||||||
GsContentRatingSystem rating_system;
|
GsContentRatingSystem rating_system;
|
||||||
const gchar *rating_age_category;
|
const gchar *rating_age_category;
|
||||||
|
@ -434,7 +437,7 @@ update_oars_level (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_allow_app_installation (CcAppPermissions *self)
|
update_allow_app_installation (MctUserControls *self)
|
||||||
{
|
{
|
||||||
gboolean allow_system_installation;
|
gboolean allow_system_installation;
|
||||||
gboolean allow_user_installation;
|
gboolean allow_user_installation;
|
||||||
|
@ -490,7 +493,7 @@ update_allow_app_installation (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_allow_web_browsers (CcAppPermissions *self)
|
update_allow_web_browsers (MctUserControls *self)
|
||||||
{
|
{
|
||||||
gboolean allow_web_browsers;
|
gboolean allow_web_browsers;
|
||||||
|
|
||||||
|
@ -511,7 +514,7 @@ update_allow_web_browsers (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_parental_control_settings (CcAppPermissions *self)
|
setup_parental_control_settings (MctUserControls *self)
|
||||||
{
|
{
|
||||||
gboolean is_authorized;
|
gboolean is_authorized;
|
||||||
|
|
||||||
|
@ -540,7 +543,7 @@ setup_parental_control_settings (CcAppPermissions *self)
|
||||||
|
|
||||||
/* Will return %NULL if @flatpak_id is not installed. */
|
/* Will return %NULL if @flatpak_id is not installed. */
|
||||||
static gchar *
|
static gchar *
|
||||||
get_flatpak_ref_for_app_id (CcAppPermissions *self,
|
get_flatpak_ref_for_app_id (MctUserControls *self,
|
||||||
const gchar *flatpak_id)
|
const gchar *flatpak_id)
|
||||||
{
|
{
|
||||||
g_autoptr(FlatpakInstalledRef) ref = NULL;
|
g_autoptr(FlatpakInstalledRef) ref = NULL;
|
||||||
|
@ -588,7 +591,7 @@ blacklist_apps_cb (gpointer data)
|
||||||
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
|
||||||
g_autoptr(MctAppFilter) new_filter = NULL;
|
g_autoptr(MctAppFilter) new_filter = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
CcAppPermissions *self = data;
|
MctUserControls *self = data;
|
||||||
GDesktopAppInfo *app;
|
GDesktopAppInfo *app;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gboolean allow_web_browsers;
|
gboolean allow_web_browsers;
|
||||||
|
@ -706,7 +709,7 @@ blacklist_apps_cb (gpointer data)
|
||||||
static void
|
static void
|
||||||
on_allow_installation_switch_active_changed_cb (GtkSwitch *s,
|
on_allow_installation_switch_active_changed_cb (GtkSwitch *s,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CcAppPermissions *self)
|
MctUserControls *self)
|
||||||
{
|
{
|
||||||
/* See the comment about policy in update_allow_app_installation(). */
|
/* See the comment about policy in update_allow_app_installation(). */
|
||||||
if (s == self->allow_user_installation_switch &&
|
if (s == self->allow_user_installation_switch &&
|
||||||
|
@ -729,7 +732,7 @@ on_allow_installation_switch_active_changed_cb (GtkSwitch *s,
|
||||||
static void
|
static void
|
||||||
on_allow_web_browsers_switch_active_changed_cb (GtkSwitch *s,
|
on_allow_web_browsers_switch_active_changed_cb (GtkSwitch *s,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CcAppPermissions *self)
|
MctUserControls *self)
|
||||||
{
|
{
|
||||||
/* Save the changes. */
|
/* Save the changes. */
|
||||||
schedule_update_blacklisted_apps (self);
|
schedule_update_blacklisted_apps (self);
|
||||||
|
@ -738,7 +741,7 @@ on_allow_web_browsers_switch_active_changed_cb (GtkSwitch *s,
|
||||||
static void
|
static void
|
||||||
on_switch_active_changed_cb (GtkSwitch *s,
|
on_switch_active_changed_cb (GtkSwitch *s,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CcAppPermissions *self)
|
MctUserControls *self)
|
||||||
{
|
{
|
||||||
GAppInfo *app;
|
GAppInfo *app;
|
||||||
gboolean allowed;
|
gboolean allowed;
|
||||||
|
@ -773,14 +776,14 @@ create_row_for_app_cb (gpointer item,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_autoptr(GIcon) icon = NULL;
|
g_autoptr(GIcon) icon = NULL;
|
||||||
CcAppPermissions *self;
|
MctUserControls *self;
|
||||||
GtkWidget *box, *w;
|
GtkWidget *box, *w;
|
||||||
GAppInfo *app;
|
GAppInfo *app;
|
||||||
gboolean allowed;
|
gboolean allowed;
|
||||||
const gchar *app_name;
|
const gchar *app_name;
|
||||||
gint size;
|
gint size;
|
||||||
|
|
||||||
self = CC_APP_PERMISSIONS (user_data);
|
self = MCT_USER_CONTROLS (user_data);
|
||||||
app = item;
|
app = item;
|
||||||
app_name = g_app_info_get_name (app);
|
app_name = g_app_info_get_name (app);
|
||||||
|
|
||||||
|
@ -852,13 +855,13 @@ on_set_age_action_activated (GSimpleAction *action,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GsContentRatingSystem rating_system;
|
GsContentRatingSystem rating_system;
|
||||||
CcAppPermissions *self;
|
MctUserControls *self;
|
||||||
const gchar * const * entries;
|
const gchar * const * entries;
|
||||||
const guint *ages;
|
const guint *ages;
|
||||||
guint age;
|
guint age;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
self = CC_APP_PERMISSIONS (user_data);
|
self = MCT_USER_CONTROLS (user_data);
|
||||||
age = g_variant_get_uint32 (param);
|
age = g_variant_get_uint32 (param);
|
||||||
|
|
||||||
rating_system = get_content_rating_system (self->user);
|
rating_system = get_content_rating_system (self->user);
|
||||||
|
@ -893,9 +896,9 @@ on_set_age_action_activated (GSimpleAction *action,
|
||||||
/* GObject overrides */
|
/* GObject overrides */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_finalize (GObject *object)
|
mct_user_controls_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = (CcAppPermissions *)object;
|
MctUserControls *self = (MctUserControls *)object;
|
||||||
|
|
||||||
g_assert (self->blacklist_apps_source_id == 0);
|
g_assert (self->blacklist_apps_source_id == 0);
|
||||||
|
|
||||||
|
@ -919,27 +922,27 @@ cc_app_permissions_finalize (GObject *object)
|
||||||
g_clear_object (&self->manager);
|
g_clear_object (&self->manager);
|
||||||
g_clear_object (&self->app_info_monitor);
|
g_clear_object (&self->app_info_monitor);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_app_permissions_parent_class)->finalize (object);
|
G_OBJECT_CLASS (mct_user_controls_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_dispose (GObject *object)
|
mct_user_controls_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = (CcAppPermissions *)object;
|
MctUserControls *self = (MctUserControls *)object;
|
||||||
|
|
||||||
flush_update_blacklisted_apps (self);
|
flush_update_blacklisted_apps (self);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_app_permissions_parent_class)->dispose (object);
|
G_OBJECT_CLASS (mct_user_controls_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_get_property (GObject *object,
|
mct_user_controls_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = CC_APP_PERMISSIONS (object);
|
MctUserControls *self = MCT_USER_CONTROLS (object);
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
@ -957,21 +960,21 @@ cc_app_permissions_get_property (GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_set_property (GObject *object,
|
mct_user_controls_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = CC_APP_PERMISSIONS (object);
|
MctUserControls *self = MCT_USER_CONTROLS (object);
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_USER:
|
case PROP_USER:
|
||||||
cc_app_permissions_set_user (self, g_value_get_object (value));
|
mct_user_controls_set_user (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_PERMISSION:
|
case PROP_PERMISSION:
|
||||||
cc_app_permissions_set_permission (self, g_value_get_object (value));
|
mct_user_controls_set_permission (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -980,15 +983,15 @@ cc_app_permissions_set_property (GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_class_init (CcAppPermissionsClass *klass)
|
mct_user_controls_class_init (MctUserControlsClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = cc_app_permissions_finalize;
|
object_class->finalize = mct_user_controls_finalize;
|
||||||
object_class->dispose = cc_app_permissions_dispose;
|
object_class->dispose = mct_user_controls_dispose;
|
||||||
object_class->get_property = cc_app_permissions_get_property;
|
object_class->get_property = mct_user_controls_get_property;
|
||||||
object_class->set_property = cc_app_permissions_set_property;
|
object_class->set_property = mct_user_controls_set_property;
|
||||||
|
|
||||||
properties[PROP_USER] = g_param_spec_object ("user",
|
properties[PROP_USER] = g_param_spec_object ("user",
|
||||||
"User",
|
"User",
|
||||||
|
@ -1008,22 +1011,22 @@ cc_app_permissions_class_init (CcAppPermissionsClass *klass)
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/user-accounts/cc-app-permissions.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentControl/ui/user-controls.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, age_menu);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, age_menu);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, allow_system_installation_switch);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, allow_system_installation_switch);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, allow_user_installation_switch);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, allow_user_installation_switch);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, allow_web_browsers_switch);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, allow_web_browsers_switch);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, restriction_button);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, restriction_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, restriction_popover);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, restriction_popover);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcAppPermissions, listbox);
|
gtk_widget_class_bind_template_child (widget_class, MctUserControls, listbox);
|
||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_allow_installation_switch_active_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_allow_installation_switch_active_changed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_allow_web_browsers_switch_active_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_allow_web_browsers_switch_active_changed_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_app_permissions_init (CcAppPermissions *self)
|
mct_user_controls_init (MctUserControls *self)
|
||||||
{
|
{
|
||||||
g_autoptr(GDBusConnection) system_bus = NULL;
|
g_autoptr(GDBusConnection) system_bus = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
@ -1077,18 +1080,18 @@ cc_app_permissions_init (CcAppPermissions *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
ActUser *
|
ActUser *
|
||||||
cc_app_permissions_get_user (CcAppPermissions *self)
|
mct_user_controls_get_user (MctUserControls *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_APP_PERMISSIONS (self), NULL);
|
g_return_val_if_fail (MCT_IS_USER_CONTROLS (self), NULL);
|
||||||
|
|
||||||
return self->user;
|
return self->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_app_permissions_set_user (CcAppPermissions *self,
|
mct_user_controls_set_user (MctUserControls *self,
|
||||||
ActUser *user)
|
ActUser *user)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_APP_PERMISSIONS (self));
|
g_return_if_fail (MCT_IS_USER_CONTROLS (self));
|
||||||
g_return_if_fail (ACT_IS_USER (user));
|
g_return_if_fail (ACT_IS_USER (user));
|
||||||
|
|
||||||
/* If we have pending unsaved changes from the previous user, force them to be
|
/* If we have pending unsaved changes from the previous user, force them to be
|
||||||
|
@ -1109,24 +1112,24 @@ on_permission_allowed_cb (GObject *obj,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcAppPermissions *self = CC_APP_PERMISSIONS (user_data);
|
MctUserControls *self = MCT_USER_CONTROLS (user_data);
|
||||||
|
|
||||||
setup_parental_control_settings (self);
|
setup_parental_control_settings (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPermission * /* (nullable) */
|
GPermission * /* (nullable) */
|
||||||
cc_app_permissions_get_permission (CcAppPermissions *self)
|
mct_user_controls_get_permission (MctUserControls *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_APP_PERMISSIONS (self), NULL);
|
g_return_val_if_fail (MCT_IS_USER_CONTROLS (self), NULL);
|
||||||
|
|
||||||
return self->permission;
|
return self->permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_app_permissions_set_permission (CcAppPermissions *self,
|
mct_user_controls_set_permission (MctUserControls *self,
|
||||||
GPermission *permission /* (nullable) */)
|
GPermission *permission /* (nullable) */)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_APP_PERMISSIONS (self));
|
g_return_if_fail (MCT_IS_USER_CONTROLS (self));
|
||||||
g_return_if_fail (permission == NULL || G_IS_PERMISSION (permission));
|
g_return_if_fail (permission == NULL || G_IS_PERMISSION (permission));
|
||||||
|
|
||||||
if (self->permission == permission)
|
if (self->permission == permission)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* cc-app-permissions.h
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
*
|
*
|
||||||
* Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
* Copyright © 2018, 2019, 2020 Endless Mobile, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -13,29 +13,30 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* Authors:
|
||||||
|
* - Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||||
|
* - Philip Withnall <withnall@endlessm.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <act/act.h>
|
#include <act/act.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <shell/cc-panel.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_APP_PERMISSIONS (cc_app_permissions_get_type())
|
#define MCT_TYPE_USER_CONTROLS (mct_user_controls_get_type())
|
||||||
|
G_DECLARE_FINAL_TYPE (MctUserControls, mct_user_controls, MCT, USER_CONTROLS, GtkGrid)
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CcAppPermissions, cc_app_permissions, CC, APP_PERMISSIONS, GtkGrid)
|
ActUser *mct_user_controls_get_user (MctUserControls *self);
|
||||||
|
void mct_user_controls_set_user (MctUserControls *self,
|
||||||
ActUser* cc_app_permissions_get_user (CcAppPermissions *self);
|
|
||||||
void cc_app_permissions_set_user (CcAppPermissions *self,
|
|
||||||
ActUser *user);
|
ActUser *user);
|
||||||
|
|
||||||
GPermission *cc_app_permissions_get_permission (CcAppPermissions *self);
|
GPermission *mct_user_controls_get_permission (MctUserControls *self);
|
||||||
void cc_app_permissions_set_permission (CcAppPermissions *self,
|
void mct_user_controls_set_permission (MctUserControls *self,
|
||||||
GPermission *permission);
|
GPermission *permission);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright © 2018, 2019, 2020 Endless, Inc. -->
|
||||||
<interface>
|
<interface>
|
||||||
<template class="CcAppPermissions" parent="GtkGrid">
|
<requires lib="gtk+" version="3.12"/>
|
||||||
|
<template class="MctUserControls" parent="GtkGrid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="margin-top">18</property>
|
<property name="margin-top">18</property>
|
||||||
<property name="row-spacing">6</property>
|
<property name="row-spacing">6</property>
|
||||||
|
@ -132,7 +134,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<signal name="notify::active" handler="on_allow_web_browsers_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
<signal name="notify::active" handler="on_allow_web_browsers_switch_active_changed_cb" object="MctUserControls" swapped="no" />
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
@ -185,7 +187,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="MctUserControls" swapped="no" />
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
@ -221,7 +223,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="MctUserControls" swapped="no" />
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
@ -293,4 +295,3 @@
|
||||||
</widgets>
|
</widgets>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
/*
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
|
*
|
||||||
|
* Copyright © 2015 Red Hat, Inc.
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
@ -9,28 +12,55 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
*
|
||||||
* (C) Copyright 2015 Red Hat, Inc.
|
* Authors:
|
||||||
|
* - Ondrej Holy <oholy@redhat.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cc-user-image.h"
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <act/act.h>
|
#include <act/act.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "user-utils.h"
|
#include "user-image.h"
|
||||||
|
|
||||||
struct _CcUserImage {
|
|
||||||
|
struct _MctUserImage
|
||||||
|
{
|
||||||
GtkImage parent_instance;
|
GtkImage parent_instance;
|
||||||
|
|
||||||
ActUser *user;
|
ActUser *user;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcUserImage, cc_user_image, GTK_TYPE_IMAGE)
|
G_DEFINE_TYPE (MctUserImage, mct_user_image, GTK_TYPE_IMAGE)
|
||||||
|
|
||||||
|
static GdkPixbuf *
|
||||||
|
round_image (GdkPixbuf *pixbuf)
|
||||||
|
{
|
||||||
|
GdkPixbuf *dest = NULL;
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
cairo_t *cr;
|
||||||
|
gint size;
|
||||||
|
|
||||||
|
size = gdk_pixbuf_get_width (pixbuf);
|
||||||
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
|
||||||
|
cr = cairo_create (surface);
|
||||||
|
|
||||||
|
/* Clip a circle */
|
||||||
|
cairo_arc (cr, size / 2, size / 2, size / 2, 0, 2 * G_PI);
|
||||||
|
cairo_clip (cr);
|
||||||
|
cairo_new_path (cr);
|
||||||
|
|
||||||
|
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
||||||
|
cairo_paint (cr);
|
||||||
|
|
||||||
|
dest = gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
render_user_icon (ActUser *user,
|
render_user_icon (ActUser *user,
|
||||||
|
@ -48,7 +78,8 @@ render_user_icon (ActUser *user,
|
||||||
|
|
||||||
icon_file = act_user_get_icon_file (user);
|
icon_file = act_user_get_icon_file (user);
|
||||||
pixbuf = NULL;
|
pixbuf = NULL;
|
||||||
if (icon_file) {
|
if (icon_file)
|
||||||
|
{
|
||||||
source_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_file,
|
source_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_file,
|
||||||
icon_size * scale,
|
icon_size * scale,
|
||||||
icon_size * scale,
|
icon_size * scale,
|
||||||
|
@ -57,9 +88,8 @@ render_user_icon (ActUser *user,
|
||||||
pixbuf = round_image (source_pixbuf);
|
pixbuf = round_image (source_pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixbuf != NULL) {
|
if (pixbuf != NULL)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
||||||
|
@ -67,14 +97,16 @@ render_user_icon (ActUser *user,
|
||||||
icon_size * scale,
|
icon_size * scale,
|
||||||
GTK_ICON_LOOKUP_FORCE_SIZE,
|
GTK_ICON_LOOKUP_FORCE_SIZE,
|
||||||
&error);
|
&error);
|
||||||
if (error) {
|
if (error)
|
||||||
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
if (pixbuf != NULL) {
|
if (pixbuf != NULL)
|
||||||
|
{
|
||||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL);
|
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +115,7 @@ render_user_icon (ActUser *user,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
render_image (CcUserImage *image)
|
render_image (MctUserImage *image)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
gint scale, pixel_size;
|
gint scale, pixel_size;
|
||||||
|
@ -101,7 +133,7 @@ render_image (CcUserImage *image)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_user_image_set_user (CcUserImage *image,
|
mct_user_image_set_user (MctUserImage *image,
|
||||||
ActUser *user)
|
ActUser *user)
|
||||||
{
|
{
|
||||||
g_clear_object (&image->user);
|
g_clear_object (&image->user);
|
||||||
|
@ -111,32 +143,32 @@ cc_user_image_set_user (CcUserImage *image,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_user_image_finalize (GObject *object)
|
mct_user_image_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcUserImage *image = CC_USER_IMAGE (object);
|
MctUserImage *image = MCT_USER_IMAGE (object);
|
||||||
|
|
||||||
g_clear_object (&image->user);
|
g_clear_object (&image->user);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_user_image_parent_class)->finalize (object);
|
G_OBJECT_CLASS (mct_user_image_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_user_image_class_init (CcUserImageClass *class)
|
mct_user_image_class_init (MctUserImageClass *class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
object_class->finalize = cc_user_image_finalize;
|
object_class->finalize = mct_user_image_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_user_image_init (CcUserImage *image)
|
mct_user_image_init (MctUserImage *image)
|
||||||
{
|
{
|
||||||
g_signal_connect_swapped (image, "notify::scale-factor", G_CALLBACK (render_image), image);
|
g_signal_connect_swapped (image, "notify::scale-factor", G_CALLBACK (render_image), image);
|
||||||
g_signal_connect_swapped (image, "notify::pixel-size", G_CALLBACK (render_image), image);
|
g_signal_connect_swapped (image, "notify::pixel-size", G_CALLBACK (render_image), image);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
cc_user_image_new (void)
|
mct_user_image_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (CC_TYPE_USER_IMAGE, NULL);
|
return g_object_new (MCT_TYPE_USER_IMAGE, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
/*
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||||
|
*
|
||||||
|
* Copyright © 2015 Red Hat, Inc.
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
@ -9,11 +12,11 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
*
|
||||||
* (C) Copyright 2015 Red Hat, Inc.
|
* Authors:
|
||||||
|
* - Ondrej Holy <oholy@redhat.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -21,12 +24,14 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <act/act.h>
|
#include <act/act.h>
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_USER_IMAGE (cc_user_image_get_type ())
|
#define MCT_TYPE_USER_IMAGE (mct_user_image_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (CcUserImage, cc_user_image, CC, USER_IMAGE, GtkImage)
|
G_DECLARE_FINAL_TYPE (MctUserImage, mct_user_image, MCT, USER_IMAGE, GtkImage)
|
||||||
|
|
||||||
GtkWidget *cc_user_image_new (void);
|
GtkWidget *mct_user_image_new (void);
|
||||||
void cc_user_image_set_user (CcUserImage *image, ActUser *user);
|
void mct_user_image_set_user (MctUserImage *image,
|
||||||
|
ActUser *user);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
accounts-service/com.endlessm.ParentalControls.policy.in
|
accounts-service/com.endlessm.ParentalControls.policy.in
|
||||||
libmalcontent/manager.c
|
libmalcontent/manager.c
|
||||||
malcontent-control/application.c
|
malcontent-control/application.c
|
||||||
|
malcontent-control/gs-content-rating.c
|
||||||
malcontent-control/main.ui
|
malcontent-control/main.ui
|
||||||
malcontent-control/org.freedesktop.MalcontentControl.appdata.xml.in
|
malcontent-control/org.freedesktop.MalcontentControl.appdata.xml.in
|
||||||
malcontent-control/org.freedesktop.MalcontentControl.desktop.in
|
malcontent-control/org.freedesktop.MalcontentControl.desktop.in
|
||||||
|
malcontent-control/user-controls.c
|
||||||
|
malcontent-control/user-controls.ui
|
||||||
pam/pam_malcontent.c
|
pam/pam_malcontent.c
|
||||||
|
|
Loading…
Reference in New Issue