Skip to content

New: Usr: Added gtkmm/2.24.5 #3410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/gtkmm/2.x.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.24.5":
sha256: 0680a53b7bf90b4e4bf444d1d89e6df41c777e0bacc96e9c09fc4dd2f5fe6b72
url: https://download.gnome.org/sources/gtkmm/2.24/gtkmm-2.24.5.tar.xz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually co-operate with the current cci gtk/system recipe?
We don't have a gtk recipe built from sources (yet).

80 changes: 80 additions & 0 deletions recipes/gtkmm/2.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os

from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanException

class ConanGTK(ConanFile):
name = "gtkmm"
url = "https://github.com/conan-io/conan-center-index"
license = "LGPL-2.1-or-later"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a COPYING.tools license (GPL-2.0-or-later) for the tools

homepage = "https://www.gtk.org"
description = "The C++ API for GTK."
settings = {"os": "Linux"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settings = {"os": "Linux"}

options = {"version": [2]}
default_options = {"version": 2}
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option depends on the value self.options["gtk"].version, and is thus not choose-able freely.
Having -o gtk:version=2 -o gtkmm:version=3 is an invalid configuration.

Also, I don't see you using this gtk version value anywhere in the recipe.
How does it choose between gtk-2 and gtk-3?

I would do the following:

Suggested change
options = {"version": [2]}
default_options = {"version": 2}
options = {"version": "auto"}
default_options = {"version": "auto"}
@property
def _gtk_version(self):
return self.options["gtk"].version
def package_id(self):
self.info.options.version = self._gtk_version

and use self._gtk_version anywhere.

topics = ("gui", "widget", "graphical")

settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False],
"fPIC": [True, False],
}
default_options = {"shared": False,
"fPIC": True}
generators = "pkg_config"
_autoconf = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.settings.compiler == "Visual Studio" and \
"MT" in str(self.settings.compiler.runtime) and self.options.shared:
raise ConanInvalidConfiguration("Visual Studio and Runtime MT is not supported for shared library.")
if self.options.shared:
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def requirements(self):
self.requires('gtk/system')
self.requires('libsigcpp/3.0.0')

def _configure_build(self):
if self._autoconf:
return self._autoconf

self._autoconf = AutoToolsBuildEnvironment(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gtkmm has meson support.
Is that working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred to use Meson too, but the meson.build files in the source repository are not in the official release tar balls. Their README talks about separate release tar balls based on autoconf and meson.build, but on their own website, I only found the ones supporting autoconf. Ergo, I went with AutoTools for the package.

return self._autoconf

def build(self):
tools.replace_in_file(self._source_subfolder + '/configure', "gtk+-2.0 >= 2.24.0", "gtk+-2.0")

autoconf = self._configure_build()
autoconf.configure(configure_dir=self._source_subfolder,
vars = {
'cross_compiling': 'no'
}
)
autoconf.make()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
autoconf = self._configure_build()
autoconf.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "res"))

I see a lot of html files in res/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not. Are we talking about the same package?


def package_info(self):
self.cpp_info.includedirs = ['include', 'include/gtkmm-2.4', 'include/gdkmm-2.4']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how this 2.4 suffix is calculated? It is not equal to gtkmm's version.

