Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
halfmexican committed Aug 25, 2024
2 parents 589ea21 + 41112a2 commit 595cdfc
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 310 deletions.
5 changes: 0 additions & 5 deletions data/io.github.halfmexican.Mingle.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
<default>true</default>
<summary>Scales combined emoji size</summary>
<description></description>
</key>
<key name="shuffle-combinations" type="b">
<default>true</default>
<summary>Shuffles the batches of combined emojis</summary>
<description></description>
</key>
<key name="color-scheme" type="i">
<default>0</default>
Expand Down
12 changes: 12 additions & 0 deletions data/io.github.halfmexican.Mingle.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
</screenshot>
</screenshots>
<releases>
<release version="0.13" date="2024-08-18">
<description>
<p>Fixes and Features</p>
<ul>
<li>Major refactor and Improved loading speeds</li>
<li>Loaded combinations are shuffled</li>
<li>Fixed bug where invalid combinations would be "displayed"</li>
<li>Updated list of supported emojis</li>
<li>Misc. bug fixes</li>
</ul>
</description>
</release>
<release version="0.12" date="2024-06-10">
<description>
<p>Fixes and Features</p>
Expand Down
Binary file modified data/pv1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/pv2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/pv3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ namespace Mingle {

construct {
ActionEntry[] action_entries = {
{ "select_random", this.select_random},
{ "select_random", this.select_random },
{ "load_batch", this.load_batch },
{ "about", this.on_about_action },
{ "preferences", this.on_preferences_action },
{ "quit", this.quit }
};
this.add_action_entries (action_entries, this);
this.set_accels_for_action ("app.quit", { "<primary>q" });
this.set_accels_for_action ("app.select_random", {"<Ctrl>R", "R"});
this.set_accels_for_action ("app.select_random", { "<Ctrl>R", "R" });
this.set_accels_for_action ("app.load_batch", {"L"});
}

public override void activate () {
Expand All @@ -48,7 +50,12 @@ namespace Mingle {

private void select_random () {
var win = (Mingle.Window) this.active_window;
win.select_random();
win.select_random ();
}

private void load_batch () {
var win = (Mingle.Window) this.active_window;
win.populate_center_flow_box_lazy.begin ();
}

private void on_about_action () {
Expand All @@ -63,7 +70,7 @@ namespace Mingle {
website = "https://github.com/halfmexican/mingle",
issue_url = "https://github.com/halfmexican/mingle/issues",
developer_name = "José Hunter",
version = "0.12",
version = "0.13",
developers = developers,
copyright = "© 2024 José Hunter",
license_type = Gtk.License.GPL_3_0,
Expand All @@ -77,4 +84,4 @@ namespace Mingle {
prefs.present (this.active_window);
}
}
}
}
46 changes: 26 additions & 20 deletions src/combined_emoji.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ using Adw, Gtk, Soup;
namespace Mingle {
public class CombinedEmoji : Gtk.Button {
private Gdk.Texture _texture;
private Gdk.Texture _scaled_texture;
private GLib.Settings settings = new GLib.Settings ("io.github.halfmexican.Mingle");
private EmojiCombination combined_emoji;
public Gtk.Revealer revealer;
public signal void copied ();
public bool image_loaded = false;
private GLib.Settings settings = new GLib.Settings ("io.github.halfmexican.Mingle");

public async CombinedEmoji (string gstatic_url, Gtk.RevealerTransitionType transition) {
public async CombinedEmoji (EmojiCombination combination_struct, Gtk.RevealerTransitionType transition, out bool image_loaded) {
try {
this.combined_emoji = combination_struct;
this.add_css_class ("flat");
// Fetch the image asynchronously
var input_stream = yield get_input_stream (gstatic_url);
var pixbuf = yield new Gdk.Pixbuf.from_stream_async (input_stream, null);

bool shrink_emoji = settings.get_boolean ("shrink-emoji");
var input_stream = yield get_input_stream (combined_emoji.gstatic_url);

if (shrink_emoji) {
int width = pixbuf.get_width ();
int height = pixbuf.get_height ();
int scaled_width = width / 4;
int scaled_height = height / 4;
pixbuf = pixbuf.scale_simple (scaled_width, scaled_height, Gdk.InterpType.BILINEAR);
}
var pixbuf = yield new Gdk.Pixbuf.from_stream_async (input_stream, null);

_texture = Gdk.Texture.for_pixbuf (pixbuf);
int width = pixbuf.get_width ();
int height = pixbuf.get_height ();
int scaled_width = width / 4;
int scaled_height = height / 4;
pixbuf = pixbuf.scale_simple (scaled_width, scaled_height, Gdk.InterpType.BILINEAR);

_scaled_texture = Gdk.Texture.for_pixbuf (pixbuf);

var overlay = new Gtk.Overlay () {
child = new Gtk.Picture () {
Expand Down Expand Up @@ -73,12 +73,13 @@ namespace Mingle {
overlay.add_overlay (revealer);
image_loaded = true;
} catch (GLib.Error error) {
stderr.printf (error.message);
// stderr.printf (error.message);
image_loaded = false;
}

this.clicked.connect (() => {
this.copy_image_to_clipboard (this._texture);
this.copy_image_to_clipboard ();
message ("combined emoji: %s\n", combined_emoji.alt);
this.copied ();
});
}
Expand All @@ -97,15 +98,20 @@ namespace Mingle {
string reason = message.reason_phrase;

if (status_code != 200) {
warning ("Status Code: %x\n Reason: %s", status_code, reason);
warning ("Status Code: %x Reason: %s", status_code, reason);
}

return input_stream;
}

public void copy_image_to_clipboard (Gdk.Texture texture) {
public void copy_image_to_clipboard () {
var clipboard = Gdk.Display.get_default ().get_clipboard ();
clipboard.set_texture (texture);

if (settings.get_boolean ("shrink-emoji")) {
clipboard.set_texture (_scaled_texture);
} else {
clipboard.set_texture (_texture);
}
}
}
}
}
Loading

0 comments on commit 595cdfc

Please sign in to comment.