×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Question how can i display notification on N900 screen?

    hello every body;
    how can i display notification on N900 screen.
    i think this is done using c ,how can i do that .
    thank you

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    82

    Re: how can i display notification on N900 screen?

    Quote Originally Posted by mismael View Post
    hello every body;
    how can i display notification on N900 screen.
    i think this is done using c ,how can i do that .
    thank you
    Check out how modest does it.

    https://git.maemo.org/projects/modes...form.c;hb=HEAD

    Function modest_platform_on_new_headers_received()

    As you can see, it also provides dbus callback to execute when pressing the displayed notification.

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: how can i display notification on N900 screen?

    There are basically two ways of doing it. First one is to use HildonBanner:
    http://maemo.org/api_refs/5.0/5.0-fi...donBanner.html
    and second one is to use libnotify (modest is using libhildon-notify, which is wrapper over libnotify):
    http://maemo.org/api_refs/5.0/5.0-fi...ification.html

    You can use those functions from Qt code as well, just add
    Code:
    CONFIG += link_pkgconfig
    PKGCONFIG += hildon-1
    or
    Code:
    CONFIG += link_pkgconfig
    PKGCONFIG += libnotify
    to the project file.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Re: how can i display notification on N900 screen?

    i found the library libnotify i used some functions from it
    NotifyNotification* notification =notify_notification_new ("any string", NULL, NULL, NULL);
    notify_notification_show(notification,NULL);
    and i included the file "libnotify/notify.h" in my application .
    and i added the following libararies to my .pro file
    -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -lnotify -lgtk-x11-2.0 -ldbus-glib-1 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgmodule-2.0 -ldbus-1 -lpthread -lgobject-2.0 -lglib-2.0
    but after all of this i got some errors like this
    In file included from /targets/FREMANTLE_ARMEL/usr/include/gtk-2.0/gtk/gtk.h:47,
    from /usr/include/libnotify/notification.h:27,
    from /usr/include/libnotify/notify.h:27,
    from main.cpp:8:
    /targets/FREMANTLE_ARMEL/usr/include/gtk-2.0/gtk/gtkbindings.h:79: error: expected unqualified-id before 'protected'
    /targets/FREMANTLE_ARMEL/usr/include/gtk-2.0/gtk/gtkbindings.h:79: error: expected ';' before 'protected'
    make: *** [main.o] Error 1
    what is the problem?
    Last edited by mismael; 2010-01-13 at 10:20.

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Re: how can i display notification on N900 screen?

    i am sorry i have a problem in internet connection so the post are sent twice.
    how can i delete a post?
    Last edited by mismael; 2010-01-13 at 10:19.

  6. #6
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    82

    Re: how can i display notification on N900 screen?

    Quote Originally Posted by mismael View Post
    and i included the file "libnotify/notify.h" in my application .
    and i added the following libararies to my .pro file
    Please use pkgconfig as instructed by Daniil:
    Code:
    CONFIG += link_pkgconfig
    PKGCONFIG += libnotify
    Even if you got your your .pro file (where you explicitly specify everything) to work, it would still get screwed up sooner or later.

  7. #7
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Re: how can i display notification on N900 screen?

    i deleted all the libraries i added by hand and i used
    CONFIG += link_pkgconfig
    PKGCONFIG += libnotify
    but i still get the same error

  8. #8
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    82

    Re: how can i display notification on N900 screen?

    Ah, the problem is "signals" macro definition by Qt.

    Try doing '#undef signals' before including notify.h

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: how can i display notification on N900 screen?

    This sample works for me:

    Code:
    #include <libnotify/notify.h>
    
    #include <QApplication>
    #include <QMainWindow>
    #include <QDebug>
    
    int
    main (int argc,
          char **argv)
    {
        const char name[] = "Qt sample notification app";
        NotifyNotification *notification;
        QApplication app(argc, argv);
        QMainWindow win;
    
        notify_init(name);
    
        win.show();
    
        notification = notify_notification_new(name, "Just want you to know...", NULL, NULL);
        if (notification) {
            notify_notification_set_timeout(notification, 3000);
            if (!notify_notification_show(notification, NULL))
                qDebug("Failed to send notification");
    
            g_object_unref(notification);
        } else
            qDebug("Failed to create notification");
    
        return app.exec();
    }

  10. #10
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    82

    Re: how can i display notification on N900 screen?

    Quote Originally Posted by divanov View Post
    This sample works for me:
    Yeah, the key here is that you include notify.h before Qt gets a chance to '#define signals'.

  11. #11
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Re: how can i display notification on N900 screen?

    realy
    #include <libnotify/notify.h>
    should be included at the first line in the program

  12. #12
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Re: how can i display notification on N900 screen?

    it's not showing any message on the yellow stripe bar :\ how do I convert a QString to gchar?

    I tried this and it's not showing anything...

    void MainWindow::showMessage(const QString &title, const QString &msg,
    QMessageBox::Icon icon) {

    NotifyNotification *notification;

    notification = notify_notification_new(title.toLatin1(), msg.toLatin1(), NULL, NULL);
    if (notification) {
    notify_notification_set_timeout(notification, 3000);
    if (!notify_notification_show(notification, NULL))
    qDebug("Failed to send notification");

    g_object_unref(notification);
    } else
    qDebug("Failed to create notification");
    }

    what am I doing wrong?

  13. #13
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: how can i display notification on N900 screen?

    QString::toLatin1() returns QByteArray. Using QString::data() or QString::constData() looks more promising.

Similar Threads

  1. set the display on the screen
    By Abhishek_karmakar in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-08-05, 13:37
  2. Showing display screen of a MIDlet using TV-out.
    By ThereseM in forum Mobile Java General
    Replies: 6
    Last Post: 2006-07-14, 20:14
  3. Replies: 1
    Last Post: 2005-11-26, 19:08
  4. Can't return display to full screen??
    By danparks in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-10-10, 05:32
  5. How to display tab screen?
    By bittony in forum Symbian
    Replies: 0
    Last Post: 2004-08-18, 08:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×