cygwin gtk 프로그래밍 연습중인데요..

yjsyjs3030의 이미지

예를들어 콤보박스랑 다른 버튼들을 한 화면에 출력하고 싶은데 합쳐지지가않내요..

테이블안에 넣고싶은데 테이블안에 콤보박스나 다른 보여주는 기능들을 넣고 싶은데 어찌해야할지 모르겟내요 ㅠㅠ 아래는 예제들입니당..
두개의 예제를 합치고 싶은데 ㅠㅠ 초보라 어렵내용..#include"config.h"이건 cygwin에서 에러를 내는데 이유도 궁금합니다..

#include "gtk/gtk.h"

/* 우리의 callback.
* 이 함수로 넘겨지는 데이타는 stdout으로 출력된다. */
void callback (GtkWidget *widget, gpointer data)
{
g_print ("Hello again - %s was pressed\n", (char *) data);
}

/* 이 callback 프로그램을 종료한다 */
void delete_event (GtkWidget *widget, gpointer data)
{
gtk_main_quit ();
}

int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *table;

gtk_init (&argc, &argv);

/* 새로운 윈도를 만든다. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

/* 윈도의 제목을 정한다. */
gtk_window_set_title (GTK_WINDOW (window), "Table");

/* GTK를 곧장 종료시키는 delete_event 핸들러를 정한다. */
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (delete_event), NULL);

/* 윈도의 border width를 정한다. */
gtk_container_border_width (GTK_CONTAINER (window), 20);

/* 2x2의 테이블을 만든다. */
table = gtk_table_new (2, 2, TRUE);

/* 테이블을 윈도에 놓는다. */
gtk_container_add (GTK_CONTAINER (window), table);

/* 첫 버튼을 만든다. */
button = gtk_button_new_with_label ("button 1");

/* 버튼이 눌리면 "button 1"을 인수로 해서 "callback" 함수를
* 부른다. */
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (callback), (gpointer) "button 1");

/* 첫 버튼을 테이블 왼쪽 제일 위에 놓는다. */
gtk_table_attach_defaults (GTK_TABLE(table), button, 0, 1, 0, 1);

gtk_widget_show (button);

/* 두번째 버튼을 만든다. */

button = gtk_button_new_with_label ("button 2");

/* 버튼이 눌리면 "button 2"을 인수로 해서 "callback" 함수를
* 부른다. */
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (callback), (gpointer) "button 2");
/* 두번째 버튼을 테이블 오른쪽 제일 위에 놓는다. */
gtk_table_attach_defaults (GTK_TABLE(table), button, 1, 2, 0, 1);

gtk_widget_show (button);

/* "Quit" 버튼을 만든다. */
button = gtk_button_new_with_label ("Quit");

/* 버튼이 눌리면 "delete_event" 함수를 호출해서
* 프로그램을 끝낸다. */
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (delete_event), NULL);

/* "Quit" 버튼을 테이블의 아랫행의 두열에 놓는다. */
gtk_table_attach_defaults (GTK_TABLE(table), button, 4, 5, 9, 10);

gtk_widget_show (button);

gtk_widget_show (table);
gtk_widget_show (window);

gtk_main ();

return 0;
}

// 콤보박스 예제
#include"config.h"
#include"gtk/gtk.h"

#include"stdio.h"

int destroy_func(GtkWidget *widget, gpointer gdata)
{
g_print("quit....\n");
//gtk 프로그램 종료
gtk_main_quit();

return FALSE;
}

void combo_is_changed(GtkWidget *widget, gpointer gdata)
{
gchar *str = NULL;
str = gtk_entry_get_text(GTK_ENTRY(widget));
g_print("combo changed to %s\n", str);

}

int main(int argc, char **argv)
{
GtkWidget *w;
GtkWidget *combo;
GList * items;

gtk_init(&argc, &argv);

//window 생성
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);

//종료시 callback function 등록
gtk_signal_connect(GTK_OBJECT(w), "delete_event",
GTK_SIGNAL_FUNC(destroy_func), NULL);

//combo box에 넣은 item 리스트를 생성
items = g_list_alloc();

items = g_list_append(items, "first");
items = g_list_append(items, "second");
items = g_list_append(items, "third");
items = g_list_append(items, "fourth");

//combo box 생성
combo = gtk_combo_new();

//item 리스트를 combo box에 추가
gtk_combo_set_popdown_strings(GTK_COMBO(combo), items);
//combo box가 변경되었을 경우 호출되어질 이벤트 핸들러 등록
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",
GTK_SIGNAL_FUNC(combo_is_changed), NULL);

//combo box의 item을 수정할 수 없도록 설정
gtk_entry_set_editable(GTK_COMBO(combo)->entry, FALSE);

gtk_widget_show(combo);

//combo box를 담을 container설정
gtk_container_border_width(GTK_CONTAINER(w), 15);

//combo box 추가
gtk_container_add(GTK_CONTAINER(w), combo);

//window 사이즈 설정
gtk_window_set_default_size(w, 200, 100);

gtk_widget_show(w);

//gtk 메인 루프
gtk_main();
return 0;
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.