[easytag] Move busy cursor handling to application window



commit 084f04adc487f21bc768835d37709fe7626ac934
Author: David King <amigadave amigadave com>
Date:   Fri Nov 21 16:34:10 2014 +0000

    Move busy cursor handling to application window
    
    Avoid the deprecated gdk_cursor_new(), and instead use
    gdk_cursor_new_for_display().

 src/application.c        |    1 -
 src/application_window.c |   37 +++++++++++++++++++++++++++++++++++++
 src/application_window.h |    2 ++
 src/easytag.c            |    4 ++--
 src/misc.c               |   36 ------------------------------------
 src/misc.h               |    4 ----
 6 files changed, 41 insertions(+), 43 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index c5c051b..7476fd6 100644
--- a/src/application.c
+++ b/src/application.c
@@ -165,7 +165,6 @@ common_init (EtApplication *self)
     /* Initialization */
     ET_Core_Create ();
     Main_Stop_Button_Pressed = FALSE;
-    Init_Mouse_Cursor ();
 
     /* The main window */
     window = et_application_window_new (GTK_APPLICATION (self));
diff --git a/src/application_window.c b/src/application_window.c
index 3162a50..3d2a424 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -66,6 +66,8 @@ struct _EtApplicationWindowPrivate
     GtkWidget *hpaned;
     GtkWidget *vpaned;
 
+    GdkCursor *cursor;
+
     gboolean is_maximized;
     gint height;
     gint width;
@@ -1628,6 +1630,12 @@ et_application_window_dispose (GObject *object)
         priv->search_dialog = NULL;
     }
 
+    if (priv->cursor)
+    {
+        g_object_unref (priv->cursor);
+        priv->cursor = NULL;
+    }
+
     G_OBJECT_CLASS (et_application_window_parent_class)->dispose (object);
 }
 
@@ -2401,6 +2409,35 @@ et_application_window_update_actions (EtApplicationWindow *self)
     }
 }
 
+void
+et_application_window_set_busy_cursor (EtApplicationWindow *self)
+{
+    EtApplicationWindowPrivate *priv;
+
+    g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+    priv = et_application_window_get_instance_private (self);
+
+    if (!priv->cursor)
+    {
+        priv->cursor = gdk_cursor_new_for_display (gdk_window_get_display (gtk_widget_get_window (GTK_WIDGET 
(self))),
+                                                   GDK_WATCH);
+
+    }
+
+    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)),
+                           priv->cursor);
+}
+
+void
+et_application_window_set_normal_cursor (EtApplicationWindow *self)
+{
+    g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+    /* Back to standard cursor */
+    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL);
+}
+
 /*
  * Display controls according the kind of tag... (Hide some controls if not available for a tag type)
  */
diff --git a/src/application_window.h b/src/application_window.h
index 2481f22..c85758a 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -58,6 +58,8 @@ void et_application_window_file_area_clear (EtApplicationWindow *self);
 void et_application_window_file_area_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
 void et_application_window_disable_command_actions (EtApplicationWindow *self);
 void et_application_window_update_actions (EtApplicationWindow *self);
+void et_application_window_set_busy_cursor (EtApplicationWindow *self);
+void et_application_window_set_normal_cursor (EtApplicationWindow *self);
 void et_application_window_tag_area_display_controls (EtApplicationWindow *self, const ET_File *ETFile);
 GtkWidget * et_application_window_get_log_area (EtApplicationWindow *self);
 void et_application_window_show_preferences_dialog_scanner (EtApplicationWindow *self);
diff --git a/src/easytag.c b/src/easytag.c
index c789f62..8a90ea5 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -1001,7 +1001,7 @@ Read_Directory (const gchar *path_real)
     }
 
     /* Open the window to quit recursion (since 27/04/2007 : not only into recursion mode) */
-    Set_Busy_Cursor();
+    et_application_window_set_busy_cursor (window);
     action = g_action_map_lookup_action (G_ACTION_MAP (MainWindow), "stop");
     g_settings_bind (MainSettings, "browse-subdir", G_SIMPLE_ACTION (action),
                      "enabled", G_SETTINGS_BIND_GET);
@@ -1116,7 +1116,7 @@ Read_Directory (const gchar *path_real)
     et_application_window_progress_set_fraction (window, 0.0);
     et_application_window_status_bar_message (window, msg, FALSE);
     g_free (msg);
-    Set_Unbusy_Cursor();
+    et_application_window_set_normal_cursor (window);
     ReadingDirectory = FALSE;
 
     return TRUE;
diff --git a/src/misc.c b/src/misc.c
index 649ed60..7e3043e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -43,8 +43,6 @@
  ***************/
 static const guint BOX_SPACING = 6;
 
-static GdkCursor *MouseCursor;
-
 /*
  * Add the 'string' passed in parameter to the list store
  * If this string already exists in the list store, it doesn't add it.
@@ -168,40 +166,6 @@ gchar *Get_Active_Combo_Box_Item (GtkComboBox *combo)
     return text;
 }
 
-/*
- * Change mouse cursor
- */
-void Init_Mouse_Cursor (void)
-{
-    MouseCursor = NULL;
-}
-
-static void
-Destroy_Mouse_Cursor (void)
-{
-    if (MouseCursor)
-    {
-        g_object_unref (MouseCursor);
-        MouseCursor = NULL;
-    }
-}
-
-void Set_Busy_Cursor (void)
-{
-    /* If still built, destroy it to avoid memory leak */
-    Destroy_Mouse_Cursor();
-    /* Create the new cursor */
-    MouseCursor = gdk_cursor_new(GDK_WATCH);
-    gdk_window_set_cursor(gtk_widget_get_window(MainWindow),MouseCursor);
-}
-
-void Set_Unbusy_Cursor (void)
-{
-    /* Back to standard cursor */
-    gdk_window_set_cursor(gtk_widget_get_window(MainWindow),NULL);
-    Destroy_Mouse_Cursor();
-}
-
 static void
 et_on_child_exited (GPid pid, gint status, gpointer user_data)
 {
diff --git a/src/misc.h b/src/misc.h
index fd740d0..bc1a10e 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -30,10 +30,6 @@ G_BEGIN_DECLS
 gboolean Add_String_To_Combo_List(GtkListStore *liststore, const gchar *string);
 gchar   *Get_Active_Combo_Box_Item(GtkComboBox *combo);
 
-void Init_Mouse_Cursor    (void);
-void Set_Busy_Cursor      (void);
-void Set_Unbusy_Cursor    (void);
-
 gchar *Convert_Duration (gulong duration);
 
 gboolean et_run_audio_player (GList *files, GError **error);


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