mono / gtk-sharp Goto Github PK
View Code? Open in Web Editor NEWGtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
Home Page: http://www.mono-project.com/GtkSharp
License: Other
Gtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
Home Page: http://www.mono-project.com/GtkSharp
License: Other
The Gtk# website can be found at: http://www.mono-project.com/GtkSharp Gtk# is a .NET language binding for the GTK+ toolkit and assorted GNOME libraries. Gtk# is free software, licensed under the GNU LGPL. Building & Installing Gtk#: --------------------------- Install the gtk-3 development headers first. On Debian, this can be done using: apt-get install libgtk-3-dev The build is the traditional: ./configure make make install You may want to consider using configure's prefix option to install Gtk# using the same prefix as Mono. That way all of your .NET assemblies get placed in the same place, and you don't need to do any extra "configuring" to make it so mono (and mint) can find your assemblies. In other words, doing something like: ./configure --prefix=`pkg-config --variable=prefix mono` make make install If you are compiling from GIT, you will need libtool and the auto* tools and will need to replace the configure above with autogen.sh. The gui-thread-check profiler module. ------------------------------------- Since version 3 of gtk# a profiler called "gui-thread-check" is included as part of the install for debugging purposes. (It's located in the subfolder gtk/gui-thread-check .) This profiler module can be used to check if a GTK# application is trying to invoke gtk or gdk methods from a thread which is not the main GUI thread. To use it, run your application with the command: mono --profile=gui-thread-check yourapp.exe If the profiler is properly installed, you'll see an output like this: *** Running with gui-thread-check *** *** GUI THREAD INITIALIZED: 2861676352 While the application is running, if the profiler detects a non-gui thread invoking gtk methods, it will print a warning message together with a stack trace. For example: *** GTK CALL NOT IN GUI THREAD: Widget.gtk_widget_get_parent Widget.get_Parent SourceEditorWidget.SetLastActiveEditor SourceEditorWidget.get_TextEditor SourceEditorWidget.get_Document SourceEditorWidget.HandleParseInformationUpdaterWorkerThreadDoWork BackgroundWorker.OnDoWork BackgroundWorker.ProcessWorker Discussion & Support: --------------------- A mailing list for Gtk# discussion is available. You can subscribe to the mailing list by visiting: http://lists.ximian.com/mailman/listinfo/gtk-sharp-list And following the instructions (on that page) to subscribe. Messages are posted on this mailing list by sending them to: [email protected] (The mailing list requires you to subscribe in order to post messages.) An archive of this mailing list can be found at: http://lists.ximian.com/archives/public/gtk-sharp-list/ Also, people can get help with and discuss Gtk# on IRC via the #gtk# or #mono channels on the irc.gnome.org IRC server. People looking for general help with C# should visit the #c# channel on irc.freenode.net IRC server. Developers: ----------- For developers wishing to "get started" with Gtk#, they are encouraged to read the Mono Hand Book: http://www.mono-project.com/docs/gui/gtksharp/ Hackers: -------- For those who wish to help with the development of Gtk#, they should read the file named: HACKING. Also, anyone wishing to hack Gtk# is encouraged to join the Gtk# mailing list. And to visit the #gtk# IRC channel (on irc.gnome.org). Join the chat at https://gitter.im/mono/gtk-sharp
We have a fairly large product written in GtkSharp using Mono (Linux and macOS) and .NET Framework (Windows).
We have been using Gtk3 for a very long time, but our application is now becoming very unstable because of memory leaks. GtkSharp is simple not able to release native memory.
We have testet with native C gtk3 program, simple creating 1000 dialog boxes and calling Hide and Destroy on them. Valgrind is reporting no memory leaks. The same program creating 1000 dialogs using C#, valgrind is reporting massive native memory leaks, as do Memory Profiler on Windows.
We have been trying to solve this for some time, but have trouble finding the cause.
I hope that someone in here is able to help us, finding this bug in the GtkSharp (wrapper).
See also: GtkSharp/GtkSharp#82
GTK# environment variable conflicts with GTK+ environment variable... since both uses same variable name:
GTKDIR / GTK_BASEPATH ...
So I think GTK# must uses different name. Because many users like me installed both GTKs on one machine
Something like GTKNET_DIR or GTKNET_BASEPATH would be great
Properties found in a glade file cannot be set through monoBasic (or VBnet, whichever is appropriate). This is true at least for the GtkButton.
In a glade file a GtkButton may have:
<property name="label">gtk-quit</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
which cannot be set in VBnet since (with the exception of the Label property) they do not exist as "member" functions. In addition a "set_property" (or something like this "Property_set" or alike) also does not exist as "member" function.
Sorry if this is not the place to report this problem.
Does gtk-2 work for windows x64? Do you have any guidance on building win x64 binaries?
In Gtk3 I got into problem on debugging Gtk-Warning-messages as:
Gtk-WARNING **: 17:24:18.112: Attempting to add a widget with type GtkBox to a container of type GtkBox, but the widget is already inside a container of type GtkBox, please remove the widget from its existing container first.
I tried to setup an log-handler but it seems to be ignored for that kind ob messages.
GLib.Log.SetLogHandler (null, GLib.LogLevelFlags.All, GLibLog);
GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.All, GLibLog);
GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.All, GLibLog);
GLib.Log.SetDefaultHandler (GLibLog);
"GLibLog" is my handler function for being able to place an break-point there.
What can help to resolve that Problem?
namespace Project1
{
public class NodeViewExample : Gtk.Window
{
public NodeViewExample() : base("NodeView")
{
SetSizeRequest(200, 150);
// Create our TreeView and add it as our child widget
Gtk.NodeView view = new Gtk.NodeView(Store);
Add(view);
// Create a column with title Artist and bind its renderer to model column 0
view.AppendColumn("Artist", new Gtk.CellRendererText(), "text", 0);
// Create a column with title 'Song Title' and bind its renderer to model column 1
view.AppendColumn("Song Title", new Gtk.CellRendererText(), "text", 1);
view.ShowAll();
}
protected override bool OnDeleteEvent(Gdk.Event ev)
{
Gtk.Application.Quit();
return true;
}
Gtk.NodeStore store;
Gtk.NodeStore Store
{
get
{
if (store == null)
{
store = new Gtk.NodeStore(typeof(MyTreeNode));
store.AddNode(new MyTreeNode("The Beatles", "Yesterday"));
store.AddNode(new MyTreeNode("Peter Gabriel", "In Your Eyes"));
store.AddNode(new MyTreeNode("Rush", "Fly By Night"));
}
return store;
}
}
public static void Main()
{
Gtk.Application.Init();
NodeViewExample win = new NodeViewExample();
win.Show();
Gtk.Application.Run();
}
}
}
it should contain 3 row data and 1 line column header.
Artist | Song Title |
---|---|
The Beatles | Yesterday |
Peter Gabriel | In Your Eyes |
Rush | Fly By Night |
[ ] macOS
[ ] Linux
[*] Windows
win 10:
Please paste the stack trace here if available.
What is shit?
Why do I should not use Gtk Sharp 3.x What do I miss that?????
gui-thread-check.c:90:1: warning: no previous prototype for ‘mono_profiler_startup’ [-Wmissing-prototypes]
mono_profiler_startup (const char *desc)
^
gui-thread-check.c: In function ‘mono_profiler_startup’:
gui-thread-check.c:94:2: warning: implicit declaration of function ‘mono_profiler_install’ [-Wimplicit-function-declaration]
mono_profiler_install (NULL, NULL);
^
gui-thread-check.c:94:2: warning: nested extern declaration of ‘mono_profiler_install’ [-Wnested-externs]
gui-thread-check.c:95:2: warning: implicit declaration of function ‘mono_profiler_install_enter_leave’ [-Wimplicit-function-declaration]
mono_profiler_install_enter_leave (simple_method_enter, NULL);
^
gui-thread-check.c:95:2: warning: nested extern declaration of ‘mono_profiler_install_enter_leave’ [-Wnested-externs]
gui-thread-check.c:96:2: warning: implicit declaration of function ‘mono_profiler_set_events’ [-Wimplicit-function-declaration]
mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE);
^
gui-thread-check.c:96:2: warning: nested extern declaration of ‘mono_profiler_set_events’ [-Wnested-externs]
gui-thread-check.c:96:28: error: ‘MONO_PROFILE_ENTER_LEAVE’ undeclared (first use in this function)
mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE);
^
gui-thread-check.c:96:28: note: each undeclared identifier is reported only once for each function it appears in
Makefile:459: recipe for target 'gui-thread-check.lo' failed
make[4]: *** [gui-thread-check.lo] Error 1
make[4]: Leaving directory '/home/sourceskyboxer/gtk-sharp/gtk/gui-thread-check/profiler'
Makefile:387: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/sourceskyboxer/gtk-sharp/gtk/gui-thread-check'
Makefile:603: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/sourceskyboxer/gtk-sharp/gtk'
Makefile:447: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/sourceskyboxer/gtk-sharp'
Makefile:375: recipe for target 'all' failed
make: *** [all] Error 2
Please listen me! I want recompile for Gtk Sharp 3.xx for Mono and OpenTK. Because Mono assemblies was updated to 5.19.0 That is why I need "recompile" with Gtk Sharp 3 and OpenTK. But OpenTK is already recompiled but Gtk Sharp 3 not :(
I`ve opened this solution on Monodevelop IDE and wanted to build it but saw strange namespaces:
Mono.Cecil;
Mono.Cecil.Cil;
Where can I take it?
When I use this code
using (Pango.Layout layout = Pango.CairoHelper.CreateLayout(cr))
{
layout.Width = Pango.Units.FromPixels(500);
layout.Height = Pango.Units.FromPixels(500);
layout.Wrap = Pango.WrapMode.Word;
layout.Alignment = Pango.Alignment.Left;
layout.Ellipsize = Pango.EllipsizeMode.Start;
layout.FontDescription = Pango.FontDescription.FromString("Ahafoni CLM Bold 20");
layout.SetMarkup("<span color=\"#ff00ff\">It’s like setting up text in word or writer <span style=\"italic\">You can have indents, </span> sizes, fonts, etc etc. In this example Pango.Layout, the width is set by converting the window width into pango units because layouts are not measured in pixels. The wrap goes hand in hand with width so that any long text will wrap at the set width value. The FontDescription is quite handy. Here you can define your font. Thanks go to TD on the #mono channel for his tips here. If you want to know the names of available fonts you can enter here, go to gedit and look at the available font names. In the example above, I have the font name of “Ahafoni CLM”, the weight of “Bold” and size of 100.</span>");
Pango.CairoHelper.ShowLayout(cr, layout);
}
My memory leaks every 2 seconds += 2Mb.
When I comment this code memory alocate is permanent
version pango are 2.99 & 2.12
Demonstrative video and example you can find here https://github.com/Rombersoft/pango-sharp-bug
This example doesn't work:
http://docs.go-mono.com/index.aspx?link=E%3AGtk.Widget.DeleteEvent
When I set my custom tittle bar to a window I cannot iconify my app via clicking a tray icon.
We've found a memory leak in the generated method "public Gtk.Requisition SizeRequest()" within Gtk.Widget class.
Here is a suggestion to fix the bug:
public Gtk.Requisition SizeRequest() {
Gtk.Requisition requisition = Requisition;
Gtk.Application.AssertMainThread();
gtk_widget_size_request(Handle, ref requisition);
return requisition;
}
Since this code is generated, any ideas on how to fix the code engine is greatly appreciated.
Nothing changes when GTK_THEME (for gtk3 themes) or GTK2_RC_FILES (for gtk2 themes) is set differently from the system gtk theme. This is essentially a re-post of mono/mono#9998 which was prematurely closed.
Setting one of those environment variables will override the GTK theme for the mono application being launched
[ ] macOS
[x] Linux
[ ] Windows
Version Used:
5.20.1 (and older)
Hello everyone,
Can I have example of Gtk.Assistant?
I can't find google. But Mono Gtk website doesn't show about Gtk.Assistant since Gtk 2.10.
Is it correct or wrong?
class MyWizard : Gtk.Assistant
{
public MyWizard()
{
// ...
}
}
But where is example of page like back, next / finish and cancel?
Since I know for Windows.Forms but I don't understand why do I need Dialog with Assistant since I checked MonoDevelop's source and It has not "Gtk.Assistant" Only Gtk.Dialog?
How do I understand that?
Thanks and stay safe and stay healthy!
I have a cross platform application that I developed under OXS with Visual Studio that should mainly run under Windows. Lately I realized, that the Gtk.PrintOperation now causes a System.AccessViolationException under Windows, regardless if I build it as native Windows Application using GtkSharp on Windows or run the Mono build from the OSX build by Mono. About one month ago, every thing worked fine.
I am clueless at this point, because nothing I tried worked out. Is there anyone who can still print with Gtk under Windows? Is there a C# application that I can build and try? I did fail to get the gtk-sharp libraries and examples built on Windows. The documentation was to poor to understand what I therefor need.
Any suggestions?
I'm trying to integrate libvlc with GTK# (see the work in progress here : https://github.com/jeremyVignelles/libvlcsharp/tree/feature/gtk-sharp )
However, the fact that this is a reference to a DLL file and not to a NuGet package makes it very inconvenient to write and maintain in cross-platform scenarios :
In our customer's csproj, they also need to depend on each dll as well:
EDIT: And we didn't even try to make it work on Mac OS
Would it be possible to create an official NuGet package for that ?
The last commit was about 9 months ago. Please continue to develop GTK#! I tried to compile the demo project and it failed to compile on my system with Mono 5.12.
The unstable release gtk-sharp 2.99.3 appeared in June 2014, which was almost six years ago. Now it is 2020 and a stable, official release of GTK# 3 has yet to appear. GTK 2 is obsolescent and most new GTK apps are developed using GTK 3, so it really seems that GTK# should support it.
What is blocking the release of GTK# 3? Is there anything that interested community members can do to help?
net core 3.1
`
static void Main(string[] args)
{
Core.Initialize();
// Initializes the GTK# app
Application.Init();
using var libvlc = new LibVLC(enableDebugLogs: true);
using var mediaPlayer = new MediaPlayer(libvlc);
// Create the window in code. This could be done in glade as well, I guess...
var myWin = new Window("LibVLCSharp.GTK.Sample");
myWin.Resize(800, 450);
Frame c = new Frame();
mediaPlayer.Hwnd = c.Handle;
myWin.Add(c);
myWin.ShowAll();
using var media = new Media(libvlc,
new Uri("https://bj.bcebos.com/kpy-organizations/U2943159/videos/2021062612303528372289135202.mp4"));
mediaPlayer.Play(media);
myWin.DeleteEvent += (sender, args) =>
{
mediaPlayer.Stop();
Application.Quit();
};
Application.Run();
}
`
Hello,
When porting LibVLCSharp to GTK#, I encounter a native crash when the mouse cursor touches the VideoView on GTK Mac. It appears to be a stackoverflow in one of your gtk patches.
Application crash with
Stack overflow in unmanaged: IP: 0x107261f69, fault addr: 0x7ffeec73eff8
Stack overflow: IP: 0x107261f69, fault addr: 0x7ffeec735ff8
Stacktrace:
at <unknown> <0xffffffff>
at Gtk.Application.Run () [0x00001] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/gtk-sharp-None/gtk/Application.cs:145
<...>
at LibVLCSharp.GTK.Sample.Program.Main () [0x0009d] in /Users/Martz/Projects/LibVLCSharp/Samples/LibVLCSharp.GTK.Sample/Program.cs:35
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) [0x0004d] in <71f4e3d7d65e42b0a699d02e59766d3c>:0
Repro with lldb attached gives
(lldb) c
Process 2937 resuming
Process 2937 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7ffee869ffc8)
frame #0: 0x000000010b061e59 libgdk-quartz-2.0.0.dylib`find_nsview_at_pos + 41
libgdk-quartz-2.0.0.dylib`find_nsview_at_pos:
-> 0x10b061e59 <+41>: callq 0x10b0784da ; symbol stub for: objc_msgSend
0x10b061e5e <+46>: movq 0x5c03b(%rip), %rsi ; "count"
0x10b061e65 <+53>: movq %rax, %rdi
0x10b061e68 <+56>: callq 0x10b0784da ; symbol stub for: objc_msgSend
Target 0: (mono) stopped.
Application does not crash.
[x] macOS
Version Used:
Mono JIT compiler version 5.16.0.221 (2018-06/b63e5378e38 Mon Nov 19 18:08:09 EST 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(3.6.0svn-mono-release_60/0b3cb8ac12c)
GC: sgen (concurrent by default)
Full backtrace https://gist.github.com/mfkl/921581898e21e0c85ffdff0d31eebd0d
Patch introduced in mono/bockbuild#66
/cc @jeremyVignelles
error:
after invoke Gtk.Application.Init(),mono crash
my code:
public class Class1
{
public static void Main(string[] args)
{
try
{
Gtk.Application.Init();
}
catch (Exception ex)
{
System.IO.File.WriteAllText(@"C:\Users\wlq\Documents\error.txt", ex.Message + ex.StackTrace, Encoding.UTF8);
}
Forms.Init();
var window = new FormsWindow();
window.Show();
Gtk.Application.Run();
}
platforms :
Windows 10
GTk Version:
gtk-sharp-2.12.45
mono version:
Mono JIT compiler version 5.16.0 (Visual Studio built mono)
## Stacktrace
libglib-2.0-0.dll at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in :0
at GLib.Global.set_ProgramName (System.String value) [0x00001] in :0
at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0
at MT.Class1.Main (System.String[] args) [0x00002] in <78ab4a6bdfde4a589bc664d09041cd02>:0
Hi All,
I am able to drag the file from anywhere and drop at my application using Gtk.DestSet.
When I am trying to drag the files from my application and drop at anywhere then Gtk.DragFailed callback triggered with DragResult=NoTarget.
I am not sure, is it issue from the framework side or not.
Can you please check the issue.
Thanks in Advance.
OS:
Steps to repro:
What I expected:
What happened:
Crash logs:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) Gdk.Pixbuf.gdk_pixbuf_get_from_drawable (intptr,intptr,intptr,int,int,int,int,int,int) <0x00015>
at Gdk.Pixbuf.FromDrawable (Gdk.Drawable,Gdk.Colormap,int,int,int,int,int,int) [0x0001c] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/gtk-sharp-None/gdk/generated/Pixbuf.custom:273
at ScreenshotCrashBug.MainClass/<>c.<Main>b__0_0 (object,System.EventArgs) [0x0002f] in /Users/marcos/Repositorios/Microsoft.SnipInsights/ScreenshotCrashBug/Program.cs:21
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) [0x0005b] in <3ef162e744784a18a992413881f08f7b>:0
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0x00012>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00032] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229
at System.Delegate.DynamicInvokeImpl (object[]) [0x000e1] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Delegate.cs:461
at System.MulticastDelegate.DynamicInvokeImpl (object[]) [0x00008] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/MulticastDelegate.cs:67
at System.Delegate.DynamicInvoke (object[]) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Delegate.cs:406
at GLib.Signal.ClosureInvokedCB (object,GLib.ClosureInvokedArgs) [0x0007f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/gtk-sharp-None/glib/Signal.cs:207
at GLib.Signal/SignalClosure.Invoke (GLib.ClosureInvokedArgs) [0x00019] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/gtk-sharp-None/glib/SignalClosure.cs:114
at GLib.Signal/SignalClosure.MarshalCallback (intptr,GLib.Value*,uint,GLib.Value*,intptr,intptr) [0x00053] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/gtk-sharp-None/glib/SignalClosure.cs:143
at (wrapper native-to-managed) GLib.Signal/SignalClosure.MarshalCallback (intptr,GLib.Value*,uint,GLib.Value*,intptr,intptr) [0x00027] in <270e7412760746b39483cb3d37bf0e03>:0
at <unknown> <0xffffffff>
at (wrapper managed-to-native) Gtk.Application.gtk_main () <0x00012>
at Gtk.Application.Run () [0x00001] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/gtk-sharp-None/gtk/Application.cs:145
at ScreenshotCrashBug.MainClass.Main (string[]) [0x00060] in /Users/marcos/Repositorios/Microsoft.SnipInsights/ScreenshotCrashBug/Program.cs:30
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <3ef162e744784a18a992413881f08f7b>:0
Native stacktrace:
Debug info from gdb:
(lldb) command source -s 0 '/tmp/mono-gdb-commands.zNUGJY'
Executing commands in '/tmp/mono-gdb-commands.zNUGJY'.
(lldb) process attach --pid 15676
warning: (i386) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/libgthread-2.0.0.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
warning: (i386) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/libgio-2.0.0.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
warning: (i386) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/libgmodule-2.0.0.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
warning: (i386) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/libgobject-2.0.0.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
warning: (i386) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/libglib-2.0.0.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
Process 15676 stopped
* thread #1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0xa73df6a6 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
-> 0xa73df6a6 <+10>: jae 0xa73df6b6 ; <+26>
0xa73df6a8 <+12>: calll 0xa73df6ad ; <+17>
0xa73df6ad <+17>: popl %edx
0xa73df6ae <+18>: movl 0x246997f(%edx), %edx
Target 0: (mono32) stopped.
Executable module set to "/Library/Frameworks/Mono.framework/Versions/5.10.1/bin/mono32".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 15676 stopped
* thread #1: tid = 0x1a6713, 0xa73df6a6 libsystem_kernel.dylib`__wait4 + 10, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
thread #2: tid = 0x1a6716, 0xa73ded4e libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
thread #3: tid = 0x1a6719, 0xa73d543e libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
thread #4: tid = 0x1a671a, 0xa73defc6 libsystem_kernel.dylib`__recvfrom + 10, name = 'Debugger agent'
thread #5: tid = 0x1a672e, 0xa73df716 libsystem_kernel.dylib`__workq_kernreturn + 10
thread #6: tid = 0x1a675e, 0xa73d5402 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.NSEventThread'
thread #7: tid = 0x1a6782, 0xa73df0a6 libsystem_kernel.dylib`__select + 10
thread #8: tid = 0x1a689a, 0xa73df716 libsystem_kernel.dylib`__workq_kernreturn + 10
(lldb) thread backtrace all
* thread #1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0xa73df6a6 libsystem_kernel.dylib`__wait4 + 10
frame #1: 0xa734ace2 libsystem_c.dylib`waitpid$UNIX2003 + 32
frame #2: 0x00176a1e mono32`mono_handle_native_crash(signal=<unavailable>, ctx=<unavailable>, info=0x00785fa0) at mini-exceptions.c:2830 [opt]
frame #3: 0x002047f2 mono32`mono_arch_handle_altstack_exception(sigctx=<unavailable>, siginfo=<unavailable>, fault_addr=<unavailable>, stack_ovf=<unavailable>) at exceptions-x86.c:1099 [opt]
frame #4: 0x000c54a2 mono32`mono_sigsegv_signal_handler(_dummy=11, _info=0x00785fa0, context=0x00785fe0) at mini-runtime.c:3133 [opt]
thread #2, name = 'SGen worker'
frame #0: 0xa73ded4e libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0xa759543c libsystem_pthread.dylib`_pthread_cond_wait + 658
frame #2: 0xa759708c libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 51
frame #3: 0x0036cd71 mono32`thread_func [inlined] mono_os_cond_wait(mutex=0x0045c92c) at mono-os-mutex.h:173 [opt]
frame #4: 0x0036cd5c mono32`thread_func at sgen-thread-pool.c:165 [opt]
frame #5: 0x0036cd4c mono32`thread_func(data=<unavailable>) at sgen-thread-pool.c:196 [opt]
frame #6: 0xa75944d5 libsystem_pthread.dylib`_pthread_body + 347
frame #7: 0xa759437a libsystem_pthread.dylib`_pthread_start + 357
frame #8: 0xa7593a56 libsystem_pthread.dylib`thread_start + 34
thread #3, name = 'Finalizer'
frame #0: 0xa73d543e libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x0031bd74 mono32`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:90 [opt]
frame #2: 0x0031bd66 mono32`finalizer_thread at mono-coop-semaphore.h:43 [opt]
frame #3: 0x0031bd55 mono32`finalizer_thread(unused=0x00000000) at gc.c:852 [opt]
frame #4: 0x002d7c49 mono32`start_wrapper [inlined] start_wrapper_internal at threads.c:1004 [opt]
frame #5: 0x002d7b94 mono32`start_wrapper(data=<unavailable>) at threads.c:1064 [opt]
frame #6: 0xa75944d5 libsystem_pthread.dylib`_pthread_body + 347
frame #7: 0xa759437a libsystem_pthread.dylib`_pthread_start + 357
frame #8: 0xa7593a56 libsystem_pthread.dylib`thread_start + 34
thread #4, name = 'Debugger agent'
frame #0: 0xa73defc6 libsystem_kernel.dylib`__recvfrom + 10
frame #1: 0xa734aec0 libsystem_c.dylib`recv$UNIX2003 + 30
frame #2: 0x001af749 mono32`socket_transport_recv(buf=<unavailable>, len=11) at debugger-agent.c:1152 [opt]
frame #3: 0x0019b1b4 mono32`debugger_thread [inlined] transport_recv(len=11) at debugger-agent.c:1558 [opt]
frame #4: 0x0019b1a2 mono32`debugger_thread(arg=0x00000000) at debugger-agent.c:10517 [opt]
frame #5: 0x002d7c49 mono32`start_wrapper [inlined] start_wrapper_internal at threads.c:1004 [opt]
frame #6: 0x002d7b94 mono32`start_wrapper(data=<unavailable>) at threads.c:1064 [opt]
frame #7: 0xa75944d5 libsystem_pthread.dylib`_pthread_body + 347
frame #8: 0xa759437a libsystem_pthread.dylib`_pthread_start + 357
frame #9: 0xa7593a56 libsystem_pthread.dylib`thread_start + 34
thread #5
frame #0: 0xa73df716 libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0xa7593e64 libsystem_pthread.dylib`_pthread_wqthread + 1035
frame #2: 0xa7593a32 libsystem_pthread.dylib`start_wqthread + 34
thread #6, name = 'com.apple.NSEventThread'
frame #0: 0xa73d5402 libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0xa73d4a3f libsystem_kernel.dylib`mach_msg + 47
frame #2: 0x9377ea68 CoreFoundation`__CFRunLoopServiceMachPort + 296
frame #3: 0x9377da56 CoreFoundation`__CFRunLoopRun + 2262
frame #4: 0x9377ce51 CoreFoundation`CFRunLoopRunSpecific + 641
frame #5: 0x9377cbba CoreFoundation`CFRunLoopRunInMode + 122
frame #6: 0x914aa580 AppKit`_NSEventThread + 165
frame #7: 0xa75944d5 libsystem_pthread.dylib`_pthread_body + 347
frame #8: 0xa759437a libsystem_pthread.dylib`_pthread_start + 357
frame #9: 0xa7593a56 libsystem_pthread.dylib`thread_start + 34
thread #7
frame #0: 0xa73df0a6 libsystem_kernel.dylib`__select + 10
frame #1: 0x032170d4 libglib-2.0.0.dylib`g_poll + 372
frame #2: 0x02892cc2 libgdk-quartz-2.0.0.dylib`select_thread_func + 386
frame #3: 0xa75944d5 libsystem_pthread.dylib`_pthread_body + 347
frame #4: 0xa759437a libsystem_pthread.dylib`_pthread_start + 357
frame #5: 0xa7593a56 libsystem_pthread.dylib`thread_start + 34
thread #8
frame #0: 0xa73df716 libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0xa7594059 libsystem_pthread.dylib`_pthread_wqthread + 1536
frame #2: 0xa7593a32 libsystem_pthread.dylib`start_wqthread + 34
(lldb) detach
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Process 15676 detached
(lldb) quit
Still waiting for 3 years old request....
What happend?
/
Wolfgang
I'm using VS2017 to develop and build an application with GTK#, it includes the package GtkSharp.Win32
(All packages are the latest as of June 3, 2018), and I am receiving a PInvokeStackImbalance
error through the Application.Init()
function. Any help here?
Describe the bug:
I've created a new ProjectReunion solution and trying to use PrintOperation class from the GtkSharp nuget package. But get the error:
System.TypeInitializationException: 'The type initializer for 'GLib.Object' threw an exception.'
Inner Exception:
DllNotFoundException: GObject: libgobject-2.0-0.dll, libgobject-2.0.so.0, libgobject-2.0.0.dylib, gobject-2.dll
Steps to reproduce:
Strange, but at the same time default .NET 5 console application with GtkSharp package working fine.
I's it a problem of ProjectReunion? Or GtkSharp is not optimized for the new platform?
NuGet package version:
Project Reunion 0.5.6
GtkSharp 3.24.24.34
Environment:
Visual Studio 2019 version 16.10.0 Preview 2.1
Windows 10 version 20H2 build 19042
I have a function, as below, attached to a NodeView widget:
`protected void onSongSelected(object o, RowActivatedArgs args)
{
object selection = o;
}'
By using GetType()
I have been able to verify that o (and thus selection also) is of type Gtk.NodeView().
However, I've been reading through this tutorial from Mono for working with Treeview and Nodeview Gtk# widgets: https://www.mono-project.com/docs/gui/gtksharp/widgets/nodeview-tutorial/
And, when I try object selection = (NodeSelection)o;
I get an error saying that object o can not be cast into the class NodeSelection. I would like to be able to access other information associated with my node, and hoped to do so via the method illustrated in the guide. But I remain unable to change the class of variable o in any way.
Is there something I am doing incorrectly that is causing this problem?
I downloaded the last mono tar to Solaris 11
I install the required packages:
# pkg install autoconf
# pkg install automake
# pkg install libtool
# pkg install gcc
When I tried to configure mono 5.18.0.268 on 64-bit Solaris 11/x86 (x86_64-pc-solaris2.11) with gcc 4.8.2, it failed
like this:
$ ./autogen.sh
(...)
checking for PTHREAD_MUTEX_RECURSIVE... no
configure: error: Posix system lacks support for recursive mutexes
I changed the "D_XOPEN_SOURCE=500" to "D_XOPEN_SOURCE=600" in the configure.ac with no improvement
dnl *****************************
dnl *** Checks for libxnet ***
dnl *****************************
case "${host}" in
*solaris* )
AC_MSG_CHECKING(for Solaris XPG4 support)
if test -f /usr/lib/libxnet.so; then
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -std=c99"
CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
LIBS="$LIBS -lxnet"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
I am aware of the Bug 31999 - C99 and XPG5 don't match on Solaris 10+
https://bugzilla.xamarin.com/show_bug.cgi?id=31999
Acording to Oracle documentation, Solaris 11 supports thread mutex using Oracle Solaris Threads and POSIX pthreads API. Some functions are:
Oracle Solaris Threads | POSIX pthreads |
---|---|
mutex_lock() | pthread_mutex_lock() |
mutex_unlock() | pthread_mutex_unlock() |
mutex_trylock() | pthread_mutex_trylock() |
mutex_init() | pthread_mutex_init() |
mutex_destroy() | pthread_mutex_destroy() |
- | pthread_mutexattr_init() |
- | pthread_mutexattr_destroy() |
type argument in mutex_init() | pthread_mutexattr_setpshared() |
- | pthread_mutexattr_getpshared() |
- | pthread_mutex_attr_settype() |
- | pthread_mutex_attr_gettype() |
More details in:
https://docs.oracle.com/cd/E53394_01/html/E54803/sthreads-96692.html
I run
$ grep PTHREAD_MUTEX_RECURSIVE /usr/include/*
/usr/include/pthread.h:#define PTHREAD_MUTEX_RECURSIVE 0x4
I am creating a project that requires embedding a foreign window into my GTK application. This require gdk_window_foreign_new, and there are currently no binding for it. This is necessary, and currently the only alternative is to create the window outside the main application.
I' m using Monodevelop 7.5 with gtk-sharp-2.0 2.12.45 on Ubuntu 18.04.
When designing a widget with translatable tooltip:
<widget class="Gtk.CheckButton" id="checkbutton1">
<property name="MemberName" />
<property name="Tooltip" translatable="yes">AM000.save.tt</property>
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">AM000.save</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
</widget>
the output cs file is not translatable for the tooltip:
this.checkbutton1 = new global::Gtk.CheckButton();
this.checkbutton1.TooltipMarkup = "AM000.save.tt";
this.checkbutton1.CanFocus = true;
this.checkbutton1.Name = "checkbutton1";
this.checkbutton1.Label = global::Mono.Unix.Catalog.GetString("AM000.save");
this.checkbutton1.DrawIndicator = true;
this.checkbutton1.UseUnderline = true;
Garbage collection doesn't free memory after pop a page.
Garbage collector should free memory after pop a page.
Linux
Version Used:
I tested with several of them but at the newest one (5.20.0) is happening too.
Don't error out when accessing a liststore from outside the main thread. It should be decided by the user to use locking. ListStore and TreeStore are not Gtk.Widgets, but GLib.Objects
It is a class with StructLayoutAttribute
and the ==
operator does not check for null, so it causes NullReferenceException
.
Hey there,
Installed policy.2.10.gtk-dotnet.dll into the gac (/usr/lib/mono/gac)
make[2]: Leaving directory '/home/Temp/rbt/gtk-sharp-2.12.45/gtkdotnet'
make[1]: Leaving directory '/home/Temp/rbt/gtk-sharp-2.12.45/gtkdotnet'
Making install in sample
make[1]: Entering directory '/home/Temp/rbt/gtk-sharp-2.12.45/sample'
Making install in test
make[2]: Entering directory '/home/Temp/rbt/gtk-sharp-2.12.45/sample/test'
/usr/bin//mcs -out:WidgetViewer.exe -r:../../glib/glib-sharp.dll -r:../../pango/pango-sharp.dll -r:../../atk/atk-sharp.dll -r:../../gdk/gdk-sharp.dll -r:../../gtk/gtk-sharp.dll ./TestCheckButton.cs ./TestColorSelection.cs ./TestRadioButton.cs ./TestRange.cs ./TestStatusbar.cs ./TestDialog.cs ./TestFlipping.cs ./TestSizeGroup.cs ./TestCombo.cs ./TestComboBox.cs ./WidgetViewer.cs
./TestCombo.cs(17,14): warning CS0612: Gtk.Combo' is obsolete ./TestRange.cs(35,6): error CS0104:
Range' is an ambiguous reference between System.Range' and
Gtk.Range'
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
/home/Temp/rbt/gtk-sharp-2.12.45/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
./TestRange.cs(35,13): error CS0030: Cannot convert type Gtk.HScale' to
System.Range'
./TestRange.cs(42,6): error CS0104: Range' is an ambiguous reference between
System.Range' and Gtk.Range' /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error) /home/Temp/rbt/gtk-sharp-2.12.45/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error) ./TestRange.cs(42,13): error CS0030: Cannot convert type
Gtk.HScrollbar' to System.Range' ./TestRange.cs(62,6): error CS0104:
Range' is an ambiguous reference between System.Range' and
Gtk.Range'
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
/home/Temp/rbt/gtk-sharp-2.12.45/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
./TestRange.cs(62,13): error CS0030: Cannot convert type Gtk.VScale' to
System.Range'
./TestCombo.cs(31,20): warning CS0612: `Gtk.Combo' is obsolete
Compilation failed: 6 error(s), 2 warnings
make[2]: *** [Makefile:502: WidgetViewer.exe] Error 1
make[2]: Leaving directory '/home/Temp/rbt/gtk-sharp-2.12.45/sample/test'
make[1]: *** [Makefile:440: install-recursive] Error 1
make[1]: Leaving directory '/home/Temp/rbt/gtk-sharp-2.12.45/sample'
make: *** [Makefile:454: install-recursive] Error 1
This may be due to my system running the latest software; gtk-sharp is already +4 years old of the last release. :(
But if someone may find some time in the future, it would be nice if gtk2 can remain supported. Note that pygobject,
ruby-gtk3, and most of the GNOME apps work fine on my system, so I doubt it is related to my system as such
and thus must be related to something within gtk-sharp. I am a noob when it comes to C/C++/C# though.
How to realize double buffering in GTK#
I do so:
at begin I create empty ImageSurface
than I draw on it all elements using Cairo.Context
than in method OnDrawn(...) I fill my ImageSurface.
Is it right or no?
Hey.
I'm running dotnet core 2.1 preview 1. After adding the latest gtk-sharp nuget, the application fails with a DllNotFoundException on Application.Init(). Is the package not expected to be self-contained and include the necessary dependencies? If not, I am missing information on what to install on MacOSX ?
The same app runs out of the box on Raspbian :)
Here's what the sample project looks like when I open it in MonoDevelop:
Xubuntu Linux 18.04. mono-complete
, monodevelop
, gtk-sharp3
, and gtk-sharp2
are both installed on my system via the package manager.
If there are other steps to get this working, well, there is no README file for the sample project...
MonoDevelop 7.5, Mono 5.12.
[ 154s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample/test'
[ 154s] /usr/bin/mcs -out:WidgetViewer.exe -r:../../glib/glib-sharp.dll -r:../../pango/pango-sharp.dll -r:../../atk/atk-sharp.dll -r:../../gdk/gdk-sharp.dll -r:../../gtk/gtk-sharp.dll ./TestCheckButton.cs ./TestColorSelection.cs ./TestRadioButton.cs ./TestRange.cs ./TestStatusbar.cs ./TestDialog.cs ./TestFlipping.cs ./TestSizeGroup.cs ./TestCombo.cs ./TestComboBox.cs ./WidgetViewer.cs
[ 154s] ./TestCombo.cs(17,14): warning CS0612: `Gtk.Combo' is obsolete
[ 154s] ./TestRange.cs(35,6): error CS0104: `Range' is an ambiguous reference between `System.Range' and `Gtk.Range'
[ 154s] /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
[ 154s] /home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
[ 154s] ./TestRange.cs(35,13): error CS0030: Cannot convert type `Gtk.HScale' to `System.Range'
[ 154s] ./TestRange.cs(42,6): error CS0104: `Range' is an ambiguous reference between `System.Range' and `Gtk.Range'
[ 154s] /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
[ 154s] /home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
[ 154s] ./TestRange.cs(42,13): error CS0030: Cannot convert type `Gtk.HScrollbar' to `System.Range'
[ 154s] ./TestRange.cs(62,6): error CS0104: `Range' is an ambiguous reference between `System.Range' and `Gtk.Range'
[ 154s] /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
[ 154s] /home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
[ 154s] ./TestRange.cs(62,13): error CS0030: Cannot convert type `Gtk.VScale' to `System.Range'
[ 154s] ./TestCombo.cs(31,20): warning CS0612: `Gtk.Combo' is obsolete
[ 154s] Compilation failed: 6 error(s), 2 warnings
[ 154s] make[3]: *** [Makefile:504: WidgetViewer.exe] Error 1
[ 154s] make[3]: Leaving directory '/home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample/test'
[ 154s] make[2]: *** [Makefile:439: all-recursive] Error 1
[ 154s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41/sample'
[ 154s] make[1]: *** [Makefile:453: all-recursive] Error 1
[ 154s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/gtk-sharp-2.12.41'
[ 154s] make: *** [Makefile:381: all] Error 2
[ 154s] error: Bad exit status from /var/tmp/rpm-tmp.BlzUbN (%build)
For building GTK#, the instructions here mention this:
The build is the traditional:
./configure
make
make install
When I try this on my system after cloning the repo:
$ ./configure
bash: ./configure: No such file or directory
$ make
make: *** No targets specified and no makefile found. Stop.
$ make install
make: *** No rule to make target 'install'. Stop.
There is a file called configure.ac
and when I try to run that:
$ ./configure.ac
bash: ./configure.ac: Permission denied
$ sudo ./configure.ac
sudo: ./configure.ac: command not found
$ sudo bash ./configure.ac
./configure.ac: line 2: syntax error near unexpected token `gtk-sharp,'
./configure.ac: line 2: `AC_INIT(gtk-sharp, 2.99.4)'
Your build instructions don't work or are incomplete.
From @jeffechua on July 13, 2018 15:35
using System;
using Gtk;
namespace TransparencyTest {
class MainClass {
public static void Main (string[] args) {
Application.Init();
Window win = new Window(WindowType.Toplevel);
const byte TRANSPARENCY = 0; // Change this at will
win.Mapped += delegate {
Gdk.GC red = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(255, 0, 0) };
Gdk.GC black = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(0, 0, 0) };
Gdk.GC translucent = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(TRANSPARENCY, TRANSPARENCY, TRANSPARENCY) };
Gdk.GC visible = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(255, 255, 255) };
Gdk.Pixmap pixmap = new Gdk.Pixmap(win.GdkWindow, 200, 200);
pixmap.DrawRectangle(black, true, 0, 0, 200, 200);
pixmap.DrawArc(red, true, 20, 20, 160, 160, 0, 23040);
Gdk.Pixmap mask = new Gdk.Pixmap(win.GdkWindow, 200, 200);
mask.DrawRectangle(visible, true, 0, 0, 200, 200);
mask.DrawArc(translucent, true, 0, 0, 100, 100, 0, 23040);
mask.DrawArc(translucent, true, 100, 100, 100, 100, 0, 23040);
Image image = new Image(pixmap, mask);
win.Add(image);
win.ShowAll();
};
win.ShowAll();
Application.Run();
}
}
}
OR
using System;
using Gtk;
namespace TransparencyTest {
class MainClass {
public static void Main (string[] args) {
Application.Init();
Window win = new Window(WindowType.Toplevel);
VBox vBox = new VBox();
HScale transparencyScale = new HScale(0, 255, 1) { Value = 255 };
Image image = new Image();
image.SetSizeRequest(200, 200);
vBox.PackStart(transparencyScale);
vBox.PackStart(image);
win.Add(vBox);
transparencyScale.ValueChanged += delegate {
int transparency = (int)transparencyScale.Value;
byte[] tBytes = BitConverter.GetBytes(transparency);
Gdk.GC red = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(255, 0, 0) };
Gdk.GC black = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(0, 0, 0) };
Gdk.GC translucent = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(tBytes[0], tBytes[0], tBytes[0]) };
Gdk.GC visible = new Gdk.GC(win.GdkWindow) { RgbFgColor = new Gdk.Color(255, 255, 255) };
Gdk.Pixmap pixmap = new Gdk.Pixmap(win.GdkWindow, 200, 200);
pixmap.DrawRectangle(black, true, 0, 0, 200, 200);
pixmap.DrawArc(red, true, 20, 20, 160, 160, 0, 23040);
Gdk.Pixmap mask = new Gdk.Pixmap(win.GdkWindow, 200, 200);
mask.DrawRectangle(visible, true, 0, 0, 200, 200);
mask.DrawArc(translucent, true, 0, 0, 100, 100, 0, 23040);
mask.DrawArc(translucent, true, 100, 100, 100, 100, 0, 23040);
image.SetFromPixmap(pixmap, mask);
image.ShowAll();
};
win.ShowAll();
Application.Run();
}
}
}
On MacOS, behavior is as expected for both test cases.
On Linux, the first test case crashes immediately whenever TRANSPARENCY == 0, and displays the supposedly translucent circles as fully opaque (i.e. indifferentiable from surrounding opacity) whenever TRANSPARENCY != 0. The second test case momentarily displays the fully opaque image (same as the first test case where TRANSPARENCY != 0) and then immediately crashes, whenever the the slider is moved, i.e. whenever Image.SetFromPixmap is invoked.
The error message in all crash cases is as below:
The program 'TransparencyTest' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
(Details: serial 1158 error_code 8 request_code 56 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
In the first test case, the two translucent circles should appear with transparency according to the value of the constant TRANSPARENCY. In the second test case, the circles should change transparency as the sliders are moved. In both test cases, the image itself (discounting alpha) is a red circle on a black background.
[x] macOS (High Sierra 10.13.5)
[x] Linux (Linux Mint 17.2 Cinnamon 64-bit, Cinnamon 2.6.13, Linux Kernel 3.13.0-141-generic)
[ ] Windows (untested)
Version Used:
5.10.1.57 for MacOS,
5.12.0.226 for Linux Mint
Using gdb and a breakpoint at "_XError" ("gdk_x_error" didn't work), the stacktrace obtained (hopefully correctly) was
"<unnamed thread>" tid=0x0x7ffff7fc8780 this=0x0x7ffff7f24130 , thread handle : 0xa39360, state : not waiting
at <unknown> <0xffffffff>
at (wrapper managed-to-native) Gtk.Application.gtk_main () [0x00008] in <e8d21baece374fadb4e2b3899720848c>:0
at Gtk.Application.Run () [0x00000] in <e8d21baece374fadb4e2b3899720848c>:0
at TransparencyTest.MainClass.Main (string[]) [0x000c1] in /Users/jefferson/Dropbox/Parahumans/TransparencyTest/Program.cs:85
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <d80c7dc187f741b8b94961002c8f0c80>:0
Copied from original issue: mono/mono#9537
I've copied the gtk-html sample script but anything html-related doesnt work. The other gtk stuff works just fine but e.g. Gtk.HTMLStream just returns the error that it doesn't exist. What am i missing here?
Code snippet:
Gtk.HTML myhtml; Gtk.HTMLStream mystream = myhtml.Begin("something");
The online API documentation linked on the Mono website is down. It returns a 500 error.
Insige the glib/GType.cs (BuildEscapedName) there is a static int witch is used to build
the gtype name "_gtksharp_X.......".
sb.Append("_gtksharp");
sb.Append(type_uid++); <-------- ?????????????
sb.Append("_");
This produces a problem with glade-designer when using own widgets.
Please remove this "type_uid" !!!!
I posted this question on Stack Overflow a while ago, and nobody responded -- so I decided I am going to go right to the source because I am very curious to know why things are the way they are.
I am using MonoDevelop with GTK Sharp 2.12. I have set this up using the default GTK Sharp windowed project. Add a button, add a button-click event and placed the following code:
protected async void OnBtnTest(object sender, EventArgs e)
{
Debug.WriteLine($"Before: {Thread.CurrentThread.ManagedThreadId}");
await Task.Delay(2000);
Debug.WriteLine($"After: {Thread.CurrentThread.ManagedThreadId}");
using (var msg = new MessageDialog(this, DialogFlags.Modal,
MessageType.Info, ButtonsType.Ok, "CRASH"))
{
msg.Run();
msg.Destroy();
}
}
The output is:
Before: 1
Started Thread 27672
After: 4
(TestSyncContext:26912): Gdk-CRITICAL **: gdk_window_set_geometry_hints: assertion 'GDK_IS_WINDOW (window)' failed
The "critical" line is a crash in the program -- This is because the UI thread didn't return when continuing on to show the MessageDialog
. You can see the managed thread ID changed after the call to await
.
Puzzled by this, I started researching and found this bit of code from a long, long time ago; Specifically these lines caught my attention:
gtk_init (ref argc, ref argv);
SynchronizationContext.SetSynchronizationContext (new GLib.GLibSynchronizationContext ());
So I started to wonder: Does GTK Sharp not set up a synchronization context by default?
I decided to throw it in the code, but GLib.GLibSynchronizationContext()
does not exist in the GLib
library.
OK, that's odd -- I searched for that on the web and found the source code to that object; Copied and pasted it in to my project, then called it as so:
class MainClass
{
public static void Main(string[] args)
{
Application.Init();
SynchronizationContext.SetSynchronizationContext(new GLibSynchronizationContext());
MainWindow win = new MainWindow();
win.Show();
Application.Run();
}
}
Ran it again, and it performs how I would have expected it to without adding a context:
Before: 1
Started Thread 22744
After: 1
No crashes. UI thread came back to continue on down the method.
My questions are:
GLib.GLibSynchronizationContext
no longer available?I have production code with this fix going out, and I want to make sure that what I did isn't unorthodox. OR: maybe there is a better way to set up GTK Sharp to handle the async/await pattern that isn't very well documented.
(BTW, I shipped the code as it is above with the make-shift sync-ctx and it's running on thousands of clients with no issues, still interested in some sort of explanation.)
Some erros are to be fixed when trying to compile with mono 6.0.12.107
Example:
make[2]: Entering directory '/builds/organization/project/component/gtk-sharp/sample/test'
/usr/bin/mcs -out:WidgetViewer.exe -r:../../glib/glib-sharp.dll -r:../../pango/pango-sharp.dll -r:../../atk/atk-sharp.dll -r:../../gdk/gdk-sharp.dll -r:../../gtk/gtk-sharp.dll ./TestCheckButton.cs ./TestColorSelection.cs ./TestRadioButton.cs ./TestRange.cs ./TestStatusbar.cs ./TestDialog.cs ./TestFlipping.cs ./TestSizeGroup.cs ./TestCombo.cs ./TestComboBox.cs ./WidgetViewer.cs
./TestCombo.cs(17,14): warning CS0612: Gtk.Combo' is obsolete ./TestRange.cs(35,6): error CS0104:
Range' is an ambiguous reference between System.Range' and
Gtk.Range'
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
/builds/organization/project/component/gtk-sharp/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
./TestRange.cs(35,13): error CS0030: Cannot convert type Gtk.HScale' to
System.Range'
./TestRange.cs(42,6): error CS0104: Range' is an ambiguous reference between
System.Range' and Gtk.Range' /usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error) /builds/organization/project/component/gtk-sharp/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error) ./TestRange.cs(42,13): error CS0030: Cannot convert type
Gtk.HScrollbar' to System.Range' ./TestRange.cs(62,6): error CS0104:
Range' is an ambiguous reference between System.Range' and
Gtk.Range'
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
/builds/organization/project/component/gtk-sharp/sample/test/../../gtk/gtk-sharp.dll (Location of the symbol related to previous error)
./TestRange.cs(62,13): error CS0030: Cannot convert type Gtk.VScale' to
System.Range'
./TestCombo.cs(31,20): warning CS0612: `Gtk.Combo' is obsolete
Compilation failed: 6 error(s), 2 warnings
make[2]: Leaving directory '/builds/organization/project/component/gtk-sharp/sample/test'
make[2]: *** [Makefile:505: WidgetViewer.exe] Error 1
make[1]: *** [Makefile:440: install-recursive] Error 1
make[1]: Leaving directory '/builds/organization/project/component/gtk-sharp/sample'
make: *** [Makefile:454: install-recursive] Error 1
Follow the steps in https://www.mono-project.com/docs/gui/gtksharp/widgets/nodeview-tutorial/
Short version:
using System;
using Gtk;
namespace NodeViewTutorial {
[Gtk.TreeNode (ListOnly=true)]
class MyTreeNode : Gtk.TreeNode {
string song_title;
public MyTreeNode (string artist, string song_title)
{
Artist = artist;
this.song_title = song_title;
}
[Gtk.TreeNodeValue (Column=0)]
public string Artist;
[Gtk.TreeNodeValue (Column=1)]
public string SongTitle {get { return song_title; } }
}
public class NodeViewExample : Gtk.Window {
public NodeViewExample () : base ("NodeView")
{
SetSizeRequest (200,150);
// Create our TreeView and add it as our child widget
Gtk.NodeView view = new Gtk.NodeView (Store());
Add (view);
// Create a column with title Artist and bind its renderer to model column 0
view.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
// Create a column with title 'Song Title' and bind its renderer to model column 1
view.AppendColumn ("Song Title", new Gtk.CellRendererText (), "text", 1);
view.ShowAll ();
}
protected override bool OnDeleteEvent (Gdk.Event ev)
{
Gtk.Application.Quit ();
return true;
}
Gtk.NodeStore store = null;
private Gtk.NodeStore Store() {
if (store == null) {
store = new Gtk.NodeStore (typeof (MyTreeNode));
store.AddNode (new MyTreeNode ("The Beatles", "Yesterday"));
store.AddNode (new MyTreeNode ("Peter Gabriel", "In Your Eyes"));
store.AddNode (new MyTreeNode ("Rush", "Fly By Night"));
}
return store;
}
public static void Main ()
{
Gtk.Application.Init ();
NodeViewExample win = new NodeViewExample ();
win.Show ();
Gtk.Application.Run ();
}
}
}
If the constructor is used to set the NodeStore, no values appear.
If the NodeStore property is used to set the NodeStore, the values appear as in the demo.
The constructor should behave the same as the NodeStore property.
[ ] macOS
[X] Linux
[ ] Windows
Version Used:
Mono JIT compiler version 4.8.0 (Stable 4.8.0.520/8f6d0f6 Thu Jun 7 07:23:56 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
$ dnf info gtk-sharp2
Last metadata expiration check: 0:00:24 ago on Fri 16 Nov 2018 09:28:43 PM CST.
Installed Packages
Name : gtk-sharp2
Version : 2.12.45
Release : 4.fc28
Arch : x86_64
Size : 2.8 M
Source : gtk-sharp2-2.12.45-4.fc28.src.rpm
Repo : @System
From repo : fedora
Summary : GTK+ and GNOME bindings for Mono
URL : http://www.mono-project.com/GtkSharp
License : LGPLv2+
Description : This package provides a library that allows you to build
: fully native graphical GNOME applications using Mono. Gtk#
: is a binding to GTK+, the cross platform user interface
: toolkit used in GNOME. It includes bindings for Gtk, Atk,
: Pango, Gdk.
N/A
Please paste the stack trace here if available.
CORRECTION
The Gentoo ebuild doesn't contain this fix. I'm not even sure you guys maintain it. Disregard.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.