Revision 501

src/eggtrayicon.c (revision 501)
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
/* eggtrayicon.c
3
 * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 * Boston, MA 02111-1307, USA.
19
 */
20
/* Added WINDOWING ifdef  2005-07-09 by Yoichi Imai <yoichi@silver-forest.com> */
21

  
22
#include <config.h>
23
#include <string.h>
24
#include <libintl.h>
25

  
26
#include "eggtrayicon.h"
27

  
28
#ifdef GDK_WINDOWING_X11
29
#include <gdk/gdkx.h>
30
#include <X11/Xatom.h>
31

  
32
#ifndef EGG_COMPILATION
33
#ifndef _
34
#define _(x) dgettext (GETTEXT_PACKAGE, x)
35
#define N_(x) x
36
#endif
37
#else
38
#define _(x) x
39
#define N_(x) x
40
#endif
41

  
42
#define SYSTEM_TRAY_REQUEST_DOCK    0
43
#define SYSTEM_TRAY_BEGIN_MESSAGE   1
44
#define SYSTEM_TRAY_CANCEL_MESSAGE  2
45

  
46
#define SYSTEM_TRAY_ORIENTATION_HORZ 0
47
#define SYSTEM_TRAY_ORIENTATION_VERT 1
48

  
49
enum {
50
  PROP_0,
51
  PROP_ORIENTATION
52
};
53
         
54
static GtkPlugClass *parent_class = NULL;
55

  
56
static void egg_tray_icon_init (EggTrayIcon *icon);
57
static void egg_tray_icon_class_init (EggTrayIconClass *klass);
58

  
59
static void egg_tray_icon_get_property (GObject    *object,
60
					guint       prop_id,
61
					GValue     *value,
62
					GParamSpec *pspec);
63

  
64
static void egg_tray_icon_realize   (GtkWidget *widget);
65
static void egg_tray_icon_unrealize (GtkWidget *widget);
66

  
67
static void egg_tray_icon_update_manager_window (EggTrayIcon *icon);
68

  
69
GType
70
egg_tray_icon_get_type (void)
71
{
72
  static GType our_type = 0;
73

  
74
  if (our_type == 0)
75
    {
76
      static const GTypeInfo our_info =
77
      {
78
	sizeof (EggTrayIconClass),
79
	(GBaseInitFunc) NULL,
80
	(GBaseFinalizeFunc) NULL,
81
	(GClassInitFunc) egg_tray_icon_class_init,
82
	NULL, /* class_finalize */
83
	NULL, /* class_data */
84
	sizeof (EggTrayIcon),
85
	0,    /* n_preallocs */
86
	(GInstanceInitFunc) egg_tray_icon_init
87
      };
88

  
89
      our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
90
    }
91

  
92
  return our_type;
93
}
94

  
95
static void
96
egg_tray_icon_init (EggTrayIcon *icon)
97
{
98
  icon->stamp = 1;
99
  icon->orientation = GTK_ORIENTATION_HORIZONTAL;
100
  
101
  gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
102
}
103

  
104
static void
105
egg_tray_icon_class_init (EggTrayIconClass *klass)
106
{
107
  GObjectClass *gobject_class = (GObjectClass *)klass;
108
  GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
109

  
110
  parent_class = g_type_class_peek_parent (klass);
111

  
112
  gobject_class->get_property = egg_tray_icon_get_property;
113

  
114
  widget_class->realize   = egg_tray_icon_realize;
115
  widget_class->unrealize = egg_tray_icon_unrealize;
116

  
117
  g_object_class_install_property (gobject_class,
118
				   PROP_ORIENTATION,
119
				   g_param_spec_enum ("orientation",
120
						      _("Orientation"),
121
						      _("The orientation of the tray."),
122
						      GTK_TYPE_ORIENTATION,
123
						      GTK_ORIENTATION_HORIZONTAL,
124
						      G_PARAM_READABLE));
125
}
126

  
127
static void
128
egg_tray_icon_get_property (GObject    *object,
129
			    guint       prop_id,
130
			    GValue     *value,
131
			    GParamSpec *pspec)
132
{
133
  EggTrayIcon *icon = EGG_TRAY_ICON (object);
134

  
135
  switch (prop_id)
136
    {
137
    case PROP_ORIENTATION:
138
      g_value_set_enum (value, icon->orientation);
139
      break;
140
    default:
141
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
142
      break;
143
    }
144
}
145

  
146
static void
147
egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
148
{
149
  Display *xdisplay;
150
  Atom type;
151
  int format;
152
  union {
153
	gulong *prop;
154
	guchar *prop_ch;
155
  } prop = { NULL };
156
  gulong nitems;
157
  gulong bytes_after;
158
  int error, result;
159

  
160
  g_assert (icon->manager_window != None);
161
  
162
  xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
163

  
164
  gdk_error_trap_push ();
165
  type = None;
166
  result = XGetWindowProperty (xdisplay,
167
			       icon->manager_window,
168
			       icon->orientation_atom,
169
			       0, G_MAXLONG, FALSE,
170
			       XA_CARDINAL,
171
			       &type, &format, &nitems,
172
			       &bytes_after, &(prop.prop_ch));
173
  error = gdk_error_trap_pop ();
174

  
175
  if (error || result != Success)
176
    return;
177

  
178
  if (type == XA_CARDINAL)
179
    {
180
      GtkOrientation orientation;
181

  
182
      orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
183
					GTK_ORIENTATION_HORIZONTAL :
184
					GTK_ORIENTATION_VERTICAL;
185

  
186
      if (icon->orientation != orientation)
187
	{
188
	  icon->orientation = orientation;
189

  
190
	  g_object_notify (G_OBJECT (icon), "orientation");
191
	}
192
    }
193

  
194
  if (prop.prop)
195
    XFree (prop.prop);
196
}
197

  
198
static GdkFilterReturn
199
egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
200
{
201
  EggTrayIcon *icon = user_data;
202
  XEvent *xev = (XEvent *)xevent;
203

  
204
  if (xev->xany.type == ClientMessage &&
205
      xev->xclient.message_type == icon->manager_atom &&
206
      xev->xclient.data.l[1] == icon->selection_atom)
207
    {
208
      egg_tray_icon_update_manager_window (icon);
209
    }
210
  else if (xev->xany.window == icon->manager_window)
211
    {
212
      if (xev->xany.type == PropertyNotify &&
213
	  xev->xproperty.atom == icon->orientation_atom)
214
	{
215
	  egg_tray_icon_get_orientation_property (icon);
216
	}
217
      if (xev->xany.type == DestroyNotify)
218
	{
219
	  egg_tray_icon_update_manager_window (icon);
220
	}
221
    }
222
  
223
  return GDK_FILTER_CONTINUE;
224
}
225

  
226
static void
227
egg_tray_icon_unrealize (GtkWidget *widget)
228
{
229
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
230
  GdkWindow *root_window;
231

  
232
  if (icon->manager_window != None)
233
    {
234
      GdkWindow *gdkwin;
235

  
236
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
237
                                              icon->manager_window);
238

  
239
      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
240
    }
241

  
242
  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
243

  
244
  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
245

  
246
  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
247
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
248
}
249

  
250
static void
251
egg_tray_icon_send_manager_message (EggTrayIcon *icon,
252
				    long         message,
253
				    Window       window,
254
				    long         data1,
255
				    long         data2,
256
				    long         data3)
257
{
258
  XClientMessageEvent ev;
259
  Display *display;
260
  
261
  ev.type = ClientMessage;
262
  ev.window = window;
263
  ev.message_type = icon->system_tray_opcode_atom;
264
  ev.format = 32;
265
  ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
266
  ev.data.l[1] = message;
267
  ev.data.l[2] = data1;
268
  ev.data.l[3] = data2;
269
  ev.data.l[4] = data3;
270

  
271
  display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
272
  
273
  gdk_error_trap_push ();
274
  XSendEvent (display,
275
	      icon->manager_window, False, NoEventMask, (XEvent *)&ev);
276
  XSync (display, False);
277
  gdk_error_trap_pop ();
278
}
279

  
280
static void
281
egg_tray_icon_send_dock_request (EggTrayIcon *icon)
282
{
283
  egg_tray_icon_send_manager_message (icon,
284
				      SYSTEM_TRAY_REQUEST_DOCK,
285
				      icon->manager_window,
286
				      gtk_plug_get_id (GTK_PLUG (icon)),
287
				      0, 0);
288
}
289

  
290
static void
291
egg_tray_icon_update_manager_window (EggTrayIcon *icon)
292
{
293
  Display *xdisplay;
294

  
295
  g_return_if_fail(GTK_IS_WIDGET(icon));
296
  
297
  xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
298
  
299
  if (icon->manager_window != None)
300
    {
301
      GdkWindow *gdkwin;
302

  
303
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
304
					      icon->manager_window);
305
      
306
      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
307
    }
308
  
309
  XGrabServer (xdisplay);
310
  
311
  icon->manager_window = XGetSelectionOwner (xdisplay,
312
					     icon->selection_atom);
313

  
314
  if (icon->manager_window != None)
315
    XSelectInput (xdisplay,
316
		  icon->manager_window, StructureNotifyMask|PropertyChangeMask);
317

  
318
  XUngrabServer (xdisplay);
319
  XFlush (xdisplay);
320
  
321
  if (icon->manager_window != None)
322
    {
323
      GdkWindow *gdkwin;
324

  
325
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
326
					      icon->manager_window);
327
      
328
      gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
329

  
330
      /* Send a request that we'd like to dock */
331
      egg_tray_icon_send_dock_request (icon);
332

  
333
      egg_tray_icon_get_orientation_property (icon);
334
    }
335
}
336

  
337
static void
338
egg_tray_icon_realize (GtkWidget *widget)
339
{
340
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
341
  GdkScreen *screen;
342
  GdkDisplay *display;
343
  Display *xdisplay;
344
  char buffer[256];
345
  GdkWindow *root_window;
346

  
347
  if (GTK_WIDGET_CLASS (parent_class)->realize)
348
    GTK_WIDGET_CLASS (parent_class)->realize (widget);
349

  
350
  screen = gtk_widget_get_screen (widget);
351
  display = gdk_screen_get_display (screen);
352
  xdisplay = gdk_x11_display_get_xdisplay (display);
353

  
354
  /* Now see if there's a manager window around */
355
  g_snprintf (buffer, sizeof (buffer),
356
	      "_NET_SYSTEM_TRAY_S%d",
357
	      gdk_screen_get_number (screen));
358

  
359
  icon->selection_atom = XInternAtom (xdisplay, buffer, False);
360
  
361
  icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
362
  
363
  icon->system_tray_opcode_atom = XInternAtom (xdisplay,
364
						   "_NET_SYSTEM_TRAY_OPCODE",
365
						   False);
366

  
367
  icon->orientation_atom = XInternAtom (xdisplay,
368
					"_NET_SYSTEM_TRAY_ORIENTATION",
369
					False);
370

  
371
  egg_tray_icon_update_manager_window (icon);
372

  
373
  root_window = gdk_screen_get_root_window (screen);
374
  
375
  /* Add a root window filter so that we get changes on MANAGER */
376
  gdk_window_add_filter (root_window,
377
			 egg_tray_icon_manager_filter, icon);
378
}
379

  
380
EggTrayIcon *
381
egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
382
{
383
  GdkDisplay *display;
384
  GdkScreen *screen;
385

  
386
  display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen));
387
  screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen));
388

  
389
  return egg_tray_icon_new_for_screen (screen, name);
390
}
391

  
392
EggTrayIcon *
393
egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
394
{
395
  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
396

  
397
  return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
398
}
399

  
400
EggTrayIcon*
401
egg_tray_icon_new (const gchar *name)
402
{
403
  return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
404
}
405

  
406
guint
407
egg_tray_icon_send_message (EggTrayIcon *icon,
408
			    gint         timeout,
409
			    const gchar *message,
410
			    gint         len)
411
{
412
  guint stamp;
413
  
414
  g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
415
  g_return_val_if_fail (timeout >= 0, 0);
416
  g_return_val_if_fail (message != NULL, 0);
417
		     
418
  if (icon->manager_window == None)
419
    return 0;
420

  
421
  if (len < 0)
422
    len = strlen (message);
423

  
424
  stamp = icon->stamp++;
425
  
426
  /* Get ready to send the message */
427
  egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
428
				      (Window)gtk_plug_get_id (GTK_PLUG (icon)),
429
				      timeout, len, stamp);
430

  
431
  /* Now to send the actual message */
432
  gdk_error_trap_push ();
433
  while (len > 0)
434
    {
435
      XClientMessageEvent ev;
436
      Display *xdisplay;
437

  
438
      xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
439
      
440
      ev.type = ClientMessage;
441
      ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
442
      ev.format = 8;
443
      ev.message_type = XInternAtom (xdisplay,
444
				     "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
445
      if (len > 20)
446
	{
447
	  memcpy (&ev.data, message, 20);
448
	  len -= 20;
449
	  message += 20;
450
	}
451
      else
452
	{
453
	  memcpy (&ev.data, message, len);
454
	  len = 0;
455
	}
456

  
457
      XSendEvent (xdisplay,
458
		  icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
459
      XSync (xdisplay, False);
460
    }
461
  gdk_error_trap_pop ();
462

  
463
  return stamp;
464
}
465

  
466
void
467
egg_tray_icon_cancel_message (EggTrayIcon *icon,
468
			      guint        id)
469
{
470
  g_return_if_fail (EGG_IS_TRAY_ICON (icon));
471
  g_return_if_fail (id > 0);
472
  
473
  egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
474
				      (Window)gtk_plug_get_id (GTK_PLUG (icon)),
475
				      id, 0, 0);
476
}
477

  
478
GtkOrientation
479
egg_tray_icon_get_orientation (EggTrayIcon *icon)
480
{
481
  g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
482

  
483
  return icon->orientation;
484
}
485

  
486
#endif
src/eggtrayicon.h (revision 501)
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
/* eggtrayicon.h
3
 * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 * Boston, MA 02111-1307, USA.
19
 */
20

  
21
#ifndef __EGG_TRAY_ICON_H__
22
#define __EGG_TRAY_ICON_H__
23

  
24
#include <gtk/gtkplug.h>
25
#include <gtk/gtk.h>
26

  
27
#ifdef GDK_WINDOWING_X11
28
#include <gdk/gdkx.h>
29

  
30
G_BEGIN_DECLS
31

  
32
#define EGG_TYPE_TRAY_ICON		(egg_tray_icon_get_type ())
33
#define EGG_TRAY_ICON(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon))
34
#define EGG_TRAY_ICON_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
35
#define EGG_IS_TRAY_ICON(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON))
36
#define EGG_IS_TRAY_ICON_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON))
37
#define EGG_TRAY_ICON_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
38
	
39
typedef struct _EggTrayIcon	  EggTrayIcon;
40
typedef struct _EggTrayIconClass  EggTrayIconClass;
41

  
42
struct _EggTrayIcon
43
{
44
  GtkPlug parent_instance;
45

  
46
  guint stamp;
47
  
48
  Atom selection_atom;
49
  Atom manager_atom;
50
  Atom system_tray_opcode_atom;
51
  Atom orientation_atom;
52
  Window manager_window;
53

  
54
  GtkOrientation orientation;
55
};
56

  
57
struct _EggTrayIconClass
58
{
59
  GtkPlugClass parent_class;
60
};
61

  
62
GType        egg_tray_icon_get_type       (void);
63

  
64
EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen   *screen,
65
					   const gchar *name);
