예제 #1
0
/**
 *  return a new GtkBuilder initiate with a file
 *
 * \param gchar         short name of UI file
 *
 * \return GtkBuilder    new GtkBuildeR
 * */
GtkBuilder *utils_gtk_builder_new_from_file ( const gchar *ui_name )
{
    GtkBuilder *builder;
    gchar *filename;

    /* obtention du nom long du fichier UI */
    filename = utils_gtkbuilder_get_full_path ( ui_name );
    if ( !g_file_test ( filename, G_FILE_TEST_EXISTS ) )
    {
        gchar* tmpstr;

        tmpstr = g_strdup_printf ( _("Cannot open file '%s': %s"),
                        filename,
                        _("File does not exist") );
        dialogue_error ( tmpstr );
        g_free ( tmpstr );
        g_free ( filename );

        return NULL;
    }

    builder = gtk_builder_new_from_file ( filename );

    g_free ( filename );

    return builder;
}
예제 #2
0
GtkWidget *
liferea_dialog_new (const gchar *name) 
{
	LifereaDialog	*ld;
	gchar 		*path;
	GError          *error = NULL;

	ld = LIFEREA_DIALOG (g_object_new (LIFEREA_DIALOG_TYPE, NULL));
	path = g_strdup_printf ("%s%s.ui", PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S, name);
	ld->priv->xml = gtk_builder_new_from_file (path);
	g_free (path);

	g_return_val_if_fail (ld->priv->xml != NULL, NULL);

	ld->priv->dialog = GTK_WIDGET (gtk_builder_get_object (ld->priv->xml, name));
	gtk_window_set_transient_for (GTK_WINDOW (ld->priv->dialog), GTK_WINDOW (liferea_shell_get_window()));
	gtk_builder_connect_signals (ld->priv->xml, NULL);
	g_return_val_if_fail (ld->priv->dialog != NULL, NULL);

	g_object_set_data (G_OBJECT (ld->priv->dialog), "LifereaDialog", ld);

	g_signal_connect_object (ld->priv->dialog, "destroy", G_CALLBACK (liferea_dialog_destroy_cb), ld, 0);

	return ld->priv->dialog;
}
예제 #3
0
void
mom_plugin_init (const char *arg, int *pargc, char ***pargv)
{
  MOM_INFORMPRINTF ("start of " __FILE__ " build %s arg=%s (argc=%d)",
		    __DATE__ "@" __TIME__, arg, *pargc);
  g_mem_gc_friendly = true;	/* from <glib/gmem.h> */
  gtk_init (pargc, pargv);
  GtkBuilder *builder = gtk_builder_new_from_file (GTKUIFILE_MOM);
  g_object_unref (builder);
}
예제 #4
0
static void
liferea_shell_init (LifereaShell *ls)
{
	/* globally accessible singleton */
	g_assert (NULL == shell);
	shell = ls;	
	shell->priv = LIFEREA_SHELL_GET_PRIVATE (ls);
	shell->priv->xml = gtk_builder_new_from_file (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "mainwindow.ui");
	if (!shell->priv->xml)
		g_error ("Loading " PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "mainwindow.ui failed");

	gtk_builder_connect_signals (shell->priv->xml, NULL);
}
예제 #5
0
파일: main.c 프로젝트: orodley/chessboard
void set_up_gui()
{
	GtkBuilder *builder = gtk_builder_new_from_file("chessboard.ui");

	GObject *window = gtk_builder_get_object(builder, "main_window");
	g_signal_connect(window, "destroy",
			G_CALLBACK(gtk_main_quit), NULL);

	GObject *open_pgn_item = gtk_builder_get_object(builder, "open_pgn_menu_item");
	g_signal_connect(open_pgn_item, "activate",
			G_CALLBACK(open_pgn_callback), window);

	GObject *flip_button = gtk_builder_get_object(builder, "flip_board_button");
	g_signal_connect(flip_button, "clicked",
			G_CALLBACK(flip_button_click_callback), NULL);

	GObject *go_end_button = gtk_builder_get_object(builder, "go_end_button");
	g_signal_connect(go_end_button, "clicked",
			G_CALLBACK(go_end_button_click_callback), NULL);

	go_next_button = GTK_WIDGET(gtk_builder_get_object(builder, "go_next_button"));
	g_signal_connect(G_OBJECT(go_next_button), "clicked",
			G_CALLBACK(go_next_button_click_callback), NULL);

	go_back_button = GTK_WIDGET(gtk_builder_get_object(builder, "go_back_button"));
	g_signal_connect(G_OBJECT(go_back_button), "clicked",
			G_CALLBACK(go_back_button_click_callback), NULL);

	GObject *go_start_button = gtk_builder_get_object(builder, "go_start_button");
	g_signal_connect(go_start_button, "clicked",
			G_CALLBACK(go_start_button_click_callback), NULL);

	board_display = GTK_WIDGET(gtk_builder_get_object(builder, "board_drawing_area"));
	gtk_widget_add_events(board_display,
			GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
			GDK_POINTER_MOTION_MASK);
	g_signal_connect(G_OBJECT(board_display), "draw",
			G_CALLBACK(board_draw_callback), NULL);
	g_signal_connect(G_OBJECT(board_display), "button-press-event",
			G_CALLBACK(board_mouse_down_callback), NULL);
	g_signal_connect(G_OBJECT(board_display), "button-release-event",
			G_CALLBACK(board_mouse_up_callback), NULL);
	g_signal_connect(G_OBJECT(board_display), "motion-notify-event",
			G_CALLBACK(board_mouse_move_callback), NULL);

	gtk_widget_show_all(GTK_WIDGET(window));

	// If we loaded a PGN file, we need to enable the forward button
	set_button_sensitivity();
}
예제 #6
0
파일: gui.cpp 프로젝트: achellko/PIO_frakt
static void activate(GtkApplication *app, gpointer user_data)
{
	GUI* gptr = (GUI*) user_data;
	Window* w = gptr->get_window();

	w->builder = gtk_builder_new_from_file ("builder.ui");
	w->save_button = GTK_WIDGET(gtk_builder_get_object(w->builder, "button_save"));
	w->window = GTK_WIDGET(gtk_builder_get_object(w->builder, "window"));
	w->drawing_area_fract = GTK_WIDGET(gtk_builder_get_object(w->builder, "drawingarea_fract"));
	w->left_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry1"));
	w->right_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry2"));
	w->up_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry3"));
	w->down_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry4"));
	w->width_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry5"));
	w->height_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry6"));
	w->render_button = GTK_WIDGET(gtk_builder_get_object(w->builder, "button_render"));
	w->combobox = GTK_WIDGET(gtk_builder_get_object(w->builder, "combobox"));

	gtk_entry_set_text((GtkEntry*)w->left_entry, "-1.0");
	gtk_entry_set_text((GtkEntry*)w->right_entry, "1.0");
	gtk_entry_set_text((GtkEntry*)w->up_entry, "1.0");
	gtk_entry_set_text((GtkEntry*)w->down_entry, "-1.0");
	gtk_entry_set_text((GtkEntry*)w->width_entry, "800");
	gtk_entry_set_text((GtkEntry*)w->height_entry, "600");


	for(int i = 0; i < gptr->get_rs_count(); ++i) {
		gtk_combo_box_text_append_text (
				(GtkComboBoxText*)w->combobox,
			   	gptr->get_rs()[i].get_id().c_str());
	}
	gtk_combo_box_set_active((GtkComboBox*)w->combobox, 0);

	gdk_window_set_events(
			gtk_widget_get_window(w->drawing_area_fract),
			GDK_ALL_EVENTS_MASK);

	g_signal_connect (w->drawing_area_fract, "draw", G_CALLBACK(draw_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "size-allocate", G_CALLBACK(da_allocate_callback), gptr);
	g_signal_connect (w->render_button, "clicked", G_CALLBACK(parse_args_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "button-press-event", G_CALLBACK(button_press_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "button-release-event", G_CALLBACK(button_release_callback), gptr);
	g_signal_connect (w->save_button, "clicked", G_CALLBACK (save_file), gptr);

	gptr->render();
	gtk_application_add_window(app, GTK_WINDOW(w->window));
}
예제 #7
0
파일: desktop.c 프로젝트: bitptr/argonaut
/*
 * A desktop file manager. This opens files and directories the same way that
 * argonaut(1) does.
 */
int
main(int argc, char *argv[])
{
	GtkBuilder	*builder;
	GtkWidget	*root, *icons;
        struct state	*d;
	char		*dir;

	if ((dir = get_dir()) == NULL)
		err(1, "get_dir");

	if ((d = state_new(BINDIR"/argonaut")) == NULL)
		err(1, "could not build the callback data");

	if (state_add_dir(d, dir) < 0)
		err(1, "state_add_dir");

	gtk_init(&argc, &argv);

	builder = gtk_builder_new_from_file(INTERFACE_PATH);
	icons = GTK_WIDGET(gtk_builder_get_object(builder, "desktop-icons"));
	d->icon_view = GTK_ICON_VIEW(icons);

	root = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_name(root, "argonaut-desktop");

	set_window_geometry(GTK_WINDOW(root), GTK_WIDGET(icons));
	desktopize(root);
	skip_pager(root);
	populate_model(dir, d->icon_view);
	set_up_icon_view(icons, d);

	gtk_container_add(GTK_CONTAINER(root), icons);

	gtk_widget_show(icons);
	gtk_widget_show(root);

	gtk_main();

	state_free(d);
	free(dir);
	return 0;
}
예제 #8
0
/* Initialize a popup window.
 * The struct is supposed to be empty at this point.
 */
static void
popup_window_init(PopupWindow *window, Audio *audio)
{
	gchar *uifile;
	GtkBuilder *builder;

	/* Build UI file depending on slider orientation */
	gchar *orientation;
	orientation = prefs_get_string("SliderOrientation", "vertical");
	if (!g_strcmp0(orientation, "horizontal"))
		uifile = get_ui_file(POPUP_WINDOW_HORIZONTAL_UI_FILE);
	else
		uifile = get_ui_file(POPUP_WINDOW_VERTICAL_UI_FILE);
	g_free(orientation);

	DEBUG("Building from ui file '%s'", uifile);
	builder = gtk_builder_new_from_file(uifile);

	/* Save some widgets for later use */
	assign_gtk_widget(builder, window, popup_window);
	assign_gtk_widget(builder, window, mute_check);
	assign_gtk_widget(builder, window, vol_scale);
	assign_gtk_adjustment(builder, window, vol_scale_adj);

	/* Configure some widgets */
	configure_vol_text(GTK_SCALE(window->vol_scale));
	configure_vol_increment(GTK_ADJUSTMENT(window->vol_scale_adj));

	/* Connect ui signal handlers */
	gtk_builder_connect_signals(builder, window);

	/* Connect audio signal handlers */
	window->audio = audio;
	audio_signals_connect(audio, on_audio_changed, window);

	/* Cleanup */
	g_object_unref(builder);
	g_free(uifile);
}
예제 #9
0
파일: main.c 프로젝트: jy2wong/spektro
static void spektro_activate_cb(GtkApplication *app, gpointer user_data) {
  GtkBuilder *builder = gtk_builder_new_from_file("spektro.ui");

  GtkApplicationWindow *app_window = GTK_APPLICATION_WINDOW(
      gtk_builder_get_object(builder, "main-window"));

  g_object_set(G_OBJECT(app_window), "application", app, NULL);
  gtk_application_window_set_show_menubar(app_window, FALSE);

  GtkGrid *grid = GTK_GRID(gtk_builder_get_object(builder, "grid"));

  // set up area where the spectrograph is displayed
  GtkScrolledWindow *scroll =GTK_SCROLLED_WINDOW(
      gtk_builder_get_object(builder, "scrolledwindow"));

  GtkImage *canvas = GTK_IMAGE(gtk_builder_get_object(builder, "canvas"));

  // file menu
  GtkFileChooserDialog *file_chooser = GTK_FILE_CHOOSER_DIALOG(gtk_builder_get_object(builder, "file-chooser-dialog"));
  GtkMenuItem *menu_open = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu-file-open"));
  g_signal_connect(G_OBJECT(menu_open), "activate", G_CALLBACK(open_cb), builder);

  GtkMenuItem *menu_quit = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu-file-quit"));
  g_signal_connect(G_OBJECT(menu_quit), "activate", G_CALLBACK(quit_cb), app);

  // open preferences window with menu
  GtkDialog *prefs = GTK_DIALOG(gtk_builder_get_object(builder, "preferences-dialog"));
  GtkMenuItem *menu_prefs = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu-edit-prefs"));
  g_signal_connect(G_OBJECT(menu_prefs), "activate", G_CALLBACK(prefs_cb), builder);

  // about dialog
  GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
  GtkMenuItem *menu_about = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu-help-about"));
  g_signal_connect(G_OBJECT(menu_about), "activate", G_CALLBACK(about_cb), about);

  return;
}
예제 #10
0
파일: testpopover.c 프로젝트: 3v1n0/gtk
int
main (int argc, char *argv[])
{
  GtkWidget *win;
  GtkWidget *box;
  GtkWidget *button;
  GtkWidget *button2;
  GtkBuilder *builder;
  GMenuModel *model;
  GSimpleActionGroup *actions;
  GtkWidget *overlay;
  GtkWidget *grid;
  GtkWidget *popover;
  GtkWidget *popover2;
  GtkWidget *label;
  GtkWidget *check;
  GtkWidget *combo;

  gtk_init (&argc, &argv);

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
  actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL);

  gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions));

  overlay = gtk_overlay_new ();
  gtk_container_add (GTK_CONTAINER (win), overlay);

  grid = gtk_grid_new ();
  gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
  gtk_widget_set_valign (grid, GTK_ALIGN_FILL);
  gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
  gtk_container_add (GTK_CONTAINER (overlay), grid);

  label = gtk_label_new ("");
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_vexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  label = gtk_label_new ("");
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_vexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1);

  builder = gtk_builder_new_from_file ("popover.ui");
  model = (GMenuModel *)gtk_builder_get_object (builder, "menu");

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  button = gtk_menu_button_new ();
  gtk_container_add (GTK_CONTAINER (box), button);
  button2 = gtk_menu_button_new ();
  gtk_container_add (GTK_CONTAINER (box), button2);

  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model);
  gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE);
  popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));

  builder = gtk_builder_new_from_file ("popover2.ui");
  popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover");
  gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2);

  g_object_set (box, "margin", 10, NULL);
  gtk_widget_set_halign (box, GTK_ALIGN_END);
  gtk_widget_set_valign (box, GTK_ALIGN_START);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box);

  label = gtk_label_new ("Popover hexpand");
  check = gtk_check_button_new ();
  g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT);
  g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1);

  label = gtk_label_new ("Popover vexpand");
  check = gtk_check_button_new ();
  g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT);
  g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1);

  label = gtk_label_new ("Button direction");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");

  g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT);
  g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1);

  label = gtk_label_new ("Button halign");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center");
  g_object_bind_property (combo, "active", box, "halign", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1);

  label = gtk_label_new ("Button valign");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center");
  g_object_bind_property (combo, "active", box, "valign", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1);


  gtk_widget_show_all (win);

  gtk_main ();

  return 0;
}
예제 #11
0
파일: main.c 프로젝트: bitptr/argonaut
/*
 * Set up the window: build the interface, connect the signals, insert the
 * file icons.
 */
static GtkWidget *
prepare_window(char *dir, struct geometry *geometry, struct state *d)
{
	GtkBuilder	*builder;
	GtkWidget	*icons, *window, *directory_close, *file_open;
	GtkWidget	*directory_up, *directory_open, *help_about;
	GtkListStore	*model;

	builder = gtk_builder_new_from_file(INTERFACE_PATH);
	window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
	icons = GTK_WIDGET(gtk_builder_get_object(builder, "icons"));
	directory_up = GTK_WIDGET(gtk_builder_get_object(builder, "directory-up-menu-item"));
	directory_open = GTK_WIDGET(gtk_builder_get_object(builder, "directory-open-menu-item"));
	directory_close = GTK_WIDGET(gtk_builder_get_object(builder, "directory-close-menu-item"));
	file_open = GTK_WIDGET(gtk_builder_get_object(builder, "file-open-menu-item"));
	help_about = GTK_WIDGET(gtk_builder_get_object(builder, "help-about-menu-item"));

	d->icon_view = GTK_ICON_VIEW(icons);

	g_object_unref(builder);

	gtk_window_set_default_size(GTK_WINDOW(window), geometry->w,
	    geometry->h);
	gtk_window_move(GTK_WINDOW(window), geometry->x, geometry->y);
	gtk_window_set_title(GTK_WINDOW(window), dir);

	model = gtk_list_store_new(MODEL_CNT,
	    G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
	if (populate(model, dir) == -1)
		err(66, "failed to populate icon model from %s", dir);

	watch_dir(model, dir);

	gtk_icon_view_set_text_column(GTK_ICON_VIEW(icons), 0);
	gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(icons), 1);
	gtk_icon_view_set_model(GTK_ICON_VIEW(icons), GTK_TREE_MODEL(model));
	g_object_unref(model);

	gtk_widget_set_sensitive(directory_up, strlen(d->dir) > 1);

	/* Drag */
	gtk_drag_source_set(icons, GDK_BUTTON1_MASK,
	    dnd_targets, TARGET_COUNT,
	    GDK_ACTION_COPY | GDK_ACTION_MOVE);
	gtk_drag_source_add_text_targets(icons);
	gtk_drag_source_add_uri_targets(icons);
	g_signal_connect(icons, "drag-begin", G_CALLBACK(on_icons_drag_begin), d);
	g_signal_connect(icons, "drag-data-get", G_CALLBACK(on_icons_drag_data_get), d);
	g_signal_connect(icons, "drag-end", G_CALLBACK(on_icons_drag_end), d);

	/* Drop */
	gtk_drag_dest_set(icons, GTK_DEST_DEFAULT_ALL,
	    dnd_targets, TARGET_COUNT,
	    GDK_ACTION_COPY | GDK_ACTION_MOVE);
	gtk_drag_dest_add_text_targets(icons);
	gtk_drag_dest_add_uri_targets(icons);
	g_signal_connect(icons, "drag-motion", G_CALLBACK(on_icons_drag_motion), d);
	g_signal_connect(icons, "drag-leave", G_CALLBACK(on_icons_data_leave), d);
	g_signal_connect(icons, "drag-data-received", G_CALLBACK(on_icons_drag_data_received), d);

	/* Activations */
	g_signal_connect(icons, "item-activated", G_CALLBACK(on_icons_item_activated), d);
	g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(window, "configure-event", G_CALLBACK(on_window_configure_event), dir);
	g_signal_connect(directory_up, "activate", G_CALLBACK(on_directory_up_menu_item_activate), d);
	g_signal_connect(directory_open, "activate", G_CALLBACK(on_directory_open_menu_item_activate), d);
	g_signal_connect(directory_close, "activate", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(file_open, "activate", G_CALLBACK(on_file_open_menu_item_activate), d);
	g_signal_connect(help_about, "activate", G_CALLBACK(on_help_about_menu_item_activate), NULL);
	g_signal_connect(icons, "button-press-event", G_CALLBACK(on_icons_button_press_event), d);

	return window;
}
예제 #12
0
/// Sets up the tabs for the action cue
static void stack_action_cue_set_tabs(StackCue *cue, GtkNotebook *notebook)
{
	StackActionCue *acue = STACK_ACTION_CUE(cue);
	
	// Create the tab
	GtkWidget *label = gtk_label_new("Action");
	
	// Load the UI
	GtkBuilder *builder = gtk_builder_new_from_file("StackActionCue.ui");
	acue->builder = builder;
	acue->action_tab = GTK_WIDGET(gtk_builder_get_object(builder, "acpGrid"));

	// Set up callbacks
	gtk_builder_add_callback_symbol(builder, "acp_cue_changed", G_CALLBACK(acp_cue_changed));
	gtk_builder_add_callback_symbol(builder, "acp_action_changed", G_CALLBACK(acp_action_changed));
	
	// Connect the signals
	gtk_builder_connect_signals(builder, (gpointer)cue);

	// Add an extra reference to the action tab - we're about to remove it's
	// parent and we don't want it to get garbage collected
	g_object_ref(acue->action_tab);

	// The tab has a parent window in the UI file - unparent the tab container from it
	gtk_widget_unparent(acue->action_tab);
	
	// Append the tab (and show it, because it starts off hidden...)
	gtk_notebook_append_page(notebook, acue->action_tab, label);
	gtk_widget_show(acue->action_tab);
	
	// Set the values: cue
	StackCue *target_cue = stack_cue_get_by_uid(acue->target);
	if (target_cue)
	{
		char cue_number[32];
		stack_cue_id_to_string(target_cue->id, cue_number, 32);

		// Build the string
		std::string button_text;
		button_text = std::string(cue_number) + ": " + std::string(target_cue->name);
	
		// Set the button text
		gtk_button_set_label(GTK_BUTTON(gtk_builder_get_object(builder, "acpCue")), button_text.c_str());
	}
	
	// Update action option
	switch (acue->action)
	{
		case STACK_ACTION_CUE_PLAY:
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "acpActionTypePlay")), true);
			break;

		case STACK_ACTION_CUE_PAUSE:
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "acpActionTypePause")), true);
			break;

		case STACK_ACTION_CUE_STOP:
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "acpActionTypeStop")), true);
			break;
	}
}
예제 #13
0
파일: main.c 프로젝트: KaiHangYang/cWorks
int main(int argc, char * argv[]) {

	/*gtk widget declare*/
	GtkBuilder *builder;
	GtkTreeIter  iter;
	GtkTreeSelection * select;
	/*gkt init*/
	gtk_init(&argc, &argv);

	/*gtk get widget from builder*/
	builder = gtk_builder_new_from_file("interface.xml");
	window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
	treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
 	select = gtk_tree_view_get_selection(treeview);
 	gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);

 	//add icon
 	gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("wolf.png"));
	//For menu
	GtkWidget * menuquit = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem5"));
	GtkWidget * menushowtypeall = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem4"));
	GtkWidget * menushowbaseall = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem11"));
	GtkWidget * menushowsellall = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem12"));
	GtkWidget * menudelete = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem6"));
	GtkWidget * menuchange = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem7"));
	GtkWidget * menuinput1 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem16"));
	GtkWidget * menuinput2 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem17"));
	GtkWidget * menuinput3 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem18"));
	GtkWidget * menusearch1 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem9"));
	GtkWidget * menusearch2 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem14"));
	GtkWidget * menusearch3 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem15"));
	GtkWidget * menudata1 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem19"));
	GtkWidget * menudata2 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem20"));
	GtkWidget * menudata3 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem21"));
	GtkWidget * menudata4_1 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem24"));
	GtkWidget * menudata4_2 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem25"));
	GtkWidget * menudata6 = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem23"));
	GtkWidget * menuabout = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem13"));
	GtkWidget * menusave = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem3"));
	GtkWidget * menuopen = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem2"));
	GtkWidget * menunew = GTK_WIDGET(gtk_builder_get_object(builder, "imagemenuitem1"));

	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(window), 500, 280);


	


	/*菜单的信号绑定*/
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(main_quit), NULL);
	g_signal_connect(G_OBJECT(menuquit), "activate", G_CALLBACK(main_quit), NULL);
	g_signal_connect(G_OBJECT(menushowtypeall), "activate", G_CALLBACK(show_info_all), "t");
	g_signal_connect(G_OBJECT(menushowbaseall), "activate", G_CALLBACK(show_info_all), "b");
 	g_signal_connect(G_OBJECT(menushowsellall), "activate", G_CALLBACK(show_info_all), "s");
 	g_signal_connect(G_OBJECT(menudelete), "activate", G_CALLBACK(cloth_info_delete), select);
 	g_signal_connect(G_OBJECT(menuchange), "activate", G_CALLBACK(cloth_info_change), select);
 	g_signal_connect(G_OBJECT(menuinput1), "activate", G_CALLBACK(cloth_info_input), "1");
 	g_signal_connect(G_OBJECT(menuinput2), "activate", G_CALLBACK(cloth_info_input), "2");
 	g_signal_connect(G_OBJECT(menuinput3), "activate", G_CALLBACK(cloth_info_input), "3");
 	g_signal_connect(G_OBJECT(menusearch1), "activate", G_CALLBACK(cloth_info_search), "1");
 	g_signal_connect(G_OBJECT(menusearch2), "activate", G_CALLBACK(cloth_info_search), "2");
 	g_signal_connect(G_OBJECT(menusearch3), "activate", G_CALLBACK(cloth_info_search), "3");
 	g_signal_connect(G_OBJECT(menudata1), "activate", G_CALLBACK(data_count), "1");
 	g_signal_connect(G_OBJECT(menudata2), "activate", G_CALLBACK(data_count), "2");
 	g_signal_connect(G_OBJECT(menudata3), "activate", G_CALLBACK(data_count), "3");
 	g_signal_connect(G_OBJECT(menudata4_1), "activate", G_CALLBACK(data_count), "4");
 	g_signal_connect(G_OBJECT(menudata4_2), "activate", G_CALLBACK(data_count), "5");
 	g_signal_connect(G_OBJECT(menudata6), "activate", G_CALLBACK(data_count), "6");
 	g_signal_connect(G_OBJECT(menuabout), "activate", G_CALLBACK(about), NULL);
 	g_signal_connect(G_OBJECT(menusave), "activate", G_CALLBACK(main_save), NULL);
 	g_signal_connect(G_OBJECT(menuopen), "activate", G_CALLBACK(main_open), NULL);
 	g_signal_connect(G_OBJECT(menunew), "activate", G_CALLBACK(main_new), NULL);

	g_object_unref(G_OBJECT(builder));

	gtk_widget_show_all(window);

	init();

	gtk_main();

	return 0;
}
예제 #14
0
int main(int argc, char*argv[])
{
    bindtextdomain ("testGtkGstreamer", "./locale");
    bind_textdomain_codeset ("testGtkGstreamer", "UTF-8");
    textdomain ("testGtkGstreamer");
    setlocale(LC_ALL, "");

    GtkWidget* window = NULL;
    GError *error = NULL;
    GOptionContext *context;
    // gtk_init(&argc, &argv);
    context = g_option_context_new (_("- a simple gtk gstreamer program"));
    g_option_context_add_main_entries (context, entries, "testGtkGstreamer");
    g_option_context_add_group (context, gtk_get_option_group (TRUE));
    if (!g_option_context_parse (context, &argc, &argv, &error)) {
        g_print ("option parsing failed: %s\n", error->message);
        exit (1);
    }

    gst_init (&argc, &argv);
    
    GtkBuilder* builder = gtk_builder_new_from_file("./main.ui");
    gtk_builder_connect_signals(builder, builder);

    window = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow"));
    // g_signal_connect(window, "delete-event", G_CALLBACK(onWindowDeleteEvent), builder);
    // g_signal_connect(window, "destroy", G_CALLBACK(onDestoryed), builder);

    GtkWidget* video_area = GTK_WIDGET(gtk_builder_get_object(builder, "video_area"));
    g_signal_connect(video_area, "realize", G_CALLBACK(on_video_area_realize), builder);

    GtkWidget* playpausebtn = GTK_WIDGET(gtk_builder_get_object(builder, "video_play_pause"));
    GtkWidget* image = gtk_image_new_from_icon_name ("media-playback-start-symbolic", GTK_ICON_SIZE_MENU);
    gtk_button_set_image (GTK_BUTTON (playpausebtn), image);
    gtk_widget_set_valign (GTK_WIDGET (playpausebtn), GTK_ALIGN_CENTER);
    gtk_style_context_add_class (gtk_widget_get_style_context (playpausebtn), "image-button");

    GtkWidget* hellobtn = GTK_WIDGET(gtk_builder_get_object(builder, "helloworld"));
    g_signal_connect(hellobtn, "clicked", G_CALLBACK(onButtonClicked), builder);
    
    GtkListStore* model = gtk_list_store_new(LIST_COLUMNS_N, G_TYPE_STRING, G_TYPE_STRING);
    int i = 0;
    for (i = 0; i < 50; i++) {
        GtkTreeIter iter;
        gtk_list_store_append(model, &iter);
        gtk_list_store_set(model, &iter, LIST_NO, g_strdup_printf("%d", i + 1), LIST_TITLE, g_strdup_printf("This is column %d", i + 1), -1);
    }
    GtkWidget* cb1 = GTK_WIDGET(gtk_builder_get_object(builder, "combobox"));
    gtk_combo_box_set_model(GTK_COMBO_BOX(cb1), GTK_TREE_MODEL(model));
    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(cb1), LIST_NO);
    
    gtk_widget_show_all(GTK_WIDGET(window));

    gtk_widget_realize(GTK_WIDGET(video_area));

    create_gst_pipline();

    gst_element_set_state (g_pipeline, GST_STATE_PLAYING);

    gtk_main();

    gst_element_set_state (g_pipeline, GST_STATE_NULL);  

    gst_object_unref(GST_OBJECT(g_pipeline));
    g_free(g_filename);
    return 0;
}