mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
API: Remove GtkStatusIcon
This commit is contained in:
parent
c0276e2c5c
commit
d2a8667f83
@ -1023,7 +1023,6 @@ gtk_use_x11_c_sources = \
|
||||
gtkplug.c \
|
||||
gtksocket.c \
|
||||
gtkxembed.c \
|
||||
deprecated/gtktrayicon-x11.c \
|
||||
gtkapplication-x11.c \
|
||||
gtkmountoperation-x11.c
|
||||
|
||||
@ -1047,7 +1046,6 @@ gtk_use_stub_c_sources = \
|
||||
gtkmountoperation-stub.c
|
||||
gtk_use_x11_private_h_sources = \
|
||||
gtkxembed.h \
|
||||
deprecated/gtktrayicon.h \
|
||||
xembed.h
|
||||
if USE_X11
|
||||
gtk_c_sources += $(gtk_use_x11_c_sources)
|
||||
|
@ -23,7 +23,6 @@ deprecated_h_sources = \
|
||||
deprecated/gtkradioaction.h \
|
||||
deprecated/gtkrc.h \
|
||||
deprecated/gtkrecentaction.h \
|
||||
deprecated/gtkstatusicon.h \
|
||||
deprecated/gtkstock.h \
|
||||
deprecated/gtkstyle.h \
|
||||
deprecated/gtkstyleproperties.h \
|
||||
@ -72,7 +71,6 @@ deprecated_c_sources = \
|
||||
deprecated/gtkradioaction.c \
|
||||
deprecated/gtkrc.c \
|
||||
deprecated/gtkrecentaction.c \
|
||||
deprecated/gtkstatusicon.c \
|
||||
deprecated/gtkstock.c \
|
||||
deprecated/gtkstyle.c \
|
||||
deprecated/gtkstyleproperties.c \
|
||||
|
@ -1,145 +0,0 @@
|
||||
/* gtkstatusicon-quartz.c:
|
||||
*
|
||||
* Copyright (C) 2006 Imendio AB
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* GCC on Mac OS X handles inlined objective C in C-files.
|
||||
*
|
||||
* Authors:
|
||||
* Mikael Hallendal <micke@imendio.com>
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <quartz/gdkquartz.h>
|
||||
|
||||
#define QUARTZ_POOL_ALLOC NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]
|
||||
#define QUARTZ_POOL_RELEASE [pool release]
|
||||
|
||||
@interface GtkQuartzStatusIcon : NSObject
|
||||
{
|
||||
GtkStatusIcon *status_icon;
|
||||
NSStatusBar *ns_bar;
|
||||
NSStatusItem *ns_item;
|
||||
NSImage *current_image;
|
||||
NSString *ns_tooltip;
|
||||
}
|
||||
- (id) initWithStatusIcon:(GtkStatusIcon *)status_icon;
|
||||
- (void) ensureItem;
|
||||
- (void) actionCb:(NSObject *)button;
|
||||
- (void) setImage:(GdkPixbuf *)pixbuf;
|
||||
- (void) setVisible:(gboolean)visible;
|
||||
- (void) setToolTip:(const gchar *)tooltip_text;
|
||||
- (float) getWidth;
|
||||
- (float) getHeight;
|
||||
@end
|
||||
|
||||
@implementation GtkQuartzStatusIcon : NSObject
|
||||
- (id) initWithStatusIcon:(GtkStatusIcon *)icon
|
||||
{
|
||||
[super init];
|
||||
status_icon = icon;
|
||||
ns_bar = [NSStatusBar systemStatusBar];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) ensureItem
|
||||
{
|
||||
if (ns_item != nil)
|
||||
return;
|
||||
|
||||
ns_item = [ns_bar statusItemWithLength:NSVariableStatusItemLength];
|
||||
[ns_item setAction:@selector(actionCb:)];
|
||||
[ns_item setTarget:self];
|
||||
[ns_item retain];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[current_image release];
|
||||
[ns_item release];
|
||||
[ns_bar release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) actionCb:(NSObject *)button
|
||||
{
|
||||
NSEvent *event = [NSApp currentEvent];
|
||||
double time = [event timestamp];
|
||||
|
||||
g_signal_emit (status_icon,
|
||||
status_icon_signals [POPUP_MENU_SIGNAL], 0,
|
||||
1,
|
||||
time * 1000.0);
|
||||
}
|
||||
|
||||
- (void) setImage:(GdkPixbuf *)pixbuf
|
||||
{
|
||||
/* Support NULL */
|
||||
[self ensureItem];
|
||||
|
||||
if (current_image != nil) {
|
||||
[current_image release];
|
||||
current_image = nil;
|
||||
}
|
||||
|
||||
if (!pixbuf) {
|
||||
[ns_item release];
|
||||
ns_item = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
current_image = gdk_quartz_pixbuf_to_ns_image_libgtk_only (pixbuf);
|
||||
[current_image retain];
|
||||
|
||||
[ns_item setImage:current_image];
|
||||
}
|
||||
|
||||
- (void) setVisible:(gboolean)visible
|
||||
{
|
||||
if (visible) {
|
||||
[self ensureItem];
|
||||
if (ns_item != nil)
|
||||
[ns_item setImage:current_image];
|
||||
if (ns_tooltip != nil)
|
||||
[ns_item setToolTip:ns_tooltip];
|
||||
} else {
|
||||
[ns_item release];
|
||||
ns_item = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setToolTip:(const gchar *)tooltip_text
|
||||
{
|
||||
[ns_tooltip release];
|
||||
ns_tooltip = [[NSString stringWithUTF8String:tooltip_text] retain];
|
||||
|
||||
[ns_item setToolTip:ns_tooltip];
|
||||
}
|
||||
|
||||
- (float) getWidth
|
||||
{
|
||||
return [ns_bar thickness];
|
||||
}
|
||||
|
||||
- (float) getHeight
|
||||
{
|
||||
return [ns_bar thickness];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,182 +0,0 @@
|
||||
/* gtkstatusicon.h:
|
||||
*
|
||||
* Copyright (C) 2003 Sun Microsystems, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Mark McLoughlin <mark@skynet.ie>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_STATUS_ICON_H__
|
||||
#define __GTK_STATUS_ICON_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkimage.h>
|
||||
#include <gtk/gtkmenu.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_STATUS_ICON (gtk_status_icon_get_type ())
|
||||
#define GTK_STATUS_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STATUS_ICON, GtkStatusIcon))
|
||||
#define GTK_STATUS_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_STATUS_ICON, GtkStatusIconClass))
|
||||
#define GTK_IS_STATUS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STATUS_ICON))
|
||||
#define GTK_IS_STATUS_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_STATUS_ICON))
|
||||
#define GTK_STATUS_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STATUS_ICON, GtkStatusIconClass))
|
||||
|
||||
typedef struct _GtkStatusIcon GtkStatusIcon;
|
||||
typedef struct _GtkStatusIconClass GtkStatusIconClass;
|
||||
typedef struct _GtkStatusIconPrivate GtkStatusIconPrivate;
|
||||
|
||||
struct _GtkStatusIcon
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkStatusIconPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkStatusIconClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* activate) (GtkStatusIcon *status_icon);
|
||||
void (* popup_menu) (GtkStatusIcon *status_icon,
|
||||
guint button,
|
||||
guint32 activate_time);
|
||||
gboolean (* size_changed) (GtkStatusIcon *status_icon,
|
||||
gint size);
|
||||
gboolean (* button_press_event) (GtkStatusIcon *status_icon,
|
||||
GdkEventButton *event);
|
||||
gboolean (* button_release_event) (GtkStatusIcon *status_icon,
|
||||
GdkEventButton *event);
|
||||
gboolean (* scroll_event) (GtkStatusIcon *status_icon,
|
||||
GdkEventScroll *event);
|
||||
gboolean (* query_tooltip) (GtkStatusIcon *status_icon,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean keyboard_mode,
|
||||
GtkTooltip *tooltip);
|
||||
|
||||
void (*__gtk_reserved1);
|
||||
void (*__gtk_reserved2);
|
||||
void (*__gtk_reserved3);
|
||||
void (*__gtk_reserved4);
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_status_icon_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkStatusIcon *gtk_status_icon_new (void);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkStatusIcon *gtk_status_icon_new_from_pixbuf (GdkPixbuf *pixbuf);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkStatusIcon *gtk_status_icon_new_from_file (const gchar *filename);
|
||||
GDK_DEPRECATED_IN_3_10_FOR(gtk_status_icon_new_from_icon_name)
|
||||
GtkStatusIcon *gtk_status_icon_new_from_stock (const gchar *stock_id);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkStatusIcon *gtk_status_icon_new_from_icon_name (const gchar *icon_name);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkStatusIcon *gtk_status_icon_new_from_gicon (GIcon *icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_from_pixbuf (GtkStatusIcon *status_icon,
|
||||
GdkPixbuf *pixbuf);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_from_file (GtkStatusIcon *status_icon,
|
||||
const gchar *filename);
|
||||
GDK_DEPRECATED_IN_3_10_FOR(gtk_status_icon_set_from_icon_name)
|
||||
void gtk_status_icon_set_from_stock (GtkStatusIcon *status_icon,
|
||||
const gchar *stock_id);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_from_icon_name (GtkStatusIcon *status_icon,
|
||||
const gchar *icon_name);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_from_gicon (GtkStatusIcon *status_icon,
|
||||
GIcon *icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GtkImageType gtk_status_icon_get_storage_type (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GdkPixbuf *gtk_status_icon_get_pixbuf (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_10_FOR(gtk_status_icon_get_icon_name)
|
||||
const gchar * gtk_status_icon_get_stock (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
const gchar * gtk_status_icon_get_icon_name (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GIcon *gtk_status_icon_get_gicon (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gint gtk_status_icon_get_size (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_screen (GtkStatusIcon *status_icon,
|
||||
GdkScreen *screen);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
GdkScreen *gtk_status_icon_get_screen (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_has_tooltip (GtkStatusIcon *status_icon,
|
||||
gboolean has_tooltip);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_tooltip_text (GtkStatusIcon *status_icon,
|
||||
const gchar *text);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_tooltip_markup (GtkStatusIcon *status_icon,
|
||||
const gchar *markup);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_title (GtkStatusIcon *status_icon,
|
||||
const gchar *title);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
const gchar * gtk_status_icon_get_title (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_name (GtkStatusIcon *status_icon,
|
||||
const gchar *name);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_set_visible (GtkStatusIcon *status_icon,
|
||||
gboolean visible);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gboolean gtk_status_icon_get_visible (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gboolean gtk_status_icon_is_embedded (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
void gtk_status_icon_position_menu (GtkMenu *menu,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gboolean *push_in,
|
||||
gpointer user_data);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gboolean gtk_status_icon_get_geometry (GtkStatusIcon *status_icon,
|
||||
GdkScreen **screen,
|
||||
GdkRectangle *area,
|
||||
GtkOrientation *orientation);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gboolean gtk_status_icon_get_has_tooltip (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gchar *gtk_status_icon_get_tooltip_text (GtkStatusIcon *status_icon);
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
gchar *gtk_status_icon_get_tooltip_markup (GtkStatusIcon *status_icon);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14
|
||||
guint32 gtk_status_icon_get_x11_window_id (GtkStatusIcon *status_icon);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_STATUS_ICON_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -1,75 +0,0 @@
|
||||
/* gtktrayicon.h
|
||||
* Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_TRAY_ICON_H__
|
||||
#define __GTK_TRAY_ICON_H__
|
||||
|
||||
#include "gtkplug.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_TRAY_ICON (gtk_tray_icon_get_type ())
|
||||
#define GTK_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TRAY_ICON, GtkTrayIcon))
|
||||
#define GTK_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TRAY_ICON, GtkTrayIconClass))
|
||||
#define GTK_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TRAY_ICON))
|
||||
#define GTK_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TRAY_ICON))
|
||||
#define GTK_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TRAY_ICON, GtkTrayIconClass))
|
||||
|
||||
typedef struct _GtkTrayIcon GtkTrayIcon;
|
||||
typedef struct _GtkTrayIconPrivate GtkTrayIconPrivate;
|
||||
typedef struct _GtkTrayIconClass GtkTrayIconClass;
|
||||
|
||||
struct _GtkTrayIcon
|
||||
{
|
||||
GtkPlug parent_instance;
|
||||
|
||||
GtkTrayIconPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkTrayIconClass
|
||||
{
|
||||
GtkPlugClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1);
|
||||
void (*_gtk_reserved2);
|
||||
void (*_gtk_reserved3);
|
||||
void (*_gtk_reserved4);
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_tray_icon_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkTrayIcon *_gtk_tray_icon_new_for_screen (GdkScreen *screen,
|
||||
const gchar *name);
|
||||
|
||||
GtkTrayIcon *_gtk_tray_icon_new (const gchar *name);
|
||||
|
||||
guint _gtk_tray_icon_send_message (GtkTrayIcon *icon,
|
||||
gint timeout,
|
||||
const gchar *message,
|
||||
gint len);
|
||||
void _gtk_tray_icon_cancel_message (GtkTrayIcon *icon,
|
||||
guint id);
|
||||
|
||||
GtkOrientation _gtk_tray_icon_get_orientation (GtkTrayIcon *icon);
|
||||
gint _gtk_tray_icon_get_padding (GtkTrayIcon *icon);
|
||||
gint _gtk_tray_icon_get_icon_size (GtkTrayIcon *icon);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TRAY_ICON_H__ */
|
@ -268,7 +268,6 @@
|
||||
#include <gtk/deprecated/gtkradioaction.h>
|
||||
#include <gtk/deprecated/gtkrc.h>
|
||||
#include <gtk/deprecated/gtkrecentaction.h>
|
||||
#include <gtk/deprecated/gtkstatusicon.h>
|
||||
#include <gtk/deprecated/gtkstock.h>
|
||||
#include <gtk/deprecated/gtkstyle.h>
|
||||
#include <gtk/deprecated/gtkstyleproperties.h>
|
||||
|
@ -117,7 +117,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testselectionmode \
|
||||
$(testsocket_programs) \
|
||||
testspinbutton \
|
||||
teststatusicon \
|
||||
teststockbuttonmenu \
|
||||
testtoolbar \
|
||||
testtoolbar2 \
|
||||
@ -254,7 +253,6 @@ testselection_DEPENDENCIES = $(TEST_DEPS)
|
||||
testsocket_DEPENDENCIES = $(DEPS)
|
||||
testsocket_child_DEPENDENCIES = $(DEPS)
|
||||
testspinbutton_DEPENDENCIES = $(TEST_DEPS)
|
||||
teststatusicon_DEPENDENCIES = $(TEST_DEPS)
|
||||
teststockbuttonmenu_DEPENDENCIES = $(TEST_DEPS)
|
||||
testtreechanging_DEPENDENCIES = $(DEPS)
|
||||
testtreednd_DEPENDENCIES = $(DEPS)
|
||||
@ -408,9 +406,6 @@ testsocket_child_SOURCES = \
|
||||
testspinbutton_SOURCES = \
|
||||
testspinbutton.c
|
||||
|
||||
teststatusicon_SOURCES = \
|
||||
teststatusicon.c
|
||||
|
||||
testmerge_SOURCES = \
|
||||
testmerge.c
|
||||
|
||||
|
@ -1,269 +0,0 @@
|
||||
/* gtkstatusicon-x11.c:
|
||||
*
|
||||
* Copyright (C) 2003 Sun Microsystems, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Mark McLoughlin <mark@skynet.ie>
|
||||
*/
|
||||
|
||||
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEST_STATUS_INFO,
|
||||
TEST_STATUS_QUESTION
|
||||
} TestStatus;
|
||||
|
||||
static TestStatus status = TEST_STATUS_INFO;
|
||||
static gint timeout = 0;
|
||||
static GSList *icons = NULL;
|
||||
|
||||
static gboolean
|
||||
size_changed_cb (GtkStatusIcon *icon,
|
||||
int size)
|
||||
{
|
||||
g_print ("status icon %p size-changed size = %d\n", icon, size);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
embedded_changed_cb (GtkStatusIcon *icon)
|
||||
{
|
||||
g_print ("status icon %p embedded changed to %d\n", icon,
|
||||
gtk_status_icon_is_embedded (icon));
|
||||
}
|
||||
|
||||
static void
|
||||
orientation_changed_cb (GtkStatusIcon *icon)
|
||||
{
|
||||
GtkOrientation orientation;
|
||||
|
||||
g_object_get (icon, "orientation", &orientation, NULL);
|
||||
g_print ("status icon %p orientation changed to %d\n", icon, orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
screen_changed_cb (GtkStatusIcon *icon)
|
||||
{
|
||||
g_print ("status icon %p screen changed to %p\n", icon,
|
||||
gtk_status_icon_get_screen (icon));
|
||||
}
|
||||
|
||||
static void
|
||||
update_icon (void)
|
||||
{
|
||||
GSList *l;
|
||||
gchar *icon_name;
|
||||
gchar *tooltip;
|
||||
|
||||
if (status == TEST_STATUS_INFO)
|
||||
{
|
||||
icon_name = "dialog-information";
|
||||
tooltip = "Some Information ...";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_name = "dialog-question";
|
||||
tooltip = "Some Question ...";
|
||||
}
|
||||
|
||||
for (l = icons; l; l = l->next)
|
||||
{
|
||||
GtkStatusIcon *status_icon = l->data;
|
||||
|
||||
gtk_status_icon_set_from_icon_name (status_icon, icon_name);
|
||||
gtk_status_icon_set_tooltip_text (status_icon, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
timeout_handler (gpointer data)
|
||||
{
|
||||
if (status == TEST_STATUS_INFO)
|
||||
status = TEST_STATUS_QUESTION;
|
||||
else
|
||||
status = TEST_STATUS_INFO;
|
||||
|
||||
update_icon ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
visible_toggle_toggled (GtkToggleButton *toggle)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = icons; l; l = l->next)
|
||||
gtk_status_icon_set_visible (GTK_STATUS_ICON (l->data),
|
||||
gtk_toggle_button_get_active (toggle));
|
||||
}
|
||||
|
||||
static void
|
||||
timeout_toggle_toggled (GtkToggleButton *toggle)
|
||||
{
|
||||
if (timeout)
|
||||
{
|
||||
g_source_remove (timeout);
|
||||
timeout = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeout = gdk_threads_add_timeout (2000, timeout_handler, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
icon_activated (GtkStatusIcon *icon)
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *toggle;
|
||||
|
||||
dialog = g_object_get_data (G_OBJECT (icon), "test-status-icon-dialog");
|
||||
if (dialog == NULL)
|
||||
{
|
||||
dialog = gtk_message_dialog_new (NULL, 0,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"You wanna test the status icon ?");
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (dialog), gtk_status_icon_get_screen (icon));
|
||||
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (icon), "test-status-icon-dialog",
|
||||
dialog, (GDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_hide), NULL);
|
||||
g_signal_connect (dialog, "delete_event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
toggle = gtk_toggle_button_new_with_mnemonic ("_Show the icon");
|
||||
gtk_box_pack_end (GTK_BOX (content_area), toggle, TRUE, TRUE, 6);
|
||||
gtk_widget_show (toggle);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
||||
gtk_status_icon_get_visible (icon));
|
||||
g_signal_connect (toggle, "toggled",
|
||||
G_CALLBACK (visible_toggle_toggled), NULL);
|
||||
|
||||
toggle = gtk_toggle_button_new_with_mnemonic ("_Change images");
|
||||
gtk_box_pack_end (GTK_BOX (content_area), toggle, TRUE, TRUE, 6);
|
||||
gtk_widget_show (toggle);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
||||
timeout != 0);
|
||||
g_signal_connect (toggle, "toggled",
|
||||
G_CALLBACK (timeout_toggle_toggled), NULL);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
do_quit (GtkMenuItem *item)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = icons; l; l = l->next)
|
||||
{
|
||||
GtkStatusIcon *icon = l->data;
|
||||
|
||||
gtk_status_icon_set_visible (icon, FALSE);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
g_slist_free (icons);
|
||||
icons = NULL;
|
||||
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static void
|
||||
do_exit (GtkMenuItem *item)
|
||||
{
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static void
|
||||
popup_menu (GtkStatusIcon *icon,
|
||||
guint button,
|
||||
guint32 activate_time)
|
||||
{
|
||||
GtkWidget *menu, *menuitem;
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
gtk_menu_set_screen (GTK_MENU (menu),
|
||||
gtk_status_icon_get_screen (icon));
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("Quit");
|
||||
g_signal_connect (menuitem, "activate", G_CALLBACK (do_quit), NULL);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("Exit abruptly");
|
||||
g_signal_connect (menuitem, "activate", G_CALLBACK (do_exit), NULL);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
gtk_menu_popup (GTK_MENU (menu),
|
||||
NULL, NULL,
|
||||
gtk_status_icon_position_menu, icon,
|
||||
button, activate_time);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkStatusIcon *icon;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
icon = gtk_status_icon_new ();
|
||||
|
||||
g_signal_connect (icon, "size-changed", G_CALLBACK (size_changed_cb), NULL);
|
||||
g_signal_connect (icon, "notify::embedded", G_CALLBACK (embedded_changed_cb), NULL);
|
||||
g_signal_connect (icon, "notify::orientation", G_CALLBACK (orientation_changed_cb), NULL);
|
||||
g_signal_connect (icon, "notify::screen", G_CALLBACK (screen_changed_cb), NULL);
|
||||
g_print ("icon size %d\n", gtk_status_icon_get_size (icon));
|
||||
|
||||
g_signal_connect (icon, "activate",
|
||||
G_CALLBACK (icon_activated), NULL);
|
||||
|
||||
g_signal_connect (icon, "popup-menu",
|
||||
G_CALLBACK (popup_menu), NULL);
|
||||
|
||||
icons = g_slist_append (icons, icon);
|
||||
|
||||
update_icon ();
|
||||
|
||||
timeout = gdk_threads_add_timeout (2000, timeout_handler, icon);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -294,11 +294,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
(strcmp (pspec->name, "adjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_STATUS_ICON) &&
|
||||
(strcmp (pspec->name, "size") == 0 ||
|
||||
strcmp (pspec->name, "screen") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_STYLE_CONTEXT) &&
|
||||
strcmp (pspec->name, "screen") == 0)
|
||||
continue;
|
||||
|
@ -425,9 +425,6 @@ test_type (gconstpointer data)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_STATUS_ICON))
|
||||
return;
|
||||
|
||||
klass = g_type_class_ref (type);
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SETTINGS))
|
||||
|
Loading…
Reference in New Issue
Block a user