コード例 #1
0
ファイル: gwsvcctl.c プロジェクト: ei-grad/samba-gtk
static GtkWidget* create_mainwindow (void)
{
	GtkWidget *mainwindow;
	GtkWidget *vbox;
	GtkWidget *menubar;
	GtkWidget *menuitem4;
	GtkWidget *menuitem4_menu;
	GtkWidget *mnu_connect;
	GtkWidget *separatormenuitem1;
	GtkWidget *quit;
	GtkWidget *service;
	GtkWidget *service_menu;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *curcol;
	GtkWidget *menuitem7;
	GtkWidget *menuitem7_menu;
	GtkWidget *about;
	GtkWidget *scrolledwindow;
	GtkWidget *statusbar;
	GtkAccelGroup *accel_group;

	accel_group = gtk_accel_group_new ();

	mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (mainwindow), 642, 562);
	gtk_window_set_title (GTK_WINDOW (mainwindow), "Service Management");

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (mainwindow), vbox);

	menubar = gtk_menu_bar_new ();
	gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);

	menuitem4 = gtk_menu_item_new_with_mnemonic ("_File");
	gtk_container_add (GTK_CONTAINER (menubar), menuitem4);

	menuitem4_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

	mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect");
	gtk_container_add (GTK_CONTAINER (menuitem4_menu), mnu_connect);
	g_signal_connect ((gpointer) mnu_connect, "activate",
	  G_CALLBACK (on_connect_activate), NULL);

	separatormenuitem1 = gtk_separator_menu_item_new ();
	gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1);
	gtk_widget_set_sensitive (separatormenuitem1, FALSE);

	quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit);

	service = gtk_menu_item_new_with_mnemonic ("_Service");
	gtk_container_add (GTK_CONTAINER (menubar), service);

	service_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (service), service_menu);

	new_service = gtk_menu_item_new_with_mnemonic ("_New");
	gtk_container_add (GTK_CONTAINER (service_menu), new_service);
	gtk_widget_set_sensitive (new_service, FALSE);

	start_service = gtk_menu_item_new_with_mnemonic ("_Start");
	gtk_container_add (GTK_CONTAINER (service_menu), start_service);
	gtk_widget_set_sensitive (start_service, FALSE);

	stop_service = gtk_menu_item_new_with_mnemonic ("St_op");
	gtk_container_add (GTK_CONTAINER (service_menu), stop_service);
	gtk_widget_set_sensitive (stop_service, FALSE);

	edit_service = gtk_menu_item_new_with_mnemonic ("_Edit");
	gtk_container_add (GTK_CONTAINER (service_menu), edit_service);
	gtk_widget_set_sensitive (edit_service, FALSE);

	delete_service = gtk_menu_item_new_with_mnemonic ("_Delete");
	gtk_widget_set_sensitive(delete_service, FALSE);
	gtk_container_add (GTK_CONTAINER (service_menu), delete_service);

	menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help");
	gtk_container_add (GTK_CONTAINER (menubar), menuitem7);

	menuitem7_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu);

	about = gtk_menu_item_new_with_mnemonic ("_About");
	gtk_container_add (GTK_CONTAINER (menuitem7_menu), about);

	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);

	services = gtk_tree_view_new ();

	curcol = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title(curcol, "Status");
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(curcol, renderer, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
	gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0);

	curcol = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title(curcol, "ID");
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(curcol, renderer, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
	gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);

	curcol = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title(curcol, "Day");
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(curcol, renderer, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
	gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2);

	curcol = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title(curcol, "Time");
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(curcol, renderer, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
	gtk_tree_view_column_add_attribute(curcol, renderer, "text", 3);

	curcol = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_title(curcol, "Command Line");
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(curcol, renderer, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
	gtk_tree_view_column_add_attribute(curcol, renderer, "text", 4);

	store_services = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(services), GTK_TREE_MODEL(store_services));
	g_object_unref(store_services);

	gtk_container_add (GTK_CONTAINER (scrolledwindow), services);

	statusbar = gtk_statusbar_new ();
	gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);

	g_signal_connect ((gpointer) quit, "activate",
	  G_CALLBACK (on_quit_activate), NULL);
	g_signal_connect ((gpointer) about, "activate",
	  G_CALLBACK (on_about_activate), NULL);

	gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group);

	return mainwindow;
}
コード例 #2
0
ファイル: gtk2_interface.c プロジェクト: forthyen/SDesk
GtkWidget*
create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *vbox1;
  GtkWidget *menubar1;
  GtkWidget *menuitem1;
  GtkWidget *menu1;
  GtkWidget *new1;
  GtkWidget *open1;
  GtkWidget *save1;
  GtkWidget *save_as1;
  GtkWidget *separatormenuitem1;
  GtkWidget *quit1;
  GtkWidget *menuitem2;
  GtkWidget *menu2;
  GtkWidget *cut1;
  GtkWidget *copy1;
  GtkWidget *paste1;
  GtkWidget *delete1;
  GtkWidget *menuitem3;
  GtkWidget *menu3;
  GtkWidget *menuitem4;
  GtkWidget *menu4;
  GtkWidget *about1;
  GtkWidget *handlebox1;
  GtkWidget *toolbar1;
  GtkWidget *tmp_toolbar_icon;
  GtkWidget *button1;
  GtkWidget *button2;
  GtkWidget *button3;
  GtkWidget *hscale1;
  GtkWidget *statusbar1;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window1), _("window1"));

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (window1), vbox1);

  menubar1 = gtk_menu_bar_new ();
  gtk_widget_show (menubar1);
  gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);

  menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File"));
  gtk_widget_show (menuitem1);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);

  menu1 = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menu1);

  new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
  gtk_widget_show (new1);
  gtk_container_add (GTK_CONTAINER (menu1), new1);

  open1 = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
  gtk_widget_show (open1);
  gtk_container_add (GTK_CONTAINER (menu1), open1);

  save1 = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
  gtk_widget_show (save1);
  gtk_container_add (GTK_CONTAINER (menu1), save1);

  save_as1 = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group);
  gtk_widget_show (save_as1);
  gtk_container_add (GTK_CONTAINER (menu1), save_as1);

  separatormenuitem1 = gtk_separator_menu_item_new ();
  gtk_widget_show (separatormenuitem1);
  gtk_container_add (GTK_CONTAINER (menu1), separatormenuitem1);
  gtk_widget_set_sensitive (separatormenuitem1, FALSE);

  quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
  gtk_widget_show (quit1);
  gtk_container_add (GTK_CONTAINER (menu1), quit1);

  menuitem2 = gtk_menu_item_new_with_mnemonic (_("_Edit"));
  gtk_widget_show (menuitem2);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem2);

  menu2 = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menu2);

  cut1 = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
  gtk_widget_show (cut1);
  gtk_container_add (GTK_CONTAINER (menu2), cut1);

  copy1 = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
  gtk_widget_show (copy1);
  gtk_container_add (GTK_CONTAINER (menu2), copy1);

  paste1 = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
  gtk_widget_show (paste1);
  gtk_container_add (GTK_CONTAINER (menu2), paste1);

  delete1 = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
  gtk_widget_show (delete1);
  gtk_container_add (GTK_CONTAINER (menu2), delete1);

  menuitem3 = gtk_menu_item_new_with_mnemonic (_("_View"));
  gtk_widget_show (menuitem3);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem3);

  menu3 = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menu3);

  menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help"));
  gtk_widget_show (menuitem4);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);

  menu4 = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menu4);

  about1 = gtk_menu_item_new_with_mnemonic (_("_About"));
  gtk_widget_show (about1);
  gtk_container_add (GTK_CONTAINER (menu4), about1);

  handlebox1 = gtk_handle_box_new ();
  gtk_widget_show (handlebox1);
  gtk_box_pack_start (GTK_BOX (vbox1), handlebox1, FALSE, TRUE, 0);

  toolbar1 = gtk_toolbar_new ();
  gtk_widget_show (toolbar1);
  gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);

  tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-open", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
  button1 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
                                GTK_TOOLBAR_CHILD_BUTTON,
                                NULL,
                                _("button1"),
                                NULL, NULL,
                                tmp_toolbar_icon, NULL, NULL);
  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
  gtk_widget_show (button1);

  tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-cdrom", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
  button2 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
                                GTK_TOOLBAR_CHILD_BUTTON,
                                NULL,
                                _("button2"),
                                NULL, NULL,
                                tmp_toolbar_icon, NULL, NULL);
  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
  gtk_widget_show (button2);

  tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-refresh", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
  button3 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
                                GTK_TOOLBAR_CHILD_BUTTON,
                                NULL,
                                _("button3"),
                                NULL, NULL,
                                tmp_toolbar_icon, NULL, NULL);
  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
  gtk_widget_show (button3);

  hscale1 = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0)));
  gtk_widget_show (hscale1);
  gtk_box_pack_start (GTK_BOX (vbox1), hscale1, TRUE, TRUE, 0);

  statusbar1 = gtk_statusbar_new ();
  gtk_widget_show (statusbar1);
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) new1, "activate",
                    G_CALLBACK (on_new1_activate),
                    NULL);
  g_signal_connect ((gpointer) open1, "activate",
                    G_CALLBACK (on_open1_activate),
                    NULL);
  g_signal_connect ((gpointer) save1, "activate",
                    G_CALLBACK (on_save1_activate),
                    NULL);
  g_signal_connect ((gpointer) save_as1, "activate",
                    G_CALLBACK (on_save_as1_activate),
                    NULL);
  g_signal_connect ((gpointer) quit1, "activate",
                    G_CALLBACK (on_quit1_activate),
                    NULL);
  g_signal_connect ((gpointer) cut1, "activate",
                    G_CALLBACK (on_cut1_activate),
                    NULL);
  g_signal_connect ((gpointer) copy1, "activate",
                    G_CALLBACK (on_copy1_activate),
                    NULL);
  g_signal_connect ((gpointer) paste1, "activate",
                    G_CALLBACK (on_paste1_activate),
                    NULL);
  g_signal_connect ((gpointer) delete1, "activate",
                    G_CALLBACK (on_delete1_activate),
                    NULL);
  g_signal_connect ((gpointer) about1, "activate",
                    G_CALLBACK (on_about1_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
  GLADE_HOOKUP_OBJECT (window1, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (window1, menubar1, "menubar1");
  GLADE_HOOKUP_OBJECT (window1, menuitem1, "menuitem1");
  GLADE_HOOKUP_OBJECT (window1, menu1, "menu1");
  GLADE_HOOKUP_OBJECT (window1, new1, "new1");
  GLADE_HOOKUP_OBJECT (window1, open1, "open1");
  GLADE_HOOKUP_OBJECT (window1, save1, "save1");
  GLADE_HOOKUP_OBJECT (window1, save_as1, "save_as1");
  GLADE_HOOKUP_OBJECT (window1, separatormenuitem1, "separatormenuitem1");
  GLADE_HOOKUP_OBJECT (window1, quit1, "quit1");
  GLADE_HOOKUP_OBJECT (window1, menuitem2, "menuitem2");
  GLADE_HOOKUP_OBJECT (window1, menu2, "menu2");
  GLADE_HOOKUP_OBJECT (window1, cut1, "cut1");
  GLADE_HOOKUP_OBJECT (window1, copy1, "copy1");
  GLADE_HOOKUP_OBJECT (window1, paste1, "paste1");
  GLADE_HOOKUP_OBJECT (window1, delete1, "delete1");
  GLADE_HOOKUP_OBJECT (window1, menuitem3, "menuitem3");
  GLADE_HOOKUP_OBJECT (window1, menu3, "menu3");
  GLADE_HOOKUP_OBJECT (window1, menuitem4, "menuitem4");
  GLADE_HOOKUP_OBJECT (window1, menu4, "menu4");
  GLADE_HOOKUP_OBJECT (window1, about1, "about1");
  GLADE_HOOKUP_OBJECT (window1, handlebox1, "handlebox1");
  GLADE_HOOKUP_OBJECT (window1, toolbar1, "toolbar1");
  GLADE_HOOKUP_OBJECT (window1, button1, "button1");
  GLADE_HOOKUP_OBJECT (window1, button2, "button2");
  GLADE_HOOKUP_OBJECT (window1, button3, "button3");
  GLADE_HOOKUP_OBJECT (window1, hscale1, "hscale1");
  GLADE_HOOKUP_OBJECT (window1, statusbar1, "statusbar1");

  gtk_window_add_accel_group (GTK_WINDOW (window1), accel_group);

  return window1;
}
コード例 #3
0
ファイル: gcalc.cpp プロジェクト: ombt/ombt
int
main(int argc, char **argv)
{
    // support standard gtk options
    gtk_init(&argc, &argv);

    // check other options
    if (argc == 2 && strcmp(argv[1], "-v") == 0) verbose = true;

    // get get some color in the world
    GdkColor yellow;
    gdk_color_parse("yellow", &yellow);
    GdkColor red;
    gdk_color_parse("red", &red);
    GdkColor darkgray;
    gdk_color_parse("dark gray", &darkgray);
    GdkColor blue;
    gdk_color_parse("blue", &blue);
    GdkColor lightblue;
    gdk_color_parse("light blue", &lightblue);
    GdkColor lightgreen;
    gdk_color_parse("light green", &lightgreen);
    GdkColor magenta;
    gdk_color_parse("magenta", &magenta);
    GdkColor orange;
    gdk_color_parse("orange", &orange);
    GdkColor violet;
    gdk_color_parse("violet", &violet);

    // create main window and add trimmings
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &blue);
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 200);
    gtk_window_set_title(GTK_WINDOW(window), "GCALC");
    gtk_container_set_border_width(GTK_CONTAINER(window), 20);

    // always handle exits
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);

    // use a table to organize
    GtkWidget *table = gtk_table_new(10, 9, FALSE);
    gtk_container_add(GTK_CONTAINER(window), table);
    gtk_table_set_row_spacings(GTK_TABLE(table), 2);
    gtk_table_set_col_spacings(GTK_TABLE(table), 2);

    // add text box at row 0
    text_entry = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(text_entry), 400);
    gtk_entry_set_editable(GTK_ENTRY(text_entry), editable);
    gtk_entry_set_alignment(GTK_ENTRY(text_entry), 0);
    gtk_table_attach_defaults(GTK_TABLE(table), text_entry, 0, 10, 0, 1);

    // add lines of separation
    GtkWidget *horizontal_line = gtk_hseparator_new();
    gtk_table_attach_defaults(GTK_TABLE(table), horizontal_line, 0, 10, 1, 2);
    GtkWidget *vertical_line = gtk_vseparator_new();
    gtk_table_attach_defaults(GTK_TABLE(table), vertical_line, 5, 6, 1, 10);

    // add row 1 buttons
    // add_button_at("quit", table, VOIDFN(gtk_main_quit), 1, 2, 2, 3, &darkgray);
    add_button_at("quit", table, VOIDFN(gtk_main_quit), 1, 2, 2, 3, &red);
#if 0
    add_button_at("(", table, VOIDFN(button_callback), 2, 3, 2, 3);
    add_button_at(")", table, VOIDFN(button_callback), 3, 4, 2, 3);
