[easytag/wip/application-window: 47/47] Move status bar to EtStatusBar object



commit 0ecd93fab7d133cc1ac8a019ce5e62d0c4095fa0
Author: David King <amigadave amigadave com>
Date:   Fri Aug 15 18:37:20 2014 +0100

    Move status bar to EtStatusBar object

 Makefile.am              |    4 +-
 po/POTFILES.in           |    2 +-
 src/application.c        |    5 +-
 src/application_window.c |   33 +++++++--
 src/application_window.h |    1 +
 src/bar.c                |  129 ----------------------------------
 src/bar.h                |   32 ---------
 src/browser.c            |    8 ++-
 src/easytag.c            |   27 ++++---
 src/et_core.c            |    5 +-
 src/load_files_dialog.c  |    1 -
 src/log.c                |    1 -
 src/misc.c               |    5 +-
 src/picture.c            |    1 -
 src/playlist_dialog.c    |    6 +-
 src/preferences_dialog.c |    1 -
 src/scan_dialog.c        |   13 +++-
 src/search_dialog.c      |    1 -
 src/setting.c            |    1 -
 src/status_bar.c         |  174 ++++++++++++++++++++++++++++++++++++++++++++++
 src/status_bar.h         |   52 ++++++++++++++
 src/tag_area.c           |   16 +++--
 22 files changed, 306 insertions(+), 212 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index af7586d..44b87c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,7 +40,6 @@ easytag_SOURCES = \
        src/about.c \
        src/application.c \
        src/application_window.c \
-       src/bar.c \
        src/browser.c \
        src/browser.h \
        src/cddb_dialog.c \
@@ -64,6 +63,7 @@ easytag_SOURCES = \
        src/scan_dialog.c \
        src/search_dialog.c \
        src/setting.c \
+       src/status_bar.c \
        src/tag_area.c \
        src/tags/id3lib/c_wrapper.cpp \
        src/tags/libapetag/apetaglib.c \
@@ -96,7 +96,6 @@ easytag_headers = \
        src/about.h \
        src/application.h \
        src/application_window.h \
-       src/bar.h \
        src/cddb_dialog.h \
        src/charset.h \
        src/crc32.h \
@@ -117,6 +116,7 @@ easytag_headers = \
        src/scan_dialog.h \
        src/search_dialog.h \
        src/setting.h \
+       src/status_bar.h \
        src/tag_area.h \
        src/tags/id3lib/id3_bugfix.h \
        src/tags/libapetag/apetaglib.h \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1c727bc..b312db5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,7 +7,6 @@ nautilus-extension/nautilus-easytag.c
 src/about.c
 src/application.c
 src/application_window.c
-src/bar.c
 src/browser.c
 src/cddb_dialog.c
 src/charset.c
@@ -23,6 +22,7 @@ src/preferences_dialog.c
 src/scan_dialog.c
 src/search_dialog.c
 src/setting.c
+src/status_bar.c
 src/tag_area.c
 src/tags/ape_tag.c
 src/tags/flac_header.c
diff --git a/src/application.c b/src/application.c
index 8e7cc01..64e4406 100644
--- a/src/application.c
+++ b/src/application.c
@@ -21,7 +21,6 @@
 #include "application.h"
 
 #include "about.h"
-#include "bar.h"
 #include "charset.h"
 #include "easytag.h"
 #include "log.h"
@@ -121,7 +120,9 @@ on_idle_init (EtApplication *self)
     }
     else
     {
-        Statusbar_Message(_("Select a directory to browse"),FALSE);
+        et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                  _("Select a directory to browse"),
+                                                  FALSE);
         g_action_group_activate_action (G_ACTION_GROUP (MainWindow),
                                         "go-default", NULL);
     }
diff --git a/src/application_window.c b/src/application_window.c
index a86339b..baea914 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -23,7 +23,6 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
 
-#include "bar.h"
 #include "browser.h"
 #include "cddb_dialog.h"
 #include "easytag.h"
@@ -40,6 +39,7 @@
 #include "scan.h"
 #include "scan_dialog.h"
 #include "setting.h"
+#include "status_bar.h"
 #include "tag_area.h"
 
 /* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
@@ -55,6 +55,7 @@ struct _EtApplicationWindowPrivate
     GtkWidget *log_area;
     GtkWidget *tag_area;
     GtkWidget *progress_bar;
+    GtkWidget *status_bar;
 
     GtkWidget *cddb_dialog;
     GtkWidget *load_files_dialog;
@@ -380,7 +381,8 @@ delete_file (ET_File *ETFile, gboolean multiple_files, GError **error)
             if (g_file_delete (cur_file, NULL, error))
             {
                 gchar *msg = g_strdup_printf(_("File '%s' deleted"), basename_utf8);
-                Statusbar_Message(msg,FALSE);
+                et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                          msg, FALSE);
                 g_free(msg);
                 g_free(basename_utf8);
                 g_object_unref (cur_file);
@@ -600,8 +602,8 @@ on_delete (GSimpleAction *action,
 
     et_application_window_progress_set_text (self, "");
     et_application_window_progress_set_fraction (self, 0.0);
-    Statusbar_Message(msg,TRUE);
-    g_free(msg);
+    et_application_window_status_bar_message (self, msg, TRUE);
+    g_free (msg);
 
     return;
 }
@@ -916,7 +918,9 @@ on_remove_tags (GSimpleAction *action,
     et_application_window_update_actions (self);
 
     et_application_window_progress_set_fraction (self, 0.0);
-    Statusbar_Message (_("All tags have been removed"),TRUE);
+    et_application_window_status_bar_message (self,
+                                              _("All tags have been removed"),
+                                              TRUE);
 }
 
 static void
@@ -1742,8 +1746,8 @@ et_application_window_init (EtApplicationWindow *self)
     gtk_widget_show (hbox);
 
     /* Status bar */
-    widget = Create_Status_Bar ();
-    gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+    priv->status_bar = et_status_bar_new ();
+    gtk_box_pack_start (GTK_BOX (hbox), priv->status_bar, TRUE, TRUE, 0);
 
     /* Progress bar */
     priv->progress_bar = et_progress_bar_new ();
@@ -1842,6 +1846,21 @@ et_application_window_progress_set_text (EtApplicationWindow *self,
     gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar), text);
 }
 
+void
+et_application_window_status_bar_message (EtApplicationWindow *self,
+                                          const gchar *message,
+                                          gboolean with_timer)
+{
+    EtApplicationWindowPrivate *priv;
+
+    g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_status_bar_message (ET_STATUS_BAR (priv->status_bar), message,
+                           with_timer);
+}
+
 GtkWidget *
 et_application_window_get_log_area (EtApplicationWindow *self)
 {
diff --git a/src/application_window.h b/src/application_window.h
index 157c378..2b6a225 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -90,6 +90,7 @@ void et_application_window_show_log_area (EtApplicationWindow *self);
 void et_application_window_scan_dialog_update_previews (EtApplicationWindow *self);
 void et_application_window_progress_set_fraction (EtApplicationWindow *self, gdouble fraction);
 void et_application_window_progress_set_text (EtApplicationWindow *self, const gchar *text);
+void et_application_window_status_bar_message (EtApplicationWindow *self, const gchar *message, gboolean 
with_timer);
 
 G_END_DECLS
 
diff --git a/src/browser.c b/src/browser.c
index 7da6b79..be23cdd 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -43,7 +43,6 @@
 #include "easytag.h"
 #include "et_core.h"
 #include "scan_dialog.h"
-#include "bar.h"
 #include "log.h"
 #include "misc.h"
 #include "setting.h"
@@ -551,7 +550,9 @@ et_browser_set_current_path_default (EtBrowser *self)
     g_settings_set_value (MainSettings, "default-path",
                           g_variant_new_bytestring (priv->current_path));
 
-    Statusbar_Message (_("New default path for files selected"),TRUE);
+    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                              _("New default path for files selected"),
+                                              TRUE);
 }
 
 /*
@@ -4714,7 +4715,8 @@ Rename_Directory (EtBrowser *self)
     g_free(tmp_path);
     g_free(tmp_path_utf8);
     g_free(directory_new_name_file);
-    Statusbar_Message(_("Directory renamed"),TRUE);
+    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                              _("Directory renamed"), TRUE);
 }
 
 static void
diff --git a/src/easytag.c b/src/easytag.c
index 13cdfbb..7fcef3c 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -41,7 +41,6 @@
 #include "browser.h"
 #include "log.h"
 #include "misc.h"
-#include "bar.h"
 #include "cddb_dialog.h"
 #include "preferences_dialog.h"
 #include "setting.h"
@@ -357,7 +356,9 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
                 /* Stop saving files + reinit progress bar */
                 et_application_window_progress_set_text (window, "");
                 et_application_window_progress_set_fraction (window, 0.0);
-                Statusbar_Message (_("Saving files was stopped"), TRUE);
+                et_application_window_status_bar_message (window,
+                                                          _("Saving files was stopped"),
+                                                          TRUE);
                 /* To update state of command buttons */
                 et_application_window_update_actions (window);
                 et_application_window_browser_set_sensitive (window, TRUE);
@@ -404,7 +405,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
 
     et_application_window_progress_set_text (window, "");
     et_application_window_progress_set_fraction (window, 0.0);
-    Statusbar_Message(msg,TRUE);
+    et_application_window_status_bar_message (window, msg, TRUE);
     g_free(msg);
     et_application_window_browser_refresh_list (window);
     return TRUE;
@@ -702,7 +703,9 @@ Save_File (ET_File *ETFile, gboolean multiple_files,
                                filename_cur_utf8, filename_new_utf8,
                                error->message);
 
-                    Statusbar_Message (_("File(s) not renamed"), TRUE);
+                    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                              _("File(s) not renamed"),
+                                                              TRUE);
                     g_error_free (error);
                 }
 
@@ -815,13 +818,15 @@ Write_File_Tag (ET_File *ETFile, gboolean hide_msgbox)
 
     basename_utf8 = g_path_get_basename(cur_filename_utf8);
     msg = g_strdup_printf(_("Writing tag of '%s'"),basename_utf8);
-    Statusbar_Message(msg,TRUE);
+    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                              msg, TRUE);
     g_free(msg);
     msg = NULL;
 
     if (ET_Save_File_Tag_To_HD (ETFile, &error))
     {
-        Statusbar_Message(_("Tag(s) written"),TRUE);
+        et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                  _("Tag(s) written"), TRUE);
         g_free (basename_utf8);
         return TRUE;
     }
@@ -938,8 +943,8 @@ gboolean Read_Directory (gchar *path_real)
 
     /* Read the directory recursively */
     msg = g_strdup_printf(_("Search in progress…"));
-    Statusbar_Message(msg,FALSE);
-    g_free(msg);
+    et_application_window_status_bar_message (window, msg, FALSE);
+    g_free (msg);
     /* Search the supported files. */
     FileList = read_directory_recursively (FileList, dir_enumerator,
                                            g_settings_get_boolean (MainSettings,
@@ -962,7 +967,7 @@ gboolean Read_Directory (gchar *path_real)
         gchar *filename_utf8 = filename_to_display(filename_real);
 
         msg = g_strdup_printf(_("File: '%s'"),filename_utf8);
-        Statusbar_Message(msg,FALSE);
+        et_application_window_status_bar_message (window, msg, FALSE);
         g_free(msg);
         g_free(filename_utf8);
 
@@ -1043,8 +1048,8 @@ gboolean Read_Directory (gchar *path_real)
     et_application_window_browser_set_sensitive (window, TRUE);
 
     et_application_window_progress_set_fraction (window, 0.0);
-    Statusbar_Message(msg,FALSE);
-    g_free(msg);
+    et_application_window_status_bar_message (window, msg, FALSE);
+    g_free (msg);
     Set_Unbusy_Cursor();
     ReadingDirectory = FALSE;
 
diff --git a/src/et_core.c b/src/et_core.c
index 367844e..fc4aff7 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -62,7 +62,6 @@
 #include "opus_tag.h"
 #include "opus_header.h"
 #endif
-#include "bar.h"
 #include "browser.h"
 #include "log.h"
 #include "misc.h"
@@ -2857,8 +2856,8 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
     }
 
     msg = g_strdup_printf(_("File: '%s'"), cur_filename_utf8);
-    Statusbar_Message(msg,FALSE);
-    g_free(msg);
+    et_application_window_status_bar_message (window, msg, FALSE);
+    g_free (msg);
 }
 
 static void
diff --git a/src/load_files_dialog.c b/src/load_files_dialog.c
index 15f0760..f4d8287 100644
--- a/src/load_files_dialog.c
+++ b/src/load_files_dialog.c
@@ -24,7 +24,6 @@
 #include <glib/gi18n.h>
 
 #include "application_window.h"
-#include "bar.h"
 #include "browser.h"
 #include "charset.h"
 #include "easytag.h"
diff --git a/src/log.c b/src/log.c
index c8f4720..8aa6625 100644
--- a/src/log.c
+++ b/src/log.c
@@ -32,7 +32,6 @@
 #include "log.h"
 #include "application_window.h"
 #include "easytag.h"
-#include "bar.h"
 #include "setting.h"
 #include "charset.h"
 
diff --git a/src/misc.c b/src/misc.c
index c84a582..0f15254 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -26,13 +26,13 @@
 #include <sys/stat.h>
 #include <errno.h>
 
+#include "application_window.h"
 #include "gtk2_compat.h"
 #include "misc.h"
 #include "easytag.h"
 #include "id3_tag.h"
 #include "browser.h"
 #include "setting.h"
-#include "bar.h"
 #include "preferences_dialog.h"
 #include "log.h"
 #include "charset.h"
@@ -336,7 +336,8 @@ et_run_program (const gchar *program_name, GList *args_list)
         g_child_watch_add (pid, et_on_child_exited, NULL);
 
         msg = g_strdup_printf (_("Executed command: %s"), program_name);
-        Statusbar_Message (msg, TRUE);
+        et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                  msg, TRUE);
         g_free (msg);
         res = TRUE;
     }
diff --git a/src/picture.c b/src/picture.c
index 27a860f..a743b5a 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -35,7 +35,6 @@
 #include "log.h"
 #include "misc.h"
 #include "setting.h"
-#include "bar.h"
 #include "charset.h"
 
 #include "win32/win32dep.h"
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index 1f953b0..39b6f26 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -23,7 +23,6 @@
 #include <glib/gi18n.h>
 
 #include "application_window.h"
-#include "bar.h"
 #include "browser.h"
 #include "charset.h"
 #include "easytag.h"
@@ -540,8 +539,9 @@ write_button_clicked (EtPlaylistDialog *self)
         {
             gchar *msg;
             msg = g_strdup_printf(_("Written playlist file '%s'"),playlist_name_utf8);
-            Statusbar_Message(msg,TRUE);
-            g_free(msg);
+            et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                                      msg, TRUE);
+            g_free (msg);
         }
         g_object_unref (file);
     }
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 0da26a7..986024a 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -33,7 +33,6 @@
 #include "application_window.h"
 #include "gtk2_compat.h"
 #include "setting.h"
-#include "bar.h"
 #include "misc.h"
 #include "scan_dialog.h"
 #include "easytag.h"
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 273943b..887b7ca 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -36,7 +36,6 @@
 #include "scan.h"
 #include "setting.h"
 #include "id3_tag.h"
-#include "bar.h"
 #include "browser.h"
 #include "log.h"
 #include "misc.h"
@@ -324,7 +323,9 @@ Scan_Tag_With_Mask (EtScanDialog *self, ET_File *ETFile)
     ET_Manage_Changes_Of_File_Data(ETFile,NULL,FileTag);
 
     g_free(mask);
-    Statusbar_Message(_("Tag successfully scanned"),TRUE);
+    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                              _("Tag successfully scanned"),
+                                              TRUE);
     filename_utf8 = g_path_get_basename( ((File_Name *)ETFile->FileNameNew->data)->value_utf8 );
     Log_Print(LOG_OK,_("Tag successfully scanned: %s"),filename_utf8);
     g_free(filename_utf8);
@@ -732,7 +733,9 @@ Scan_Rename_File_With_Mask (EtScanDialog *self, ET_File *ETFile)
     ET_Manage_Changes_Of_File_Data(ETFile,FileName,NULL);
     g_free(filename_new_utf8);
 
