www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - gtkD window centering message up and no app on taskbar

reply Johnson Jones <JJ Dynomite.com> writes:
When trying to center the window. If one uses ALWAYS_CENTERED any 
resizing of the window is totally busted. CENTER also does not 
work. move(0,0) seems to not be relative to the main display. I'd 
basically like to center the window on the main display or at 
least be able to set coordinates properly. Windows sets (0,0) to 
be the lower left corner of the main display I believe. What 
happens is that the gtk window, when using 0,0 actually is like 
-1000,0 or something in windows coordinates and ends up on my 
secondary monitor.

When the app starts there's no taskbar icon. Luckily I still have 
the console shown but Eventually I'll need the taskbar. I'm not 
setting skipTaskBarHint, but I have tried both true and false 
without any difference.
Aug 05 2017
parent reply Mike Wey <mike-wey example.com> writes:
On 05-08-17 20:14, Johnson Jones wrote:
 When trying to center the window. If one uses ALWAYS_CENTERED any 
 resizing of the window is totally busted. CENTER also does not work. 
 move(0,0) seems to not be relative to the main display. I'd basically 
 like to center the window on the main display or at least be able to set 
 coordinates properly. Windows sets (0,0) to be the lower left corner of 
 the main display I believe. What happens is that the gtk window, when 
 using 0,0 actually is like -1000,0 or something in windows coordinates 
 and ends up on my secondary monitor.
 
 When the app starts there's no taskbar icon. Luckily I still have the 
 console shown but Eventually I'll need the taskbar. I'm not setting 
 skipTaskBarHint, but I have tried both true and false without any 
 difference.
 
gtk.Widget.translateCoordinates or gtk.Fixed could be useful for positioning the widgets. Windows will only show the taskbar icon if you are not running the application from the console. -- Mike Wey
Aug 05 2017
next sibling parent Johnson Jones <JJ Dynomite.com> writes:
On Saturday, 5 August 2017 at 20:56:10 UTC, Mike Wey wrote:
 On 05-08-17 20:14, Johnson Jones wrote:
 When trying to center the window. If one uses ALWAYS_CENTERED 
 any resizing of the window is totally busted. CENTER also does 
 not work. move(0,0) seems to not be relative to the main 
 display. I'd basically like to center the window on the main 
 display or at least be able to set coordinates properly. 
 Windows sets (0,0) to be the lower left corner of the main 
 display I believe. What happens is that the gtk window, when 
 using 0,0 actually is like -1000,0 or something in windows 
 coordinates and ends up on my secondary monitor.
 
 When the app starts there's no taskbar icon. Luckily I still 
 have the console shown but Eventually I'll need the taskbar. 
 I'm not setting skipTaskBarHint, but I have tried both true 
 and false without any difference.
 
gtk.Widget.translateCoordinates or gtk.Fixed could be useful for positioning the widgets. Windows will only show the taskbar icon if you are not running the application from the console.
Is there a way to get it to show up or have it correlate with the console's taskbar? What I'm finding is that if the window has no title bar(maximized) and/or behind other windows I have to do some window juggling to find it. I need the console for debugging. I could probably set the project as win32 and then create a console manually if necessary but seems to be overkill for something relatively basic.
Aug 06 2017
prev sibling next sibling parent reply Johnson Jones <JJ Dynomite.com> writes:
On Saturday, 5 August 2017 at 20:56:10 UTC, Mike Wey wrote:
 On 05-08-17 20:14, Johnson Jones wrote:
 When trying to center the window. If one uses ALWAYS_CENTERED 
 any resizing of the window is totally busted. CENTER also does 
 not work. move(0,0) seems to not be relative to the main 
 display. I'd basically like to center the window on the main 
 display or at least be able to set coordinates properly. 
 Windows sets (0,0) to be the lower left corner of the main 
 display I believe. What happens is that the gtk window, when 
 using 0,0 actually is like -1000,0 or something in windows 
 coordinates and ends up on my secondary monitor.
 
 When the app starts there's no taskbar icon. Luckily I still 
 have the console shown but Eventually I'll need the taskbar. 
 I'm not setting skipTaskBarHint, but I have tried both true 
 and false without any difference.
 
Windows will only show the taskbar icon if you are not running the application from the console.
This doesn't seem to be true. I switched over, changed everything to windows, and I still get no taskbar icon. I changed the settings L:Subsystem to windows and added the appropriate def file. I think I did this in another app and it worked fine. So it's probably a gtk glade setting(I was using the older glade versions that we talked about). Now I have no console window and no taskbar icon.
Aug 07 2017
parent Johnson Jones <JJ Dynomite.com> writes:
and I do have skipTaskbar disabled... tried enabling it with no 
long... and fidgeting with other settings and using a Window 
instead of Application Window.

Maybe gtk needs to be told that that the window is the "main 
window" of the application?
Aug 07 2017
prev sibling parent reply Johnson Jones <JJ Dynomite.com> writes:
On Saturday, 5 August 2017 at 20:56:10 UTC, Mike Wey wrote:
 Windows will only show the taskbar icon if you are not running 
 the application from the console.
Now in x64 it is showing, not in x86. So, not sure what's going on but at least it is showing. I was in a windows console and added a main.def but dmd says that it's not compatible with x64 or something: main.def(1) : warning LNK4017: EXETYPE statement not supported for the target platform; ignored main.def(4) : warning LNK4017: SUBSYSTEM statement not supported for the target platform; ignored but adding that file seemed to allow the icon like you said. I'm not doing anything different for x86 except switching gtk versions... but maybe there is a flag or setting somewhere that is causing the problem. and, in the x64 version I get both the console and gtk app task bar icons... which is what I originally wanted and expected.
Aug 07 2017
parent reply Mike Wey <mike-wey example.com> writes:
On 07-08-17 22:46, Johnson Jones wrote:
 On Saturday, 5 August 2017 at 20:56:10 UTC, Mike Wey wrote:
 Windows will only show the taskbar icon if you are not running the 
 application from the console.
Now in x64 it is showing, not in x86. So, not sure what's going on but at least it is showing. I was in a windows console and added a main.def but dmd says that it's not compatible with x64 or something: main.def(1) : warning LNK4017: EXETYPE statement not supported for the target platform; ignored main.def(4) : warning LNK4017: SUBSYSTEM statement not supported for the target platform; ignored but adding that file seemed to allow the icon like you said. I'm not doing anything different for x86 except switching gtk versions... but maybe there is a flag or setting somewhere that is causing the problem. and, in the x64 version I get both the console and gtk app task bar icons... which is what I originally wanted and expected.
This appears to be a GTK issue, a work around might be to get the Window handle from gtk and use the Windows API to set the taskbar visibility. Interestingly the icon shows up after restarting explorer.exe. For 64bit apps dmd uses the microsoft linker, so you probably have to use different flags to set the subsystem. -- Mike Wey
Aug 07 2017
parent reply Johnson Jones <JJ Dynomite.com> writes:
On Monday, 7 August 2017 at 20:57:08 UTC, Mike Wey wrote:
 On 07-08-17 22:46, Johnson Jones wrote:
 [...]
This appears to be a GTK issue, a work around might be to get the Window handle from gtk and use the Windows API to set the taskbar visibility.
Yeah, I was thinking about that but haven't yet figured out how to find the window handle ;/
Aug 07 2017
parent reply Mike Wey <mike-wey example.com> writes:
On 07-08-17 23:52, Johnson Jones wrote:
 On Monday, 7 August 2017 at 20:57:08 UTC, Mike Wey wrote:
 On 07-08-17 22:46, Johnson Jones wrote:
 [...]
This appears to be a GTK issue, a work around might be to get the Window handle from gtk and use the Windows API to set the taskbar visibility.
Yeah, I was thinking about that but haven't yet figured out how to find the window handle ;/
To get the Window handle you could use this for 32bit Windows: ``` import gtk.c.functions; // Danger, Will Robinson! HANDLE handle = *(cast(HANDLE*)((cast(void*)gtk_widget_get_window(w.getWidgetStruct()))+4)); ``` Where w is your application window, i used this in the map event signal so the handle is actually set. To complicate things there is a race condition in gdk some ware so at random the handle isn't valid. I haven't been able to set the taskbar icon with is tough. The two attempts: -Setting the parent window to null as windows with no parent should have an taskbar icon: ``` ShowWindow(handle, SW_HIDE); SetParent(handle, null); ShowWindow(handle, SW_SHOW); ``` Or set the extended window style to WS_EX_APPWINDOW as that should fore an taskbar icon according to msdn. ``` ShowWindow(handle, SW_HIDE); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); ``` -- Mike Wey
Aug 08 2017
parent reply Johnson Jones <JJ Dynomite.com> writes:
On Tuesday, 8 August 2017 at 21:37:40 UTC, Mike Wey wrote:
 On 07-08-17 23:52, Johnson Jones wrote:
 On Monday, 7 August 2017 at 20:57:08 UTC, Mike Wey wrote:
 On 07-08-17 22:46, Johnson Jones wrote:
 [...]
This appears to be a GTK issue, a work around might be to get the Window handle from gtk and use the Windows API to set the taskbar visibility.
Yeah, I was thinking about that but haven't yet figured out how to find the window handle ;/
To get the Window handle you could use this for 32bit Windows: ``` import gtk.c.functions; // Danger, Will Robinson! HANDLE handle = *(cast(HANDLE*)((cast(void*)gtk_widget_get_window(w.getWidgetStruct()))+4)); ``` Where w is your application window, i used this in the map event signal so the handle is actually set. To complicate things there is a race condition in gdk some ware so at random the handle isn't valid. I haven't been able to set the taskbar icon with is tough. The two attempts: -Setting the parent window to null as windows with no parent should have an taskbar icon: ``` ShowWindow(handle, SW_HIDE); SetParent(handle, null); ShowWindow(handle, SW_SHOW); ``` Or set the extended window style to WS_EX_APPWINDOW as that should fore an taskbar icon according to msdn. ``` ShowWindow(handle, SW_HIDE); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); ```
Yeah, they keep returning null or some integer < 100(probably junk values). There surely has to be a way to get the windows handle? We could use Win32 api and "search" for the window and get the handle but that isn't that safe unless we can specify the windows classname or title uniquely. Things like ispy can find windows by coordinates but I think they essentially use the above methods and region compares. e.g., there is no FindWindowByCoordinates... which still wouldn't be very accurate. // Fixup missing taskbar icon void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) { import core.sys.windows.winuser, gdk.Window; auto x = window.getWidgetStruct(); auto y = ((cast(void*)gtk.gtk_widget_get_window(window.getWidgetStruct()))+4); auto handle = *(cast(core.sys.windows.winuser.HANDLE*)((cast(void*)gtk.gtk_widget_get_window(window.getWidgetStruct()))+4)); ShowWindow(handle, SW_HIDE); SetParent(handle, null); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); } return; } Sometimes I get y = 4, which I think is what you were saying before. Sometimes I get handle = < 100. I've tried in a few places but not after Main.run(), which maybe is needed for gtk to register the window and all that? I guess I can run that function in a callback and see if it is valid... Didn't work. I can't really find anything on line about getting a windows handle from gtk ;/ There is this: https://stackoverflow.com/questions/23021327/how-i-can-get-drawingarea-window-handle-in-gtk3 Gdk.threads_enter() #get the gdk window and the corresponding c gpointer drawingareawnd = drawingarea.get_property("window") #make sure to call ensure_native before e.g. on realize if not drawingareawnd.has_native(): print("Your window is gonna freeze as soon as you move or resize it...") ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object] drawingarea_gpointer = ctypes.pythonapi.PyCapsule_GetPointer(drawingareawnd.__gpointer__, None) #get the win32 handle gdkdll = ctypes.CDLL ("libgdk-3-0.dll") hnd = gdkdll.gdk_win32_window_get_handle(drawingarea_gpointer) #do what you want with it ... I pass it to a gstreamer videosink Gdk.threads_leave() which suggests that maybe gdk_win32_window_get_handle can be used Ok, I was able to get it to work using that code. I had to do some wonky dll imports and stuff but that function seems to be the correct one. I could not use it until after the window was created(I used it in a button handler), else it crashed the app for some reason. import core.sys.windows.winuser, gdk.Window; auto handle = cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct())); ShowWindow(handle, SW_HIDE); SetParent(handle, null); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); Seems to work. So you might want to add gdk_win32_window_get_handle as an export in gtkD so it can be used easier. The full code is: void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) { import core.sys.windows.winuser, gdk.Window; auto handle = cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct())); ShowWindow(handle, SW_HIDE); SetParent(handle, null); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); } return; } Probably could be designed better. If I use it like MainWindow.addOnShow((Widget widget) { MainWindow.SetTaskBarIcon(); }); the window never shows and a lot of gtk errors are given about updating the window. (test.exe:4440): Gdk-WARNING **: gdkwindow-win32.c:439: UpdateLayeredWindow failed with code 87: The parameter is incorrect. which comes from this line: SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW); So maybe we have to GetWindowLong and modify it slightly SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW); which doesn't work. The error is no longer their but the icon doesn't show up. But, finally, this does seem to work: // Fixup missing taskbar icon void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) { import core.sys.windows.winuser, gdk.Window; auto handle = cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct())); ShowWindow(handle, SW_HIDE); // SetParent(handle, null); SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW); ShowWindow(handle, SW_SHOW); } return; } Of course, along with this: MainWindow.addOnShow((Widget widget) { MainWindow.SetTaskBarIcon(); });
Aug 08 2017
parent reply Mike Wey <mike-wey example.com> writes:
On 09-08-17 01:00, Johnson Jones wrote:
 But, finally, this does seem to work:
 
 
 // Fixup missing taskbar icon
 void SetTaskBarIcon(gtk.ApplicationWindow window)
 {
 
      version(Windows)
          version(X86)
          {
              import core.sys.windows.winuser, gdk.Window;
              auto handle = 
 cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.
etWidgetStruct())); 
 
              ShowWindow(handle, SW_HIDE);
 //            SetParent(handle, null);
              SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, 
 GWL_EXSTYLE) | WS_EX_APPWINDOW);
              ShowWindow(handle, SW_SHOW);
          }
      return;
 }
 
 Of course, along with this:
 
 
 MainWindow.addOnShow((Widget widget) { MainWindow.SetTaskBarIcon(); });
`gdk_win32_window_get_handle` I spend way to much time looking for a function like this, before giving up and doing the pointer arithmetic. This should do it for getting the function: ``` import gtkd.Loader; import gdk.c.functions; //Still at gtkc.gdk for 3.6. __gshared extern(C) HANDLE function(GdkWindow*) gdk_win32_window_get_handle; Linker.link(gdk_win32_window_get_handle, "gdk_win32_window_get_handle", LIBRARY_GDK); ``` I did find out that gdk set the Desktop window as the parent window and doesn't set `WS_EX_APPWINDOW` i should try if setting it for top level windows would fix this from within gdk. -- Mike Wey
Aug 09 2017
next sibling parent Johnson <Johnson Johnson.com> writes:
On Wednesday, 9 August 2017 at 15:10:46 UTC, Mike Wey wrote:
 On 09-08-17 01:00, Johnson Jones wrote:
 But, finally, this does seem to work:
 
 
 // Fixup missing taskbar icon
 void SetTaskBarIcon(gtk.ApplicationWindow window)
 {
 
      version(Windows)
          version(X86)
          {
              import core.sys.windows.winuser, gdk.Window;
              auto handle = 
 cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct()));
 
              ShowWindow(handle, SW_HIDE);
 //            SetParent(handle, null);
              SetWindowLong(handle, GWL_EXSTYLE, 
 GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW);
              ShowWindow(handle, SW_SHOW);
          }
      return;
 }
 
 Of course, along with this:
 
 
 MainWindow.addOnShow((Widget widget) { 
 MainWindow.SetTaskBarIcon(); });
`gdk_win32_window_get_handle` I spend way to much time looking for a function like this, before giving up and doing the pointer arithmetic. This should do it for getting the function: ``` import gtkd.Loader; import gdk.c.functions; //Still at gtkc.gdk for 3.6. __gshared extern(C) HANDLE function(GdkWindow*) gdk_win32_window_get_handle; Linker.link(gdk_win32_window_get_handle, "gdk_win32_window_get_handle", LIBRARY_GDK); ``` I did find out that gdk set the Desktop window as the parent window and doesn't set `WS_EX_APPWINDOW` i should try if setting it for top level windows would fix this from within gdk.
ok, I guess I was still using 3.6 cause I couldn't find anything about gdk.c.functions and had to import it myself. Upgraded. Actually, searching the install for gdk.c.functions returns nothing ;/ Oops, I guess you meant the master on git hub. Could you add a link on the main gtkD page to the github site? Anyways, looks like this problem is solved/nearly solved so I'll move on to the next ;)
Aug 09 2017
prev sibling next sibling parent Johnson <Johnson Johnson.com> writes:
Also, could there be an easier way to import everything that is 
generally required?

I'm using an import script that does the work but I have to 
replace it upgrade time I upgrade gtkD(since I have to delete 
everything). I find that having a ton of imports is a big ugly.

What I use is, which was basically extracted from some gtkD 
example:
[It also lets use generate json for it a bit easier and use with 
easier. Probably could be enhanced but just something I through 
together]

module GtkD_All;

public import gtk.AboutDialog;
public import gtk.AccelGroup;
public import gtk.AccelLabel;
public import gtk.AccelMap;
public import gtk.Accessible;
public import gtk.Action;
public import gtk.ActionableIF;
public import gtk.ActionableT;
public import gtk.ActionBar;
public import gtk.ActionGroup;
public import gtk.ActivatableIF;
public import gtk.ActivatableT;
public import gtk.Adjustment;
public import gtk.Alignment;
public import gtk.AppChooserButton;
public import gtk.AppChooserDialog;
public import gtk.AppChooserIF;
public import gtk.AppChooserT;
public import gtk.AppChooserWidget;
public import gtk.Application;
public import gtk.ApplicationWindow;
public import gtk.Arrow;
public import gtk.ArrowAccessible;
public import gtk.AspectFrame;
public import gtk.Assistant;
public import gtk.Bin;
public import gtk.BindingEntry;
public import gtk.BindingSet;
public import gtk.BooleanCellAccessible;
public import gtk.Border;
public import gtk.Box;
public import gtk.BuildableIF;
public import gtk.BuildableT;
public import gtk.Builder;
public import gtk.Button;
public import gtk.ButtonAccessible;
public import gtk.ButtonBox;
public import gtk.Calendar;
public import gtk.CellAccessible;
public import gtk.CellAccessibleParentIF;
public import gtk.CellAccessibleParentT;
public import gtk.CellArea;
public import gtk.CellAreaBox;
public import gtk.CellAreaClass;
public import gtk.CellAreaContext;
public import gtk.CellEditable;
public import gtk.CellEditableIF;
public import gtk.CellEditableT;
public import gtk.CellLayoutIF;
public import gtk.CellLayoutT;
public import gtk.CellRenderer;
public import gtk.CellRendererAccel;
public import gtk.CellRendererClass;
public import gtk.CellRendererCombo;
public import gtk.CellRendererPixbuf;
public import gtk.CellRendererProgress;
public import gtk.CellRendererSpin;
public import gtk.CellRendererSpinner;
public import gtk.CellRendererText;
public import gtk.CellRendererToggle;
public import gtk.CellView;
public import gtk.CheckButton;
public import gtk.CheckMenuItem;
public import gtk.CheckMenuItemAccessible;
public import gtk.Clipboard;
public import gtk.ColorButton;
public import gtk.ColorChooserDialog;
public import gtk.ColorChooserIF;
public import gtk.ColorChooserT;
public import gtk.ColorChooserWidget;
public import gtk.ColorSelection;
public import gtk.ColorSelectionDialog;
public import gtk.ComboBox;
public import gtk.ComboBoxAccessible;
public import gtk.ComboBoxText;
public import gtk.Container;
public import gtk.ContainerAccessible;
public import gtk.ContainerCellAccessible;
public import gtk.ContainerClass;
public import gtk.CssProvider;
public import gtk.CssSection;
public import gtk.Dialog;
public import gtk.DragAndDrop;
public import gtk.DrawingArea;
public import gtk.EditableIF;
public import gtk.EditableT;
public import gtk.Entry;
public import gtk.EntryAccessible;
public import gtk.EntryBuffer;
public import gtk.EntryCompletion;
public import gtk.EventBox;
public import gtk.EventController;
public import gtk.Expander;
public import gtk.ExpanderAccessible;
public import gtk.FileChooserButton;
public import gtk.FileChooserDialog;
public import gtk.FileChooserIF;
public import gtk.FileChooserNative;
public import gtk.FileChooserT;
public import gtk.FileChooserWidget;
public import gtk.FileFilter;
public import gtk.Fixed;
public import gtk.FlowBox;
public import gtk.FlowBoxAccessible;
public import gtk.FlowBoxChild;
public import gtk.FlowBoxChildAccessible;
public import gtk.FontButton;
public import gtk.FontChooserDialog;
public import gtk.FontChooserIF;
public import gtk.FontChooserT;
public import gtk.FontChooserWidget;
public import gtk.FontSelection;
public import gtk.FontSelectionDialog;
public import gtk.Frame;
public import gtk.FrameAccessible;
public import gtk.Gesture;
public import gtk.GestureDrag;
public import gtk.GestureLongPress;
public import gtk.GestureMultiPress;
public import gtk.GesturePan;
public import gtk.GestureRotate;
public import gtk.GestureSingle;
public import gtk.GestureSwipe;
public import gtk.GestureZoom;
public import gtk.GLArea;
public import gtk.Gradient;
public import gtk.Grid;
public import gtk.HandleBox;
public import gtk.HBox;
public import gtk.HButtonBox;
public import gtk.HeaderBar;
public import gtk.HPaned;
public import gtk.HScale;
public import gtk.HScrollbar;
public import gtk.HSeparator;
public import gtk.HSV;
public import gtk.IconFactory;
public import gtk.IconInfo;
public import gtk.IconSet;
public import gtk.IconSize;
public import gtk.IconSource;
public import gtk.IconTheme;
public import gtk.IconView;
public import gtk.IconViewAccessible;
public import gtk.Image;
public import gtk.ImageAccessible;
public import gtk.ImageCellAccessible;
public import gtk.ImageMenuItem;
public import gtk.IMContext;
public import gtk.IMContextSimple;
public import gtk.IMMulticontext;
public import gtk.InfoBar;
public import gtk.Invisible;
public import gtk.Label;
public import gtk.LabelAccessible;
public import gtk.Layout;
public import gtk.LevelBar;
public import gtk.LevelBarAccessible;
public import gtk.LinkButton;
public import gtk.LinkButtonAccessible;
public import gtk.ListBox;
public import gtk.ListBoxAccessible;
public import gtk.ListBoxRow;
public import gtk.ListBoxRowAccessible;
public import gtk.ListStore;
public import gtk.LockButton;
public import gtk.LockButtonAccessible;
public import gtk.Main;
public import gtk.MainWindow;
public import gtk.Menu;
public import gtk.MenuAccessible;
public import gtk.MenuBar;
public import gtk.MenuButton;
public import gtk.MenuButtonAccessible;
public import gtk.MenuItem;
public import gtk.MenuItemAccessible;
public import gtk.MenuShell;
public import gtk.MenuShellAccessible;
public import gtk.MenuToolButton;
public import gtk.MessageDialog;
public import gtk.Misc;
public import gtk.ModelButton;
public import gtk.MountOperation;
public import gtk.NativeDialog;
public import gtk.Notebook;
public import gtk.NotebookAccessible;
public import gtk.NotebookPageAccessible;
public import gtk.NumerableIcon;
public import gtk.OffscreenWindow;
public import gtk.OrientableIF;
public import gtk.OrientableT;
public import gtk.Overlay;
public import gtk.PadController;
public import gtk.PageSetup;
public import gtk.Paned;
public import gtk.PanedAccessible;
public import gtk.PaperSize;
public import gtk.PlacesSidebar;
public import gtk.Plug;
public import gtk.Popover;
public import gtk.PopoverAccessible;
public import gtk.PopoverMenu;
public import gtk.PopupBox;
public import gtk.PrintContext;
public import gtk.PrintOperation;
public import gtk.PrintOperationPreview;
public import gtk.PrintOperationPreviewIF;
public import gtk.PrintOperationPreviewT;
public import gtk.PrintSettings;
public import gtk.ProgressBar;
public import gtk.ProgressBarAccessible;
public import gtk.RadioAction;
public import gtk.RadioButton;
public import gtk.RadioButtonAccessible;
public import gtk.RadioMenuItem;
public import gtk.RadioMenuItemAccessible;
public import gtk.RadioToolButton;
public import gtk.Range;
public import gtk.RangeAccessible;
public import gtk.RcProperty;
public import gtk.RcStyle;
public import gtk.RecentAction;
public import gtk.RecentChooserDialog;
public import gtk.RecentChooserIF;
public import gtk.RecentChooserMenu;
public import gtk.RecentChooserT;
public import gtk.RecentChooserWidget;
public import gtk.RecentFilter;
public import gtk.RecentInfo;
public import gtk.RecentManager;
public import gtk.RendererCellAccessible;
public import gtk.Requisition;
public import gtk.Revealer;
public import gtk.Scale;
public import gtk.ScaleAccessible;
public import gtk.ScaleButton;
public import gtk.ScaleButtonAccessible;
public import gtk.ScrollableIF;
public import gtk.ScrollableT;
public import gtk.Scrollbar;
public import gtk.ScrolledWindow;
public import gtk.ScrolledWindowAccessible;
public import gtk.SearchBar;
public import gtk.SearchEntry;
public import gtk.SelectionData;
public import gtk.Separator;
public import gtk.SeparatorMenuItem;
public import gtk.SeparatorToolItem;
public import gtk.Settings;
public import gtk.ShortcutLabel;
public import gtk.ShortcutsGroup;
public import gtk.ShortcutsSection;
public import gtk.ShortcutsShortcut;
public import gtk.ShortcutsWindow;
public import gtk.SizeGroup;
public import gtk.Socket;
public import gtk.SpinButton;
public import gtk.SpinButtonAccessible;
public import gtk.Spinner;
public import gtk.SpinnerAccessible;
public import gtk.Stack;
public import gtk.StackAccessible;
public import gtk.StackSidebar;
public import gtk.StackSwitcher;
public import gtk.Statusbar;
public import gtk.StatusbarAccessible;
public import gtk.StatusIcon;
public import gtk.StockItem;
public import gtk.Style;
public import gtk.StyleContext;
public import gtk.StyleProperties;
public import gtk.StyleProviderIF;
public import gtk.StyleProviderT;
public import gtk.Switch;
public import gtk.SwitchAccessible;
public import gtk.SymbolicColor;
public import gtk.Table;
public import gtk.TargetEntry;
public import gtk.TargetList;
public import gtk.TearoffMenuItem;
public import gtk.Testing;
public import gtk.TextAttributes;
public import gtk.TextBuffer;
public import gtk.TextCellAccessible;
public import gtk.TextChildAnchor;
public import gtk.TextIter;
public import gtk.TextMark;
public import gtk.TextTag;
public import gtk.TextTagTable;
public import gtk.TextView;
public import gtk.TextViewAccessible;
public import gtk.ThemingEngine;
public import gtk.ToggleAction;
public import gtk.ToggleButton;
public import gtk.ToggleButtonAccessible;
public import gtk.ToggleToolButton;
public import gtk.Toolbar;
public import gtk.ToolButton;
public import gtk.ToolItem;
public import gtk.ToolItemGroup;
public import gtk.ToolPalette;
public import gtk.ToolShellIF;
public import gtk.ToolShellT;
public import gtk.Tooltip;
public import gtk.ToplevelAccessible;
public import gtk.TreeDragDestIF;
public import gtk.TreeDragDestT;
public import gtk.TreeDragSourceIF;
public import gtk.TreeDragSourceT;
public import gtk.TreeIter;
public import gtk.TreeIterError;
public import gtk.TreeModel;
public import gtk.TreeModelFilter;
public import gtk.TreeModelIF;
public import gtk.TreeModelSort;
public import gtk.TreeModelT;
public import gtk.TreeNode;
public import gtk.TreePath;
public import gtk.TreeRowReference;
public import gtk.TreeSelection;
public import gtk.TreeSortableIF;
public import gtk.TreeSortableT;
public import gtk.TreeStore;
public import gtk.TreeView;
public import gtk.TreeViewAccessible;
public import gtk.TreeViewColumn;
public import gtk.UIManager;
public import gtk.VBox;
public import gtk.VButtonBox;
public import gtk.Version;
public import gtk.Viewport;
public import gtk.VolumeButton;
public import gtk.VPaned;
public import gtk.VScale;
public import gtk.VScrollbar;
public import gtk.VSeparator;
public import gtk.Widget;
public import gtk.WidgetAccessible;
public import gtk.WidgetClass;
public import gtk.WidgetPath;
public import gtk.Window;
public import gtk.WindowAccessible;
public import gtk.WindowGroup;

