~elementary-apps/pantheon-files/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
 * Copyright (C) 2010 ammonkey
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * version 3.0 as published by the Free Software Foundation.
 *
 * This library 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 Lesser General Public License version 3.0 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Author: ammonkey <am.monkeyd@gmail.com>
 */

#include "marlin-window-columns.h"
//#include "gof-directory-async.h"
//#include "fm-list-view.h"
#include "fm-columns-view.h"

/*static void gof_window_slot_init       (GOFWindowSlot *slot);
static void gof_window_slot_class_init (GOFWindowSlotClass *class);
static void gof_window_slot_finalize   (GObject *object);*/
static void marlin_window_columns_finalize   (GObject *object);

G_DEFINE_TYPE (MarlinWindowColumns, marlin_window_columns, G_TYPE_OBJECT)

#define parent_class marlin_window_columns_parent_class

void
marlin_window_columns_change_location (GOFWindowSlot *slot, GFile *location)
{
        MarlinWindowColumns *mwcols = slot->mwcols;
        GtkWidget *window = mwcols->window;

        load_dir_async_cancel(slot->directory);
        gtk_widget_destroy (mwcols->view_box);
        
        mwcols = marlin_window_columns_new (location, window);
}

MarlinWindowColumns *
marlin_window_columns_new (GFile *location, GtkWidget *window)
{
        printf("%s\n", G_STRFUNC);
        MarlinWindowColumns *mwcols;
        mwcols = g_object_new (MARLIN_TYPE_WINDOW_COLUMNS, NULL);
        mwcols->location = location;
        mwcols->window = window;

        GOFWindowSlot *slot = gof_window_slot_column_new (location, window);
        slot->mwcols = mwcols;
        mwcols->active_slot = slot;
        //marlin_window_set_active_slot (MARLIN_WINDOW (window), slot);
        
        mwcols->colpane = gtk_hbox_new (FALSE, 0);
        slot->colpane = mwcols->colpane;
        gtk_widget_show (mwcols->colpane);
        mwcols->view_box = gtk_scrolled_window_new(0, 0);
        gtk_widget_show (mwcols->view_box);
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (mwcols->view_box), mwcols->colpane);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mwcols->view_box),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_NEVER);

        gof_window_column_add(slot, slot->view_box);

        gtk_container_add( GTK_CONTAINER(window), mwcols->view_box);
        return mwcols;
}

void
marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)
{
        GOFWindowSlot *slot = gof_window_slot_column_new (location, mwcols->window);
        slot->mwcols = mwcols;
        slot->colpane = mwcols->active_slot->colpane;
        //mwcols->active_slot = slot;
        //add_column(mwcols, slot->view_box);
        gof_window_column_add(slot, slot->view_box);
}

static void
marlin_window_columns_init (MarlinWindowColumns *mwcol)
{
#if 0
	GtkWidget *content_box, *eventbox, *extras_vbox, *frame, *hsep;

	content_box = gtk_vbox_new (FALSE, 0);
	slot->content_box = content_box;
	gtk_widget_show (content_box);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
	gtk_box_pack_start (GTK_BOX (content_box), frame, TRUE, TRUE, 0);
	gtk_widget_show (frame);

	slot->view_box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (frame), slot->view_box);
	gtk_widget_show (slot->view_box);
#endif
        //slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW, NULL));
        /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW,
                                                   "window-slot", slot, NULL));*/
	//gtk_box_pack_start (GTK_BOX (slot->content_box), GTK_WIDGET (slot->list_view->tree), TRUE, TRUE, 0);
        

        /*GtkWidget *m_scwin;
        m_scwin = gtk_scrolled_window_new(NULL,NULL);
	slot->content_box = m_scwin;
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_scwin), GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_scwin), GTK_SHADOW_NONE);*/

        //gtk_container_add( GTK_CONTAINER(m_scwin), GTK_WIDGET (slot->list_view->tree));


#if 0
	eventbox = gtk_event_box_new ();
	slot->extra_location_event_box = eventbox;
	gtk_widget_set_name (eventbox, "nautilus-extra-view-widget");
	gtk_box_pack_start (GTK_BOX (slot->view_box), eventbox, FALSE, FALSE, 0);

	extras_vbox = gtk_vbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (extras_vbox), 6);
	slot->extra_location_widgets = extras_vbox;
	gtk_container_add (GTK_CONTAINER (eventbox), extras_vbox);
	gtk_widget_show (extras_vbox);

	hsep = gtk_hseparator_new ();
	gtk_box_pack_start (GTK_BOX (slot->view_box), hsep, FALSE, FALSE, 0);
	slot->extra_location_separator = hsep;

	slot->title = g_strdup (_("Loading..."));
#endif
}

static void
marlin_window_columns_class_init (MarlinWindowColumnsClass *class)
{
	/*class->active = real_active;
	class->inactive = real_inactive;
	class->update_query_editor = real_update_query_editor; */

	G_OBJECT_CLASS (class)->finalize = marlin_window_columns_finalize;
}

/*GOFWindowSlot *
marlin_window_columns_get_active_slot (MarlinWindowColumns *mwcols)
{
        return (mwcols->active_slot);
}*/

GFile *
marlin_window_columns_get_location (MarlinWindowColumns *mwcols)
{
        return mwcols->location;
}

#if 0
void
nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
{
	gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
			       remove_all,
			       slot->extra_location_widgets);
	gtk_widget_hide (slot->extra_location_event_box);
	gtk_widget_hide (slot->extra_location_separator);
}

void
nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *slot,
						GtkWidget *widget)
{
	gtk_box_pack_start (GTK_BOX (slot->extra_location_widgets),
			    widget, TRUE, TRUE, 0);
	gtk_widget_show (slot->extra_location_event_box);
	gtk_widget_show (slot->extra_location_separator);
}

void
nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot)
{

	if ((slot->pane->window == NULL || !NAUTILUS_IS_DESKTOP_WINDOW (slot->pane->window)) &&
	    nautilus_add_bookmark_to_history_list (slot->current_location_bookmark)) {
		nautilus_send_history_list_changed ();
	}
}
#endif

static void
marlin_window_columns_finalize (GObject *object)
{
	//MarlinWindowColumns *mwcols = MARLIN_WINDOW_COLUMNS (object);
	
        G_OBJECT_CLASS (parent_class)->finalize (object);

#if 0
	GtkWidget *widget;

	if (slot->content_view) {
		widget = nautilus_view_get_widget (slot->content_view);
		gtk_widget_destroy (widget);
		g_object_unref (slot->content_view);
		slot->content_view = NULL;
	}

	if (slot->new_content_view) {
		widget = nautilus_view_get_widget (slot->new_content_view);
		gtk_widget_destroy (widget);
		g_object_unref (slot->new_content_view);
		slot->new_content_view = NULL;
	}

	nautilus_window_slot_set_viewed_file (slot, NULL);
	/* TODO? why do we unref here? the file is NULL.
	 * It was already here before the slot move, though */
	nautilus_file_unref (slot->viewed_file);


	eel_g_list_free_deep (slot->pending_selection);
	slot->pending_selection = NULL;

	g_free (slot->title);
	slot->title = NULL;

	g_free (slot->status_text);
	slot->status_text = NULL;
#endif
	//G_OBJECT_CLASS (parent_class)->dispose (object);
}