Ejemplo n.º 1
0
static void activate (GtkApplication *app, gpointer user_data)
{
    GtkWidget *window;
    GtkWidget *grid;

    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "Minesweeper GTK");
    gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

    // Create grid
    grid = gtk_grid_new();
    gtk_grid_set_row_homogeneous((GtkGrid*)grid, TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)grid, TRUE);
    
    // and buttons for mines
    for (int x = 0; x < board->_width; x++) {
        for (int y = 0; y < board->_height; y++) {
            GtkWidget *button = gtk_button_new_with_label ("#");
            struct board_pos pos;
            pos.x = x;
            pos.y = y;

            g_signal_connect (button, "clicked", G_CALLBACK (button_callback), &pos);
            gtk_grid_attach (grid, button, x, y, 1, 1);
        }
    }

    gtk_container_add (GTK_CONTAINER (window), grid);
    gtk_widget_show_all (window);
}
Ejemplo n.º 2
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;

  GSimpleAction *about_action;

  /* Create a window with a title and a default size */
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "AboutDialog Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  /* Create a new simple action, giving it a NULL parameter type. It will 
   * always be NULL for actions invoked from a menu. (e.g clicking on an "ok" 
   * or "cancel" button)
   */
  about_action = g_simple_action_new ("about", NULL); 

  /* Connect the "activate" signal to the appropriate callback function. 
   * It will indicate that the action was just activated.
   */
  g_signal_connect (about_action, "activate", G_CALLBACK (about_cb), 
                    GTK_WINDOW (window));

  /* Adds the about_action to the overall action map. An Action map is an 
   * interface that contains a number of named GAction instances 
   * (such as about_action) 
   */
  g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action));

  gtk_widget_show_all (window);
}
Ejemplo n.º 3
0
/**
 * Gets called when the Application is started, creates the main window.
 */
void activate(GtkApplication *app, gpointer user_data)
{
	GtkWidget *window;
	
	window = gtk_application_window_new(app);
	gtk_window_set_title(GTK_WINDOW(window), "PSV Kanu EFB");
	gtk_window_set_default_size(GTK_WINDOW(window), 600, 300);
	g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(on_key_pressed), NULL);
	
	GtkWidget *box_main;
	box_main = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add(GTK_CONTAINER(window), box_main);
	
	GtkWidget *notebook_main;
	notebook_main = gtk_notebook_new();
	gtk_box_pack_start(GTK_BOX(box_main), notebook_main, TRUE, TRUE, 0);
	gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook_main), TRUE);
	gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook_main));
	
	//KALENDER
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook_main), calendar_get_instance(), gtk_label_new("Kalender"));
	gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook_main), calendar_get_instance(), TRUE);
	
	//FAHRTENBUCH
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook_main), efb_get_instance(), gtk_label_new("Fahrtenbuch"));
	gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook_main), efb_get_instance(), TRUE);
	
	gtk_widget_show_all(window);
}
Ejemplo n.º 4
0
static void 
activate(GtkApplication *app,
		gpointer user_data)
{
 GtkWidget *window;
 GtkWidget *grid;
 GtkWidget *button;

	//create new window and set title
	window = gtk_application_window_new(app);
	gtk_window_set_title(GTK_WINDOW(window), "window");
	gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);
	//construct container that is going to pack our widget
	grid = gtk_grid_new();
	//pack container in window
	gtk_container_add(GTK_CONTAINER(window), grid);
	
	button = gtk_button_new_with_label("Button1");
	g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
	//place the first button in grid cell
	gtk_grid_attach(GTK_GRID(grid), button, 0,0,1,1);

	button = gtk_button_new_with_label("Button2");
	g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
	//place second button in grid cell
	gtk_grid_attach(GTK_GRID(grid), button, 1,0,1,1);
         
	button = gtk_button_new_with_label("QUIT");
	g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy), window);
	gtk_grid_attach(GTK_GRID(grid), button,0, 1,2,1);
	
