Commit 05d13f43 authored by Zander's avatar Zander 💥

Load wallpapers, report bad icons

parent 6e8c8943
[*.vala]
indent_style = tab
indent_size = 4
[*.css]
indent_style = tab
indent_size = 4
......@@ -37,7 +37,8 @@ namespace IconPreview {
var styles = new CssProvider();
styles.load_from_resource("/org/gnome/IconPreview/gtk/style.css");
StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), styles, STYLE_PROVIDER_PRIORITY_APPLICATION);
// Use of uint.MAX isn't ideal but we are effectivly in an arms race
StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), styles, uint.MAX);
set_accels_for_action ("win.open", { "<primary>O" });
set_accels_for_action ("win.recents", { "<primary><shift>O" });
......
......@@ -7,4 +7,17 @@
.drop-zone * {
margin: 15px;
}
\ No newline at end of file
}
colour-view .sizes, colour-view .wallpaper grid {
padding: 15px;
}
colour-view .wallpaper {
background-size: cover;
background-image: url('resource://org/gnome/IconPreview/wallpapers/Adwaita.jpg');
}
.theme-Adwaita-dark .wallpaper {
background-image: url('resource://org/gnome/IconPreview/wallpapers/Adwaita-dark.jpg');
}
......@@ -16,6 +16,10 @@ namespace IconPreview {
}
}
class construct {
set_css_name("colour-view");
}
construct {
homogeneous = true;
......
......@@ -7,112 +7,126 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkGrid" id="sizes">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
<property name="spacing">40</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">10</property>
<property name="column_spacing">30</property>
<child>
<object class="GtkGrid" id="sizes">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="row_spacing">10</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">128</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">64</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">32</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">32</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">128</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">64</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<property name="valign">end</property>
<property name="pixel_size">128</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">64</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">32</property>
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">32</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">128</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">64</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<style>
<class name="sizes"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="row_spacing">10</property>
<property name="column_spacing">10</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">15</property>
<property name="column_spacing">15</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
......@@ -135,14 +149,18 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<style>
<class name="wallpaper"/>
<class name="background"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">2</property>
</packing>
</child>
<style>
......
......@@ -61,15 +61,20 @@ namespace IconPreview {
}
set {
var context = get_style_context();
context.remove_class("theme-" + _theme);
_theme = value;
context.add_class("theme-" + _theme);
provider = CssProvider.get_named(value, null);
apply_css(this);
}
}
construct {
class construct {
set_css_name("pane");
}
construct {
// Not sure i should be hardcoding this
foreach (var icon in IconTheme.get_default().list_icons("Applications")) {
if (!icon.has_suffix("symbolic")) {
......@@ -92,6 +97,8 @@ namespace IconPreview {
grid.attach(ico, 2, 1);
grid.show_all();
theme = theme;
shuffle();
}
......@@ -102,7 +109,7 @@ namespace IconPreview {
if (existing != null) {
context.remove_provider(existing);
}
context.add_provider(provider, uint.MAX);
context.add_provider(provider, uint.MAX - 10);
widget.set_data("pane-style-provider", provider);
if (widget is Container) {
(widget as Container).forall(apply_css);
......
using Gtk;
namespace IconPreview {
/*
enum Target {
INT32,
STRING,
ROOTWIN
}
*/
[GtkTemplate (ui = "/org/gnome/IconPreview/initial.ui")]
class InitialState : Grid {
......
......@@ -16,6 +16,10 @@ namespace IconPreview {
}
}
class construct {
set_css_name("symbolic-view");
}
construct {
light.theme = "Adwaita";
dark.theme = "Adwaita-dark";
......
......@@ -64,26 +64,9 @@
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">10</property>
<property name="border_width">15</property>
<property name="orientation">vertical</property>
<property name="spacing">16</property>
<child>
<object class="GtkMenuButton" id="picker">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="draw_indicator">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="sizes">
<property name="visible">True</property>
......
......@@ -3,9 +3,6 @@ using Gtk;
namespace IconPreview {
[GtkTemplate (ui = "/org/gnome/IconPreview/symbolicpane.ui")]
public class SymbolicPane : Box {
[GtkChild]
MenuButton picker;
[GtkChild]
Grid sizes;
......@@ -47,11 +44,11 @@ namespace IconPreview {
}
}
construct {
class construct {
set_css_name("pane");
}
bind_property("theme", picker, "label");
construct {
foreach (var icon in IconTheme.get_default().list_icons(null)) {
if (icon.has_suffix("symbolic")) {
symbolics.append(icon);
......@@ -74,6 +71,8 @@ namespace IconPreview {
icons.append((state as Button).image as Image);
});
theme = theme;
shuffle();
}
......@@ -84,7 +83,7 @@ namespace IconPreview {
if (existing != null) {
context.remove_provider(existing);
}
context.add_provider(provider, uint.MAX);
context.add_provider(provider, uint.MAX - 10);
widget.set_data("pane-style-provider", provider);
if (widget is Container) {
(widget as Container).forall(apply_css);
......
......@@ -46,6 +46,7 @@
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Icon Preview</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox">
......@@ -57,6 +58,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Open an icon</property>
<property name="action_name">win.open</property>
</object>
<packing>
......@@ -70,6 +72,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Recent</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -97,6 +100,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Reload</property>
<property name="action_name">win.refresh</property>
<property name="image">image1</property>
<property name="always_show_image">True</property>
......@@ -110,6 +114,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......
......@@ -50,17 +50,15 @@ namespace IconPreview {
mode = SYMBOLIC;
} else {
// We are very specific about what we like
mode = INITIAL;
_file = null;
_load_failed();
return;
// TODO report bad icon
}
} catch (Error e) {
critical("Failed to load %s: %s", value.get_basename(), e.message);
mode = INITIAL;
_file = null;
_load_failed();
return;
// TODO report bad icon
}
recents.open_file(value);
try {
......@@ -132,11 +130,19 @@ namespace IconPreview {
add_action_entries(entries, this);
}
private void _load_failed () {
var dlg = new MessageDialog(this, MODAL, WARNING, CANCEL, "This file is defective");
dlg.secondary_text = "Please start from a template to ensure that your file will work as a GNOME icon";
dlg.response.connect(() => dlg.destroy());
dlg.show();
}
private void mode_changed () {
message("Switched to %s", mode.to_string());
refreshbtn.visible = exportbtn.visible = mode != INITIAL;
switch (mode) {
case INITIAL:
title = "Icon Preview";
if (!(content.visible_child is InitialState)) {
content.visible_child.destroy();
message("Destroyed");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment