[gnome-games] ui: Add MediaMenuButton
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Add MediaMenuButton
- Date: Fri, 19 Aug 2016 21:09:50 +0000 (UTC)
commit 39c749ed20a30dd2959038f06d79b0f36bc791f8
Author: Ricard Gascons <gascons1995 gmail com>
Date: Thu Aug 18 16:28:53 2016 +0200
ui: Add MediaMenuButton
This ui component will be used in a subsequent commit implementing the
multi-source functionality.
This is part of a series of commits to add multi-source support.
data/org.gnome.Games.gresource.xml | 1 +
data/ui/media-menu-button.ui | 20 ++++++++++++++++++++
src/Makefile.am | 1 +
src/ui/media-menu-button.vala | 22 ++++++++++++++++++++++
4 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index e11eb58..8f17469 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -15,6 +15,7 @@
<file preprocess="xml-stripblanks">ui/error-display.ui</file>
<file preprocess="xml-stripblanks">ui/error-info-bar.ui</file>
<file preprocess="xml-stripblanks">ui/game-icon-view.ui</file>
+ <file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
<file preprocess="xml-stripblanks">ui/media-selector.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-page-plugins-item.ui</file>
diff --git a/data/ui/media-menu-button.ui b/data/ui/media-menu-button.ui
new file mode 100644
index 0000000..8c3fcf9
--- /dev/null
+++ b/data/ui/media-menu-button.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="GamesMediaMenuButton" parent="GtkMenuButton">
+ <style>
+ <class name="image-button"/>
+ </style>
+ <signal name="notify::media-set" handler="on_media_set_changed"/>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="a11y-display-discs">
+ <property name="accessible-name" translatable="yes">Media</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="media_image">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c1f6e8..b90ec18 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -105,6 +105,7 @@ gnome_games_SOURCES = \
ui/game-icon-view.vala \
ui/game-thumbnail.vala \
ui/media-selector.vala \
+ ui/media-menu-button.vala \
ui/preferences-page.vala \
ui/preferences-page-plugins.vala \
ui/preferences-page-plugins-item.vala \
diff --git a/src/ui/media-menu-button.vala b/src/ui/media-menu-button.vala
new file mode 100644
index 0000000..1396443
--- /dev/null
+++ b/src/ui/media-menu-button.vala
@@ -0,0 +1,22 @@
+// This file is part of GNOME Games. License: GPLv3
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/media-menu-button.ui")]
+private class Games.MediaMenuButton : Gtk.MenuButton {
+ public MediaSet media_set { set; get; }
+
+ [GtkChild]
+ private Gtk.Image media_image;
+
+ [GtkCallback]
+ private void on_media_set_changed () {
+ if (media_set == null || media_set.get_size () < 2) {
+ hide ();
+
+ return;
+ }
+
+ media_image.set_from_gicon (media_set.icon, Gtk.IconSize.LARGE_TOOLBAR);
+
+ show ();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]