Example #1
0
static void *Run (void *data)
{
    services_discovery_t *sd = data;
    services_discovery_sys_t *p_sys = sd->p_sys;
    xcb_connection_t *conn = p_sys->conn;
    int fd = xcb_get_file_descriptor (conn);
    if (fd == -1)
        return NULL;

    while (!xcb_connection_has_error (conn))
    {
        xcb_generic_event_t *ev;
        struct pollfd ufd = { .fd = fd, .events = POLLIN, };

        poll (&ufd, 1, -1);

        int canc = vlc_savecancel ();
        while ((ev = xcb_poll_for_event (conn)) != NULL)
        {
            if ((ev->response_type & 0x7F) == XCB_PROPERTY_NOTIFY)
            {
                 const xcb_property_notify_event_t *pn =
                     (xcb_property_notify_event_t *)ev;
                 if (pn->atom == p_sys->net_client_list)
                     UpdateApps (sd);
            }
            free (ev);
        }
        vlc_restorecancel (canc);
    }
    return NULL;
}
Example #2
0
StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){
  ui->setupUi(this); //load the designer file
  sysapps = LSession::handle()->applicationMenu()->currentAppHash();
  connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) );
  UpdateAll();
  QTimer::singleShot(10, this,SLOT(UpdateApps()));
  QTimer::singleShot(10, this, SLOT(UpdateFavs()));
}
int CPreviewApps::GetAllMenuEntries(CMenu& rMenu, const CPartFile* file)
{
	UpdateApps();

	for (int i = 0; i < m_aApps.GetCount(); i++)
	{
		const SPreviewApp& rSvc = m_aApps.GetAt(i);
		if (MP_PREVIEW_APP_MIN + i > MP_PREVIEW_APP_MAX)
			break;
		bool bEnabled = false;
		if (file)
		{
			if (file->GetCompletedSize() >= 16*1024)
				bEnabled = true;
		}
		rMenu.AppendMenu(MF_STRING | (bEnabled ? MF_ENABLED : MF_GRAYED), MP_PREVIEW_APP_MIN + i, rSvc.strTitle);
	}
	return m_aApps.GetCount();
}
Example #4
0
StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){
  ui->setupUi(this); //load the designer file
  this->setMouseTracking(true);
  searchTimer = new QTimer(this);
    searchTimer->setInterval(300); //~1/3 second
    searchTimer->setSingleShot(true);
  connect(searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()) );
  sysapps = LSession::handle()->applicationMenu()->currentAppHash();
  connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) );
  //Need to load the last used setting of the application list
  QString state = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/systemstart/showcategories", "partial").toString();
  if(state=="partial"){ui->check_apps_showcats->setCheckState(Qt::PartiallyChecked); }
  else if(state=="true"){ ui->check_apps_showcats->setCheckState(Qt::Checked); }
  else{ ui->check_apps_showcats->setCheckState(Qt::Unchecked); }
  connect(ui->check_apps_showcats, SIGNAL(stateChanged(int)), this, SLOT(catViewChanged()) );
  UpdateAll();
  QTimer::singleShot(10, this,SLOT(UpdateApps()));
  QTimer::singleShot(10, this, SLOT(UpdateFavs()));
}
int CPreviewApps::GetPreviewApp(const CPartFile* file)
{
	LPCTSTR pszExt = PathFindExtension(file->GetFileName());
	if (pszExt == NULL)
		return -1;

	UpdateApps();

	int iApp = -1;
	for (int i = 0; iApp == -1 && i < m_aApps.GetCount(); i++)
	{
		const SPreviewApp& rApp = m_aApps.GetAt(i);
		for (int j = 0; j < rApp.astrExtensions.GetCount(); j++)
		{
			if (rApp.astrExtensions.GetAt(j).CompareNoCase(pszExt) == 0) {
				iApp = i;
				break;
			}
		}
	}

	return iApp;
}
Example #6
0
void StartMenu::ChangeCategory(QString cat){
  //This only happens on user interaction - make sure to run the update routine in a separate thread
  CCat = cat;
  UpdateApps();
  //QtConcurrent::run(this, &StartMenu::UpdateApps);
}
Example #7
0
/**
 * Probes and initializes.
 */
static int Open (vlc_object_t *obj)
{
    services_discovery_t *sd = (services_discovery_t *)obj;
    services_discovery_sys_t *p_sys = malloc (sizeof (*p_sys));

    if (p_sys == NULL)
        return VLC_ENOMEM;
    sd->p_sys = p_sys;
    sd->description = _("Screen capture");

    /* Connect to X server */
    char *display = var_InheritString (obj, "x11-display");
    int snum;
    xcb_connection_t *conn = xcb_connect (display, &snum);
    free (display);
    if (xcb_connection_has_error (conn))
    {
        free (p_sys);
        return VLC_EGENERIC;
    }
    p_sys->conn = conn;

    /* Find configured screen */
    const xcb_setup_t *setup = xcb_get_setup (conn);
    const xcb_screen_t *scr = NULL;
    for (xcb_screen_iterator_t i = xcb_setup_roots_iterator (setup);
         i.rem > 0; xcb_screen_next (&i))
    {
        if (snum == 0)
        {
            scr = i.data;
            break;
        }
        snum--;
    }
    if (scr == NULL)
    {
        msg_Err (obj, "bad X11 screen number");
        goto error;
    }

    /* Add a permanent item for the entire desktop */
    AddDesktop (sd);

    p_sys->root_window = scr->root;
    xcb_change_window_attributes (conn, scr->root, XCB_CW_EVENT_MASK,
                               &(uint32_t) { XCB_EVENT_MASK_PROPERTY_CHANGE });

    /* TODO: check that _NET_CLIENT_LIST is in _NET_SUPPORTED
     * (and _NET_SUPPORTING_WM_CHECK) */
    xcb_intern_atom_reply_t *r;
    xcb_intern_atom_cookie_t ncl, nwn;

    ncl = xcb_intern_atom (conn, 1, strlen ("_NET_CLIENT_LIST"),
                          "_NET_CLIENT_LIST");
    nwn = xcb_intern_atom (conn, 0, strlen ("_NET_WM_NAME"), "_NET_WM_NAME");

    r = xcb_intern_atom_reply (conn, ncl, NULL);
    if (r == NULL || r->atom == 0)
    {
        vlc_dialog_display_error (sd, _("Screen capture"),
            _("Your window manager does not provide a list of applications."));
        msg_Err (sd, "client list not supported (_NET_CLIENT_LIST absent)");
    }
    p_sys->net_client_list = r ? r->atom : 0;
    free (r);
    r = xcb_intern_atom_reply (conn, nwn, NULL);
    if (r != NULL)
    {
        p_sys->net_wm_name = r->atom;
        free (r);
    }

    p_sys->apps = NULL;
    p_sys->apps_root = input_item_NewExt("vlc://nop", _("Applications"), -1,
                                         ITEM_TYPE_NODE, ITEM_LOCAL);
    if (likely(p_sys->apps_root != NULL))
        services_discovery_AddItem(sd, p_sys->apps_root);

    UpdateApps (sd);

    if (vlc_clone (&p_sys->thread, Run, sd, VLC_THREAD_PRIORITY_LOW))
        goto error;
    return VLC_SUCCESS;

error:
    xcb_disconnect (p_sys->conn);
    tdestroy (p_sys->apps, DelApp);
    if (p_sys->apps_root != NULL)
        input_item_Release(p_sys->apps_root);
    free (p_sys);
    return VLC_EGENERIC;
}