-    Statusbar_Message (_("New filename successfully scanned"),TRUE);
+    et_application_window_status_bar_message (ET_APPLICATION_WINDOW (MainWindow),
+                                              _("New filename successfully scanned"),
+                                              TRUE);
 
     filename_new_utf8 = g_path_get_basename(((File_Name *)ETFile->FileNameNew->data)->value_utf8);
     Log_Print (LOG_OK, _("New filename successfully scanned: %s"),
@@ -3464,7 +3467,9 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
 
     et_application_window_progress_set_text (window, "");
     et_application_window_progress_set_fraction (window, 0.0);
-    Statusbar_Message(_("All tags have been scanned"),TRUE);
+    et_application_window_status_bar_message (window,
+                                              _("All tags have been scanned"),
+                                              TRUE);
 }
 
 /*
diff --git a/src/search_dialog.c b/src/search_dialog.c
index 32cabd7..86d6994 100644
--- a/src/search_dialog.c
+++ b/src/search_dialog.c
@@ -23,7 +23,6 @@
 #include <glib/gi18n.h>
 
 #include "application_window.h"
-#include "bar.h"
 #include "browser.h"
 #include "charset.h"
 #include "easytag.h"
diff --git a/src/setting.c b/src/setting.c
index c3cebeb..76ef09d 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -38,7 +38,6 @@
 #include "playlist_dialog.h"
 #include "preferences_dialog.h"
 #include "search_dialog.h"
-#include "bar.h"
 #include "easytag.h"
 #include "charset.h"
 #include "scan_dialog.h"
diff --git a/src/status_bar.c b/src/status_bar.c
new file mode 100644
index 0000000..3e7e4d0
--- /dev/null
+++ b/src/status_bar.c
@@ -0,0 +1,174 @@
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "status_bar.h"
+#include "charset.h"
+
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtStatusBar, et_status_bar, GTK_TYPE_STATUSBAR)
+
+#define et_status_bar_get_instance_private(bar) (bar->priv)
+
+struct _EtStatusBarPrivate
+{
+    guint message_context;
+    guint timer_context;
+    guint timer_id;
+};
+
+static void et_status_bar_remove_timer (EtStatusBar *self);
+
+static gboolean
+et_status_bar_stop_timer (EtStatusBar *self)
+{
+    EtStatusBarPrivate *priv;
+
+    priv = et_status_bar_get_instance_private (self);
+
+    gtk_statusbar_pop (GTK_STATUSBAR (self), priv->timer_context);
+
+    return G_SOURCE_REMOVE;
+}
+
+static void
+et_status_bar_reset_timer (EtStatusBar *self)
+{
+    EtStatusBarPrivate *priv;
+
+    priv = et_status_bar_get_instance_private (self);
+
+    priv->timer_id = 0;
+}
+
+static void
+et_status_bar_start_timer (EtStatusBar *self)
+{
+    EtStatusBarPrivate *priv;
+
+    priv = et_status_bar_get_instance_private (self);
+
+    et_status_bar_remove_timer (self);
+    priv->timer_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 4,
+                                                 (GSourceFunc)et_status_bar_stop_timer,
+                                                 self,
+                                                 (GDestroyNotify)et_status_bar_reset_timer);
+    g_source_set_name_by_id (priv->timer_id, "Statusbar stop timer");
+}
+
+static void
+et_status_bar_remove_timer (EtStatusBar *self)
+{
+    EtStatusBarPrivate *priv;
+
+    priv = et_status_bar_get_instance_private (self);
+
+    if (priv->timer_id)
+    {
+        et_status_bar_stop_timer (self);
+        g_source_remove (priv->timer_id);
+        et_status_bar_reset_timer (self);
+    }
+}
+
+/*
+ * Send a message to the status bar
+ *  - with_timer: if TRUE, the message will be displayed during 4s
+ *                if FALSE, the message will be displayed up to the next posted message
+ */
+void
+et_status_bar_message (EtStatusBar *self,
+                       const gchar *message,
+                       gboolean with_timer)
+{
+    EtStatusBarPrivate *priv;
+    gchar *msg_temp;
+
+    g_return_if_fail (ET_STATUS_BAR (self));
+
+    priv = et_status_bar_get_instance_private (self);
+
+    msg_temp = Try_To_Validate_Utf8_String (message);
+    
+    /* Push the given message */
+    if (with_timer)
+    {
+        et_status_bar_start_timer (self);
+        gtk_statusbar_push (GTK_STATUSBAR (self), priv->timer_context,
+                            msg_temp);
+    }
+    else
+    {
+        gtk_statusbar_pop (GTK_STATUSBAR (self), priv->message_context);
+        gtk_statusbar_push (GTK_STATUSBAR (self), priv->message_context,
+                            msg_temp);
+    }
+
+    g_free (msg_temp);
+}
+
+static void
+create_status_bar (EtStatusBar *self)
+{
+    EtStatusBarPrivate *priv;
+
+    priv = et_status_bar_get_instance_private (self);
+
+    /* Specify a size to avoid statubar resizing if the message is too long */
+    gtk_widget_set_size_request (GTK_WIDGET (self), 200, -1);
+
+    /* Create serie */
+    priv->message_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (self),
+                                                          "messages");
+    priv->timer_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (self),
+                                                        "timer");
+
+    et_status_bar_message (self, _("Ready to start"), TRUE);
+}
+
+static void
+et_status_bar_init (EtStatusBar *self)
+{
+    self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_STATUS_BAR,
+                                              EtStatusBarPrivate);
+
+    create_status_bar (self);
+}
+
+static void
+et_status_bar_class_init (EtStatusBarClass *klass)
+{
+    g_type_class_add_private (klass, sizeof (EtStatusBarPrivate));
+}
+
+/*
+ * et_status_bar_new:
+ *
+ * Create a new EtStatusBar instance.
+ *
+ * Returns: a new #EtStatusBar
+ */
+GtkWidget *
+et_status_bar_new (void)
+{
+    return g_object_new (ET_TYPE_STATUS_BAR, NULL);
+}
diff --git a/src/status_bar.h b/src/status_bar.h
new file mode 100644
index 0000000..abd038f
--- /dev/null
+++ b/src/status_bar.h
@@ -0,0 +1,52 @@
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ET_STATUS_BAR_H_
+#define ET_STATUS_BAR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_STATUS_BAR (et_status_bar_get_type ())
+#define ET_STATUS_BAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_STATUS_BAR, EtStatusBar))
+
+typedef struct _EtStatusBar EtStatusBar;
+typedef struct _EtStatusBarClass EtStatusBarClass;
+typedef struct _EtStatusBarPrivate EtStatusBarPrivate;
+
+struct _EtStatusBar
+{
+    /*< private >*/
+    GtkStatusbar parent_instance;
+    EtStatusBarPrivate *priv;
+};
+
+struct _EtStatusBarClass
+{
+    /*< private >*/
+    GtkStatusbarClass parent_class;
+};
+
+GType et_status_bar_get_type (void);
+GtkWidget * et_status_bar_new (void);
+void et_status_bar_message (EtStatusBar *self, const gchar *message, gboolean with_timer);
+
+G_END_DECLS
+
+#endif /* ET_STATUS_BAR_H_ */
diff --git a/src/tag_area.c b/src/tag_area.c
index 82c4824..c986a47 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -24,7 +24,6 @@
 #include <glib/gi18n.h>
 
 #include "application_window.h"
