Add gtk18
This commit is contained in:
parent
fc44182405
commit
14537aab92
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="gtk18" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/gtk18" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/gtk18" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Unit filename="main.cpp" />
|
||||
<Extensions />
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
|
@ -0,0 +1,62 @@
|
|||
[Project]
|
||||
FileName=gtk18.dev
|
||||
Name=gtk18
|
||||
Type=1
|
||||
Ver=2
|
||||
ObjFiles=
|
||||
Includes=
|
||||
Libs=
|
||||
PrivateResource=
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=
|
||||
CppCompiler=
|
||||
Linker=
|
||||
IsCpp=1
|
||||
Icon=
|
||||
ExeOutput=
|
||||
ObjectOutput=
|
||||
LogOutput=
|
||||
LogOutputEnabled=0
|
||||
OverrideOutput=0
|
||||
OverrideOutputName=gtk18.exe
|
||||
HostApplication=
|
||||
UseCustomMakefile=0
|
||||
CustomMakefile=
|
||||
CommandLine=
|
||||
Folders=
|
||||
IncludeVersionInfo=0
|
||||
SupportXPThemes=0
|
||||
CompilerSet=6
|
||||
CompilerSettings=000000a100000000000000000
|
||||
UnitCount=1
|
||||
|
||||
[VersionInfo]
|
||||
Major=1
|
||||
Minor=0
|
||||
Release=0
|
||||
Build=0
|
||||
LanguageID=1033
|
||||
CharsetID=1252
|
||||
CompanyName=
|
||||
FileVersion=1.0.0.0
|
||||
FileDescription=Developed using the Dev-C++ IDE
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
AutoIncBuildNr=0
|
||||
SyncProduct=1
|
||||
|
||||
[Unit1]
|
||||
FileName=main.cpp
|
||||
CompileCpp=1
|
||||
Folder=
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1787" topLine="32" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="liststore1">
|
||||
<columns>
|
||||
<!-- column-name sddjdddn -->
|
||||
<column type="gchar"/>
|
||||
<!-- column-name sndndjdnff -->
|
||||
<column type="gchar"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFixed">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkComboBox">
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">80</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="model">liststore1</property>
|
||||
<property name="active">2</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">252</property>
|
||||
<property name="y">89</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText">
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">80</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">2</property>
|
||||
<property name="has_entry">True</property>
|
||||
<property name="active_id">1</property>
|
||||
<items>
|
||||
<item translatable="yes">Hello</item>
|
||||
<item translatable="yes">ajsnsjnsk</item>
|
||||
</items>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="text" translatable="yes">Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">118</property>
|
||||
<property name="y">137</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,46 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
void print1(GtkWidget *widget,gpointer data){
|
||||
//Check user selection of combo box and print specific char
|
||||
const gchar *str=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(data));
|
||||
g_print("%s\n",str);
|
||||
if(strcmp(str,"test1")==0){
|
||||
g_print("1\n");
|
||||
}else{
|
||||
g_print("2\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void activate(GtkApplication *app,gpointer user_data){
|
||||
GtkWidget *window;
|
||||
GtkWidget *fixed;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *button;
|
||||
window=gtk_application_window_new(app);//Create a window sized 300x200
|
||||
gtk_window_set_title(GTK_WINDOW(window),"gtk (18)");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window),300,200);
|
||||
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
|
||||
fixed=gtk_fixed_new();//Put the widget at a fixed position
|
||||
gtk_container_add(GTK_CONTAINER(window),fixed);
|
||||
combo=gtk_combo_box_text_new();//Create a combo box
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),"test1");
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),"test2");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);//Set default selection
|
||||
gtk_widget_set_size_request(combo,100,40);
|
||||
gtk_fixed_put(GTK_FIXED(fixed),combo,100,50);
|
||||
button=gtk_button_new_with_label("Print");//Button to response
|
||||
gtk_widget_set_size_request(button,100,50);
|
||||
gtk_fixed_put(GTK_FIXED(fixed),button,100,105);
|
||||
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(print1),(gpointer)combo);
|
||||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
//Common way to create a gtk application
|
||||
GtkApplication *app;
|
||||
int status;
|
||||
app=gtk_application_new("com.github.daleclack.gtk18",G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect(app,"activate",G_CALLBACK(activate),NULL);
|
||||
status=g_application_run(G_APPLICATION(app),argc,argv);
|
||||
return status;
|
||||
}
|
Loading…
Reference in New Issue