[easytag/wip/application-window: 36/79] Remove local CDDB search function



commit 2dd2fba076cbc72f424094e691877bdcc60cb398
Author: David King <amigadave amigadave com>
Date:   Sat Jun 28 19:11:38 2014 +0100

    Remove local CDDB search function
    
    It is very unlikely that people have a local copy of the CDDB, and the
    settings code for this would be rather awkward.

 README                             |    2 +-
 data/org.gnome.EasyTAG.gschema.xml |   12 ---
 src/cddb_dialog.c                  |  130 +-----------------------------------
 src/preferences_dialog.c           |   58 ----------------
 src/preferences_dialog.h           |    3 -
 src/setting.c                      |   31 ---------
 src/setting.h                      |    2 -
 7 files changed, 2 insertions(+), 236 deletions(-)
---
diff --git a/README b/README
index 287bb36..15c2ac6 100644
--- a/README
+++ b/README
@@ -37,7 +37,7 @@ Currently EasyTAG supports the following:
 * ability to process fields of tag and filename (convert letters into
   upper case, lower case, …)
 * ability to open a directory or a file with an external program
-* remote and local CDDB support for manual or automatic search
+* CDDB support for manual or automatic search
 * a tree based browser or a view by Artist & Album
 * a list to select files
 * a playlist generator window
diff --git a/data/org.gnome.EasyTAG.gschema.xml b/data/org.gnome.EasyTAG.gschema.xml
index 013f646..a4deef3 100644
--- a/data/org.gnome.EasyTAG.gschema.xml
+++ b/data/org.gnome.EasyTAG.gschema.xml
@@ -101,18 +101,6 @@
       <default>true</default>
     </key>
 
-    <key name="cddb-local" type="b">
-      <summary>Use local CDDB</summary>
-      <description>Whether to use a locally-stored copy of the CDDB</description>
-      <default>false</default>
-    </key>
-
-    <key name="cddb-local-path" type="s">
-      <summary>Path to local CDDB</summary>
-      <description>A path to a locally-stored copy of the CDDB</description>
-      <default>''</default>
-    </key>
-
     <key name="cddb-proxy-enabled" type="b">
       <summary>Enable proxy for remote CDDB</summary>
       <description>Whether to access remote CDDB through a proxy</description>
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index 96ce1e1..e50fac6 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -88,7 +88,6 @@ struct _EtCDDBDialogPrivate
 
     GtkWidget *run_scanner_toggle;
     GtkWidget *use_dlm2_toggle; /* '2' as also used in prefs.c */
-    GtkWidget *use_local_access_toggle;
 
     GtkWidget *separator_h;
     GtkWidget *category_toggle[10];
@@ -3003,18 +3002,6 @@ create_cddb_dialog (EtCDDBDialog *self)
     Separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
     gtk_box_pack_start(GTK_BOX(hbox),Separator,FALSE,FALSE,0);
 
-    // Check box to run the scanner
-    priv->use_local_access_toggle = gtk_check_button_new_with_label(_("Use local CDDB"));
-    gtk_box_pack_start(GTK_BOX(hbox),priv->use_local_access_toggle,FALSE,FALSE,0);
-    g_settings_bind (MainSettings, "cddb-local", priv->use_local_access_toggle,
-                     "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text(priv->use_local_access_toggle,_("When activating this option, after loading 
the "
-        "fields, the current selected scanner will be ran (the scanner window must be opened)."));
-
-    // Separator line
-    Separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
-    gtk_box_pack_start(GTK_BOX(hbox),Separator,FALSE,FALSE,0);
-
     /* Button to quit. */
     Button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
     gtk_box_pack_end(GTK_BOX(hbox),Button,FALSE,FALSE,0);
@@ -3817,7 +3804,7 @@ et_cddb_dialog_search_from_selection (EtCDDBDialog *self)
     gchar *proxy_hostname;
     guint proxy_port;
     gint   server_try = 0;
-    gchar *tmp, *valid;
+    gchar *tmp;
     gchar *query_string;
     gchar *cddb_discid;
     gchar *cddb_end_str;
@@ -3948,123 +3935,8 @@ et_cddb_dialog_search_from_selection (EtCDDBDialog *self)
     gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_auto_search_button),TRUE);
 
 
-    if (g_settings_get_boolean (MainSettings, "cddb-local"))
     {
         /*
-         * Local cddb acces
-         */
-        static const gchar *CddbDir[] = // Or use cddb_genre_vs_id3_genre[][2]?
-        {
-            "blues", "classical", "country", "data",   "folk",
-            "jazz",  "misc",      "newage",  "reggae", "rock",
-            "soundtrack"
-        };
-        static const gsize CddbDirSize = G_N_ELEMENTS (CddbDir) - 1;
-        gsize i;
-
-        // We check if the file corresponding to the discid exists in each directory
-        for (i=0; i<=CddbDirSize; i++)
-        {
-            gchar *file_path;
-
-            if (!CDDB_LOCAL_PATH || strlen(CDDB_LOCAL_PATH)==0)
-            {
-                GtkWidget *msgdialog;
-
-                msgdialog = gtk_message_dialog_new(GTK_WINDOW(self),
-                                                   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                   GTK_MESSAGE_ERROR,
-                                                   GTK_BUTTONS_CLOSE,
-                                                   "%s",
-                                                   _("The path for 'Local CD Database' was not defined"));
-                /* Translators: 'it' in this sentence refers to the local CD
-                 * database path. */
-                gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msgdialog), "%s", _("Enter it in 
the preferences window before using this search."));
-                gtk_window_set_title (GTK_WINDOW (msgdialog),
-                                      _("Local CD search"));
-
-                gtk_dialog_run(GTK_DIALOG(msgdialog));
-                gtk_widget_destroy(msgdialog);
-                break;
-            }
-            file_path = g_strconcat(CDDB_LOCAL_PATH,
-                                    CDDB_LOCAL_PATH[strlen(CDDB_LOCAL_PATH)-1]!=G_DIR_SEPARATOR ? 
G_DIR_SEPARATOR_S : "",
-                                    CddbDir[i],"/",cddb_discid,NULL);
-
-            if ( (file=fopen(file_path,"r"))!=0 )
-            {
-                // File found
-                CddbAlbum *cddbalbum;
-                gint rc = 0;
-
-                cddbalbum = g_malloc0(sizeof(CddbAlbum));
-
-                // Parameters of the server used (Local acces => specific!)
-                cddbalbum->server_name     = NULL;                // No server name
-                cddbalbum->server_port     = 0;                   // No server port
-                cddbalbum->server_cgi_path = g_strdup(file_path); /* Filename. */
-                cddbalbum->bitmap          = Cddb_Get_Pixbuf_From_Server_Name(file_path);
-
-                // Get album category
-                cddbalbum->category = Try_To_Validate_Utf8_String(CddbDir[i]);
-
-                // Get album ID
-                cddbalbum->id = Try_To_Validate_Utf8_String(cddb_discid);
-
-                while ( self && !priv->stop_searching
-                && (rc = Cddb_Read_Line(&file,&cddb_out)) > 0 )
-                {
-                    if (!cddb_out) // Empty line?
-                        continue;
-                    //g_print("%s\n",cddb_out);
-
-                    // Get Album and Artist names
-                    if ( strncmp(cddb_out,"DTITLE=",7)==0 )
-                    {
-                        // Note : disc title too long take severals lines. For example :
-                        // DTITLE=Marilyn Manson / The Nobodies (2005 Against All Gods Mix - Korea Tour L
-                        // DTITLE=imited Edition)
-                        if (!cddbalbum->artist_album)
-                        {
-                            // It is the first time we find DTITLE...
-
-                            // Artist and album
-                            cddbalbum->artist_album = Try_To_Validate_Utf8_String(cddb_out+7); // '7' to 
skip 'DTITLE='
-                        }else
-                        {
-                            // It is at least the second time we find DTITLE
-                            // So we suppose that only the album was truncated
-
-                            // Album
-                            valid = Try_To_Validate_Utf8_String(cddb_out+7); // '7' to skip 'DTITLE='
-                            tmp = cddbalbum->artist_album; // To free...
-                            cddbalbum->artist_album = g_strconcat(cddbalbum->artist_album,valid,NULL);
-                            g_free(tmp);
-
-                            // Don't need to read more data to read in the file
-                            break;
-                        }
-                    }
-
-                    g_free(cddb_out);
-                }
-
-                priv->album_list = g_list_append(priv->album_list,cddbalbum);
-
-                // Need to close it, if not done in Cddb_Read_Line
-                if (file)
-                    fclose(file);
-                file = NULL;
-            }
-            g_free(file_path);
-
-        }
-
-
-    }else
-    {
-
-        /*
          * Remote cddb acces
          *
          * Request the two servers
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 5e89513..d581fa0 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -52,7 +52,6 @@ static const guint BOX_SPACING = 6;
 
 struct _EtPreferencesDialogPrivate
 {
-    GtkListStore *cddb_local_path_model;
     GtkListStore *default_path_model;
     GtkListStore *file_player_model;
 
@@ -95,7 +94,6 @@ static void et_prefs_on_pad_disc_number_spinbutton_changed (GtkWidget *label,
                                                             GtkWidget *spinbutton);
 
 static void Change_Id3_Settings_Toggled (GtkWidget *blah, EtPreferencesDialog *self);
-static void CddbLocalPath_Combo_Add_String (void);
 
 static void et_preferences_on_response (GtkDialog *dialog, gint response_id,
                                         gpointer user_data);
@@ -1498,51 +1496,6 @@ create_preferences_dialog (EtPreferencesDialog *self)
                      CddbServerCgiPathManualSearch, "text",
                      G_SETTINGS_BIND_DEFAULT);
 
-    /* Local access for CDDB (Automatic Search). */
-    Frame = gtk_frame_new (_("Local CDDB"));
-    gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
-    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BOX_SPACING);
-    gtk_container_add(GTK_CONTAINER(Frame),vbox);
-    gtk_container_set_border_width (GTK_CONTAINER (vbox), BOX_SPACING);
-
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
-    gtk_container_add(GTK_CONTAINER(vbox),hbox);
-    Label = gtk_label_new(_("Path:"));
-    gtk_box_pack_start(GTK_BOX(hbox),Label,FALSE,FALSE,2);
-
-    priv->cddb_local_path_model = gtk_list_store_new (MISC_COMBO_COUNT,
-                                                      G_TYPE_STRING);
-
-    CddbLocalPath = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->cddb_local_path_model));
-    g_object_unref (priv->cddb_local_path_model);
-    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(CddbLocalPath),MISC_COMBO_TEXT);
-    gtk_box_pack_start(GTK_BOX(hbox),CddbLocalPath,FALSE,FALSE,0);
-    gtk_widget_set_size_request(GTK_WIDGET(CddbLocalPath), 450, -1);
-    gtk_widget_set_tooltip_text(gtk_bin_get_child(GTK_BIN(CddbLocalPath)),_("Specify the directory "
-        "where the local CD database is located. The local CD database contains the eleven following "
-        "directories 'blues', 'classical', 'country', 'data', 'folk', 'jazz', 'newage', 'reggae', "
-        "'rock', 'soundtrack' and 'misc'."));
-    
g_signal_connect(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(CddbLocalPath)))),"activate",G_CALLBACK(CddbLocalPath_Combo_Add_String),NULL);
-    
//g_signal_connect(G_OBJECT(GTK_ENTRY(GTK_BIN(CddbLocalPath)->child)),"focus_out_event",G_CALLBACK(CddbLocalPath_Combo_Add_String),NULL);
-
-    // History list
-    Load_Cddb_Local_Path_List(priv->cddb_local_path_model, MISC_COMBO_TEXT);
-
-    // If default path hasn't been added already, add it now..
-    if (CDDB_LOCAL_PATH)
-    {
-        gchar *path_utf8 = filename_to_display (CDDB_LOCAL_PATH);
-        Add_String_To_Combo_List(priv->cddb_local_path_model, path_utf8);
-        if (path_utf8)
-            gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(CddbLocalPath))), path_utf8);
-        g_free(path_utf8);
-    }
-
-    Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
-    gtk_box_pack_start(GTK_BOX(hbox),Button,FALSE,FALSE,0);
-    g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-                             
G_CALLBACK(File_Selection_Window_For_Directory),G_OBJECT(gtk_bin_get_child(GTK_BIN(CddbLocalPath))));
-
     // CDDB Proxy Settings
     Frame = gtk_frame_new (_("Proxy Settings"));
     gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
@@ -2017,7 +1970,6 @@ OptionsWindow_Save_Button (EtPreferencesDialog *self)
 #ifndef G_OS_WIN32
     /* FIXME : make gtk crash on win32 */
     Add_String_To_Combo_List(priv->file_player_model,       
gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(FilePlayerCombo)))));
-    Add_String_To_Combo_List(priv->cddb_local_path_model,    
gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(CddbLocalPath)))));
 #endif /* !G_OS_WIN32 */
 
     Save_Changes_Of_Preferences_Window();
@@ -2048,7 +2000,6 @@ et_preferences_dialog_apply_changes (EtPreferencesDialog *self)
 
     /* Save combobox history lists before exit */
     Save_Audio_File_Player_List (priv->file_player_model, MISC_COMBO_TEXT);
-    Save_Cddb_Local_Path_List (priv->cddb_local_path_model, MISC_COMBO_TEXT);
 }
 
 void
@@ -2065,15 +2016,6 @@ et_preferences_dialog_show_scanner (EtPreferencesDialog *self)
     gtk_window_present (GTK_WINDOW (self));
 }
 
-static void
-CddbLocalPath_Combo_Add_String (void)
-{
-    const gchar *path;
-
-    path = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(CddbLocalPath))));
-    Add_String_To_Combo_List(GTK_LIST_STORE(CddbLocalPath), path);
-}
-
 /*
  * et_preferences_on_response:
  * @dialog: the dialog which trigerred the response signal
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
index 705d681..f6f7863 100644
--- a/src/preferences_dialog.h
+++ b/src/preferences_dialog.h
@@ -56,7 +56,4 @@ G_END_DECLS
 /* Misc */
 GtkWidget *FilePlayerCombo;
 
