[easytag/wip/musicbrainz-support-merge: 115/149] Make "mbDialog" and "builder" static



commit 7c536bd7465a138f274c0c98ad0b441decccbb5b
Author: Abhinav <abhijangda hotmail com>
Date:   Sat Jul 26 15:40:11 2014 +0530

    Make "mbDialog" and "builder" static
    
    mbDialog and builder are static variables in musicbrainz_dialog.c
    Added a new function et_music_brainz_dialog_set_statusbar_message

 src/mbentityview.c       |   13 +++++--------
 src/musicbrainz_dialog.c |   41 +++++++++++++++++++++++++++++++++--------
 src/musicbrainz_dialog.h |    8 +++++---
 3 files changed, 43 insertions(+), 19 deletions(-)
---
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 2eaa154..8fe4b82 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -665,10 +665,8 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
     thread_data = user_data;
     entity_view = thread_data->entity_view;
     priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
+    et_music_brainz_dialog_set_statusbar_message (_("Retrieving Completed"));
 
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
-                        "statusbar")),
-                        0, "Retrieving Completed");
     /* Check if child node has children or not */
     if (!g_node_first_child (thread_data->child))
     {
@@ -677,7 +675,8 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
 
     priv->mb_tree_current_node = thread_data->child;
 
-    if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (priv->list_store), &thread_data->iter))
+    if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (priv->list_store),
+                                      &thread_data->iter))
     {
         /* Only run if iter is valid i.e. it is not a Refresh Option */
         children = gtk_container_get_children (GTK_CONTAINER (priv->bread_crumb_box));
@@ -723,8 +722,7 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
 
     if (et_music_brainz_get_exit_on_complete ())
     {
-        gtk_dialog_response (GTK_DIALOG (mbDialog),
-                             GTK_RESPONSE_DELETE_EVENT);
+        et_music_brainz_dialog_set_response (GTK_RESPONSE_DELETE_EVENT);
     }
 }
 
@@ -909,8 +907,7 @@ search_in_levels (EtMbEntityView *entity_view, GNode *child,
         return;
     }
 
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
-                        0, _("Starting MusicBrainz Search"));
+    et_music_brainz_dialog_set_statusbar_message (_("Starting MusicBrainz Search"));
     async_result = g_simple_async_result_new (NULL,
                                               search_in_levels_callback,
                                               thread_data,
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index bf7381d..90c5ad9 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -166,9 +166,11 @@ struct _EtMusicBrainzDialogPrivate
     GtkTreeModel *tag_choice_store;
     GtkWidget *tag_choice_dialog;
     GtkWidget *entityView;
+    gboolean exit_on_complete;
 };
 
-static gboolean exit_on_complete;
+static GtkWidget *mbDialog;
+static GtkBuilder *builder;
 
 /*
  * ManualSearchThreadData:
@@ -279,6 +281,20 @@ et_initialize_tag_choice_dialog (EtMusicBrainzDialogPrivate *mb_dialog_priv);
  * Functions *
  *************/
 
