0.8.11claws11
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 13 Mar 2003 21:21:39 +0000 (21:21 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 13 Mar 2003 21:21:39 +0000 (21:21 +0000)
* src/folder.[ch]
* src/foldersel.c
* src/folderview.c
* src/imap.c
* src/mbox_folder.c
* src/mh.c
* src/news.c
* src/prefs_scoring.c
* src/summaryview.c
        use a common function to get a displayable name
        for a FolderItem

12 files changed:
ChangeLog.claws
configure.ac
src/folder.c
src/folder.h
src/foldersel.c
src/folderview.c
src/imap.c
src/mbox_folder.c
src/mh.c
src/news.c
src/prefs_scoring.c
src/summaryview.c

index 047ddd4..b37d151 100644 (file)
@@ -1,3 +1,17 @@
+2003-03-13 [christoph] 0.8.11claws11
+
+       * src/folder.[ch]
+       * src/foldersel.c
+       * src/folderview.c
+       * src/imap.c
+       * src/mbox_folder.c
+       * src/mh.c
+       * src/news.c
+       * src/prefs_scoring.c
+       * src/summaryview.c
+               use a common function to get a displayable name
+               for a FolderItem
+
 2003-03-13 [paul]      0.8.11claws10
 
        * tools/Makefile.am
index 2a30b85..a262f43 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws10
+EXTRA_VERSION=claws11
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index afa143d..208dd72 100644 (file)
@@ -662,6 +662,71 @@ FolderItem *folder_find_item_from_identifier(const gchar *identifier)
        return d[1];
 }
 
+/**
+ * Get a displayable name for a FolderItem
+ *
+ * \param item FolderItem for that a name should be created
+ * \return Displayable name for item, returned string has to
+ *         be freed
+ */
+gchar *folder_item_get_name(FolderItem *item)
+{
+       gchar *name = NULL;
+
+       switch (item->stype) {
+       case F_INBOX:
+               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+                               !strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
+                               item->name);
+               break;
+       case F_OUTBOX:
+               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+                               !strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
+                               item->name);
+               break;
+       case F_QUEUE:
+               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+                               !strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
+                               item->name);
+               break;
+       case F_TRASH:
+               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+                               !strcmp2(item->name, TRASH_DIR) ? _("Trash") :
+                               item->name);
+               break;
+       case F_DRAFT:
+               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+                               !strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
+                               item->name);
+               break;
+       default:
+               break;
+       }
+
+       if (name == NULL) {
+               /*
+                * should probably be done by a virtual function,
+                * the folder knows the ui string and how to abbrev
+               */
+               if (!item->parent) {
+                       name = g_strconcat(item->name, " (", item->folder->class->uistr, ")", NULL);
+               } else {
+                       if (FOLDER_CLASS(item->folder) == news_get_class() &&
+                           item->path && !strcmp2(item->name, item->path))
+                               name = get_abbrev_newsgroup_name
+                                       (item->path,
+                                        prefs_common.ng_abbrev_len);
+                       else
+                               name = g_strdup(item->name);
+               }
+       }
+
+       if (name == NULL)
+               name = g_strdup("");
+
+       return name;
+}
+
 Folder *folder_get_default_folder(void)
 {
        return folder_list ? FOLDER(folder_list->data) : NULL;
index 572e7f6..5778e4d 100644 (file)
@@ -153,6 +153,7 @@ struct _FolderClass
 {
        FolderType  type;
        gchar      *idstr;
+       gchar      *uistr;
 
        /* virtual functions */
 
@@ -370,6 +371,7 @@ FolderClass *folder_get_class_from_string   (const gchar    *str);
 gchar      *folder_get_identifier              (Folder         *folder);
 gchar      *folder_item_get_identifier         (FolderItem     *item);
 FolderItem *folder_find_item_from_identifier   (const gchar    *identifier);
+gchar     *folder_item_get_name                (FolderItem     *item);
 
 Folder     *folder_get_default_folder  (void);
 FolderItem *folder_get_default_inbox   (void);
index 0c00cf3..7f02cf0 100644 (file)
@@ -218,40 +218,7 @@ static gboolean foldersel_gnode_func(GtkCTree *ctree, guint depth,
        FolderItem *item = FOLDER_ITEM(gnode->data);
        gchar *name;
 
-       switch (item->stype) {
-       case F_INBOX:
-               name = _("Inbox");
-               break;
-       case F_OUTBOX:
-               name = _("Sent");
-               break;
-       case F_QUEUE:
-               name = _("Queue");
-               break;
-       case F_TRASH:
-               name = _("Trash");
-               break;
-       case F_DRAFT:
-               name = _("Drafts");
-               break;
-       default:
-               name = item->name;
-
-               if (!item->parent) {
-                       switch (FOLDER_TYPE(item->folder)) {
-                       case F_MBOX:
-                               Xstrcat_a(name, name, " (MBOX)", ); break;
-                       case F_MH:
-                               Xstrcat_a(name, name, " (MH)", ); break;
-                       case F_IMAP:
-                               Xstrcat_a(name, name, " (IMAP4)", ); break;
-                       case F_NEWS:
-                               Xstrcat_a(name, name, " (News)", ); break;
-                       default:
-                               break;
-                       }
-               }
-       }
+       name = folder_item_get_name(item);
 
        gtk_ctree_node_set_row_data(ctree, cnode, item);
        gtk_ctree_set_node_info(ctree, cnode, name,
@@ -260,6 +227,8 @@ static gboolean foldersel_gnode_func(GtkCTree *ctree, guint depth,
                                folderopenxpm, folderopenxpmmask,
                                FALSE, FALSE);
 
+       g_free(name);
+
        return TRUE;
 }
 
index 854e05c..a103308 100644 (file)
@@ -1103,9 +1103,6 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openxpm = inboxopenxpm;
                        openmask = inboxopenxpmmask;
                }
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
-                               item->name);
                break;
        case F_OUTBOX:
                if (item->hide_read_msgs) {
@@ -1119,9 +1116,6 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openxpm = outboxopenxpm;
                        openmask = outboxopenxpmmask;
                }
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
-                               item->name);
                break;
        case F_QUEUE:
                if (item->hide_read_msgs) {
@@ -1135,9 +1129,6 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openxpm = queueopenxpm;
                        openmask = queueopenxpmmask;
                }
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
-                               item->name);
                break;
        case F_TRASH:
                if (item->hide_read_msgs) {
@@ -1151,18 +1142,12 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openxpm = trashopenxpm;
                        openmask = trashopenxpmmask;
                }
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, TRASH_DIR) ? _("Trash") :
-                               item->name);
                break;
        case F_DRAFT:
                xpm = draftsxpm;
                mask = draftsxpmmask;
                openxpm = draftsopenxpm;
                openmask = draftsopenxpmmask;
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
-                               item->name);
                break;
        default:
                if (item->hide_read_msgs) {
@@ -1176,31 +1161,8 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openxpm = folderopenxpm;
                        openmask = folderopenxpmmask;
                }
