Skip to content

Commit a61cd42

Browse files
fix #1098
hide unused module categories in sidebar mod.list and mod.mgr install + maintenance. also update main window module lists every time install/remove occurs.
1 parent 3ad055e commit a61cd42

File tree

4 files changed

+218
-102
lines changed

4 files changed

+218
-102
lines changed

src/backend/module_manager.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ MOD_MGR *backend_module_mgr_get_next_module(void)
227227
(category &&
228228
!strcmp(category, "Cults / Unorthodox / Questionable Material"));
229229

230+
char *prayerlist = (char *)module->getConfigEntry("GSType");
231+
mod_info->is_prayerlist = (prayerlist && !strcmp(prayerlist, "PrayerList"));
232+
230233
mod_info->old_version =
231234
backend_mod_mgr_get_config_entry(name, "Version");
232235
mod_info->installed =

src/gtk/mod_mgr.c

Lines changed: 92 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ static gboolean local;
162162
static const gchar *source;
163163
static const gchar *destination;
164164
static gboolean have_configs;
165-
static gboolean have_changes;
166165
static gint current_page;
167166
static GdkPixbuf *INSTALLED;
168167
static GdkPixbuf *FASTICON;
@@ -1005,7 +1004,10 @@ static void remove_install_modules(GList *modules, int activity)
10051004
tmp = g_list_next(tmp);
10061005
}
10071006
current_mod = NULL;
1008-
have_changes = TRUE;
1007+
if (!first_time_user) {
1008+
main_update_module_lists();
1009+
main_load_module_tree(sidebar.module_list);
1010+
}
10091011
g_list_free(modules);
10101012

10111013
if (result) {
@@ -1428,23 +1430,36 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
14281430
GtkTreeIter repository_name;
14291431
GtkTreeIter category_type;
14301432
GtkTreeIter category_avail;
1433+
14311434
GtkTreeIter text;
1435+
gboolean need_text = 0;
14321436
GtkTreeIter commentary;
1437+
gboolean need_commentary = 0;
14331438
GtkTreeIter dictionary;
1439+
gboolean need_dictionary = 0;
14341440
GtkTreeIter devotional;
1441+
gboolean need_devotional = 0;
14351442
GtkTreeIter book;
1443+
gboolean need_book = 0;
14361444
GtkTreeIter map;
1445+
gboolean need_map = 0;
14371446
GtkTreeIter image;
1447+
gboolean need_image = 0;
14381448
GtkTreeIter cult;
1449+
gboolean need_cult = 0;
14391450
GtkTreeIter glossary;
1451+
gboolean need_glossary = 0;
1452+
GtkTreeIter prayerlist;
1453+
gboolean need_prayerlist = 0;
1454+
14401455
GtkTreeIter separator;
14411456
GtkTreeIter update;
14421457
GtkTreeIter uninstalled;
1443-
GtkTreeIter prayerlist;
14441458
GtkTreeIter unindexed;
1459+
gboolean first_unindexed = FALSE;
1460+
14451461
GList *tmp = NULL;
14461462
GList *tmp2 = NULL;
1447-
gboolean first_unindexed = FALSE;
14481463

14491464
if (install) {
14501465
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_source))) {
@@ -1491,6 +1506,37 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
14911506
// true -> we must have all modules available, incl. ~/.sword content.
14921507
}
14931508

1509+
// find which folders are needed.
1510+
tmp2 = tmp;
1511+
while (tmp2) {
1512+
MOD_MGR *info = (MOD_MGR *)tmp2->data;
1513+
if (info->is_cult)
1514+
need_cult++;
1515+
else if (info->type[0] == 'B')
1516+
need_text++;
1517+
else if (info->type[0] == 'C')
1518+
need_commentary++;
1519+
else if (info->is_maps)
1520+
need_map++;
1521+
else if (info->is_images)
1522+
need_image++;
1523+
else if (info->is_devotional)
1524+
need_devotional++;
1525+
else if (info->is_glossary)
1526+
need_glossary++;
1527+
else if (info->type[0] == 'L')
1528+
need_dictionary++;
1529+
else if (info->is_prayerlist)
1530+
need_prayerlist++;
1531+
else if (info->type[0] == 'G')
1532+
need_book++;
1533+
else {
1534+
XI_warning(("mod `%s' unknown type `%s'",
1535+
info->name, info->type));
1536+
}
1537+
tmp2 = g_list_next(tmp2);
1538+
}
1539+
14941540
gtk_tree_view_set_model(treeview, NULL);
14951541
store = GTK_TREE_STORE(create_model());
14961542
gtk_tree_store_clear(store);
@@ -1526,42 +1572,61 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
15261572
_("Categorized by\nModule Type"), -1);
15271573
}
15281574

1575+
/* add only those folders actually represented. */
1576+
15291577
/* add Biblical Texts folder */
1530-
gtk_tree_store_append(store, &text, NULL);
1531-
gtk_tree_store_set(store, &text, 0, _("Biblical Texts"), -1);
1578+
if (need_text) {
1579+
gtk_tree_store_append(store, &text, NULL);
1580+
gtk_tree_store_set(store, &text, 0, _("Biblical Texts"), -1);
1581+
}
15321582

15331583
/* add Commentaries folder */
1534-
gtk_tree_store_append(store, &commentary, NULL);
1535-
gtk_tree_store_set(store, &commentary, 0, _("Commentaries"), -1);
1584+
if (need_commentary) {
1585+
gtk_tree_store_append(store, &commentary, NULL);
1586+
gtk_tree_store_set(store, &commentary, 0, _("Commentaries"), -1);
1587+
}
15361588