#endif
    add_button_at("swap", table, VOIDFN(swap_button_callback), 2, 3, 2, 3, &darkgray);
    add_button_at("C", table, VOIDFN(clear_button_callback), 3, 4, 2, 3, &darkgray);
    add_button_at("AC", table, VOIDFN(allclear_button_callback), 4, 5, 2, 3, &darkgray);
    add_button_at("MC", table, VOIDFN(memory_button_callback), 6, 7, 2, 3, &orange);
    add_button_at("M+", table, VOIDFN(memory_button_callback), 7, 8, 2, 3, &orange);
    add_button_at("M-", table, VOIDFN(memory_button_callback), 8, 9, 2, 3, &orange);
    add_button_at("MR", table, VOIDFN(memory_button_callback), 9, 10, 2, 3, &orange);


    // add row 2 buttons
    add_button_at("1/x", table, VOIDFN(unaryop_button_callback), 1, 2, 3, 4, &magenta);
    add_button_at("x^2", table, VOIDFN(unaryop_button_callback), 2, 3, 3, 4, &magenta);
    add_button_at("x^3", table, VOIDFN(unaryop_button_callback), 3, 4, 3, 4, &magenta);
    add_button_at("y^x", table, VOIDFN(binaryop_button_callback), 4, 5, 3, 4, &lightgreen);
    add_button_at("%", table, VOIDFN(unaryop_button_callback), 6, 7, 3, 4, &magenta);
    add_button_at("+/-", table, VOIDFN(unaryop_button_callback), 7, 8, 3, 4, &magenta);
    add_button_at("/", table, VOIDFN(binaryop_button_callback), 8, 9, 3, 4, &lightgreen);
    add_button_at("x", table, VOIDFN(binaryop_button_callback), 9, 10, 3, 4, &lightgreen);

    // add row 3 buttons
    add_button_at("x!", table, VOIDFN(unaryop_button_callback), 1, 2, 4, 5, &magenta);
    add_button_at("sqrt", table, VOIDFN(unaryop_button_callback), 2, 3, 4, 5, &magenta);
    add_button_at("y^1/x", table, VOIDFN(binaryop_button_callback), 3, 4, 4, 5, &lightgreen);
    add_button_at("log10", table, VOIDFN(unaryop_button_callback), 4, 5, 4, 5, &magenta);
    add_button_at("7", table, VOIDFN(number_button_callback), 6, 7, 4, 5, &yellow);
    add_button_at("8", table, VOIDFN(number_button_callback), 7, 8, 4, 5, &yellow);
    add_button_at("9", table, VOIDFN(number_button_callback), 8, 9, 4, 5, &yellow);
    add_button_at("-", table, VOIDFN(binaryop_button_callback), 9, 10, 4, 5, &lightgreen);

    // add row 4 buttons
    add_button_at("sin", table, VOIDFN(unaryop_button_callback), 1, 2, 5, 6, &magenta);
    add_button_at("cos", table, VOIDFN(unaryop_button_callback), 2, 3, 5, 6, &magenta);
    add_button_at("tan", table, VOIDFN(unaryop_button_callback), 3, 4, 5, 6, &magenta);
    add_button_at("ln", table, VOIDFN(unaryop_button_callback), 4, 5, 5, 6, &magenta);
    add_button_at("4", table, VOIDFN(number_button_callback), 6, 7, 5, 6, &yellow);
    add_button_at("5", table, VOIDFN(number_button_callback), 7, 8, 5, 6, &yellow);
    add_button_at("6", table, VOIDFN(number_button_callback), 8, 9, 5, 6, &yellow);
    add_button_at("+", table, VOIDFN(binaryop_button_callback), 9, 10, 5, 6, &lightgreen);

    // add row 5 buttons
    add_button_at("sinh", table, VOIDFN(unaryop_button_callback), 1, 2, 6, 7, &magenta);
    add_button_at("cosh", table, VOIDFN(unaryop_button_callback), 2, 3, 6, 7, &magenta);
    add_button_at("tanh", table, VOIDFN(unaryop_button_callback), 3, 4, 6, 7, &magenta);
    add_button_at("e^x", table, VOIDFN(unaryop_button_callback), 4, 5, 6, 7, &magenta);
    add_button_at("1", table, VOIDFN(number_button_callback), 6, 7, 6, 7, &yellow);
    add_button_at("2", table, VOIDFN(number_button_callback), 7, 8, 6, 7, &yellow);
    add_button_at("3", table, VOIDFN(number_button_callback), 8, 9, 6, 7, &yellow);
    add_button_at("=", table, VOIDFN(equal_button_callback), 9, 10, 6, 8, &lightblue);

    // add row 6 buttons
    add_button_at("asin", table, VOIDFN(unaryop_button_callback), 1, 2, 7, 8, &magenta);
    add_button_at("acos", table, VOIDFN(unaryop_button_callback), 2, 3, 7, 8, &magenta);
    add_button_at("atan", table, VOIDFN(unaryop_button_callback), 3, 4, 7, 8, &magenta);
    add_button_at("log2", table, VOIDFN(unaryop_button_callback), 4, 5, 7, 8, &magenta);
    add_button_at("0", table, VOIDFN(number_button_callback), 6, 8, 7, 8, &yellow);
    add_button_at(".", table, VOIDFN(number_button_callback), 8, 9, 7, 8, &lightblue);

    // add row 7 buttons
    add_button_at("asinh", table, VOIDFN(unaryop_button_callback), 1, 2, 8, 9, &magenta);
    add_button_at("acosh", table, VOIDFN(unaryop_button_callback), 2, 3, 8, 9, &magenta);
    add_button_at("atanh", table, VOIDFN(unaryop_button_callback), 3, 4, 8, 9, &magenta);
    add_button_at("2^x", table, VOIDFN(unaryop_button_callback), 4, 5, 8, 9, &magenta);

    // add row 8 buttons
    GSList *group = add_radio_button_at("rad", table, NULL, TRUE, VOIDFN(angle_button_callback), 1, 2, 9, 10, &violet);
    add_radio_button_at("deg", table, group, FALSE, VOIDFN(angle_button_callback), 2, 3, 9, 10, &violet);
    add_button_at("pi", table, VOIDFN(constant_button_callback), 3, 4, 9, 10, &violet);
    add_button_at("EE", table, VOIDFN(button_callback), 4, 5, 9, 10, &violet);

#if 0
    // add debug button
    add_button_at("dbg", table, VOIDFN(debug_button_callback), 9, 10, 9, 10, &violet);
#else
    // add menu item with choices to activate
    GtkWidget *menubar = gtk_menu_bar_new();

    GtkWidget *options = gtk_menu_item_new_with_label("options");
    gtk_menu_bar_append(GTK_MENU_BAR(menubar), options);

    GtkWidget *submenu= gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(options), submenu);

    GtkWidget *dbgitem = gtk_check_menu_item_new_with_label("dbg");
    gtk_menu_append(GTK_MENU(submenu), dbgitem);
    g_signal_connect(G_OBJECT(dbgitem), "activate",
                     G_CALLBACK(checked_callback), (gpointer)"dbg");

    GtkWidget *edtitem = gtk_check_menu_item_new_with_label("edt");
    gtk_menu_append(GTK_MENU(submenu), edtitem);
    g_signal_connect(G_OBJECT(edtitem), "activate",
                     G_CALLBACK(checked_callback), (gpointer)"edt");

    gtk_table_attach_defaults(GTK_TABLE(table), menubar, 8, 10, 9, 10);
#endif

    // show main window and anything it contains
    gtk_widget_show_all(window);

    // start up main event loop
    gtk_main();

    // all done
    return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: donwoc/icancode
int main (int argc, char *argv[])
{
  GtkWidget *window1;
  GdkPixbuf *window1_icon_pixbuf;
  GtkWidget *vbox1;
  GtkWidget *menubar1;
  GtkWidget *menuitem1;
  GtkWidget *menuitem1_menu;
  GtkWidget *Save_s_1;
  GtkWidget *Quit_q_1;
  GtkWidget *menuitem2;
  GtkWidget *menuitem2_menu;
  GtkWidget *Add_a_1;
  GtkWidget *Edit_e_1;
  GtkWidget *Delete_d_1;
  GtkWidget *menuitem3;
  GtkWidget *menuitem3_menu;
  GtkWidget *Find_f_1;
  GtkWidget *toolbar1;
  GtkIconSize tmp_toolbar_icon_size;
  GtkWidget *toolbutton1;
  GtkWidget *toolbutton2;
  GtkWidget *toolbutton3;
  GtkWidget *toolbutton4;
  GtkWidget *toolbutton5;
  GtkWidget *hbox1;
  GtkWidget *scrolledwindow1;
  GtkWidget *treeview;
  GtkWidget *scrolledwindow2;
  GtkWidget *textview1;
  GtkAccelGroup *accel_group;
  GtkTooltips *tooltips;
  GtkTreeSelection *selection;

  
  //初始化GTK+
  gtk_init (&argc, &argv);

  tooltips = gtk_tooltips_new ();

  accel_group = gtk_accel_group_new ();

  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_size_request (window1, 450, 600);
  gtk_window_set_title (GTK_WINDOW (window1), "Echo Addressbook");
  
  gtk_window_set_icon_from_file(GTK_WINDOW (window1), "./pixmaps/logo.png", NULL);
 


  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window1), vbox1);

//菜单
  menubar1 = gtk_menu_bar_new ();
  gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);

  menuitem1 = gtk_menu_item_new_with_mnemonic ("_File");
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);

	menuitem1_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);

	Save_s_1 = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), Save_s_1);

	Quit_q_1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), Quit_q_1);

  menuitem2 = gtk_menu_item_new_with_mnemonic ("_Edit");
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem2);

	menuitem2_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menuitem2_menu);

	Add_a_1 = gtk_image_menu_item_new_from_stock ("gtk-add", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), Add_a_1);
    gtk_widget_add_accelerator (Add_a_1, "activate", accel_group, GDK_a, (GdkModifierType) GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

	Edit_e_1 = gtk_image_menu_item_new_from_stock ("gtk-edit", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), Edit_e_1);
    gtk_widget_add_accelerator (Edit_e_1, "activate", accel_group, GDK_e, (GdkModifierType) GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

	Delete_d_1 = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), Delete_d_1);
    gtk_widget_add_accelerator (Delete_d_1, "activate", accel_group, GDK_d, (GdkModifierType) GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

  menuitem3 = gtk_menu_item_new_with_mnemonic ("_Search");
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem3);

	menuitem3_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menuitem3_menu);

	Find_f_1 = gtk_image_menu_item_new_from_stock ("gtk-find", accel_group);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), Find_f_1);
//菜单


//工具条
  toolbar1 = gtk_toolbar_new ();
  gtk_box_pack_start (GTK_BOX (vbox1), toolbar1, FALSE, FALSE, 0);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_ICONS);
  tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1));

  toolbutton1 = (GtkWidget *) gtk_tool_button_new_from_stock ("gtk-add");
  gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton1);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton1), tooltips, "Add", NULL);
  

  toolbutton2 = (GtkWidget *) gtk_tool_button_new_from_stock ("gtk-find");
  gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton2);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton2), tooltips, "Search", NULL);

  toolbutton3 = (GtkWidget *) gtk_tool_button_new_from_stock ("gtk-edit");
  gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton3);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton3), tooltips, "Edit", NULL);

  toolbutton4 = (GtkWidget *) gtk_tool_button_new_from_stock ("gtk-save");
  gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton4);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton4), tooltips, "Save", NULL);

  toolbutton5 = (GtkWidget *) gtk_tool_button_new_from_stock ("gtk-delete");
  gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton5);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton5), tooltips, "Delete", NULL);
  
//工具条
  
                                  /*   hbox  start*/
  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
  
  
  statusbar = gtk_statusbar_new ();
  
//Treeview
  //创建treeview
  model = create_model ();
  treeview = gtk_tree_view_new_with_model (model);
  //创建栏目
  creat_columns (GTK_TREE_VIEW (treeview));

  //加载数据
  LoadFile();
  BuildTreeView(GTK_TREE_VIEW (treeview));
  
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);  
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));

  
  //滚动条1---treeview
  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow1, FALSE, TRUE, 0);
  gtk_widget_set_size_request (scrolledwindow1, 160, -1);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview);
//  

  //GTK textview
  textview1 = gtk_text_view_new ();  
  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview1), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview1), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview1), GTK_WRAP_CHAR);
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)); 
  gtk_text_buffer_create_tag (buffer, "x-large","scale", PANGO_SCALE_X_LARGE, NULL);
  
  //滚动条2---textview
  scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
  gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow2, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (scrolledwindow2), textview1);
                                /*   hbox  end    */
								
//状态栏								
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0);

  
  
  //设置回调函数
  g_signal_connect (window1, "destroy", G_CALLBACK (gtk_main_quit),NULL);
  g_signal_connect (selection, "changed", G_CALLBACK (GetSelect), treeview); 
  g_signal_connect (toolbutton1, "clicked", G_CALLBACK (add_people), treeview);
  g_signal_connect (toolbutton2, "clicked", G_CALLBACK (search_people), treeview);
  g_signal_connect (toolbutton3, "clicked", G_CALLBACK (edit_people), treeview);
  g_signal_connect (toolbutton4, "clicked", G_CALLBACK (SaveFile), NULL);
  g_signal_connect (toolbutton5, "clicked",G_CALLBACK (remove_item),treeview); 
  g_signal_connect (Add_a_1, "activate", G_CALLBACK (add_people), treeview);
  g_signal_connect (Edit_e_1, "activate", G_CALLBACK (edit_people),treeview);
  g_signal_connect (Find_f_1, "activate", G_CALLBACK (search_people),treeview);
  g_signal_connect (Delete_d_1, "activate", G_CALLBACK (remove_item),treeview);
  g_signal_connect (Quit_q_1, "activate", G_CALLBACK (gtk_main_quit),treeview);
 
  //快捷键组
  gtk_window_add_accel_group (GTK_WINDOW (window1), accel_group);
  
  gtk_widget_show_all (window1);
  
  //GTK_main
  gtk_main ();

  return 0;
}
コード例 #5
0
ファイル: GUI_main.cpp プロジェクト: ChunHungLiu/ctf-writeup
void GUIShowMainWindow()
{
	gui.windows.main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(gui.windows.main), "rcracki_mt-GUI");
	gtk_window_set_default_size(GTK_WINDOW(gui.windows.main), 740, 540);
	gtk_window_set_icon(GTK_WINDOW(gui.windows.main), gdk_pixbuf_new_from_file("icon.png", NULL));
	
	gui.fixed.main = gtk_fixed_new();
	gtk_container_add(GTK_CONTAINER(gui.windows.main), gui.fixed.main);
	
	/* Menu bar */
	gui.menu.bar = gtk_menu_bar_new();
	gtk_widget_set_size_request(gui.menu.bar, 740, 28);
	gui.menu.filemenu = gtk_menu_new();
	gui.menu.settingsmenu = gtk_menu_new();
	gui.menu.helpmenu = gtk_menu_new();
	
	gui.menu.file = gtk_menu_item_new_with_mnemonic("_File");
	gui.menu.tables = gtk_menu_item_new_with_label("Add tables");
	gui.menu.hashes = gtk_menu_item_new_with_label("Add hashes");
	gui.menu.session = gtk_menu_item_new_with_label("Load session");
	gui.menu.quit = gtk_menu_item_new_with_label("Quit");
	
	gui.menu.settings = gtk_menu_item_new_with_mnemonic("_Settings");
	gui.menu.preferences = gtk_menu_item_new_with_label("Preferences");
	
	gui.menu.help = gtk_menu_item_new_with_mnemonic("_Help");
	gui.menu.info = gtk_menu_item_new_with_label("About");
	
	gui.menu.seperator = gtk_separator_menu_item_new();
	
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(gui.menu.file), gui.menu.filemenu);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.filemenu), gui.menu.tables);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.filemenu), gui.menu.hashes);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.filemenu), gui.menu.session);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.filemenu), gui.menu.seperator);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.filemenu), gui.menu.quit);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.bar), gui.menu.file);
	
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(gui.menu.settings), gui.menu.settingsmenu);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.settingsmenu), gui.menu.preferences);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.bar), gui.menu.settings);
	
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(gui.menu.help), gui.menu.helpmenu);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.helpmenu), gui.menu.info);
	gtk_menu_shell_append(GTK_MENU_SHELL(gui.menu.bar), gui.menu.help);
	
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.menu.bar, 0, 0);
	
	/* Control buttons */
	gui.buttons.run = gtk_button_new_with_label("Run");
	gtk_widget_set_size_request(gui.buttons.run, 64, 32);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.buttons.run, 8, 56);
	
	gui.buttons.pause = gtk_button_new_with_label("Pause");
	gtk_widget_set_size_request(gui.buttons.pause, 64, 32);
	gtk_widget_set_sensitive(gui.buttons.pause, false);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.buttons.pause, 88, 56);
	
	gui.buttons.abort = gtk_button_new_with_label("Abort");
	gtk_widget_set_size_request(gui.buttons.abort, 64, 32);
	gtk_widget_set_sensitive(gui.buttons.abort, false);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.buttons.abort, 168, 56);
	
	gui.buttons.clear = gtk_button_new_with_label("Clear");
	gtk_widget_set_size_request(gui.buttons.clear, 64, 32);
	gtk_widget_set_tooltip_text(gui.buttons.clear, "Clear all messages");
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.buttons.clear, 248, 56);
	
	/* Message view */
	GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
	
	gui.frame = gtk_aspect_frame_new("Messages", 0.1, 0.1, 10, true);
	gtk_widget_set_size_request(gui.frame, 740, 165);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.frame, 5, 100);
	
	gui.txtview.msg = gtk_text_view_new();
	gtk_widget_set_size_request(gui.txtview.msg, 712, 140);
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(gui.txtview.msg), 5);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(gui.txtview.msg), false);
	gui.txtview.msg_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui.txtview.msg));
	
	gtk_container_add(GTK_CONTAINER(scroll), gui.txtview.msg);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), scroll, 8, 120);
	
	/* Plaintext view */
	scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
	
	gui.frame = gtk_aspect_frame_new("Plaintexts", 0.0, 0.0, 10, true);
	gtk_widget_set_size_request(gui.frame, 740, 165);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.frame, 5, 280);
	
	gui.txtview.hashes = gtk_text_view_new();
	gtk_widget_set_size_request(gui.txtview.hashes, 712, 140);
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(gui.txtview.hashes), 5);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(gui.txtview.hashes), false);
	gui.txtview.hashes_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui.txtview.hashes));
	gtk_container_add(GTK_CONTAINER(scroll), gui.txtview.hashes);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), scroll, 8, 300);
	
	gtk_text_buffer_get_iter_at_offset(gui.txtview.msg_buffer, &gui.txtview.msg_iter, 0);
	gtk_text_buffer_get_iter_at_offset(gui.txtview.hashes_buffer, &gui.txtview.hashes_iter, 0);
	
	GdkColor color;
	gdk_color_parse("red", &color);
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-red", "foreground-gdk", &color, NULL);
	gdk_color_parse("darkblue", &color);
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-blue", "foreground-gdk", &color, NULL);
	gdk_color_parse("grey", &color);
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-grey", "foreground-gdk", &color, NULL);
	gdk_color_parse("black", &color);
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-black", "foreground-gdk", &color, NULL);
	gdk_color_parse("darkgreen", &color);
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-green", "foreground-gdk", &color, NULL);
	color.red = color.green = color.blue = 12000;
	gtk_text_buffer_create_tag(gui.txtview.msg_buffer, "col-darkgrey", "foreground-gdk", &color, NULL);
	
	/* Progress bar */
	gui.progbar = gtk_progress_bar_new();
	gtk_widget_set_size_request(gui.progbar, 735, 32);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.progbar, 8, 450);
	
	/* Information bar */
	gui.label = gtk_label_new("Current:");
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.label, 20, 510);
	gui.entries.current = gtk_entry_new();
	gtk_entry_set_editable(GTK_ENTRY(gui.entries.current), false);
	gtk_entry_set_text(GTK_ENTRY(gui.entries.current), "None");
	gtk_widget_set_tooltip_text(gui.entries.current, "Current action");
	gtk_widget_set_size_request(gui.entries.current, 120, 24);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.entries.current, 90, 505);
	
	gui.label = gtk_label_new("Found:");
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.label, 250, 510);
	gui.entries.found = gtk_entry_new();
	gtk_entry_set_editable(GTK_ENTRY(gui.entries.found), false);
	gtk_widget_set_tooltip_text(gui.entries.found, "Cracked hashes");
	gtk_widget_set_size_request(gui.entries.found, 120, 24);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.entries.found, 320, 505);
	
	gui.label = gtk_label_new("Elapsed time:");
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.label, 470, 510);
	gui.entries.time= gtk_entry_new();
	gtk_entry_set_editable(GTK_ENTRY(gui.entries.time), false);
	gtk_widget_set_tooltip_text(gui.entries.time, "Elapsed time since start");
	gtk_widget_set_size_request(gui.entries.time, 120, 24);
	gtk_fixed_put(GTK_FIXED(gui.fixed.main), gui.entries.time, 570, 505);
	
	gtk_widget_show_all(gui.windows.main);
	g_signal_connect(gui.windows.main, "destroy", G_CALLBACK(QuitApplication), NULL);
	g_signal_connect(gui.windows.main, "delete-event", G_CALLBACK(QuitApplication), NULL);
	g_signal_connect(gui.menu.hashes, "activate", G_CALLBACK(ShowHashWindow), NULL);
	g_signal_connect(gui.menu.tables, "activate", G_CALLBACK(GUIShowTableWindow), NULL);
	g_signal_connect(gui.menu.preferences, "activate", G_CALLBACK(GUIShowSettingsWindow), NULL);
	g_signal_connect(gui.buttons.run, "clicked", G_CALLBACK(StartSession), NULL);
	g_signal_connect(gui.buttons.clear, "clicked", G_CALLBACK(ClearMessages), NULL);
	g_signal_connect(gui.menu.session, "activate", G_CALLBACK(BrowseSessionFile), NULL);
	g_signal_connect(gui.buttons.pause, "clicked", G_CALLBACK(PauseResumeSession), NULL);
	g_signal_connect(gui.buttons.abort, "clicked", G_CALLBACK(AbortSession), NULL);
	g_signal_connect(gui.menu.quit, "activate", G_CALLBACK(QuitApplication), NULL);
	g_signal_connect(gui.menu.info, "activate", G_CALLBACK(GUIShowInfo), NULL);
}
コード例 #6
0
static void
gdict_sidebar_init (GdictSidebar *sidebar)
{
  GdictSidebarPrivate *priv;
  GtkWidget *hbox;
  GtkWidget *select_hbox;
  GtkWidget *select_button;
  GtkWidget *close_button;
  GtkWidget *arrow;

  sidebar->priv = priv = GDICT_SIDEBAR_GET_PRIVATE (sidebar);

  /* we store all the pages inside the list, but we keep
   * a pointer inside the hash table for faster look up
   * times; what's inside the table will be destroyed with
   * the list, so there's no need to supply the destroy
   * functions for keys and values.
   */
  priv->pages = NULL;
  priv->pages_by_id = g_hash_table_new (g_str_hash, g_str_equal);

  /* top option menu */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start (GTK_BOX (sidebar), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);
  priv->hbox = hbox;

  select_button = gtk_toggle_button_new ();
  gtk_button_set_relief (GTK_BUTTON (select_button), GTK_RELIEF_NONE);
  g_signal_connect (select_button, "button-press-event",
		    G_CALLBACK (gdict_sidebar_select_button_press_cb),
		    sidebar);
  g_signal_connect (select_button, "key-press-event",
		    G_CALLBACK (gdict_sidebar_select_key_press_cb),
		    sidebar);
  priv->select_button = select_button;

  select_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  
  priv->label = gtk_label_new (NULL);
  gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
  gtk_box_pack_start (GTK_BOX (select_hbox), priv->label, FALSE, FALSE, 0);
  gtk_widget_show (priv->label);

  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
  gtk_box_pack_end (GTK_BOX (select_hbox), arrow, FALSE, FALSE, 0);
  gtk_widget_show (arrow);

  gtk_container_add (GTK_CONTAINER (select_button), select_hbox);
  gtk_widget_show (select_hbox);

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

  close_button = gtk_button_new ();
  gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
  gtk_button_set_image (GTK_BUTTON (close_button),
		        gtk_image_new_from_stock (GTK_STOCK_CLOSE,
						  GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect (close_button, "clicked",
		    G_CALLBACK (gdict_sidebar_close_clicked_cb),
		    sidebar);
  gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
  gtk_widget_show (close_button);
  priv->close_button = close_button;

  sidebar->priv->menu = gtk_menu_new ();
  g_signal_connect (sidebar->priv->menu, "deactivate",
		    G_CALLBACK (gdict_sidebar_menu_deactivate_cb),
		    sidebar);
  gtk_menu_attach_to_widget (GTK_MENU (sidebar->priv->menu),
		  	     GTK_WIDGET (sidebar),
			     gdict_sidebar_menu_detach_cb);
  gtk_widget_show (sidebar->priv->menu);

  sidebar->priv->notebook = gtk_notebook_new ();
  gtk_notebook_set_show_border (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
  gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->notebook, TRUE, TRUE, 6);
  gtk_widget_show (sidebar->priv->notebook);
}
コード例 #7
0
ファイル: dirmenu.c プロジェクト: TKr/lxde-lxpanel
/* Create a menu populated with all subdirectories. */
static GtkWidget * dirmenu_create_menu(DirMenuPlugin * dm, const char * path, gboolean open_at_top)
{
    /* Create a menu. */
    GtkWidget * menu = gtk_menu_new();

    if (dm->folder_icon == NULL)
    {
        int w;
        int h;
        gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(menu), GTK_ICON_SIZE_MENU, &w, &h);
        dm->folder_icon = gtk_icon_theme_load_icon(
            panel_get_icon_theme(dm->panel),
            "gnome-fs-directory", MAX(w, h), 0, NULL);
        if (dm->folder_icon == NULL)
            dm->folder_icon = gtk_widget_render_icon(menu, GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
    }

    g_object_set_data_full(G_OBJECT(menu), "path", g_strdup(path), g_free);

    /* Scan the specified directory to populate the menu with its subdirectories. */
    DirectoryName * dir_list = NULL;
    GDir * dir = g_dir_open(path, 0, NULL);
    if (dir != NULL)
    {
        const char * name;
        while ((name = g_dir_read_name(dir)) != NULL)	/* Memory owned by glib */
        {
            /* Omit hidden files. */
            if (name[0] != '.')
            {
                char * full = g_build_filename(path, name, NULL);
                if (g_file_test(full, G_FILE_TEST_IS_DIR))
                {
                    /* Convert name to UTF-8 and to the collation key. */
                    char * directory_name = g_filename_display_name(name);
                    char * directory_name_collate_key = g_utf8_collate_key(directory_name, -1);

                    /* Locate insertion point. */
                    DirectoryName * dir_pred = NULL;
                    DirectoryName * dir_cursor;
                    for (dir_cursor = dir_list; dir_cursor != NULL; dir_pred = dir_cursor, dir_cursor = dir_cursor->flink)
                    {
                        if (strcmp(directory_name_collate_key, dir_cursor->directory_name_collate_key) <= 0)
                            break;
                    }

                    /* Allocate and initialize sorted directory name entry. */
                    dir_cursor = g_new0(DirectoryName, 1);
                    dir_cursor->directory_name = directory_name;
                    dir_cursor->directory_name_collate_key = directory_name_collate_key;
                    if (dir_pred == NULL)
                    {
                        dir_cursor->flink = dir_list;
                        dir_list = dir_cursor;
                    }
                    else
                    {
                        dir_cursor->flink = dir_pred->flink;
                        dir_pred->flink = dir_cursor;
                    }
                }
                g_free(full);
            }
        }
        g_dir_close(dir);
    }

    /* The sorted directory name list is complete.  Loop to create the menu. */
    DirectoryName * dir_cursor;
    while ((dir_cursor = dir_list) != NULL)
    {
        /* Create and initialize menu item. */
        GtkWidget * item = gtk_image_menu_item_new_with_label(dir_cursor->directory_name);
        gtk_image_menu_item_set_image(
            GTK_IMAGE_MENU_ITEM(item),
            gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU));
        GtkWidget * dummy = gtk_menu_new();
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), dummy);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

        /* Unlink and free sorted directory name element, but reuse the directory name string. */
        dir_list = dir_cursor->flink;
        g_object_set_data_full(G_OBJECT(item), "name", dir_cursor->directory_name, g_free);
        g_free(dir_cursor->directory_name_collate_key);
        g_free(dir_cursor);

        /* Connect signals. */
        g_signal_connect(G_OBJECT(item), "select", G_CALLBACK(dirmenu_menuitem_select), dm);
        g_signal_connect(G_OBJECT(item), "deselect", G_CALLBACK(dirmenu_menuitem_deselect), dm);
    }

    /* Create "Open" and "Open in Terminal" items. */
    GtkWidget * item = gtk_image_menu_item_new_from_stock( GTK_STOCK_OPEN, NULL );
    g_signal_connect(item, "activate", G_CALLBACK(dirmenu_menuitem_open_directory), dm);
    GtkWidget * term = gtk_menu_item_new_with_mnemonic( _("Open in _Terminal") );
    g_signal_connect(term, "activate", G_CALLBACK(dirmenu_menuitem_open_in_terminal), dm);

    /* Insert or append based on caller's preference. */
    if (open_at_top)
    {
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new(), 0);
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), term, 0);
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, 0);
    }
    else {
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), term);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
    }

    /* Show the menu and return. */
    gtk_widget_show_all(menu);
    return menu;
}
コード例 #8
0
ファイル: applet.c プロジェクト: mate-desktop/mate-panel
static void
add_to_submenus (AppletInfo *info,
		 const char *path,
		 const char *name,
		 AppletUserMenu *menu,
		 GtkWidget *submenu,
		 GList *user_menu)
{
	char *n = g_strdup (name);
	char *p = strchr (n, '/');
	char *t;
	AppletUserMenu *s_menu;

	/*this is the last one*/
	if (p == NULL) {
		g_free (n);
		setup_an_item (menu, submenu, FALSE);
		return;
	}

	/*this is the last one and we are a submenu, we have already been
	  set up*/
	if(p==(n + strlen(n) - 1)) {
		g_free(n);
		return;
	}

	*p = '\0';
	p++;

	t = g_strconcat (path, n, "/", NULL);
	s_menu = mate_panel_applet_get_callback (user_menu, t);
	/*the user did not give us this sub menu, whoops, will create an empty
	  one then*/
	if (s_menu == NULL) {
		s_menu = g_new0 (AppletUserMenu,1);
		s_menu->name = g_strdup (t);
		s_menu->gicon = NULL;
		s_menu->text = g_strdup (_("???"));
		s_menu->sensitive = TRUE;
		s_menu->info = info;
		s_menu->menuitem = NULL;
		s_menu->submenu = NULL;
		info->user_menu = g_list_append (info->user_menu,s_menu);
		user_menu = info->user_menu;
	}

	if (s_menu->submenu == NULL) {
		s_menu->submenu = gtk_menu_new ();
		/*a more elegant way to do this should be done
		  when I don't want to go to sleep */
		if (s_menu->menuitem != NULL) {
			gtk_widget_destroy (s_menu->menuitem);
			s_menu->menuitem = NULL;
		}
	}
	if (s_menu->menuitem == NULL)
		setup_an_item (s_menu, submenu, TRUE);

	add_to_submenus (info, t, p, menu, s_menu->submenu, user_menu);

	g_free(t);
	g_free(n);
}
コード例 #9
0
ファイル: applet.c プロジェクト: mate-desktop/mate-panel
GtkWidget *
mate_panel_applet_create_menu (AppletInfo *info)
{
	GtkWidget   *menu;
	GtkWidget   *menuitem;
	GList       *l;
	PanelWidget *panel_widget;
	gboolean     added_anything = FALSE;

	panel_widget = mate_panel_applet_get_panel_widget (info);

	menu = g_object_ref_sink (gtk_menu_new ());

	gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);

	/* connect the show & deactivate signal, so that we can "disallow" and
	 * "re-allow" autohide when the menu is shown/deactivated.
	 */
	g_signal_connect (menu, "show",
			  G_CALLBACK (applet_menu_show), info);
	g_signal_connect (menu, "deactivate",
			  G_CALLBACK (applet_menu_deactivate), info);

	for (l = info->user_menu; l; l = l->next) {
		AppletUserMenu *user_menu = l->data;

		if (user_menu->is_enabled_func && !user_menu->is_enabled_func ())
			continue;

		add_to_submenus (info, "", user_menu->name, user_menu,
				 menu, info->user_menu);

		added_anything = TRUE;
	}

	if (!panel_lockdown_get_locked_down ()) {
		gboolean   locked;
		gboolean   lockable;
		gboolean   movable;
		gboolean   removable;

		lockable = mate_panel_applet_lockable (info);
		movable = mate_panel_applet_can_freely_move (info);
		removable = panel_profile_id_lists_are_writable ();

		locked = panel_widget_get_applet_locked (panel_widget, info->widget);

		if (added_anything) {
			menuitem = gtk_separator_menu_item_new ();
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
			gtk_widget_show (menuitem);
		}

		menuitem = panel_image_menu_item_new_from_icon ("list-remove", _("_Remove From Panel"));

		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (applet_remove_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, (!locked || lockable) && removable);

		menuitem = panel_image_menu_item_new_from_icon (NULL, _("_Move"));

		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (move_applet_callback), info);
		gtk_widget_show (menuitem);
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, !locked && movable);

		g_assert (info->move_item == NULL);

		info->move_item = menuitem;
		g_object_add_weak_pointer (G_OBJECT (menuitem),
					   (gpointer *) &info->move_item);

		menuitem = gtk_separator_menu_item_new ();
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_show (menuitem);

		menuitem = gtk_check_menu_item_new_with_mnemonic (_("Loc_k To Panel"));

		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
						locked);

		g_signal_connect (menuitem, "map",
				  G_CALLBACK (checkbox_status), info);

		menuitem = panel_check_menu_item_new (menuitem);

		g_signal_connect (menuitem, "activate",
				  G_CALLBACK (mate_panel_applet_lock), info);

		gtk_widget_show (menuitem);

		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
		gtk_widget_set_sensitive (menuitem, lockable);

		added_anything = TRUE;
	}

	if ( ! added_anything) {
		g_object_unref (menu);
		return NULL;
	}

/* Set up theme and transparency support */
	GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
	GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
	GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); 
