Created
October 24, 2012 00:41
-
-
Save chergert/3943022 to your computer and use it in GitHub Desktop.
example for status icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "dropline-status-icon.h" | |
G_DEFINE_TYPE(DroplineStatusIcon, dropline_status_icon, GTK_TYPE_STATUS_ICON) | |
struct _DroplineStatusIconPrivate | |
{ | |
/* | |
* XXX: Put stuff you need during runtime here. | |
*/ | |
gpointer dummy; | |
}; | |
GtkStatusIcon * | |
dropline_status_icon_new (void) | |
{ | |
return g_object_new(DROPLINE_TYPE_STATUS_ICON, | |
"icon-name", GTK_STOCK_EXECUTE, /* you can also use "file", "gicon", or "pixbuf". */ | |
NULL); | |
/* when you want to show this, use gtk_status_icon_set_visible(status_icon, TRUE) */ | |
} | |
static void | |
dropline_status_icon_finalize (GObject *object) | |
{ | |
DroplineStatusIconPrivate *priv; | |
priv = DROPLINE_STATUS_ICON(object)->priv; | |
/* | |
* XXX: Free stuff in _DroplineStatusIconPrivate here. | |
*/ | |
G_OBJECT_CLASS(dropline_status_icon_parent_class)->finalize(object); | |
} | |
static void | |
dropline_status_icon_class_init (DroplineStatusIconClass *klass) | |
{ | |
GObjectClass *object_class; | |
object_class = G_OBJECT_CLASS(klass); | |
object_class->finalize = dropline_status_icon_finalize; | |
g_type_class_add_private(object_class, sizeof(DroplineStatusIconPrivate)); | |
} | |
static void | |
dropline_status_icon_init (DroplineStatusIcon *icon) | |
{ | |
icon->priv = | |
G_TYPE_INSTANCE_GET_PRIVATE(icon, | |
DROPLINE_TYPE_STATUS_ICON, | |
DroplineStatusIconPrivate); | |
/* | |
* XXX: Initialize anything you need here, like perhaps setting | |
* the icon. | |
*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef DROPLINE_STATUS_ICON_H | |
#define DROPLINE_STATUS_ICON_H | |
#include <gtk/gtk.h> | |
G_BEGIN_DECLS | |
#define DROPLINE_TYPE_STATUS_ICON (dropline_status_icon_get_type()) | |
#define DROPLINE_STATUS_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DROPLINE_TYPE_STATUS_ICON, DroplineStatusIcon)) | |
#define DROPLINE_STATUS_ICON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DROPLINE_TYPE_STATUS_ICON, DroplineStatusIcon const)) | |
#define DROPLINE_STATUS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DROPLINE_TYPE_STATUS_ICON, DroplineStatusIconClass)) | |
#define DROPLINE_IS_STATUS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DROPLINE_TYPE_STATUS_ICON)) | |
#define DROPLINE_IS_STATUS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DROPLINE_TYPE_STATUS_ICON)) | |
#define DROPLINE_STATUS_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DROPLINE_TYPE_STATUS_ICON, DroplineStatusIconClass)) | |
typedef struct _DroplineStatusIcon DroplineStatusIcon; | |
typedef struct _DroplineStatusIconClass DroplineStatusIconClass; | |
typedef struct _DroplineStatusIconPrivate DroplineStatusIconPrivate; | |
struct _DroplineStatusIcon | |
{ | |
GtkStatusIcon parent; | |
/*< private >*/ | |
DroplineStatusIconPrivate *priv; | |
}; | |
struct _DroplineStatusIconClass | |
{ | |
GtkStatusIconClass parent_class; | |
}; | |
GType dropline_status_icon_get_type (void) G_GNUC_CONST; | |
GtkStatusIcon *dropline_status_icon_new (void); | |
G_END_DECLS | |
#endif /* DROPLINE_STATUS_ICON_H */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment