Back to index

libappindicator  12.10.0
Classes | Defines | Typedefs | Enumerations | Functions | Variables
test-libappindicator-fallback-item.c File Reference
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
#include <app-indicator.h>

Go to the source code of this file.

Classes

struct  _TestLibappindicatorFallbackItemClass
struct  _TestLibappindicatorFallbackItem

Defines

#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE   (test_libappindicator_fallback_item_get_type ())
#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItem))
#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass))
#define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE))
#define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE))
#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass))
#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemPrivate))

Typedefs

typedef struct _TestLibappindicatorFallbackItem
typedef struct _TestLibappindicatorFallbackItemClass

Enumerations

enum  {
  STATE_INIT, STATE_FALLBACK, STATE_UNFALLBACK, STATE_REFALLBACK,
  STATE_REUNFALLBACK
}

Functions

GType test_libappindicator_fallback_item_get_type (void)
static void test_libappindicator_fallback_item_class_init (TestLibappindicatorFallbackItemClass *klass)
static void test_libappindicator_fallback_item_init (TestLibappindicatorFallbackItem *self)
static GtkStatusIcon * fallback (AppIndicator *indicator)
static void unfallback (AppIndicator *indicator, GtkStatusIcon *status_icon)
 G_DEFINE_TYPE (TestLibappindicatorFallbackItem, test_libappindicator_fallback_item, APP_INDICATOR_TYPE)
gboolean kill_func (gpointer data)
int main (int argc, char **argv)

Variables

GMainLoop * mainloop = NULL
gboolean passed = FALSE
gint state = STATE_INIT

Class Documentation

struct _TestLibappindicatorFallbackItemClass

Definition at line 17 of file test-libappindicator-fallback-item.c.

Class Members
AppIndicatorClass parent_class
struct _TestLibappindicatorFallbackItem

Definition at line 22 of file test-libappindicator-fallback-item.c.

Collaboration diagram for _TestLibappindicatorFallbackItem:
Class Members
AppIndicator parent

Define Documentation

#define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE))

Definition at line 10 of file test-libappindicator-fallback-item.c.

#define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE))

Definition at line 11 of file test-libappindicator-fallback-item.c.

#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItem))

Definition at line 8 of file test-libappindicator-fallback-item.c.

#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass))

Definition at line 9 of file test-libappindicator-fallback-item.c.

#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass))

Definition at line 12 of file test-libappindicator-fallback-item.c.

#define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_PRIVATE (   o)    (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemPrivate))

Definition at line 29 of file test-libappindicator-fallback-item.c.

Definition at line 7 of file test-libappindicator-fallback-item.c.


Typedef Documentation

Definition at line 14 of file test-libappindicator-fallback-item.c.

Definition at line 15 of file test-libappindicator-fallback-item.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
STATE_INIT 
STATE_FALLBACK 
STATE_UNFALLBACK 
STATE_REFALLBACK 
STATE_REUNFALLBACK 

Definition at line 56 of file test-libappindicator-fallback-item.c.


Function Documentation

static GtkStatusIcon * fallback ( AppIndicator *  indicator) [static]

Definition at line 67 of file test-libappindicator-fallback-item.c.

{
       g_debug("Fallback");
       if (state == STATE_INIT) {
              state = STATE_FALLBACK;
       } else if (state == STATE_UNFALLBACK) {
              state = STATE_REFALLBACK;
       } else {
              g_debug("Error, fallback in state: %d", state);
              passed = FALSE;
       }
       return (GtkStatusIcon *)5;
}

Here is the caller graph for this function:

G_DEFINE_TYPE ( TestLibappindicatorFallbackItem  ,
test_libappindicator_fallback_item  ,
APP_INDICATOR_TYPE   
)
gboolean kill_func ( gpointer  data)

Definition at line 99 of file test-libappindicator-fallback-item.c.

{
       g_debug("Kill Function");
       g_main_loop_quit(mainloop);
       return FALSE;
}
int main ( int  argc,
char **  argv 
)

Definition at line 107 of file test-libappindicator-fallback-item.c.

{
       gtk_init(&argc, &argv);

       GError * error = NULL;
       DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
       if (error != NULL) {
              g_error("Unable to get session bus: %s", error->message);
              return 1;
       }

    DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);

       guint nameret = 0;

       if (!org_freedesktop_DBus_request_name(bus_proxy, "org.test", 0, &nameret, NULL)) {
              g_error("Unable to call to request name");
              return 1;
       }   

       if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
              g_error("Unable to get name");
              return 1;
       }

       TestLibappindicatorFallbackItem * item = g_object_new(TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE,
              "id", "test-id",
              "category", "Other",
              "icon-name", "bob",
              NULL);
       
       GtkWidget * menu = gtk_menu_new();
       app_indicator_set_menu(APP_INDICATOR(item), GTK_MENU(menu));

       g_timeout_add_seconds(2, kill_func, NULL);

       mainloop = g_main_loop_new(NULL, FALSE);
       g_main_loop_run(mainloop);

       g_object_unref(G_OBJECT(item));

       if (passed) {
              return 0;
       } else {
              return 1;
       }
}

Here is the call graph for this function:

static void test_libappindicator_fallback_item_class_init ( TestLibappindicatorFallbackItemClass *  klass) [static]

Definition at line 40 of file test-libappindicator-fallback-item.c.

{
       AppIndicatorClass * aiclass = APP_INDICATOR_CLASS(klass);

       aiclass->fallback = fallback;
       aiclass->unfallback = unfallback;
}

Here is the call graph for this function:

static void test_libappindicator_fallback_item_init ( TestLibappindicatorFallbackItem *  self) [static]

Definition at line 49 of file test-libappindicator-fallback-item.c.

{
}
static void unfallback ( AppIndicator *  indicator,
GtkStatusIcon *  status_icon 
) [static]

Definition at line 82 of file test-libappindicator-fallback-item.c.

{
       g_debug("Unfallback");
       if (state == STATE_FALLBACK) {
              state = STATE_UNFALLBACK;
       } else if (state == STATE_REFALLBACK) {
              state = STATE_REUNFALLBACK;
              passed = TRUE;
              g_main_loop_quit(mainloop);
       } else {
              g_debug("Error, unfallback in state: %d", state);
              passed = FALSE;
       }
       return;
}

Here is the caller graph for this function:


Variable Documentation

GMainLoop* mainloop = NULL

Definition at line 53 of file test-libappindicator-fallback-item.c.

gboolean passed = FALSE

Definition at line 54 of file test-libappindicator-fallback-item.c.

gint state = STATE_INIT

Definition at line 64 of file test-libappindicator-fallback-item.c.