malcontent-control: Add widgets from gnome-control-center
Add `CcCarousel` and `CcAppPermissions` from gnome-control-center and rename the files. None of the contents of the files have been changed yet. The files are from git master of gnome-control-center on 2020-01-08. `carousel.{c,h,ui}` are licensed under GPLv2+, and are copyright 2016 Red Hat, Inc. The original author was Felipe Borges. `user-controls.{c,h,ui}` are licensed under GPLv3+, and are copyright 2018, 2019 Endless, Inc. `gs-content-rating.{c,h}` are originally from gnome-software, are licensed under GPLv2+, and are copyright 2015, 2016 Richard Hughes. He was also the original author. These files are needed by `user-controls.{c,h}`. `user-image.{c,h}` are licensed under GPLv2+ and are copyright 2015, Red Hat, Inc. The original author was Ondrej Holy. This code will not stay as copy-paste code for too long. The ultimate plan is to rework most of the widgets: • `CcCarousel`: Will be reworked to provide more information about the screen time usage of each user. It will become a summary widget as well as a selector. • `GsContentRating`: Will be abstracted out into libappstream-glib, or some other suitable library, where its implementation can be shared between gnome-software and malcontent. • `CcUserControls`: Will be reworked as the UI of malcontent evolves. Will also be removed from gnome-control-center once malcontent-control is released. • `CcUserImage`: As per `CcCarousel`, this will evolve into a new widget. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
b0f72c432f
commit
aa6ece8a91
|
@ -0,0 +1,429 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright 2016 (c) Red Hat, Inc,
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Felipe Borges <felipeborges@gnome.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cc-carousel.h"
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#define ARROW_SIZE 20
|
||||||
|
|
||||||
|
struct _CcCarouselItem {
|
||||||
|
GtkRadioButton parent;
|
||||||
|
|
||||||
|
gint page;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (CcCarouselItem, cc_carousel_item, GTK_TYPE_RADIO_BUTTON)
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
cc_carousel_item_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (CC_TYPE_CAROUSEL_ITEM, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_item_class_init (CcCarouselItemClass *klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_item_init (CcCarouselItem *self)
|
||||||
|
{
|
||||||
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (self), FALSE);
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
|
||||||
|
"carousel-item");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _CcCarousel {
|
||||||
|
GtkRevealer parent;
|
||||||
|
|
||||||
|
GList *children;
|
||||||
|
gint visible_page;
|
||||||
|
CcCarouselItem *selected_item;
|
||||||
|
GtkWidget *last_box;
|
||||||
|
GtkWidget *arrow;
|
||||||
|
gint arrow_start_x;
|
||||||
|
|
||||||
|
/* Widgets */
|
||||||
|
GtkStack *stack;
|
||||||
|
GtkWidget *go_back_button;
|
||||||
|
GtkWidget *go_next_button;
|
||||||
|
|
||||||
|
GtkStyleProvider *provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (CcCarousel, cc_carousel, GTK_TYPE_REVEALER)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ITEM_ACTIVATED,
|
||||||
|
NUM_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[NUM_SIGNALS] = { 0, };
|
||||||
|
|
||||||
|
#define ITEMS_PER_PAGE 3
|
||||||
|
|
||||||
|
static gint
|
||||||
|
cc_carousel_item_get_x (CcCarouselItem *item,
|
||||||
|
CcCarousel *carousel)
|
||||||
|
{
|
||||||
|
GtkWidget *widget, *parent;
|
||||||
|
gint width;
|
||||||
|
gint dest_x;
|
||||||
|
|
||||||
|
parent = GTK_WIDGET (carousel->stack);
|
||||||
|
widget = GTK_WIDGET (item);
|
||||||
|
|
||||||
|
width = gtk_widget_get_allocated_width (widget);
|
||||||
|
gtk_widget_translate_coordinates (widget,
|
||||||
|
parent,
|
||||||
|
width / 2,
|
||||||
|
0,
|
||||||
|
&dest_x,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return CLAMP (dest_x - ARROW_SIZE,
|
||||||
|
0,
|
||||||
|
gtk_widget_get_allocated_width (parent));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_move_arrow (CcCarousel *self)
|
||||||
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
|
gchar *css;
|
||||||
|
gint end_x;
|
||||||
|
GtkSettings *settings;
|
||||||
|
gboolean animations;
|
||||||
|
|
||||||
|
if (!self->selected_item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
end_x = cc_carousel_item_get_x (self->selected_item, self);
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (self->arrow);
|
||||||
|
if (self->provider)
|
||||||
|
gtk_style_context_remove_provider (context, self->provider);
|
||||||
|
g_clear_object (&self->provider);
|
||||||
|
|
||||||
|
settings = gtk_widget_get_settings (GTK_WIDGET (self));
|
||||||
|
g_object_get (settings, "gtk-enable-animations", &animations, NULL);
|
||||||
|
|
||||||
|
/* Animate the arrow movement if animations are enabled. Otherwise,
|
||||||
|
* jump the arrow to the right location instantly. */
|
||||||
|
if (animations)
|
||||||
|
{
|
||||||
|
css = g_strdup_printf ("@keyframes arrow_keyframes-%d-%d {\n"
|
||||||
|
" from { margin-left: %dpx; }\n"
|
||||||
|
" to { margin-left: %dpx; }\n"
|
||||||
|
"}\n"
|
||||||
|
"* {\n"
|
||||||
|
" animation-name: arrow_keyframes-%d-%d;\n"
|
||||||
|
"}\n",
|
||||||
|
self->arrow_start_x, end_x,
|
||||||
|
self->arrow_start_x, end_x,
|
||||||
|
self->arrow_start_x, end_x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
css = g_strdup_printf ("* { margin-left: %dpx }", end_x);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||||
|
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (self->provider), css, -1, NULL);
|
||||||
|
gtk_style_context_add_provider (context, self->provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
|
g_free (css);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
get_last_page_number (CcCarousel *self)
|
||||||
|
{
|
||||||
|
if (g_list_length (self->children) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return ((g_list_length (self->children) - 1) / ITEMS_PER_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_buttons_visibility (CcCarousel *self)
|
||||||
|
{
|
||||||
|
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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cc_carousel_find_item:
|
||||||
|
* @carousel: an CcCarousel instance
|
||||||
|
* @data: user data passed to the comparation function
|
||||||
|
* @func: the function to call for each element.
|
||||||
|
* It should return 0 when the desired element is found
|
||||||
|
*
|
||||||
|
* Finds an CcCarousel item using the supplied function to find the
|
||||||
|
* desired element.
|
||||||
|
* Ideally useful for matching a model object and its correspondent
|
||||||
|
* widget.
|
||||||
|
*
|
||||||
|
* Returns: the found CcCarouselItem, or %NULL if it is not found
|
||||||
|
*/
|
||||||
|
CcCarouselItem *
|
||||||
|
cc_carousel_find_item (CcCarousel *self,
|
||||||
|
gconstpointer data,
|
||||||
|
GCompareFunc func)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
list = self->children;
|
||||||
|
while (list != NULL)
|
||||||
|
{
|
||||||
|
if (!func (list->data, data))
|
||||||
|
return list->data;
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_item_toggled (CcCarouselItem *item,
|
||||||
|
GdkEvent *event,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
CcCarousel *self = CC_CAROUSEL (user_data);
|
||||||
|
|
||||||
|
cc_carousel_select_item (self, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cc_carousel_select_item (CcCarousel *self,
|
||||||
|
CcCarouselItem *item)
|
||||||
|
{
|
||||||
|
gchar *page_name;
|
||||||
|
gboolean page_changed = TRUE;
|
||||||
|
|
||||||
|
/* Select first user if none is specified */
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
if (self->children != NULL)
|
||||||
|
item = self->children->data;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->selected_item != NULL)
|
||||||
|
{
|
||||||
|
page_changed = (self->selected_item->page != item->page);
|
||||||
|
self->arrow_start_x = cc_carousel_item_get_x (self->selected_item, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->selected_item = item;
|
||||||
|
self->visible_page = item->page;
|
||||||
|
g_signal_emit (self, signals[ITEM_ACTIVATED], 0, item);
|
||||||
|
|
||||||
|
if (!page_changed)
|
||||||
|
{
|
||||||
|
cc_carousel_move_arrow (self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
page_name = g_strdup_printf ("%d", self->visible_page);
|
||||||
|
gtk_stack_set_visible_child_name (self->stack, page_name);
|
||||||
|
|
||||||
|
g_free (page_name);
|
||||||
|
|
||||||
|
update_buttons_visibility (self);
|
||||||
|
|
||||||
|
/* cc_carousel_move_arrow is called from on_transition_running */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_select_item_at_index (CcCarousel *self,
|
||||||
|
gint index)
|
||||||
|
{
|
||||||
|
GList *l = NULL;
|
||||||
|
|
||||||
|
l = g_list_nth (self->children, index);
|
||||||
|
cc_carousel_select_item (self, l->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_goto_previous_page (GtkWidget *button,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
CcCarousel *self = CC_CAROUSEL (user_data);
|
||||||
|
|
||||||
|
self->visible_page--;
|
||||||
|
if (self->visible_page < 0)
|
||||||
|
self->visible_page = 0;
|
||||||
|
|
||||||
|
/* Select first item of the page */
|
||||||
|
cc_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_goto_next_page (GtkWidget *button,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
CcCarousel *self = CC_CAROUSEL (user_data);
|
||||||
|
gint last_page;
|
||||||
|
|
||||||
|
last_page = get_last_page_number (self);
|
||||||
|
|
||||||
|
self->visible_page++;
|
||||||
|
if (self->visible_page > last_page)
|
||||||
|
self->visible_page = last_page;
|
||||||
|
|
||||||
|
/* Select first item of the page */
|
||||||
|
cc_carousel_select_item_at_index (self, self->visible_page * ITEMS_PER_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_add (GtkContainer *container,
|
||||||
|
GtkWidget *widget)
|
||||||
|
{
|
||||||
|
CcCarousel *self = CC_CAROUSEL (container);
|
||||||
|
gboolean last_box_is_full;
|
||||||
|
|
||||||
|
if (!CC_IS_CAROUSEL_ITEM (widget)) {
|
||||||
|
GTK_CONTAINER_CLASS (cc_carousel_parent_class)->add (container, widget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "menu");
|
||||||
|
gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
|
||||||
|
|
||||||
|
self->children = g_list_append (self->children, widget);
|
||||||
|
CC_CAROUSEL_ITEM (widget)->page = get_last_page_number (self);
|
||||||
|
if (self->selected_item != NULL)
|
||||||
|
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);
|
||||||
|
|
||||||
|
last_box_is_full = ((g_list_length (self->children) - 1) % ITEMS_PER_PAGE == 0);
|
||||||
|
if (last_box_is_full) {
|
||||||
|
gchar *page;
|
||||||
|
|
||||||
|
page = g_strdup_printf ("%d", CC_CAROUSEL_ITEM (widget)->page);
|
||||||
|
self->last_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
gtk_widget_show (self->last_box);
|
||||||
|
gtk_widget_set_valign (self->last_box, GTK_ALIGN_CENTER);
|
||||||
|
gtk_stack_add_named (self->stack, self->last_box, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_show_all (widget);
|
||||||
|
gtk_box_pack_start (GTK_BOX (self->last_box), widget, TRUE, FALSE, 10);
|
||||||
|
|
||||||
|
update_buttons_visibility (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cc_carousel_purge_items (CcCarousel *self)
|
||||||
|
{
|
||||||
|
gtk_container_forall (GTK_CONTAINER (self->stack),
|
||||||
|
(GtkCallback) gtk_widget_destroy,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_list_free (self->children);
|
||||||
|
self->children = NULL;
|
||||||
|
self->visible_page = 0;
|
||||||
|
self->selected_item = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CcCarousel *
|
||||||
|
cc_carousel_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (CC_TYPE_CAROUSEL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_class_init (CcCarouselClass *klass)
|
||||||
|
{
|
||||||
|
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
|
||||||
|
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource (wclass,
|
||||||
|
"/org/gnome/control-center/user-accounts/cc-carousel.ui");
|
||||||
|
|
||||||
|
gtk_widget_class_bind_template_child (wclass, CcCarousel, stack);
|
||||||
|
gtk_widget_class_bind_template_child (wclass, CcCarousel, go_back_button);
|
||||||
|
gtk_widget_class_bind_template_child (wclass, CcCarousel, go_next_button);
|
||||||
|
gtk_widget_class_bind_template_child (wclass, CcCarousel, arrow);
|
||||||
|
|
||||||
|
gtk_widget_class_bind_template_callback (wclass, cc_carousel_goto_previous_page);
|
||||||
|
gtk_widget_class_bind_template_callback (wclass, cc_carousel_goto_next_page);
|
||||||
|
|
||||||
|
container_class->add = cc_carousel_add;
|
||||||
|
|
||||||
|
signals[ITEM_ACTIVATED] = g_signal_new ("item-activated",
|
||||||
|
CC_TYPE_CAROUSEL,
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
CC_TYPE_CAROUSEL_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_size_allocate (CcCarousel *self)
|
||||||
|
{
|
||||||
|
if (self->selected_item == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gtk_stack_get_transition_running (self->stack))
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->arrow_start_x = cc_carousel_item_get_x (self->selected_item, self);
|
||||||
|
cc_carousel_move_arrow (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_transition_running (CcCarousel *self)
|
||||||
|
{
|
||||||
|
if (!gtk_stack_get_transition_running (self->stack))
|
||||||
|
cc_carousel_move_arrow (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_carousel_init (CcCarousel *self)
|
||||||
|
{
|
||||||
|
GtkStyleProvider *provider;
|
||||||
|
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||||
|
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
|
||||||
|
"/org/gnome/control-center/user-accounts/carousel.css");
|
||||||
|
|
||||||
|
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||||
|
provider,
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
|
g_object_unref (provider);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (self->stack, "size-allocate", G_CALLBACK (on_size_allocate), self);
|
||||||
|
g_signal_connect_swapped (self->stack, "notify::transition-running", G_CALLBACK (on_transition_running), self);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
cc_carousel_get_item_count (CcCarousel *self)
|
||||||
|
{
|
||||||
|
return g_list_length (self->children);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
.carousel-arrow-container {
|
||||||
|
border-bottom: 1px solid @borders;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel-arrow,
|
||||||
|
.carousel-inner-arrow {
|
||||||
|
border-width: 20px; /* ARROW_SIZE */
|
||||||
|
border-style: solid;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel-arrow {
|
||||||
|
border-bottom-color: @borders;
|
||||||
|
margin-bottom: -1px;
|
||||||
|
animation-duration: 200ms;
|
||||||
|
animation-timing-function: ease-in-out;
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel-inner-arrow {
|
||||||
|
border-bottom-color: @theme_bg_color;
|
||||||
|
margin-bottom: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel-item {
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
border: none;
|
||||||
|
color: @theme_fg_color;
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright 2016 (c) Red Hat, Inc,
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author: Felipe Borges <felipeborges@gnome.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CC_TYPE_CAROUSEL_ITEM (cc_carousel_item_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (CcCarouselItem, cc_carousel_item, CC, CAROUSEL_ITEM, GtkRadioButton)
|
||||||
|
|
||||||
|
#define CC_TYPE_CAROUSEL (cc_carousel_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (CcCarousel, cc_carousel, CC, CAROUSEL, GtkRevealer)
|
||||||
|
|
||||||
|
GtkWidget *cc_carousel_item_new (void);
|
||||||
|
|
||||||
|
CcCarousel *cc_carousel_new (void);
|
||||||
|
|
||||||
|
void cc_carousel_purge_items (CcCarousel *self);
|
||||||
|
|
||||||
|
CcCarouselItem *cc_carousel_find_item (CcCarousel *self,
|
||||||
|
gconstpointer data,
|
||||||
|
GCompareFunc func);
|
||||||
|
|
||||||
|
void cc_carousel_select_item (CcCarousel *self,
|
||||||
|
CcCarouselItem *item);
|
||||||
|
|
||||||
|
guint cc_carousel_get_item_count (CcCarousel *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.8 -->
|
||||||
|
<template class="CcCarousel" parent="GtkRevealer">
|
||||||
|
<property name="transition_duration">400</property>
|
||||||
|
<property name="reveal-child">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkOverlay">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="border_width">16</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStack" id="stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="transition_duration">400</property>
|
||||||
|
<property name="transition_type">GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT</property>
|
||||||
|
<style>
|
||||||
|
<class name="location-bar"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="overlay">
|
||||||
|
<object class="GtkOverlay">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
|
||||||
|
<property name="border_width">12</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="go_back_button">
|
||||||
|
<property name="visible">False</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<style>
|
||||||
|
<class name="circular"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon-size">4</property>
|
||||||
|
<property name="icon_name">go-previous-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<signal name="clicked" handler="cc_carousel_goto_previous_page" object="CcCarousel" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">GTK_PACK_START</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="go_next_button">
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<style>
|
||||||
|
<class name="circular"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon-size">4</property>
|
||||||
|
<property name="icon_name">go-next-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<signal name="clicked" handler="cc_carousel_goto_next_page" object="CcCarousel" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">GTK_PACK_END</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="overlay">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="valign">GTK_ALIGN_END</property>
|
||||||
|
<style>
|
||||||
|
<class name="carousel-arrow-container"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkOverlay">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="arrow">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="halign">GTK_ALIGN_END</property>
|
||||||
|
<style>
|
||||||
|
<class name="carousel-arrow"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="overlay">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="halign">GTK_ALIGN_END</property>
|
||||||
|
<style>
|
||||||
|
<class name="carousel-inner-arrow"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pass-through">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pass-through">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -0,0 +1,968 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015-2016 Richard Hughes <richard@hughsie.com>
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License Version 2
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gs-content-rating.h"
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gs_content_rating_system_to_str (GsContentRatingSystem system)
|
||||||
|
{
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_INCAA)
|
||||||
|
return "INCAA";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ACB)
|
||||||
|
return "ACB";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_DJCTQ)
|
||||||
|
return "DJCTQ";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_GSRR)
|
||||||
|
return "GSRR";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_PEGI)
|
||||||
|
return "PEGI";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_KAVI)
|
||||||
|
return "KAVI";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_USK)
|
||||||
|
return "USK";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ESRA)
|
||||||
|
return "ESRA";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_CERO)
|
||||||
|
return "CERO";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_OFLCNZ)
|
||||||
|
return "OFLCNZ";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_RUSSIA)
|
||||||
|
return "RUSSIA";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_MDA)
|
||||||
|
return "MDA";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_GRAC)
|
||||||
|
return "GRAC";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ESRB)
|
||||||
|
return "ESRB";
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_IARC)
|
||||||
|
return "IARC";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gs_content_rating_key_value_to_str (const gchar *id, MctAppFilterOarsValue value)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
const struct {
|
||||||
|
const gchar *id;
|
||||||
|
MctAppFilterOarsValue value;
|
||||||
|
const gchar *desc;
|
||||||
|
} tab[] = {
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No cartoon violence") },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Cartoon characters in unsafe situations") },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Cartoon characters in aggressive conflict") },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic violence involving cartoon characters") },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No fantasy violence") },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Characters in unsafe situations easily distinguishable from reality") },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Characters in aggressive conflict easily distinguishable from reality") },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic violence easily distinguishable from reality") },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No realistic violence") },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Mildly realistic characters in unsafe situations") },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions of realistic characters in aggressive conflict") },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic violence involving realistic characters") },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No bloodshed") },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Unrealistic bloodshed") },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Realistic bloodshed") },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions of bloodshed and the mutilation of body parts") },
|
||||||
|
{ "violence-sexual", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No sexual violence") },
|
||||||
|
{ "violence-sexual", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Rape or other violent sexual behavior") },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to alcohol") },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("References to alcoholic beverages") },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Use of alcoholic beverages") },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to illicit drugs") },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("References to illicit drugs") },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Use of illicit drugs") },
|
||||||
|
{ "drugs-tobacco", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("References to tobacco products") },
|
||||||
|
{ "drugs-tobacco", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Use of tobacco products") },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No nudity of any sort") },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Brief artistic nudity") },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Prolonged nudity") },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references or depictions of sexual nature") },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Provocative references or depictions") },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Sexual references or depictions") },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic sexual behavior") },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No profanity of any kind") },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Mild or infrequent use of profanity") },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Moderate use of profanity") },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Strong or frequent use of profanity") },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No inappropriate humor") },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Slapstick humor") },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Vulgar or bathroom humor") },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Mature or sexual humor") },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No discriminatory language of any kind") },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Negativity towards a specific group of people") },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Discrimination designed to cause emotional harm") },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Explicit discrimination based on gender, sexuality, race or religion") },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No advertising of any kind") },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Product placement") },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Explicit references to specific brands or trademarked products") },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Users are encouraged to purchase specific real-world items") },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No gambling of any kind") },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Gambling on random events using tokens or credits") },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Gambling using “play” money") },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Gambling using real money") },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No ability to spend money") },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_MILD, /* v1.1 */
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Users are encouraged to donate real money") },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Ability to spend real money in-game") },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No way to chat with other users") },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("User-to-user game interactions without chat functionality") },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Moderated chat functionality between users") },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Uncontrolled chat functionality between users") },
|
||||||
|
{ "social-audio", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No way to talk with other users") },
|
||||||
|
{ "social-audio", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Uncontrolled audio or video chat functionality between users") },
|
||||||
|
{ "social-contacts", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No sharing of social network usernames or email addresses") },
|
||||||
|
{ "social-contacts", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Sharing social network usernames or email addresses") },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No sharing of user information with 3rd parties") },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_MILD, /* v1.1 */
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Checking for the latest application version") },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_MODERATE, /* v1.1 */
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Sharing diagnostic data that does not let others identify the user") },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Sharing information that lets others identify the user") },
|
||||||
|
{ "social-location", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No sharing of physical location to other users") },
|
||||||
|
{ "social-location", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Sharing physical location to other users") },
|
||||||
|
|
||||||
|
/* v1.1 */
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to homosexuality") },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Indirect references to homosexuality") },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Kissing between people of the same gender") },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic sexual behavior between people of the same gender") },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to prostitution") },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Indirect references to prostitution") },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Direct references to prostitution") },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic depictions of the act of prostitution") },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to adultery") },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Indirect references to adultery") },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Direct references to adultery") },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic depictions of the act of adultery") },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No sexualized characters") },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Scantily clad human characters") },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Overtly sexualized human characters") },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to desecration") },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions or references to historical desecration") },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions of modern-day human desecration") },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic depictions of modern-day desecration") },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No visible dead human remains") },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Visible dead human remains") },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Dead human remains that are exposed to the elements") },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic depictions of desecration of human bodies") },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_NONE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("No references to slavery") },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_MILD,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions or references to historical slavery") },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_MODERATE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Depictions of modern-day slavery") },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
|
/* TRANSLATORS: content rating description */
|
||||||
|
_("Graphic depictions of modern-day slavery") },
|
||||||
|
{ NULL, 0, NULL } };
|
||||||
|
for (i = 0; tab[i].id != NULL; i++) {
|
||||||
|
if (g_strcmp0 (tab[i].id, id) == 0 && tab[i].value == value)
|
||||||
|
return tab[i].desc;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* data obtained from https://en.wikipedia.org/wiki/Video_game_rating_system */
|
||||||
|
const gchar *
|
||||||
|
gs_utils_content_rating_age_to_str (GsContentRatingSystem system, guint age)
|
||||||
|
{
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_INCAA) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "+18";
|
||||||
|
if (age >= 13)
|
||||||
|
return "+13";
|
||||||
|
return "ATP";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ACB) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "R18+";
|
||||||
|
if (age >= 15)
|
||||||
|
return "MA15+";
|
||||||
|
return "PG";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_DJCTQ) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16";
|
||||||
|
if (age >= 14)
|
||||||
|
return "14";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12";
|
||||||
|
if (age >= 10)
|
||||||
|
return "10";
|
||||||
|
return "L";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_GSRR) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "限制";
|
||||||
|
if (age >= 15)
|
||||||
|
return "輔15";
|
||||||
|
if (age >= 12)
|
||||||
|
return "輔12";
|
||||||
|
if (age >= 6)
|
||||||
|
return "保護";
|
||||||
|
return "普通";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_PEGI) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12";
|
||||||
|
if (age >= 7)
|
||||||
|
return "7";
|
||||||
|
if (age >= 3)
|
||||||
|
return "3";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_KAVI) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18+";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16+";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12+";
|
||||||
|
if (age >= 7)
|
||||||
|
return "7+";
|
||||||
|
if (age >= 3)
|
||||||
|
return "3+";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_USK) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12";
|
||||||
|
if (age >= 6)
|
||||||
|
return "6";
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
/* Reference: http://www.esra.org.ir/ */
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ESRA) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "+18";
|
||||||
|
if (age >= 15)
|
||||||
|
return "+15";
|
||||||
|
if (age >= 12)
|
||||||
|
return "+12";
|
||||||
|
if (age >= 7)
|
||||||
|
return "+7";
|
||||||
|
if (age >= 3)
|
||||||
|
return "+3";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_CERO) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "Z";
|
||||||
|
if (age >= 17)
|
||||||
|
return "D";
|
||||||
|
if (age >= 15)
|
||||||
|
return "C";
|
||||||
|
if (age >= 12)
|
||||||
|
return "B";
|
||||||
|
return "A";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_OFLCNZ) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "R18";
|
||||||
|
if (age >= 16)
|
||||||
|
return "R16";
|
||||||
|
if (age >= 15)
|
||||||
|
return "R15";
|
||||||
|
if (age >= 13)
|
||||||
|
return "R13";
|
||||||
|
return "G";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_RUSSIA) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18+";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16+";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12+";
|
||||||
|
if (age >= 6)
|
||||||
|
return "6+";
|
||||||
|
return "0+";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_MDA) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "M18";
|
||||||
|
if (age >= 16)
|
||||||
|
return "ADV";
|
||||||
|
return "General";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_GRAC) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "18";
|
||||||
|
if (age >= 15)
|
||||||
|
return "15";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12";
|
||||||
|
return "ALL";
|
||||||
|
}
|
||||||
|
if (system == GS_CONTENT_RATING_SYSTEM_ESRB) {
|
||||||
|
if (age >= 18)
|
||||||
|
return "Adults Only";
|
||||||
|
if (age >= 17)
|
||||||
|
return "Mature";
|
||||||
|
if (age >= 13)
|
||||||
|
return "Teen";
|
||||||
|
if (age >= 10)
|
||||||
|
return "Everyone 10+";
|
||||||
|
if (age >= 6)
|
||||||
|
return "Everyone";
|
||||||
|
return "Early Childhood";
|
||||||
|
}
|
||||||
|
/* IARC = everything else */
|
||||||
|
if (age >= 18)
|
||||||
|
return "18+";
|
||||||
|
if (age >= 16)
|
||||||
|
return "16+";
|
||||||
|
if (age >= 12)
|
||||||
|
return "12+";
|
||||||
|
if (age >= 7)
|
||||||
|
return "7+";
|
||||||
|
if (age >= 3)
|
||||||
|
return "3+";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse_locale:
|
||||||
|
* @locale: (transfer full): a locale to parse
|
||||||
|
* @language_out: (out) (optional) (nullable): return location for the parsed
|
||||||
|
* language, or %NULL to ignore
|
||||||
|
* @territory_out: (out) (optional) (nullable): return location for the parsed
|
||||||
|
* territory, or %NULL to ignore
|
||||||
|
* @codeset_out: (out) (optional) (nullable): return location for the parsed
|
||||||
|
* codeset, or %NULL to ignore
|
||||||
|
* @modifier_out: (out) (optional) (nullable): return location for the parsed
|
||||||
|
* modifier, or %NULL to ignore
|
||||||
|
*
|
||||||
|
* Parse @locale as a locale string of the form
|
||||||
|
* `language[_territory][.codeset][@modifier]` — see `man 3 setlocale` for
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* On success, %TRUE will be returned, and the components of the locale will be
|
||||||
|
* returned in the given addresses, with each component not including any
|
||||||
|
* separators. Otherwise, %FALSE will be returned and the components will be set
|
||||||
|
* to %NULL.
|
||||||
|
*
|
||||||
|
* @locale is modified, and any returned non-%NULL pointers will point inside
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success, %FALSE otherwise
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
parse_locale (gchar *locale /* (transfer full) */,
|
||||||
|
const gchar **language_out,
|
||||||
|
const gchar **territory_out,
|
||||||
|
const gchar **codeset_out,
|
||||||
|
const gchar **modifier_out)
|
||||||
|
{
|
||||||
|
gchar *separator;
|
||||||
|
const gchar *language = NULL, *territory = NULL, *codeset = NULL, *modifier = NULL;
|
||||||
|
|
||||||
|
separator = strrchr (locale, '@');
|
||||||
|
if (separator != NULL) {
|
||||||
|
modifier = separator + 1;
|
||||||
|
*separator = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
separator = strrchr (locale, '.');
|
||||||
|
if (separator != NULL) {
|
||||||
|
codeset = separator + 1;
|
||||||
|
*separator = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
separator = strrchr (locale, '_');
|
||||||
|
if (separator != NULL) {
|
||||||
|
territory = separator + 1;
|
||||||
|
*separator = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
language = locale;
|
||||||
|
|
||||||
|
/* Parse failure? */
|
||||||
|
if (*language == '\0') {
|
||||||
|
language = NULL;
|
||||||
|
territory = NULL;
|
||||||
|
codeset = NULL;
|
||||||
|
modifier = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (language_out != NULL)
|
||||||
|
*language_out = language;
|
||||||
|
if (territory_out != NULL)
|
||||||
|
*territory_out = territory;
|
||||||
|
if (codeset_out != NULL)
|
||||||
|
*codeset_out = codeset;
|
||||||
|
if (modifier_out != NULL)
|
||||||
|
*modifier_out = modifier;
|
||||||
|
|
||||||
|
return (language != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* data obtained from https://en.wikipedia.org/wiki/Video_game_rating_system */
|
||||||
|
GsContentRatingSystem
|
||||||
|
gs_utils_content_rating_system_from_locale (const gchar *locale)
|
||||||
|
{
|
||||||
|
g_autofree gchar *locale_copy = g_strdup (locale);
|
||||||
|
const gchar *language, *territory;
|
||||||
|
|
||||||
|
/* Default to IARC for locales which can’t be parsed. */
|
||||||
|
if (!parse_locale (locale_copy, &language, &territory, NULL, NULL))
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_IARC;
|
||||||
|
|
||||||
|
/* Argentina */
|
||||||
|
if (g_strcmp0 (language, "ar") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_INCAA;
|
||||||
|
|
||||||
|
/* Australia */
|
||||||
|
if (g_strcmp0 (language, "au") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_ACB;
|
||||||
|
|
||||||
|
/* Brazil */
|
||||||
|
if (g_strcmp0 (language, "pt") == 0 &&
|
||||||
|
g_strcmp0 (territory, "BR") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_DJCTQ;
|
||||||
|
|
||||||
|
/* Taiwan */
|
||||||
|
if (g_strcmp0 (language, "zh") == 0 &&
|
||||||
|
g_strcmp0 (territory, "TW") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_GSRR;
|
||||||
|
|
||||||
|
/* Europe (but not Finland or Germany), India, Israel,
|
||||||
|
* Pakistan, Quebec, South Africa */
|
||||||
|
if ((g_strcmp0 (language, "en") == 0 &&
|
||||||
|
g_strcmp0 (territory, "GB") == 0) ||
|
||||||
|
g_strcmp0 (language, "gb") == 0 ||
|
||||||
|
g_strcmp0 (language, "al") == 0 ||
|
||||||
|
g_strcmp0 (language, "ad") == 0 ||
|
||||||
|
g_strcmp0 (language, "am") == 0 ||
|
||||||
|
g_strcmp0 (language, "at") == 0 ||
|
||||||
|
g_strcmp0 (language, "az") == 0 ||
|
||||||
|
g_strcmp0 (language, "by") == 0 ||
|
||||||
|
g_strcmp0 (language, "be") == 0 ||
|
||||||
|
g_strcmp0 (language, "ba") == 0 ||
|
||||||
|
g_strcmp0 (language, "bg") == 0 ||
|
||||||
|
g_strcmp0 (language, "hr") == 0 ||
|
||||||
|
g_strcmp0 (language, "cy") == 0 ||
|
||||||
|
g_strcmp0 (language, "cz") == 0 ||
|
||||||
|
g_strcmp0 (language, "dk") == 0 ||
|
||||||
|
g_strcmp0 (language, "ee") == 0 ||
|
||||||
|
g_strcmp0 (language, "fr") == 0 ||
|
||||||
|
g_strcmp0 (language, "ge") == 0 ||
|
||||||
|
g_strcmp0 (language, "gr") == 0 ||
|
||||||
|
g_strcmp0 (language, "hu") == 0 ||
|
||||||
|
g_strcmp0 (language, "is") == 0 ||
|
||||||
|
g_strcmp0 (language, "it") == 0 ||
|
||||||
|
g_strcmp0 (language, "kz") == 0 ||
|
||||||
|
g_strcmp0 (language, "xk") == 0 ||
|
||||||
|
g_strcmp0 (language, "lv") == 0 ||
|
||||||
|
g_strcmp0 (language, "fl") == 0 ||
|
||||||
|
g_strcmp0 (language, "lu") == 0 ||
|
||||||
|
g_strcmp0 (language, "lt") == 0 ||
|
||||||
|
g_strcmp0 (language, "mk") == 0 ||
|
||||||
|
g_strcmp0 (language, "mt") == 0 ||
|
||||||
|
g_strcmp0 (language, "md") == 0 ||
|
||||||
|
g_strcmp0 (language, "mc") == 0 ||
|
||||||
|
g_strcmp0 (language, "me") == 0 ||
|
||||||
|
g_strcmp0 (language, "nl") == 0 ||
|
||||||
|
g_strcmp0 (language, "no") == 0 ||
|
||||||
|
g_strcmp0 (language, "pl") == 0 ||
|
||||||
|
g_strcmp0 (language, "pt") == 0 ||
|
||||||
|
g_strcmp0 (language, "ro") == 0 ||
|
||||||
|
g_strcmp0 (language, "sm") == 0 ||
|
||||||
|
g_strcmp0 (language, "rs") == 0 ||
|
||||||
|
g_strcmp0 (language, "sk") == 0 ||
|
||||||
|
g_strcmp0 (language, "si") == 0 ||
|
||||||
|
g_strcmp0 (language, "es") == 0 ||
|
||||||
|
g_strcmp0 (language, "se") == 0 ||
|
||||||
|
g_strcmp0 (language, "ch") == 0 ||
|
||||||
|
g_strcmp0 (language, "tr") == 0 ||
|
||||||
|
g_strcmp0 (language, "ua") == 0 ||
|
||||||
|
g_strcmp0 (language, "va") == 0 ||
|
||||||
|
g_strcmp0 (language, "in") == 0 ||
|
||||||
|
g_strcmp0 (language, "il") == 0 ||
|
||||||
|
g_strcmp0 (language, "pk") == 0 ||
|
||||||
|
g_strcmp0 (language, "za") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_PEGI;
|
||||||
|
|
||||||
|
/* Finland */
|
||||||
|
if (g_strcmp0 (language, "fi") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_KAVI;
|
||||||
|
|
||||||
|
/* Germany */
|
||||||
|
if (g_strcmp0 (language, "de") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_USK;
|
||||||
|
|
||||||
|
/* Iran */
|
||||||
|
if (g_strcmp0 (language, "ir") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_ESRA;
|
||||||
|
|
||||||
|
/* Japan */
|
||||||
|
if (g_strcmp0 (language, "jp") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_CERO;
|
||||||
|
|
||||||
|
/* New Zealand */
|
||||||
|
if (g_strcmp0 (language, "nz") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_OFLCNZ;
|
||||||
|
|
||||||
|
/* Russia: Content rating law */
|
||||||
|
if (g_strcmp0 (language, "ru") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_RUSSIA;
|
||||||
|
|
||||||
|
/* Singapore */
|
||||||
|
if (g_strcmp0 (language, "sg") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_MDA;
|
||||||
|
|
||||||
|
/* South Korea */
|
||||||
|
if (g_strcmp0 (language, "kr") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_GRAC;
|
||||||
|
|
||||||
|
/* USA, Canada, Mexico */
|
||||||
|
if ((g_strcmp0 (language, "en") == 0 &&
|
||||||
|
g_strcmp0 (territory, "US") == 0) ||
|
||||||
|
g_strcmp0 (language, "us") == 0 ||
|
||||||
|
g_strcmp0 (language, "ca") == 0 ||
|
||||||
|
g_strcmp0 (language, "mx") == 0)
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_ESRB;
|
||||||
|
|
||||||
|
/* everything else is IARC */
|
||||||
|
return GS_CONTENT_RATING_SYSTEM_IARC;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *content_rating_strings[GS_CONTENT_RATING_SYSTEM_LAST][7] = {
|
||||||
|
{ "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_UNKNOWN */
|
||||||
|
{ "ATP", "+13", "+18", NULL }, /* GS_CONTENT_RATING_SYSTEM_INCAA */
|
||||||
|
{ "PG", "MA15+", "R18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_ACB */
|
||||||
|
{ "L", "10", "12", "14", "16", "18", NULL }, /* GS_CONTENT_RATING_SYSTEM_DJCTQ */
|
||||||
|
{ "普通", "保護", "輔12", "輔15", "限制", NULL }, /* GS_CONTENT_RATING_SYSTEM_GSRR */
|
||||||
|
{ "3", "7", "12", "16", "18", NULL }, /* GS_CONTENT_RATING_SYSTEM_PEGI */
|
||||||
|
{ "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_KAVI */
|
||||||
|
{ "0", "6", "12", "16", "18", NULL}, /* GS_CONTENT_RATING_SYSTEM_USK */
|
||||||
|
{ "+3", "+7", "+12", "+15", "+18", NULL }, /* GS_CONTENT_RATING_SYSTEM_ESRA */
|
||||||
|
{ "A", "B", "C", "D", "Z", NULL }, /* GS_CONTENT_RATING_SYSTEM_CERO */
|
||||||
|
{ "G", "R13", "R15", "R16", "R18", NULL }, /* GS_CONTENT_RATING_SYSTEM_OFLCNZ */
|
||||||
|
{ "0+", "6+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_RUSSIA */
|
||||||
|
{ "General", "ADV", "M18", NULL }, /* GS_CONTENT_RATING_SYSTEM_MDA */
|
||||||
|
{ "ALL", "12", "15", "18", NULL }, /* GS_CONTENT_RATING_SYSTEM_GRAC */
|
||||||
|
{ "Early Childhood", "Everyone", "Everyone 10+", "Teen", "Mature", "Adults Only", NULL }, /* GS_CONTENT_RATING_SYSTEM_ESRB */
|
||||||
|
{ "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_IARC */
|
||||||
|
};
|
||||||
|
|
||||||
|
const gchar * const *
|
||||||
|
gs_utils_content_rating_get_values (GsContentRatingSystem system)
|
||||||
|
{
|
||||||
|
g_assert (system < GS_CONTENT_RATING_SYSTEM_LAST);
|
||||||
|
return content_rating_strings[system];
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint content_rating_ages[GS_CONTENT_RATING_SYSTEM_LAST][7] = {
|
||||||
|
{ 3, 7, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_UNKNOWN */
|
||||||
|
{ 0, 13, 18 }, /* GS_CONTENT_RATING_SYSTEM_INCAA */
|
||||||
|
{ 0, 15, 18 }, /* GS_CONTENT_RATING_SYSTEM_ACB */
|
||||||
|
{ 0, 10, 12, 14, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_DJCTQ */
|
||||||
|
{ 0, 6, 12, 15, 18 }, /* GS_CONTENT_RATING_SYSTEM_GSRR */
|
||||||
|
{ 3, 7, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_PEGI */
|
||||||
|
{ 3, 7, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_KAVI */
|
||||||
|
{ 0, 6, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_USK */
|
||||||
|
{ 3, 7, 12, 15, 18 }, /* GS_CONTENT_RATING_SYSTEM_ESRA */
|
||||||
|
{ 0, 12, 15, 17, 18 }, /* GS_CONTENT_RATING_SYSTEM_CERO */
|
||||||
|
{ 0, 13, 15, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_OFLCNZ */
|
||||||
|
{ 0, 6, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_RUSSIA */
|
||||||
|
{ 0, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_MDA */
|
||||||
|
{ 0, 12, 15, 18 }, /* GS_CONTENT_RATING_SYSTEM_GRAC */
|
||||||
|
{ 0, 6, 10, 13, 17, 18 }, /* GS_CONTENT_RATING_SYSTEM_ESRB */
|
||||||
|
{ 3, 7, 12, 16, 18 }, /* GS_CONTENT_RATING_SYSTEM_IARC */
|
||||||
|
};
|
||||||
|
|
||||||
|
const guint *
|
||||||
|
gs_utils_content_rating_get_ages (GsContentRatingSystem system)
|
||||||
|
{
|
||||||
|
g_assert (system < GS_CONTENT_RATING_SYSTEM_LAST);
|
||||||
|
return content_rating_ages[system];
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct {
|
||||||
|
const gchar *id;
|
||||||
|
MctAppFilterOarsValue value;
|
||||||
|
guint csm_age;
|
||||||
|
} id_to_csm_age[] = {
|
||||||
|
/* v1.0 */
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_MILD, 3 },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_MODERATE, 4 },
|
||||||
|
{ "violence-cartoon", MCT_APP_FILTER_OARS_VALUE_INTENSE, 6 },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_MILD, 3 },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_MODERATE, 7 },
|
||||||
|
{ "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE, 8 },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_MILD, 4 },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_MODERATE, 9 },
|
||||||
|
{ "violence-realistic", MCT_APP_FILTER_OARS_VALUE_INTENSE, 14 },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_MILD, 9 },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_MODERATE, 11 },
|
||||||
|
{ "violence-bloodshed", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "violence-sexual", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-sexual", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_MILD, 11 },
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_MODERATE, 13 },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_MILD, 12 },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_MODERATE, 14 },
|
||||||
|
{ "drugs-tobacco", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "drugs-tobacco", MCT_APP_FILTER_OARS_VALUE_MILD, 10 },
|
||||||
|
{ "drugs-tobacco", MCT_APP_FILTER_OARS_VALUE_MODERATE, 13 },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_MILD, 12 },
|
||||||
|
{ "sex-nudity", MCT_APP_FILTER_OARS_VALUE_MODERATE, 14 },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_MILD, 13 },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_MODERATE, 14 },
|
||||||
|
{ "sex-themes", MCT_APP_FILTER_OARS_VALUE_INTENSE, 15 },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_MILD, 8 },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_MODERATE, 11 },
|
||||||
|
{ "language-profanity", MCT_APP_FILTER_OARS_VALUE_INTENSE, 14 },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_MILD, 3 },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_MODERATE, 8 },
|
||||||
|
{ "language-humor", MCT_APP_FILTER_OARS_VALUE_INTENSE, 14 },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_MILD, 9 },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_MODERATE,10 },
|
||||||
|
{ "language-discrimination", MCT_APP_FILTER_OARS_VALUE_INTENSE, 11 },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_MILD, 7 },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_MODERATE, 8 },
|
||||||
|
{ "money-advertising", MCT_APP_FILTER_OARS_VALUE_INTENSE, 10 },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_MILD, 7 },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_MODERATE, 10 },
|
||||||
|
{ "money-gambling", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_INTENSE, 15 },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_MILD, 4 },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_MODERATE, 10 },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_INTENSE, 13 },
|
||||||
|
{ "social-audio", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "social-audio", MCT_APP_FILTER_OARS_VALUE_INTENSE, 15 },
|
||||||
|
{ "social-contacts", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "social-contacts", MCT_APP_FILTER_OARS_VALUE_INTENSE, 12 },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_INTENSE, 13 },
|
||||||
|
{ "social-location", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "social-location", MCT_APP_FILTER_OARS_VALUE_INTENSE, 13 },
|
||||||
|
/* v1.1 additions */
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_MILD, 0 },
|
||||||
|
{ "social-info", MCT_APP_FILTER_OARS_VALUE_MODERATE, 13 },
|
||||||
|
{ "money-purchasing", MCT_APP_FILTER_OARS_VALUE_MILD, 12 },
|
||||||
|
{ "social-chat", MCT_APP_FILTER_OARS_VALUE_MODERATE, 14 },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_MILD, 10 },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_MODERATE, 13 },
|
||||||
|
{ "sex-homosexuality", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_MILD, 12 },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_MODERATE, 14 },
|
||||||
|
{ "sex-prostitution", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_MILD, 8 },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_MODERATE, 10 },
|
||||||
|
{ "sex-adultery", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_MODERATE, 10 },
|
||||||
|
{ "sex-appearance", MCT_APP_FILTER_OARS_VALUE_INTENSE, 15 },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_MILD, 13 },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_MODERATE, 15 },
|
||||||
|
{ "violence-worship", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_MILD, 13 },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_MODERATE, 15 },
|
||||||
|
{ "violence-desecration", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_NONE, 0 },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_MILD, 13 },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_MODERATE, 15 },
|
||||||
|
{ "violence-slavery", MCT_APP_FILTER_OARS_VALUE_INTENSE, 18 },
|
||||||
|
|
||||||
|
/* EOS customisation to add at least one CSM ↔ OARS mapping for ages 16 and 17,
|
||||||
|
* as these are used in many locale-specific ratings systems. Without them,
|
||||||
|
* mapping (e.g.) OFLCNZ R16 → CSM 16 → OARS → CSM gives CSM 15, which then maps
|
||||||
|
* back to OFLCNZ R15, which is not what we want. The addition of these two
|
||||||
|
* mappings should not expose younger users to content they would not have seen
|
||||||
|
* with the default upstream mappings; it instead slightly raises the age at
|
||||||
|
* which users are allowed to see intense content in these two categories.
|
||||||
|
*
|
||||||
|
* See https://phabricator.endlessm.com/T23897#666769. */
|
||||||
|
{ "drugs-alcohol", MCT_APP_FILTER_OARS_VALUE_INTENSE, 16 },
|
||||||
|
{ "drugs-narcotics", MCT_APP_FILTER_OARS_VALUE_INTENSE, 17 },
|
||||||
|
{ NULL, 0, 0 } };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* as_content_rating_id_value_to_csm_age:
|
||||||
|
* @id: the subsection ID e.g. "violence-cartoon"
|
||||||
|
* @value: the #AsContentRatingValue, e.g. %MCT_APP_FILTER_OARS_VALUE_INTENSE
|
||||||
|
*
|
||||||
|
* Gets the Common Sense Media approved age for a specific rating level.
|
||||||
|
*
|
||||||
|
* Returns: The age in years, or 0 for no details.
|
||||||
|
*
|
||||||
|
* Since: 0.5.12
|
||||||
|
**/
|
||||||
|
guint
|
||||||
|
as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
for (i = 0; id_to_csm_age[i].id != NULL; i++) {
|
||||||
|
if (value == id_to_csm_age[i].value &&
|
||||||
|
g_strcmp0 (id, id_to_csm_age[i].id) == 0)
|
||||||
|
return id_to_csm_age[i].csm_age;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* as_content_rating_id_csm_age_to_value:
|
||||||
|
* @id: the subsection ID e.g. "violence-cartoon"
|
||||||
|
* @age: the age
|
||||||
|
*
|
||||||
|
* Gets the #MctAppFilterOarsValue for a given age.
|
||||||
|
*
|
||||||
|
* Returns: the #MctAppFilterOarsValue
|
||||||
|
**/
|
||||||
|
MctAppFilterOarsValue
|
||||||
|
as_content_rating_id_csm_age_to_value (const gchar *id, guint age)
|
||||||
|
{
|
||||||
|
MctAppFilterOarsValue value;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
value = MCT_APP_FILTER_OARS_VALUE_UNKNOWN;
|
||||||
|
|
||||||
|
for (i = 0; id_to_csm_age[i].id != NULL; i++) {
|
||||||
|
if (age >= id_to_csm_age[i].csm_age &&
|
||||||
|
g_strcmp0 (id, id_to_csm_age[i].id) == 0)
|
||||||
|
value = MAX (value, id_to_csm_age[i].value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015-2016 Richard Hughes <richard@hughsie.com>
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License Version 2
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <libmalcontent/malcontent.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GS_CONTENT_RATING_SYSTEM_UNKNOWN,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_INCAA,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_ACB,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_DJCTQ,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_GSRR,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_PEGI,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_KAVI,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_USK,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_ESRA,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_CERO,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_OFLCNZ,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_RUSSIA,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_MDA,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_GRAC,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_ESRB,
|
||||||
|
GS_CONTENT_RATING_SYSTEM_IARC,
|
||||||
|
/*< private >*/
|
||||||
|
GS_CONTENT_RATING_SYSTEM_LAST
|
||||||
|
} GsContentRatingSystem;
|
||||||
|
|
||||||
|
const gchar *gs_utils_content_rating_age_to_str (GsContentRatingSystem system,
|
||||||
|
guint age);
|
||||||
|
GsContentRatingSystem gs_utils_content_rating_system_from_locale (const gchar *locale);
|
||||||
|
const gchar *gs_content_rating_key_value_to_str (const gchar *id,
|
||||||
|
MctAppFilterOarsValue value);
|
||||||
|
const gchar *gs_content_rating_system_to_str (GsContentRatingSystem system);
|
||||||
|
const gchar * const *gs_utils_content_rating_get_values (GsContentRatingSystem system);
|
||||||
|
const guint *gs_utils_content_rating_get_ages (GsContentRatingSystem system);
|
||||||
|
guint as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value);
|
||||||
|
MctAppFilterOarsValue as_content_rating_id_csm_age_to_value (const gchar *id, guint age);
|
||||||
|
|
||||||
|
G_END_DECLS
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,41 @@
|
||||||
|
/* cc-app-permissions.h
|
||||||
|
*
|
||||||
|
* Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <act/act.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <shell/cc-panel.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CC_TYPE_APP_PERMISSIONS (cc_app_permissions_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (CcAppPermissions, cc_app_permissions, CC, APP_PERMISSIONS, GtkGrid)
|
||||||
|
|
||||||
|
ActUser* cc_app_permissions_get_user (CcAppPermissions *self);
|
||||||
|
void cc_app_permissions_set_user (CcAppPermissions *self,
|
||||||
|
ActUser *user);
|
||||||
|
|
||||||
|
GPermission *cc_app_permissions_get_permission (CcAppPermissions *self);
|
||||||
|
void cc_app_permissions_set_permission (CcAppPermissions *self,
|
||||||
|
GPermission *permission);
|
||||||
|
|
||||||
|
G_END_DECLS
|
|
@ -0,0 +1,296 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="CcAppPermissions" parent="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="margin-top">18</property>
|
||||||
|
<property name="row-spacing">6</property>
|
||||||
|
<property name="column-spacing">12</property>
|
||||||
|
<property name="valign">start</property>
|
||||||
|
|
||||||
|
<!-- Restricted Apps -->
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0.0</property>
|
||||||
|
<property name="label" translatable="yes">Restrict Apps</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold" />
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">0</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0.0</property>
|
||||||
|
<property name="label" translatable="yes">Prevent this user from opening some apps by turning them off below.</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">listbox</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="0.83333" />
|
||||||
|
</attributes>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">1</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</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>
|
||||||
|
|
||||||
|
<!-- Restricted Apps Listbox -->
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox" id="listbox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="selection-mode">none</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">2</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<!-- Restricted Web Browsers -->
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0.0</property>
|
||||||
|
<property name="label" translatable="yes">Restrict Web Browsers</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold" />
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">3</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0.0</property>
|
||||||
|
<property name="label" translatable="yes">Prevent this user from running web browsers by turning them off below. Note that if the computer is connected to the internet, limited web content may still be available in other applications.</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="max-width-chars">55</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">allow_web_browsers_switch</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="0.83333" />
|
||||||
|
</attributes>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">4</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="browsers_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">1.0</property>
|
||||||
|
<property name="label" translatable="yes">Web _Browsers</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">allow_web_browsers_switch</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="allow_web_browsers_switch">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<signal name="notify::active" handler="on_allow_web_browsers_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">5</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<!-- App Center Restrictions -->
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="margin-top">12</property>
|
||||||
|
<property name="xalign">0.0</property>
|
||||||
|
<property name="label" translatable="yes">App Center Restrictions</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold" />
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">6</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="user_installation_label">
|
||||||
|
<property name="visible" bind-source="allow_user_installation_switch" bind-property="visible" bind-flags="default|sync-create" />
|
||||||
|
<property name="xalign">1.0</property>
|
||||||
|
<property name="label" translatable="yes">App _Installation</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">allow_user_installation_switch</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="allow_user_installation_switch">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">7</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="system_installation_label">
|
||||||
|
<property name="visible" bind-source="allow_system_installation_switch" bind-property="visible" bind-flags="default|sync-create" />
|
||||||
|
<property name="xalign">1.0</property>
|
||||||
|
<property name="label" translatable="yes">Install Apps for All _Users</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">allow_system_installation_switch</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="allow_system_installation_switch">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<signal name="notify::active" handler="on_allow_installation_switch_active_changed_cb" object="CcAppPermissions" swapped="no" />
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">8</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="app_restriction_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">1.0</property>
|
||||||
|
<property name="label" translatable="yes">Show Apps _Suitable For</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-underline">True</property>
|
||||||
|
<property name="mnemonic-widget">restriction_button</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuButton" id="restriction_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="popover">restriction_popover</property>
|
||||||
|
<property name="width-request">200</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">9</property>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<object class="GtkPopoverMenu" id="restriction_popover" />
|
||||||
|
<menu id="age_menu" />
|
||||||
|
|
||||||
|
<object class="GtkSizeGroup">
|
||||||
|
<property name="mode">horizontal</property>
|
||||||
|
<widgets>
|
||||||
|
<widget name="restriction_button" />
|
||||||
|
<widget name="restriction_popover" />
|
||||||
|
</widgets>
|
||||||
|
</object>
|
||||||
|
|
||||||
|
<object class="GtkSizeGroup">
|
||||||
|
<property name="mode">horizontal</property>
|
||||||
|
<widgets>
|
||||||
|
<widget name="browsers_label" />
|
||||||
|
<widget name="app_restriction_label" />
|
||||||
|
<widget name="user_installation_label" />
|
||||||
|
<widget name="system_installation_label" />
|
||||||
|
</widgets>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* (C) Copyright 2015 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cc-user-image.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <act/act.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "user-utils.h"
|
||||||
|
|
||||||
|
struct _CcUserImage {
|
||||||
|
GtkImage parent_instance;
|
||||||
|
|
||||||
|
ActUser *user;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (CcUserImage, cc_user_image, GTK_TYPE_IMAGE)
|
||||||
|
|
||||||
|
static cairo_surface_t *
|
||||||
|
render_user_icon (ActUser *user,
|
||||||
|
gint icon_size,
|
||||||
|
gint scale)
|
||||||
|
{
|
||||||
|
g_autoptr(GdkPixbuf) source_pixbuf = NULL;
|
||||||
|
GdkPixbuf *pixbuf = NULL;
|
||||||
|
GError *error;
|
||||||
|
const gchar *icon_file;
|
||||||
|
cairo_surface_t *surface = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
||||||
|
g_return_val_if_fail (icon_size > 12, NULL);
|
||||||
|
|
||||||
|
icon_file = act_user_get_icon_file (user);
|
||||||
|
pixbuf = NULL;
|
||||||
|
if (icon_file) {
|
||||||
|
source_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_file,
|
||||||
|
icon_size * scale,
|
||||||
|
icon_size * scale,
|
||||||
|
NULL);
|
||||||
|
if (source_pixbuf)
|
||||||
|
pixbuf = round_image (source_pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pixbuf != NULL) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = NULL;
|
||||||
|
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
||||||
|
"avatar-default",
|
||||||
|
icon_size * scale,
|
||||||
|
GTK_ICON_LOOKUP_FORCE_SIZE,
|
||||||
|
&error);
|
||||||
|
if (error) {
|
||||||
|
g_warning ("%s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
if (pixbuf != NULL) {
|
||||||
|
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
render_image (CcUserImage *image)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
gint scale, pixel_size;
|
||||||
|
|
||||||
|
if (image->user == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pixel_size = gtk_image_get_pixel_size (GTK_IMAGE (image));
|
||||||
|
scale = gtk_widget_get_scale_factor (GTK_WIDGET (image));
|
||||||
|
surface = render_user_icon (image->user,
|
||||||
|
pixel_size > 0 ? pixel_size : 48,
|
||||||
|
scale);
|
||||||
|
gtk_image_set_from_surface (GTK_IMAGE (image), surface);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cc_user_image_set_user (CcUserImage *image,
|
||||||
|
ActUser *user)
|
||||||
|
{
|
||||||
|
g_clear_object (&image->user);
|
||||||
|
image->user = g_object_ref (user);
|
||||||
|
|
||||||
|
render_image (image);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_user_image_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
CcUserImage *image = CC_USER_IMAGE (object);
|
||||||
|
|
||||||
|
g_clear_object (&image->user);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cc_user_image_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_user_image_class_init (CcUserImageClass *class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
|
object_class->finalize = cc_user_image_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_user_image_init (CcUserImage *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);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
cc_user_image_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (CC_TYPE_USER_IMAGE, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* (C) Copyright 2015 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <act/act.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CC_TYPE_USER_IMAGE (cc_user_image_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (CcUserImage, cc_user_image, CC, USER_IMAGE, GtkImage)
|
||||||
|
|
||||||
|
GtkWidget *cc_user_image_new (void);
|
||||||
|
void cc_user_image_set_user (CcUserImage *image, ActUser *user);
|
||||||
|
|
||||||
|
G_END_DECLS
|
Loading…
Reference in New Issue