Skip to content

Commit

Permalink
Style Code
Browse files Browse the repository at this point in the history
  • Loading branch information
torikulhabib committed Apr 12, 2020
1 parent 319f3c8 commit 789356c
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 132 deletions.
3 changes: 2 additions & 1 deletion data/com.github.torikulhabib.niki.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<li>Equalizer.</li>
<li>Video Balance.</li>
<li>Album art as background.</li>
<li>Audio Tag.</li>
<li>Blurred background.</li>
<li>DLNA Explorer.</li>
<li>DLNA Controller.</li>
Expand All @@ -31,7 +32,7 @@
<binary>com.github.torikulhabib.niki</binary>
</provides>
​ <releases>
<release version="0.7.35" date="2020-4-6">
<release version="0.7.36" date="2020-4-6">
<description>
<p>Fix and add Features!</p>
<p>Lyric Maker!</p>
Expand Down
75 changes: 0 additions & 75 deletions src/AudioCover.vala

This file was deleted.

5 changes: 2 additions & 3 deletions src/Lyric.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace niki {
}

public void add_line (int64 time, string text) {
set (time, text);
set (time + offset, text);
}

private Gee.BidirMapIterator<int64?, string> iterator_get () {
Expand All @@ -30,8 +30,7 @@ namespace niki {
}

public int64 get_lyric_timestamp (int64 time_in_us, bool cur_pos = true) {
var time_with_offset = time_in_us + offset;
return iterator_lyric (time_with_offset, cur_pos).get_key ();
return iterator_lyric (time_in_us, cur_pos).get_key ();
}

private Gee.BidirMapIterator<int64?, string> iterator_lyric (int64 time_in_us, bool cur_pos = true) {
Expand Down
6 changes: 3 additions & 3 deletions src/LyricParser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace niki {
string lrc_str, tag1, tag2;
int64 time_lrc;
model.get (iter, 0, out time_lrc, 1, out lrc_str, 2, out tag1, 3, out tag2);
if (time_lrc != -1 && lrc_str != "-1") {
lyric.add_line (time_lrc, lrc_str);
}
if (tag1.char_count () > 0 && tag2.char_count () > 0) {
lyric.add_metadata (tag1, tag2);
}
if (time_lrc != -1 && lrc_str != "-1") {
lyric.add_line (time_lrc, lrc_str);
}
return false;
});
return lyric;
Expand Down
32 changes: 5 additions & 27 deletions src/MediaEditor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ namespace niki {
}
});
duration_video.text = seconds_to_time ((int)(info.get_duration ()/1000000000));
sekable_video.text = info.get_seekable ()? "Yes" : "No";
sekable_video.text = info.get_seekable ()? StringPot.Yes : StringPot.No;
info.get_video_streams ().foreach ((list)=> {
var stream_video = (Gst.PbUtils.DiscovererVideoInfo)list;
video_height.text = "%u".printf (stream_video.get_height ());
video_width.text = "%u".printf (stream_video.get_width ());
interlaced.text = "%s".printf (stream_video.is_interlaced ()? "Yes" : "No");
interlaced.text = "%s".printf (stream_video.is_interlaced ()? StringPot.Yes : StringPot.No);
pixel_ratio.text = "%u/%u".printf (stream_video.get_par_num (), stream_video.get_par_denom ());
video_bitrate.text = "%u".printf (stream_video.get_bitrate ());
video_bitrate_max.text = "%u".printf (stream_video.get_max_bitrate ());
Expand Down Expand Up @@ -486,7 +486,7 @@ namespace niki {
astring.append_printf ("%s%s", value.value_nick, i + 1 == channels ? "" : ", ");
}
} else {
astring.append ("unknown layout");
astring.append (StringPot.Unknown_Layout);
}
return astring.str;
}
Expand All @@ -498,26 +498,9 @@ namespace niki {
label_bitrate.label = tagfile.audioproperties.bitrate.to_string () + _(" kHz");
label_sample.label = tagfile.audioproperties.samplerate.to_string () + _(" bps");
label_chanel.label = tagfile.audioproperties.channels == 2? _("Stereo") : _("Mono");

var info = get_discoverer_info (file_name);
label_duration.label = seconds_to_time ((int)(info.get_duration ()/1000000000));
Gdk.Pixbuf pixbuf_sample = null;
var tag_list = info.get_tags ();
var sample = get_cover_sample (tag_list);
if (sample == null) {
tag_list.get_sample (Gst.Tags.IMAGE, out sample);
}
if (sample != null) {
var buffer = sample.get_buffer ();
if (buffer != null) {
pixbuf_sample = get_pixbuf_from_buffer (buffer);
if (pixbuf_sample != null) {
apply_cover_pixbuf (pixbuf_sample);
}
}
} else {
apply_cover_pixbuf (from_theme_icon ("avatar-default-symbolic", 128, 85));
}
apply_cover_pixbuf (align_and_scale_pixbuf (pix_from_tag (info.get_tags ()), 256));
title_entry.text = tagfile.tag.title;
artist_entry.text = tagfile.tag.artist;
album_entry.text = tagfile.tag.album;
Expand Down Expand Up @@ -582,12 +565,7 @@ namespace niki {
private void select_image (string inpu_data) {
var crop_dialog = new CropDialog (inpu_data);
crop_dialog.show_all ();
crop_dialog.request_avatar_change.connect (pixbuf_crop);
}

private void pixbuf_crop (Gdk.Pixbuf pixbuf) {
asyncimage.set_from_pixbuf (align_and_scale_pixbuf (pixbuf, 85));
asyncimage.show ();
crop_dialog.request_avatar_change.connect (apply_cover_pixbuf);
}
}
}
14 changes: 7 additions & 7 deletions src/PlayerPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -464,17 +464,17 @@ namespace niki {
private bool audio_banner () {
Gdk.Pixbuf preview = null;
Gdk.Pixbuf preview_blur = null;
var audiocover = new AudioCover();
switch (NikiApp.settings.get_enum ("player-mode")) {
case PlayerMode.AUDIO :
audiocover.import (NikiApp.settings.get_string("uri-video"));
preview = audiocover.pixbuf_albumart;
preview_blur = audiocover.pixbuf_blur;
if (file_exists (NikiApp.settings.get_string("uri-video"))) {
Gdk.Pixbuf pixt = pix_from_tag (get_discoverer_info (NikiApp.settings.get_string("uri-video")).get_tags ());
preview = align_and_scale_pixbuf (pixt, 764);
preview_blur = align_and_scale_pixbuf (pix_mode_blur (pixt), 764);
}
break;
case PlayerMode.STREAMAUD :
audiocover.create_background (unknown_cover ());
preview = audiocover.pixbuf_albumart;
preview_blur = audiocover.pixbuf_blur;
preview = align_and_scale_pixbuf (unknown_cover (), 764);
preview_blur = align_and_scale_pixbuf (pix_mode_blur (unknown_cover ()), 764);
break;
}
if (preview_blur != null && preview != null) {
Expand Down
14 changes: 6 additions & 8 deletions src/Playlist.vala
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,10 @@ namespace niki {
string info_songs = get_song_info (path);
string album_music = get_album_music (file_name);
string artist_music = get_artist_music (file_name);
string nameimage = cache_image (info_songs + " " + artist_music);
string nameimage = cache_image (@"$(info_songs) $(artist_music)");
if (!FileUtils.test (nameimage, FileTest.EXISTS)) {
var audiocover = new AudioCover();
audiocover.import (path.get_uri ());
preview = audiocover.pixbuf_playlist;
preview = align_and_scale_pixbuf (pix_from_tag (get_discoverer_info (path.get_uri ()).get_tags ()), 48);
pix_to_file (preview, nameimage);
} else {
preview = pix_scale (nameimage, 48);
}
Expand Down Expand Up @@ -438,11 +437,10 @@ namespace niki {
} else if (get_mime_type (path).has_prefix ("audio/")) {
album_music = get_album_music (file_name);
artist_music = get_artist_music (file_name);
string nameimage = cache_image (info_songs + " " + artist_music);
string nameimage = cache_image (@"$(info_songs) $(artist_music)");
if (!FileUtils.test (nameimage, FileTest.EXISTS)) {
var audiocover = new AudioCover();
audiocover.import (path.get_uri ());
preview = audiocover.pixbuf_playlist;
preview = align_and_scale_pixbuf (pix_from_tag (get_discoverer_info (path.get_uri ()).get_tags ()), 48);
pix_to_file (preview, nameimage);
} else {
preview = pix_scale (nameimage, 48);
}
Expand Down
2 changes: 2 additions & 0 deletions src/RightBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ namespace niki {
notify["child-revealed"].connect (() => {
if (!child_revealed) {
hovered = child_revealed;
} else {
playlist.show ();
}
size_flexible ();
});
Expand Down
3 changes: 3 additions & 0 deletions src/StringPot.vala
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,8 @@ namespace niki {
public abstract const string Right = _("Right :");
public abstract const string Resolution = _("Resolution");
public abstract const string Taged = _("Taged");
public abstract const string Yes = _("Yes");
public abstract const string No = _("No");
public abstract const string Unknown_Layout = _("unknown layout");
}
}
4 changes: 4 additions & 0 deletions src/TimeMusic.vala
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ namespace niki {
case 0:
break;
case 1:
for (int i = 0; i < text.char_count (); i++) {
attr = Pango.attr_rise_new ((int)((1.0 -time) * 60000));
attrlist.change ((owned) attr);
}
break;
case 2:
int letter_count = 0;
Expand Down
24 changes: 22 additions & 2 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,27 @@ namespace niki {
props.sets (Canberra.PROP_MEDIA_ROLE, "event");
context.play_full (0, props, null);
}
private Gdk.Pixbuf pix_from_tag (Gst.TagList tag_list) {
var sample = get_cover_sample (tag_list);
if (sample == null) {
tag_list.get_sample (Gst.Tags.IMAGE, out sample);
}
if (sample != null) {
var buffer = sample.get_buffer ();
if (buffer != null) {
return get_pixbuf_from_buffer (buffer);
}
}
return unknown_cover ();
}
private Gdk.Pixbuf pix_mode_blur (Gdk.Pixbuf pixbuf) {
var surface = new Granite.Drawing.BufferSurface ((int)pixbuf.get_width (), (int)pixbuf.get_height ());
Gdk.cairo_set_source_pixbuf (surface.context, pixbuf, 0, 0);
surface.context.paint ();
surface.exponential_blur (15);
surface.context.paint ();
return Gdk.pixbuf_get_from_surface (surface.surface, 0, 0, pixbuf.get_width (), pixbuf.get_height ());
}
private Gst.Sample? get_cover_sample (Gst.TagList tag_list) {
Gst.Sample sample;
for (int i = 0; tag_list.get_sample_index (Gst.Tags.IMAGE, i, out sample); i++) {
Expand Down Expand Up @@ -606,8 +627,7 @@ namespace niki {
private Gdk.Pixbuf get_pixbuf_device_info (GUPnP.DeviceInfo info) {
string udn = info.get_udn ();
string icon_url = info.get_icon_url (null, 32, 25, 25, true, null, null, null, null);
Gdk.Pixbuf? return_value = get_pixbuf_from_url (icon_url, udn);
return return_value;
return get_pixbuf_from_url (icon_url, udn);
}
private Gdk.Pixbuf? get_pixbuf_from_url (string url, string filename) {
Gdk.Pixbuf? return_value = null;
Expand Down
6 changes: 1 addition & 5 deletions src/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ namespace niki {
NikiApp.settings.changed["fullscreen"].connect (() => {
if (NikiApp.settings.get_boolean ("fullscreen")) {
unfullscreen ();
player_page.stage.set_fullscreen (false);
} else {
fullscreen ();
player_page.stage.set_fullscreen (true);
}
});
NikiApp.settings.changed["maximize"].connect (() => {
Expand Down Expand Up @@ -234,9 +232,7 @@ namespace niki {
pixbuf = pix_scale (large_thumb (file_pre), 256);
}
} else if (get_mime_type (file_pre).has_prefix ("audio/")) {
var audiocover = new AudioCover();
audiocover.import (file_pre.get_uri ());
pixbuf = audiocover.pixbuf_albumart;
pixbuf = align_and_scale_pixbuf (pix_from_tag (get_discoverer_info (file_pre.get_uri ()).get_tags ()), 256);
} else if (get_mime_type (file_pre).has_prefix ("image/")) {
pixbuf = pix_scale (file_pre.get_path (), 256);
}
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ executable(
'WelcomeButton.vala',
'ScanFolder.vala',
'DbusThumbnailer.vala',
'AudioCover.vala',
'EqualizerPreset.vala',
'AudioMix.vala',
'VideoMix.vala',
Expand Down

0 comments on commit 789356c

Please sign in to comment.