// Loads the glade interface element id's and types directly from 
the glade interface file so we do not have to declare them 
manually
// Use:  ("Glade") { 
mixin(DeclareGladeInterfaceElements!gladeFile); } where ever 
variables will be defined and InstantiateGladeInterfaceElements( 
to initalize them
public string DeclareGladeInterfaceElements(string filename)()
{
	auto token1 = "<object class=\"";
	auto token2 = " id=\"";
	string res = "";
	import std.file;
	auto data = import(filename);
	for(int i = 0; i < data.length; i++)
	{
		// Matched class/object type, get name actual type then get id 
if it has one.
		if (i+token1.length < data.length && data[i..i+token1.length] 
== token1)
		{
			i += token1.length;
			auto pos = i;
			while(i < data.length && data[i] != '"') i++;
			auto type = cast(string)data[pos..i];

			// Match id if it has one.
			while(i+token2.length < data.length && data[i] != '>' && 
data[i] != '<' && data[i] != '"' && data[i..i+token2.length] != 
token2) i++;
			i++;

			if (data[i] == '>') { continue; }
			i += token2.length;
			pos = i;
			if (data[i] == '>') { continue; }
			while(i+1 < data.length && data[i] != '"') i++;
			res ~= "public gtk."~type[3..$] ~ " " ~ data[pos..i] ~ 
";\n";			
		}

		if (i > data.length - 7130)
		{
			continue;
		}
	}
	return res;
}

public void InstantiateGladeInterfaceElements(T)(Builder builder, 
T t)
{
	import std.meta;		
	foreach(m; __traits(allMembers, T))
	{
		mixin("enum w = __traits(getAttributes, T."~m~");");		
		static if (w.length > 0 && w[0] == "Glade")
		{
			mixin("t."~m~" = 
(cast(typeof(T."~m~"))builder.getObject(`"~m~"`));");
			mixin("if (t."~m~" is null) { error(\"Error: `"~m~"` not 
found, User Interface Corrupted, Cannot continue!\"); }");
		}
	}
}


void error(string err)
{
	import core.stdc.stdlib, std.stdio;
	writeln(err);
	getchar();
	
	core.stdc.stdlib.exit(-1);
}
Aug 09 2017
prev sibling parent reply Johnson Jones <JJ Dynomite.com> writes:
On Wednesday, 9 August 2017 at 15:10:46 UTC, Mike Wey wrote:
 On 09-08-17 01:00, Johnson Jones wrote:
 But, finally, this does seem to work:
 
 
 // Fixup missing taskbar icon
 void SetTaskBarIcon(gtk.ApplicationWindow window)
 {
 
      version(Windows)
          version(X86)
          {
              import core.sys.windows.winuser, gdk.Window;
              auto handle = 
 cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct()));
 
              ShowWindow(handle, SW_HIDE);
 //            SetParent(handle, null);
              SetWindowLong(handle, GWL_EXSTYLE, 
 GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW);
              ShowWindow(handle, SW_SHOW);
          }
      return;
 }
 
 Of course, along with this:
 
 
 MainWindow.addOnShow((Widget widget) { 
 MainWindow.SetTaskBarIcon(); });