/* Set menu and it's toplevel window to follow panel theme */
	GtkStyleContext *context;
	context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
	gtk_style_context_add_class(context,"gnome-panel-menu-bar");
	gtk_style_context_add_class(context,"mate-panel-menu-bar");

	return menu;
}
コード例 #10
0
ファイル: guis.cpp プロジェクト: KeithDHedger/ManPageEditor
void buildMainGui(void)
{
	GtkWidget*					vbox;
	GtkWidget*					menuitem;
	GtkWidget*					menu;
	GtkWidget*					toolbar;
	GtkToolItem*				toolbutton;
	GtkAccelGroup*				accgroup;
	GtkWidget*					image;

	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title((GtkWindow*)window,"Manpage Editor");
	gtk_window_set_default_size((GtkWindow*)window,windowWidth,windowHeight);
	if(windowX!=-1 && windowY!=-1)
		gtk_window_move((GtkWindow *)window,windowX,windowY);

	g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(doShutdown),NULL);
	accgroup=gtk_accel_group_new();
	gtk_window_add_accel_group((GtkWindow*)window,accgroup);

	notebook=(GtkNotebook*)gtk_notebook_new();
	gtk_notebook_set_scrollable(notebook,true);
	g_signal_connect(G_OBJECT(notebook),"page-reordered",G_CALLBACK(reorderDirty),NULL);

	vbox=creatNewBox(NEWVBOX,false,0);

	menubar=gtk_menu_bar_new();
	toolbar=gtk_toolbar_new();

	gtk_box_pack_start(GTK_BOX(vbox),(GtkWidget*)menubar,false,true,0);
	gtk_box_pack_start(GTK_BOX(vbox),(GtkWidget*)toolbar,false,true,0);
	gtk_box_pack_start(GTK_BOX(vbox),(GtkWidget*)notebook,true,true,0);

//toolbar
//new
	newButton=makeNewToolItem(GTK_STOCK_NEW,"New");
	gtk_toolbar_insert((GtkToolbar*)toolbar,newButton,-1);
	g_signal_connect(G_OBJECT(newButton),"clicked",G_CALLBACK(newSection),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)newButton,"New File");

//save
	saveButton=makeNewToolItem(GTK_STOCK_SAVE,"Save");
	gtk_toolbar_insert((GtkToolbar*)toolbar,saveButton,-1);
	g_signal_connect(G_OBJECT(saveButton),"clicked",G_CALLBACK(saveManpage),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)saveButton,"Save File");

	gtk_toolbar_insert((GtkToolbar*)toolbar,gtk_separator_tool_item_new(),-1);

//edit buttons
//cut
	toolbutton=makeNewToolItem(GTK_STOCK_CUT,"Cut");
	gtk_toolbar_insert((GtkToolbar*)toolbar,toolbutton,-1);
	g_signal_connect(G_OBJECT(toolbutton),"clicked",G_CALLBACK(cutToClip),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)toolbutton,"Cut");
//copy
	toolbutton=makeNewToolItem(GTK_STOCK_COPY,"Copy");
	gtk_toolbar_insert((GtkToolbar*)toolbar,toolbutton,-1);
	g_signal_connect(G_OBJECT(toolbutton),"clicked",G_CALLBACK(copyToClip),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)toolbutton,"Copy");
//paste
	toolbutton=makeNewToolItem(GTK_STOCK_PASTE,"Paste");
	gtk_toolbar_insert((GtkToolbar*)toolbar,toolbutton,-1);
	g_signal_connect(G_OBJECT(toolbutton),"clicked",G_CALLBACK(pasteFromClip),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)toolbutton,"Paste");

	gtk_toolbar_insert((GtkToolbar*)toolbar,gtk_separator_tool_item_new(),-1);

//undo
	undoButton=makeNewToolItem(GTK_STOCK_UNDO,"Undo");
	gtk_toolbar_insert((GtkToolbar*)toolbar,undoButton,-1);
	g_signal_connect(G_OBJECT(undoButton),"clicked",G_CALLBACK(undo),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)undoButton,"Undo");
//redo
	redoButton=makeNewToolItem(GTK_STOCK_REDO,"Redo");
	gtk_toolbar_insert((GtkToolbar*)toolbar,redoButton,-1);
	g_signal_connect(G_OBJECT(redoButton),"clicked",G_CALLBACK(redo),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)redoButton,"Redo");
	gtk_toolbar_insert((GtkToolbar*)toolbar,gtk_separator_tool_item_new(),-1);

//find
	toolbutton=makeNewToolItem(GTK_STOCK_FIND,"Find");
	gtk_toolbar_insert((GtkToolbar*)toolbar,toolbutton,-1);
	g_signal_connect(G_OBJECT(toolbutton),"clicked",G_CALLBACK(find),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)toolbutton,"Find/Replace");

//livesearch
	liveSearchWidget=gtk_entry_new();
	toolbutton=gtk_tool_item_new();
	gtk_container_add((GtkContainer *)toolbutton,liveSearchWidget);
	gtk_toolbar_insert((GtkToolbar*)toolbar,toolbutton,-1);
	g_signal_connect_after(G_OBJECT(liveSearchWidget),"key-release-event",G_CALLBACK(doLiveSearch),NULL);
	gtk_widget_set_tooltip_text((GtkWidget*)toolbutton,"Live Search");

//menus
//file menu
	menufile=gtk_menu_item_new_with_label("File");
	menu=gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menufile),menu);
//new
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_New");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(newManpage),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'N',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//newsection
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("New Section");
#else
	menuitem=gtk_image_menu_item_new_with_label("New Section");
	image=gtk_image_new_from_stock(GTK_STOCK_NEW,GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(newSection),NULL);

//open
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Open");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(openManpage),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'O',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//open recent menu
	menuitem=gtk_menu_item_new_with_mnemonic("_Recent");
	setupRecent((GtkMenuItem*)menuitem);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//newtemplate
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_label("New From Template");
#else
	menuitem=gtk_image_menu_item_new_with_label("New From Template");
	image=gtk_image_new_from_stock(GTK_STOCK_NEW,GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(openManpage),(void*)1);

//new editor
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_label("New Editor");
#else
	menuitem=gtk_image_menu_item_new_with_label("New Editor");
	image=gtk_image_new_from_stock(GTK_STOCK_NEW,GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(newEditor),NULL);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//save
#ifdef _USEGTK3_
	saveMenu=gtk_menu_item_new_with_mnemonic("_Save");
#else
	saveMenu=gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),saveMenu);
	g_signal_connect(G_OBJECT(saveMenu),"activate",G_CALLBACK(saveManpage),NULL);
	gtk_widget_add_accelerator((GtkWidget *)saveMenu,"activate",accgroup,'S',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//save as
#ifdef _USEGTK3_
	saveAsMenu=gtk_menu_item_new_with_label("Save As");
#else
	saveAsMenu=gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),saveAsMenu);
	g_signal_connect(G_OBJECT(saveAsMenu),"activate",G_CALLBACK(saveAs),NULL);
	gtk_widget_set_sensitive((GtkWidget*)saveAsMenu,false);

//export
#ifdef _USEGTK3_
	exportMenu=gtk_menu_item_new_with_label("Export Man Page");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_CONVERT,GTK_ICON_SIZE_MENU);
	exportMenu=gtk_image_menu_item_new_with_label("Export Man Page");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)exportMenu,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),exportMenu);
	g_signal_connect(G_OBJECT(exportMenu),"activate",G_CALLBACK(exportFile),NULL);

//export as
#ifdef _USEGTK3_
	exportAsMenu=gtk_menu_item_new_with_label("Export As");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_CONVERT,GTK_ICON_SIZE_MENU);
	exportAsMenu=gtk_image_menu_item_new_with_label("Export As");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)exportAsMenu,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),exportAsMenu);
	g_signal_connect(G_OBJECT(exportAsMenu),"activate",G_CALLBACK(exportFile),(void*)1);

//import
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_label("Import Manpage");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_OPEN,GTK_ICON_SIZE_MENU);
	menuitem=gtk_image_menu_item_new_with_label("Import Manpage");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(importManpage),NULL);

//import sysmanpage
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_label("Import System Manpage");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_OPEN,GTK_ICON_SIZE_MENU);
	menuitem=gtk_image_menu_item_new_with_label("Import System Manpage");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(importManpage),(void*)1);

//preview
#ifdef _USEGTK3_
	previewMenu=gtk_menu_item_new_with_label("Preview Page");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_FIND,GTK_ICON_SIZE_MENU);
	previewMenu=gtk_image_menu_item_new_with_label("Preview Page");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)previewMenu,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),previewMenu);
	g_signal_connect(G_OBJECT(previewMenu),"activate",G_CALLBACK(previewPage),NULL);

//properties
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_label("Properties");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_PROPERTIES,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(redoProps),NULL);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//printmanpage
#ifdef _USEGTK3_
	menuprint=gtk_menu_item_new_with_label("Print Manpage to LP");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_PRINT,GTK_ICON_SIZE_MENU);
	menuprint=gtk_image_menu_item_new_with_label("Print Manpage to LP");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuprint,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuprint);
	g_signal_connect(G_OBJECT(menuprint),"activate",G_CALLBACK(printFile),(void*)1);

//print manpage to pdf
#ifdef _USEGTK3_
	menuprint=gtk_menu_item_new_with_label("Print Manpage To PDF");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_PRINT,GTK_ICON_SIZE_MENU);
	menuprint=gtk_image_menu_item_new_with_label("Print Manpage To PDF");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)menuprint,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuprint);
	g_signal_connect(G_OBJECT(menuprint),"activate",G_CALLBACK(printFile),(void*)2);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//close
#ifdef _USEGTK3_
	menuclose=gtk_menu_item_new_with_mnemonic("_Close");
#else
	menuclose=gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuclose);
	g_signal_connect(G_OBJECT(menuclose),"activate",G_CALLBACK(closePage),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuclose,"activate",accgroup,'W',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//close section
#ifdef _USEGTK3_
	closeSectionMenu=gtk_menu_item_new_with_label("Delete Section");
#else
	image=gtk_image_new_from_stock(GTK_STOCK_DELETE,GTK_ICON_SIZE_MENU);
	closeSectionMenu=gtk_image_menu_item_new_with_label("Delete Section");
	gtk_image_menu_item_set_image((GtkImageMenuItem *)closeSectionMenu,image);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),closeSectionMenu);
	g_signal_connect(G_OBJECT(closeSectionMenu),"activate",G_CALLBACK(deleteSection),NULL);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
//quit
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Quit");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doShutdown),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'Q',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//edit menu
	menuedit=gtk_menu_item_new_with_label("Edit");
	menu=gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuedit),menu);
//undo
#ifdef _USEGTK3_
	undoMenu=gtk_menu_item_new_with_mnemonic("_Undo");
#else
	undoMenu=gtk_image_menu_item_new_from_stock(GTK_STOCK_UNDO,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),undoMenu);
	g_signal_connect(G_OBJECT(undoMenu),"activate",G_CALLBACK(undo),NULL);
	gtk_widget_add_accelerator((GtkWidget *)undoMenu,"activate",accgroup,'Z',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//redo
#ifdef _USEGTK3_
	redoMenu=gtk_menu_item_new_with_mnemonic("_Redo");
#else
	redoMenu=gtk_image_menu_item_new_from_stock(GTK_STOCK_REDO,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),redoMenu);
	g_signal_connect(G_OBJECT(redoMenu),"activate",G_CALLBACK(redo),NULL);
	gtk_widget_add_accelerator((GtkWidget *)redoMenu,"activate",accgroup,'Z',(GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK),GTK_ACCEL_VISIBLE);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//cut
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Cut");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(cutToClip),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'X',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//copy
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Copy");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(copyToClip),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'C',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

//paste
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Paste");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(pasteFromClip),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'V',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//find
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Find");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_FIND,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(find),NULL);
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,'F',GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);

	menuitem=gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

//prefs
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Preferences");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doPrefs),NULL);

//formattin menu
	menuformat=gtk_menu_item_new_with_label("Formating");
	menu=gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuformat),menu);
//bold
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Bold");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_BOLD,NULL);
#endif
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,GDK_KEY_B,(GdkModifierType)GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doFormat),(void*)BOLD);
//italic
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Italic");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_ITALIC,NULL);
#endif
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,GDK_KEY_I,(GdkModifierType)GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doFormat),(void*)ITALIC);
//normal
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Clear");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR,NULL);
#endif
	gtk_widget_add_accelerator((GtkWidget *)menuitem,"activate",accgroup,GDK_KEY_R,(GdkModifierType)GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doFormat),(void*)NORMAL);

//help
	menuhelp=gtk_menu_item_new_with_label("Help");
	menu=gtk_menu_new();
//about
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuhelp),menu);
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_About");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL);
#endif
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(doAbout),NULL);
//help
#ifdef _USEGTK3_
	menuitem=gtk_menu_item_new_with_mnemonic("_Help");
#else
	menuitem=gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP,NULL);