66

  
67
EggTrayIcon *egg_tray_icon_new            (const gchar *name);
68

  
69
guint        egg_tray_icon_send_message   (EggTrayIcon *icon,
70
					   gint         timeout,
71
					   const char  *message,
72
					   gint         len);
73
void         egg_tray_icon_cancel_message (EggTrayIcon *icon,
74
					   guint        id);
75

  
76
GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
77
					    
78
G_END_DECLS
79

  
80
#endif /* GDK_WINDOWING_X11 */
81
#endif /* __EGG_TRAY_ICON_H__ */
src/Makefile.am (revision 501)
108 108
	simple-gettext.c \
109 109
	manual.c manual.h \
110 110
	stringtable.c stringtable.h \
111
	eggtrayicon.c eggtrayicon.h \
111 112
	quote_fmt_lex.l quote_fmt_lex.h \
112 113
	quote_fmt_parse.y quote_fmt.h \
113 114
	sylpheed-marshal.c sylpheed-marshal.h
src/stock_pixmap.c (revision 501)
161 161
	return gtk_image_new_from_pixbuf(pixbuf);
162 162
}
163 163

  
164
GtkWidget *stock_pixbuf_widget_scale(GtkWidget *window, StockPixmap icon,
165
				     gint width, gint height)
166
{
167
	GdkPixbuf *pixbuf;
168
	GdkPixbuf *scaled_pixbuf;
169
	GtkWidget *image;
170

  
171
	g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
172

  
173
	stock_pixbuf_gdk(window, icon, &pixbuf);
174
	scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height,
175
						GDK_INTERP_HYPER);
176
	image = gtk_image_new_from_pixbuf(scaled_pixbuf);
177
	g_object_unref(scaled_pixbuf);
178

  
179
	return image;
180
}
181

  
164 182
/* create GdkPixmap if it has not created yet */
165 183
gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
166 184
		      GdkPixmap **pixmap, GdkBitmap **mask)
src/stock_pixmap.h (revision 501)
80 80
				 StockPixmap	  icon);
81 81
GtkWidget *stock_pixbuf_widget	(GtkWidget	 *window,
82 82
				 StockPixmap	  icon);
83

  
84
GtkWidget *stock_pixbuf_widget_scale	(GtkWidget	*window,
85
					 StockPixmap	 icon,
86
					 gint		 width,
87
					 gint		 height);
88

  
83 89
gint stock_pixmap_gdk		(GtkWidget	 *window,
84 90
				 StockPixmap	  icon,
85 91
				 GdkPixmap	**pixmap,
src/mainwindow.c (revision 501)
77 77
#include "alertpanel.h"
78 78
#include "statusbar.h"
79 79
#include "inputdialog.h"
80
#include "eggtrayicon.h"
80 81
#include "utils.h"
81 82
#include "gtkutils.h"
82 83
#include "codeconv.h"
......
159 160
static void ac_menu_popup_closed		(GtkMenuShell	*menu_shell,
160 161
						 gpointer	 data);
161 162

  
163
static void tray_icon_button_pressed		(GtkWidget	*widget,
164
						 GdkEventButton	*event,
165
						 gpointer	 data);
166

  
162 167
static gint main_window_close_cb		(GtkWidget	*widget,
163 168
						 GdkEventAny	*event,
164 169
						 gpointer	 data);
......
799 804
	GtkWidget *ac_button;
800 805
	GtkWidget *ac_label;
801 806

  
807
	GtkWidget *tray_icon;
808
	GtkWidget *tray_icon_img;
809
	GtkWidget *eventbox;
810
	GtkTooltips *tray_icon_tip;
811

  
802 812
	FolderView *folderview;
803 813
	SummaryView *summaryview;
804 814
	MessageView *messageview;
......
904 914

  
905 915
	gtk_widget_show_all(statusbar);
906 916

  
917
	tray_icon = GTK_WIDGET(egg_tray_icon_new("Sylpheed"));
918

  
919
	eventbox = gtk_event_box_new();
920
	gtk_container_add(GTK_CONTAINER(tray_icon), eventbox);
921
	g_signal_connect(G_OBJECT(eventbox), "button_press_event",
922
			 G_CALLBACK(tray_icon_button_pressed), mainwin);
923
	tray_icon_img = stock_pixbuf_widget_scale(NULL, STOCK_PIXMAP_SYLPHEED,
924
						  24, 24);
925
	gtk_container_add(GTK_CONTAINER(eventbox), tray_icon_img);
926

  
927
	tray_icon_tip = gtk_tooltips_new();
928
	gtk_tooltips_set_tip(tray_icon_tip, tray_icon, _("Sylpheed"), NULL);
929

  
930
	gtk_widget_show_all(tray_icon);
931

  
907 932
	/* create views */
908 933
	mainwin->folderview  = folderview  = folderview_create();
909 934
	mainwin->summaryview = summaryview = summary_create();
......
937 962
	mainwin->ac_button      = ac_button;
938 963
	mainwin->ac_label       = ac_label;
939 964

  
965
	mainwin->tray_icon      = tray_icon;
966
	mainwin->tray_icon_img  = tray_icon_img;
967
	mainwin->tray_icon_tip  = tray_icon_tip;
968

  
940 969
	/* set context IDs for status bar */
941 970
	mainwin->mainwin_cid = gtk_statusbar_get_context_id
942 971
		(GTK_STATUSBAR(statusbar), "Main Window");
......
2541 2570
	manage_window_focus_in(mainwin->window, NULL, NULL);
2542 2571
}
2543 2572

  
2573
static void tray_icon_button_pressed(GtkWidget *widget, GdkEventButton *event,
2574
				     gpointer data)
2575
{
2576
	MainWindow *mainwin = (MainWindow *)data;
2577

  
2578
	if (event && event->button == 1)
2579
		gtk_window_present(GTK_WINDOW(mainwin->window));
2580
}
2581

  
2544 2582
static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2545 2583
				 gpointer data)
2546 2584
{
src/mainwindow.h (revision 501)
111 111
	GtkWidget *ac_label;
112 112
	GtkWidget *ac_menu;
113 113

  
114
	GtkWidget *tray_icon;
115
	GtkWidget *tray_icon_img;
116
	GtkTooltips *tray_icon_tip;
117

  
114 118
	/* context IDs for status bar */
115 119
	gint mainwin_cid;
116 120
	gint folderview_cid;
ChangeLog.ja (revision 501)
1 1
2005-08-23
2 2

  
3
	* src/eggtrayicon.[ch]: ?ɲ?(Loqui svn trunk ?????Ҽ?)??
4
	* src/mainwindow.[ch]: ?ȥ쥤?????????κǽ??μ?????
5
	* src/stock_pixmap.[ch]: stock_pixbuf_widget_scale() ???ɲá?
6

  
7
2005-08-23
8

  
3 9
	* src/textview.c: mime ?ѡ??ȤΥե????Ȥ?Ĵ????
4 10

  
5 11
2005-08-22
ChangeLog (revision 501)
1 1
2005-08-23
2 2

  
3
	* src/eggtrayicon.[ch]: added (borrowed from Loqui svn trunk).
4
	* src/mainwindow.[ch]: initial implementation of the tray icon.
5
	* src/stock_pixmap.[ch]: added stock_pixbuf_widget_scale().
6

  
7
2005-08-23
8

  
3 9
	* src/textview.c: modified fonts for mime parts.
4 10

  
5 11
2005-08-22

Also available in: Unified diff