gtk_widget_show_all(window);
}
Ejemplo n.º 5
0
static void run_gui(GtkApplication *app, gpointer user_data){
  GtkWidget* box;
  GtkWidget* button;
  GtkWidget* text_view;
  GtkWidget* text_field;
  GtkWidget* window;
  //GtkWidget* button_box;

  window = gtk_application_window_new(app);
  gtk_window_set_title(GTK_WINDOW(window),"Halakahiki");
  gtk_window_set_default_size(GTK_WINDOW(window),800,600);

  button = gtk_button_new_with_label("Enter");
  text_view = gtk_text_view_new();
  //gtk_text_view_set_top_margin (GTK_Object(text_view), 400);
  gtk_text_view_set_pixels_below_lines (GTK_Object(text_view),400);
  text_field = gtk_entry_new();
  //gtk_entry_set_max_length (text_field, 1024);

  box = gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
  gtk_container_add(GTK_CONTAINER (window), box);
  gtk_container_add(GTK_CONTAINER(box), text_view);
  gtk_container_add(GTK_CONTAINER(box), text_field);
  gtk_container_add(GTK_CONTAINER(box), button);

  gtk_widget_show_all (window);
}
Ejemplo n.º 6
0
/**************************************************************** MAIN WINDOW */
static void
bmd_activate (GtkApplication *app, gpointer data)
{

	bmd_widgets *a = (bmd_widgets *) data;

	// create a window with title, default size and icons
	a->window = gtk_application_window_new (app);
	gtk_window_set_application (GTK_WINDOW (a->window), GTK_APPLICATION (app));
	gtk_window_set_position (GTK_WINDOW (a->window), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (a->window), "Book Management Demo");
	gtk_window_set_default_size (GTK_WINDOW (a->window), XSIZE, YSIZE);
	gtk_window_set_default_icon_from_file ("bmd_icon.png", NULL);
	a->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add (GTK_CONTAINER (a->window), a->box);


	/* moved the creation of the menu to a dedicated function */
	bmd_construct_menu (app, (gpointer) a);
	a->paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_box_pack_start (GTK_BOX (a->box), a->paned, TRUE, TRUE, 0);
	bmd_construct_editablecells (app, (gpointer) a);
	bmd_construct_imagedemo (app, (gpointer) a);

	gtk_widget_show_all (GTK_WIDGET (a->window));
}
Ejemplo n.º 7
0
Archivo: grid.c Proyecto: AoEiuV020/gtk
static void activate(GtkApplication * app, gpointer user_data)
{
	GtkWidget *window;
	GtkWidget *grid;
	GtkWidget *button;

	/*
	 * create a new window, and set its title 
	 */
	window = gtk_application_window_new(app);
	gtk_window_set_title(GTK_WINDOW(window), "Window");
	//gtk_window_set_default_size(GTK_WINDOW(window), width, height);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	/*
	 * Here we construct the container that is going pack our buttons 
	 */
	grid = gtk_grid_new();

	/*
	 * Pack the container in the window 
	 */
	gtk_container_add(GTK_CONTAINER(window), grid);

	button = gtk_button_new_with_label("Button 1");
	g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);

	/*
	 * Place the first button in the grid cell (0, 0), and make it fill just 1 
	 * cell horizontally and vertically (ie no spanning) 
	 */
	gtk_grid_attach(GTK_GRID(grid), button, 0, 0, 1, 1);

	button = gtk_button_new_with_label("Button 2");
	g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);

	/*
	 * Place the second button in the grid cell (1, 0), and make it fill just
	 * 1 cell horizontally and vertically (ie no spanning) 
	 */
	gtk_grid_attach(GTK_GRID(grid), button, 1, 0, 1, 1);

	button = gtk_button_new_with_label("Quit");
	g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy), window);

	/*
	 * Place the Quit button in the grid cell (0, 1), and make it span 2
	 * columns. 
	 */
	gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);

	/*
	 * Now that we are done packing our widgets, we show them all in one go,
	 * by calling gtk_widget_show_all() on the window. This call recursively
	 * calls gtk_widget_show() on all widgets that are contained in the
	 * window, directly or indirectly. 
	 */
	gtk_widget_show_all(window);

}
Ejemplo n.º 8
0
static void
activate (GtkApplication* app,
          gpointer        user_data)
{
  GtkWidget *window;

  /*
   * gtk_application_window_new() 함수는 GtkWindow 객체를 생성한다.
   * GtkWindow 객체는 운영체제별로 다른 프레임, 제목표시줄, 창 제어버튼은 갖는다.
   */
  window = gtk_application_window_new (app);

  /*
   * gtk_window_set_title() 함수는 GtkWindow 객체에 제목을 설정한다.
   * GTK_WINDOW() 함수는 해당 포인터 인자가 GtkWindow 인스턴스이면 그 포인터를 내어놓고,
   * 그렇지 않으면 경고 메시지를 내어준다.
   */
  gtk_window_set_title (GTK_WINDOW (window), "이것은 제목입니다.");

  // gtk_window_set_default_size() 함수는 GtkWindow 객체의 창 크기를 설정한다.
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);

  // gtk_widget_show_all() 함수는 GtkWindow 객체를 화면에 표시한다.
  gtk_widget_show_all (window);
}
Ejemplo n.º 9
0
static void
activate (GApplication *app)
{
  GtkBuilder *builder;
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *contents;
  GtkWidget *status;
  GtkWidget *message;
  GtkWidget *button;
  GtkWidget *infobar;
  GtkWidget *menutool;
  GMenuModel *toolmenu;
  GtkTextBuffer *buffer;

  window = gtk_application_window_new (GTK_APPLICATION (app));
  gtk_window_set_title (GTK_WINDOW (window), "Application Class");
  gtk_window_set_icon_name (GTK_WINDOW (window), "document-open");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  g_action_map_add_action_entries (G_ACTION_MAP (window),
                                   win_entries, G_N_ELEMENTS (win_entries),
                                   window);

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/application/application.ui", NULL);

  grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
  contents = (GtkWidget *)gtk_builder_get_object (builder, "contents");
  status = (GtkWidget *)gtk_builder_get_object (builder, "status");
  message = (GtkWidget *)gtk_builder_get_object (builder, "message");
  button = (GtkWidget *)gtk_builder_get_object (builder, "button");
  infobar = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
  menutool = (GtkWidget *)gtk_builder_get_object (builder, "menutool");
  toolmenu = (GMenuModel *)gtk_builder_get_object (builder, "toolmenu");

  g_object_set_data (G_OBJECT (window), "message", message);
  g_object_set_data (G_OBJECT (window), "infobar", infobar);

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menutool),
                                 gtk_menu_new_from_model (toolmenu));

  gtk_widget_grab_focus (contents);
  g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), infobar);

  /* Show text widget info in the statusbar */
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
  g_signal_connect_object (buffer, "changed",
                           G_CALLBACK (update_statusbar), status, 0);
  g_signal_connect_object (buffer, "mark-set",
                           G_CALLBACK (mark_set_callback), status, 0);

  update_statusbar (buffer, GTK_STATUSBAR (status));

  gtk_widget_show_all (window);

  g_object_unref (builder);
}
Ejemplo n.º 10
0
static void activate (GtkApplication* app, gpointer user_data) {
  GtkWidget *window;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "RChat");
  gtk_window_set_default_size (GTK_WINDOW (window), 500, 400);
  gtk_widget_show_all (window);
}
Ejemplo n.º 11
0
static void activate(GtkApplication *app, gpointer user_data) {

  GtkWidget *window;
  GtkWidget *grid;

  GtkWidget *toolbar;
  GtkToolItem *tool_item;

  GtkWidget *notes;


  int position = 0; // toolbar position

  // Create a window with a title, default size, and set border width
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW(window), "GUI: notebook");
  gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_container_set_border_width (GTK_CONTAINER(window), 10);  

  // ------------- TOOLBAR ----------------
  // Create a basic toolbar
  toolbar = gtk_toolbar_new();
  gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);

  tool_item = gtk_tool_button_new_from_stock (GTK_STOCK_REFRESH);

  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, position ++);

  tool_item = gtk_separator_tool_item_new();
  gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(tool_item), FALSE);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, position ++);

  tool_item = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
  // connect application quit callback here
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, position ++);


  // ------------- NOTEPAD -----------------

  notes = gtk_notebook_new();

  gtk_notebook_append_page(GTK_NOTEBOOK(notes), 
			   create_notepage_fileselect(), 
			   gtk_label_new("Config"));

  // Create a full-window grid to contain toolbar and the notebook
  grid = gtk_grid_new();
  gtk_grid_attach (GTK_GRID(grid), toolbar, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID(grid), notes, 0, 1, 1, 1);

  gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(grid));


  gtk_widget_show_all (window);
}
Ejemplo n.º 12
0
void activate (GtkApplication *app, gpointer user_data)
{
	GtkWidget *window;
	GtkWidget *frame;
// 	struct itimerval timerv, timero;
	
	window = gtk_application_window_new (app);
	gtk_window_set_title (GTK_WINDOW (window), "Play Coding");
	
	g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
	g_signal_connect (window, "key_press_event", G_CALLBACK (on_key_press), NULL);
	
	gtk_container_set_border_width (GTK_CONTAINER (window), 4);
	
	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (window), frame);
	
	pDraw = gtk_drawing_area_new ();
	/* set a minimum size */
	gtk_widget_set_size_request (pDraw, 800, 600);
	
	gtk_container_add (GTK_CONTAINER (frame), pDraw);
	
	/* Signals used to handle the backing surface */
	g_signal_connect (pDraw, "draw",
	                  G_CALLBACK (draw_cb), NULL);
	g_signal_connect (pDraw,"configure-event",
	                  G_CALLBACK (configure_event_cb), NULL);
	
	/* Event signals */
	g_signal_connect (pDraw, "motion-notify-event",
	                  G_CALLBACK (motion_notify_event_cb), NULL);
	g_signal_connect (pDraw, "button-press-event",
	                  G_CALLBACK (button_press_event_cb), NULL);  
	
	/* Ask to receive events the drawing area doesn't normally
	 * subscribe to. In particular, we need to ask for the
	 * button press and motion notify events that want to handle.
	 */
	
	gtk_widget_set_events (pDraw, gtk_widget_get_events (pDraw)
	                                   | GDK_BUTTON_PRESS_MASK
	                                   | GDK_POINTER_MOTION_MASK);
/*
	signal(SIGALRM, sigroutine);
	timerv.it_value.tv_sec = 0;
	timerv.it_value.tv_usec = 40000;
	timerv.it_interval.tv_sec = 0;
	timerv.it_interval.tv_usec = 40000;
	setitimer(ITIMER_REAL, &timerv, &timero);
*/
	timer = g_timeout_add (40, sigroutine, pDraw);
	
	gtk_widget_show_all (window);
}
Ejemplo n.º 13
0
static void
activate (GApplication *app,
          gpointer      user_data)
{
    GtkWidget *win;
    GtkWidget *button;
    GSimpleActionGroup *doc_actions;
    GtkBuilder *builder;
    GMenuModel *doc_menu;
    GMenuModel *win_menu;
    GMenu *button_menu;
    GMenuItem *section;

    if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
        return;

    win = gtk_application_window_new (GTK_APPLICATION (app));

    doc_actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);

    g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries,
                                     G_N_ELEMENTS (win_entries), win);

    builder = gtk_builder_new ();
    gtk_builder_add_from_string (builder, menu_ui, -1, NULL);

    doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
    win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));

    button_menu = g_menu_new ();

    section = g_menu_item_new_section (NULL, doc_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    section = g_menu_item_new_section (NULL, win_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "win");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    button = gtk_menu_button_new ();
    gtk_button_set_label (GTK_BUTTON (button), "Menu");
    gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));

    gtk_container_add (GTK_CONTAINER (win), button);
    gtk_container_set_border_width (GTK_CONTAINER (win), 12);
    gtk_widget_show_all (win);

    g_object_unref (button_menu);
    g_object_unref (doc_actions);
    g_object_unref (builder);
}
Ejemplo n.º 14
0
 virtual attached_t create_detached(GtkApplication* application) const {
     attached_t detached = 0;
     if ((application)) {
         GNOMA_LOG_MESSAGE_DEBUG("gtk_application_window_new(application = " << gpointer_to_string(application) << ")...");
         if ((detached = gtk_application_window_new(application))) {
             GNOMA_LOG_MESSAGE_DEBUG("..." << gpointer_to_string(detached) << " = gtk_application_window_new(application = " << gpointer_to_string(application) << ")");
         } else {
             GNOMA_LOG_ERROR("failed on gtk_application_window_new(application = " << gpointer_to_string(application) << ")");
         }
     }
     return detached;
 }
