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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* Nautilus
* Copyright (C) 1999, 2000 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Andy Hertzfeld <andy@eazel.com>
*
* This is the index panel widget, which displays overview information
* in a vertical panel and hosts the meta-views.
*
*/
#include <config.h>
#include "ntl-index-panel.h"
#include <math.h>
#include <gnome.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus/nautilus-background.h>
#include <libnautilus/nautilus-directory.h>
#include <libnautilus/nautilus-file.h>
#include <libnautilus/nautilus-glib-extensions.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include <libnautilus/nautilus-metadata.h>
#include <libnautilus/nautilus-string.h>
#include "ntl-meta-view.h"
#include "nautilus-index-tabs.h"
#include "nautilus-index-title.h"
#include <libnautilus/nautilus-mime-type.h>
struct _NautilusIndexPanelDetails {
GtkWidget *index_container;
GtkWidget *index_title;
GtkWidget *notebook;
GtkWidget *index_tabs;
GtkWidget *title_tab;
GtkWidget *button_box;
gboolean has_buttons;
char *uri;
int selected_index;
NautilusDirectory *directory;
int background_connection;
};
static void nautilus_index_panel_initialize_class (GtkObjectClass *object_klass);
static void nautilus_index_panel_initialize (GtkObject *object);
static gboolean nautilus_index_panel_press_event(GtkWidget *widget, GdkEventButton *event);
static gboolean nautilus_index_panel_leave_event (GtkWidget *widget, GdkEventCrossing *event);
static gboolean nautilus_index_panel_motion_event(GtkWidget *widget, GdkEventMotion *event);
static void nautilus_index_panel_destroy (GtkObject *object);
static void nautilus_index_panel_finalize (GtkObject *object);
static void nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *context,
int x, int y,
GtkSelectionData *selection_data,
guint info, guint time);
static void nautilus_index_panel_set_up_info (NautilusIndexPanel *index_panel, const char* new_uri, const char *initial_title);
static void nautilus_index_panel_set_up_buttons (NautilusIndexPanel *index_panel, const char* new_uri);
static void add_command_buttons(NautilusIndexPanel *index_panel, GList *command_list);
#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF"
#define INDEX_PANEL_WIDTH 136
/* drag and drop definitions */
enum {
TARGET_URI_LIST,
TARGET_COLOR,
TARGET_GNOME_URI_LIST
};
static GtkTargetEntry index_dnd_target_table[] = {
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "application/x-color", 0, TARGET_COLOR },
{ "special/x-gnome-icon-list", 0, TARGET_GNOME_URI_LIST }
};
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexPanel, nautilus_index_panel, GTK_TYPE_EVENT_BOX)
/* initializing the class object by installing the operations we override */
static void
nautilus_index_panel_initialize_class (GtkObjectClass *object_klass)
{
GtkWidgetClass *widget_class;
NautilusIndexPanelClass *klass;
widget_class = GTK_WIDGET_CLASS (object_klass);
klass = NAUTILUS_INDEX_PANEL_CLASS (object_klass);
object_klass->destroy = nautilus_index_panel_destroy;
object_klass->finalize = nautilus_index_panel_finalize;
widget_class->drag_data_received = nautilus_index_panel_drag_data_received;
widget_class->motion_notify_event = nautilus_index_panel_motion_event;
widget_class->leave_notify_event = nautilus_index_panel_leave_event;
widget_class->button_press_event = nautilus_index_panel_press_event;
}
/* utility routine to allocate the box the holds the command buttons */
static void
make_button_box(NautilusIndexPanel *index_panel)
{
index_panel->details->button_box = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (index_panel->details->button_box), 8);
gtk_widget_show (index_panel->details->button_box);
gtk_container_add (GTK_CONTAINER (index_panel->details->index_container), index_panel->details->button_box);
index_panel->details->has_buttons = FALSE;
}
/* initialize the instance's fields, create the necessary subviews, etc. */
static void
nautilus_index_panel_initialize (GtkObject *object)
{
NautilusIndexPanel *index_panel;
GtkWidget* widget;
index_panel = NAUTILUS_INDEX_PANEL (object);
widget = GTK_WIDGET (object);
index_panel->details = g_new0 (NautilusIndexPanelDetails, 1);
/* set the size of the index panel */
gtk_widget_set_usize (widget, INDEX_PANEL_WIDTH, 400);
/* create the container box */
index_panel->details->index_container = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (index_panel->details->index_container), 0);
gtk_widget_show (index_panel->details->index_container);
gtk_container_add (GTK_CONTAINER (index_panel), index_panel->details->index_container);
/* allocate and install the index title widget */
index_panel->details->index_title = nautilus_index_title_new();
gtk_widget_show(index_panel->details->index_title);
gtk_box_pack_start (GTK_BOX (index_panel->details->index_container),
index_panel->details->index_title, FALSE, FALSE, 0);
/* first, allocate the index tabs */
index_panel->details->index_tabs = GTK_WIDGET(nautilus_index_tabs_new());
index_panel->details->selected_index = -1;
/* also, allocate the title tab */
index_panel->details->title_tab = GTK_WIDGET(nautilus_index_tabs_new());
nautilus_index_tabs_set_title_mode(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), TRUE);
gtk_widget_show (index_panel->details->index_tabs);
gtk_box_pack_end (GTK_BOX (index_panel->details->index_container), index_panel->details->index_tabs, FALSE, FALSE, 0);
/* allocate and install the meta-tabs */
index_panel->details->notebook = gtk_notebook_new ();
gtk_widget_ref (index_panel->details->notebook);
gtk_object_sink (GTK_OBJECT (index_panel->details->notebook));
gtk_widget_set_usize (index_panel->details->notebook, INDEX_PANEL_WIDTH, 200);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(index_panel->details->notebook), FALSE);
/* allocate and install the command button container */
make_button_box(index_panel);
/* prepare ourselves to receive dropped objects */
gtk_drag_dest_set (GTK_WIDGET (index_panel),
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
index_dnd_target_table, NAUTILUS_N_ELEMENTS (index_dnd_target_table), GDK_ACTION_COPY);
}
static void
nautilus_index_panel_destroy (GtkObject *object)
{
NautilusIndexPanel *index_panel;
index_panel = NAUTILUS_INDEX_PANEL (object);
gtk_widget_unref (index_panel->details->notebook);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
static void
nautilus_index_panel_finalize (GtkObject *object)
{
NautilusIndexPanel *index_panel;
index_panel = NAUTILUS_INDEX_PANEL (object);
g_free (index_panel->details->uri);
g_free (index_panel->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, finalize, (object));
}
/* create a new instance */
NautilusIndexPanel *
nautilus_index_panel_new (void)
{
return NAUTILUS_INDEX_PANEL (gtk_type_new (nautilus_index_panel_get_type ()));
}
/* drag and drop handler for index panel */
static void
nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *context,
int x, int y,
GtkSelectionData *selection_data, guint info, guint time)
{
NautilusIndexPanel *index_panel;
g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (widget));
switch (info)
{
case TARGET_GNOME_URI_LIST:
case TARGET_URI_LIST:
g_message("dropped data on index panel: %s", selection_data->data);
/* handle background images and keywords soon */
/* handle images dropped on the logo specially */
/* handle files by setting the location to the file */
break;
case TARGET_COLOR:
/* Let the background change based on the dropped color. */
index_panel = NAUTILUS_INDEX_PANEL (widget);
/* if the click is in the main tabs, tell them about it */
if (y >= index_panel->details->index_tabs->allocation.y) {
nautilus_index_tabs_receive_dropped_color
(NAUTILUS_INDEX_TABS(index_panel->details->index_tabs),
x, y, selection_data);
}
/* try the title tab */
else
if ((y >= index_panel->details->title_tab->allocation.y) &&
(y <= (index_panel->details->title_tab->allocation.y + index_panel->details->title_tab->allocation.height)))
nautilus_index_tabs_receive_dropped_color
(NAUTILUS_INDEX_TABS(index_panel->details->title_tab),
x, y, selection_data);
/* otherwise, pass it along to the index panel background */
else
nautilus_background_receive_dropped_color
(nautilus_get_widget_background (widget),
widget, x, y, selection_data);
break;
default:
g_warning ("unknown drop type");
break;
}
}
/* add a new meta-view to the index panel */
void
nautilus_index_panel_add_meta_view (NautilusIndexPanel *index_panel, NautilusView *meta_view)
{
GtkWidget *label;
const char *description;
char cbuf[32];
int page_num;
g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (index_panel));
g_return_if_fail (NAUTILUS_IS_META_VIEW (meta_view));
description = nautilus_meta_view_get_label (NAUTILUS_META_VIEW (meta_view));
if (description == NULL) {
description = cbuf;
g_snprintf (cbuf, sizeof (cbuf), "%p", meta_view);
}
label = gtk_label_new (description);
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (index_panel->details->notebook), GTK_WIDGET (meta_view), label);
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (index_panel->details->notebook), GTK_WIDGET (meta_view));
/* tell the index tabs about it */
nautilus_index_tabs_add_view(NAUTILUS_INDEX_TABS(index_panel->details->index_tabs),
description, GTK_WIDGET(meta_view), page_num);
gtk_widget_show (GTK_WIDGET (meta_view));
}
/* remove the passed-in meta-view from the index panel */
void
nautilus_index_panel_remove_meta_view (NautilusIndexPanel *index_panel, NautilusView *meta_view)
{
int page_num;
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (index_panel->details->notebook), GTK_WIDGET (meta_view));
g_return_if_fail (page_num >= 0);
gtk_notebook_remove_page (GTK_NOTEBOOK (index_panel->details->notebook), page_num);
}
/* utility to activate the metaview corresponding to the passed in index */
static void
nautilus_index_panel_activate_meta_view(NautilusIndexPanel *index_panel, int which_view)
{
char *title;
GtkNotebook *notebook = GTK_NOTEBOOK(index_panel->details->notebook);
if (index_panel->details->selected_index < 0) {
gtk_widget_show (index_panel->details->notebook);
if (index_panel->details->notebook->parent == NULL)
gtk_box_pack_end (GTK_BOX (index_panel->details->index_container), index_panel->details->notebook, FALSE, FALSE, 0);
gtk_widget_show (index_panel->details->title_tab);
if (index_panel->details->title_tab->parent == NULL)
gtk_box_pack_end (GTK_BOX (index_panel->details->index_container), index_panel->details->title_tab, FALSE, FALSE, 0);
}
index_panel->details->selected_index = which_view;
title = nautilus_index_tabs_get_title_from_index(NAUTILUS_INDEX_TABS(index_panel->details->index_tabs), which_view);
nautilus_index_tabs_set_title(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), title);
nautilus_index_tabs_prelite_tab(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), -1);
g_free(title);
/* hide the buttons, since they look confusing when partially overlapped */
gtk_widget_hide(index_panel->details->button_box);
gtk_notebook_set_page(notebook, which_view);
}
/* utility to deactivate the active metaview */
static void
nautilus_index_panel_deactivate_meta_view(NautilusIndexPanel *index_panel)
{
if (index_panel->details->selected_index >= 0) {
gtk_widget_hide (index_panel->details->notebook);
gtk_widget_hide (index_panel->details->title_tab);
}
gtk_widget_show(index_panel->details->button_box);
index_panel->details->selected_index = -1;
nautilus_index_tabs_select_tab(NAUTILUS_INDEX_TABS(index_panel->details->index_tabs), -1);
}
/* handle mouse motion events by passing it to the tabs if necessary for pre-lighting */
static gboolean
nautilus_index_panel_motion_event (GtkWidget *widget, GdkEventMotion *event)
{
int x, y;
NautilusIndexPanel *index_panel = NAUTILUS_INDEX_PANEL (widget);
NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(index_panel->details->index_tabs);
gtk_widget_get_pointer(widget, &x, &y);
/* if the click is in the main tabs, tell them about it */
if (y >= index_panel->details->index_tabs->allocation.y) {
int which_tab = nautilus_index_tabs_hit_test(index_tabs, (double) x, (double) y);
nautilus_index_tabs_prelite_tab(index_tabs, which_tab);
}
/* also handle prelighting in the title tab if necessary */
if (index_panel->details->selected_index >= 0) {
int title_top = index_panel->details->title_tab->allocation.y;
int title_bottom = title_top + index_panel->details->title_tab->allocation.height;
if ((y >= title_top) && (y <= title_bottom)) {
int which_tab = nautilus_index_tabs_hit_test(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), (double) x, (double) y);
nautilus_index_tabs_prelite_tab(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), which_tab);
}
else
nautilus_index_tabs_prelite_tab(NAUTILUS_INDEX_TABS(index_panel->details->title_tab), -1);
}
return TRUE;
}
/* handle the leave event by turning off the preliting */
static gboolean
nautilus_index_panel_leave_event (GtkWidget *widget, GdkEventCrossing *event)
{
NautilusIndexPanel *index_panel = NAUTILUS_INDEX_PANEL (widget);
NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(index_panel->details->index_tabs);
nautilus_index_tabs_prelite_tab(index_tabs, -1);
index_tabs = NAUTILUS_INDEX_TABS(index_panel->details->title_tab);
nautilus_index_tabs_prelite_tab(index_tabs, -1);
return TRUE;
}
/* hit-test the index tabs and activate if necessary */
static gboolean
nautilus_index_panel_press_event (GtkWidget *widget, GdkEventButton *event)
{
int title_top, title_bottom;
NautilusIndexPanel *index_panel = NAUTILUS_INDEX_PANEL (widget);
NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(index_panel->details->index_tabs);
NautilusIndexTabs *title_tab = NAUTILUS_INDEX_TABS(index_panel->details->title_tab);
int rounded_y = floor(event->y + .5);
/* if the click is in the main tabs, tell them about it */
if (rounded_y >= index_panel->details->index_tabs->allocation.y) {
int which_tab = nautilus_index_tabs_hit_test(index_tabs, event->x, event->y);
if (which_tab >= 0) {
nautilus_index_tabs_select_tab(index_tabs, which_tab);
nautilus_index_panel_activate_meta_view(index_panel, which_tab);
gtk_widget_queue_draw(widget);
}
}
/* also handle clicks in the title tab if necessary */
if (index_panel->details->selected_index >= 0) {
title_top = index_panel->details->title_tab->allocation.y;
title_bottom = title_top + index_panel->details->title_tab->allocation.height;
if ((rounded_y >= title_top) && (rounded_y <= title_bottom)) {
int which_tab = nautilus_index_tabs_hit_test(title_tab, event->x, event->y);
if (which_tab >= 0) {
/* the user clicked in the title tab, so deactivate the metaview */
nautilus_index_panel_deactivate_meta_view(index_panel);
}
}
}
return TRUE;
}
static void
nautilus_index_panel_background_changed (NautilusIndexPanel *index_panel)
{
NautilusBackground *background;
char *color_spec;
if (index_panel->details->directory == NULL)
return;
background = nautilus_get_widget_background (GTK_WIDGET (index_panel));
color_spec = nautilus_background_get_color (background);
nautilus_directory_set_metadata (index_panel->details->directory,
INDEX_PANEL_BACKGROUND_COLOR_METADATA_KEY,
DEFAULT_BACKGROUND_COLOR,
color_spec);
g_free (color_spec);
}
/* utility to fork a process to actually execute the button command */
static void
command_button_cb (GtkWidget *button, char* command_str)
{
pid_t button_pid;
NautilusIndexPanel *index_panel;
char *parameter_ptr;
index_panel = NAUTILUS_INDEX_PANEL (gtk_object_get_user_data (GTK_OBJECT (button)));
parameter_ptr = index_panel->details->uri;
if (nautilus_str_has_prefix (parameter_ptr, "file://")) {
parameter_ptr += 7;
}
button_pid = fork();
if (button_pid == 0) {
execlp(command_str, command_str, parameter_ptr, NULL);
exit(0);
}
}
/* utility routine that allocates the command buttons from the command list */
static void
add_command_buttons(NautilusIndexPanel *index_panel, GList *command_list)
{
char *command_string, *temp_str;
GList *this_item = command_list;
GtkWidget *temp_button, *temp_label;
while (this_item != NULL)
{
NautilusCommandInfo *info = (NautilusCommandInfo*) this_item->data;
index_panel->details->has_buttons = TRUE;
temp_button = gtk_button_new();
temp_label = gtk_label_new(info->display_name);
gtk_widget_show(temp_label);
gtk_container_add(GTK_CONTAINER(temp_button), temp_label);
gtk_box_pack_start(GTK_BOX(index_panel->details->button_box), temp_button, FALSE, TRUE, 2);
gtk_button_set_relief(GTK_BUTTON(temp_button), GTK_RELIEF_NORMAL);
gtk_widget_set_usize(GTK_WIDGET(temp_button), 80, 20);
/* FIXME: we must quote the uri in case it has blanks */
if (nautilus_str_has_prefix (index_panel->details->uri, "file://")) {
temp_str = index_panel->details->uri + 7;
} else {
temp_str = index_panel->details->uri;
}
command_string = g_strdup_printf(info->command_string, temp_str);
gtk_signal_connect(GTK_OBJECT (temp_button), "clicked", GTK_SIGNAL_FUNC (command_button_cb), command_string);
gtk_object_set_user_data(GTK_OBJECT(temp_button), index_panel);
gtk_widget_show(temp_button);
this_item = this_item->next;
}
}
/* here's where we set up the command buttons, based on the mime-type of the associated URL */
/* FIXME: eventually, we need a way to override/augment the type from info in the metadata */
void
nautilus_index_panel_set_up_buttons (NautilusIndexPanel *index_panel, const char* new_uri)
{
NautilusFile *file_object;
GList *command_list;
/* dispose any existing buttons */
if (index_panel->details->has_buttons) {
gtk_container_remove(GTK_CONTAINER(index_panel->details->index_container), index_panel->details->button_box);
make_button_box(index_panel);
}
/* allocate a file object and fetch the associated mime-type */
file_object = nautilus_file_get(new_uri);
if (file_object) {
const char* mime_type = nautilus_file_get_mime_type(file_object);
/* generate a command list from the mime-type */
if (mime_type) {
command_list = nautilus_mime_type_get_commands(mime_type);
/* install a button for each command in the list */
if (command_list != NULL) {
add_command_buttons(index_panel, command_list);
nautilus_mime_type_dispose_list(command_list);
}
}
nautilus_file_unref(file_object);
}
}
/* this routine populates the index panel with the per-uri information */
void
nautilus_index_panel_set_up_info (NautilusIndexPanel *index_panel,
const char* new_uri,
const char* initial_title)
{
NautilusDirectory *directory;
NautilusBackground *background;
char *background_color;
directory = nautilus_directory_get (new_uri);
if (index_panel->details->directory != NULL)
gtk_object_unref (GTK_OBJECT (index_panel->details->directory));
index_panel->details->directory = directory;
/* Connect the background changed signal to code that writes the color. */
background = nautilus_get_widget_background (GTK_WIDGET (index_panel));
if (index_panel->details->background_connection == 0)
index_panel->details->background_connection =
gtk_signal_connect_object (GTK_OBJECT (background),
"changed",
nautilus_index_panel_background_changed,
GTK_OBJECT (index_panel));
/* Set up the background color from the metadata. */
background_color = nautilus_directory_get_metadata (directory,
INDEX_PANEL_BACKGROUND_COLOR_METADATA_KEY,
DEFAULT_BACKGROUND_COLOR);
nautilus_background_set_color (background, background_color);
g_free (background_color);
/* tell the title widget about it */
nautilus_index_title_set_uri(NAUTILUS_INDEX_TITLE(index_panel->details->index_title), new_uri, initial_title);
/* add keywords if we got any */
/* set up the command buttons */
nautilus_index_panel_set_up_buttons(index_panel, new_uri);
}
/* here is the key routine that populates the index panel with the appropriate information when the uri changes */
void
nautilus_index_panel_set_uri (NautilusIndexPanel *index_panel,
const char* new_uri,
const char* initial_title)
{
/* there's nothing to do if the uri is the same as the current one */
if (nautilus_strcmp (index_panel->details->uri, new_uri) == 0)
return;
g_free (index_panel->details->uri);
index_panel->details->uri = g_strdup (new_uri);
/* populate the per-uri box with the info */
nautilus_index_panel_set_up_info (index_panel, new_uri, initial_title);
}
void
nautilus_index_panel_set_title (NautilusIndexPanel *index_panel, const char* new_title)
{
nautilus_index_title_set_text (NAUTILUS_INDEX_TITLE(index_panel->details->index_title), new_title);
}
|