Ejemplo n.º 1
0
void GMSourceView::init() {
  loadSettings("window");
  clear();
  listsources();


  FXString key = getApp()->reg().readStringEntry("window","source-list-current","");
  if (!key.empty()){
    FXTreeItem * item = sourcelist->getFirstItem();
    while(item){
      GMSource * src = static_cast<GMSource*>(item->getData());
      if (src->settingKey()==key) {
        sourcelist->setCurrentItem(item);
        break;
        }
      item=item->getBelow();
      }
    }

  if (sourcelist->getCurrentItem()==nullptr && sourcelist->getFirstItem())
    sourcelist->setCurrentItem(sourcelist->getFirstItem());

  source=static_cast<GMSource*>(sourcelist->getItemData(sourcelist->getCurrentItem()));
  GMPlayerManager::instance()->getTrackView()->init(source);
  }
Ejemplo n.º 2
0
long GMSourceView::onCmdNewStation(FXObject*sender,FXSelector,void*ptr){
  for (FXint i=0;i<GMPlayerManager::instance()->getNumSources();i++){
    GMSource * src = GMPlayerManager::instance()->getSource(i);
    if (src->getType()==SOURCE_INTERNET_RADIO)
      return src->handle(sender,FXSEL(SEL_COMMAND,GMStreamSource::ID_NEW_STATION),ptr);
    }
  return 0;
  }
Ejemplo n.º 3
0
long GMSourceView::onSourceTipText(FXObject*sender,FXSelector,void*ptr){
  FXint x,y; FXuint buttons;
  sourcelist->getCursorPosition(x,y,buttons);
  FXTreeItem * item = sourcelist->getItemAt(x,y);
  if (item && item->getData()) {
    GMSource * src = static_cast<GMSource*>(item->getData());
    return src->handle(sender,FXSEL(SEL_QUERY_TIP,0),ptr);
    }
  return 0;
  }
Ejemplo n.º 4
0
FXbool GMSourceView::listsources() {
  GMTreeItem * item=NULL;
  for (FXint i=0;i<GMPlayerManager::instance()->getNumSources();i++){
    GMSource * source = GMPlayerManager::instance()->getSource(i);
    FXIcon * icon=icon_for_sourcetype(source->getType());
    item = new GMTreeItem(source->getName(),icon,icon,source);
    sourcelist->appendItem(NULL,item);
    }
  sourcelist->sortItems();
  return true;
  }
Ejemplo n.º 5
0
long GMSourceView::onSourceContextMenu(FXObject*,FXSelector,void*ptr){
  FXEvent * event =static_cast<FXEvent*>(ptr);
  if (event->moved) return 0;
  GMTreeItem * item = dynamic_cast<GMTreeItem*>(sourcelist->getItemAt(event->win_x,event->win_y));
  GMMenuPane pane(this);
  GMSource * src = item ? static_cast<GMSource*>(item->getData()) : nullptr;
  FXbool src_items = false;

  if (src)
    src_items = src->source_context_menu(&pane);

  if (src && src->canBrowse()) {
    if (src_items) new FXMenuSeparator(&pane);
    new GMMenuCheck(&pane,tr("Show Browser\tCtrl-B\tShow Browser"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_BROWSER);
    new GMMenuCheck(&pane,tr("Show Tags\tCtrl-T\tShow Tags"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_TAGS);
    }

  // Install Source Items (Group by source)
  if (src==nullptr || src_items==false) {
    FXint nadded=(&pane)->numChildren();
    FXint nlast=(&pane)->numChildren();
    for (FXint i=0;i<GMPlayerManager::instance()->getNumSources();i++) {
      if (nadded>1) {
        new FXMenuSeparator(&pane);
        nadded=0;
        nlast+=1;
        }
      if (GMPlayerManager::instance()->getSource(i)->source_menu(&pane)){
        FXint n = (&pane)->numChildren();
        nadded = n - nlast;
        nlast  = n;
        }
      }
    }

  if (item) {
    sourcelist->setCurrentItem(item);
    onCmdSourceSelected(nullptr,0,nullptr); // Simulate SEL_COMMAND
    }

  if (pane.getFirst()){
    pane.create();
    ewmh_change_window_type(&pane,WINDOWTYPE_POPUP_MENU);
    pane.popup(nullptr,event->root_x,event->root_y);
    getApp()->runPopup(&pane);
    }
  return 1;
  }
Ejemplo n.º 6
0
long GMSourceView::onDndSourceMotion(FXObject*,FXSelector,void*ptr){
  FXEvent * event = static_cast<FXEvent*>(ptr);
  GMTreeItem * item = dynamic_cast<GMTreeItem*>(sourcelist->getItemAt(event->win_x,event->win_y));
  if (item) {
    GMSource * src = static_cast<GMSource *>(item->getData());
    FXDragType*types;
    FXuint     ntypes;
    if (sourcelist->inquireDNDTypes(FROM_DRAGNDROP,types,ntypes)){
      if (src->dnd_accepts(types,ntypes)){
        sourcedrop=src;
        sourcelist->acceptDrop(DRAG_ACCEPT);
        freeElms(types);
        return 1;
        }
      freeElms(types);
      }
    }
  sourcedrop=nullptr;
  return 0;
  }
Ejemplo n.º 7
0
FXbool GMSourceView::listsources() {
  GMTreeItem * item=nullptr;
  GMTreeItem * dbitem=nullptr;
  for (FXint i=0;i<GMPlayerManager::instance()->getNumSources();i++){
    GMSource * src = GMPlayerManager::instance()->getSource(i);
    FXIcon * icon=icon_for_sourcetype(src->getType());
    item = new GMTreeItem(src->getName(),icon,icon,src);
    if (src->getType()==SOURCE_DATABASE_FILTER) {
      FXASSERT(dbitem);
      sourcelist->appendItem(dbitem,item);
      dbitem->setExpanded(true);
      }
    else {
      sourcelist->appendItem(nullptr,item);
      }
    if (src->getType()==SOURCE_DATABASE) dbitem=item;
    }
  sourcelist->sortItems();
  return true;
  }
Ejemplo n.º 8
0
long GMSourceView::onSourceContextMenu(FXObject*,FXSelector,void*ptr){
  FXEvent * event = reinterpret_cast<FXEvent*>(ptr);
  if (event->moved) return 0;
  GMTreeItem * item = dynamic_cast<GMTreeItem*>(sourcelist->getItemAt(event->win_x,event->win_y));
  GMMenuPane pane(this);
  GMSource * source = item ? reinterpret_cast<GMSource*>(item->getData()) : NULL;
  FXbool src_items = false;
  
  if (source) 
    src_items = source->source_context_menu(&pane);
      
  //new GMMenuCommand(&pane,tr("New Playlist…\t\tCreate a new playlist"),GMIconTheme::instance()->icon_playlist,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_NEW_PLAYLIST);
  //new GMMenuCommand(&pane,tr("Import Playlist…\t\tImport a existing playlist"),GMIconTheme::instance()->icon_import,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_IMPORT_PLAYLIST);

  if (source && source->canBrowse()) { 
    if (src_items) new FXMenuSeparator(&pane);
    new GMMenuCheck(&pane,tr("Show Browser\tCtrl-B\tShow Browser"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_BROWSER);
    new GMMenuCheck(&pane,tr("Show Tags\tCtrl-T\tShow Tags"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_TAGS);  
    }

  if (item) {
    sourcelist->setCurrentItem(item);
    onCmdSourceSelected(NULL,0,NULL); // Simulate SEL_COMMAND
    }

/*  if (item) {
    GMSource * source = (GMSource*)item->getData();
    if (source) {
      FXbool src_menu = source->source_context_menu(&pane);

      if (source->canBrowse()) {
        if (src_menu) new FXMenuSeparator(&pane);
        new GMMenuCheck(&pane,tr("Show Browser\tCtrl-B\tShow Browser"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_BROWSER);
        new GMMenuCheck(&pane,tr("Show Tags\tCtrl-T\tShow Tags"),GMPlayerManager::instance()->getTrackView(),GMTrackView::ID_TOGGLE_TAGS);
        }
      }
    sourcelist->setCurrentItem(item);
    onCmdSourceSelected(NULL,0,NULL); // Simulate SEL_COMMAND
    }

  if 


  else {
    new GMMenuCommand(&pane,tr("New Playlist…\t\tCreate a new playlist"),GMIconTheme::instance()->icon_playlist,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_NEW_PLAYLIST);
    new GMMenuCommand(&pane,tr("Import Playlist…\t\tImport a existing playlist"),GMIconTheme::instance()->icon_import,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_IMPORT_PLAYLIST);
    }

    //new GMMenuCommand(&pane,tr("New Playlist…\t\tCreate a new playlist"),GMIconTheme::instance()->icon_playlist,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_NEW_PLAYLIST);
    //new GMMenuCommand(&pane,tr("Import Playlist…\t\tImport a existing playlist"),GMIconTheme::instance()->icon_import,GMPlayerManager::instance()->getSource(0),GMDatabaseSource::ID_IMPORT_PLAYLIST);
  //  }
  //else {
 //   new GMMenuCommand(&pane,tr("New Radio Station…\t\tCreate a new playlist"),NULL,this,GMSourceView::ID_NEW_STATION);
    //}
*/    
  if (pane.getFirst()){
    pane.create();
    ewmh_change_window_type(&pane,WINDOWTYPE_POPUP_MENU);
    pane.popup(NULL,event->root_x,event->root_y);
    getApp()->runPopup(&pane);
    }
  return 1;
  }