Ejemplo n.º 15
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  /* Declare variables */
  GtkWidget *window;
  GtkWidget *label;
  GtkWidget *grid;
  GtkWidget *spin_button;
  GtkAdjustment *adjustment;


  /* Create a window with a title, a border width, and a default size */
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "SpinButton Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 210, 70);
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);

  /* Create a label to be shown in the window */
  label = gtk_label_new ("Choose a number");

  /* Create an adjustment representing an adjustable bounded value */
  adjustment = gtk_adjustment_new (0, 0, 100, 1, 0, 0);


  /* Create a spin button that is to be as wide as possible */
  spin_button = gtk_spin_button_new (adjustment, 1, 0);
  gtk_widget_set_hexpand (spin_button, TRUE);
  
  /* Connecting the "value-changed" signal for the spinbutton 
   * to the appropriate callback function. 
   */
  g_signal_connect (spin_button, 
                    "value-changed", 
                    G_CALLBACK (spin_clicked), 
                    label);


  /* Create a grid and arrange everything accordingly */
  grid = gtk_grid_new ();
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
  gtk_grid_attach (GTK_GRID (grid), spin_button, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
  

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_widget_show_all (window);
}
Ejemplo n.º 16
0
static void activate (GtkApplication *app, gpointer user_data) {
    GtkWidget *window;
    GtkWidget *image;
    
    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");
    gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
    
    image = gtk_image_new_from_file ("gnome-image.png");
    
    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (image));
    
    gtk_widget_show_all (GTK_WIDGET (window));
}
Ejemplo n.º 17
0
static void activate(GtkApplication *app)
{
  GtkWidget *window;
  GtkWidget *button;

  window = gtk_application_window_new(app);
  button = gtk_button_new_with_label("Hello World");

  g_signal_connect_swapped(button, "clicked",
			   G_CALLBACK(gtk_widget_destroy), window);
  gtk_container_add(GTK_CONTAINER(window), button);

  gtk_widget_show_all(window);
}
Ejemplo n.º 18
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
    GtkWidget *window;
    GtkWidget *frame;
    GtkWidget *drawing_area;
    GtkWidget *chooser_button;

    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");

    g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);

    gtk_container_set_border_width (GTK_CONTAINER (window), 8);

    frame = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
    gtk_container_add (GTK_CONTAINER (window), frame);

    chooser_button = gtk_file_chooser_button_new("Select problem...", GTK_FILE_CHOOSER_ACTION_OPEN);

    drawing_area = gtk_drawing_area_new ();
    /* set a minimum size */
    gtk_widget_set_size_request (drawing_area, 800, 800);

    gtk_paned_add1(GTK_PANED(frame), drawing_area);
    gtk_paned_add2(GTK_PANED(frame), chooser_button);

    /* Signals used to handle the backing surface */
    g_signal_connect (drawing_area, "draw",
                      G_CALLBACK (draw_cb), NULL);
    g_signal_connect (drawing_area,"configure-event",
                      G_CALLBACK (configure_event_cb), NULL);
    g_signal_connect(drawing_area, "button_press_event",
                      G_CALLBACK(button_press_event_cb), NULL);
    g_signal_connect(chooser_button, "file-set",
                         G_CALLBACK(set_file), chooser_button);

    /* Ask to receive events the drawing area doesn't normally
     * subscribe to. In particular, we need to ask for the
     * button press and motion notify events that want to handle.
     */
    gtk_widget_set_events (drawing_area, gtk_widget_get_events (drawing_area)
                                         | GDK_BUTTON_PRESS_MASK
                                         | GDK_POINTER_MOTION_MASK);

    gtk_widget_show_all (window);
}
Ejemplo n.º 19
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *frame;
  GtkWidget *drawing_area;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");

  g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (window), frame);

  drawing_area = gtk_drawing_area_new ();
  /* set a minimum size */
  gtk_widget_set_size_request (drawing_area, 100, 100);

  gtk_container_add (GTK_CONTAINER (frame), drawing_area);

  /* Signals used to handle the backing surface */
  g_signal_connect (drawing_area, "draw",
                    G_CALLBACK (draw_cb), NULL);
  g_signal_connect (drawing_area,"configure-event",
                    G_CALLBACK (configure_event_cb), NULL);

  /* Event signals */
  g_signal_connect (drawing_area, "motion-notify-event",
                    G_CALLBACK (motion_notify_event_cb), NULL);
  g_signal_connect (drawing_area, "button-press-event",
                    G_CALLBACK (button_press_event_cb), NULL);

  /* Ask to receive events the drawing area doesn't normally
   * subscribe to. In particular, we need to ask for the
   * button press and motion notify events that want to handle.
   */
  gtk_widget_set_events (drawing_area, gtk_widget_get_events (drawing_area)
                                     | GDK_BUTTON_PRESS_MASK
                                     | GDK_POINTER_MOTION_MASK);

  gtk_widget_show_all (window);
}
Ejemplo n.º 20
0
void
ManageDB_sidebar(GtkApplication *application){
    GtkWidget *sidebar;
    GtkWidget *stack;
    GtkWidget *box;
    GtkWidget *widget;
    GtkWidget *header;
    
    windowdb = gtk_application_window_new (application);
    
    header = gtk_header_bar_new ();
    gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(header), TRUE);
    gtk_window_set_titlebar (GTK_WINDOW(windowdb), header);
    gtk_window_set_title(GTK_WINDOW(windowdb), "Gerenciamento do Banco de Dados");
    
    gtk_window_set_default_size (GTK_WINDOW (windowdb), 500, 500);
    
    g_signal_connect (windowdb, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &windowdb);
    
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    sidebar = gtk_stack_sidebar_new ();
    gtk_box_pack_start (GTK_BOX (box), sidebar, FALSE, FALSE, 0);

    stack = gtk_stack_new ();
    gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
    gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), GTK_STACK (stack));

    /* Separator between sidebar and stack */
    widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
    gtk_box_pack_start (GTK_BOX(box), widget, FALSE, FALSE, 0);

    gtk_box_pack_start (GTK_BOX (box), stack, TRUE, TRUE, 0);
    
    
    /* Precisamos adicionar as ações... */
    Welcome_side(widget, stack);
    Create_side(widget, stack);
    Backup_side(widget, stack);
    Restore_side(widget, stack);
    Delete_side(widget, stack);
    Advanced_side(widget, stack);
    
    gtk_container_add (GTK_CONTAINER (windowdb), box);
    
    gtk_widget_show_all (windowdb);
}
Ejemplo n.º 21
0
static GtkWidget *
nimf_settings_build_main_window (NimfSettings *nsettings)
{
  GtkWidget  *window;
  GtkWidget  *notebook;
  GList      *schema_list = NULL;
  gchar     **non_relocatable;
  gint        i;

  window = gtk_application_window_new (nsettings->app);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
  gtk_window_set_title        (GTK_WINDOW (window), _("Nimf Settings"));
  gtk_window_set_icon_name    (GTK_WINDOW (window), "nimf");

  notebook = gtk_notebook_new ();
  gtk_notebook_set_tab_pos    (GTK_NOTEBOOK (notebook), GTK_POS_LEFT);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
  gtk_container_add (GTK_CONTAINER (window), notebook);

  g_settings_schema_source_list_schemas (nsettings->schema_source, TRUE,
                                         &non_relocatable, NULL);

  for (i = 0; non_relocatable[i] != NULL; i++)
    if (g_str_has_prefix (non_relocatable[i], "org.nimf"))
      schema_list = g_list_prepend (schema_list, non_relocatable[i]);

  for (schema_list = g_list_sort (schema_list, (GCompareFunc) on_comparison);
       schema_list != NULL;
       schema_list = schema_list->next)
  {
    NimfSettingsPage  *page;
    GtkWidget         *scrolled_w;

    scrolled_w = gtk_scrolled_window_new (NULL, NULL);
    page = nimf_settings_page_new (nsettings,
                                   (const gchar *) schema_list->data);
    gtk_container_add (GTK_CONTAINER (scrolled_w), page->box);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_w, page->label);
    g_ptr_array_add (nsettings->pages, page);
  }

  g_strfreev (non_relocatable);
  g_list_free (schema_list);

  return window;
}
Ejemplo n.º 22
0
void activate(GtkApplication *app, gpointer) {

    GtkWidget *window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "GTK+ App");
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);

    GtkWidget *button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    gtk_container_add(GTK_CONTAINER(window), button_box);

    GtkWidget *button = gtk_button_new_with_label("Hello, World!!");
    g_signal_connect(button, "clicked", G_CALLBACK(helloworld), NULL);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy), window);
    gtk_container_add(GTK_CONTAINER(button_box), button);

    gtk_widget_show_all(window);

}
Ejemplo n.º 23
0
///////////////////////////////////////////////////////////////////////////////
// Creation de la fenetre et de son contenu
///////////////////////////////////////////////////////////////////////////////
static void startApplication(GtkApplication *app,gpointer data) {
  GtkWidget *window=gtk_application_window_new(app);
  gtk_window_set_title(GTK_WINDOW(window),"Application GTK+3 v2");
  gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window),400,100);

  gtk_container_set_border_width(GTK_CONTAINER(window),10);

  GtkWidget *grid=gtk_grid_new();
  gtk_container_add(GTK_CONTAINER(window),grid);
  gtk_grid_set_row_spacing(GTK_GRID(grid),2);
  gtk_grid_set_column_spacing(GTK_GRID(grid),5);
  gtk_widget_set_valign(grid,GTK_ALIGN_CENTER);
  gtk_widget_set_halign(grid,GTK_ALIGN_CENTER);

  int col=0,row=0;
  GtkWidget *label_user=gtk_label_new("UserName");
  gtk_grid_attach(GTK_GRID(grid),label_user,col,row,1,1);
  col++;
  GtkWidget *entry_user=gtk_entry_new();
  gtk_entry_set_placeholder_text(GTK_ENTRY(entry_user),"UserName");
  //gtk_entry_set_width_chars(GTK_ENTRY(entry_user),25);
  gtk_grid_attach(GTK_GRID(grid),entry_user,col,row,1,1);
  col=0;row++;
  GtkWidget *label_pass=gtk_label_new("Password");
  gtk_grid_attach(GTK_GRID(grid),label_pass,col,row,1,1);
  col++;
  GtkWidget *entry_pass=gtk_entry_new();
  gtk_entry_set_placeholder_text(GTK_ENTRY(entry_pass),"Password");
  //gtk_entry_set_max_length(GTK_ENTRY(entry_pass),8);
  gtk_entry_set_visibility(GTK_ENTRY(entry_pass),FALSE);
  //gtk_entry_set_invisible_char(GTK_ENTRY(entry_pass),42);
  //gtk_entry_set_input_purpose(GTK_ENTRY(entry_pass),
                              //GTK_INPUT_PURPOSE_PASSWORD);
  gtk_grid_attach(GTK_GRID(grid),entry_pass,col,row,1,1);
  col=0;row++;
  GtkWidget *btn=gtk_button_new_with_label("Authentication");
  //gtk_widget_set_hexpand(btn,FALSE);
  //gtk_widget_set_vexpand(btn,FALSE);
  //gtk_widget_set_halign(btn,GTK_ALIGN_CENTER);
  //gtk_widget_set_valign(btn,GTK_ALIGN_CENTER);
  //gtk_widget_set_size_request(btn,220,50);
  gtk_grid_attach(GTK_GRID(grid),btn,col,row,2,1);

  gtk_widget_show_all(window);
}
Ejemplo n.º 24
0
static void activate(GtkApplication* app, 
                     gpointer        user_data)
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *button_rs;
    GtkWidget *button_box;
    GtkWidget *draw_area;
    GtkWidget *fixed_container;

    window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "Five Son Chess");
    gtk_window_set_default_size(GTK_WINDOW(window), 900, 900);
    gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
   
    fixed_container = gtk_fixed_new();
    
    // Draw Area
    draw_area = gtk_drawing_area_new();
    gtk_widget_set_size_request(draw_area, CanvasWidth, CanvasWidth);
    g_signal_connect(draw_area, "draw", G_CALLBACK(draw_cb), NULL);
    g_signal_connect(draw_area, "configure-event", G_CALLBACK(configure_event_cb), NULL);
    gtk_widget_add_events(draw_area, GDK_BUTTON_PRESS_MASK);

    g_signal_connect(draw_area, "button_press_event", G_CALLBACK(PutPiece), draw_area);
    
    gtk_fixed_put(GTK_FIXED(fixed_container), draw_area, 0, 0);

    // Buttons
    button_box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
    gtk_fixed_put(GTK_FIXED(fixed_container), button_box, CanvasWidth, 0);


    button = gtk_button_new_with_label("从头再来");
    g_signal_connect(button, "clicked", G_CALLBACK(init_cb), draw_area);
    button_rs = gtk_button_new_with_label("随机开局");
    g_signal_connect(button_rs, "clicked", G_CALLBACK(init_rs_cb), draw_area);
    gtk_container_add(GTK_CONTAINER(button_box), button);
    gtk_container_add(GTK_CONTAINER(button_box), button_rs);
    gtk_container_add(GTK_CONTAINER(window), fixed_container);

    gtk_widget_show_all(window);

    // Game starts here!
    InitializeGame();
}
Ejemplo n.º 25
0
static void activate (GtkApplication *app, gpointer user_app) {
    GtkWidget *window;
    GtkWidget *progress_bar;
    gdouble fraction = 0.0;
    
    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "ProgressBar Example");
    gtk_window_set_default_size (GTK_WINDOW (window), 220, 20);
    
    progress_bar = gtk_progress_bar_new ();
    gtk_container_add (GTK_CONTAINER (window), progress_bar);

    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), fraction);
    g_timeout_add (500, fill, GTK_PROGRESS_BAR (progress_bar));

    gtk_widget_show_all (window);
}
Ejemplo n.º 26
0
static void activate (GtkApplication *app, gpointer user_data) {
  GtkWidget *window;
  GtkWidget *button;
  GtkWidget *button_box;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "MainWindow");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_container_add (GTK_CONTAINER (window), button_box);

  button = gtk_button_new_with_label ("Hello World");
  g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
  gtk_container_add (GTK_CONTAINER (button_box), button);

  gtk_widget_show_all (window);
}
Ejemplo n.º 27
0
// app activate callback - creates the window
static void
activate (GtkApplication* app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *label_name;
  GtkWidget *clr_button, *ok_button;

  // create the window and set a title
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Welcome");

  // create a grid to be used as layout container
  grid = gtk_grid_new();
  gtk_container_add (GTK_CONTAINER (window), grid);

  // output label
  label_output = gtk_label_new ("Hello?");
  gtk_grid_attach(GTK_GRID(grid), label_output, 0,0,2,1);

  // name label
  label_name = gtk_label_new ("Name:");
  gtk_grid_attach(GTK_GRID(grid), label_name, 0,1,1,1);

  // text entry
  input_entry = gtk_entry_new();
  gtk_grid_attach(GTK_GRID(grid), input_entry, 1,1,1,1);

  // CLEAR button
  clr_button = gtk_button_new_with_mnemonic("_Clear");
  gtk_grid_attach(GTK_GRID(grid), clr_button, 0,2,1,1);
  // connect a signal when the button is clicked -> invoke clr_clicked() callback
  g_signal_connect(clr_button, "clicked", G_CALLBACK(clr_clicked), NULL);

  // OKAY button
  ok_button = gtk_button_new_with_mnemonic("_Okay");
  gtk_grid_attach(GTK_GRID(grid), ok_button, 1,2,1,1);
  // connect a signal when the button is clicked -> invoke cok_clicked() callback
  g_signal_connect(ok_button, "clicked", G_CALLBACK(ok_clicked), NULL);

  gtk_widget_show_all (window);
}
Ejemplo n.º 28
0
static void
pragha_application_construct_window (PraghaApplication *pragha)
{
	gchar *icon_uri = NULL;

	/* Main window */

	pragha->mainwindow = gtk_application_window_new (GTK_APPLICATION (pragha));

	icon_uri = g_build_filename (PIXMAPDIR, "pragha.png", NULL);
	pragha->pixbuf_app = gdk_pixbuf_new_from_file (icon_uri, NULL);
	g_free (icon_uri);

	if (!pragha->pixbuf_app)
		g_warning("Unable to load pragha png");
	else
		gtk_window_set_icon (GTK_WINDOW(pragha->mainwindow),
		                     pragha->pixbuf_app);
	
	gtk_window_set_title(GTK_WINDOW(pragha->mainwindow), _("Pragha Music Player"));

	/* Get all widgets instances */

	pragha->menu_ui_manager = pragha_menubar_new ();
	pragha->toolbar = pragha_toolbar_new ();
	pragha->infobox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	pragha->pane1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	pragha->pane2 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	pragha->sidebar1 = pragha_sidebar_new ();
	pragha->sidebar2 = pragha_sidebar_new ();
	pragha->library = pragha_library_pane_new ();
	pragha->playlist = pragha_playlist_new ();
	pragha->statusbar = pragha_statusbar_get ();
	pragha->scanner = pragha_scanner_new();

	pragha->status_icon = pragha_status_icon_new (pragha);

	pragha_menubar_connect_signals (pragha->menu_ui_manager, pragha);

	/* Contruct the window. */

	pragha_window_new (pragha);
}
Ejemplo n.º 29
0
static void
new_window (GApplication *app,
            GFile        *file)
{
  GtkWidget *window, *grid, *scrolled, *view;

  window = gtk_application_window_new (GTK_APPLICATION (app));
  gtk_window_set_default_size ((GtkWindow*)window, 640, 480);
  g_action_map_add_action_entries (G_ACTION_MAP (window), win_entries, G_N_ELEMENTS (win_entries), window);
  gtk_window_set_title (GTK_WINDOW (window), "Plugman");

  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_hexpand (scrolled, TRUE);
  gtk_widget_set_vexpand (scrolled, TRUE);
  view = gtk_text_view_new ();

  g_object_set_data ((GObject*)window, "plugman-text", view);

  gtk_container_add (GTK_CONTAINER (scrolled), view);

  gtk_grid_attach (GTK_GRID (grid), scrolled, 0, 0, 1, 1);

  if (file != NULL)
    {
      gchar *contents;
      gsize length;

      if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
        {
          GtkTextBuffer *buffer;

          buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
          gtk_text_buffer_set_text (buffer, contents, length);
          g_free (contents);
        }
    }

  gtk_widget_show_all (GTK_WIDGET (window));
}
Ejemplo n.º 30
0
static void button_activate(GtkApplication* app, gpointer user_data)
{
	GtkWidget* window;
	GtkWidget* entry;

	window=gtk_application_window_new(app);
	gtk_window_set_title(GTK_WINDOW(window),"Gsistant");
	gtk_window_set_default_size(GTK_WINDOW(window),200,100);

	//entry_box=gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
	//gtk_container_add(GTK_CONTAINER(window),button_box);

	//button=gtk_button_new_with_label("Hello World");
	entry=gtk_entry_new();
	g_signal_connect(entry,"activate",G_CALLBACK(aloha),entry);
	//g_signal_connect(button,"clicked",G_CALLBACK(print_hello),NULL);
	//g_signal_connect_swapped(button,"clicked",G_CALLBACK(gtk_widget_destroy),window);
	gtk_container_add(GTK_CONTAINER(window),entry);

	gtk_widget_show_all(window);
}