[easytag/wip/application-window: 24/54] Split progress bar from status bar
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 24/54] Split progress bar from status bar
- Date: Thu, 4 Sep 2014 17:35:32 +0000 (UTC)
commit 21208c2e87e066a7284a256302be5d5f5c662a9b
Author: David King <amigadave amigadave com>
Date: Fri Aug 15 16:10:20 2014 +0100
Split progress bar from status bar
There is no need to subclass GtkProgressBar, so just move the progress
bar code to a separate file.
Makefile.am | 2 +
src/application_window.c | 59 +++++++++++++++++++++++++++++++++------------
src/application_window.h | 2 +
src/bar.c | 11 --------
src/bar.h | 6 ----
src/easytag.c | 39 +++++++++++++++--------------
src/gtk2_compat.c | 16 +-----------
src/gtk2_compat.h | 2 -
src/progress_bar.c | 31 ++++++++++++++++++++++++
src/progress_bar.h | 29 ++++++++++++++++++++++
src/scan_dialog.c | 24 ++++++++++--------
11 files changed, 141 insertions(+), 80 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 532fa1b..af7586d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,6 +59,7 @@ easytag_SOURCES = \
src/picture.c \
src/playlist_dialog.c \
src/preferences_dialog.c \
+ src/progress_bar.c \
src/scan.c \
src/scan_dialog.c \
src/search_dialog.c \
@@ -111,6 +112,7 @@ easytag_headers = \
src/picture.h \
src/playlist_dialog.h \
src/preferences_dialog.h \
+ src/progress_bar.h \
src/scan.h \
src/scan_dialog.h \
src/search_dialog.h \
diff --git a/src/application_window.c b/src/application_window.c
index 414129f..a86339b 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -35,6 +35,7 @@
#include "picture.h"
#include "playlist_dialog.h"
#include "preferences_dialog.h"
+#include "progress_bar.h"
#include "search_dialog.h"
#include "scan.h"
#include "scan_dialog.h"
@@ -53,6 +54,8 @@ struct _EtApplicationWindowPrivate
GtkWidget *file_area;
GtkWidget *log_area;
GtkWidget *tag_area;
+ GtkWidget *progress_bar;
+
GtkWidget *cddb_dialog;
GtkWidget *load_files_dialog;
GtkWidget *playlist_dialog;
@@ -484,10 +487,10 @@ on_delete (GSimpleAction *action,
nb_files_to_delete = gtk_tree_selection_count_selected_rows (selection);
/* Initialize status bar */
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0);
+ et_application_window_progress_set_fraction (self, 0.0);
progress_bar_index = 0;
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_delete);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (self, progress_bar_text);
/* Set to unsensitive all command buttons (except Quit button) */
et_application_window_disable_command_actions (self);
@@ -523,12 +526,10 @@ on_delete (GSimpleAction *action,
et_application_window_browser_select_file_by_et_file (self, ETFile,
FALSE);
fraction = (++progress_bar_index) / (double) nb_files_to_delete;
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (ProgressBar),
- fraction);
+ et_application_window_progress_set_fraction (self, fraction);
g_snprintf (progress_bar_text, 30, "%d/%d", progress_bar_index,
nb_files_to_delete);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (ProgressBar),
- progress_bar_text);
+ et_application_window_progress_set_text (self, progress_bar_text);
/* FIXME: Needed to refresh status bar */
while (gtk_events_pending ())
{
@@ -560,8 +561,8 @@ on_delete (GSimpleAction *action,
}
break;
case -1:
- // Stop deleting files + reinit progress bar
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0.0);
+ /* Stop deleting files + reinit progress bar. */
+ et_application_window_progress_set_fraction (self, 0.0);
/* To update state of command buttons. */
et_application_window_update_actions (self);
et_application_window_browser_set_sensitive (self, TRUE);
@@ -597,8 +598,8 @@ on_delete (GSimpleAction *action,
et_application_window_tag_area_set_sensitive (self, TRUE);
et_application_window_file_area_set_sensitive (self, TRUE);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
+ et_application_window_progress_set_text (self, "");
+ et_application_window_progress_set_fraction (self, 0.0);
Statusbar_Message(msg,TRUE);
g_free(msg);
@@ -882,7 +883,7 @@ on_remove_tags (GSimpleAction *action,
ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
/* Initialize status bar */
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (ProgressBar), 0.0);
+ et_application_window_progress_set_fraction (self, 0.0);
selection = et_application_window_browser_get_selection (self);
selectcount = gtk_tree_selection_count_selected_rows (selection);
progress_bar_index = 0;
@@ -897,8 +898,7 @@ on_remove_tags (GSimpleAction *action,
ET_Manage_Changes_Of_File_Data (etfile, NULL, FileTag);
fraction = (++progress_bar_index) / (double) selectcount;
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (ProgressBar),
- fraction);
+ et_application_window_progress_set_fraction (self, fraction);
/* Needed to refresh status bar */
while (gtk_events_pending ())
{
@@ -915,7 +915,7 @@ on_remove_tags (GSimpleAction *action,
ET_Display_File_Data_To_UI (ETCore->ETFileDisplayed);
et_application_window_update_actions (self);
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (ProgressBar), 0.0);
+ et_application_window_progress_set_fraction (self, 0.0);
Statusbar_Message (_("All tags have been removed"),TRUE);
}
@@ -1746,8 +1746,8 @@ et_application_window_init (EtApplicationWindow *self)
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
/* Progress bar */
- widget = Create_Progress_Bar ();
- gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+ priv->progress_bar = et_progress_bar_new ();
+ gtk_box_pack_end (GTK_BOX (hbox), priv->progress_bar, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET (main_vbox));
}
@@ -1815,6 +1815,33 @@ et_application_window_scan_dialog_update_previews (EtApplicationWindow *self)
}
}
+void
+et_application_window_progress_set_fraction (EtApplicationWindow *self,
+ gdouble fraction)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar),
+ fraction);
+}
+
+void
+et_application_window_progress_set_text (EtApplicationWindow *self,
+ const gchar *text)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar), text);
+}
+
GtkWidget *
et_application_window_get_log_area (EtApplicationWindow *self)
{
diff --git a/src/application_window.h b/src/application_window.h
index 271fd58..157c378 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -88,6 +88,8 @@ void et_application_window_browser_refresh_sort (EtApplicationWindow *self);
void et_application_window_hide_log_area (EtApplicationWindow *self);
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);
G_END_DECLS
diff --git a/src/bar.c b/src/bar.c
index c94e79f..3857b9f 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -127,14 +127,3 @@ Statusbar_Message (const gchar *message, gboolean with_timer)
g_free(msg_temp);
}
-
-/*
- * Progress bar
- */
-GtkWidget *Create_Progress_Bar (void)
-{
- ProgressBar = et_progress_bar_new ();
-
- gtk_widget_show(ProgressBar);
- return ProgressBar;
-}
diff --git a/src/bar.h b/src/bar.h
index 193926a..d766d0f 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -22,17 +22,11 @@
#ifndef __BAR_H__
#define __BAR_H__
-/***************
- * Declaration *
- ***************/
-GtkWidget *ProgressBar;
-
/**************
* Prototypes *
**************/
GtkWidget *Create_Status_Bar (void);
void Statusbar_Message (const gchar *message, gboolean with_timer);
-GtkWidget *Create_Progress_Bar (void);
#endif /* __BAR_H__ */
diff --git a/src/easytag.c b/src/easytag.c
index 6e3c833..13cdfbb 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -257,10 +257,10 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
}
/* Initialize status bar */
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0);
+ et_application_window_progress_set_fraction (window, 0.0);
progress_bar_index = 0;
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_save);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window, progress_bar_text);
/* Set to unsensitive all command buttons (except Quit button) */
et_application_window_disable_command_actions (window);
@@ -332,15 +332,16 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
/* ET_Display_File_Data_To_UI ((ET_File *)l->data);
* Use of 'currentPath' to try to increase speed. Indeed, in many
* cases, the next file to select, is the next in the list. */
- et_application_window_browser_select_file_by_et_file2 (ET_APPLICATION_WINDOW (MainWindow),
+ et_application_window_browser_select_file_by_et_file2 (window,
(ET_File *)l->data,
FALSE,
currentPath);
fraction = (++progress_bar_index) / (double) nb_files_to_save;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
+ et_application_window_progress_set_fraction (window, fraction);
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_save);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window,
+ progress_bar_text);
/* Needed to refresh status bar */
while (gtk_events_pending())
@@ -354,11 +355,11 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
if (saving_answer == -1)
{
/* Stop saving files + reinit progress bar */
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
+ et_application_window_progress_set_text (window, "");
+ et_application_window_progress_set_fraction (window, 0.0);
Statusbar_Message (_("Saving files was stopped"), TRUE);
/* To update state of command buttons */
- et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
+ et_application_window_update_actions (window);
et_application_window_browser_set_sensitive (window, TRUE);
et_application_window_tag_area_set_sensitive (window, TRUE);
et_application_window_file_area_set_sensitive (window, TRUE);
@@ -401,11 +402,11 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
/* Give again focus to the first entry, else the focus is passed to another */
gtk_widget_grab_focus(GTK_WIDGET(widget_focused));
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
+ et_application_window_progress_set_text (window, "");
+ et_application_window_progress_set_fraction (window, 0.0);
Statusbar_Message(msg,TRUE);
g_free(msg);
- et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
+ et_application_window_browser_refresh_list (window);
return TRUE;
}
@@ -949,9 +950,9 @@ gboolean Read_Directory (gchar *path_real)
nbrfile = g_list_length(FileList);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
+ et_application_window_progress_set_fraction (window, 0.0);
g_snprintf(progress_bar_text, 30, "%d/%d", 0, nbrfile);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window, progress_bar_text);
// Load the supported files (Extension recognized)
for (l = FileList; l != NULL && !Main_Stop_Button_Pressed;
@@ -968,18 +969,18 @@ gboolean Read_Directory (gchar *path_real)
// Warning: Do not free filename_real because ET_Add_File.. uses it for internal structures
ET_Add_File_To_File_List(filename_real);
- // Update the progress bar
+ /* Update the progress bar. */
fraction = (++progress_bar_index) / (double) nbrfile;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
+ et_application_window_progress_set_fraction (window, fraction);
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nbrfile);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window, progress_bar_text);
while (gtk_events_pending())
gtk_main_iteration();
}
/* Just free the list, not the data. */
g_list_free (FileList);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
+ et_application_window_progress_set_text (window, "");
/* Close window to quit recursion */
Destroy_Quit_Recursion_Function_Window();
@@ -1037,11 +1038,11 @@ gboolean Read_Directory (gchar *path_real)
}
/* Update sensitivity of buttons and menus */
- et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
+ et_application_window_update_actions (window);
et_application_window_browser_set_sensitive (window, TRUE);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
+ et_application_window_progress_set_fraction (window, 0.0);
Statusbar_Message(msg,FALSE);
g_free(msg);
Set_Unbusy_Cursor();
diff --git a/src/gtk2_compat.c b/src/gtk2_compat.c
index 530bd9d..7b65d94 100644
--- a/src/gtk2_compat.c
+++ b/src/gtk2_compat.c
@@ -1,5 +1,4 @@
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
+/* EasyTAG - Tag editor for audio files
* Copyright (C) 2012 David King <amigadave amigadave com>
*
* This program is free software; you can redistribute it and/or modify
@@ -45,16 +44,3 @@ void et_grid_attach_margins (GtkGrid *grid, GtkWidget *child, gint left,
et_grid_attach_full (grid, child, left, top, width, height, FALSE, FALSE,
hmargin, vmargin);
}
-
-GtkWidget *
-et_progress_bar_new (void)
-{
- GtkWidget *progress;
-
- progress = gtk_progress_bar_new ();
-
- gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (progress), TRUE);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "");
-
- return progress;
-}
diff --git a/src/gtk2_compat.h b/src/gtk2_compat.h
index dc70b5f..2093f92 100644
--- a/src/gtk2_compat.h
+++ b/src/gtk2_compat.h
@@ -33,8 +33,6 @@ void et_grid_attach_margins (GtkGrid *grid, GtkWidget *child, gint left,
gint top, gint width, gint height, gint hmargin,
gint vmargin);
-GtkWidget * et_progress_bar_new (void);
-
G_END_DECLS
#endif /* GTK2_COMPAT_H_ */
diff --git a/src/progress_bar.c b/src/progress_bar.c
new file mode 100644
index 0000000..afb2b45
--- /dev/null
+++ b/src/progress_bar.c
@@ -0,0 +1,31 @@
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave 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/>.
+ */
+
+#include "progress_bar.h"
+
+GtkWidget *
+et_progress_bar_new (void)
+{
+ GtkWidget *progress;
+
+ progress = gtk_progress_bar_new ();
+
+ gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (progress), TRUE);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "");
+
+ return progress;
+}
diff --git a/src/progress_bar.h b/src/progress_bar.h
new file mode 100644
index 0000000..1d9d63c
--- /dev/null
+++ b/src/progress_bar.h
@@ -0,0 +1,29 @@
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave 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_PROGRESS_BAR_H_
+#define ET_PROGRESS_BAR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+GtkWidget * et_progress_bar_new (void);
+
+G_END_DECLS
+
+#endif /* ET_PROGRESS_BAR_H_ */
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 519af7f..273943b 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -3409,6 +3409,7 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
GList *selfilelist = NULL;
GList *l;
ET_File *etfile;
+ EtApplicationWindow *window;
GtkTreeSelection *selection;
g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
@@ -3417,15 +3418,16 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
/* Initialize status bar */
- selection = et_application_window_browser_get_selection (ET_APPLICATION_WINDOW (MainWindow));
+ window = ET_APPLICATION_WINDOW (MainWindow);
+ selection = et_application_window_browser_get_selection (window);
selectcount = gtk_tree_selection_count_selected_rows (selection);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0);
+ et_application_window_progress_set_fraction (window, 0.0);
progress_bar_index = 0;
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, selectcount);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window, progress_bar_text);
/* Set to unsensitive all command buttons (except Quit button) */
- et_application_window_disable_command_actions (ET_APPLICATION_WINDOW (MainWindow));
+ et_application_window_disable_command_actions (window);
progress_bar_index = 0;
@@ -3433,16 +3435,16 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
for (l = selfilelist; l != NULL; l = g_list_next (l))
{
- etfile = et_application_window_browser_get_et_file_from_path (ET_APPLICATION_WINDOW (MainWindow),
+ etfile = et_application_window_browser_get_et_file_from_path (window,
l->data);
/* Run the current scanner. */
Scan_Select_Mode_And_Run_Scanner (self, etfile);
fraction = (++progress_bar_index) / (double) selectcount;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
+ et_application_window_progress_set_fraction (window, fraction);
g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, selectcount);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ et_application_window_progress_set_text (window, progress_bar_text);
/* Needed to refresh status bar */
while (gtk_events_pending())
@@ -3452,16 +3454,16 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
/* 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 */
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
/* To update state of command buttons */
- et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
+ et_application_window_update_actions (window);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
+ et_application_window_progress_set_text (window, "");
+ et_application_window_progress_set_fraction (window, 0.0);
Statusbar_Message(_("All tags have been scanned"),TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]