[easytag/wip/musicbrainz-support-appwin-merge: 38/82] Make "mbDialog" and "builder" static



commit e38beca984455f274030dd063273e8a67d4f486f
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 f78aa5f..8e20b69 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -667,10 +667,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))
     {
@@ -679,7 +677,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));
@@ -725,8 +724,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);
     }
 }
 
@@ -911,8 +909,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 24cef13..8bb9c2f 100755
--- 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);
     }
@@ -1035,7 +1051,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);
     }
@@ -1179,7 +1195,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);
     }
@@ -1762,7 +1778,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;
 }
 
 /*
@@ -1833,6 +1852,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);
@@ -1843,7 +1865,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);
     }
@@ -1919,7 +1941,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");
@@ -2022,14 +2044,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 905937e..5249e33 100755
--- 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_libmusicbrainz */
\ No newline at end of file


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