Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › Fail API wrapper class, I need criticism..

Fail API wrapper class, I need criticism..

Posts 1–13 of 13 · Page 1 of 1
Void
Void
Fail API wrapper class, I need criticism..
As some of you may know I recently started programming on Ubuntu.. well, not that you guys care anyway.

So, I come here to post my fail wrapper for the GTK+ class... Well it's not even a fail, it's less than that because it isn't finished and I'm not really ready for it yet, the I tried setting up a single callback for every widget and I failed hardcore so I'm putting this on pause for a bit.

Also, the reason I was making this wrapper was because GTK+ is fucking disgusting... I know I'm going to get flamed cause I know that Linux is the superior programming OS, as some say.. I'm just too much of a Windows fanboy to possibly like the way they set up the GTK library, just the names of the functions is enough to make me puke..

Anyway, posting this 'cause I would like some suggestions on how I could improve on the parts I've already done, anything at all, anything to make the class easier to use.

How I was originally going to do it was... a little like this...

Main class -> Widget class -> Seperate class for each widget.

But that obviously didn't work out, kind of.. I just didn't add the other classes to the widget class, and I didn't make them all, yet.. I didn't even make the main class yet, I was working backwards..

CWidget.h
[php]
#ifndef CWIDGET_H
#define CWIDGET_H

#include <gtk/gtk.h>
#include "CMenu.h"

enum WidgetType { WT_BUTTON = 0,
WT_LABEL,
WT_CHECKBUTTON,
WT_MENU,
WT_CHILD
};

class CWidget {
private:
static GtkWidget* PlacementFrame;
GtkWidget* Widget;
WidgetType Type;
public:
static void InitializeWidget(GtkWidget*);
void CreateWidget(WidgetType,char*,int,int,int,int);
void SetText(char*);
};


#endif
[/php]

CWidget.cpp
[php]
#include "CWidget.h"

GtkWidget* CWidget::PlacementFrame = NULL;

void CWidget::InitializeWidget(GtkWidget* pf)
{
CWidget::PlacementFrame = pf;
}

void CWidget::CreateWidget(WidgetType Type,char* text,int Width,int Height,int X,int Y)
{
switch(Type)
{
case WT_BUTTON:
CWidget::Widget = gtk_button_new_with_label(text);
gtk_widget_set_size_request(CWidget::Widget,Width, Height);
gtk_fixed_put(GTK_FIXED(PlacementFrame),CWidget::W idget,X,Y);
CWidget::Type = WT_BUTTON;
break;

case WT_LABEL:
CWidget::Widget = gtk_label_new(text);
gtk_fixed_put(GTK_FIXED(PlacementFrame),CWidget::W idget,X,Y);
CWidget::Type = WT_LABEL;
break;
}
}

void CWidget::SetText(char* text)
{
switch(CWidget::Type)
{
case WT_BUTTON:
gtk_button_set_label((GtkButton*)CWidget::Widget,t ext);
break;
case WT_LABEL:
gtk_label_set_text((GtkLabel*)CWidget::Widget,text );
break;
}
}
[/php]

CCheckButton.h
[php]
#ifndef CCHECKBUTTON_H
#define CCHECKBUTTON_H

#include <gtk/gtk.h>

class CCheckButton {
private:
GtkWidget* CheckButton;
public:
void CreateCheckButton(GtkWidget* Place,char*,int,int,bool);
bool GetStatus();
void SetStatus(bool);
};

#endif
[/php]

CCheckButton.cpp
[php]
#include "CCheckButton.h"

void CCheckButton::CreateCheckButton(GtkWidget* Place,char* text,int X,int Y,bool active)
{
CCheckButton::CheckButton = gtk_check_button_new_with_label(text);
GTK_WIDGET_UNSET_FLAGS(CCheckButton::CheckButton,G TK_CAN_FOCUS);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CCh eckButton::CheckButton),active);
gtk_fixed_put(GTK_FIXED(Place),CCheckButton::Check Button,X,Y);
}

bool CCheckButton::GetStatus()
{
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CCh eckButton::CheckButton));
}

void CCheckButton::SetStatus(bool active)
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CCh eckButton::CheckButton),active);
}
[/php]

CMenu.h
[php]
#ifndef CMENU_H
#define CMENU_H

#include <gtk/gtk.h>

class CMenu {
private:
GtkWidget* Placement;
GtkWidget* MenuBar;
GtkWidget* MenuItem[128];
public:
void CreateMenu(GtkWidget*,int,int);
void AddMenuSelection(char*,int);
void AddMenuItem(char*,int);

};

#endif
[/php]

CMenu.cpp
[php]
#include "CMenu.h"

void CMenu::CreateMenu(GtkWidget* Place,int X,int Y)
{
CMenu::MenuBar = gtk_menu_bar_new();
gtk_fixed_put(GTK_FIXED(Place),CMenu::MenuBar,X,Y) ;
}

void CMenu::AddMenuSelection(char* text,int index)
{
CMenu::MenuItem[index] = gtk_menu_new();
GtkWidget* ItemName = gtk_menu_item_new_with_label(text);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(ItemName), CMenu::MenuItem[index]);
gtk_menu_shell_append(GTK_MENU_SHELL(CMenu::MenuBa r),ItemName);
}

void CMenu::AddMenuItem(char* item,int index)
{
GtkWidget* Item = gtk_menu_item_new_with_label(item);
gtk_menu_shell_append(GTK_MENU_SHELL(CMenu::MenuIt em[index]),Item);
}
[/php]

And here's an example of how to use it... You may have noticed there is some GTK API in the main file, as I said, the main class is not complete so I had to create the placement frame and the actual window using the actual GTK API..

Main.cpp
[php]
#include <gtk/gtk.h>
#include "CWidget.h"
#include "CCheckButton.h"

CWidget* Button;
CCheckButton* CheckButton;
CMenu *Menu;

int main()
{
GtkWidget* MainWindow;
GtkWidget* cPlacementFrame;

gtk_init(NULL,NULL);
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(MainWindow) ,300,300);

cPlacementFrame = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(MainWindow),cPlace mentFrame);

CWidget::InitializeWidget(cPlacementFrame);

//Button
Button = new CWidget;
Button->CreateWidget(WT_BUTTON,"Button",85,50,30,30);

//CheckButton
CheckButton = new CCheckButton;
CheckButton->CreateCheckButton(cPlacementFrame,"Check button",30,80,false);

//Menu
Menu = new CMenu;
Menu->CreateMenu(cPlacementFrame,0,0);
Menu->AddMenuSelection("File",1);
Menu->AddMenuItem("New",1);
Menu->AddMenuItem("Open",1);
Menu->AddMenuItem("Quit",1);

gtk_widget_show_all(MainWindow);
gtk_main();
return 0;
}
[/php]

Remember, I want suggestions on how to make it better. Also, your opinion on the structure of everything..
#1 · 16y ago
Auxilium
Auxilium
I thought it was Xandros?
#2 · 16y ago
Void
Void
I installed a distro of Linux that doesn't suck shit. Now I can actually program.
#3 · 16y ago
Auxilium
Auxilium
Oh. Isn't it a netbook? I though Ubuntu Was resource heavy / It sort of lags on Virtual PC given 512 MB RAM../
#4 · 16y ago
Void
Void
Nah it runs fine on my netbook. Anyways, any opinion on my class?
#5 · 16y ago
Auxilium
Auxilium
Quote Originally Posted by Void View Post
Nah it runs fine on my netbook. Anyways, any opinion on my class?
Oh. I can't really judge the class because i just finished my classes chapter.
#6 · 16y ago
Void
Void
Quote Originally Posted by Koreans View Post


Oh. I can't really judge the class because i just finished my classes chapter.
That's enough to give some criticism.
#7 · 16y ago
Auxilium
Auxilium
Alright. from a noob at C++ like myself, they seem great. But that's from a noob.
#8 · 16y ago
FA
Fabolous
It looks nice. Good Job Void
#9 · 16y ago
Hell_Demon
Hell_Demon
Enough code to make me want to stay away from linux, gj
#10 · 16y ago
Kallisti
Kallisti
Im thinking about installing Linux Side by side and using dualboot.
But when i installed it in virtual PC. Whenever its booting up, its has like retarded green scanlines and the resolution changes like 3 times before finally getting to the login screen /
#11 · 16y ago
Void
Void
Install Ubuntu 10.04. It looks really nice, and functional.
#12 · 16y ago
Kallisti
Kallisti
Quote Originally Posted by Void View Post
Install Ubuntu 10.04. It looks really nice, and functional.
I did. When you boot up, right after the little blinking underscore appears it gets retarded scanlines for a while, but goes away when you get to login screen.

And also, Since im a retard When i last formatted i just made 1 big partition ( C: ). Will it work fine on the same partition as windows with ntfs?
#13 · 16y ago
Posts 1–13 of 13 · Page 1 of 1

Post a Reply

Similar Threads

  • Piano may not be considered 'cool' by the uncool kids here on MPGH, need criticismBy Jabuuty671 in Art & Graphic Design
    13Last post 15y ago
  • some good constructive criticism neededBy Remorse in Showroom
    13Last post 17y ago
  • PATCH FAIL! NEED SOMEONES FILE!By Justin in Combat Arms Help
    3Last post 17y ago
  • Win32 Api Class [In Devolopment]By zhaoyun333 in C++/C Programming
    15Last post 16y ago
  • Hmmmmm I need v.i.p coz pub hx failBy invisible29 in CrossFire Hacks & Cheats
    3Last post 16y ago

Tags for this Thread

None