Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtk-3.0/gtk/gtk.h>
- #include <string>
- #include <iostream>
- typedef struct t_WINDOWSCBSD
- {
- GtkWidget *window, *textView;
- } WINDOWSCBSD;
- static void destroy(GtkWidget *widget, gpointer data)
- {
- gtk_main_quit();
- }
- static void buttonClickedD(GtkWidget *buttony, gpointer data)
- {
- WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
- const gchar *gtextView;
- std::string stextView;
- gtextView = gtk_entry_get_text(GTK_ENTRY(myData->textView));
- stextView = gtextView;
- std::cout<<stextView<<std::endl;
- }
- static void buttonClickedC(GtkWidget *buttony, gpointer data)
- {
- GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
- WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
- WINDOWSCBSD dataB;
- windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(windowB, 160, 80);
- gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
- g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
- dataB.window = myData->window;
- grid = gtk_grid_new();
- gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
- gtk_container_add(GTK_CONTAINER(windowB), grid);
- label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
- gtk_widget_set_halign(label, GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
- textView = gtk_entry_new();
- gtk_widget_set_size_request(textView, 75, 18);
- dataB.textView = myData->textView;
- gtk_entry_set_text(GTK_ENTRY(textView), "testextD");
- gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
- button = gtk_button_new_with_label((gchar *)"Clicky");
- buttonLabel = gtk_bin_get_child(GTK_BIN(button));
- gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
- g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedD), &dataB);//&myData //&dataB
- gtk_widget_set_tooltip_text(button, "Click here to start child");
- gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
- gtk_widget_grab_focus(button);
- gtk_widget_show_all(windowB);
- gtk_main();
- }
- static void buttonClickedB(GtkWidget *buttony, gpointer data)
- {
- GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
- WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
- WINDOWSCBSD dataB;
- windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(windowB, 160, 80);
- gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
- g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
- dataB.window = myData->window;
- grid = gtk_grid_new();
- gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
- gtk_container_add(GTK_CONTAINER(windowB), grid);
- label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
- gtk_widget_set_halign(label, GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
- textView = gtk_entry_new();
- gtk_widget_set_size_request(textView, 75, 18);
- dataB.textView = myData->textView;
- gtk_entry_set_text(GTK_ENTRY(textView), "testextD");
- gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
- button = gtk_button_new_with_label((gchar *)"Clicky");
- buttonLabel = gtk_bin_get_child(GTK_BIN(button));
- gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
- g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedC), &dataB);//&myData //&dataB
- gtk_widget_set_tooltip_text(button, "Click here to start child");
- gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
- gtk_widget_grab_focus(button);
- gtk_widget_show_all(windowB);
- gtk_main();
- }
- static void buttonClicked(GtkWidget *buttony, gpointer data)
- {
- GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
- WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
- WINDOWSCBSD dataB;
- windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(windowB, 160, 80);
- gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
- g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
- dataB.window = myData->window;
- grid = gtk_grid_new();
- gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
- gtk_container_add(GTK_CONTAINER(windowB), grid);
- label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
- gtk_widget_set_halign(label, GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
- textView = gtk_entry_new();
- gtk_widget_set_size_request(textView, 75, 18);
- dataB.textView = myData->textView;
- gtk_entry_set_text(GTK_ENTRY(textView), "testextD");
- gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
- button = gtk_button_new_with_label((gchar *)"Clicky");
- buttonLabel = gtk_bin_get_child(GTK_BIN(button));
- gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
- g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedB), &dataB);//&myData //&dataB
- gtk_widget_set_tooltip_text(button, "Click here to start child");
- gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
- gtk_widget_grab_focus(button);
- gtk_widget_show_all(windowB);
- gtk_main();
- }
- int main(int argc, char *argv[])
- {
- GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
- //WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
- WINDOWSCBSD dataB;
- gtk_init(&argc, &argv);
- windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(windowB, 160, 80);
- gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
- g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
- dataB.window = windowB;
- grid = gtk_grid_new();
- gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
- gtk_container_add(GTK_CONTAINER(windowB), grid);
- label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
- gtk_widget_set_halign(label, GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
- textView = gtk_entry_new();
- gtk_widget_set_size_request(textView, 75, 18);
- dataB.textView = textView;
- gtk_entry_set_text(GTK_ENTRY(textView), "testext");
- gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
- button = gtk_button_new_with_label((gchar *)"Clicky");
- buttonLabel = gtk_bin_get_child(GTK_BIN(button));
- gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
- g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClicked), &dataB);
- gtk_widget_set_tooltip_text(button, "Click here to start child");
- gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
- gtk_widget_grab_focus(button);
- gtk_widget_show_all(windowB);
- gtk_main();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement