#1 Le 19/12/2016, à 04:30
- JPlaroche
creer votre Wizard gtkmm pour codeblocks
bonjour, un truc sympa pour programmer avec codeblocks et gtkmm
a) GTKMM 3.x
** sudo apt install libgtkmm-3.0-dev
** sudo apt install libgtkmm-3.0-doc
** sudo apt install libgstreamermm-1.0-dev
** sudo apt install devhelp
si vous ne voulez plus
** sudo apt purge --auto-remove libgtkmm-3.0-dev ect...
** sudo apt purge --auto-remove libgtkmm-3.0-doc
** sudo apt purge --auto-remove libgstreamermm-1.0-dev
** sudo apt purge --auto-remove devhelp
dans codeblocks
copier le repertoir gtk dans gtkmm
sudo cp -R /usr/share/codeblocks/templates/wizard/gtk/ /usr/share/codeblocks/templates/wizard/gtkmm/
supprimer le fichier
sudo rm /usr/share/codeblocks/templates/wizard/gtkmm/wizard.script
creer un fichier sur votre bureau wizard.script et copier le code
////////////////////////////////////////////////////////////////////////////////
//
// GTKMM project wizard
//
////////////////////////////////////////////////////////////////////////////////
// globals
GtkmmPathDefault <- _T("$(#gtkmm)");
GtkmmPathDefaultInc <- _T("$(#gtkmm.include)");
GtkmmPathDefaultLib <- _T("$(#gtkmm.lib)");
GtkmmPath <- _T("");
// GtkVersion <- 3.0
function BeginWizard()
{
local intro_msg = _T("Welcome to the new GTKMM project wizard!\n" +
"This wizard will guide you to create a new GTKMM project\n" +
"using the GTKMM cross-platform GUI toolkit\n\n" +
"When you're ready to proceed, please click \"Next\"...");
local gtkmmpath_msg = _T("Please select the location of GTKMM on your computer.\n" +
"This is the top-level folder where GTKMMM was installed.\n" +
"To help you, this folder must contain the subfolders\n" +
"\"include\" and \"lib\".");
Wizard.AddInfoPage(_T("GtkmmIntro"), intro_msg);
Wizard.AddProjectPathPage();
Wizard.AddCompilerPage(_T(""), _T("gcc*"), true, true);
}
////////////////////////////////////////////////////////////////////////////////
// Gtk's path page
////////////////////////////////////////////////////////////////////////////////
function OnLeave_GtkmmPath(fwd)
{
if (fwd)
{
local dir = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
local dir_nomacro = VerifyDirectory(dir);
if (dir_nomacro.IsEmpty())
return false;
// verify include dependencies
local dir_nomacro_inc = GetCompilerIncludeDir(dir, GtkmmPathDefault, GtkmmPathDefaultInc);
if (dir_nomacro_inc.IsEmpty())
return false;
if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtkmm-3.0") , _T("gtkmm.h"), _T("GTKMM's include")))
return false;
// verify library dependencies
local dir_nomacro_lib = GetCompilerLibDir(dir, GtkmmPathDefault, GtkmmPathDefaultLib);
if (dir_nomacro_lib.IsEmpty())
return false;
if (!VerifyLibFile(dir_nomacro_lib, _T("gtkmm-3.0"), _T("GTKMM's")))
return false;
GtkmmPath = dir; // Remember the original selection.
local is_macro = _T("");
// try to resolve the include directory as macro
is_macro = GetCompilerIncludeMacro(dir, GtkPathDefault, GtkPathDefaultInc);
if (is_macro.IsEmpty())
{
// not possible -> use the real inc path we had computed instead
GtkPathDefaultInc = dir_nomacro_inc;
}
// try to resolve the library directory as macro
is_macro = GetCompilerLibMacro(dir, GtkmmPathDefault, GtkmmPathDefaultLib);
if (is_macro.IsEmpty())
{
// not possible -> use the real lib path we had computed instead
GtkmmPathDefaultLib = dir_nomacro_lib;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// Gtk's version page (For *nix users)
////////////////////////////////////////////////////////////////////////////////
function OnLeave_GtkVersionPage(fwd)
{
if (fwd)
{
GtkVersion = Wizard.GetListboxSelection(_T("GenericChoiceList"));
}
return true;
}
// return the files this project contains
function GetFilesDir()
{
return _T("gtkmm/files");
}
// setup the already created project
function SetupProject(project)
{
if (PLATFORM == PLATFORM_MSW)
{
project.AddIncludeDir(GtkmmPathDefaultInc) ;
project.AddIncludeDir(GtkmmPathDefaultInc + wxFILE_SEP_PATH + _T("gdkmm-3.0"));
project.AddIncludeDir(GtkmmPathDefaultLib + wxFILE_SEP_PATH + _T("gdkmm-3.0") + wxFILE_SEP_PATH + _T("include"));
project.AddLibDir(GtkmmPathDefaultLib);
// add link libraries
project.AddLinkLib(_T("gtkmm-3.0"));
project.AddCompilerOption(_T("-mms-bitfields"));
}
else
{
project.AddCompilerOption(_T("`pkg-config gtkmm-3.0 --cflags`"));
project.AddLinkerOption(_T("`pkg-config gtkmm-3.0 --libs`"));
}
// enable compiler warnings (project-wide)
WarningsOn(project, Wizard.GetCompilerID());
// Debug
local target = project.GetBuildTarget(Wizard.GetDebugName());
if (!IsNull(target))
{
target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
// enable generation of debugging symbols for target
DebugSymbolsOn(target, Wizard.GetCompilerID());
}
// Release
target = project.GetBuildTarget(Wizard.GetReleaseName());
if (!IsNull(target))
{
target.SetTargetType(ttExecutable); // ttExecutable: no console
target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
// enable optimizations for target
OptimizationsOn(target, Wizard.GetCompilerID());
}
return true;
}
sudo cp /home/?????/Bureau/wizard.script /usr/share/codeblocks/templates/wizard/gtkmm/wizard.script
supprimer le fichier de votre bureau
===============================================================================
supprimer le fichier main.c
sudo rm /usr/share/codeblocks/templates/wizard/gtkmm/files/main.c
executer le code pour creer le fichier main.cpp
sudo sh -c 'printf "#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(400, 200);
return app->run(window);
}" >/usr/share/codeblocks/templates/wizard/gtkm/files/main.cpp
'
lire les deux méthodes avant
pour le fichier config.script 1° methode
modifier le fichier /usr/share/codeblocks/templates/wizard/config.script
afin que code blocks reconnaisse GTKMM
ligne 36 après GTK
RegisterWizard(wizProject, _T("gtkmm"), _T("GTKMM project"), _T("GUI"));
pour le fichier config.script 2° methode
vous n'avez pas grand risque en ligne 35 ce trouve GTK même si sa bouge (peu en vérité) cela vous évitera de faire la première méthode
insert à la ligne 36 le code pour gtkmm
sudo sed -i 36i'RegisterWizard(wizProject, _T("gtkmm"), _T("GTKMM project"), _T("GUI"));' /usr/share/codeblocks/templates/wizard/config.script
si vous êtes en mis a jour nigth alors la second solution est pour vous car la mise à jour régénère le fichier config.script par contre le dossier ouvert le template n'est pas touché
c'est terminer..... Ouf
allez dans votre code::blocks ouvrer
et vous aurez l'iconne gtkmm après c'est comme pour les autres projets
j'espere que cela vous aura été utile
:cool:
Dernière modification par JPlaroche (Le 21/12/2016, à 21:01)
depuis 2004 avec Ubuntu
depuis 1976 informaticien Mon site plein d'information pour les programmeurs http://www.ombrebleu.com
Hors ligne
#2 Le 21/12/2016, à 21:05
- JPlaroche
Re : creer votre Wizard gtkmm pour codeblocks
bonjour à la place :
sudo sed -i 36i'RegisterWizard(wizProject, _T("gtkmm"), _T("GTKMM project"), _T("GUI"));' /usr/share/codeblocks/templates/wizard/config.script
un petit script qui automatise cela sans risque
gtkmm.sh
#!/bin/bash
gtk=$(grep -n GTK+ /usr/share/codeblocks/templates/wizard/config.script | cut -d: -f1)
if [[ $gtk == "" ]]
then
echo "Pas de lib GTK+"
exit 0
fi
gtkmm=$(grep -n GTKMM /usr/share/codeblocks/templates/wizard/config.script | cut -d: -f1)
if [[ $gtkmm > "" ]]
then
echo "gtkmm déjà actif"
exit 0
fi
gtk=$(expr $gtk + 1)
# echo -e $ligne
sudo sed -i 36i'RegisterWizard(wizProject, _T("gtkmm"), _T("GTKMM project"), _T("GUI"));' /usr/share/codeblocks/templates/wizard/config.script
echo "gtkmm Installé"
exit 0
:P;)
depuis 2004 avec Ubuntu
depuis 1976 informaticien Mon site plein d'information pour les programmeurs http://www.ombrebleu.com
Hors ligne