Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Gtkmm-Widget  (Read 6836 times)

0 Members and 1 Guest are viewing this topic.

Robert42

  • Newbie
  • *
  • Posts: 31
    • View Profile
Gtkmm-Widget
« on: August 07, 2012, 09:57:44 pm »
Hi,

I needed to use SFML in a gtkmm based GUI and luckily I found some Code-Snippets in the old Wiki:
http://www.sfml-dev.org/wiki/en/sources/gtksfmlwidget

Before I can upload my Code-Changes to my online git repository I wanted to
  • Ask which License the Wiki is using.
  • Request a License note in the wiki regarding the Code Snippets (I searched, but couldn't find)


Open Source is about sharing, so I wanted to share the changes I've made to the gtkmm-example code (Tested on Linux Mint 12.04 64Bit, NVidia; SFML 2.0; gtkmm-2.4):
  • The Widget was flickering extremely when I resized the window, so I needed to disable the Widgets default double buffering by adding the following line to the end of the on_realize method:
this->set_double_buffered(false);
  • On neighbor Widgets, there were strange artifacts when I resized the widgets. The Workaround I used was to suppress the Widgets default drawing Method using a invisible Pattern:
this->get_window()->set_back_pixmap(Glib::RefPtr<Gdk::Pixmap>());
  • The on_idle Method presented in the snipped caused my application to crash as returning true caused the application to ignore the main loop. Instead I used the widgets on_expose Method.
  • To have the operating system dependend Code in only one place, I used the following Preprocessor Code to do most of the work:
#if defined(SFML_SYSTEM_WINDOWS)

#include <gdk/gdkwin32.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_HANDLE

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)

#include <gdk/gdkx.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_XID

#elif defined(SFML_SYSTEM_MACOS)

#error Note: You have to figure out an analogue way to access the handle of the widget on a Mac-System

#else

#error Unsupported Operating System

#endif

In order to keep the Window handling Method within the on_realize Method simple:
        this->sf::RenderWindow::create(GET_WINDOW_HANDLE_FROM_GDK(m_refGdkWindow->gobj()));

I've attached the whole Code. Be aware that the current Version of gtkmm is 3.0 And The Code I've created is compatible to gtkmm 2.4.

[attachment deleted by admin]

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Gtkmm-Widget
« Reply #1 on: August 08, 2012, 02:11:54 am »
There isn't a specific license defined for the wiki. I guess it would be quite good to have a clause somewhere, stating that if not other specified every contribution would fall under the zlib license as SFML is under, because if code doesn't have a license the author could potentially sue you at every moment if you'd use it in a commercial application.
Since the wiki is from the users to the users I guess it's content could be something similar to zlib.

Nice change!
It would be great if you could create a new Source Code/Tutorial page on the new official wiki.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Robert42

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Gtkmm-Widget
« Reply #2 on: August 08, 2012, 07:21:56 pm »
Ok, I just added the Wiki Page:
https://github.com/SFML/SFML/wiki/Sourcegtksfmlwidget

I am a little confused, it shows "Sourcegtksfmlwidget" as Title although I have used "# SFMLWidget" as first line.

It's the first time for me that I "created" a public Wiki-Page. As my english isn't the best, I would feel more comfortable if some of you guys could take a look at this page.

Also I tested the code only on Linux.

Ah yes, and I should check whether this code is also working with gtkmm 3.0 -- I'll be back^^
« Last Edit: August 08, 2012, 07:50:50 pm by Robert42 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Gtkmm-Widget
« Reply #3 on: August 08, 2012, 08:22:17 pm »
I am a little confused, it shows "Sourcegtksfmlwidget" as Title although I have used "# SFMLWidget" as first line.
Unfortunatly GitHub has changed their way of displaying titles but the rules haven't been updated...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Gtkmm-Widget
« Reply #4 on: August 08, 2012, 08:27:53 pm »
Quote
Unfortunatly GitHub has changed their way of displaying titles but the rules haven't been updated...
Since they are on the wiki, the rules can be updated by anyone ;D
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Gtkmm-Widget
« Reply #5 on: August 08, 2012, 08:38:49 pm »
Since they are on the wiki, the rules can be updated by anyone ;D
Does update also imply changing? :P
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Gtkmm-Widget
« Reply #6 on: August 08, 2012, 08:44:31 pm »
Yes. And since I almost never check the wiki history... it can be quite dangerous.
Laurent Gomila - SFML developer