+void
+et_music_brainz_dialog_set_response (GtkResponseType response)
+{
+    gtk_dialog_response (GTK_DIALOG (mbDialog), response);
+}
+
+void
+et_music_brainz_dialog_set_statusbar_message (gchar *message)
+{
+    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
+                        "statusbar")),
+                        0, message);
+}
+
 /*
  * et_mb_destroy_search:
  * @search: EtMbSearch
@@ -769,7 +785,7 @@ selected_find_callback (GObject *source, GAsyncResult *res,
     g_hash_table_destroy (((SelectedFindThreadData *)user_data)->hash_table);
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
 
-    if (exit_on_complete)
+    if (mb_dialog_priv->exit_on_complete)
     {
         btn_close_clicked (NULL, NULL);
     }
@@ -1044,7 +1060,7 @@ discid_search_callback (GObject *source, GAsyncResult *res,
     g_slice_free (DiscIDSearchThreadData, thread_data);
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
 
-    if (exit_on_complete)
+    if (mb_dialog_priv->exit_on_complete)
     {
         btn_close_clicked (NULL, NULL);
     }
@@ -1188,7 +1204,7 @@ freedbid_search_callback (GObject *source, GAsyncResult *res,
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
     et_mb_set_automatic_search (&mb_dialog_priv->search);
 
-    if (exit_on_complete)
+    if (mb_dialog_priv->exit_on_complete)
     {
         btn_close_clicked (NULL, NULL);
     }
@@ -1780,7 +1796,10 @@ et_initialize_tag_choice_dialog (EtMusicBrainzDialogPrivate *mb_dialog_priv)
 gboolean
 et_music_brainz_get_exit_on_complete (void)
 {
-    return exit_on_complete;
+    EtMusicBrainzDialogPrivate *mb_dialog_priv;
+
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));    
+    return mb_dialog_priv->exit_on_complete;
 }
 
 /*
@@ -1851,6 +1870,9 @@ mb5_search_error_callback (GObject *source, GAsyncResult *res,
                            gpointer user_data)
 {
     GError *dest;
+    EtMusicBrainzDialogPrivate *mb_dialog_priv;
+
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
     dest = NULL;
     g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res),
                                            &dest);
@@ -1861,7 +1883,7 @@ mb5_search_error_callback (GObject *source, GAsyncResult *res,
     g_error_free (dest);
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
 
-    if (exit_on_complete)
+    if (mb_dialog_priv->exit_on_complete)
     {
         et_music_brainz_dialog_destroy (mbDialog);
     }
@@ -1937,7 +1959,7 @@ et_musicbrainz_dialog_init (EtMusicBrainzDialog *dialog)
 
     priv->mb_tree_root = g_node_new (NULL);
     priv->search = NULL;
-    exit_on_complete = FALSE;
+    priv->exit_on_complete = FALSE;
     priv->entityView = et_mb_entity_view_new ();
     box = GTK_WIDGET (gtk_builder_get_object (builder, "mb_box"));
     gtk_window_set_title (GTK_WINDOW (dialog), "MusicBrainz Search");
@@ -2040,14 +2062,17 @@ et_musicbrainz_dialog_new ()
 void
 et_open_musicbrainz_dialog ()
 {
+    EtMusicBrainzDialogPrivate *priv;
+
     mbDialog = et_musicbrainz_dialog_new ();
+    priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
     gtk_widget_show_all (mbDialog);
     gtk_dialog_run (GTK_DIALOG (mbDialog));
 
     if (gtk_widget_get_sensitive (GTK_WIDGET (gtk_builder_get_object (builder,
                                   "btnStop"))))
     {
-        exit_on_complete = TRUE;
+        priv->exit_on_complete = TRUE;
         btn_manual_stop_clicked (NULL, NULL);
         gtk_widget_hide (mbDialog);
     }
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
index e7bfacd..549b060 100644
--- a/src/musicbrainz_dialog.h
+++ b/src/musicbrainz_dialog.h
@@ -45,10 +45,8 @@ G_BEGIN_DECLS
  * Declarations *
  ****************/
 
-GtkBuilder *builder;
-GtkWidget *mbDialog;
-
 typedef struct _EtMusicBrainzDialogPrivate EtMusicBrainzDialogPrivate;
+
 /*
  * EtMbEntityView:
  * @vbox: GtkBox, parent class of EtMbEntityView
@@ -95,6 +93,10 @@ void
 et_music_brainz_dialog_destroy (GtkWidget *widget);
 gboolean
 et_music_brainz_get_exit_on_complete (void);
+void
+et_music_brainz_dialog_set_statusbar_message (gchar *message);
+void
+et_music_brainz_dialog_set_response (GtkResponseType response);
 G_END_DECLS
 #endif /* __MUSICBRAINZ_DIALOG_H__ */
 #endif /* ENABLE_MUSICBRAINZ */


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