self.cpp_info.libs = tools.collect_libs(self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libdirs.append(os.path.join(self.package_folder, "lib", "cairo"))
ls /home/conan/.conan/data/cairo/1.17.2/_/_/package/8d0b5f353aa5e0e4f75b6ab896cdd7f05569992f/lib/cairo/
libcairo-trace.a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see that file. Are we talking about the same package (gtkmm)? Your path seems to suggest otherwise.

8 changes: 8 additions & 0 deletions recipes/gtkmm/2.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/gtkmm/2.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
184 changes: 184 additions & 0 deletions recipes/gtkmm/2.x.x/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/* Application main window
*
* Demonstrates a typical application window, with menubar, toolbar, statusbar.
*/

#include <gtkmm.h>

class Example_AppWindow : public Gtk::Window
{
public:
Example_AppWindow();
virtual ~Example_AppWindow();

protected:
//Signal handlers:
virtual void on_menu_item();
virtual void on_text_changed();
virtual void on_text_mark_set(const Gtk::TextBuffer::iterator& new_location, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark);

//Member widgets:
Gtk::Table m_Table;
Gtk::Menu m_Menubar;
Gtk::Toolbar m_Toolbar;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TextView m_TextView;
Gtk::Statusbar m_Statusbar;
};


//Called by DemoWindow;
Gtk::Window* do_appwindow()
{
return new Example_AppWindow();
}


Example_AppWindow::Example_AppWindow()
: m_Table(1, 4)
{
set_title("Application Window");

add(m_Table);

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the commented-out code not working? Or can it be removed/re-enabled?

//Menu:
{
using namespace Gtk::Menu_Helpers;

//File menu:
Gtk::Menu* pMenuFile = Gtk::manage( new Gtk::Menu() );
MenuList& list_file = pMenuFile->items();
list_file.push_back( MenuElem("_New", "<control>N", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_file.push_back( MenuElem("_Open", "<control>O", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_file.push_back( MenuElem("_Save", "<control>S", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_file.push_back( MenuElem("Save _As", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_file.push_back(SeparatorElem());
list_file.push_back( MenuElem("_Quit", "<control>Q", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );

//Preferences menu:
Gtk::Menu* pMenuPreferences = Gtk::manage( new Gtk::Menu() );
MenuList& list_preferences = pMenuPreferences->items();

// Create a submenu
Gtk::Menu* pMenuSub_Color = Gtk::manage( new Gtk::Menu());
MenuList& list_sub = pMenuSub_Color->items();
list_sub.push_back( MenuElem("_Red", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_sub.push_back( MenuElem("_Green", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_sub.push_back( MenuElem("_Blue", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );

list_preferences.push_back( MenuElem("_Color", *pMenuSub_Color) );

// Create a submenu
Gtk::Menu* pMenuSub_Shape = Gtk::manage( new Gtk::Menu());
list_sub = pMenuSub_Shape->items();
list_sub.push_back( MenuElem("_Square", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_sub.push_back( MenuElem("_Rectangle", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );
list_sub.push_back( MenuElem("_Oval", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );

list_preferences.push_back( MenuElem("_Shape", *pMenuSub_Shape) );

//Help menu:
Gtk::Menu* pMenuHelp = Gtk::manage( new Gtk::Menu() );
MenuList& list_help = pMenuHelp->items();
list_help.push_back( MenuElem("_About", sigc::mem_fun(*this, &Example_AppWindow::on_menu_item)) );


//Create the menu bar
MenuList& list_bar = m_Menubar.items();
list_bar.push_front(MenuElem("_Help", *pMenuHelp));
list_bar.front()->set_right_justified();
list_bar.push_front(MenuElem("_Preferences", *pMenuPreferences));
list_bar.push_front(MenuElem("_File", *pMenuFile));

//Add the menu bar to the Table:
m_Table.attach(m_Menubar,
// X direction Y direction
0, 1, 0, 1,
Gtk::FILL|Gtk::EXPAND, Gtk::AttachOptions(0)
);
} //menu

*/
//Toolbar:
{
m_Table.attach(m_Toolbar,
/* X direction */ /* Y direction */
0, 1, 1, 2,
Gtk::FILL|Gtk::EXPAND, Gtk::AttachOptions(0)
);
}


m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_ScrolledWindow.set_shadow_type(Gtk::SHADOW_IN);
m_Table.attach(m_ScrolledWindow,
/* X direction */ /* Y direction */
0, 1, 2, 3);

set_default_size(200, 200);

m_ScrolledWindow.add(m_TextView);


/* Create statusbar */

m_Table.attach(m_Statusbar,
/* X direction */ /* Y direction */
0, 1, 3, 4,
Gtk::FILL|Gtk::EXPAND, Gtk::AttachOptions(0)
);


/* Show text widget info in the statusbar */
Glib::RefPtr<Gtk::TextBuffer> refTextBuffer = m_TextView.get_buffer();
refTextBuffer->signal_changed().connect(sigc::mem_fun(*this, &Example_AppWindow::on_text_changed));
refTextBuffer->signal_mark_set().connect(sigc::mem_fun(*this, &Example_AppWindow::on_text_mark_set));
on_text_changed();

show_all();
}

Example_AppWindow::~Example_AppWindow()
{
}

void Example_AppWindow::on_menu_item()
{
Gtk::MessageDialog dialog(*this, "You selected or toggled the menu item", false,
Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE);
dialog.run();
}

void Example_AppWindow::on_text_changed()
{
m_Statusbar.pop();

Glib::RefPtr<Gtk::TextBuffer> refBuffer = m_TextView.get_buffer();
gint count = refBuffer->get_char_count();

Gtk::TextBuffer::iterator iter = refBuffer->get_iter_at_mark(refBuffer->get_insert());

gint row = iter.get_line();
gint col = iter.get_line_offset();

gchar* msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
row, col, count);
m_Statusbar.push(msg);
g_free (msg);
}


void Example_AppWindow::on_text_mark_set(const Gtk::TextBuffer::iterator&, const Glib::RefPtr<Gtk::TextBuffer::Mark>&)
{
on_text_changed();
}

int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);

Example_AppWindow window;

return 0;
}
3 changes: 3 additions & 0 deletions recipes/gtkmm/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.24.5":
folder: "2.x.x"