-/* CDDB */
-GtkWidget *CddbLocalPath;
-
 #endif /* ET_PREFERENCES_DIALOG_H_ */
diff --git a/src/setting.c b/src/setting.c
index 0f95672..2896deb 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -84,8 +84,6 @@ static const gchar FILE_TO_LOAD_HISTORY_FILE[] = "file_to_load.history";
 static const gchar CDDB_SEARCH_STRING_HISTORY_FILE[] = "cddb_search_string.history";
 // File for history of CddbSearchStringInResultEntry combobox
 static const gchar CDDB_SEARCH_STRING_IN_RESULT_HISTORY_FILE[] = "cddb_search_string_in_result.history";
-// File for history of CddbLocalPath combobox
-static const gchar CDDB_LOCAL_PATH_HISTORY_FILE[] = "cddb_local_path.history";
 
 
 
@@ -106,8 +104,6 @@ static const tConfigVariable Config_Variables[] =
 
     {"audio_file_player",                       CV_TYPE_STRING,&AUDIO_FILE_PLAYER                        },
 
-    {"cddb_local_path",                         CV_TYPE_STRING,  &CDDB_LOCAL_PATH                        },
-
     {"scan_tag_default_mask",                   CV_TYPE_STRING,  &SCAN_TAG_DEFAULT_MASK                  },
     {"rename_file_default_mask",                CV_TYPE_STRING,  &RENAME_FILE_DEFAULT_MASK               },
     {"rename_directory_default_mask",           CV_TYPE_STRING,  &RENAME_DIRECTORY_DEFAULT_MASK          },
@@ -162,11 +158,6 @@ void Init_Config_Variables (void)
 #endif /* !G_OS_WIN32 */
 
     /*
-     * CDDB window
-     */
-    CDDB_LOCAL_PATH                         = NULL;
-
-    /*
      * Masks
      */
     SCAN_TAG_DEFAULT_MASK           = NULL;
@@ -201,10 +192,6 @@ Apply_Changes_Of_Preferences_Window (void)
         g_settings_set_boolean (MainSettings, "id3v2-version-4", TRUE);
 #endif
 
-        /* CDDB */
-        if (CDDB_LOCAL_PATH) g_free(CDDB_LOCAL_PATH);
-        CDDB_LOCAL_PATH = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(CddbLocalPath)))));
-
         /* Parameters and variables of Scanner Window are in "scan.c" file */
         /* Parameters and variables of Cddb Window are in "cddb.c" file */
     }
@@ -522,7 +509,6 @@ gboolean Setting_Create_Files (void)
     check_or_create_file (FILE_TO_LOAD_HISTORY_FILE);
     check_or_create_file (CDDB_SEARCH_STRING_HISTORY_FILE);
     check_or_create_file (CDDB_SEARCH_STRING_IN_RESULT_HISTORY_FILE);
-    check_or_create_file (CDDB_LOCAL_PATH_HISTORY_FILE);
 
     return TRUE;
 }
@@ -820,22 +806,6 @@ void Save_Cddb_Search_String_In_Result_List (GtkListStore *liststore, gint colnu
 }
 
 /*
- * Functions for writing and reading list of 'CddbLocalPath3' combobox
- */
-void Load_Cddb_Local_Path_List (GtkListStore *liststore, gint colnum)
-{
-    Populate_List_Store_From_File(CDDB_LOCAL_PATH_HISTORY_FILE, liststore, colnum);
-}
-void Save_Cddb_Local_Path_List (GtkListStore *liststore, gint colnum)
-{
-    Save_List_Store_To_File(CDDB_LOCAL_PATH_HISTORY_FILE, liststore, colnum);
-}
-
-
-
-
-
-/*
  * migrate_config_to_xdg_dir:
  * @old_path: (type filename): the path to migrate from
  * @new_path: (type filename): the path to migrate to
@@ -859,7 +829,6 @@ migrate_config_file_dir (const gchar *old_path, const gchar *new_path)
                                         FILE_TO_LOAD_HISTORY_FILE,
                                         CDDB_SEARCH_STRING_HISTORY_FILE,
                                         CDDB_SEARCH_STRING_IN_RESULT_HISTORY_FILE,
-                                        CDDB_LOCAL_PATH_HISTORY_FILE,
                                         NULL
     };
 
diff --git a/src/setting.h b/src/setting.h
index 63b873f..c891d1a 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -260,8 +260,6 @@ GSettings *MainSettings;
 /* Misc */
 gchar  *AUDIO_FILE_PLAYER;
 
-gchar  *CDDB_LOCAL_PATH;
-
 /* Default mask */
 gchar  *SCAN_TAG_DEFAULT_MASK;
 gchar  *RENAME_FILE_DEFAULT_MASK;


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