diff --git a/ChangeLog b/ChangeLog index 47bcc9e..2103db3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ Change Log ========== +## 0.2.2 (2021-05-07) + +Changes: + +* Code review + + ## 0.2.1 (2021-05-03) Changes: diff --git a/configure.ac b/configure.ac index 709e748..c92ee54 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ dnl *************************************************************************** AC_PREREQ([2.69]) AC_INIT([Nautilus Hide], - [0.2.1], + [0.2.2], [madmurphy333@gmail.com], [nautilus-hide], [https://gitlab.gnome.org/madmurphy/nautilus-hide]) diff --git a/package.json b/package.json index d282d9f..d1ebc8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nautilus-hide", - "version": "0.2.1", + "version": "0.2.2", "description": "A simple Nautilus extension that adds \"Hide\" and \"Unhide\" to Nautilus right-click menu", "homepage": "https://gitlab.gnome.org/madmurphy/nautilus-hide", "author": "madmurphy333@gmail.com", @@ -25,8 +25,13 @@ "email" : "madmurphy333@gmail.com" }, "keywords": [ - "c", + "desktop", + "desktop-environment", + "dotfiles", + "hidden-files", "gnome", + "gnu", + "gnu-linux", "nautilus", "nautilus-extension" ] diff --git a/po/it.po b/po/it.po index 82f3ab2..e218c70 100644 --- a/po/it.po +++ b/po/it.po @@ -5,10 +5,10 @@ # msgid "" msgstr "" -"Project-Id-Version: 0.2.1\n" +"Project-Id-Version: 0.2.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-02 23:17+0200\n" -"PO-Revision-Date: 2021-05-02 23:17+0200\n" +"POT-Creation-Date: 2021-05-07 14:09+0200\n" +"PO-Revision-Date: 2021-05-07 14:09+0200\n" "Last-Translator: FULL NAME \n" "Language-Team: Italian \n" "Language: it\n" @@ -17,41 +17,41 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: ../src/nautilus-hide.c:105 +#: ../src/nautilus-hide.c:106 msgid "Could not close the database of hidden files" msgstr "Impossibile chiudere il database dei file nascosti" -#: ../src/nautilus-hide.c:125 ../src/nautilus-hide.c:142 -#: ../src/nautilus-hide.c:156 ../src/nautilus-hide.c:249 -#: ../src/nautilus-hide.c:302 +#: ../src/nautilus-hide.c:126 ../src/nautilus-hide.c:144 +#: ../src/nautilus-hide.c:159 ../src/nautilus-hide.c:258 +#: ../src/nautilus-hide.c:312 msgid "Error allocating memory" msgstr "Errore nell'allocare memoria" -#: ../src/nautilus-hide.c:207 +#: ../src/nautilus-hide.c:213 msgid "Error attempting to access the database of hidden files" msgstr "Impossibile accedere al database dei file nascosti" -#: ../src/nautilus-hide.c:221 +#: ../src/nautilus-hide.c:228 msgid "Could not calculate the size of the database of hidden files" msgstr "Impossibile calcolare le dimensioni del database dei file nascosti" -#: ../src/nautilus-hide.c:234 +#: ../src/nautilus-hide.c:242 msgid "Database of hidden files is too big" msgstr "Il database dei file nascosti è troppo grande" -#: ../src/nautilus-hide.c:263 +#: ../src/nautilus-hide.c:273 msgid "I/O error while accessing database of hidden files" msgstr "Errore I/O nell'accedere al database dei file nascosti" -#: ../src/nautilus-hide.c:356 +#: ../src/nautilus-hide.c:375 msgid "Could not get file path" msgstr "Impossibile ottenere la posizione del file" -#: ../src/nautilus-hide.c:438 +#: ../src/nautilus-hide.c:459 msgid "No files have been selected to be hidden" msgstr "Non ci sono file selezionati da nascondere" -#: ../src/nautilus-hide.c:453 +#: ../src/nautilus-hide.c:475 msgid "" "Could not hide the selected files, error attempting to group them according " "to their parent directories" @@ -59,18 +59,18 @@ msgstr "" "Impossibile nascondere i file selezionati, errore nel tentativo di " "raggrupparli in base alla loro directory di appartenenza" -#: ../src/nautilus-hide.c:481 +#: ../src/nautilus-hide.c:504 msgid "" "Could not hide the selected files, error attempting to edit the database" msgstr "" "Impossibile nascondere i file selezionati, errore nel tentativo di " "modificare il database" -#: ../src/nautilus-hide.c:607 +#: ../src/nautilus-hide.c:632 msgid "No files have been selected to be unhidden" msgstr "Non ci sono file selezionati da rendere visibili" -#: ../src/nautilus-hide.c:622 +#: ../src/nautilus-hide.c:648 msgid "" "Could not unhide the selected files, error attempting to group them " "according to their parent directories" @@ -78,32 +78,32 @@ msgstr "" "Impossibile rendere visibili i file selezionati, errore nel tentativo di " "raggrupparli in base alla loro directory di appartenenza" -#: ../src/nautilus-hide.c:662 +#: ../src/nautilus-hide.c:689 msgid "" "Could not unhide the selected files, error attempting to edit the database" msgstr "" "Impossibile rendere visibili i file selezionati, errore nel tentativo di " "modificare il database" -#: ../src/nautilus-hide.c:920 +#: ../src/nautilus-hide.c:948 msgid "_Hide file" msgid_plural "_Hide files" msgstr[0] "_Nascondi" msgstr[1] "_Nascondi i file" -#: ../src/nautilus-hide.c:926 +#: ../src/nautilus-hide.c:954 msgid "Hide the selected file" msgid_plural "Hide the selected files" msgstr[0] "Nascondi il file selezionato" msgstr[1] "Nascondi i file selezionati" -#: ../src/nautilus-hide.c:959 +#: ../src/nautilus-hide.c:987 msgid "_Unhide file" msgid_plural "_Unhide files" msgstr[0] "Ripristina _visibilità" msgstr[1] "Ripristina _visibilità dei file" -#: ../src/nautilus-hide.c:965 +#: ../src/nautilus-hide.c:993 msgid "Unhide the selected file" msgid_plural "Unhide the selected files" msgstr[0] "Rendi visibile il file selezionato" diff --git a/src/nautilus-hide.c b/src/nautilus-hide.c index ab54a54..88d70db 100644 --- a/src/nautilus-hide.c +++ b/src/nautilus-hide.c @@ -1,4 +1,5 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* Please make sure that the TAB width in your editor is set to 4 spaces */ /*\ |*| @@ -8,12 +9,12 @@ |*| |*| Copyright (C) 2021 |*| -|*| nautilus-hide 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 3 of the License, or (at your option) -|*| any later version. +|*| **Nautilus Hide** 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 3 of the License, or (at your +|*| option) any later version. |*| -|*| nautilus-hide is distributed in the hope that it will be useful, but +|*| **Nautilus Hide** 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. @@ -124,6 +125,7 @@ static ssofwcp * ssofwcp_new_with_dir ( "Nautilus Hide: %s (ENOMEM ID: k75zc4j)\n", _("Error allocating memory") ); + return NULL; } @@ -141,6 +143,7 @@ static ssofwcp * ssofwcp_new_with_dir ( "Nautilus Hide: %s (ENOMEM ID: nkyd8w8)\n", _("Error allocating memory") ); + free(new_ssofwcp); return NULL; @@ -155,6 +158,7 @@ static ssofwcp * ssofwcp_new_with_dir ( "Nautilus Hide: %s (ENOMEM ID: bo9axpr)\n", _("Error allocating memory") ); + free(new_ssofwcp->directory); free(new_ssofwcp); return NULL; @@ -163,11 +167,13 @@ static ssofwcp * ssofwcp_new_with_dir ( memcpy(new_ssofwcp->directory, dpath, dp_len + 1); memcpy(new_ssofwcp->hdb_path, dpath, dp_len); + memcpy( new_ssofwcp->hdb_path + dp_len + 1, hidden_db_fname, sizeof(hidden_db_fname) ); + new_ssofwcp->hdb_path[dp_len] = '/'; new_ssofwcp->hdb_access = ( @@ -207,6 +213,7 @@ static ssofwcp * ssofwcp_new_with_dir ( _("Error attempting to access the database of hidden files"), new_ssofwcp->hdb_path ); + return new_ssofwcp; } @@ -221,6 +228,7 @@ static ssofwcp * ssofwcp_new_with_dir ( _("Could not calculate the size of the database of hidden files"), new_ssofwcp->hdb_path ); + close_hdb_file(hdb_file, new_ssofwcp->hdb_path); return new_ssofwcp; @@ -234,6 +242,7 @@ static ssofwcp * ssofwcp_new_with_dir ( _("Database of hidden files is too big"), new_ssofwcp->hdb_path ); + close_hdb_file(hdb_file, new_ssofwcp->hdb_path); return new_ssofwcp; @@ -248,6 +257,7 @@ static ssofwcp * ssofwcp_new_with_dir ( "Nautilus Hide: %s (ENOMEM ID: kmh80ll)\n", _("Error allocating memory") ); + close_hdb_file(hdb_file, new_ssofwcp->hdb_path); return new_ssofwcp; @@ -263,6 +273,7 @@ static ssofwcp * ssofwcp_new_with_dir ( _("I/O error while accessing database of hidden files"), new_ssofwcp->hdb_path ); + free(cache); close_hdb_file(hdb_file, new_ssofwcp->hdb_path); return new_ssofwcp; @@ -278,8 +289,6 @@ static ssofwcp * ssofwcp_new_with_dir ( if (cache[idx] == '\n') { - cache[idx] = '\0'; - if (line_start != idx) { fileno++; @@ -287,6 +296,7 @@ static ssofwcp * ssofwcp_new_with_dir ( } line_start = idx + 1; + cache[idx] = '\0'; } @@ -301,6 +311,7 @@ static ssofwcp * ssofwcp_new_with_dir ( "Nautilus Hide: %s (ENOMEM ID: fk9c9sj)\n", _("Error allocating memory") ); + free(cache); return new_ssofwcp; @@ -338,16 +349,24 @@ static GList * ordered_file_selection_new ( GList * const file_selection ) { + char * dpath; + GFile * location; GList * ordered_selection = NULL; ssofwcp * new_ssofwcp; - char * dpath; - for (GList * d_iter, * s_iter = file_selection; s_iter; s_iter = s_iter->next) { + for ( + GList * d_iter, * s_iter = file_selection; + s_iter; + s_iter = s_iter->next + ) { - dpath = g_file_get_path( - nautilus_file_info_get_parent_location(NAUTILUS_FILE_INFO(s_iter->data)) + location = nautilus_file_info_get_parent_location( + NAUTILUS_FILE_INFO(s_iter->data) ); + dpath = g_file_get_path(location); + g_object_unref(location); + if (!dpath) { fprintf( @@ -355,6 +374,7 @@ static GList * ordered_file_selection_new ( "Nautilus Hide: %s\n", _("Could not get file path") ); + return NULL; } @@ -365,12 +385,13 @@ static GList * ordered_file_selection_new ( if (!strcmp(subselection->directory, dpath)) { - /* The parent directory of this file has already been indicized */ + /* The parent directory of this file was already indicized */ subselection->selection = g_list_prepend( subselection->selection, s_iter->data ); + goto free_and_continue; } @@ -426,8 +447,8 @@ static void nautilus_hide_push_files ( ) { GList * const file_selection = g_object_get_data( - (GObject *) menu_item, - "nautilus_hide_files" + G_OBJECT(menu_item), + "nautilus_hide_files" ); if (!file_selection) { @@ -437,6 +458,7 @@ static void nautilus_hide_push_files ( "Nautilus Hide: %s\n", _("No files have been selected to be hidden") ); + return; } @@ -454,6 +476,7 @@ static void nautilus_hide_push_files ( "to group them according to their parent directories" ) ); + return; } @@ -483,6 +506,7 @@ static void nautilus_hide_push_files ( ), subselection->hdb_path ); + continue; } @@ -533,6 +557,7 @@ static void nautilus_hide_push_files ( strlen(subselection->hdb_entries[idx]), hdb_file_w ); + fputc('\n', hdb_file_w); } @@ -595,7 +620,7 @@ static void nautilus_hide_pop_files ( ) { GList * const file_selection = g_object_get_data( - (GObject *) menu_item, + G_OBJECT(menu_item), "nautilus_hide_files" ); @@ -606,6 +631,7 @@ static void nautilus_hide_pop_files ( "Nautilus Hide: %s\n", _("No files have been selected to be unhidden") ); + return; } @@ -623,6 +649,7 @@ static void nautilus_hide_pop_files ( "to group them according to their parent directories" ) ); + return; } @@ -664,6 +691,7 @@ static void nautilus_hide_pop_files ( ), subselection->hdb_path ); + continue; } @@ -720,9 +748,9 @@ static void nautilus_hide_pop_files ( 1, strlen(subselection->hdb_entries[idx]), hdb_file_w ); + fputc('\n', hdb_file_w); b_keep_hdb_file = true; - idx++; goto check_member; @@ -938,7 +966,7 @@ static GList * nautilus_hide_get_file_items ( ); g_object_set_data_full( - (GObject *) menu_item, + G_OBJECT(menu_item), "nautilus_hide_files", nautilus_file_info_list_copy(file_selection), (GDestroyNotify) nautilus_file_info_list_free @@ -977,7 +1005,7 @@ static GList * nautilus_hide_get_file_items ( ); g_object_set_data_full( - (GObject *) menu_item, + G_OBJECT(menu_item), "nautilus_hide_files", nautilus_file_info_list_copy(file_selection), (GDestroyNotify) nautilus_file_info_list_free @@ -1026,7 +1054,7 @@ static void nautilus_hide_register_type ( sizeof(NautilusHide), 0, (GInstanceInitFunc) NULL, - (GTypeValueTable * ) NULL + (GTypeValueTable *) NULL }; static const GInterfaceInfo menu_provider_iface_info = {