Commit 244e6e54 authored by Canek Peláez's avatar Canek Peláez
Browse files

ApplicationWindow: One method for icon change.

parent b31ddf1a
Loading
Loading
Loading
Loading
+14 −31
Original line number Diff line number Diff line
@@ -28,16 +28,22 @@ namespace MLM {
    [GtkTemplate (ui = "/mx/unam/MLM/mlm.ui")]
    public class ApplicationWindow : Gtk.ApplicationWindow {

        /**
         * Play icon name.
         */
        public const string ICON_NAME_PLAY = "media-playback-start-symbolic";

        /**
         * Pause icon name.
         */
        public const string ICON_NAME_PAUSE = "media-playback-pause-symbolic";

        /* Cascade Style Sheet. */
        private const string CSS_URI = "resource:///mx/unam/MLM/mlm.css";
        /* CD icon name. */
        private const string ICON_NAME_CD = "media-optical-cd-audio-symbolic";
        /* Avatar icon name. */
        private const string ICON_NAME_AVATAR = "avatar-default-symbolic";
        /* Play icon name. */
        private const string ICON_NAME_PLAY = "media-playback-start-symbolic";
        /* Pause icon name. */
        private const string ICON_NAME_PAUSE = "media-playback-pause-symbolic";
        /* Icon size. */
        private const Gtk.IconSize ICON_SIZE = Gtk.IconSize.SMALL_TOOLBAR;

@@ -211,13 +217,11 @@ namespace MLM {
        /* The on popover visibility changed callback. */
        [GtkCallback]
        private void on_popover_visibility_changed() {
            if (!encode_popover.visible) {
            if (!encode_popover.visible)
                mlm.activate_action("stop-encoder", null);
            } else {
                encode_progress_bar.set_fraction(0.0);
            else
                mlm.activate_action("start-encoder", null);
        }
        }

        /* The on save clicked callback. */
        [GtkCallback]
@@ -330,32 +334,11 @@ namespace MLM {
            time_label.set_text(time);
        }

        /**
         * Sets the pause icon.
         */
        public void set_pause_icon() {
            play_image.set_from_icon_name(ICON_NAME_PAUSE, ICON_SIZE);
        }

        /**
         * Sets the play icon.
         */
        public void set_play_icon() {
            play_image.set_from_icon_name(ICON_NAME_PLAY, ICON_SIZE);
        }

        /**
         * Shows a warning dialog.
         * @param message the warning message.
         */
        public void warning(string message) {
            var dialog = new Gtk.MessageDialog(
                this, Gtk.DialogFlags.DESTROY_WITH_PARENT,
                Gtk.MessageType.WARNING, Gtk.ButtonsType.CLOSE,
                message);
            dialog.title = _("Warning");
            dialog.run();
            dialog.destroy();
        public void set_play_icon(string name) {
            play_image.set_from_icon_name(name, ICON_SIZE);
        }

        /**
+7 −11
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ namespace MLM {
                this.files.add(file);
            }
            total = this.files.size;
            this.files.sort(compare_files_by_path);
            this.files.sort((a,b) => a.get_path().collate(b.get_path()));
            activate();
        }

@@ -219,16 +219,17 @@ namespace MLM {
        /* The play action. */
        private void play() {
            if (player != null && !player.working) {
                window.set_pause_icon();
                window.set_play_icon(ApplicationWindow.ICON_NAME_PAUSE);
                player.play();
            } else {
                window.set_play_icon();
                window.set_play_icon(ApplicationWindow.ICON_NAME_PLAY);
                player.pause();
            }
        }

        /* Starts the encoder. */
        private void start_encoder() {
            window.update_encoding(0.0);
            var target = "";
            string prefix = (
                (tags.artist != null ? tags.artist.replace("/", "_") : "") +
@@ -280,11 +281,6 @@ namespace MLM {
            shortcuts_window.show_all();
        }

        /* Compares two files by path. */
        private int compare_files_by_path(GLib.File a, GLib.File b) {
            return a.get_path().collate(b.get_path());
        }

        /* Updates a file. */
        private void update_file() {
            if (player != null)
@@ -328,13 +324,13 @@ namespace MLM {
        private void player_state_changed(Gst.State state) {
            switch (state) {
            case Gst.State.PLAYING:
                window.set_pause_icon();
                window.set_play_icon(ApplicationWindow.ICON_NAME_PAUSE);
                GLib.Idle.add(monitor_player);
                break;
            case Gst.State.PAUSED:
                if (player_completion() == 0.0)
                    window.update_player_view(0.0, "00:00");
                window.set_play_icon();
                window.set_play_icon(ApplicationWindow.ICON_NAME_PLAY);
                break;
            }
        }
@@ -342,7 +338,7 @@ namespace MLM {
        /* Monitors the player in the model. */
        private bool monitor_player() {
            if (player != null && !player.working) {
                window.set_play_icon();
                window.set_play_icon(ApplicationWindow.ICON_NAME_PLAY);
                return false;
            }
            window.update_player_view(player_completion(),