#endif
	g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(openHelp),NULL);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);

	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),menufile);
	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),menuedit);
	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),menuformat);
	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),menuhelp);

	gtk_container_add(GTK_CONTAINER(window),(GtkWidget*)vbox);
	gtk_widget_set_sensitive((GtkWidget*)saveButton,false);
	gtk_widget_set_sensitive((GtkWidget*)saveMenu,false);
}
コード例 #11
0
ファイル: drqm_jobs_blender.c プロジェクト: Hyask/drqueue
GtkWidget *
dnj_koj_frame_blender (struct drqm_jobs_info *info) {
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox,*hbox2;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *button;
  GtkWidget *bbox;
  GtkWidget *rt_menu;
  GtkWidget *rt_omenu;
  GtkWidget *rt_menuitem1;
  const gchar *rt_menuitem1_text;
  GtkWidget *rt_menuitem2;
  const gchar *rt_menuitem2_text;
  GtkTooltips *tooltips;

  tooltips = TooltipsNew ();

  /* Frame */
  frame = gtk_frame_new ("Blender job information");

  /* Main vbox */
  vbox = gtk_vbox_new (FALSE,2);
  gtk_container_add (GTK_CONTAINER(frame),vbox);

  /* Scene file */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Scene file:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  info->dnj.koji_blender.escene = entry;
  gtk_tooltips_set_tip(tooltips,entry,"File name of the blender scene file that should be rendered",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the blender scene file",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_blender_scene_search),&info->dnj.koji_blender);

  /* View command */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("View command:");
  gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,2);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Command that will be executed when you select 'Watch image' "
                       "in the frames list (inside the detailed job view)",NULL);
  info->dnj.koji_blender.eviewcmd = entry;
  gtk_entry_set_text(GTK_ENTRY(entry),KOJ_BLENDER_DFLT_VIEWCMD);
  gtk_box_pack_start (GTK_BOX(hbox),entry,TRUE,TRUE,2);

  /* Script directory */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Script directory:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  entry = gtk_entry_new_with_max_length (BUFFERLEN-1);
  gtk_tooltips_set_tip(tooltips,entry,"Directory in which, in case of using the automatic "
                       "script generator, the command script will be saved.",NULL);
  info->dnj.koji_blender.escript = entry;
  gtk_entry_set_text (GTK_ENTRY(entry),blendersg_default_script_path());
  gtk_box_pack_start (GTK_BOX(hbox2),entry,TRUE,TRUE,2);
  button = gtk_button_new_with_label ("Search");
  gtk_tooltips_set_tip(tooltips,button,"File selector for the script directory",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),button,FALSE,FALSE,2);
  g_signal_connect (G_OBJECT(button),"clicked",
                    G_CALLBACK(dnj_koj_frame_blender_script_search),&info->dnj.koji_blender);

  /* Render type */
  hbox = gtk_hbox_new (TRUE,2);
  gtk_box_pack_start (GTK_BOX(vbox),hbox,FALSE,FALSE,2);
  label = gtk_label_new ("Render type:");
  gtk_box_pack_start (GTK_BOX(hbox),label,TRUE,TRUE,2);
  hbox2 = gtk_hbox_new (FALSE,0);
  gtk_box_pack_start (GTK_BOX(hbox),hbox2,TRUE,TRUE,0);
  
  rt_omenu = gtk_option_menu_new ();
  rt_menu = gtk_menu_new ();
  rt_menuitem1_text = "animation";
  rt_menuitem1 = gtk_menu_item_new_with_label (rt_menuitem1_text);
  gtk_menu_append (GTK_MENU(rt_menu), rt_menuitem1);
  rt_menuitem2_text = "single image";
  rt_menuitem2 = gtk_menu_item_new_with_label (rt_menuitem2_text);
  gtk_menu_append (GTK_MENU(rt_menu), rt_menuitem2);
  gtk_option_menu_set_menu (GTK_OPTION_MENU(rt_omenu), rt_menu);
  
  gtk_tooltips_set_tip(tooltips,rt_omenu,"Choose 'animation' for computing whole frames each task. "
  							"Choose 'single image' for distributed computing of single images.",NULL);
  gtk_box_pack_start (GTK_BOX(hbox2),rt_omenu,TRUE,TRUE,0);
  g_signal_connect (G_OBJECT(rt_menuitem1),"activate",
                    GTK_SIGNAL_FUNC (dnj_koj_frame_blender_menuitem_response), &info->dnj.koji_blender);
  g_signal_connect (G_OBJECT(rt_menuitem2),"activate",
                    GTK_SIGNAL_FUNC (dnj_koj_frame_blender_menuitem_response), &info->dnj.koji_blender);
  

  /* Buttons */
  /* Create script */
  bbox = gtk_hbutton_box_new ();
  gtk_box_pack_start (GTK_BOX(vbox),bbox,TRUE,TRUE,5);
  gtk_widget_show (bbox);
  button = gtk_button_new_with_label ("Create Script");
  gtk_tooltips_set_tip(tooltips,button,"Create automagically the script based on the given information",NULL);
  gtk_box_pack_start (GTK_BOX(bbox),button,TRUE,TRUE,2);
  switch (info->dnj.koj) {
  case KOJ_BLENDER:
    g_signal_connect (G_OBJECT(button),"clicked",
                      G_CALLBACK(dnj_koj_frame_blender_bcreate_pressed),&info->dnj);
    break;
  default:
    fprintf (stderr,"What ?!\n");
    break;
  }

  gtk_widget_show_all(frame);

  return frame;
}
コード例 #12
0
GtkWidget	*create_dialogAudioCodec (void)
{
    GtkWidget *dialogAudioCodec;
    GtkWidget *dialog_vbox1;
    GtkWidget *vbox1;
    GtkWidget *optionmenu_CodecList;
    GtkWidget *menu1;
    GtkWidget *uncompressed;
    GtkWidget *ffmpeg_mpeg_audio;
    GtkWidget *ffmpeg_ac3_2_channels1;
#ifdef HAVE_LIBMP3LAME
    GtkWidget *lame_mp1;
#endif
#ifdef USE_VORBIS
    GtkWidget *vorbis;
#endif

#ifdef USE_FAAC
    GtkWidget *faac;
#endif
    GtkWidget *toolame,*libtoolame;
    GtkWidget *buttonConfigure;
    GtkWidget *dialog_action_area1;
    GtkWidget *cancelbutton1;
    GtkWidget *okbutton1;
    GtkWidget *acodec[10];
    int acodecNb=0;

    dialogAudioCodec = gtk_dialog_new ();
    gtk_window_set_title (GTK_WINDOW (dialogAudioCodec), _("AudioCodec"));

    dialog_vbox1 = GTK_DIALOG (dialogAudioCodec)->vbox;
    gtk_widget_show (dialog_vbox1);

    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox1);
    gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);

    optionmenu_CodecList = gtk_option_menu_new ();
    gtk_widget_show (optionmenu_CodecList);
    gtk_box_pack_start (GTK_BOX (vbox1), optionmenu_CodecList, FALSE, FALSE, 0);

    menu1 = gtk_menu_new ();

    /***************/
    for(int i=0; i<sizeof(myCodecList)/sizeof(CODECLIST); i++)
    {
        acodec[i]=gtk_menu_item_new_with_mnemonic(myCodecList[i].menuName);
        gtk_widget_show(acodec[i]);
        gtk_container_add(GTK_CONTAINER(menu1),acodec[i]);
    }
    /***************/
    gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_CodecList), menu1);

    buttonConfigure = gtk_button_new_with_mnemonic (_("Configure codec"));
    gtk_widget_show (buttonConfigure);
    gtk_box_pack_start (GTK_BOX (vbox1), buttonConfigure, FALSE, FALSE, 0);

    dialog_action_area1 = GTK_DIALOG (dialogAudioCodec)->action_area;
    gtk_widget_show (dialog_action_area1);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

    cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
    gtk_widget_show (cancelbutton1);
    gtk_dialog_add_action_widget (GTK_DIALOG (dialogAudioCodec), cancelbutton1, GTK_RESPONSE_CANCEL);
    GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);

    okbutton1 = gtk_button_new_from_stock ("gtk-ok");
    gtk_widget_show (okbutton1);
    gtk_dialog_add_action_widget (GTK_DIALOG (dialogAudioCodec), okbutton1, GTK_RESPONSE_OK);
    GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

    /* Store pointers to all widgets, for use by lookup_widget(). */
    GLADE_HOOKUP_OBJECT_NO_REF (dialogAudioCodec, dialogAudioCodec, "dialogAudioCodec");
    GLADE_HOOKUP_OBJECT_NO_REF (dialogAudioCodec, dialog_vbox1, "dialog_vbox1");
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, vbox1, "vbox1");
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, optionmenu_CodecList, "optionmenu_CodecList");
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, menu1, "menu1");
    /****/
    for(int i=0; i<sizeof(myCodecList)/sizeof(CODECLIST); i++)
    {
        GLADE_HOOKUP_OBJECT (dialogAudioCodec, acodec[i],myCodecList[i].name );
    }

    /****/
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, buttonConfigure, "buttonConfigure");
    GLADE_HOOKUP_OBJECT_NO_REF (dialogAudioCodec, dialog_action_area1, "dialog_action_area1");
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, cancelbutton1, "cancelbutton1");
    GLADE_HOOKUP_OBJECT (dialogAudioCodec, okbutton1, "okbutton1");
    gtk_signal_connect(GTK_OBJECT(buttonConfigure), "clicked",
                       GTK_SIGNAL_FUNC(okCallback),                   (void *) 0);
    return dialogAudioCodec;
}
コード例 #13
0
static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *event, VikViewport *vvp )
{
  VikCoord coord;
  static struct LatLon ll;

  gchar *full_path;
  gchar *dem_file = NULL;

  vik_viewport_screen_to_coord ( vvp, event->x, event->y, &coord );
  vik_coord_to_latlon ( &coord, &ll );

  
  if ( vdl->source == DEM_SOURCE_SRTM )
    dem_file = srtm_lat_lon_to_dest_fn ( ll.lat, ll.lon );
#ifdef VIK_CONFIG_DEM24K
  else if ( vdl->source == DEM_SOURCE_DEM24K )
    dem_file = dem24k_lat_lon_to_dest_fn ( ll.lat, ll.lon );
#endif

  if ( ! dem_file )
    return TRUE;

  full_path = g_strdup_printf("%s%s", MAPS_CACHE_DIR, dem_file );

  g_debug("%s: %s", __FUNCTION__, full_path);

  if ( event->button == 1 ) {
    // TODO: check if already in filelist
    if ( ! dem_layer_add_file(vdl, full_path) ) {
      gchar *tmp = g_strdup_printf ( _("Downloading DEM %s"), dem_file );
      DEMDownloadParams *p = g_malloc(sizeof(DEMDownloadParams));
      p->dest = g_strdup(full_path);
      p->lat = ll.lat;
      p->lon = ll.lon;
      p->vdl = vdl;
      p->mutex = g_mutex_new();
      p->source = vdl->source;
      g_object_weak_ref(G_OBJECT(p->vdl), weak_ref_cb, p );

      a_background_thread ( VIK_GTK_WINDOW_FROM_LAYER(vdl), tmp,
                            (vik_thr_func) dem_download_thread, p,
                            (vik_thr_free_func) free_dem_download_params, NULL, 1 );

      g_free ( tmp );
    }
    else
      vik_layer_emit_update ( VIK_LAYER(vdl) );
  }
  else {
    if ( !vdl->right_click_menu ) {
      GtkWidget *item;
      vdl->right_click_menu = GTK_MENU ( gtk_menu_new () );

      item = gtk_image_menu_item_new_with_mnemonic ( _("_Show DEM File Information") );
      gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU) );
      g_signal_connect ( G_OBJECT(item), "activate", G_CALLBACK(dem_layer_file_info), &ll );
      gtk_menu_shell_append (GTK_MENU_SHELL(vdl->right_click_menu), item);
    }

    gtk_menu_popup ( vdl->right_click_menu, NULL, NULL, NULL, NULL, event->button, event->time );
    gtk_widget_show_all ( GTK_WIDGET(vdl->right_click_menu) );
  }

  g_free ( dem_file );
  g_free ( full_path );

  return TRUE;
}
コード例 #14
0
ファイル: spellcheck.c プロジェクト: zakkudo/gwaei
void 
gw_spellcheck_populate_popup (GwSpellcheck *spellcheck, 
                              GtkMenu      *menu)
{
    //Sanity checks
    g_return_if_fail (spellcheck != NULL);
    g_return_if_fail (menu != NULL);

    //Declarations
    GwSpellcheckPrivate *priv = NULL;
    GtkWidget *menuitem = NULL, *spellmenuitem = NULL;
    GtkWidget *spellmenu = NULL;

    gint index;
    gint xoffset, yoffset, x, y;
    gint start_offset, end_offset;
    gint i;
    gchar **iter = NULL;

    LwMorphologyEngine *morphologyengine = NULL;

    //Initializations
    priv = spellcheck->priv;
    if (priv->tokens == NULL) return;
    morphologyengine = gw_application_get_morphologyengine (priv->application);
    g_return_if_fail (morphologyengine != NULL);

    xoffset = gw_spellcheck_get_layout_x_offset (spellcheck);
    yoffset = gw_spellcheck_get_layout_y_offset (spellcheck);
    x = priv->x - xoffset;
    y = priv->y - yoffset; //Since a GtkEntry is single line, we want the y to always be in the area
    index =  _get_string_index (priv->entry, x, y);

    start_offset = 0;
    iter = priv->tokens;
    while (*iter != NULL && start_offset + strlen(*iter) < index)
    {
      start_offset += strlen(*iter) + 1;
      iter++;
    }
    if (*iter == NULL) return;
    end_offset = start_offset + strlen(*iter);

    LwMorphologyList *morphologylist = NULL;
    LwMorphology *morphology = NULL;
    gchar **suggestions = NULL;

    morphologylist = lw_morphologyengine_analyze (morphologyengine, *iter, TRUE); if (morphologylist == NULL) goto errored;
    morphology = lw_morphologylist_read (morphologylist); if (morphology == NULL) goto errored;

    if (morphology->spellcheck != NULL)
    {
      suggestions = g_strsplit (morphology->spellcheck, LW_MORPHOLOGY_SPELLCHECK_DELIMITOR, -1);
      gsize total_suggestions = g_strv_length (suggestions);

      if (total_suggestions > 0 && suggestions != NULL)
      {
        menuitem = gtk_separator_menu_item_new ();
        gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
        gtk_widget_show (menuitem);

        spellmenu = gtk_menu_new ();
        spellmenuitem = gtk_menu_item_new_with_label (gettext("_Spellcheck"));
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (spellmenuitem), spellmenu);
        gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), spellmenuitem);
        gtk_widget_show (spellmenuitem);

        gchar *text = g_strdup_printf (gettext("Add \"%s\" to the dictionary"), *iter);
        if (text != NULL)
        {
          GtkWidget *image = gtk_image_new_from_icon_name ("gtk-add", GTK_ICON_SIZE_MENU);
          menuitem = gtk_menu_item_new_with_label (text);
          g_object_set_data_full (G_OBJECT (menuitem), "word", g_strdup (*iter), g_free);
          g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (gw_spellcheck_add_menuitem_activated_cb), spellcheck);
          gtk_menu_shell_append (GTK_MENU_SHELL (spellmenu), menuitem);
          g_free (text); text = NULL;
          gtk_widget_show (menuitem);
        }

        menuitem = gtk_separator_menu_item_new ();
        gtk_menu_shell_append (GTK_MENU_SHELL (spellmenu), menuitem);
        gtk_widget_show (menuitem);

        //Menuitems
        for (i = 0; i < total_suggestions; i++)
        {
          menuitem = gtk_menu_item_new_with_label (suggestions[i]);
          g_object_set_data (G_OBJECT (menuitem), "start-offset", GINT_TO_POINTER (start_offset));
          g_object_set_data (G_OBJECT (menuitem), "end-offset", GINT_TO_POINTER (end_offset));
          g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (gw_spellcheck_menuitem_activated_cb), spellcheck);
          gtk_widget_show (GTK_WIDGET (menuitem));
          gtk_menu_shell_append (GTK_MENU_SHELL (spellmenu), menuitem);
        }

      }
    }

errored:

    if (suggestions != NULL) g_strfreev (suggestions); suggestions = NULL;
    if (morphologylist != NULL) lw_morphologylist_free (morphologylist); morphologylist = NULL;
}
コード例 #15
0
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), NULL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 400, 500);
gtk_widget_show(window);

table = gtk_table_new(10, 10, TRUE);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_widget_show(table);

menubar = gtk_menu_bar_new();
gtk_table_attach_defaults(GTK_TABLE(table), menubar, 0, 10, 0, 1);
gtk_widget_show(menubar);

filemenu = gtk_menu_new();
gtk_widget_show(filemenu);

file = gtk_menu_item_new_with_label("File");
quit = gtk_menu_item_new_with_label("Quit");
gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
gtk_widget_show(quit);
gtk_widget_show(file);

view = gtk_text_view_new();
gtk_widget_show(view);

button = gtk_button_new_with_label("Send");
gtk_table_attach_defaults(GTK_TABLE(table), button, 8, 9, 9, 10);
コード例 #16
0
ファイル: vikaggregatelayer.c プロジェクト: gdt/viking
static void aggregate_layer_add_menu_items ( VikAggregateLayer *val, GtkMenu *menu, gpointer vlp )
{
  // Data to pass on in menu functions
  static gpointer data[2];
  data[0] = val;
  data[1] = vlp;

  GtkWidget *item = gtk_menu_item_new();
  gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
  gtk_widget_show ( item );

  GtkWidget *vis_submenu = gtk_menu_new ();
  item = gtk_menu_item_new_with_mnemonic ( _("_Visibility") );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), vis_submenu );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Show All") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_on), data );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Hide All") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_off), data );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("_Toggle") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_child_visible_toggle), data );
  gtk_menu_shell_append (GTK_MENU_SHELL (vis_submenu), item);
  gtk_widget_show ( item );

  GtkWidget *submenu_sort = gtk_menu_new ();
  item = gtk_image_menu_item_new_with_mnemonic ( _("_Sort") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU) );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu_sort );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Name _Ascending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_a2z), data );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Name _Descending") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_SORT_DESCENDING, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_sort_z2a), data );
  gtk_menu_shell_append ( GTK_MENU_SHELL(submenu_sort), item );
  gtk_widget_show ( item );

  item = gtk_menu_item_new_with_mnemonic ( _("_Statistics") );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_analyse), data );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_show ( item );

  item = gtk_image_menu_item_new_with_mnemonic ( _("Track _List...") );
  gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
  g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(aggregate_layer_track_list_dialog), data );
  gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
  gtk_widget_show ( item );
}
コード例 #17
0
/** \brief Create and run GtkSatModule popup menu.
 *  \param module The module that should have the popup menu attached to it.
 *
 * This function ctreates and executes a popup menu that is related to a
 * GtkSatModule widget. The module must be a valid GtkSatModule, since it makes
 * no sense whatsoever to have this kind of popup menu without a GtkSatModule
 * parent.
 *
 */
void gtk_sat_module_popup (GtkSatModule *module)
{
    GtkWidget *menu;        /* The pop-up menu */
    GtkWidget *satsubmenu;  /* Satellite selection submenu */
    GtkWidget *menuitem;    /* Widget used to create the menu items */
    GtkWidget *image;       /* Widget used to create menu item icons */
    
    /* misc variables */
    GList  *sats;
    sat_t  *sat;
    gchar  *buff;
    guint   i,n;



    if ((module == NULL) || !IS_GTK_SAT_MODULE (module)) {
        sat_log_log (SAT_LOG_LEVEL_ERROR,
                     _("%s:%d: %s called with NULL parameter!"),
                     __FILE__, __LINE__, __FUNCTION__);

        return;
    }

    menu = gtk_menu_new ();

    if (module->state == GTK_SAT_MOD_STATE_DOCKED) {

        menuitem = gtk_image_menu_item_new_with_label (_("Detach module"));
        buff = icon_file_name ("gpredict-notebook.png");
        image = gtk_image_new_from_file (buff);
        g_free (buff);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
        gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
        g_signal_connect (menuitem, "activate",
                          G_CALLBACK (docking_state_cb), module);
    }
    else {

        menuitem = gtk_image_menu_item_new_with_label (_("Attach module"));
        buff = icon_file_name ("gpredict-notebook.png");
        image = gtk_image_new_from_file (buff);
        g_free (buff);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
        gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
        g_signal_connect (menuitem, "activate",
                          G_CALLBACK (docking_state_cb), module);

    }

    if (module->state == GTK_SAT_MOD_STATE_FULLSCREEN) {

        menuitem = gtk_image_menu_item_new_with_label (_("Exit full screen"));
        image = gtk_image_new_from_stock (GTK_STOCK_LEAVE_FULLSCREEN,
                                          GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
        gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
        g_signal_connect (menuitem, "activate",
                          G_CALLBACK (screen_state_cb), module);
    }
    else {
        menuitem = gtk_image_menu_item_new_with_label (_("Full screen"));
        image = gtk_image_new_from_stock (GTK_STOCK_FULLSCREEN,
                                          GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
        gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
        g_signal_connect (menuitem, "activate",
                          G_CALLBACK (screen_state_cb), module);
    }

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* select satellite submenu */
    menuitem = gtk_menu_item_new_with_label(_("Select satellite"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
    
    satsubmenu = gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), satsubmenu);
    
    sats = g_hash_table_get_values(module->satellites);  
    sats = g_list_sort(sats , (GCompareFunc) sat_nickname_compare );

    n = g_list_length(sats);
    for (i = 0; i < n; i++) {
        sat = SAT(g_list_nth_data(sats, i));
        menuitem = gtk_menu_item_new_with_label(sat->nickname);
        g_object_set_data(G_OBJECT(menuitem), "catnum", GINT_TO_POINTER(sat->tle.catnr));
        g_signal_connect(menuitem, "activate", G_CALLBACK (sat_selected_cb), module);
        gtk_menu_shell_append(GTK_MENU_SHELL(satsubmenu), menuitem);
    }

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* sky at a glance */
    menuitem = gtk_image_menu_item_new_with_label (_("Sky at a glance"));
    buff = icon_file_name ("gpredict-planner-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate",
                      G_CALLBACK (sky_at_glance_cb), module);

    /* time manager */
    menuitem = gtk_image_menu_item_new_with_label (_("Time Controller"));
    buff = icon_file_name ("gpredict-clock-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate", G_CALLBACK (tmgr_cb), module);
    
    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* Radio Control */
    menuitem = gtk_image_menu_item_new_with_label (_("Radio Control"));
    buff = icon_file_name ("gpredict-oscilloscope-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate", G_CALLBACK (rigctrl_cb), module);
    
    /* Antenna Control */
    menuitem = gtk_image_menu_item_new_with_label (_("Antenna Control"));
    buff = icon_file_name ("gpredict-antenna-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate", G_CALLBACK (rotctrl_cb), module);

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* configure */
    menuitem = gtk_image_menu_item_new_with_label (_("Configure"));
    image = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES,
                                      GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate",
                      G_CALLBACK (config_cb), module);

    /* clone */
    menuitem = gtk_image_menu_item_new_with_label (_("Clone..."));
    image = gtk_image_new_from_stock (GTK_STOCK_COPY,
                                      GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate",
                      G_CALLBACK (clone_cb), module);

    /* separator */
    menuitem = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);

    /* delete module */
    menuitem = gtk_image_menu_item_new_with_label (_("Delete"));
    image = gtk_image_new_from_stock (GTK_STOCK_DELETE,
                                      GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate",
                      G_CALLBACK (delete_cb), module);

    /* close */
    menuitem = gtk_image_menu_item_new_with_label (_("Close"));
    image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
                                      GTK_ICON_SIZE_MENU);
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
    g_signal_connect (menuitem, "activate",
                      G_CALLBACK (close_cb), module);

    gtk_widget_show_all (menu);

    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
                    0, gdk_event_get_time (NULL));
}
コード例 #18
0
ファイル: nautilus-dnd.c プロジェクト: rn10950/FVWM95-Updated
/* Pops up a menu of actions to perform on dropped files */
GdkDragAction
nautilus_drag_drop_action_ask (GtkWidget *widget,
			       GdkDragAction actions)
{
	GtkWidget *menu;
	GtkWidget *menu_item;
	DropActionMenuData damd;
	
	/* Create the menu and set the sensitivity of the items based on the
	 * allowed actions.
	 */
	menu = gtk_menu_new ();
	gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));
	
	append_drop_action_menu_item (menu, _("_Move Here"),
				      GDK_ACTION_MOVE,
				      (actions & GDK_ACTION_MOVE) != 0,
				      &damd);

	append_drop_action_menu_item (menu, _("_Copy Here"),
				      GDK_ACTION_COPY,
				      (actions & GDK_ACTION_COPY) != 0,
				      &damd);
	
	append_drop_action_menu_item (menu, _("_Link Here"),
				      GDK_ACTION_LINK,
				      (actions & GDK_ACTION_LINK) != 0,
				      &damd);

	append_drop_action_menu_item (menu, _("Set as _Background"),
				      NAUTILUS_DND_ACTION_SET_AS_BACKGROUND,
				      (actions & NAUTILUS_DND_ACTION_SET_AS_BACKGROUND) != 0,
				      &damd);

	eel_gtk_menu_append_separator (GTK_MENU (menu));
	
	menu_item = gtk_menu_item_new_with_mnemonic (_("Cancel"));
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
	gtk_widget_show (menu_item);
	
	damd.chosen = 0;
	damd.loop = g_main_loop_new (NULL, FALSE);

	g_signal_connect (menu, "deactivate",
			  G_CALLBACK (menu_deactivate_callback),
			  &damd);
	
	gtk_grab_add (menu);
	
	gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
			NULL, NULL, 0, GDK_CURRENT_TIME);
	
	g_main_loop_run (damd.loop);

	gtk_grab_remove (menu);
	
	g_main_loop_unref (damd.loop);
	
	gtk_object_sink (GTK_OBJECT (menu));
	
	return damd.chosen;
}
コード例 #19
0
ファイル: common.c プロジェクト: henux/gtk-feed
/* Creates the singleton main menu object.  Subsequent calls will return
   the same menu object. */