`gdk_win32_window_get_handle` I spend way to much time looking for a function like this, before giving up and doing the pointer arithmetic. This should do it for getting the function: ``` import gtkd.Loader; import gdk.c.functions; //Still at gtkc.gdk for 3.6. __gshared extern(C) HANDLE function(GdkWindow*) gdk_win32_window_get_handle; Linker.link(gdk_win32_window_get_handle, "gdk_win32_window_get_handle", LIBRARY_GDK); ``` I did find out that gdk set the Desktop window as the parent window and doesn't set `WS_EX_APPWINDOW` i should try if setting it for top level windows would fix this from within gdk.
Ok, I added import core.sys.windows.winuser; __gshared extern(C) core.sys.windows.winuser.HANDLE function(GdkWindow*) gdk_win32_window_get_handle; Linker.link(gdk_win32_window_get_handle, "gdk_win32_window_get_handle", LIBRARY_GDK); to GtkD\generated\gtkd\gdk\c\functions.d and rebuilt and it seems to work. Hopefully that is the right place so in the future when I replace GtkD with it won't show up as a bug in my code somewhere. I assume master will be updated with this at some point?
Aug 09 2017
parent Mike Wey <mike-wey example.com> writes:
On 09-08-17 23:54, Johnson Jones wrote:
 Ok, I added
 
      import core.sys.windows.winuser;
      __gshared extern(C) core.sys.windows.winuser.HANDLE 
 function(GdkWindow*) gdk_win32_window_get_handle;
      Linker.link(gdk_win32_window_get_handle, 
 "gdk_win32_window_get_handle", LIBRARY_GDK);
 
 to GtkD\generated\gtkd\gdk\c\functions.d
 
 and rebuilt and it seems to work. Hopefully that is the right place so 
 in the future when I replace GtkD with it won't show up as a bug in my 
 code somewhere. I assume master will be updated with this at some point?
That would be the correct place. If it is added to GtkD it won't be in functions.d, which is generated. It would be something like: gdk.c.win32. -- Mike Wey
Aug 10 2017