がんばって英語で書くブログ
英語勉強中なので、ブログも英語で書こうかと。
スポンサーサイト
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

GTK+ studying7
This is GTK+ memo. using combo box.


#include <gtk/gtk.h>

static gboolean button_clicked(GtkWidget *widget,
gpointer data)
{
GtkWidget *combo = (GtkWidget *) data;

gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
gint idx = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
g_print("active text is [%s(index:%d)]\n", str, idx);

return FALSE;
}

static GtkWidget *create_button(void *data)
{
GtkWidget *button;

button = gtk_button_new_with_label("ok");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(button_clicked), data);

return button;
}

void create_window(void)
{
GtkWidget *window;
GtkWidget *hbox;
GtkWidget *vbox1;
GtkWidget *vbox2;
GtkWidget *button;
GtkWidget *separator;
GtkWidget *combo;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "combo box test");

gtk_container_set_border_width(GTK_CONTAINER(window), 5);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);

hbox = gtk_hbox_new(FALSE, 0);
vbox1 = gtk_vbox_new(FALSE,0);
vbox2 = gtk_vbox_new(FALSE, 0);

gtk_container_add(GTK_CONTAINER(vbox1), hbox);

combo = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "test1");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "test2");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "test3");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "test4");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "test5");
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);

gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);

gtk_widget_show(combo);

gtk_widget_show(hbox);

gtk_container_add(GTK_CONTAINER(window), vbox1);
gtk_widget_show(vbox1);

separator = gtk_hseparator_new ();
gtk_box_pack_start(GTK_BOX(vbox1), separator, FALSE, TRUE, 0);
gtk_widget_show(separator);

button = create_button(combo);
gtk_box_pack_start(GTK_BOX(vbox2), button, TRUE, TRUE, 0);
gtk_widget_show(button);

gtk_container_add(GTK_CONTAINER(vbox1), vbox2);
gtk_widget_show(vbox2);

gtk_widget_show(window);

}

int main(int argc, char **argv)
{
gtk_init(&argc, &argv);

create_window();

gtk_main();

return 0;
}



テーマ:英語日記 - ジャンル:学問・文化・芸術

GTK+ studying6
This is GTK+ memo. using spin button.


#include <gtk/gtk.h>

static gboolean button_clicked(GtkWidget *widget,
gpointer data)
{
GtkWidget *spin = (GtkWidget *) data;

gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));

g_print("selected value is [%d]\n", value);

return FALSE;
}

static GtkWidget *create_button(void *data)
{
GtkWidget *button;

button = gtk_button_new_with_label("ok");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(button_clicked), data);

return button;
}

void create_window(void)
{
GtkWidget *window;
GtkWidget *hbox;
GtkWidget *vbox1;
GtkWidget *vbox2;
GtkWidget *button;
GtkWidget *separator;
GtkWidget *spin;
GtkObject *adjstment;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "spin button test");

gtk_container_set_border_width(GTK_CONTAINER(window), 5);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);

hbox = gtk_hbox_new(FALSE, 0);
vbox1 = gtk_vbox_new(FALSE,0);
vbox2 = gtk_vbox_new(FALSE, 0);

gtk_container_add(GTK_CONTAINER(vbox1), hbox);

/* range is 0 to 10 */
adjstment = gtk_adjustment_new(0.0, 0.0, 10.0, 1.0, 1.0, 0.0);

spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjstment), 0, 0);

gtk_box_pack_start(GTK_BOX(hbox), spin, TRUE, TRUE, 0);
gtk_widget_show(spin);

gtk_widget_show(hbox);

gtk_container_add(GTK_CONTAINER(window), vbox1);
gtk_widget_show(vbox1);

separator = gtk_hseparator_new ();
gtk_box_pack_start(GTK_BOX(vbox1), separator, FALSE, TRUE, 0);
gtk_widget_show(separator);

button = create_button(spin);
gtk_box_pack_start(GTK_BOX(vbox2), button, TRUE, TRUE, 0);
gtk_widget_show(button);

gtk_container_add(GTK_CONTAINER(vbox1), vbox2);
gtk_widget_show(vbox2);

gtk_widget_show(window);

}

int main(int argc, char **argv)
{
gtk_init(&argc, &argv);

create_window();

gtk_main();

return 0;
}


テーマ:英語日記 - ジャンル:学問・文化・芸術

GTK+ studying5
This is GTK+ memo. using multi line text and scrolled window.


#include <gtk/gtk.h>

static gboolean button_clicked(GtkWidget *widget,
gpointer data)
{
GtkWidget *text = (GtkWidget *) data;
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
GtkTextIter start, end;

/* i need start and end position */
gtk_text_buffer_get_start_iter(buffer, &start);
gtk_text_buffer_get_end_iter(buffer, &end);

gchar *str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);

g_print("text is [%s]\n", str);

return TRUE;
}

static GtkWidget *create_button(void *data)
{
GtkWidget *button;

button = gtk_button_new_with_label("ok");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(button_clicked), data);

return button;
}

void create_window(void)
{
GtkWidget *window;
GtkWidget *vbox1;
GtkWidget *vbox2;
GtkWidget *button;
GtkWidget *separator;
GtkWidget *text;
GtkWidget *scrollWindow;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "multiline text test");
gtk_widget_set_size_request(GTK_WIDGET(window), 200, 250);

gtk_container_set_border_width(GTK_CONTAINER(window), 5);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);

vbox1 = gtk_vbox_new(FALSE, 7);
vbox2 = gtk_vbox_new(FALSE, 5);

/* create scrolled window */
scrollWindow = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollWindow),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);

gtk_box_pack_start(GTK_BOX(vbox1), scrollWindow, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(vbox1), scrollWindow);

text = gtk_text_view_new();

gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), TRUE);
gtk_widget_set_size_request(GTK_WIDGET(scrollWindow), 180, 200);

gtk_widget_show(scrollWindow);

gtk_container_add(GTK_CONTAINER(scrollWindow), text);
gtk_widget_show(text);

gtk_container_add(GTK_CONTAINER(window), vbox1);
gtk_widget_show(vbox1);

separator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox1), separator, FALSE, TRUE, 0);
gtk_widget_show(separator);

button = create_button(text);
gtk_box_pack_start(GTK_BOX(vbox2), button, TRUE, TRUE, 0);
gtk_widget_show(button);

gtk_container_add(GTK_CONTAINER(vbox1), vbox2);
gtk_widget_show(vbox2);

gtk_widget_show(window);

}

int main(int argc, char **argv)
{
gtk_init(&argc, &argv);

create_window();

gtk_main();

return 0;
}



テーマ:英語日記 - ジャンル:学問・文化・芸術

GTK+ studying4
This my gtk+ memo. using text entry.


#include <gtk/gtk.h>

static gboolean button_clicked(GtkWidget *widget,
gpointer data)
{
GtkWidget *entry = (GtkWidget *) data;

const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));

g_print("text is [%s]\n", text);

return FALSE;
}

static GtkWidget *create_button(void *data)
{
GtkWidget *button;

button = gtk_button_new_with_label("ok");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(button_clicked), data);

return button;
}

static gboolean toggled_check_button(GtkWidget *widget,
gpointer data)
{
GtkWidget *entry = (GtkWidget *) data;

gtk_editable_set_editable(GTK_EDITABLE(entry),
GTK_TOGGLE_BUTTON(widget)->active);

return TRUE;
}

void create_window(void)
{
GtkWidget *window;
GtkWidget *hbox;
GtkWidget *vbox1;
GtkWidget *vbox2;
GtkWidget *button;
GtkWidget *separator;
GtkWidget *entry;
GtkWidget *check;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "button-test");

gtk_container_set_border_width(GTK_CONTAINER(window), 5);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);

hbox = gtk_hbox_new(FALSE, 0);
vbox1 = gtk_vbox_new(FALSE,0);
vbox2 = gtk_vbox_new(FALSE, 0);

gtk_container_add(GTK_CONTAINER(vbox1), hbox);

entry = gtk_entry_new();

/* default text is Hello World */
gtk_entry_set_text(GTK_ENTRY(entry), "Hello World");
gtk_editable_select_region(GTK_EDITABLE(entry),
0,
GTK_ENTRY(entry)->text_length);

/* default: you can't change text */
gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE);
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
gtk_widget_show(entry);

/* if you toggled this checkbox, you'll be able to change text */
check = gtk_check_button_new_with_label("editable");
g_signal_connect(G_OBJECT(check), "toggled",
G_CALLBACK(toggled_check_button), entry);

gtk_box_pack_start(GTK_BOX(hbox), check, TRUE, TRUE, 0);
gtk_widget_show(check);

gtk_widget_show(hbox);

gtk_container_add(GTK_CONTAINER(window), vbox1);
gtk_widget_show(vbox1);

separator = gtk_hseparator_new ();
gtk_box_pack_start(GTK_BOX(vbox1), separator, FALSE, TRUE, 0);
gtk_widget_show(separator);

button = create_button(entry);
gtk_box_pack_start(GTK_BOX(vbox2), button, TRUE, TRUE, 0);
gtk_widget_show(button);

gtk_container_add(GTK_CONTAINER(vbox1), vbox2);
gtk_widget_show(vbox2);

gtk_widget_show(window);

}

int main(int argc, char **argv)
{
gtk_init(&argc, &argv);

create_window();

gtk_main();

return 0;
}



テーマ:英語日記 - ジャンル:学問・文化・芸術

pbuilder on stable
if you want to use pbuilder on stable machine, I recommend you do this.

$ sudo pbuilder create --distribution sarge
$ sudo pbuilder login --save-after-login
change /etc/apt/sources.list
chroot# apt-get update
chroot# exit
$

at first, you create sarge environment, then change to unstable.
it's easy way I think.


テーマ:英語日記 - ジャンル:学問・文化・芸術



上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。