GtkWidget *
get_main_menu ()
{ 
  static GtkWidget *main_menu = NULL;

  if (main_menu == NULL) {
    GtkWidget *item, *image;

    /* Menu object. */
    main_menu = gtk_menu_new ();

    /* Subscribe menu item. */
    image = g_object_new (GTK_TYPE_IMAGE,
                          "stock", GTK_STOCK_ADD,
                          "icon-size", GTK_ICON_SIZE_MENU,
                          NULL);

    item = gtk_image_menu_item_new_with_mnemonic ("_Subscribe");

    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item),
                                   image);

    gtk_menu_shell_append (GTK_MENU_SHELL(main_menu),
                           item);

    g_signal_connect (item,
                      "activate",
                      G_CALLBACK(on_main_subscribe),
                      NULL);

    /* Feeds menu item. */
    image = gtk_image_new_from_icon_name ("gtk-feed",
                                          GTK_ICON_SIZE_MENU);

    item = gtk_image_menu_item_new_with_mnemonic ("_Feeds");

    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item),
                                   image);

    gtk_menu_shell_append (GTK_MENU_SHELL(main_menu),
                           item);

    g_signal_connect (item,
                      "activate",
                      G_CALLBACK(on_main_feeds),
                      NULL);

    /* About menu item. */
    item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT,
                                               NULL);

    gtk_menu_shell_append (GTK_MENU_SHELL(main_menu),
                           item);

    g_signal_connect (item,
                      "activate",
                      G_CALLBACK(on_main_about),
                      NULL);

    /* Quit menu item. */
    item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT,
                                               NULL);

    gtk_menu_shell_append (GTK_MENU_SHELL(main_menu),
                           item);

    g_signal_connect (item,
                      "activate",
                      G_CALLBACK(on_main_quit),
                      NULL);

    /* Show the menu. */
    gtk_widget_show_all (main_menu);
  }

  return main_menu;
}
コード例 #20
0
ファイル: menu.c プロジェクト: CBke/xfwm4
Menu *
menu_default (GdkScreen *gscr, Window xid, MenuOp ops, MenuOp insensitive, MenuFunc func,
    gint ws, gint nws, gchar **wsn, gint wsn_items, eventFilterSetup *filter_setup, gpointer data)
{
    GtkWidget *menuitem;
    GtkWidget *image;
    GtkWidget *ws_menu;
    MenuData *menudata;
    Menu *menu;
    const gchar *label;
    int i;

    TRACE ("entering menu_new");
    menu = g_new (Menu, 1);
    menu->func = func;
    menu->filter_setup = filter_setup;
    menu->data = data;
    menu->ops = ops;
    menu->insensitive = insensitive;
    menu->screen = gscr;
    menu->xid = xid;
    menu->menu = gtk_menu_new ();
    gtk_menu_set_screen (GTK_MENU (menu->menu), menu->screen);

    i = 0;
    while (i < (int) (sizeof (menuitems) / sizeof (MenuItem)))
    {
        if ((ops & menuitems[i].op) || (menuitems[i].op == MENU_OP_SEPARATOR))
        {
            label = _(menuitems[i].label);
            ws_menu = NULL;
            switch (menuitems[i].op)
            {
                case MENU_OP_SEPARATOR:
                    menuitem = gtk_separator_menu_item_new ();
                    break;
                case MENU_OP_WORKSPACES:
                    menuitem = gtk_menu_item_new_with_mnemonic (label);
                    if (insensitive & menuitems[i].op)
                    {
                        gtk_widget_set_sensitive (menuitem, FALSE);
                    }
                    ws_menu = menu_workspace (menu, insensitive, ws, nws, wsn, wsn_items);
                    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), ws_menu);
                    g_signal_connect (GTK_OBJECT (ws_menu), "selection-done", GTK_SIGNAL_FUNC (menu_closed), menu);
                    break;
                default:
                    if (menuitems[i].image_name)
                    {
                        menuitem = gtk_image_menu_item_new_with_mnemonic (label);
                        image =
                            gtk_image_new_from_icon_name (menuitems[i].image_name,
                            GTK_ICON_SIZE_MENU);
                        gtk_widget_show (image);
                        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
                    }
                    else
                    {
                        menuitem = gtk_menu_item_new_with_mnemonic (label);
                    }
                    if (insensitive & menuitems[i].op)
                    {
                        gtk_widget_set_sensitive (menuitem, FALSE);
                    }
                    menudata = g_new (MenuData, 1);
                    menudata->menu = menu;
                    menudata->op = menuitems[i].op;
                    menudata->data = data;
                    menu_item_connect (menuitem, menudata);
                    break;
            }
            gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), menuitem);
            gtk_widget_show (menuitem);
        }
        ++i;
    }
    g_signal_connect (GTK_OBJECT (menu->menu), "selection-done", GTK_SIGNAL_FUNC (menu_closed), menu);

    return (menu);
}
コード例 #21
0
ファイル: dirmenu.c プロジェクト: TKr/lxde-lxpanel
/* Handler for deselect event on popup menu item. */
static void dirmenu_menuitem_deselect(GtkMenuItem * item, DirMenuPlugin * dm)
{
    /* Delete old menu on deselect to save resource. */
    gtk_menu_item_set_submenu(item, gtk_menu_new());
}
コード例 #22
0
ファイル: bugd.c プロジェクト: moonsdad/bugd
/********************************************************************** MAIN: */
int main( int argc, char **argv )
{
    gchar* title[BUG_LIST_COLS] = { "ID#", "STATUS", "NAME" };
    GtkWidget* window[2];
    GtkWidget* table[2];
    GtkWidget* menu[2];
    GtkWidget* button, * view;
    int i;

    gtk_init( &argc, &argv );

    /* Setup Main Window */
    window[OUTER] = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    gtk_window_set_title( GTK_WINDOW (window[OUTER]), "bugd" );
    gtk_window_set_icon( GTK_WINDOW (window[OUTER]), load_pixbuf("/usr/share/icons/bugd.png"));
    g_signal_connect( window[OUTER], "destroy", G_CALLBACK (gtk_main_quit), NULL);
    gtk_container_set_border_width( GTK_CONTAINER (window[OUTER]), 0 );
    gtk_window_set_default_size( GTK_WINDOW (window[OUTER]), DEFAULT_WINDOW_SIZE );
    table[OUTER] = gtk_vbox_new( FALSE, 0 );
    gtk_container_add( GTK_CONTAINER (window[OUTER]), table[OUTER] );

    /* Setup Menu */
    menu[MENU] = gtk_menu_new();

    menu[ITEM] = gtk_menu_item_new_with_label( "Open..." );
    gtk_menu_shell_append( GTK_MENU_SHELL (menu[MENU]), menu[ITEM] );
    g_signal_connect_swapped( menu[ITEM], "activate", G_CALLBACK (menu_file_open), NULL );
    gtk_widget_show( menu[ITEM] );

    menu[ITEM] = gtk_menu_item_new_with_label( "Close" );
    gtk_menu_shell_append( GTK_MENU_SHELL (menu[MENU]), menu[ITEM] );
    g_signal_connect_swapped( menu[ITEM], "activate", G_CALLBACK (menu_file_close), NULL );
    gtk_widget_show( menu[ITEM] );

    menu[ITEM] = gtk_separator_menu_item_new();
    gtk_menu_shell_append( GTK_MENU_SHELL (menu[MENU]), menu[ITEM] );
    gtk_widget_show( menu[ITEM] );

    menu[ITEM] = gtk_menu_item_new_with_label( "Quit" );
    gtk_menu_shell_append( GTK_MENU_SHELL (menu[MENU]), menu[ITEM] );
    g_signal_connect_swapped( menu[ITEM], "activate", G_CALLBACK (gtk_main_quit), NULL );
    gtk_widget_show( menu[ITEM] );

    menu[ROOT] = gtk_menu_item_new_with_label( "File" );
    gtk_widget_show( menu[ROOT] );
    gtk_menu_item_set_submenu( GTK_MENU_ITEM (menu[ROOT]), menu[MENU] );

    menu[_BAR] = gtk_menu_bar_new();
    gtk_box_pack_start( GTK_BOX (table[OUTER]), menu[_BAR], FALSE, FALSE, 2 );
    gtk_widget_show( menu[_BAR] );

    gtk_menu_shell_append( GTK_MENU_SHELL (menu[_BAR]), menu[ROOT] );

    /* Setup Buglist Window */
    window[INNER] = gtk_scrolled_window_new( NULL, NULL );
    gtk_container_set_border_width( GTK_CONTAINER (window[INNER]), BORDER_WID_INNER );
    gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (window[INNER]), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start( GTK_BOX (table[OUTER]), window[INNER], TRUE, TRUE, 0 );

    buglist = gtk_list_store_new( LIST_COL_QT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
    view = gtk_tree_view_new_with_model( GTK_TREE_MODEL (buglist) );
//     gtk_clist_set_column_justification( GTK_CLIST (buglist), 0, GTK_JUSTIFY_CENTER );
//     gtk_clist_set_column_justification( GTK_CLIST (buglist), 1, GTK_JUSTIFY_CENTER );
    for( i = ID_COL; i < LIST_COL_QT; i++ )
        gtk_tree_view_append_column( GTK_TREE_VIEW (view),
            gtk_tree_view_column_new_with_attributes( title[i],
                gtk_cell_renderer_text_new(), "text", i, NULL ) );
    //gtk_tree_view_set_grid_lines( GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_BOTH );
    gtk_widget_show( view );
    gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW (window[INNER]), view );

    /* Setup Button Table */
    table[INNER] = gtk_table_new( 3, 3, TRUE );
    gtk_box_pack_start( GTK_BOX (table[OUTER]), table[INNER], FALSE, TRUE, BORDER_WID_TWIXT );
    gtk_widget_show( table[OUTER] );
    table[H_BOX] = gtk_hbox_new( TRUE, 0 ); /* Reuseing Widget Pointer [H_BOX == OUTER] */

    button = gtk_button_new_with_label( "Add" );
    gtk_signal_connect_object( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC (add_bug), NULL );
    gtk_table_attach_defaults( GTK_TABLE (table[INNER]), button, 0, 1, 0, 1 );
    gtk_widget_show( button );

    button = gtk_button_new_with_label( "Fix" );
    g_signal_connect( button, "clicked", G_CALLBACK (change_status), (gpointer) view );
    gtk_table_attach_defaults( GTK_TABLE (table[INNER]), button, 1, 2, 0, 1 );
    gtk_widget_show( button );

    button = gtk_button_new_with_label( "Edit" );
    g_signal_connect( button, "clicked", G_CALLBACK (modify_select_bug), (gpointer) view );
    gtk_table_attach_defaults( GTK_TABLE (table[INNER]), button, 2, 3, 0, 1 );
    gtk_widget_show( button );

    gtk_table_attach_defaults(GTK_TABLE (table[INNER]), table[H_BOX], 0, 3, 1, 2 );

    button = gtk_button_new_with_label( "Reproduce" );
    g_signal_connect( button, "clicked", G_CALLBACK (open_reproduce_window), (gpointer) view );
    gtk_box_pack_start( GTK_BOX (table[H_BOX]), button, TRUE, TRUE, 0 );
    gtk_widget_show( button );

    button = gtk_button_new_with_label( "Behaviour" );
    g_signal_connect( button, "clicked", G_CALLBACK (open_behave_window), (gpointer) view );
    gtk_box_pack_start( GTK_BOX (table[H_BOX]), button, TRUE, TRUE, 0 );
    gtk_widget_show( button );

    button = gtk_button_new_with_label( "Quit" );
    g_signal_connect( button, "clicked", G_CALLBACK (gtk_main_quit), NULL );
    gtk_table_attach_defaults( GTK_TABLE (table[INNER]), button, 1, 2, 2, 3 );
    gtk_widget_show( button );

    /* Display GUI */
    gtk_widget_show( table[H_BOX] );
    gtk_widget_show( table[INNER] );
    gtk_widget_show( window[INNER] );
    gtk_widget_show( window[OUTER] );

    /* Open File via Command Line Parameter */
    for ( i = 1; i < argc; i++ )
        if(( argv[i][0] != '-' )&&( cl_open(argv[i]) )) break;

    gtk_main();

    if( opendb ) sqlite3_close( bugdb );
    return 0;
}/* End main Func */
コード例 #23
0
ファイル: uimenu.c プロジェクト: martinpiper/VICE
void ui_menu_create(GtkWidget *w, GtkAccelGroup *accel, const char *menu_name, ui_menu_entry_t *list)
{
    static int level = 0;
    unsigned int i, j;
    ui_menu_cb_obj *obj = NULL;

    level++;

#ifdef DEBUG_MENUS
    printf("allocate new: %s\t(%p)\t%s\n",
	   gtk_type_name(GTK_WIDGET_TYPE(w)), w,
	   menu_name);
#endif

        for (i = j = 0; list[i].string; i++) {
            GtkWidget *new_item = NULL;
            int do_right_justify = 0;

            char name[256];

            sprintf(name, "MenuItem%d", j);	/* ugly... */
            switch (*list[i].string) 
	    {
	    case '-':		/* line */
		new_item  = gtk_menu_item_new();
                break;
	    case '*':		/* toggle */
	    {
		/* Add this item to the list of calls to perform to update the
		   menu status. */
                char *label = make_menu_label(&list[i]);
		if (list[i].callback) 
		{
		    checkmark_t *cmt;
		    new_item = gtk_check_menu_item_new_with_label(label + 1);
		    
		    cmt = (checkmark_t *)lib_malloc(sizeof(checkmark_t));
		    cmt->name = lib_stralloc(list[i].string+1);
		    cmt->w = new_item;
		    cmt->cb = list[i].callback;
		    cmt->obj.value = (void*) list[i].callback_data;
		    cmt->obj.status = CB_NORMAL;
		    cmt->handlerid = 
			g_signal_connect(G_OBJECT(new_item),"activate",
					 G_CALLBACK(list[i].callback),
					 (gpointer) &(cmt->obj)); 
		    g_signal_connect(G_OBJECT(new_item), "destroy",
				     G_CALLBACK(delete_checkmark_cb),
				     (gpointer) cmt);
		    checkmark_list = g_list_prepend(checkmark_list, cmt);
		    obj = &cmt->obj;
		} 
		else 
		    new_item = gtk_menu_item_new_with_label(label + 1);

		j++;
		lib_free(label);
		break;
	    }
            case 0:
                break;
	    default:
	    {
		char *item, *itemp;
		item = itemp = make_menu_label(&list[i]);
                if (strncmp(item, "RJ", 2) == 0)
                {
                    do_right_justify = 1;
                    item += 2;
                }

		new_item = gtk_menu_item_new_with_label(item);
		if (list[i].callback) {
		    obj = (ui_menu_cb_obj*)lib_malloc(sizeof(ui_menu_cb_obj));
		    obj->value = (void*) list[i].callback_data;
		    
		    g_signal_connect(G_OBJECT(new_item),"activate",
				     G_CALLBACK(list[i].callback),
				     (gpointer) obj); 
		}
		lib_free(itemp);
		j++;
	    }
            }

            if (new_item)
            {
	        gtk_menu_shell_append(GTK_MENU_SHELL(w), new_item);
	        gtk_widget_show(new_item);
                if (do_right_justify)
                    gtk_menu_item_set_right_justified(GTK_MENU_ITEM(new_item), TRUE);
#ifdef DEBUG_MENUS
	    printf("allocate new: %s\t(%p)\t%s\n",
		   gtk_type_name(GTK_WIDGET_TYPE(new_item)), new_item,
		   list[i].string);
#endif
            }

            if (list[i].sub_menu) 
	    {
                GtkWidget *sub;
                if (new_item && *list[i].string != '-')
                {
                    sub = gtk_menu_new();
		    gtk_menu_item_set_submenu(GTK_MENU_ITEM(new_item),sub);
                }
                else
                {
                    sub = w;
                }
		ui_menu_create(sub, accel, list[i].string, 
				     list[i].sub_menu);
            } 
	    else 
	    {            /* no submenu */
	        if (accel && list[i].hotkey_keysym != KEYSYM_NONE
		    && list[i].callback != NULL && new_item != NULL)
                    add_accelerator(new_item,
                               accel, list[i].hotkey_keysym,
                               list[i].hotkey_modifier);
            }
        }
    
    level--;
}
コード例 #24
0
ファイル: cookie-manager-page.c プロジェクト: sinoory/webv8
static GtkWidget *cm_tree_prepare(CookieManagerPage *cmp)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkTreeSelection *sel;
    GtkWidget *item;
    GtkWidget *menu;
    GtkWidget *treeview;
    CookieManagerPagePrivate *priv = cmp->priv;

    treeview = priv->treeview = gtk_tree_view_new();

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(
                 _("Name"), renderer, "text", COOKIE_MANAGER_COL_NAME, NULL);
    gtk_tree_view_column_set_expand (column, TRUE);
    gtk_tree_view_column_set_sort_indicator(column, TRUE);
    gtk_tree_view_column_set_sort_column_id(column, COOKIE_MANAGER_COL_NAME);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_cell_data_func(column, renderer,
                                            (GtkTreeCellDataFunc) cm_tree_render_text_cb, NULL, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
    gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), COOKIE_MANAGER_COL_NAME);

    /* selection handling */
    sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
    gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);

    /* signals */
    g_signal_connect(sel, "changed", G_CALLBACK(cm_tree_selection_changed_cb), cmp);
    g_signal_connect(treeview, "key-press-event", G_CALLBACK(cm_tree_key_press_cb), cmp);
    g_signal_connect(treeview, "button-press-event", G_CALLBACK(cm_tree_button_press_event_cb), cmp);
    g_signal_connect(treeview, "button-release-event", G_CALLBACK(cm_tree_button_release_event_cb), cmp);
    g_signal_connect(treeview, "popup-menu", G_CALLBACK(cm_tree_popup_menu_cb), cmp);

    /* tooltips */
    gtk_widget_set_has_tooltip(treeview, TRUE);
    g_signal_connect(treeview, "query-tooltip", G_CALLBACK(cm_tree_query_tooltip), cmp);

    /* drag'n'drop */
    gtk_tree_view_enable_model_drag_source(
        GTK_TREE_VIEW(treeview),
        GDK_BUTTON1_MASK,
        NULL,
        0,
        GDK_ACTION_COPY
    );
    gtk_drag_source_add_text_targets(treeview);
    g_signal_connect(treeview, "drag-data-get", G_CALLBACK(cm_tree_drag_data_get_cb), cmp);

    /* popup menu */
    priv->popup_menu = menu = gtk_menu_new();

    item = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
    gtk_widget_show(item);
    gtk_container_add(GTK_CONTAINER(menu), item);
    g_signal_connect(item, "activate", G_CALLBACK(cm_button_delete_clicked_cb), cmp);
    priv->delete_popup_button = item;

    item = gtk_separator_menu_item_new();
    gtk_widget_show(item);
    gtk_container_add(GTK_CONTAINER(menu), item);

    item = gtk_image_menu_item_new_with_mnemonic(_("_Expand All"));
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                  gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
    gtk_widget_show(item);
    gtk_container_add(GTK_CONTAINER(menu), item);
    g_signal_connect(item, "activate", G_CALLBACK(cm_tree_popup_expand_activate_cb), cmp);
    priv->expand_buttons[2] = item;

    item = gtk_image_menu_item_new_with_mnemonic(_("_Collapse All"));
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                  gtk_image_new_from_icon_name(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
    gtk_widget_show(item);
    gtk_container_add(GTK_CONTAINER(menu), item);
    g_signal_connect(item, "activate", G_CALLBACK(cm_tree_popup_collapse_activate_cb), cmp);
    priv->expand_buttons[3] = item;

    return treeview;
}
コード例 #25
0
ファイル: accounts-window.cpp プロジェクト: Klom/ekiga
/* Public API */
GtkWidget *
accounts_window_new (boost::shared_ptr<Ekiga::AccountCore> account_core,
		     boost::shared_ptr<Ekiga::PersonalDetails> details)
{
  AccountsWindow *self = NULL;

  boost::signals::connection conn;

  GtkWidget *vbox = NULL;
  GtkWidget *menu_bar = NULL;
  GtkWidget *menu_item = NULL;
  GtkWidget *menu = NULL;
  GtkWidget *item = NULL;
  GtkWidget *event_box = NULL;
  GtkWidget *scroll_window = NULL;
  GtkWidget* button_box = NULL;
  GtkWidget* button = NULL;

  GtkWidget *frame = NULL;
  GtkWidget *hbox = NULL;

  GtkCellRenderer *renderer = NULL;
  GtkListStore *list_store = NULL;
  GtkTreeViewColumn *column = NULL;

  GtkTreeSelection* selection = NULL;

  AtkObject *aobj;

  const gchar *column_names [] = {

    "",
    "",
    "",
    "",
    _("Account Name"),
    _("Status")
  };

  /* The window */
  self = (AccountsWindow *) g_object_new (ACCOUNTS_WINDOW_TYPE, NULL);

  self->priv = new AccountsWindowPrivate;
  self->priv->details = details;
  self->priv->account_core = account_core;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_window_set_title (GTK_WINDOW (self), _("Accounts"));

  /* The menu */
  menu_bar = gtk_menu_bar_new ();

  self->priv->accel = gtk_accel_group_new ();
  gtk_window_add_accel_group (GTK_WINDOW (self), self->priv->accel);
  g_object_unref (self->priv->accel);

  self->priv->menu_item_core = gtk_menu_item_new_with_mnemonic (_("_Accounts"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), self->priv->menu_item_core);
  g_object_ref (self->priv->menu_item_core);

  menu_item = gtk_menu_item_new_with_mnemonic (_("_Help"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);

  menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  g_signal_connect (item, "activate", G_CALLBACK (help_callback), NULL);

  /* The accounts list store */
  list_store = gtk_list_store_new (COLUMN_ACCOUNT_NUMBER,
                                   G_TYPE_POINTER,
                                   G_TYPE_STRING,  /* Icon */
				   G_TYPE_BOOLEAN, /* Is account active? */
				   G_TYPE_INT,
				   G_TYPE_STRING,  /* Account Name */
				   G_TYPE_STRING,  /* Error Message */
				   G_TYPE_INT);    /* State */

  self->priv->accounts_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
  g_object_unref (list_store);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->priv->accounts_list), TRUE);
  gtk_tree_view_set_reorderable (GTK_TREE_VIEW (self->priv->accounts_list), TRUE);

  aobj = gtk_widget_get_accessible (GTK_WIDGET (self->priv->accounts_list));
  atk_object_set_name (aobj, _("Accounts"));

  renderer = gtk_cell_renderer_pixbuf_new ();
  column = gtk_tree_view_column_new ();
  g_object_set (renderer, "yalign", 0.5, "xpad", 5, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, renderer,
				      "icon-name", COLUMN_ACCOUNT_ICON);
  gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->accounts_list), column);

  /* Add all text renderers */
  for (int i = COLUMN_ACCOUNT_ACCOUNT_NAME ; i < COLUMN_ACCOUNT_NUMBER ; i++) {

    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes (column_names [i],
						       renderer,
						       "text",
						       i,
						       "weight",
						       COLUMN_ACCOUNT_WEIGHT,
						       NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->accounts_list), column);
    gtk_tree_view_column_set_resizable (GTK_TREE_VIEW_COLUMN (column), TRUE);
    gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
				     GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    gtk_tree_view_column_set_sort_column_id (column, i);
  }

  g_signal_connect (self->priv->accounts_list, "event_after",
		    G_CALLBACK (account_clicked_cb), self);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->accounts_list));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
  g_signal_connect (selection, "changed",
		    G_CALLBACK (on_selection_changed), self);

  /* The scrolled window with the accounts list store */
  scroll_window = gtk_scrolled_window_new (FALSE, FALSE);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);

  event_box = gtk_event_box_new ();
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
  gtk_container_add (GTK_CONTAINER (event_box), hbox);

  frame = gtk_frame_new (NULL);
  gtk_widget_set_size_request (GTK_WIDGET (frame), 250, 150);
  gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (frame), scroll_window);
  gtk_container_add (GTK_CONTAINER (scroll_window), self->priv->accounts_list);
  gtk_container_set_border_width (GTK_CONTAINER (self->priv->accounts_list), 0);
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  /* setting up a horizontal button box
   * (each button with be dynamically disabled/enabled as needed)
   */
  button_box = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_CENTER);
  button = gtk_button_new_with_mnemonic (_("_Enable"));
  gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
  self->priv->toolbar.add_button ("user-available", GTK_BUTTON (button));
  button = gtk_button_new_with_mnemonic (_("_Disable"));
  gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
  self->priv->toolbar.add_button ("user-offline", GTK_BUTTON (button));
  button = gtk_button_new_with_mnemonic (_("Edi_t"));
  gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
  self->priv->toolbar.add_button ("edit", GTK_BUTTON (button));
  button = gtk_button_new_with_mnemonic (_("_Remove"));
  gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
  self->priv->toolbar.add_button ("remove", GTK_BUTTON (button));
  gtk_box_pack_start (GTK_BOX (hbox), button_box, FALSE, FALSE, 10);

  populate_menu (GTK_WIDGET (self)); // This will add static and dynamic actions
  gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), event_box, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (self), vbox);
  gtk_widget_show_all (GTK_WIDGET (vbox));

  /* Engine Signals callbacks */
  conn = self->priv->account_core->bank_added.connect (boost::bind (&on_bank_added, _1, self));
  self->priv->connections.add (conn);
  conn = self->priv->account_core->account_added.connect (boost::bind (&on_account_added, _1, _2, self));
  self->priv->connections.add (conn);
  conn = self->priv->account_core->account_updated.connect (boost::bind (&on_account_updated, _1, _2, self));
  self->priv->connections.add (conn);
  conn = self->priv->account_core->account_removed.connect (boost::bind (&on_account_removed, _1, _2, self));
  self->priv->connections.add (conn);
  conn = self->priv->account_core->questions.connect (boost::bind (&on_handle_questions, _1, (gpointer) self));
  self->priv->connections.add (conn);

  self->priv->presence = self->priv->details->get_presence ();
  conn = self->priv->details->updated.connect (boost::bind (&on_personal_details_updated, self, self->priv->details));
  self->priv->connections.add (conn);

  self->priv->account_core->visit_banks (boost::bind (&on_visit_banks, _1, self));

  return GTK_WIDGET (self);
}
コード例 #26
0
static void
setup_photo_popup (UmPhotoDialog *um)
{
        GtkWidget *menu, *menuitem, *image;
        guint x, y;
        const gchar * const * dirs;
        guint i;
        GDir *dir;
        const char *face;
        gboolean none_item_shown;
        gboolean added_faces;

        menu = gtk_menu_new ();

        x = 0;
        y = 0;
        none_item_shown = added_faces = FALSE;

        dirs = g_get_system_data_dirs ();
        for (i = 0; dirs[i] != NULL; i++) {
                char *path;

                path = g_build_filename (dirs[i], "pixmaps", "faces", NULL);
                dir = g_dir_open (path, 0, NULL);
                if (dir == NULL) {
                        g_free (path);
                        continue;
                }

                while ((face = g_dir_read_name (dir)) != NULL) {
                        char *filename;

                        added_faces = TRUE;

                        filename = g_build_filename (path, face, NULL);
                        menuitem = menu_item_for_filename (um, filename);
                        g_free (filename);
                        if (menuitem == NULL)
                                continue;

                        gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
                                         x, x + 1, y, y + 1);
                        gtk_widget_show (menuitem);

                        x++;
                        if (x >= ROW_SPAN - 1) {
                                y++;
                                x = 0;
                        }
                }
                g_dir_close (dir);
                g_free (path);

                if (added_faces)
                        break;
        }

        if (!added_faces)
                goto skip_faces;

        image = gtk_image_new_from_icon_name ("avatar-default", GTK_ICON_SIZE_DIALOG);
        menuitem = gtk_menu_item_new ();
        gtk_container_add (GTK_CONTAINER (menuitem), image);
        gtk_widget_show_all (menuitem);
        gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
                         x, x + 1, y, y + 1);
        g_signal_connect (G_OBJECT (menuitem), "activate",
                          G_CALLBACK (none_icon_selected), um);
        gtk_widget_show (menuitem);
        none_item_shown = TRUE;
        y++;

skip_faces:
        if (!none_item_shown) {
                menuitem = gtk_menu_item_new_with_label (_("Disable image"));
                gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
                                 0, ROW_SPAN - 1, y, y + 1);
                g_signal_connect (G_OBJECT (menuitem), "activate",
                                  G_CALLBACK (none_icon_selected), um);
                gtk_widget_show (menuitem);
                y++;
        }

        /* Separator */
        menuitem = gtk_separator_menu_item_new ();
        gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
                         0, ROW_SPAN - 1, y, y + 1);
        gtk_widget_show (menuitem);

        y++;

