Advertisement
Combreal

testGtk01.cpp

Apr 11th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. #include <gtk-3.0\gtk\gtk.h>
  2.  
  3.  
  4. static void destroy(GtkWidget *widget, gpointer data)
  5. {
  6.     gtk_main_quit();
  7. }
  8.  
  9. static void button_clicked(GtkWidget *button, gpointer data)
  10. {
  11.     g_print("Button clicked\n");
  12. }
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16. GtkWidget *window;
  17.     GtkWidget *area;
  18.     GtkWidget *button;
  19.     GtkWidget *label;
  20.     GtkWidget *textview;
  21.     GtkTextBuffer *textbuffer;
  22.     GtkWidget *icon;
  23.  
  24.     gtk_init(&argc, &argv);
  25.    
  26.     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  27.     gtk_window_set_icon_from_file(GTK_WINDOW(window), "bu.ICO", NULL);
  28.     gtk_widget_set_size_request(window, 528, 184);
  29.     gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
  30.     gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
  31.     g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
  32.  
  33.     area = gtk_fixed_new ();
  34.     gtk_container_add(GTK_CONTAINER (window), area);
  35.  
  36.     label = gtk_label_new("Dossier source : ");
  37.     //myPangoF = "sans bold 12";
  38.     GtkStyle *style = gtk_widget_get_style(label);
  39.     pango_font_description_set_weight(style->font_desc, PANGO_WEIGHT_BOLD);
  40.     pango_font_description_set_size(style->font_desc, 20);
  41.     gtk_widget_modify_font(label, style->font_desc);
  42.     //gtk_widget_modify_font(label, pango_font_description_from_string("Monospace 12"));
  43.     gtk_fixed_put(GTK_FIXED(area), label, 8, 5);
  44.     gtk_widget_set_size_request(label, 150, 30);
  45.  
  46.     textbuffer = gtk_text_buffer_new(NULL);
  47.     gtk_text_buffer_set_text(textbuffer, "C:\\Users\\mjolly", -1);
  48.     textview = gtk_text_view_new_with_buffer(textbuffer);
  49.     gtk_fixed_put(GTK_FIXED(area), textview, 170, 12);
  50.     gtk_widget_set_size_request(textview, 180, 18);
  51.  
  52.     button = gtk_button_new();
  53.     icon = gtk_image_new_from_file("folder.ICO");
  54.     g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(button_clicked), NULL);
  55.     gtk_fixed_put(GTK_FIXED(area), button, 380, 8);
  56.     gtk_button_set_image(GTK_BUTTON(button), icon);
  57.     gtk_widget_set_size_request(textview, 30, 30);
  58.  
  59.  
  60.  
  61.     gtk_widget_show_all(window);
  62.     gtk_main();
  63.    
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement