~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to lcl/interfaces/gtk2/gtk2trayicon.inc

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
const
56
56
  SYSTEM_TRAY_REQUEST_DOCK   = 0;
57
 
  SYSTEM_TRAY_BEGIN_MESSAGE  = 1;
58
 
  SYSTEM_TRAY_CANCEL_MESSAGE = 2;
 
57
  //SYSTEM_TRAY_BEGIN_MESSAGE  = 1;
 
58
  //SYSTEM_TRAY_CANCEL_MESSAGE = 2;
59
59
 
60
60
{$ifdef HasGdk2X}
61
61
var
70
70
*  RETURNS:        ?
71
71
*
72
72
*******************************************************************}
73
 
function TempX11ErrorHandler(Display:PDisplay; ErrorEv:PXErrorEvent):longint;cdecl;
 
73
function TempX11ErrorHandler({%H-}Display:PDisplay; ErrorEv:PXErrorEvent):longint;cdecl;
74
74
begin
75
75
  XError := ErrorEv^.error_code;
76
76
  WriteLn('Error: ' + IntToStr(XError));
91
91
var
92
92
  Ev: TXEvent;
93
93
begin
94
 
  FillChar(Ev, SizeOf(TXEvent), 0);
 
94
  FillChar(Ev{%H-}, SizeOf(TXEvent), 0);
95
95
 
96
96
  ev.xclient._type := ClientMessage;
97
97
  ev.xclient.window := window;
161
161
*  RETURNS:        Nothing
162
162
*
163
163
*******************************************************************}
164
 
procedure realize_cb(widget: PGtkWidget; user_data: gpointer); cdecl;
 
164
procedure realize_cb({%H-}widget: PGtkWidget; user_data: gpointer); cdecl;
165
165
var
166
166
  wsTrayIcon: TCustomTrayIcon absolute user_data;
167
167
begin
193
193
*  RETURNS:        Nothing
194
194
*
195
195
*******************************************************************}
196
 
function button_release_cb(widget: PGtkWidget; event: PGdkEventButton;
 
196
function button_release_cb({%H-}widget: PGtkWidget; event: PGdkEventButton;
197
197
 user_data: gpointer): gboolean; cdecl;
198
198
var
199
199
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
231
231
*  RETURNS:        Nothing
232
232
*
233
233
*******************************************************************}
234
 
function button_press_cb(widget: PGtkWidget; event: PGdkEventButton;
 
234
function button_press_cb({%H-}widget: PGtkWidget; event: PGdkEventButton;
235
235
 user_data: gpointer): gboolean; cdecl;
236
236
var
237
237
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
265
265
*  RETURNS:        Nothing
266
266
*
267
267
*******************************************************************}
268
 
function popup_cb(widget: PGtkWidget; user_data: gpointer): Boolean; cdecl;
 
268
function popup_cb({%H-}widget: PGtkWidget; user_data: gpointer): Boolean; cdecl;
269
269
var
270
270
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
271
271
begin
285
285
*  RETURNS:        Nothing
286
286
*
287
287
*******************************************************************}
288
 
function motion_cb(widget: PGtkWidget; event: PGdkEventMotion; user_data: gpointer): Boolean; cdecl;
 
288
function motion_cb({%H-}widget: PGtkWidget; event: PGdkEventMotion; user_data: gpointer): Boolean; cdecl;
289
289
var
290
290
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
291
291
begin
296
296
end;
297
297
 
298
298
{$ifdef UseStatusIcon}
299
 
procedure activate_cb_statusicon(status_icon: PGtkStatusIcon; user_data: gpointer); cdecl;
 
299
procedure activate_cb_statusicon({%H-}status_icon: PGtkStatusIcon; user_data: gpointer); cdecl;
300
300
var
301
301
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
302
302
begin
305
305
      vwsTrayIcon.OnMouseDown(vwsTrayIcon, mbLeft, [], X, Y);
306
306
end;
307
307
 
308
 
procedure popup_cb_statusicon(status_icon: PGtkStatusIcon; button: guint;
309
 
                activate_time: guint; user_data: gpointer); cdecl;
 
308
procedure popup_cb_statusicon({%H-}status_icon: PGtkStatusIcon; {%H-}button: guint;
 
309
                {%H-}activate_time: guint; user_data: gpointer); cdecl;
310
310
var
311
311
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
312
312
begin
313
313
  if Assigned(vwsTrayIcon.PopUpMenu) then
314
314
    vwsTrayIcon.PopUpMenu.PopUp(Mouse.CursorPos.X, Mouse.CursorPos.Y);
315
315
end;
 
316
 
 
317
function button_press_cb_statusicon({%H-}status_icon: PGtkStatusIcon;
 
318
  event: PGdkEvent; user_data: gpointer): gboolean; cdecl;
 
319
var
 
320
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
 
321
begin
 
322
  Result := False;
 
323
 
 
324
  if (PGdkEventButton(event)^._type = GDK_2BUTTON_PRESS) and Assigned(vwsTrayIcon.OnDblClick) then
 
325
   vwsTrayIcon.OnDblClick(vwsTrayIcon)
 
326
  else
 
327
  begin
 
328
    case PGdkEventButton(event)^.button of
 
329
      1: if Assigned(vwsTrayIcon.OnMouseDown) then
 
330
          vwsTrayIcon.OnMouseDown(vwsTrayIcon, mbLeft, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
331
 
 
332
      2: if Assigned(vwsTrayIcon.OnMouseDown) then
 
333
          vwsTrayIcon.OnMouseDown(vwsTrayIcon, mbMiddle, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
334
 
 
335
      3: if Assigned(vwsTrayIcon.OnMouseDown) then
 
336
          vwsTrayIcon.OnMouseDown(vwsTrayIcon, mbRight, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
337
    end;
 
338
  end;
 
339
end;
 
340
 
 
341
function button_release_cb_statusicon({%H-}status_icon: PGtkStatusIcon;
 
342
  event: PGdkEvent; user_data: gpointer): gboolean; cdecl;
 
343
var
 
344
  vwsTrayIcon: TCustomTrayIcon absolute user_data;
 
345
begin
 
346
  Result := False;
 
347
  case PGdkEventButton(event)^.button of
 
348
    1:
 
349
    begin
 
350
      if Assigned(vwsTrayIcon.OnClick) then vwsTrayIcon.OnClick(vwsTrayIcon);
 
351
      if Assigned(vwsTrayIcon.OnMouseUp) then
 
352
       vwsTrayIcon.OnMouseUp(vwsTrayIcon, mbLeft, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
353
    end;
 
354
    
 
355
    2: if Assigned(vwsTrayIcon.OnMouseUp) then
 
356
        vwsTrayIcon.OnMouseUp(vwsTrayIcon, mbMiddle, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
357
 
 
358
    3:
 
359
    begin
 
360
      if Assigned(vwsTrayIcon.OnMouseUp) then
 
361
       vwsTrayIcon.OnMouseUp(vwsTrayIcon, mbRight, [], Round(PGdkEventButton(event)^.X), Round(PGdkEventButton(event)^.Y));
 
362
      if Assigned(vwsTrayIcon.PopUpMenu) then
 
363
       vwsTrayIcon.PopUpMenu.PopUp(Mouse.CursorPos.X, Mouse.CursorPos.Y);
 
364
     end;
 
365
  end;
 
366
end;
 
367
 
316
368
{$endif}
317
369
 
318
370
constructor TGtk2TrayIconHandle.Create(const wsTrayIcon: TCustomTrayIcon);
324
376
  if Available_GtkStatusIcon_2_10 then
325
377
  begin
326
378
    FStatusIcon := gtk_status_icon_new();
327
 
    gtk_status_icon_set_from_pixbuf(FStatusIcon, PGdkPixbuf(FTrayIcon.Icon.Handle));
 
379
    gtk_status_icon_set_from_pixbuf(FStatusIcon, {%H-}PGdkPixbuf(FTrayIcon.Icon.Handle));
328
380
    gtk_status_icon_set_tooltip(FStatusIcon, PChar(FTrayIcon.Hint));
329
381
    fEmbedded := gtk_status_icon_is_embedded(FStatusIcon);
330
382
 
331
383
    g_signal_connect(FStatusIcon, 'activate', TGCallback(@activate_cb_statusicon), fTrayIcon);
332
384
    g_signal_connect(FStatusIcon, 'popup-menu', TGCallback(@popup_cb_statusicon), fTrayIcon);
 
385
    g_signal_connect(FStatusIcon, 'button-press-event', TGCallback(@button_press_cb_statusicon), fTrayIcon);
 
386
    g_signal_connect(FStatusIcon, 'button-release-event', TGCallback(@button_release_cb_statusicon), fTrayIcon);
333
387
  end
334
388
  else
335
389
{$endif}
352
406
    //  Draws the icon
353
407
    with wsTrayIcon do
354
408
    begin
355
 
      DrawingArea := gtk_image_new_from_pixbuf(PGdkPixbuf(Icon.Handle));
 
409
      DrawingArea := gtk_image_new_from_pixbuf({%H-}PGdkPixbuf(Icon.Handle));
356
410
      gtk_widget_show(DrawingArea);
357
411
      gtk_container_add(GTK_CONTAINER(plug), DrawingArea);
358
412
    end;
364
418
{$ifdef UseStatusIcon}
365
419
  if FStatusIcon <> nil then
366
420
  begin
 
421
    gtk_status_icon_set_visible(FStatusIcon, False);
367
422
    g_object_unref(FStatusIcon);
368
423
    FStatusIcon := nil;
369
424
  end
479
534
  *  Now shows the GtkPlug
480
535
  *******************************************************************}
481
536
  TrayIconHandle.Show;
 
537
  {$ifdef UseStatusIcon}
 
538
  Result := True;
 
539
  {$else}
482
540
  if TrayIconHandle.fEmbedded then
483
541
    Result := True
484
542
  else
485
543
    Hide(ATrayIcon);
 
544
  {$endif}
486
545
end;
487
546
 
488
547
{*******************************************************************
499
558
class procedure TGtk2WSCustomTrayIcon.InternalUpdate(const ATrayIcon: TCustomTrayIcon);
500
559
begin
501
560
  if ATrayIcon.Handle <> 0 then
502
 
    TGtk2TrayIconHandle(ATrayIcon.Handle).Update(PGdkPixbuf(ATrayIcon.Icon.Handle), ATrayIcon.Hint);
 
561
    TGtk2TrayIconHandle(ATrayIcon.Handle).Update({%H-}PGdkPixbuf(ATrayIcon.Icon.Handle), ATrayIcon.Hint);
503
562
end;
504
563
 
505
564
{*******************************************************************