void NaviModules::SetDesEnv(MEnv* aDesEnv) { if (aDesEnv != iDesEnv) { unset_model(); remove_all_columns(); Glib::RefPtr<TreeModel> curmdl = get_model(); curmdl.reset(); iDesEnv = aDesEnv; if (iDesEnv != NULL) { Glib::RefPtr<Gtk::ListStore> mdl = Gtk::ListStore::create(iColRec); GtkTreeModel* model = mdl->Gtk::TreeModel::gobj(); set_model(mdl); append_column( "one", iColRec.name); enable_model_drag_source(); drag_source_set (Gtk::ArrayHandle_TargetEntry(KModListTargets, 1, Glib::OWNERSHIP_NONE), Gdk::MODIFIER_MASK, Gdk::ACTION_COPY); // Fill out the model // List modules directory struct dirent **entlist; string modpath = iDesEnv->Provider()->ModulesPath(); int n = scandir (modpath.c_str(), &entlist, FilterModulesDirEntries, alphasort); // Fill out the model for (int cnt = 0; cnt < n; ++cnt) { Gtk::TreeIter it = mdl->append(); Glib::ustring data = entlist[cnt]->d_name; (*it).set_value(iColRec.name, data); } } } }
int main(int argc, char *argv[]) { gtk_init(&argc, &argv); gchar *dirname = g_path_get_dirname(argv[0]); gchar *dataFilename = g_build_filename(dirname, "phonebook.dat", NULL); base_t *ctx = base_new(dataFilename); g_free(dirname); g_free(dataFilename); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "PSP1Beleg"); gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gbase_list_singleton = gbase_list_new(ctx); tree_view_singleton = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gbase_list_singleton)); g_object_unref(gbase_list_singleton); //fill_model(gbase_list_singleton); gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree_view_singleton), GBASE_LIST_COL_NUMBER); g_signal_connect(G_OBJECT(tree_view_singleton), "key-press-event", G_CALLBACK(on_key_press), NULL); append_column(GBASE_LIST_COL_NUMBER, "Phone Number"); append_column(GBASE_LIST_COL_NAME, "Surname"); append_column(GBASE_LIST_COL_FORENAME, "Forename"); GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view_singleton); gtk_container_add(GTK_CONTAINER(window), scrolled_window); gtk_widget_show_all(window); gtk_main(); bool ok = base_save(ctx); base_delete(ctx); return ok ? 0 : 1; }
ObjectsTreeView::ObjectsTreeView(std::shared_ptr<CG::World> world) : _world(world) { _refObjectsTreeModel = Gtk::ListStore::create(_objectsModelColumns); set_model(_refObjectsTreeModel); append_column("Name", _objectsModelColumns.colName); append_column("Type", _objectsModelColumns.colType); // _refObjectsTreeModel->set_sort_column(0, Gtk::SORT_ASCENDING); //Make all the columns reorderable for(guint i = 0; i < 2; i++) { Gtk::TreeView::Column* pColumn = get_column(i); pColumn->set_reorderable(); } init_popup_menu(); }
Tree::Tree() { // Initializing everything char DIR[256] = "/home/brian/Programs/classcatcher"; sprintf( course_file, "%s/etc/.courses", DIR ); sprintf( course_temp, "%s/etc/.courses.tmp", DIR ); m_refTreeModel = Gtk::ListStore::create( m_Columns ); set_model( m_refTreeModel ); append_column( "CRN", m_Columns.m_col_crn ); append_column( "Term", m_Columns.m_col_term ); append_column( "Year", m_Columns.m_col_year ); append_column( "Subject", m_Columns.m_col_subj ); append_column( "CRSE", m_Columns.m_col_crse ); loadfromfile(); }
/** * ClassesTreeView */ ImportClassesBox::ClassesTreeView::ClassesTreeView( BaseObjectType* cobject, const Glib::RefPtr < Gtk::Builder >& /*refGlade*/) : Gtk::TreeView(cobject), mClasses(0) { mRefTreeModel = Gtk::ListStore::create(mColumns); set_model(mRefTreeModel); append_column(_("Class name"), mColumns.m_col_name); mRefTreeSelection = get_selection(); }
TreeViewGoods::TreeViewGoods() { /* Create tree */ treeRecords = Gtk::ListStore::create( treeColumns ); set_model( treeRecords ); /* Create columns */ append_column( "Код", treeColumns.id ); append_column( "Наименование", treeColumns.name ); append_column( "Цена", treeColumns.price ); append_column( "Ед.Изм.", treeColumns.item ); /* Create popup menu */ Gtk::MenuItem* item = Gtk::manage( new Gtk::MenuItem( "Подробнее" ) ); item->signal_activate().connect( sigc::mem_fun( *this, &TreeViewGoods::on_menu_file_popup_generic ) ); menuPopup.append( *item ); menuPopup.accelerate( *this ); menuPopup.show_all(); /* Connect press event signal (mouse clicks) */ signal_button_press_event().connect( sigc::mem_fun( *this, &TreeViewGoods::on_button_press_event ), false ); }
Gtk::TreeView::Column* Chooser::addTextColumn( const Glib::ustring& name, Gtk::TreeModelColumnBase& column ) { Gtk::CellRendererText* renderer = Gtk::manage( new Gtk::CellRendererText ); Gtk::TreeView::Column* col = Gtk::manage( new Gtk::TreeView::Column( name, *renderer ) ); col->add_attribute( renderer->property_text(), column ); /*col->add_attribute( renderer->property_cell_background(), f_columns.background_color ); col->add_attribute( renderer->property_foreground(), f_columns.foreground_color ); col->add_attribute( renderer->property_style(), f_columns.style ); col->add_attribute( renderer->property_sensitive(), f_columns.sensitive );*/ col->set_resizable( true ); col->set_alignment( 0.5 ); col->set_sort_column( column ); append_column( *col ); return col; }
MainTreeView::MainTreeView(std::vector<Player>& players_list) : players_list(players_list) { //Create the Tree model: m_refTreeModel = Gtk::ListStore::create(m_Columns); set_model(m_refTreeModel); //Fill the TreeView's model updateTreeView(); //Add the TreeView's view columns: append_column("Rank", m_Columns.m_col_rank); append_column("ID", m_Columns.m_col_id); append_column("Name", m_Columns.m_col_name); append_column("Elo", m_Columns.m_col_elo); append_column("K Coefficient", m_Columns.m_col_kcoeff); //Fill popup menu: auto item = Gtk::manage(new Gtk::MenuItem("_Edit", true)); item->signal_activate().connect( sigc::mem_fun(*this, &MainTreeView::on_menu_file_popup_edit_player) ); m_Menu_Popup.append(*item); item = Gtk::manage(new Gtk::MenuItem("_Add a Result", true)); item->signal_activate().connect( sigc::mem_fun(*this, &MainTreeView::on_menu_file_popup_add_result) ); m_Menu_Popup.append(*item); item = Gtk::manage(new Gtk::MenuItem("_Remove", true)); item->signal_activate().connect( sigc::mem_fun(*this, &MainTreeView::on_menu_file_popup_remove_player) ); m_Menu_Popup.append(*item); m_Menu_Popup.accelerate(*this); m_Menu_Popup.show_all(); //Show all menu items when the menu pops up }
void NaviNatN::SetDesEnv(MEnv* aDesEnv) { if (aDesEnv != iDesEnv) { unset_model(); remove_all_columns(); Glib::RefPtr<TreeModel> curmdl = get_model(); curmdl.reset(); iDesEnv = aDesEnv; if (iDesEnv != NULL) { Glib::RefPtr<NatnTreeMdl> mdl = NatnTreeMdl::create(iDesEnv->Provider()); GtkTreeModel* model = mdl->Gtk::TreeModel::gobj(); bool isds = GTK_IS_TREE_DRAG_SOURCE(model); set_model(mdl); append_column( "one", mdl->ColRec().name); enable_model_drag_source(); drag_source_set (Gtk::ArrayHandle_TargetEntry(targetentries)); } } }
void show_server_info_dialog(Gtk::Window& w, Glib::ustring game_v, Glib::ustring host_v, Server data, std::function<void()> cb_launch) { PlayerListModelColumns player_list_columns; RuleListModelColumns rule_list_columns; // Set models auto game = Gtk::manage(new Gtk::Label(game_v)); game->set_halign(Gtk::Align::ALIGN_START); auto host = Gtk::manage(new Gtk::Label(host_v)); host->set_halign(Gtk::Align::ALIGN_START); auto name = Gtk::manage(new Gtk::Label); name->set_halign(Gtk::Align::ALIGN_START); auto terrain = Gtk::manage(new Gtk::Label); terrain->set_halign(Gtk::Align::ALIGN_START); auto ping = Gtk::manage(new Gtk::Label); ping->set_halign(Gtk::Align::ALIGN_START); auto players = Gtk::manage(new Gtk::Label); players->set_halign(Gtk::Align::ALIGN_START); set_label_from_optional(name, data.name); set_label_from_optional(terrain, data.terrain); set_label_from_optional(ping, data.ping); try { players->set_text(Glib::ustring::compose("%1 / %2", data.player_count.value(), data.player_limit.value())); } catch (const std::experimental::bad_optional_access&) {} auto player_list = Gtk::ListStore::create(player_list_columns); for (auto v : data.players) { auto& row = *player_list->append(); row[player_list_columns.name] = v.name; try { row[player_list_columns.ping] = std::stoi(v.info.at("ping")); } catch (...) {} try { row[player_list_columns.score] = std::stoi(v.info.at("score")); } catch (...) {} } auto rule_list = Gtk::ListStore::create(rule_list_columns); for (auto v : data.rules) { auto& row = *rule_list->append(); row[rule_list_columns.key] = v.first; row[rule_list_columns.value] = v.second; } // Create presentation auto server_info_data_grid = Gtk::manage(new Gtk::Grid); server_info_data_grid->set_row_spacing(5); server_info_data_grid->set_column_spacing(5); { auto i = -1; auto name_label = Gtk::manage(new Gtk::Label); name_label->set_markup("<b>Name:</b>"); name_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*name_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*name, *name_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto host_label = Gtk::manage(new Gtk::Label); host_label->set_markup("<b>Host:</b>"); host_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*host_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*host, *host_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto game_label = Gtk::manage(new Gtk::Label); game_label->set_markup("<b>Game:</b>"); game_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*game_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*game, *game_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto terrain_label = Gtk::manage(new Gtk::Label); terrain_label->set_markup("<b>Terrain:</b>"); terrain_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*terrain_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*terrain, *terrain_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto players_label = Gtk::manage(new Gtk::Label); players_label->set_markup("<b>Players:</b>"); players_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*players_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*players, *players_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto ping_label = Gtk::manage(new Gtk::Label); ping_label->set_markup("<b>Ping:</b>"); ping_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*ping_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*ping, *ping_label, Gtk::PositionType::POS_RIGHT, 1, 1); } auto player_list_view = Gtk::manage(new Gtk::TreeView(player_list)); { auto col = Gtk::manage(new Gtk::TreeViewColumn("Name")); col->pack_start(player_list_columns.name); player_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Score")); col->pack_start(player_list_columns.score); player_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Ping")); col->pack_start(player_list_columns.ping); player_list_view->append_column(*col); } auto player_list_sw = Gtk::manage(new Gtk::ScrolledWindow); player_list_sw->set_hexpand(true); player_list_sw->set_vexpand(true); player_list_sw->add(*player_list_view); auto server_info_grid = Gtk::manage(new Gtk::Grid); server_info_grid->set_row_spacing(10); { auto i = -1; server_info_grid->attach(*server_info_data_grid, 0, i++, 1, 1); server_info_grid->attach(*player_list_sw, 0, i++, 1, 1); } // Server rules auto rule_list_view = Gtk::manage(new Gtk::TreeView(rule_list)); { auto col = Gtk::manage(new Gtk::TreeViewColumn("Key")); col->pack_start(rule_list_columns.key); rule_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Value")); col->pack_start(rule_list_columns.value); rule_list_view->append_column(*col); } auto server_rules_sw = Gtk::manage(new Gtk::ScrolledWindow); server_rules_sw->add(*rule_list_view); // The stack auto stack = Gtk::manage(new Gtk::Stack); stack->property_margin().set_value(10); stack->add(*server_info_grid, "info", "Information"); stack->add(*server_rules_sw, "rules", "Rules"); auto stack_switcher = Gtk::manage(new Gtk::StackSwitcher); stack_switcher->set_stack(*stack); stack_switcher->set_halign(Gtk::Align::ALIGN_CENTER); // The dialog Gtk::Dialog dialog_window("Server info", w); auto content = dialog_window.get_content_area(); content->pack_start(*stack_switcher, Gtk::PackOptions::PACK_SHRINK); content->pack_start(*stack); auto connect_button = dialog_window.add_button("Connect", 0); auto close_button = dialog_window.add_button("Close", 0); connect_button->signal_clicked().connect([&dialog_window, cb_launch]() { try { cb_launch(); } catch (const std::bad_function_call&) {} }); dialog_window.show_all(); dialog_window.run(); }
ListView::ListView() : Gtk::TreeView() { // поиграемся с TreeView // создаём модель m_refTreeModel = Gtk::ListStore::create( m_Columns ); set_model( m_refTreeModel ); // Теперь добавляем столбцы для отображения append_column( "Name", m_Columns.m_col_name ); append_column( "Size", m_Columns.m_col_size ); append_column( "User/Group", m_Columns.m_col_users ); append_column( "Permission", m_Columns.m_col_permission ); append_column( "Type", m_Columns.m_col_type ); append_column( "Modified", m_Columns.m_col_modified ); //Set the sort column of the Tree model: m_refTreeModel->set_sort_column(0, Gtk::SORT_ASCENDING); Gtk::TreeView::Column* pColumn; pColumn = get_column(0); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_name ); pColumn = get_column(1); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_size ); pColumn = get_column(2); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_users ); pColumn = get_column(3); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_permission ); pColumn = get_column(4); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_type ); pColumn = get_column(5); if( pColumn ) pColumn->set_sort_column( m_Columns.m_col_modified ); //Fill popup menu: Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem("_Open", true)); item->signal_activate().connect( sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) ); m_Menu_Popup.append(*item); item = Gtk::manage(new Gtk::MenuItem("_Open with…", true)); item->signal_activate().connect( sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) ); m_Menu_Popup.append(*item); item = Gtk::manage(new Gtk::MenuItem("_Properties", true)); item->signal_activate().connect( sigc::mem_fun(*this, &ListView::on_menu_file_popup_generic) ); m_Menu_Popup.append(*item); m_Menu_Popup.accelerate(*this); m_Menu_Popup.show_all(); //Show all menu items when the menu pops up signal_button_press_event() .connect(sigc::mem_fun(*this, &ListView::on_button_press_event), false); Navigator nvg; show_file_list( nvg.get_file_list() ); }
// Cringe. void GtkTorrentSideBar::setupColumns() { int cid = 0; Gtk::TreeViewColumn *col = nullptr; Gtk::CellRendererText *cell = Gtk::manage(new Gtk::CellRendererText()); Gtk::CellRendererPixbuf *cellp = Gtk::manage(new Gtk::CellRendererPixbuf()); cell->set_alignment(0, 0.5); cell->signal_edited().connect([this](const std::string& path,const std::string& name){ addedItem(path, name); }); cid = append_column(*Gtk::manage(new Gtk::TreeViewColumn("Name"))); col = get_column(cid - 1); col->pack_start(*cellp); col->pack_start(*cell); col->add_attribute(cell->property_markup(), m_cols.name); col->add_attribute(cell->property_editable(), m_cols.editable); col->add_attribute(cellp->property_pixbuf(), m_cols.icon); // This really isn't "setupColumns" anymore from this point. // TODO Move to own function m_torrent_row = *(m_liststore->append()); m_torrent_row[m_cols.name] = "Torrents"; m_torrent_row[m_cols.editable] = false; m_torrent_row[m_cols.clickCallback] = [](){}; // clicks on titles don't do shit auto torrent_icon = Gdk::Pixbuf::create_from_resource("/org/gtk/gtorrent/icon-torrent.png"); auto torrent_icon_scaled = torrent_icon->scale_simple(16, 16, Gdk::INTERP_BILINEAR); m_torrent_row[m_cols.icon] = torrent_icon_scaled; // XXX TMP WILL REMOVE AND REPLACE WITH PROPER FUNCTION // Yes this is horrible. Bear with it for now. auto g = Application::getSingleton()->getCore()->getAllTorrents(); Gtk::TreeModel::Row row = *(m_liststore->append(m_torrent_row.children())); row[m_cols.name] = "All"; row[m_cols.title] = "All"; row[m_cols.group] = g; row[m_cols.group_vector] = &g->m_torrents_all; Gtk::TreeModel::Row row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Downloading"; row2[m_cols.title] = "Downloading"; row2[m_cols.group_vector] = &g->m_torrents_downloading; row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Seeding"; row2[m_cols.title] = "Seeding"; row2[m_cols.group_vector] = &g->m_torrents_seeding; row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Checking"; row2[m_cols.title] = "Checking"; row2[m_cols.group_vector] = &g->m_torrents_checking; row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Finished"; row2[m_cols.title] = "Finished"; row2[m_cols.group_vector] = &g->m_torrents_finished; row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Stopped"; row2[m_cols.title] = "Stopped"; row2[m_cols.group_vector] = &g->m_torrents_stopped; row2 = *(m_liststore->append(row.children())); row2[m_cols.name] = "Paused"; row2[m_cols.title] = "Paused"; row2[m_cols.group_vector] = &g->m_torrents_paused; // End of new horrible code // Continue horrible code from before //row = *(m_liststore->append(m_torrent_row.children())); //row[m_cols.name] = "Add a label"; //row[m_cols.editable] = true; //row[m_cols.icon] = Gtk::IconTheme::get_default()->lookup_icon("list-add-symbolic", 16, Gtk::ICON_LOOKUP_USE_BUILTIN).load_icon(); //row[m_cols.clickCallback] = [row](){}; m_rssfeed_row = *(m_liststore->append()); m_rssfeed_row[m_cols.name] = "RSS Feeds"; m_rssfeed_row[m_cols.editable] = false; m_rssfeed_row[m_cols.clickCallback] = [](){}; auto rss_icon = Gdk::Pixbuf::create_from_resource("/org/gtk/gtorrent/icon-rss.png"); auto rss_icon_scaled = rss_icon->scale_simple(16, 16, Gdk::INTERP_BILINEAR); m_rssfeed_row[m_cols.icon] = rss_icon_scaled; for(auto fg : Application::getSingleton()->getCore()->m_feeds) { row = *(m_liststore->append(m_rssfeed_row.children())); row[m_cols.name] = fg->name; row[m_cols.editable] = false; // TODO change icon to some sort of generic RSS icon row[m_cols.clickCallback] = [this, fg](){m_rss->run(fg->name);m_rss->hide();}; } row = *(m_liststore->append(m_rssfeed_row.children())); row[m_cols.name] = "Add an RSS group"; row[m_cols.editable] = true; row[m_cols.icon] = Gtk::IconTheme::get_default()->lookup_icon("list-add-symbolic", 16, Gtk::ICON_LOOKUP_USE_BUILTIN).load_icon(); row[m_cols.clickCallback] = [row](){}; //Maybe migrate settings there /* row = *(m_liststore->append()); row[m_cols.name] = "Settings"; row[m_cols.title] = true; row[m_cols.clickCallback] = [](){}; // clicks on titles don't do shit*/ }
void GtkPeerTreeView::setupColumns() { int cid; Gtk::TreeViewColumn *col; cid = append_column("IP" , m_cols.m_col_ip); col = get_column(cid - 1); col->set_sort_column(m_cols.m_col_ip); append_column("Port", m_cols.m_col_port); cid = append_column("Client" , m_cols.m_col_client); col = get_column(cid - 1); col->set_sort_column(m_cols.m_col_client); append_column("Flags", m_cols.m_col_flags); append_column("%", m_cols.m_col_percent); append_column("Relevance", m_cols.m_col_relevance); cid = append_column("Down Speed", m_cols.m_col_down); col = get_column(cid - 1); col->set_sort_column(m_cols.m_col_down); cid = append_column("Up Speed" , m_cols.m_col_up); col = get_column(cid - 1); col->set_sort_column(m_cols.m_col_up); append_column("Reqs", m_cols.m_col_reqs); append_column("Waited", m_cols.m_col_waited); append_column("Downloaded", m_cols.m_col_downloaded); append_column("Uploaded", m_cols.m_col_uploaded); append_column("Hasherr", m_cols.m_col_hasherr); append_column("Peer Download Rate", m_cols.m_col_peer_download_rate); append_column("MaxDown", m_cols.m_col_max_down); append_column("MaxUp", m_cols.m_col_max_up); append_column("Queued", m_cols.m_col_queued); append_column("Inactive", m_cols.m_col_inactive); append_column("Debug", m_cols.m_col_debug); }