Back to index

libindicate  12.10.0
Functions | Variables
im-client.c File Reference
#include <glib.h>
#include "libindicate/server.h"
#include "libindicate/indicator.h"
#include "libindicate-gtk/indicator.h"

Go to the source code of this file.

Functions

static gboolean timeout_cb (gpointer data)
static void display (IndicateIndicator *indicator, gpointer data)
static void server_display (IndicateServer *server, gpointer data)
static void interest_added (IndicateServer *server, IndicateInterests interest)
void interest_removed (IndicateServer *server, IndicateInterests interest)
void menuitem_click (DbusmenuMenuitem *menuitem, guint timestamp, gpointer data)
int main (int argc, char **argv)

Variables

gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png"
gchar * pathb = "/usr/share/icons/hicolor/22x22/apps/empathy.png"
gchar * lastpath = NULL

Function Documentation

static void display ( IndicateIndicator *  indicator,
gpointer  data 
) [static]

Definition at line 58 of file im-client.c.

{
       g_debug("Ah, my indicator has been displayed");
}

Here is the caller graph for this function:

static void interest_added ( IndicateServer *  server,
IndicateInterests  interest 
) [static]

Definition at line 70 of file im-client.c.

{
       g_debug("Oh, someone is interested in me for: %d", interest);
}

Here is the caller graph for this function:

void interest_removed ( IndicateServer *  server,
IndicateInterests  interest 
)

Definition at line 76 of file im-client.c.

{
       g_debug("Someone is no longer interested in my for: %d", interest);
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 88 of file im-client.c.

{
       g_type_init();

       IndicateServer * server = indicate_server_ref_default();
       indicate_server_set_type(server, "message.im");
       indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop");
       g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, G_CALLBACK(server_display), NULL);
       g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL);
       g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, G_CALLBACK(interest_removed), NULL);

       DbusmenuServer * dmserver = dbusmenu_server_new("/dbusmenu/path");
       DbusmenuMenuitem * root = dbusmenu_menuitem_new();
       dbusmenu_server_set_root(dmserver, root);
       DbusmenuMenuitem * item;

       item = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Label 1");
       dbusmenu_menuitem_child_append(root, item);
       g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_click), "Label 1");

       item = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Label 2");
       dbusmenu_menuitem_child_append(root, item);
       g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_click), "Label 2");

       indicate_server_set_menu(server, dmserver);

       IndicateIndicator * indicator;

       indicator = indicate_indicator_new();
       indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im");
       indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test");
       GTimeVal time; g_get_current_time(&time);
       indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);
       indicate_indicator_show(INDICATE_INDICATOR(indicator));

       g_get_current_time(&time);
       indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);

       g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAY, G_CALLBACK(display), NULL);

       g_timeout_add_seconds(180, timeout_cb, indicator);

       g_main_loop_run(g_main_loop_new(NULL, FALSE));

       return 0;
}

Here is the call graph for this function:

void menuitem_click ( DbusmenuMenuitem *  menuitem,
guint  timestamp,
gpointer  data 
)

Definition at line 82 of file im-client.c.

{
       g_debug("Menuitem '%s' clicked at %d", (gchar *)data, timestamp);
}

Here is the caller graph for this function:

static void server_display ( IndicateServer *  server,
gpointer  data 
) [static]

Definition at line 64 of file im-client.c.

{
       g_debug("Ah, my server has been displayed");
}

Here is the caller graph for this function:

static gboolean timeout_cb ( gpointer  data) [static]

Definition at line 32 of file im-client.c.

{
       g_debug("Modifying properties");

       IndicateIndicator * indicator = INDICATE_INDICATOR(data);

       GTimeVal time;
       g_get_current_time(&time);
       indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);

       if (lastpath == patha) {
              lastpath = pathb;
       } else {
              lastpath = patha;
       }
       
       GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(lastpath, NULL);
       g_return_val_if_fail(pixbuf != NULL, TRUE);

       indicate_gtk_indicator_set_property_icon(INDICATE_INDICATOR(indicator), "icon", pixbuf);
       g_object_unref(G_OBJECT(pixbuf));

       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

gchar* lastpath = NULL

Definition at line 29 of file im-client.c.

gchar* patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png"

Definition at line 27 of file im-client.c.

gchar* pathb = "/usr/share/icons/hicolor/22x22/apps/empathy.png"

Definition at line 28 of file im-client.c.