Exemple #1
0
void RecentManager::updateMenu() {
	XOJ_CHECK_TYPE(RecentManager);

	GtkRecentManager * recentManager = gtk_recent_manager_get_default();
	GList * items = gtk_recent_manager_get_items(recentManager);
	GList * filteredItemsXoj = filterRecent(items, true);
	GList * filteredItemsPdf = filterRecent(items, false);

	freeOldMenus();

	int i = 0;
	for (GList * l = filteredItemsXoj; l != NULL; l = l->next) {
		GtkRecentInfo * info = (GtkRecentInfo *) l->data;

		if (i >= maxRecent) {
			break;
		}
		i++;

		addRecentMenu(info, i);
	}

	GtkWidget * separator = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator);
	gtk_widget_set_visible(GTK_WIDGET(separator), true);
	this->menuItemList = g_list_append(this->menuItemList, separator);

	i = 0;
	for (GList * l = filteredItemsPdf; l != NULL; l = l->next) {
		GtkRecentInfo * info = (GtkRecentInfo *) l->data;

		if (i >= maxRecent) {
			break;
		}
		i++;

		addRecentMenu(info, i + maxRecent);
	}

	g_list_free(filteredItemsXoj);
	g_list_free(filteredItemsPdf);

	g_list_foreach(items, (GFunc) gtk_recent_info_unref, NULL);
	g_list_free(items);
}
void PeopleApplication::createPeoplePage()
{

    //m_AccountManager = AccountManger::getInstance();
    m_mainPage = new MApplicationPage;
    m_mainPage->setTitle(QObject::tr("People","Title of the application"));

    QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(Qt::Vertical);
    linear->setContentsMargins(0, 0, 0, 0);
    linear->setSpacing(0);
    m_mainPage->centralWidget()->setLayout(linear);

    m_topSpacer = new QGraphicsWidget;
    m_topSpacer->setPreferredHeight(0);
    linear->addItem(m_topSpacer);

    m_people = new SeasidePeople;
    linear->addItem(m_people);

    m_bottomSpacer = new QGraphicsWidget;
    m_bottomSpacer->setPreferredHeight(0);
    linear->addItem(m_bottomSpacer); 

    m_actionSearch = new MAction(QObject::tr("Search","Menu action to bring up search for contact list"), this);
    m_actionSearch->setLocation(MAction::ApplicationMenuLocation);
    m_mainPage->addAction(m_actionSearch);
    connect(m_actionSearch, SIGNAL(triggered()), this, SLOT(searchClicked()));

    m_actionAdd = new MAction(QObject::tr("Add Contact","Menu action to add contact"), this);
    m_actionAdd->setLocation(MAction::ApplicationMenuLocation);
    m_mainPage->addAction(m_actionAdd);
    connect(m_actionAdd, SIGNAL(triggered()), this, SLOT(addNewContact()));

    m_actionAll = new MAction(QObject::tr("<b>Show All</b>","Menu filter to show all contacts"), this);  
    m_actionAll->setLocation(MAction::ApplicationMenuLocation);
    m_actionAll->setObjectName("ShowAllFilter");
    m_actionAll->setCheckable(true);
    connect(m_actionAll, SIGNAL(triggered()), m_people, SLOT(filterAll()));

    m_actionFav = new MAction(QObject::tr("Show Favorites", "Menu filter to show all contacts marked as favorites"), this);
    m_actionFav->setLocation(MAction::ApplicationMenuLocation);
    m_actionFav->setObjectName("ShowFavoritesFilter");
    m_actionFav->setCheckable(true);
    connect(m_actionFav, SIGNAL(triggered()), m_people, SLOT(filterFavorites()));

    m_actionRecent = new MAction(QObject::tr("Show Recent","Menu filter to show all contacts with recent communications"), this);
    m_actionRecent->setLocation(MAction::ApplicationMenuLocation);
    m_actionRecent->setCheckable(true);
    m_actionRecent->setObjectName("ShowRecentFilter");
    connect(m_actionRecent, SIGNAL(triggered()), m_people, SLOT(filterRecent()));

    m_actionFilters = new QActionGroup(this);
    m_actionFilters->addAction(m_actionAll);
    m_actionFilters->addAction(m_actionRecent);
    m_actionFilters->addAction(m_actionFav);
    m_actionFilters->setExclusive(true);
    m_mainPage->addActions(m_actionFilters->actions());
    connect(m_actionFilters, SIGNAL(triggered(QAction*)), this, SLOT(menuFilterSelected(QAction*)));

    connect(m_people, SIGNAL(itemClicked(QModelIndex)),
            this, SLOT(createDetailPage(QModelIndex)));
    connect(m_people, SIGNAL(editRequest(QModelIndex)),
            this, SLOT(createEditPage(QModelIndex)));

    connect(m_people, SIGNAL(callNumber(const QString&)),
            this, SLOT(callNumber(const QString&)));
    connect(m_people, SIGNAL(composeSMS(const QString&)),
            this, SLOT(composeSMS(const QString&)));
    connect(m_people, SIGNAL(composeIM(const QString&)),
            this, SLOT(composeIM(const QString&)));
    connect(m_people, SIGNAL(composeEmail(const QString&)),
            this, SLOT(composeEmail(const QString&)));

    m_mainPage->appear();

    initSlider();
    initSearch();
    repositionOverlays();
}