Add folderview_get_opened_item() function.
authorAndrej Kacian <andrej@kacian.sk>
Wed, 21 Oct 2015 20:21:57 +0000 (22:21 +0200)
committerAndrej Kacian <andrej@kacian.sk>
Wed, 21 Oct 2015 20:21:57 +0000 (22:21 +0200)
src/folderview.c
src/folderview.h
src/plugins/vcalendar/vcal_folder.c

index 1db8aa4..9014165 100644 (file)
@@ -554,7 +554,7 @@ void folderview_set_column_order(FolderView *folderview)
        if (folderview->selected)
                sel_item = folderview_get_selected_item(folderview);
        if (folderview->opened)
-               op_item = gtk_cmctree_node_get_row_data(GTK_CMCTREE(ctree), folderview->opened);
+               op_item = folderview_get_opened_item(folderview);
 
        debug_print("recreating tree...\n");
        gtk_widget_destroy(folderview->ctree);
@@ -771,7 +771,7 @@ void folderview_set(FolderView *folderview)
        if (folderview->selected)
                sel_item = folderview_get_selected_item(folderview);
        if (folderview->opened)
-               op_item = gtk_cmctree_node_get_row_data(ctree, folderview->opened);
+               op_item = folderview_get_opened_item(folderview);
 
        folderview->selected = NULL;
        folderview->opened = NULL;
@@ -991,6 +991,14 @@ FolderItem *folderview_get_selected_item(FolderView *folderview)
        return gtk_cmctree_node_get_row_data(ctree, folderview->selected);
 }
 
+FolderItem *folderview_get_opened_item(FolderView *folderview)
+{
+       GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
+
+       if (!folderview->opened) return NULL;
+       return gtk_cmctree_node_get_row_data(ctree, folderview->opened);
+}
+
 static void folderview_set_folders(FolderView *folderview)
 {
        GList *list;
index cc36427..d4bb5f5 100644 (file)
@@ -118,6 +118,7 @@ void folderview_select_next_with_flag       (FolderView     *folderview,
                                         gboolean        force_open);
 
 FolderItem *folderview_get_selected_item(FolderView    *folderview);
+FolderItem *folderview_get_opened_item(FolderView      *folderview);
 
 void folderview_rescan_tree            (Folder         *folder,
                                         gboolean        rebuild);
index ec86574..266f486 100644 (file)
@@ -2066,13 +2066,12 @@ static void set_view_cb(GtkAction *gaction, GtkRadioAction *current, gpointer da
 {
        FolderView *folderview = (FolderView *)data;
        gint action = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
-       GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
        FolderItem *item = NULL, *oitem = NULL;
 
        if (!folderview->selected) return;
        if (setting_sensitivity) return;
 
-       oitem = gtk_cmctree_node_get_row_data(ctree, folderview->opened);
+       oitem = folderview_get_opened_item(folderview);
        item = folderview_get_selected_item(folderview);
 
        if (!item)