-               if (!item->parent) {
-                       switch (FOLDER_TYPE(item->folder)) {
-                       case F_MH:
-                               name = " (MH)"; break;
-                       case F_MBOX:
-                               name = " (mbox)"; break;
-                       case F_IMAP:
-                               name = " (IMAP4)"; break;
-                       case F_NEWS:
-                               name = " (News)"; break;
-                       default:
-                               name = "";
-                       }
-                       name = g_strconcat(item->name, name, NULL);
-               } else {
-                       if (FOLDER_TYPE(item->folder) == F_NEWS &&
-                           item->path &&
-                           !strcmp2(item->name, item->path))
-                               name = get_abbrev_newsgroup_name
-                                       (item->path,
-                                        prefs_common.ng_abbrev_len);
-                       else
-                               name = g_strdup(item->name);
-               }
        }
+       name = folder_item_get_name(item);
 
        if (!GTK_CTREE_ROW(node)->expanded &&
            folderview_have_unread_children(folderview, node))
index e6d4283..f618742 100644 (file)
@@ -298,6 +298,7 @@ FolderClass imap_class =
 {
        F_IMAP,
        "imap",
+       "IMAP4",
 
        /* Folder functions */
        imap_folder_new,
index 2f2a96c..58aa60c 100644 (file)
@@ -54,6 +54,7 @@ FolderClass mbox_class =
 {
        F_MBOX,
        "mbox",
+       "MBOX",
 
        /* Folder functions */
        mbox_folder_new,
index 2a9ea02..eeea14b 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -112,6 +112,7 @@ FolderClass mh_class =
 {
        F_MH,
        "mh",
+       "MH",
 
        /* Folder functions */
        mh_folder_new,
index 345d771..c2a25da 100644 (file)
@@ -110,6 +110,7 @@ FolderClass news_class =
 {
        F_NEWS,
        "news",
+       "News",
 
        /* Folder functions */
        news_folder_new,
index bada3cf..0b09ba6 100644 (file)
@@ -391,19 +391,10 @@ static void prefs_scoring_set_dialog(ScoringProp * cond)
                cur_important_score = prefs_common.important_score;
                gtk_widget_show(scoring.kill_score_label);
                gtk_widget_show(scoring.kill_score_entry);
-       }
-       else {
+       } else {
                prefs_scoring = cur_item->prefs->scoring;
                cur_kill_score = cur_item->prefs->kill_score;
                cur_important_score = cur_item->prefs->important_score;
-               if (FOLDER_TYPE(cur_item->folder) != F_NEWS) {
-                       gtk_widget_hide(scoring.kill_score_label);
-                       gtk_widget_hide(scoring.kill_score_entry);
-               }
-               else {
-                       gtk_widget_show(scoring.kill_score_label);
-                       gtk_widget_show(scoring.kill_score_entry);
-               }
        }
 
        for(cur = prefs_scoring ; cur != NULL ;
index 91c3671..fee3ae8 100644 (file)
@@ -1912,6 +1912,7 @@ static void summary_status_show(SummaryView *summaryview)
        guint n_selected = 0;
        off_t sel_size = 0;
        MsgInfo *msginfo;
+       gchar *name;
 
        if (!summaryview->folder_item) {
                gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), "");
@@ -1933,21 +1934,9 @@ static void summary_status_show(SummaryView *summaryview)
                }
        }
 
-       if (FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) {
-               if (summaryview->folder_item->path != NULL) {
-                       gchar *group;
-                       group = get_abbrev_newsgroup_name
-                               (g_basename(summaryview->folder_item->path),
-                                prefs_common.ng_abbrev_len);
-                       gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), group);
-                       g_free(group);
-               } else {
-                       gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), "");
-               }
-       } else {
-               gtk_label_set(GTK_LABEL(summaryview->statlabel_folder),
-                             summaryview->folder_item->path);
-       }
+       name = folder_item_get_name(summaryview->folder_item);
+       gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), name);
+       g_free(name);
 
        if (summaryview->deleted)
                del = g_strdup_printf(_("%d deleted"), summaryview->deleted);