Re: GtkStatusIcon and Drag and Drop?

2008-01-15 Thread Scott Horowitz
2008/1/15 Enrico Tröger [EMAIL PROTECTED]:
 I was just playing around with the GtkStatusIcon API and wondered if
 there is any way to use Drag And Drop with a GtkStatusIcon object? The
 usual way doesn't work because GtkStatusIcon is a subclass of GObject
 and not an ordinary GtkWidget.

 Or is not possible at all because of the tray icon specification? I
 read the specification at
 http://www.freedesktop.org/wiki/Standards/systemtray-spec but didn't
 find anything regarding Drag and Drop.

http://bugzilla.gnome.org/show_bug.cgi?id=409435

Scott
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkStatusIcon and Drag and Drop?

2008-01-15 Thread Enrico Tröger
On Tue, 15 Jan 2008 23:20:28 -0700, Scott Horowitz
[EMAIL PROTECTED] wrote:

 2008/1/15 Enrico Tröger [EMAIL PROTECTED]:
  I was just playing around with the GtkStatusIcon API and wondered if
  there is any way to use Drag And Drop with a GtkStatusIcon object?
  The usual way doesn't work because GtkStatusIcon is a subclass of
  GObject and not an ordinary GtkWidget.
 
  Or is not possible at all because of the tray icon specification? I
  read the specification at
  http://www.freedesktop.org/wiki/Standards/systemtray-spec but didn't
  find anything regarding Drag and Drop.
 
 http://bugzilla.gnome.org/show_bug.cgi?id=409435
Thanks a lot. I was googling a lot but didn't find that bug report.


Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.key
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkStatusIcon and popup menu

2006-11-06 Thread Peter Lund
On Sun, 2006-11-05 at 18:31 +0100, Chris tophe wrote:


 click somewhere out of it. I tried around, this problem doesn't happen when
 calling gtk_menu_popup in response to a widget's button-press-event/button
 == 3 for example, only in popup-menu callback. Any idea to make this menu
 go away normally? Thanks.


The program I wrote earlier this year just uses the button-press-event
signal.  In the handler I create a menu and connect a deactivation
function to its deactive signal.

Seems to work fine.

-Peter


static void deactivatemenu(GtkMenuShell *menushell, gpointer user_data)
{
GtkWidget   *attach_widget;

(void) user_data;

gtk_menu_popdown(GTK_MENU(menushell));
attach_widget = gtk_menu_get_attach_widget(GTK_MENU(menushell));
if (attach_widget)
gtk_widget_set_state(attach_widget, GTK_STATE_NORMAL);
}



static gboolean tray_icon_button_press(EggTrayIcon*tray_icon,
   GdkEventButton *event,
   gpointeruser_data)
{
(void) user_data;

/* single click with the left mouse button */
if (event-type == GDK_BUTTON_PRESS  event-button == 1) {
GtkMenu *menu;

menu = make_left_click_menu(GTK_WIDGET(tray_icon));

g_signal_connect(menu, deactivate,
 G_CALLBACK(deactivatemenu),
 NULL);
gtk_menu_popup(menu,
   NULL,
   NULL,
   calc_menu_position,
   NULL,
   event-button,
   gdk_event_get_time((GdkEvent *) event));
gtk_widget_set_state(gtk_menu_get_attach_widget(menu), 
GTK_STATE_SELECTED);

return TRUE; /* we handled the click */
}

/* single click with the right mouse button */
if (event-type == GDK_BUTTON_PRESS  event-button == 3) {
GtkMenu *menu;

menu = make_right_click_menu(GTK_WIDGET(tray_icon));

g_signal_connect(menu, deactivate,
 G_CALLBACK(deactivatemenu),
 NULL);
gtk_menu_popup(menu,
   NULL,
   NULL,
   calc_menu_position,
   NULL,
   event-button,
   gdk_event_get_time((GdkEvent *) event));
gtk_widget_set_state(gtk_menu_get_attach_widget(menu), 
GTK_STATE_SELECTED);

return TRUE; /* we handled the click */
}

return FALSE; /* we did not handle the click (or whatever it was) */
}


and the initialization code:


...
tray_icon = egg_tray_icon_new(bælg);

event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(tray_icon), event_box);

w = gtk_label_new(Bælg);
gtk_container_add(GTK_CONTAINER(event_box), w);
gtk_widget_show_all(GTK_WIDGET(tray_icon));

g_signal_connect(event_box, button-press-event,
 G_CALLBACK(tray_icon_button_press),
 NULL);
...

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkStatusIcon and popup menu

2006-11-06 Thread Chris tophe
2006/11/7, Peter Lund [EMAIL PROTECTED]:

The program I wrote earlier this year just uses the button-press-event
 signal.  In the handler I create a menu and connect a deactivation function
 to its deactive signal.

 Seems to work fine.

 -Peter


Thanks for your answer. I can't do this :

event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(tray_icon), event_box);


Because GtkStatusIcon is not a widget.
Here is some example code that shows my problem :

int button_press_event_callback(GtkWidget* widget, GdkEvent* event)
{
GdkEventButton* event_button;

if(event-type == GDK_BUTTON_PRESS)
{
event_button = (GdkEventButton*)event;
if(event_button-button == 3)
{
/* this menu behaves normally */
gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL,
event_button-button, event_button-time);
return TRUE;
}
}

return FALSE;
}

void popup_callback(GtkStatusIcon* icon, guint button, guint activate_time,
gpointer data)
{
/* this menu won't go away */
gtk_menu_popup(GTK_MENU(data), NULL, NULL, NULL, NULL, button,
activate_time);
}

int main(int argc, char* argv[])
{
GtkWidget* window;
GtkWidget* button;
GtkStatusIcon* trayicon;
GtkWidget* menu;
GtkWidget* menuitem;

gtk_init(argc, argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label(button);
gtk_container_add(GTK_CONTAINER(window), button);

trayicon = gtk_status_icon_new_from_file(some-nice-pic);

menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label(hello);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);

g_signal_connect(G_OBJECT(trayicon), popup-menu,
G_CALLBACK(popup_callback), G_OBJECT(menu));
g_signal_connect_swapped(G_OBJECT(button), button-press-event,
G_CALLBACK(button_press_event_callback), G_OBJECT(menu));

gtk_widget_show_all(window);

gtk_main();

return 0;
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkStatusIcon

2005-11-09 Thread Matthias Clasen
On Wed, 2005-11-09 at 19:08 +0100, Giuliano Montecarlo wrote:
 Hi,
 I'm about to write an App using GTK+.
 I'm trying to get a Status Icon in Yellow.
 
 --snip--
   GdkPixbuf* YI = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 24, 24);
   GdkColor color;
   guint32 pixel;
   if (gdk_color_parse (Yellow, color))
 pixel =
   (color.red8)  24 |
   (color.green  8)  16 |
   (color.blue   8)  8;
   gdk_pixbuf_fill (YI, pixel);
   GtkStatusIcon* YellowIcon=gtk_status_icon_new_from_pixbuf(YI);
 --snap--
 
 OK. Should be correct, but I get Errors while I compile:
 --snip--
 main.c: In function `main':
 main.c:106: error: `GtkStatusIcon' undeclared (first use in this function)
 main.c:106: error: (Each undeclared identifier is reported only once
 main.c:106: error: for each function it appears in.)
 main.c:106: error: `YellowIcon' undeclared (first use in this function)
 
 make: *** [main.o] Error 1
 --snap--
 
 When I replace GtkStatusIcon with GtkWidget I get
 --snip--
 main.c: In function `main':
 main.c:106: warning: initialization makes pointer from integer without a cast
 (...)
 main.o:main.c:(.text+0x881): undefined reference to
 `gtk_status_icon_new_from_pixbuf'
 --snap--
 
 So, where it is? I've included gtk/gtk.h. and as libs I've
 -lcairo -lpangox11-1.0 -latk-1.0 -lgdk_pixbuf-2.0 -lgdk-x11-2.0
 -lglib-2.0.dll -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lgtk-x11-2.0
 -lpango-1.0

GtkStatusIcon is new api that is not in any stable gtk release yet. It
will appear in gtk 2.10.

Matthias

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list