#ifdef HAVE_CHEESE
        um->take_photo_menuitem = gtk_menu_item_new_with_label (_("Take a photo…"));
        gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (um->take_photo_menuitem),
                         0, ROW_SPAN - 1, y, y + 1);
        g_signal_connect (G_OBJECT (um->take_photo_menuitem), "activate",
                          G_CALLBACK (webcam_icon_selected), um);
        gtk_widget_set_sensitive (um->take_photo_menuitem, FALSE);
        gtk_widget_show (um->take_photo_menuitem);

        um->monitor = cheese_camera_device_monitor_new ();
        g_signal_connect (G_OBJECT (um->monitor), "added",
                          G_CALLBACK (device_added), um);
        g_signal_connect (G_OBJECT (um->monitor), "removed",
                          G_CALLBACK (device_removed), um);
        cheese_camera_device_monitor_coldplug (um->monitor);

        y++;
#endif /* HAVE_CHEESE */

        menuitem = gtk_menu_item_new_with_label (_("Browse for more pictures…"));
        gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
                         0, ROW_SPAN - 1, y, y + 1);
        g_signal_connect (G_OBJECT (menuitem), "activate",
                          G_CALLBACK (file_icon_selected), um);
        gtk_widget_show (menuitem);

        um->photo_popup = menu;
}
コード例 #27
0
ファイル: gui.cpp プロジェクト: viralex/project-secure-chat
void main_gui(int argc, char **argv)
{
    /* inits */
    gdk_threads_init();
    gdk_threads_enter();
    gtk_init (&argc, &argv);
    pthread_mutex_init(&mutex_guichange, NULL);

    /* window */
    gres.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(gres.window), 0);
    gtk_window_set_urgency_hint (GTK_WINDOW(gres.window), TRUE);
    gtk_window_set_title (GTK_WINDOW (gres.window), _PROJECTNAME);
    gtk_window_set_default_size(GTK_WINDOW(gres.window), 800, 600);
    gtk_window_set_position(GTK_WINDOW(gres.window), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable(GTK_WINDOW(gres.window), TRUE);

    /* setting window icon */
    gtk_window_set_icon(GTK_WINDOW(gres.window), create_pixbuf(GUI_ICON));

    gtk_widget_show(gres.window);

    g_signal_connect(G_OBJECT(gres.window), "delete_event", G_CALLBACK(on_destroy), NULL);
    g_signal_connect(G_OBJECT(gres.window), "destroy", G_CALLBACK(on_destroy), NULL);

    /* vbox principale */
    gres.vbox_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
    gtk_container_add(GTK_CONTAINER(gres.window), gres.vbox_main);
    gtk_container_set_border_width(GTK_CONTAINER(gres.vbox_main),0);

    /* accellgroup */
    gres.accel_group = gtk_accel_group_new();
    gtk_window_add_accel_group(GTK_WINDOW(gres.window), gres.accel_group);

    /* menubar */
    gres.menubar = gtk_menu_bar_new();
    gres.filemenu = gtk_menu_new();
    gres.helpmenu = gtk_menu_new();

    gres.file = gtk_menu_item_new_with_label("File");
    //gres.connect = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
    gres.open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
    gres.font = gtk_image_menu_item_new_from_stock(GTK_STOCK_SELECT_FONT, NULL);
    gres.sep = gtk_separator_menu_item_new();
    gres.quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, gres.accel_group);
    gres.help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, NULL);
    gres.about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.file), gres.filemenu);
    //gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.connect);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.font);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.sep);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.quit);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.file);

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.help), gres.helpmenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.helpmenu), gres.about);
    gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.help);

    gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.menubar, FALSE, FALSE, 0);

    g_signal_connect(G_OBJECT(gres.quit), "activate", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(G_OBJECT(gres.font), "activate", G_CALLBACK(select_font), G_OBJECT(gres.window));
    g_signal_connect(G_OBJECT(gres.about), "activate", G_CALLBACK(show_about), NULL);

    /* toolbar */
    gres.toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(gres.toolbar), GTK_TOOLBAR_BOTH);

    gtk_container_set_border_width(GTK_CONTAINER(gres.toolbar), 2);

    gres.toolbar_connect = gtk_tool_button_new_from_stock(GTK_STOCK_NETWORK);
    if (!c_core->GetSession()->IsConnected())
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Connect");
    else
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Disconnect");
    gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_connect, -1);
    g_signal_connect(G_OBJECT(gres.toolbar_connect), "clicked", G_CALLBACK(toolbar_connect_click), NULL);

    //gres.toolbar_refresh = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
    //gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_refresh, -1);
    //g_signal_connect(G_OBJECT(gres.toolbar_refresh), "clicked", G_CALLBACK(set_nick), G_OBJECT(gres.window));

    gres.toolbar_reset = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
    gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_reset, -1);
    g_signal_connect(G_OBJECT(gres.toolbar_reset), "clicked", G_CALLBACK(toolbar_reset_click), NULL);

    gres.toolbar_separator = gtk_separator_tool_item_new();
    gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_separator, -1);

    gres.toolbar_exit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
    gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_exit, -1);
    g_signal_connect(G_OBJECT(gres.toolbar_exit), "clicked", G_CALLBACK(gtk_main_quit), NULL);

    gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.toolbar, FALSE, FALSE, 0);

    /* Paned */
    gres.paned_main = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
    gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.paned_main, TRUE, TRUE, 0);

    gres.scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
    gtk_paned_pack1 (GTK_PANED(gres.paned_main), gres.scrolledwindow_chat, true, true);

    gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_chat), 2);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_chat),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);

    gres.view_chat = gtk_text_view_new();

    GdkRGBA color;
    gdk_rgba_parse (&color, CFG_GET_STRING("chat_bg").c_str());
    gtk_widget_override_background_color(GTK_WIDGET(gres.view_chat),
                                         GTK_STATE_FLAG_NORMAL, &color);

    PangoFontDescription *font_desc = pango_font_description_from_string(CFG_GET_STRING("chat_font").c_str());
    if (font_desc)
        gtk_widget_modify_font(gres.view_chat, font_desc);

    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gres.view_chat), GTK_WRAP_WORD_CHAR);
    gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (gres.view_chat), FALSE);
    gtk_text_view_set_left_margin (GTK_TEXT_VIEW (gres.view_chat), 1);
    gtk_text_view_set_right_margin (GTK_TEXT_VIEW (gres.view_chat), 1);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(gres.view_chat), FALSE);
    gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_chat), gres.view_chat);
    gres.tbuf_chat = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gres.view_chat));
    
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_bg", "background", CFG_GET_STRING("chat_bg").c_str() , NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_sys_msg_fg", "foreground", CFG_GET_STRING("chat_sys_msg_fg").c_str() , NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_msg_fg", "foreground", CFG_GET_STRING("chat_msg_fg").c_str() , NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_join_fg", "foreground", CFG_GET_STRING("chat_join_fg").c_str() , NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_leave_fg", "foreground", CFG_GET_STRING("chat_leave_fg").c_str() , NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_whisp_fg", "foreground", CFG_GET_STRING("chat_whisp_fg").c_str() , NULL);

    gtk_text_buffer_create_tag(gres.tbuf_chat, "gap", "pixels_above_lines", 30, NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "lmarg", "left_margin", 5, NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "black_fg", "foreground", "#000000", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "white_fg", "foreground", "#ffffff", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_fg", "foreground", "#3200ff", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_fg", "foreground", "#ff32ff", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "green_fg", "foreground", "#55ff00", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "red_fg", "foreground", "#ff3200", NULL);
    
    gtk_text_buffer_create_tag(gres.tbuf_chat, "green_bg", "background", "#55ff00", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_bg", "background", "#3200ff", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "red_bg", "background", "#ff3200", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "yellow_bg", "background", "#f7f732", NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_bg", "background", "#ff32ff", NULL);
    
    gtk_text_buffer_create_tag(gres.tbuf_chat, "italic", "style", PANGO_STYLE_ITALIC, NULL);
    gtk_text_buffer_create_tag(gres.tbuf_chat, "bold", "weight", PANGO_WEIGHT_BOLD, NULL);

    gres.scrolledwindow_user_list = gtk_scrolled_window_new (NULL, NULL);
    gtk_paned_pack2 (GTK_PANED(gres.paned_main), gres.scrolledwindow_user_list, false, false);
    gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_user_list), 2);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_user_list),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);
    gtk_widget_show (gres.scrolledwindow_user_list);

    gres.model_user_list     = gtk_list_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
    gres.view_user_list      = gtk_tree_view_new_with_model (GTK_TREE_MODEL(gres.model_user_list));
    gres.selection_user_list = gtk_tree_view_get_selection(GTK_TREE_VIEW(gres.view_user_list));

    gtk_tree_selection_set_mode(gres.selection_user_list, GTK_SELECTION_SINGLE);
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(gres.view_user_list), TRUE);

    gres.renderer_user_list = gtk_cell_renderer_text_new();
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list), /* vista */
                        -1,                  /* posizione della colonna */
                        "Name",  /* titolo della colonna */
                        gres.renderer_user_list,            /* cella inserita nella colonna */
                        "text",              /* attributo colonna */
                        COLUMN_STRING1,    /* colonna inserita  */
                        NULL);               /* fine ;-) */

    gres.renderer_user_list = gtk_cell_renderer_text_new();
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list),
                        -1,
                        "Type",
                        gres.renderer_user_list,
                        "text",
                        COLUMN_STRING2,
                        NULL);

    gtk_widget_show (gres.view_user_list);
    g_object_unref(gres.model_user_list);

    gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_user_list), gres.view_user_list);
    gtk_container_set_border_width (GTK_CONTAINER (gres.view_user_list), 0);
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (gres.view_user_list), TRUE);

    /* INPUTS */
    gres.hbox_inputs = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.hbox_inputs, FALSE, FALSE, 0);
    
    gres.label_nick = gtk_label_new((gchar *) CFG_GET_STRING("username").c_str()); 
    gtk_misc_set_alignment(GTK_MISC(gres.label_nick), 0.0, 0.5);
    gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.label_nick, FALSE, FALSE, 2 );

    gres.entry_command = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.entry_command, TRUE, TRUE, 5);
    
    gres.button_send = gtk_button_new_with_label("Send");
    gtk_widget_set_size_request (GTK_WIDGET (gres.button_send), 70, 30);
    gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.button_send, FALSE, FALSE, 0);

    gres.text_entry = gres.entry_command;
    g_signal_connect(G_OBJECT(gres.entry_command), "activate", G_CALLBACK(button_send_click), NULL);
    g_signal_connect(G_OBJECT(gres.button_send), "clicked", G_CALLBACK(button_send_click), NULL);

    /* status_bar */
    gres.status_bar = gtk_statusbar_new();
    gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.status_bar, FALSE, FALSE, 0);

    /* end_widgets */
    gtk_widget_show_all(gres.window);

    /* default focus on command entry */
    gtk_widget_grab_focus (GTK_WIDGET(gres.text_entry));

    INFO ("debug", "GUI: starting GUI thread\n");
    pthread_t tid;
    StartThread(GuiThread, (void*)&gres, tid);

    INFO ("debug", "GUI: starting GTK+3\n");
    gtk_main();
    gdk_threads_leave();
    pthread_mutex_destroy(&mutex_guichange);

    return;
}
コード例 #28
0
ファイル: chat.c プロジェクト: mjpak0109/linphone
GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *with){
	GtkWidget *chat_view=linphone_gtk_create_widget("chatroom_frame");
	GtkWidget *main_window=linphone_gtk_get_main_window();
	GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
	GtkWidget *text=linphone_gtk_get_widget(chat_view,"textview");
	GdkColor color_grey = {0, 32512, 32512, 32512};
	GdkColor color_light_grey = {0, 56832, 60928, 61952};
	GdkColor color_black = {0};
	int idx;
	GtkWidget *button;
	GtkWidget *entry = linphone_gtk_get_widget(chat_view,"text_entry");
	MSList *messages;
	GHashTable *table;
	GtkTextTag *tmp_tag;
	GtkWidget *link_ctx_menu = gtk_menu_new();
	GtkWidget *link_ctx_menu_copy_item = gtk_menu_item_new_with_label(_("Copy"));

	gtk_notebook_append_page(notebook,chat_view,create_tab_chat_header(cr,with));
	idx = gtk_notebook_page_num(notebook, chat_view);
	gtk_notebook_set_current_page(notebook, idx);
	gtk_widget_show(chat_view);
	table=g_hash_table_new_full(g_direct_hash,g_direct_equal,NULL,NULL);
	g_object_set_data(G_OBJECT(chat_view),"cr",cr);
	g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
	g_object_set_data(G_OBJECT(chat_view),"table",table);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"me",
		"foreground_gdk", &color_black,
		"paragraph-background-gdk", &color_light_grey,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"from",
		"weight", PANGO_WEIGHT_BOLD,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"body",
		"indent", 10,
		NULL);

	gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"status",
		"size-points", 9.0,
		"foreground_gdk", &color_grey,
		"style", PANGO_STYLE_ITALIC,
		"justification", GTK_JUSTIFY_RIGHT,
		NULL);

	tmp_tag = gtk_text_buffer_create_tag(
		gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
		"link",
		"underline", PANGO_UNDERLINE_SINGLE,
		"foreground_gdk", _linphone_gtk_chatroom_get_link_color(chat_view),
		NULL);
	g_signal_connect(G_OBJECT(tmp_tag), "event", G_CALLBACK(link_event_handler), NULL);
	g_signal_connect(G_OBJECT(text), "event", G_CALLBACK(chatroom_event), NULL);
	gtk_menu_shell_append(GTK_MENU_SHELL(link_ctx_menu), link_ctx_menu_copy_item);
	g_signal_connect(G_OBJECT(link_ctx_menu_copy_item), "activate", G_CALLBACK(copy_uri_into_clipboard_handler), NULL);
	gtk_widget_show_all(link_ctx_menu);
	g_object_set_data_full(G_OBJECT(text), "link_ctx_menu", link_ctx_menu, g_object_unref);
	g_object_ref_sink(G_OBJECT(link_ctx_menu));

	messages = linphone_chat_room_get_history(cr,NB_MSG_HIST);
	display_history_message(chat_view,messages,with);
	button = linphone_gtk_get_widget(chat_view,"send");
	g_signal_connect_swapped(G_OBJECT(button),"clicked",(GCallback)linphone_gtk_send_text,NULL);

	g_signal_connect_swapped(G_OBJECT(entry),"activate",(GCallback)linphone_gtk_send_text,NULL);
	g_signal_connect_swapped(G_OBJECT(entry),"changed",(GCallback)linphone_gtk_compose_text,NULL);
	g_signal_connect(G_OBJECT(notebook),"switch_page",(GCallback)linphone_gtk_notebook_tab_select,NULL);
	return chat_view;
}
コード例 #29
0
static void
gctt_rebuild_menu (GncCombott *combott, GtkTreeModel *model)
{
    GncCombottPrivate *priv;
    GtkTreeIter iter;
    GtkWidget *menu_items;
    gboolean valid;
    gint num = 1;
    gint items = 0;

    g_return_if_fail (GNC_IS_COMBOTT (combott));
    g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));

    priv = GNC_COMBOTT_GET_PRIVATE (combott);

    priv->menu = NULL;

    priv->menu = gtk_menu_new();

    valid = gtk_tree_model_get_iter_first (model, &iter);
    while (valid)
    {
        GtkWidget *label;

        /* Walk through the list, reading each row */
        gchar *str_data;
        gchar *tip_data;
        gtk_tree_model_get (model, &iter,
                            priv->text_col, &str_data,
                            priv->tip_col, &tip_data,
                            -1);

        /* Create a new menu-item with a name... */
        menu_items = gtk_menu_item_new_with_label (str_data);

        /* Get widget width to max number of characters in list */
        if(strlen(str_data) > num)
            num = strlen(str_data);

        /* Add the tooltip to the child label */
        label = gtk_bin_get_child(GTK_BIN(menu_items));
        gtk_widget_set_tooltip_text (label, tip_data);
        gnc_label_set_alignment (label, 0, 0.5);

        /* ...and add it to the menu. */
        gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_items);
        g_signal_connect (menu_items, "activate",
                          G_CALLBACK (menuitem_response_cb),
                          combott);

        /* Show the widget */
        gtk_widget_show (menu_items);

        g_free (str_data);
        g_free (tip_data);
        items++;
        valid = gtk_tree_model_iter_next (model, &iter);
    }

    g_signal_connect(G_OBJECT(priv->menu), "size-allocate", G_CALLBACK(menu_getsize_cb), combott);

    /* Set widget width to max number of characters in list */
    priv->max_number_char = num;
    gtk_label_set_width_chars(GTK_LABEL(priv->label), priv->max_number_char);

    priv->num_items = items;
}
コード例 #30
0
ファイル: menus.c プロジェクト: ivan-dives/audacious-plugins
GtkWidget * make_menu_tab (GtkAccelGroup * accel)
{
    GtkWidget * shell = gtk_menu_new ();
    populate_menu (shell, tab_items, G_N_ELEMENTS (tab_items), accel);
    return shell;
}