~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to src/marlin-window-columns.c

  • Committer: am.monkeyd at gmail
  • Date: 2010-11-08 13:17:02 UTC
  • Revision ID: am.monkeyd@gmail.com-20101108131702-rqeywh4r5pyx2ycz
let's roll

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * Copyright (C) 2010 ammonkey
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU Lesser General Public License
 
7
 * version 3.0 as published by the Free Software Foundation.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Lesser General Public License version 3.0 for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library. If not, see
 
16
 * <http://www.gnu.org/licenses/>.
 
17
 *
 
18
 * Author: ammonkey <am.monkeyd@gmail.com>
 
19
 */
 
20
 
 
21
#include "marlin-window-columns.h"
 
22
//#include "gof-directory-async.h"
 
23
//#include "fm-list-view.h"
 
24
#include "fm-columns-view.h"
 
25
 
 
26
/*static void gof_window_slot_init       (GOFWindowSlot *slot);
 
27
static void gof_window_slot_class_init (GOFWindowSlotClass *class);
 
28
static void gof_window_slot_finalize   (GObject *object);*/
 
29
static void marlin_window_columns_finalize   (GObject *object);
 
30
 
 
31
G_DEFINE_TYPE (MarlinWindowColumns, marlin_window_columns, G_TYPE_OBJECT)
 
32
 
 
33
#define parent_class marlin_window_columns_parent_class
 
34
 
 
35
void
 
36
marlin_window_columns_change_location (GOFWindowSlot *slot, GFile *location)
 
37
{
 
38
        MarlinWindowColumns *mwcols = slot->mwcols;
 
39
        GtkWidget *window = mwcols->window;
 
40
 
 
41
        load_dir_async_cancel(slot->directory);
 
42
        gtk_widget_destroy (mwcols->view_box);
 
43
        
 
44
        mwcols = marlin_window_columns_new (location, window);
 
45
}
 
46
 
 
47
MarlinWindowColumns *
 
48
marlin_window_columns_new (GFile *location, GtkWidget *window)
 
49
{
 
50
        printf("%s\n", G_STRFUNC);
 
51
        MarlinWindowColumns *mwcols;
 
52
        mwcols = g_object_new (MARLIN_TYPE_WINDOW_COLUMNS, NULL);
 
53
        mwcols->location = location;
 
54
        mwcols->window = window;
 
55
 
 
56
        GOFWindowSlot *slot = gof_window_slot_column_new (location, window);
 
57
        slot->mwcols = mwcols;
 
58
        mwcols->active_slot = slot;
 
59
        //marlin_window_set_active_slot (MARLIN_WINDOW (window), slot);
 
60
        
 
61
        mwcols->colpane = gtk_hbox_new (FALSE, 0);
 
62
        slot->colpane = mwcols->colpane;
 
63
        gtk_widget_show (mwcols->colpane);
 
64
        mwcols->view_box = gtk_scrolled_window_new(0, 0);
 
65
        gtk_widget_show (mwcols->view_box);
 
66
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (mwcols->view_box), mwcols->colpane);
 
67
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mwcols->view_box),
 
68
                                        GTK_POLICY_AUTOMATIC,
 
69
                                        GTK_POLICY_NEVER);
 
70
 
 
71
        gof_window_column_add(slot, slot->view_box);
 
72
 
 
73
        gtk_container_add( GTK_CONTAINER(window), mwcols->view_box);
 
74
        return mwcols;
 
75
}
 
76
 
 
77
void
 
78
marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)
 
79
{
 
80
        GOFWindowSlot *slot = gof_window_slot_column_new (location, mwcols->window);
 
81
        slot->mwcols = mwcols;
 
82
        slot->colpane = mwcols->active_slot->colpane;
 
83
        //mwcols->active_slot = slot;
 
84
        //add_column(mwcols, slot->view_box);
 
85
        gof_window_column_add(slot, slot->view_box);
 
86
}
 
87
 
 
88
static void
 
89
marlin_window_columns_init (MarlinWindowColumns *mwcol)
 
90
{
 
91
#if 0
 
92
        GtkWidget *content_box, *eventbox, *extras_vbox, *frame, *hsep;
 
93
 
 
94
        content_box = gtk_vbox_new (FALSE, 0);
 
95
        slot->content_box = content_box;
 
96
        gtk_widget_show (content_box);
 
97
 
 
98
        frame = gtk_frame_new (NULL);
 
99
        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
 
100
        gtk_box_pack_start (GTK_BOX (content_box), frame, TRUE, TRUE, 0);
 
101
        gtk_widget_show (frame);
 
102
 
 
103
        slot->view_box = gtk_vbox_new (FALSE, 0);
 
104
        gtk_container_add (GTK_CONTAINER (frame), slot->view_box);
 
105
        gtk_widget_show (slot->view_box);
 
106
#endif
 
107
        //slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW, NULL));
 
108
        /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW,
 
109
                                                   "window-slot", slot, NULL));*/
 
110
        //gtk_box_pack_start (GTK_BOX (slot->content_box), GTK_WIDGET (slot->list_view->tree), TRUE, TRUE, 0);
 
111
        
 
112
 
 
113
        /*GtkWidget *m_scwin;
 
114
        m_scwin = gtk_scrolled_window_new(NULL,NULL);
 
115
        slot->content_box = m_scwin;
 
116
        gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_scwin), GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC);
 
117
        gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_scwin), GTK_SHADOW_NONE);*/
 
118
 
 
119
        //gtk_container_add( GTK_CONTAINER(m_scwin), GTK_WIDGET (slot->list_view->tree));
 
120
 
 
121
 
 
122
#if 0
 
123
        eventbox = gtk_event_box_new ();
 
124
        slot->extra_location_event_box = eventbox;
 
125
        gtk_widget_set_name (eventbox, "nautilus-extra-view-widget");
 
126
        gtk_box_pack_start (GTK_BOX (slot->view_box), eventbox, FALSE, FALSE, 0);
 
127
 
 
128
        extras_vbox = gtk_vbox_new (FALSE, 6);
 
129
        gtk_container_set_border_width (GTK_CONTAINER (extras_vbox), 6);
 
130
        slot->extra_location_widgets = extras_vbox;
 
131
        gtk_container_add (GTK_CONTAINER (eventbox), extras_vbox);
 
132
        gtk_widget_show (extras_vbox);
 
133
 
 
134
        hsep = gtk_hseparator_new ();
 
135
        gtk_box_pack_start (GTK_BOX (slot->view_box), hsep, FALSE, FALSE, 0);
 
136
        slot->extra_location_separator = hsep;
 
137
 
 
138
        slot->title = g_strdup (_("Loading..."));
 
139
#endif
 
140
}
 
141
 
 
142
static void
 
143
marlin_window_columns_class_init (MarlinWindowColumnsClass *class)
 
144
{
 
145
        /*class->active = real_active;
 
146
        class->inactive = real_inactive;
 
147
        class->update_query_editor = real_update_query_editor; */
 
148
 
 
149
        G_OBJECT_CLASS (class)->finalize = marlin_window_columns_finalize;
 
150
}
 
151
 
 
152
/*GOFWindowSlot *
 
153
marlin_window_columns_get_active_slot (MarlinWindowColumns *mwcols)
 
154
{
 
155
        return (mwcols->active_slot);
 
156
}*/
 
157
 
 
158
GFile *
 
159
marlin_window_columns_get_location (MarlinWindowColumns *mwcols)
 
160
{
 
161
        return mwcols->location;
 
162
}
 
163
 
 
164
#if 0
 
165
void
 
166
nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
 
167
{
 
168
        gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
 
169
                               remove_all,
 
170
                               slot->extra_location_widgets);
 
171
        gtk_widget_hide (slot->extra_location_event_box);
 
172
        gtk_widget_hide (slot->extra_location_separator);
 
173
}
 
174
 
 
175
void
 
176
nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *slot,
 
177
                                                GtkWidget *widget)
 
178
{
 
179
        gtk_box_pack_start (GTK_BOX (slot->extra_location_widgets),
 
180
                            widget, TRUE, TRUE, 0);
 
181
        gtk_widget_show (slot->extra_location_event_box);
 
182
        gtk_widget_show (slot->extra_location_separator);
 
183
}
 
184
 
 
185
void
 
186
nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot)
 
187
{
 
188
 
 
189
        if ((slot->pane->window == NULL || !NAUTILUS_IS_DESKTOP_WINDOW (slot->pane->window)) &&
 
190
            nautilus_add_bookmark_to_history_list (slot->current_location_bookmark)) {
 
191
                nautilus_send_history_list_changed ();
 
192
        }
 
193
}
 
194
#endif
 
195
 
 
196
static void
 
197
marlin_window_columns_finalize (GObject *object)
 
198
{
 
199
        //MarlinWindowColumns *mwcols = MARLIN_WINDOW_COLUMNS (object);
 
200
        
 
201
        G_OBJECT_CLASS (parent_class)->finalize (object);
 
202
 
 
203
#if 0
 
204
        GtkWidget *widget;
 
205
 
 
206
        if (slot->content_view) {
 
207
                widget = nautilus_view_get_widget (slot->content_view);
 
208
                gtk_widget_destroy (widget);
 
209
                g_object_unref (slot->content_view);
 
210
                slot->content_view = NULL;
 
211
        }
 
212
 
 
213
        if (slot->new_content_view) {
 
214
                widget = nautilus_view_get_widget (slot->new_content_view);
 
215
                gtk_widget_destroy (widget);
 
216
                g_object_unref (slot->new_content_view);
 
217
                slot->new_content_view = NULL;
 
218
        }
 
219
 
 
220
        nautilus_window_slot_set_viewed_file (slot, NULL);
 
221
        /* TODO? why do we unref here? the file is NULL.
 
222
         * It was already here before the slot move, though */
 
223
        nautilus_file_unref (slot->viewed_file);
 
224
 
 
225
 
 
226
        eel_g_list_free_deep (slot->pending_selection);
 
227
        slot->pending_selection = NULL;
 
228
 
 
229
        g_free (slot->title);
 
230
        slot->title = NULL;
 
231
 
 
232
        g_free (slot->status_text);
 
233
        slot->status_text = NULL;
 
234
#endif
 
235
        //G_OBJECT_CLASS (parent_class)->dispose (object);
 
236
}
 
237