Gtk 에서 파일의 아이콘을 Gdk::Pixbuf 로 가져오기

탐색기 상에 나타나는 파일의 아이콘을 Gtk 위젯에 뿌려주기 위함.

Gio 의 GIcon 을 이용해 Pixbuf를 가져온다.



Glib::ustring fullpath("full/path");

Glib::RefPtr<Gio::File> directory = Gio::File::create_for_parse_name(fullpath);


if(!directory) return;


Glib::RefPtr<Gio::FileEnumerator> enumerator = directory->enumerate_children();


if(!enumerator) return;


Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();

Glib::RefPtr<Gio::FileInfo> fileInfo = enumerator->next_file();


while(fileInfo)

{

    Glib::RefPtr<Gio::Icon> gicon = fileInfo->get_icon();


    Gtk::IconInfo iconInfo = iconTheme->lookup_icon(gicon, 16, Gtk::ICON_LOOKUP_USE_BUILTIN);

    Glib::RefPtr<Gdk::Pixbuf> pixbuf = iconInfo.load_icon();


    // pixbuf 사용


    fileInfo = enumerator->next_file();

}

이 글과 관련된 글
  1. [2012/04/09] signpost - 메모 관리 프로그램 (마크다운 지원) by oot! (222)
  2. [2012/04/05] Gtk Stock Icon 에서 pixbuf 가져오기 by oot! (272)
  3. [2010/12/13] Gtk::FileChooserDialog클래스의 get_filenames() 리턴값 받기 by oot! (1044) *1
  4. [2010/12/13] vs2008 에서 gtkmm 사용하기 by oot! (679)
  5. [2010/12/13] clutter 문서 by oot! (1252)

Leave Comments



T-NAVI