comparison src/view_dir_list.c @ 401:0a2e1b130a25

Add some wrappers in view_dir.c and simplify even more.
author zas_
date Thu, 17 Apr 2008 20:03:49 +0000
parents a7be56e84870
children 7840ccc95aee
comparison
equal deleted inserted replaced
400:35346871af88 401:0a2e1b130a25
282 vd->path = NULL; 282 vd->path = NULL;
283 vdlist_set_path(vd, path); 283 vdlist_set_path(vd, path);
284 g_free(path); 284 g_free(path);
285 } 285 }
286 286
287 static gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) 287 gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
288 { 288 {
289 ViewDir *vd = data; 289 ViewDir *vd = data;
290 GtkTreePath *tpath; 290 GtkTreePath *tpath;
291 291
292 if (event->keyval != GDK_Menu) return FALSE; 292 if (event->keyval != GDK_Menu) return FALSE;
315 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME); 315 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
316 316
317 return TRUE; 317 return TRUE;
318 } 318 }
319 319
320 static gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 320 gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
321 { 321 {
322 ViewDir *vd = data; 322 ViewDir *vd = data;
323 GtkTreePath *tpath; 323 GtkTreePath *tpath;
324 GtkTreeIter iter; 324 GtkTreeIter iter;
325 FileData *fd = NULL; 325 FileData *fd = NULL;
347 } 347 }
348 348
349 return TRUE; 349 return TRUE;
350 } 350 }
351 351
352 static void vdlist_destroy_cb(GtkWidget *widget, gpointer data) 352 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
353 { 353 {
354 ViewDir *vd = data; 354 ViewDir *vd = data;
355 355
356 vd_dnd_drop_scroll_cancel(vd); 356 vd_dnd_drop_scroll_cancel(vd);
357 widget_auto_scroll_stop(vd->view); 357 widget_auto_scroll_stop(vd->view);
366 GtkTreeViewColumn *column; 366 GtkTreeViewColumn *column;
367 GtkCellRenderer *renderer; 367 GtkCellRenderer *renderer;
368 368
369 vd->info = g_new0(ViewDirInfoList, 1); 369 vd->info = g_new0(ViewDirInfoList, 1);
370 vd->type = DIRVIEW_LIST; 370 vd->type = DIRVIEW_LIST;
371 vd->widget_destroy_cb = vdlist_destroy_cb;
372 371
373 VDLIST_INFO(vd, list) = NULL; 372 VDLIST_INFO(vd, list) = NULL;
374 373
375 store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); 374 store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
376 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); 375 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
377 g_object_unref(store); 376 g_object_unref(store);
378 377
379 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE); 378 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
380 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vd->view), FALSE); 379 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vd->view), FALSE);
381 g_signal_connect(G_OBJECT(vd->view), "row_activated", 380 g_signal_connect(G_OBJECT(vd->view), "row_activated",
382
383 G_CALLBACK(vd_activate_cb), vd); 381 G_CALLBACK(vd_activate_cb), vd);
384 382
385 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view)); 383 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
386 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); 384 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
387 385
399 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL); 397 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
400 398
401 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column); 399 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
402 400
403 g_signal_connect(G_OBJECT(vd->view), "key_press_event", 401 g_signal_connect(G_OBJECT(vd->view), "key_press_event",
404 G_CALLBACK(vdlist_press_key_cb), vd); 402 G_CALLBACK(vd_press_key_cb), vd);
405 gtk_container_add(GTK_CONTAINER(vd->widget), vd->view); 403 gtk_container_add(GTK_CONTAINER(vd->widget), vd->view);
406 gtk_widget_show(vd->view); 404 gtk_widget_show(vd->view);
407 405
408 vd_dnd_init(vd); 406 vd_dnd_init(vd);
409 407
410 g_signal_connect(G_OBJECT(vd->view), "button_press_event", 408 g_signal_connect(G_OBJECT(vd->view), "button_press_event",
411 G_CALLBACK(vdlist_press_cb), vd); 409 G_CALLBACK(vd_press_cb), vd);
412 g_signal_connect(G_OBJECT(vd->view), "button_release_event", 410 g_signal_connect(G_OBJECT(vd->view), "button_release_event",
413 G_CALLBACK(vd_release_cb), vd); 411 G_CALLBACK(vd_release_cb), vd);
414 412
415 if (path) vdlist_set_path(vd, path); 413 if (path) vdlist_set_path(vd, path);
416 414