15371589
/* add Dictionaries folder */
1538-
gtk_tree_store_append(store, &dictionary, NULL);
1539-
gtk_tree_store_set(store, &dictionary, 0, _("Dictionaries"), -1);
1590+
if (need_dictionary) {
1591+
gtk_tree_store_append(store, &dictionary, NULL);
1592+
gtk_tree_store_set(store, &dictionary, 0, _("Dictionaries"), -1);
1593+
}
15401594

15411595
/* add Glossaries folder */
1542-
gtk_tree_store_append(store, &glossary, NULL);
1543-
gtk_tree_store_set(store, &glossary, 0, _("Glossaries"), -1);
1596+
if (need_glossary) {
1597+
gtk_tree_store_append(store, &glossary, NULL);
1598+
gtk_tree_store_set(store, &glossary, 0, _("Glossaries"), -1);
1599+
}
15441600

15451601
/* add Devotionals folder */
1546-
gtk_tree_store_append(store, &devotional, NULL);
1547-
gtk_tree_store_set(store, &devotional, 0, _("Daily Devotionals"),
1548-
-1);
1602+
if (need_devotional) {
1603+
gtk_tree_store_append(store, &devotional, NULL);
1604+
gtk_tree_store_set(store, &devotional, 0, _("Daily Devotionals"), -1);
1605+
}
15491606

15501607
/* add Books folder */
1551-
gtk_tree_store_append(store, &book, NULL);
1552-
gtk_tree_store_set(store, &book, 0, _("General Books"), -1);
1608+
if (need_book) {
1609+
gtk_tree_store_append(store, &book, NULL);
1610+
gtk_tree_store_set(store, &book, 0, _("General Books"), -1);
1611+
}
15531612

15541613
/* add Maps folder */
1555-
gtk_tree_store_append(store, &map, NULL);
1556-
gtk_tree_store_set(store, &map, 0, _("Maps"), -1);
1614+
if (need_map) {
1615+
gtk_tree_store_append(store, &map, NULL);
1616+
gtk_tree_store_set(store, &map, 0, _("Maps"), -1);
1617+
}
15571618

15581619
/* add Images folder */
1559-
gtk_tree_store_append(store, &image, NULL);
1560-
gtk_tree_store_set(store, &image, 0, _("Images"), -1);
1620+
if (need_image) {
1621+
gtk_tree_store_append(store, &image, NULL);
1622+
gtk_tree_store_set(store, &image, 0, _("Images"), -1);
1623+
}
15611624

15621625
/* add Cult folder */
1563-
gtk_tree_store_append(store, &cult, NULL);
1564-
gtk_tree_store_set(store, &cult, 0, _("Cult/Unorthodox"), -1);
1626+
if (need_cult) {
1627+
gtk_tree_store_append(store, &cult, NULL);
1628+
gtk_tree_store_set(store, &cult, 0, _("Cult/Unorthodox"), -1);
1629+
}
15651630

15661631
if (install && !first_time_user) {
15671632
gtk_tree_store_append(store, &separator, NULL);
@@ -1581,7 +1646,8 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
15811646
gtk_tree_store_set(store, &uninstalled, 0,
15821647
_("Uninstalled"), -1);
15831648
} else {
1584-
if (settings.prayerlist) {
1649+
/* add Journal/PrayerList folder */
1650+
if (settings.prayerlist && need_prayerlist) {
15851651
gtk_tree_store_append(store, &prayerlist, NULL);
15861652
gtk_tree_store_set(store, &prayerlist, 0,
15871653
_("Prayer List/Journal"), -1);
@@ -1649,15 +1715,10 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
16491715
GTK_TREE_MODEL(store), dictionary,
16501716
info, install);
16511717
} else if (info->type[0] == 'G') {
1652-
gchar *gstype;
1653-
if (first_time_user ||
1654-
((gstype =
1655-
main_get_mod_config_entry(info->name,
1656-
"GSType")) == NULL) ||
1657-
strcmp(gstype, "PrayerList")) {
1718+
if (first_time_user || !info->is_prayerlist) {
16581719
add_module_to_language_folder(treeview, GTK_TREE_MODEL(store), book,
16591720
info, install);
1660-
} else if (settings.prayerlist) {
1721+
} else if (settings.prayerlist && need_prayerlist) {
16611722
add_language_folder(GTK_TREE_MODEL(store), prayerlist,
16621723
info->language);
16631724
add_module_to_language_folder(treeview,
@@ -2467,10 +2528,6 @@ static void on_dialog_destroy(GObject *object, gpointer user_data)
24672528

24682529
mod_mgr_shut_down();
24692530
sync_windows();
2470-
if (have_changes && !first_time_user) {
2471-
main_update_module_lists();
2472-
main_load_module_tree(sidebar.module_list);
2473-
}
24742531

24752532
/* little bits of nonsense left behind by the engine. */
24762533
str = g_strdup_printf("%s/dirlist", settings.homedir);
@@ -3364,7 +3421,6 @@ static void setup_ui_labels()
33643421
{
33653422
gchar *str;
33663423

3367-
have_changes = FALSE;
33683424
str = g_strdup_printf("%s/%s", settings.homedir,
33693425
DOTSWORD "/InstallMgr/InstallMgr.conf");
33703426
if (!mod_mgr_check_for_file(str)) {

src/main/mod_mgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct _mm
4949
int is_images;
5050
int is_glossary;
5151
int is_cult;
52+
int is_prayerlist;
5253
int locked;
5354
char *installsize;
5455
char *about;

0 commit comments

Comments
 (0)