-#include "bar.h"
 #include "charset.h"
 #include "easytag.h"
 #include "et_core.h"
@@ -136,6 +135,7 @@ on_apply_to_selection (GObject *object,
                        EtTagArea *self)
 {
     EtTagAreaPrivate *priv;
+    EtApplicationWindow *window;
     GList *etfilelist = NULL;
     GList *selection_filelist = NULL;
     GList *l;
@@ -150,18 +150,20 @@ on_apply_to_selection (GObject *object,
 
     priv = et_tag_area_get_instance_private (self);
 
+    window = ET_APPLICATION_WINDOW (MainWindow);
+
     // Save the current displayed data
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
     /* Warning : 'selection_filelist' is not a list of 'ETFile' items! */
-    selection = et_application_window_browser_get_selection (ET_APPLICATION_WINDOW (MainWindow));
+    selection = et_application_window_browser_get_selection (window);
     selection_filelist = gtk_tree_selection_get_selected_rows (selection, NULL);
 
     // Create an 'ETFile' list from 'selection_filelist'
     for (l = selection_filelist; l != NULL; l = g_list_next (l))
     {
-        etfile = et_application_window_browser_get_et_file_from_path (ET_APPLICATION_WINDOW (MainWindow),
-                                                   l->data);
+        etfile = et_application_window_browser_get_et_file_from_path (window,
+                                                                      l->data);
         etfilelist = g_list_prepend (etfilelist, etfile);
     }
 
@@ -587,7 +589,7 @@ on_apply_to_selection (GObject *object,
     g_list_free(etfilelist);
 
     /* Refresh the whole list (faster than file by file) to show changes. */
-    et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
+    et_application_window_browser_refresh_list (window);
 
     /* Display the current file (Needed when sequencing tracks) */
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
@@ -595,14 +597,14 @@ on_apply_to_selection (GObject *object,
     if (msg)
     {
         Log_Print(LOG_OK,"%s",msg);
-        Statusbar_Message(msg,TRUE);
+        et_application_window_status_bar_message (window, msg,TRUE);
         g_free(msg);
     }
     g_free(string_to_set);
     g_free(string_to_set1);
 
     /* To update state of Undo button */
-    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
+    et_application_window_update_actions (window);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]