Skip to content

Commit

Permalink
NES_GTK: added icon (P from the logo)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amjad50 committed Sep 30, 2020
1 parent 3c1b2fe commit edacb0a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion nes_ui_gtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ gtk = "0.9.2"
gio = "0.9.1"
glib = "0.10.2"
gdk = "0.13.2"
gdk-pixbuf = "0.9.0"

[dependencies.cairo-rs]
version = "0.9.0"
features = ["v1_16"]
features = ["v1_16", "png"]
12 changes: 12 additions & 0 deletions nes_ui_gtk/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use std::sync::{
};

use gdk::{keys::constants as key_vals, keyval_to_upper, DragAction, ModifierType};
use gdk_pixbuf::prelude::*;
use gdk_pixbuf::PixbufLoader;
use gio::prelude::*;
use glib::source::timeout_add_local;
use gtk::prelude::*;
Expand Down Expand Up @@ -69,6 +71,16 @@ impl UiProvider for GtkProvider {
.get_object::<MenuItem>("menu_action_resume")
.unwrap();

// setup window icon
let icon_png_raw_data = include_bytes!("../../images/icon.png");
let icon_loader = PixbufLoader::with_type("png").unwrap();
icon_loader.write(icon_png_raw_data).unwrap();
icon_loader.close().unwrap();

if let Some(icon) = icon_loader.get_pixbuf() {
window.set_icon(Some(&icon));
}

for i in 1..=NUMBER_OF_STATES {
let save_action = MenuItem::with_label(&format!("_{} <empty>", i));
let load_action = MenuItem::with_label(&format!("_{} <empty>", i));
Expand Down

0 comments on commit edacb0a

Please sign in to comment.