Exemplo n.º 1
0
GtkWidget *create_main_win(void)
{
	GtkWidget *win_main;
	GtkWidget *main_box;
	GtkWidget *menubar;
	GtkWidget *black_label;
	GtkWidget *black_label_frame;
	GtkWidget *white_label;
	GtkWidget *white_label_frame;
	GtkWidget *label_box;
	GtkWidget *again_button;
	GtkWidget *drawingarea;
	GtkWidget *statusbar;
	GtkAccelGroup *accel_group;

	accel_group = gtk_accel_group_new();

	win_main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_object_set_data(G_OBJECT(win_main), "main_win", win_main);
	gtk_window_set_title(GTK_WINDOW(win_main), _("Reversi"));

	main_box = gtk_vbox_new(FALSE, 0);
	gtk_widget_ref(main_box);
	g_object_set_data_full(G_OBJECT(win_main), "main_box", main_box,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(main_box);
	gtk_container_add(GTK_CONTAINER(win_main), main_box);

	menubar = create_menus(win_main);
	gtk_widget_ref(menubar);
	g_object_set_data_full(G_OBJECT(win_main), "menubar", menubar,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(menubar);
	gtk_box_pack_start(GTK_BOX(main_box), menubar, FALSE, FALSE, 0);

	// Create labels frames
	white_label_frame = gtk_frame_new(NULL);
	gtk_widget_ref(white_label_frame);
	g_object_set_data_full(G_OBJECT(win_main), "white_label_frame",
			       white_label_frame,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(white_label_frame);

	black_label_frame = gtk_frame_new(NULL);
	gtk_widget_ref(black_label_frame);
	g_object_set_data_full(G_OBJECT(win_main), "black_label_frame",
			       black_label_frame,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(black_label_frame);

	// Create labels
	white_label = gtk_label_new("White: 0");
	// Why is that? Really don't know, but all the other scripts have it!
	gtk_widget_ref(white_label);
	g_object_set_data_full(G_OBJECT(win_main), "white_label",
			       white_label,
			       (GtkDestroyNotify) gtk_widget_unref);

	black_label = gtk_label_new("Black: 0");
	gtk_widget_ref(black_label);
	g_object_set_data_full(G_OBJECT(win_main), "black_label",
			       black_label,
			       (GtkDestroyNotify) gtk_widget_unref);

	gtk_container_add(GTK_CONTAINER(white_label_frame), white_label);
	gtk_container_add(GTK_CONTAINER(black_label_frame), black_label);
	gtk_widget_show(white_label);
	gtk_widget_show(black_label);

	// Play again button
	again_button = gtk_button_new_with_label("Play again");
	gtk_widget_ref(again_button);
	g_object_set_data_full(G_OBJECT(win_main), "again_button",
			       again_button,
			       (GtkDestroyNotify) gtk_widget_unref);
	//gtk_container_add(GTK_CONTAINER(win_main), again_button);


	// Label box
	label_box = gtk_hbox_new(TRUE, 5);
	gtk_widget_ref(label_box);
	g_object_set_data_full(G_OBJECT(win_main), "label_box", label_box,
			       (GtkDestroyNotify) gtk_widget_unref);

	gtk_box_pack_start(GTK_BOX(label_box), black_label_frame, FALSE,
			   TRUE, 0);
	gtk_box_pack_start(GTK_BOX(label_box), again_button, TRUE, TRUE,
			   0);
	gtk_box_pack_end(GTK_BOX(label_box), white_label_frame, FALSE,
			 TRUE, 0);
	gtk_widget_show(label_box);
	gtk_box_pack_start(GTK_BOX(main_box), label_box, FALSE, TRUE, 0);

	// Drawing area
	drawingarea = gtk_drawing_area_new();
	gtk_widget_ref(drawingarea);
	g_object_set_data_full(G_OBJECT(win_main), "drawingarea",
			       drawingarea,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(drawingarea);
	gtk_box_pack_start(GTK_BOX(main_box), drawingarea, TRUE, TRUE, 0);
	gtk_widget_set_size_request(drawingarea, 48 * 8, 48 * 8);
	gtk_widget_set_events(drawingarea,
			      GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);

	// Status bar
	statusbar = gtk_statusbar_new();
	gtk_widget_ref(statusbar);
	g_object_set_data_full(G_OBJECT(win_main), "statusbar", statusbar,
			       (GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show(statusbar);
	gtk_box_pack_start(GTK_BOX(main_box), statusbar, FALSE, FALSE, 0);

	g_signal_connect(GTK_OBJECT(win_main), "delete_event",
			 GTK_SIGNAL_FUNC(main_exit), NULL);
	g_signal_connect(GTK_OBJECT(win_main), "realize",
			 GTK_SIGNAL_FUNC(on_main_win_realize), NULL);
	g_signal_connect(GTK_OBJECT(drawingarea), "configure_event",
			 GTK_SIGNAL_FUNC(configure_handle), NULL);
	g_signal_connect(GTK_OBJECT(drawingarea), "expose_event",
			 GTK_SIGNAL_FUNC(expose_handle), NULL);
	g_signal_connect(GTK_OBJECT(drawingarea), "button_press_event",
			 GTK_SIGNAL_FUNC(handle_move), NULL);
	g_signal_connect(GTK_OBJECT(again_button), "clicked",
			 GTK_SIGNAL_FUNC(play_again), NULL);

	gtk_window_add_accel_group(GTK_WINDOW(win_main), accel_group);

	return win_main;
}
Exemplo n.º 2
0
static void
anjuta_window_instance_init (AnjutaWindow *win)
{
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};

	DEBUG_PRINT ("%s", "Initializing Anjuta...");

	gtk_window_set_geometry_hints (GTK_WINDOW (win), GTK_WIDGET (win),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (win), TRUE);

	/*
	 * Main box
	 */
	main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add (GTK_CONTAINER (win), main_box);
	gtk_widget_show (main_box);

	win->values = NULL;
	win->widgets = NULL;
	win->maximized = FALSE;

	/* Settings */
	win->settings = g_settings_new (PREF_SCHEMA);

	/* Status bar */
	win->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (win->status, GTK_WIDGET (win));
	gtk_widget_show (GTK_WIDGET (win->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (win->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (win->status));
	g_object_add_weak_pointer (G_OBJECT (win->status), (gpointer)&win->status);

	/* configure dock */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (hbox);
	win->dock = gdl_dock_new ();
	gtk_widget_show (win->dock);
	gtk_box_pack_end(GTK_BOX (hbox), win->dock, TRUE, TRUE, 0);

	dockbar = gdl_dock_bar_new (G_OBJECT (win->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);

	win->layout_manager = gdl_dock_layout_new (G_OBJECT (win->dock));
	g_signal_connect (win->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), win);
	g_signal_connect (gdl_dock_layout_get_master (win->layout_manager), "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), win);

	/* UI engine */
	win->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (win->ui), (gpointer)&win->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (win->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  win);
	g_signal_connect (win->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  win);

	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	win->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (win),
													 win->status,
													 plugins_dirs);
	win->profile_manager = anjuta_profile_manager_new (win->plugin_manager);
	g_list_free (plugins_dirs);

	/* Preferences */
	win->preferences = anjuta_preferences_new (win->plugin_manager, PREF_SCHEMA);
	g_object_add_weak_pointer (G_OBJECT (win->preferences),
							   (gpointer)&win->preferences);

	g_signal_connect (win->settings, "changed::" GDL_STYLE,
	                  G_CALLBACK (on_gdl_style_changed), win);
	on_gdl_style_changed (win->settings, GDL_STYLE, win);

	/* Register actions */
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_toggle_action_group_entries (win->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, win);

	/* Merge UI */
	anjuta_ui_merge (win->ui, UI_FILE);

	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (win),
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (win->ui)));

	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);

	/* create toolbar */
	win->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/ToolbarMain");
    if (!g_settings_get_boolean (win->settings, TOOLBAR_VISIBLE))
		gtk_widget_hide (win->toolbar);
	gtk_style_context_add_class (gtk_widget_get_style_context (win->toolbar),
	                             GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	gtk_toolbar_set_icon_size (GTK_TOOLBAR (win->toolbar),
	                           GTK_ICON_SIZE_MENU);
	gtk_box_pack_start (GTK_BOX (main_box), win->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (win->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  g_settings_get_boolean (win->settings,
								                          TOOLBAR_VISIBLE));
	g_signal_connect (win->settings, "changed::" TOOLBAR_STYLE,
	                  G_CALLBACK (on_toolbar_style_changed), win);
	on_toolbar_style_changed (win->settings, TOOLBAR_STYLE, win);

	/* Create widgets menu */
	view_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								  "/MenuMain/MenuView");
	win->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));

	/* Create about plugins menu */
	about_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (win), about_menu);

	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);

	/* Connect to session */
	g_signal_connect (G_OBJECT (win), "save_session",
					  G_CALLBACK (on_session_save), win);
	g_signal_connect (G_OBJECT (win), "load_session",
					  G_CALLBACK (on_session_load), win);

	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	win->save_count = 0;
}
Exemplo n.º 3
0
static void
create_window (MduShell *shell)
{
        GtkWidget *vbox;
        GtkWidget *vbox1;
        GtkWidget *vbox2;
        GtkWidget *menubar;
        GtkAccelGroup *accel_group;
        GtkWidget *hpane;
        GtkWidget *tree_view_scrolled_window;
        GtkTreeSelection *select;
        GtkWidget *label;
        GtkTreeViewColumn *column;
        GError *error;

        error = NULL;
        if (!add_pool (shell, NULL, NULL, &error)) {
                g_printerr ("Error creating pool: `%s'\n", error->message);
                g_error_free (error);
                g_critical ("Bailing out");
        }

        shell->priv->app_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_resizable (GTK_WINDOW (shell->priv->app_window), TRUE);
        gtk_window_set_default_size (GTK_WINDOW (shell->priv->app_window), 800, 600);
        gtk_window_set_title (GTK_WINDOW (shell->priv->app_window), _("Disk Utility"));

        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (shell->priv->app_window), vbox);

        shell->priv->ui_manager = create_ui_manager (shell);
        accel_group = gtk_ui_manager_get_accel_group (shell->priv->ui_manager);
        gtk_window_add_accel_group (GTK_WINDOW (shell->priv->app_window), accel_group);

        menubar = gtk_ui_manager_get_widget (shell->priv->ui_manager, "/menubar");
        gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);

        /* tree view */
        tree_view_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_view_scrolled_window),
                                        GTK_POLICY_NEVER,
                                        GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (tree_view_scrolled_window),
                                             GTK_SHADOW_IN);
        shell->priv->model = mdu_pool_tree_model_new (shell->priv->pools,
                                                      NULL,
                                                      MDU_POOL_TREE_MODEL_FLAGS_NO_VOLUMES);
        shell->priv->tree_view = mdu_pool_tree_view_new (shell->priv->model,
                                                         MDU_POOL_TREE_VIEW_FLAGS_NONE);
        g_object_unref (shell->priv->model);
        gtk_container_add (GTK_CONTAINER (tree_view_scrolled_window), shell->priv->tree_view);


        /* --- */

        vbox1 = gtk_vbox_new (FALSE, 0);

        /* --- */

        vbox2 = gtk_vbox_new (FALSE, 0);
        //gtk_container_set_border_width (GTK_CONTAINER (vbox2), 12);
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0);

        /* --- */

        shell->priv->sections_vbox = gtk_vbox_new (FALSE, 12);
        gtk_container_set_border_width (GTK_CONTAINER (shell->priv->sections_vbox), 6);
        gtk_box_pack_start (GTK_BOX (vbox2), shell->priv->sections_vbox, TRUE, TRUE, 0);

        /* setup and add horizontal pane */
        hpane = gtk_hpaned_new ();

        label = gtk_label_new (NULL);
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label),
                                            _("_Storage Devices"));
        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), shell->priv->tree_view);

        column = gtk_tree_view_get_column (GTK_TREE_VIEW (shell->priv->tree_view), 0);
        gtk_tree_view_column_set_widget (column, label);
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (shell->priv->tree_view), TRUE);
        gtk_widget_show (label);

        gtk_paned_add1 (GTK_PANED (hpane), tree_view_scrolled_window);
        gtk_paned_add2 (GTK_PANED (hpane), vbox1);
        gtk_widget_set_size_request (shell->priv->tree_view, 260, -1),
        //gtk_paned_set_position (GTK_PANED (hpane), 260);

        gtk_box_pack_start (GTK_BOX (vbox), hpane, TRUE, TRUE, 0);

        select = gtk_tree_view_get_selection (GTK_TREE_VIEW (shell->priv->tree_view));
        gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
        g_signal_connect (select, "changed", (GCallback) device_tree_changed, shell);

        /* when starting up, set focus on tree view */
        gtk_widget_grab_focus (shell->priv->tree_view);

        g_signal_connect (shell->priv->app_window, "delete-event", gtk_main_quit, NULL);

        gtk_widget_show_all (vbox);

        mdu_pool_tree_view_select_first_presentable (MDU_POOL_TREE_VIEW (shell->priv->tree_view));
}
Exemplo n.º 4
0
int main (int argc, char *argv[]) {
    /* set up i18n */
    bindtextdomain (PACKAGE, GUMMI_LOCALES);
    setlocale (LC_ALL, "");
    textdomain (PACKAGE);

    GError* error = NULL;
    GOptionContext* context = g_option_context_new ("files");
    g_option_context_add_main_entries (context, entries, PACKAGE);
    g_option_context_parse (context, &argc, &argv, &error);
    if (error) g_error("%s\n", error->message);

    if (showversion) {
        printf("Gummi %s\n", PACKAGE_VERSION);
        return 0;
    }

    /* initialize GTK */
    g_thread_init (NULL);
    gdk_threads_init ();
    gtk_init (&argc, &argv);
    GError* ui_error = NULL;
    GtkBuilder* builder = gtk_builder_new ();
    gchar* ui = g_build_filename (GUMMI_DATA, "ui", "gummi.glade", NULL);

    // exit program when gummi.glade can not be located:
    if (!g_file_test (ui, G_FILE_TEST_EXISTS)) {
        printf("Could not locate Glade interface file at:\n%s\n", ui);
        return 0;
    }

    gtk_builder_add_from_file (builder, ui, &ui_error);
    if (ui_error) {
        g_error ("%s\n", ui_error->message);
    }
    gtk_builder_set_translation_domain (builder, PACKAGE);
    g_free (ui);

    /* Initialize logging */
    slog_init (debug);
    slog (L_INFO, PACKAGE_NAME" version: "PACKAGE_VERSION"\n");

    /* Initialize configuration */
    gchar* configname = g_build_filename (g_get_user_config_dir (), "gummi",
                                  "gummi.cfg", NULL);
    config_init (configname);
    config_load ();
    g_free (configname);

    /* Initialize signals */
    gummi_signals_register ();

    /* Initialize Classes */
    gchar* snippetsname = g_build_filename (g_get_user_config_dir (), "gummi",
            "snippets.cfg", NULL);

    // why do we not load this from environment, like gui-main does? -A
    GuMotion* motion = motion_init ();
    GuIOFunc* io = iofunctions_init();
    GuLatex* latex = latex_init ();
    GuBiblio* biblio = biblio_init (builder);
    GuTemplate* templ = template_init (builder);
    GuTabmanager* tabm = tabmanager_init ();
    GuProject* proj = project_init ();

    GuSnippets* snippets = snippets_init (snippetsname);
    gummi = gummi_init (motion, io, latex, biblio, templ, snippets, tabm, proj);
    slog (L_DEBUG, "Gummi created!\n");
    g_free (snippetsname);

    /* Initialize GUI */
    gui = gui_init (builder);

    slog_set_gui_parent (gui->mainwindow);
    slog (L_DEBUG, "GummiGui created!\n");

    /* Start compile thread */
    if (external_exists (config_get_value("typesetter"))) {
        typesetter_setup ();
        motion_start_compile_thread (motion);
    }
    else {
        infoscreengui_enable (gui->infoscreengui, "program_error");
        slog (L_ERROR, "Could not locate the typesetter program\n");
    }

    /* Install acceleration group to mainwindow */
    gtk_window_add_accel_group (gui->mainwindow, snippets->accel_group);

    if (argc != 2)
        tabmanager_create_tab (A_DEFAULT, NULL, NULL);
    else {
        if (!g_file_test(argv[1], G_FILE_TEST_EXISTS)) {
            slog(L_ERROR, "Failed to open file '%s': No such file or "
                    "directory\n", argv[1]);
            exit(1);
        }
        tabmanager_create_tab (A_LOAD, argv[1], NULL);
    }

    if (config_get_value ("autosaving")) iofunctions_start_autosave ();

    gui_main (builder);
    config_save ();
    config_clean_up ();
    return 0;
}
Exemplo n.º 5
0
void gtkui_create_menu(int live)
{
   GtkAccelGroup *accel_group;
   GtkWidget *vbox, *item;
   GtkItemFactory *root_menu;
   int num_items = 0;
   
   DEBUG_MSG("gtk_create_menu");

   /* remove old menu, it will be automatically destroyed by gtk_main */
   vbox = gtk_bin_get_child(GTK_BIN (window));
   gtk_container_remove(GTK_CONTAINER (vbox), main_menu);

   /* Prepare to generate menus from the definitions in ec_gtk.h */
   accel_group = gtk_accel_group_new ();
   root_menu = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
   
   /* Start Menu */
   num_items = sizeof (gmenu_start) / sizeof (gmenu_start[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_start, NULL);
   
   /* Targets Menu */
   num_items = sizeof (gmenu_targets) / sizeof (gmenu_targets[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_targets, NULL);
   
   /* Hosts Menu */
   if (live > 0 && GBL_SNIFF->type != SM_BRIDGED) {
      num_items = sizeof (gmenu_hosts) / sizeof (gmenu_hosts[0]);
      gtk_item_factory_create_items (root_menu, num_items, gmenu_hosts, NULL);
   }
   
   /* View Menu */
   num_items = sizeof (gmenu_view) / sizeof (gmenu_view[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_view, NULL);
   
   /* MITM Menu */
   if (live > 0 && GBL_SNIFF->type != SM_BRIDGED) {
      num_items = sizeof (gmenu_mitm) / sizeof (gmenu_mitm[0]);
      gtk_item_factory_create_items (root_menu, num_items, gmenu_mitm, NULL);
   }
   
   /* Filters Menu */
   num_items = sizeof (gmenu_filters) / sizeof (gmenu_filters[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_filters, NULL);
   
   /* Logging Menu */
   num_items = sizeof (gmenu_logging) / sizeof (gmenu_logging[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_logging, NULL);

#ifdef HAVE_PLUGINS
   /* Plugins Menu */
   if(live > 0) {
      num_items = sizeof (gmenu_plugins) / sizeof (gmenu_plugins[0]);
      gtk_item_factory_create_items (root_menu, num_items, gmenu_plugins, NULL);
   }
#endif

#ifndef OS_WINDOWS
   /* Help Menu */
   num_items = sizeof (gmenu_help) / sizeof (gmenu_help[0]);
   gtk_item_factory_create_items (root_menu, num_items, gmenu_help, NULL);
#endif

   if(GBL_OPTIONS->reversed) {
      GBL_OPTIONS->reversed = 0;
      item = gtk_item_factory_get_item(root_menu, "/Targets/Reverse matching");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM (item), TRUE);
   }

   if(GBL_OPTIONS->resolve) {
      GBL_OPTIONS->resolve = 0;
      item = gtk_item_factory_get_item(root_menu, "/View/Resolve IP addresses");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM (item), TRUE);
   }

   if(GBL_OPTIONS->compress) {
      GBL_OPTIONS->compress = 0;
      item = gtk_item_factory_get_item(root_menu, "/Logging/Compressed file");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM (item), TRUE);
   }

   /* get the menu widget and add it to the window */
   main_menu = gtk_item_factory_get_widget (root_menu, "<main>");
   gtk_box_pack_start(GTK_BOX(vbox), main_menu, FALSE, FALSE, 0);
   gtk_widget_show(main_menu);
}
Exemplo n.º 6
0
static bool_t init (void)
{
    search_tool = aud_plugin_lookup_basename ("search-tool");

    aud_config_set_defaults ("gtkui", gtkui_defaults);

    pw_col_init ();

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_has_resize_grip ((GtkWindow *) window, FALSE);

    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(window_delete), NULL);

    accel = gtk_accel_group_new ();
    gtk_window_add_accel_group ((GtkWindow *) window, accel);

    vbox_outer = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_container_add ((GtkContainer *) window, vbox_outer);

    menu_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start ((GtkBox *) vbox_outer, menu_box, FALSE, FALSE, 0);

    toolbar = gtk_toolbar_new ();
    gtk_toolbar_set_style ((GtkToolbar *) toolbar, GTK_TOOLBAR_ICONS);
    GtkStyleContext * context = gtk_widget_get_style_context (toolbar);
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
    gtk_box_pack_start ((GtkBox *) vbox_outer, toolbar, FALSE, FALSE, 0);

    /* search button */
    if (search_tool)
    {
        search_button = toggle_button_new ("edit-find", toggle_search_tool);
        gtk_toolbar_insert ((GtkToolbar *) toolbar, search_button, -1);
        gtk_toggle_tool_button_set_active ((GtkToggleToolButton *) search_button,
         aud_plugin_get_enabled (search_tool));
        aud_plugin_add_watch (search_tool, search_tool_toggled, NULL);
    }

    /* playback buttons */
    toolbar_button_add (toolbar, button_open_pressed, "document-open");
    toolbar_button_add (toolbar, button_add_pressed, "list-add");
    button_play = toolbar_button_add (toolbar, aud_drct_play_pause, "media-playback-start");
    button_stop = toolbar_button_add (toolbar, aud_drct_stop, "media-playback-stop");
    toolbar_button_add (toolbar, aud_drct_pl_prev, "media-skip-backward");
    toolbar_button_add (toolbar, aud_drct_pl_next, "media-skip-forward");

    /* time slider and label */
    GtkToolItem * boxitem1 = gtk_tool_item_new ();
    gtk_tool_item_set_expand (boxitem1, TRUE);
    gtk_toolbar_insert ((GtkToolbar *) toolbar, boxitem1, -1);

    GtkWidget * box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_add ((GtkContainer *) boxitem1, box1);

    slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
    gtk_range_set_increments ((GtkRange *) slider, 5000, 5000);
    gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
    gtk_widget_set_size_request(slider, 120, -1);
    gtk_widget_set_valign (slider, GTK_ALIGN_CENTER);
    gtk_widget_set_can_focus(slider, FALSE);
    gtk_box_pack_start ((GtkBox *) box1, slider, TRUE, TRUE, 6);

    label_time = markup_label_new(NULL);
    gtk_box_pack_end ((GtkBox *) box1, label_time, FALSE, FALSE, 6);

    gtk_widget_set_no_show_all (slider, TRUE);
    gtk_widget_set_no_show_all (label_time, TRUE);

    /* repeat and shuffle buttons */
    button_repeat = toggle_button_new ("media-playlist-repeat", toggle_repeat);
    gtk_toolbar_insert ((GtkToolbar *) toolbar, button_repeat, -1);
    button_shuffle = toggle_button_new ("media-playlist-shuffle", toggle_shuffle);
    gtk_toolbar_insert ((GtkToolbar *) toolbar, button_shuffle, -1);

    /* volume button */
    GtkToolItem * boxitem2 = gtk_tool_item_new ();
    gtk_toolbar_insert ((GtkToolbar *) toolbar, boxitem2, -1);

    GtkWidget * box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_add ((GtkContainer *) boxitem2, box2);

    volume = gtk_volume_button_new();
    gtk_button_set_relief(GTK_BUTTON(volume), GTK_RELIEF_NONE);
    gtk_scale_button_set_adjustment(GTK_SCALE_BUTTON(volume), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 100, 1, 5, 0)));
    gtk_widget_set_can_focus(volume, FALSE);

    int lvol = 0, rvol = 0;
    aud_drct_get_volume(&lvol, &rvol);
    gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume), (lvol + rvol) / 2);

    gtk_box_pack_start ((GtkBox *) box2, volume, FALSE, FALSE, 0);

    /* main UI layout */
    layout_load ();

    GtkWidget * layout = layout_new ();
    gtk_box_pack_start ((GtkBox *) vbox_outer, layout, TRUE, TRUE, 0);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    layout_add_center (vbox);

    ui_playlist_notebook_new ();
    gtk_box_pack_start ((GtkBox *) vbox, (GtkWidget *) UI_PLAYLIST_NOTEBOOK, TRUE, TRUE, 0);

    /* optional UI elements */
    show_menu (aud_get_bool ("gtkui", "menu_visible"));
    show_infoarea (aud_get_bool ("gtkui", "infoarea_visible"));

    if (aud_get_bool ("gtkui", "statusbar_visible"))
    {
        statusbar = ui_statusbar_new ();
        gtk_box_pack_end ((GtkBox *) vbox_outer, statusbar, FALSE, FALSE, 0);
    }

    AUDDBG("hooks associate\n");
    ui_hooks_associate();

    AUDDBG("playlist associate\n");
    ui_playlist_notebook_populate();

    g_signal_connect(slider, "change-value", G_CALLBACK(ui_slider_change_value_cb), NULL);
    g_signal_connect(slider, "button-press-event", G_CALLBACK(ui_slider_button_press_cb), NULL);
    g_signal_connect(slider, "button-release-event", G_CALLBACK(ui_slider_button_release_cb), NULL);

    volume_change_handler_id = g_signal_connect(volume, "value-changed", G_CALLBACK(ui_volume_value_changed_cb), NULL);
    g_signal_connect(volume, "pressed", G_CALLBACK(ui_volume_pressed_cb), NULL);
    g_signal_connect(volume, "released", G_CALLBACK(ui_volume_released_cb), NULL);
    update_volume_timeout_source = g_timeout_add(250, (GSourceFunc) ui_volume_slider_update, volume);

    g_signal_connect (window, "map-event", (GCallback) window_mapped_cb, NULL);
    g_signal_connect (window, "key-press-event", (GCallback) window_keypress_cb, NULL);
    g_signal_connect (UI_PLAYLIST_NOTEBOOK, "key-press-event", (GCallback) playlist_keypress_cb, NULL);

    if (aud_drct_get_playing ())
    {
        ui_playback_begin ();
        if (aud_drct_get_ready ())
            ui_playback_ready ();
    }
    else
        ui_playback_stop ();

    title_change_cb ();

    gtk_widget_show_all (vbox_outer);

    update_toggles (NULL, NULL);

    menu_rclick = make_menu_rclick (accel);
    menu_tab = make_menu_tab (accel);

    return TRUE;
}
Exemplo n.º 7
0
static GtkWidget *create_window(void)
{
  GtkWidget *startwin;
  GtkWidget *hlayout;
  GtkWidget *banner;
  GtkWidget *vlayout;
  GtkWidget *tabs;
  GtkWidget *configvlayout;
  GtkWidget *configlayout;
  GtkWidget *vmode3dlabel;
  GtkWidget *vmode3dcombo;
  GtkWidget *fullscreencheck;
  GtkWidget *alwaysshowcheck;
  GtkWidget *configtab;
  GtkWidget *messagesscroll;
  GtkWidget *messagestext;
  GtkWidget *messagestab;
  GtkWidget *buttons;
  GtkWidget *cancelbutton;
  GtkWidget *cancelbuttonalign;
  GtkWidget *cancelbuttonlayout;
  GtkWidget *cancelbuttonicon;
  GtkWidget *cancelbuttonlabel;
  GtkWidget *startbutton;
  GtkWidget *startbuttonalign;
  GtkWidget *startbuttonlayout;
  GtkWidget *startbuttonicon;
  GtkWidget *startbuttonlabel;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  // Basic window
  startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (startwin), apptitle);	// NOTE: use global app title
  gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER);
  gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE);
  gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG);

  // Horizontal layout of banner and controls
  hlayout = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hlayout);
  gtk_container_add (GTK_CONTAINER (startwin), hlayout);

  // Banner
  {
	GdkPixbuf *pixbuf = load_banner();
	banner = gtk_image_new_from_pixbuf(pixbuf);
	g_object_unref((gpointer)pixbuf);
  }
  gtk_widget_show (banner);
  gtk_box_pack_start (GTK_BOX (hlayout), banner, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (banner), 0.5, 0);

  // Vertical layout of tab control and start+cancel buttons
  vlayout = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vlayout);
  gtk_box_pack_start (GTK_BOX (hlayout), vlayout, TRUE, TRUE, 0);

  // Tab control
  tabs = gtk_notebook_new ();
  gtk_widget_show (tabs);
  gtk_box_pack_start (GTK_BOX (vlayout), tabs, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (tabs), 4);

  // Vertical layout of config page main body
  configvlayout = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (configvlayout);
  gtk_container_add (GTK_CONTAINER (tabs), configvlayout);

  // Fixed-position layout of config page controls
  configlayout = gtk_fixed_new ();
  gtk_widget_show (configlayout);
  gtk_box_pack_start (GTK_BOX (configvlayout), configlayout, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (configlayout), 6);

  // 3D video mode label
  vmode3dlabel = gtk_label_new_with_mnemonic ("_Video mode:");
  gtk_widget_show (vmode3dlabel);
  gtk_fixed_put (GTK_FIXED (configlayout), vmode3dlabel, 0, 0);
  gtk_widget_set_size_request (vmode3dlabel, 88, 29);
  gtk_misc_set_alignment (GTK_MISC (vmode3dlabel), 0, 0.5);

  // 3D video mode combo
  {
	GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
	GtkCellRenderer *cell;

	vmode3dcombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list));
	g_object_unref(G_OBJECT(list));

	cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL);
  }
  gtk_widget_show (vmode3dcombo);
  gtk_fixed_put (GTK_FIXED (configlayout), vmode3dcombo, 88, 0);
  gtk_widget_set_size_request (vmode3dcombo, 150, 29);
  gtk_widget_add_accelerator (vmode3dcombo, "grab_focus", accel_group,
                              GDK_V, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);

  // Fullscreen checkbox
  fullscreencheck = gtk_check_button_new_with_mnemonic ("_Fullscreen");
  gtk_widget_show (fullscreencheck);
  gtk_fixed_put (GTK_FIXED (configlayout), fullscreencheck, 248, 0);
  gtk_widget_set_size_request (fullscreencheck, 85, 29);
  gtk_widget_add_accelerator (fullscreencheck, "grab_focus", accel_group,
                              GDK_F, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);

  // Always show config checkbox
  alwaysshowcheck = gtk_check_button_new_with_mnemonic ("_Always show configuration on start");
  gtk_widget_show (alwaysshowcheck);
  gtk_box_pack_start (GTK_BOX (configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
  gtk_widget_add_accelerator (alwaysshowcheck, "grab_focus", accel_group,
                              GDK_A, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);

  // Configuration tab
  configtab = gtk_label_new ("Configuration");
  gtk_widget_show (configtab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 0), configtab);

  // Messages scrollable area
  messagesscroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (messagesscroll);
  gtk_container_add (GTK_CONTAINER (tabs), messagesscroll);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

  // Messages text area
  messagestext = gtk_text_view_new ();
  gtk_widget_show (messagestext);
  gtk_container_add (GTK_CONTAINER (messagesscroll), messagestext);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (messagestext), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (messagestext), GTK_WRAP_WORD);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (messagestext), FALSE);
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (messagestext), 2);
  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (messagestext), 2);

  // Messages tab
  messagestab = gtk_label_new ("Messages");
  gtk_widget_show (messagestab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 1), messagestab);

  // Dialogue box buttons layout
  buttons = gtk_hbutton_box_new ();
  gtk_widget_show (buttons);
  gtk_box_pack_start (GTK_BOX (vlayout), buttons, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END);

  // Cancel button
  cancelbutton = gtk_button_new ();
  gtk_widget_show (cancelbutton);
  gtk_container_add (GTK_CONTAINER (buttons), cancelbutton);
  GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT);
  gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group,
                              GDK_C, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group,
                              GDK_Escape, 0,
                              GTK_ACCEL_VISIBLE);

  cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (cancelbuttonalign);
  gtk_container_add (GTK_CONTAINER (cancelbutton), cancelbuttonalign);

  cancelbuttonlayout = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (cancelbuttonlayout);
  gtk_container_add (GTK_CONTAINER (cancelbuttonalign), cancelbuttonlayout);

  cancelbuttonicon = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (cancelbuttonicon);
  gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);

  cancelbuttonlabel = gtk_label_new_with_mnemonic ("_Cancel");
  gtk_widget_show (cancelbuttonlabel);
  gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);

  // Start button
  startbutton = gtk_button_new ();
  gtk_widget_show (startbutton);
  gtk_container_add (GTK_CONTAINER (buttons), startbutton);
  GTK_WIDGET_SET_FLAGS (startbutton, GTK_CAN_DEFAULT);
  gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group,
                              GDK_S, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_widget_add_accelerator (startbutton, "clicked", accel_group,
                              GDK_Return, 0,
                              GTK_ACCEL_VISIBLE);

  startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (startbuttonalign);
  gtk_container_add (GTK_CONTAINER (startbutton), startbuttonalign);

  startbuttonlayout = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (startbuttonlayout);
  gtk_container_add (GTK_CONTAINER (startbuttonalign), startbuttonlayout);

  startbuttonicon = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (startbuttonicon);
  gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);

  startbuttonlabel = gtk_label_new_with_mnemonic ("_Start");
  gtk_widget_show (startbuttonlabel);
  gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);

  // Wire up the signals
  g_signal_connect ((gpointer) startwin, "delete_event",
                    G_CALLBACK (on_startwin_delete_event),
                    NULL);
  g_signal_connect ((gpointer) vmode3dcombo, "changed",
                    G_CALLBACK (on_vmode3dcombo_changed),
                    NULL);
  g_signal_connect ((gpointer) fullscreencheck, "toggled",
                    G_CALLBACK (on_fullscreencheck_toggled),
                    NULL);
  g_signal_connect ((gpointer) alwaysshowcheck, "toggled",
                    G_CALLBACK (on_alwaysshowcheck_toggled),
                    NULL);
  g_signal_connect ((gpointer) cancelbutton, "clicked",
                    G_CALLBACK (on_cancelbutton_clicked),
                    NULL);
  g_signal_connect ((gpointer) startbutton, "clicked",
                    G_CALLBACK (on_startbutton_clicked),
                    NULL);

  // Associate labels with their controls
  gtk_label_set_mnemonic_widget (GTK_LABEL (vmode3dlabel), vmode3dcombo);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin");
  GLADE_HOOKUP_OBJECT (startwin, hlayout, "hlayout");
  GLADE_HOOKUP_OBJECT (startwin, banner, "banner");
  GLADE_HOOKUP_OBJECT (startwin, vlayout, "vlayout");
  GLADE_HOOKUP_OBJECT (startwin, tabs, "tabs");
  GLADE_HOOKUP_OBJECT (startwin, configvlayout, "configvlayout");
  GLADE_HOOKUP_OBJECT (startwin, configlayout, "configlayout");
  GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel");
  GLADE_HOOKUP_OBJECT (startwin, vmode3dcombo, "vmode3dcombo");
  GLADE_HOOKUP_OBJECT (startwin, fullscreencheck, "fullscreencheck");
  GLADE_HOOKUP_OBJECT (startwin, alwaysshowcheck, "alwaysshowcheck");
  GLADE_HOOKUP_OBJECT (startwin, configtab, "configtab");
  GLADE_HOOKUP_OBJECT (startwin, messagesscroll, "messagesscroll");
  GLADE_HOOKUP_OBJECT (startwin, messagestext, "messagestext");
  GLADE_HOOKUP_OBJECT (startwin, messagestab, "messagestab");
  GLADE_HOOKUP_OBJECT (startwin, buttons, "buttons");
  GLADE_HOOKUP_OBJECT (startwin, cancelbutton, "cancelbutton");
  GLADE_HOOKUP_OBJECT (startwin, cancelbuttonalign, "cancelbuttonalign");
  GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlayout, "cancelbuttonlayout");
  GLADE_HOOKUP_OBJECT (startwin, cancelbuttonicon, "cancelbuttonicon");
  GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlabel, "cancelbuttonlabel");
  GLADE_HOOKUP_OBJECT (startwin, startbutton, "startbutton");
  GLADE_HOOKUP_OBJECT (startwin, startbuttonalign, "startbuttonalign");
  GLADE_HOOKUP_OBJECT (startwin, startbuttonlayout, "startbuttonlayout");
  GLADE_HOOKUP_OBJECT (startwin, startbuttonicon, "startbuttonicon");
  GLADE_HOOKUP_OBJECT (startwin, startbuttonlabel, "startbuttonlabel");

  gtk_window_add_accel_group (GTK_WINDOW (startwin), accel_group);

  return startwin;
}
Exemplo n.º 8
0
/*主界面进入点*/
int main(int argc,char **argv)
{
	GtkWidget *win;
	GtkWidget *menu;
	GtkWidget *menu_bar;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *text;
	GtkWidget *scrolled;
	GtkWidget *open;
	GtkWidget *close;
	GtkWidget *clean;
	GtkTextBuffer *buffer;
	GtkAccelGroup *accel_group;
	PangoFontDescription *font_name;
	DATA data;
	CONFDATA conf;
	ABOUT about_data;
	//HELP help_data;
	struct sigaction act,old;

	setpgrp();

	init_with_conf(&conf);
	init_about_data(&about_data);
	//init_help_data(&help_data);

	data.buf=g_string_new(NULL);
	data.python_path=conf.python_path;
	data.proxy_py_path=conf.proxy_py_path;
	setlocale(LC_ALL,"");

	/*设置语言环境*/
	if(conf.language_env == NULL)
	{
		setlocale(LC_CTYPE,"zh_CN.UTF-8");
		setenv("LANG","zh_CN.UTF-8",1);
	}
	else
	{
		setlocale(LC_CTYPE,conf.language_env);
		setenv("LANG",conf.language_env,1);
	}
	
	if(conf.gtk_goagent_path!=NULL)
		chdir(conf.gtk_goagent_path);

	/*是否自动更新
	 * 如果是则在后台运行版更新进程
	 */
	if(strcmp(conf.goagent_auto_upgrade,"true")==0)
		auto_upgrade_goagent(GOAGENT_URL,&conf);

	/*国际化*/
	bindtextdomain("gtk_goagent","./locale/");
	textdomain("gtk_goagent");

	act.sa_flags=0;
	act.sa_handler=clean_data;
	/*设置自定义信号处理
	 * 用于在启动GoAgent失败时清理数据
	 */
	sigaction(SIGUSR1,&act,&old);

	gtk_init(&argc,&argv);

	win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(win),GTK_WIN_POS_CENTER);
	gtk_window_set_title(GTK_WINDOW(win),"Gtk GoAgent");
	gtk_window_set_icon_from_file(GTK_WINDOW(win),"img/64x64/gtk_goagent.png",NULL);

	create_tray(win);
	//create_pre_ui(&pre,&conf);

	vbox=gtk_vbox_new(FALSE,0);
	accel_group=gtk_accel_group_new();
	gtk_window_add_accel_group(GTK_WINDOW(win),accel_group);
	gtk_container_add(GTK_CONTAINER(win),vbox);

	text=gtk_text_view_new();

	/*设置日志显示框字体*/
	if(conf.font!=NULL)
	{
		font_name=pango_font_description_from_string(conf.font);
		gtk_widget_modify_font(text,font_name);
	}

	buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	/*创建红色黑色和黄色标记
	 * 正常日志黑色输出
	 * 绿色用于警告
	 * 红色用于错误
	 * 黄色用于调试
	 */
	gtk_text_buffer_create_tag(buffer,"green_fg",
			"foreground","green",NULL);
	gtk_text_buffer_create_tag(buffer,"red_fg","foreground",
			"red",NULL);
	gtk_text_buffer_create_tag(buffer,"black_fg","foreground",
			"black",NULL);
	gtk_text_buffer_create_tag(buffer,"yellow_fg",
			"foreground","yellow",NULL);

	data.text=text;
	data.off=0;

	menu_bar=gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(vbox),menu_bar,FALSE,FALSE,0);
	/*创建菜单*/
	menu=create_menu(menu_bar,_("_File"));
	create_menu_with_image(menu,GTK_STOCK_OPEN,accel_group,connect_goagent,&data);
	create_menu_with_image(menu,GTK_STOCK_CLOSE,accel_group,disconnect_goagent,&data);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),gtk_separator_menu_item_new());
	create_menu_with_image(menu,GTK_STOCK_QUIT,accel_group,really_quit,&data);

	menu=create_menu(menu_bar,_("_Edit"));
	create_menu_with_image(menu,GTK_STOCK_PREFERENCES,accel_group,preferences,NULL);
	create_menu_with_image(menu,_("Up_load"),accel_group,upload,&conf);

	menu=create_menu(menu_bar,_("_Help"));
	create_menu_with_image(menu,GTK_STOCK_HELP,accel_group,help,NULL);
	create_menu_with_image(menu,GTK_STOCK_ABOUT,accel_group,about,&about_data);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),gtk_separator_menu_item_new());
	create_menu_with_image(menu,_("Upgrade GoAg_ent"),accel_group,upgrade_goagent,conf.proxy_py_path);
	//create_menu_with_image(menu,_("Upgrade _Gtk GoAGent"),accel_group,upgrade_gtk_goagent,NULL);

	gtk_widget_set_size_request(text,0x300,0x180);
	/*设置显示构件不可编辑和自动换行*/
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text),FALSE);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text),GTK_WRAP_CHAR);
	/*创建滚动条并设置自动更新*/
	scrolled=gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrolled),text);
	gtk_box_pack_start(GTK_BOX(vbox),scrolled,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(vbox),gtk_separator_menu_item_new(),FALSE,FALSE,5);
	show_time(vbox);
	gtk_box_pack_start(GTK_BOX(vbox),gtk_separator_menu_item_new(),FALSE,FALSE,5);

	hbox=gtk_hbox_new(FALSE,0);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
	
	open=gtk_button_new_with_label(_("Connect"));
	gtk_box_pack_start(GTK_BOX(hbox),open,FALSE,FALSE,30);
	g_signal_connect(G_OBJECT(open),"clicked",G_CALLBACK(connect_goagent),&data);
	clean=gtk_button_new_with_label(_("Clean"));
	gtk_box_pack_start(GTK_BOX(hbox),clean,TRUE,TRUE,100);
	g_signal_connect(G_OBJECT(clean),"clicked",G_CALLBACK(clean_buffer),&data);
	close=gtk_button_new_with_label(_("Disconnect"));
	gtk_box_pack_end(GTK_BOX(hbox),close,FALSE,FALSE,30);
	g_signal_connect(G_OBJECT(close),"clicked",G_CALLBACK(disconnect_goagent),&data);

	g_signal_connect(G_OBJECT(win),"delete_event",G_CALLBACK(really_quit),NULL);

	gtk_widget_show_all(win);

	gtk_main();

	//setpgrp();
	g_idle_remove_by_data(&data);
	g_string_free(data.buf,TRUE);

	kill(0,SIGKILL);
	//killpg(getpgrp(),SIGKILL);
	while(waitpid(-1,NULL,WNOHANG)!=-1);
	//g_idle_remove_by_data(&data);

	return 0;
}
Exemplo n.º 9
0
 void IWindow::add_accel_group(AccelGroup group)
 {
     gtk_window_add_accel_group(this, group);
 }
Exemplo n.º 10
0
GtkWindow * gw_progress_bar_box_create ( GtkWindow *window, gchar *title, gchar *subject, gchar *text, gfloat max, func_stop_progress_t stop, gpointer p)
{
	GtkWidget *w = NULL;
	GtkWidget *frame;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *file_name;
	GtkWidget *progress_bar	= NULL;
	GtkWidget *button;
	guint button_key;
	GtkAccelGroup *accel = NULL;
	gchar *text_utf8 = NULL;


#ifdef GW_DEBUG_GUI_COMPONENT
	g_print	( "*** GW - %s (%d) :: %s() : %f\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, max);
#endif

	/* Inits accel group for keystroke shortcuts */
	accel =	gtk_accel_group_new ( );

	if ( !w	)
	{
		w = gtk_window_new ( GTK_WINDOW_DIALOG);
		gtk_window_set_policy (	GTK_WINDOW ( w), FALSE,	FALSE, FALSE);
		g_strdup_to_gtk_text ( title, text_utf8);
		gtk_window_set_title ( GTK_WINDOW ( w),	text_utf8);
		g_free ( text_utf8);
		gtk_container_border_width ( GTK_CONTAINER ( w), 5);

		gtk_window_set_modal ( GTK_WINDOW ( w),TRUE);
		gtk_window_set_transient_for ( GTK_WINDOW ( w),	window);
		gtk_window_set_position	( GTK_WINDOW ( w), GTK_WIN_POS_CENTER);

		gtk_widget_ref ( GTK_WIDGET ( window));
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_PARENT_WINDOW, window, (GtkDestroyNotify) gtk_widget_unref);

		if ( stop != NULL )
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect signals on delete_event and destroy\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

			/* These signals do nothing. In	this way the window cannot be destroyed. What must be done when	stop is	NULL? */
			gtk_signal_connect ( GTK_OBJECT	( w), "delete_event", GTK_SIGNAL_FUNC (	gw_progress_bar_box_signal_do_nothing), NULL);
			gtk_signal_connect ( GTK_OBJECT	( w), "destroy", GTK_SIGNAL_FUNC ( gw_progress_bar_box_signal_do_nothing),	NULL);
		}

		g_strdup_to_gtk_text ( subject, text_utf8);
		frame =	gtk_frame_new (	text_utf8);
		g_free ( text_utf8);
		gtk_container_add ( GTK_CONTAINER ( w),	frame);

		vbox = gtk_vbox_new ( FALSE, 0);
		gtk_container_add ( GTK_CONTAINER ( frame), vbox);
		gtk_container_set_border_width ( GTK_CONTAINER ( vbox),	10);

		g_strdup_to_gtk_text ( text, text_utf8);
		file_name = gtk_label_new ( text_utf8);
		g_free ( text_utf8);

		/* Store the reference to the text info	label to describe the current processing. */
		gtk_widget_ref ( file_name);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_TEXT_INFO_LABEL, file_name,	(GtkDestroyNotify) gtk_widget_unref);
		gtk_label_set_justify (	GTK_LABEL ( file_name),	GTK_JUSTIFY_LEFT);
		gtk_box_pack_start ( GTK_BOX ( vbox), file_name, TRUE, TRUE, 0);

#ifdef GW_DEBUG_GUI_COMPONENT
		g_print	( "*** GW - %s (%d) :: %s() : creates the real progress	bar\n",	__FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif
		progress_bar = gtk_progress_bar_new ( );

		/* Store reference to the real progress	bar */
		gtk_widget_ref ( progress_bar);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_PROGRESS_BAR, progress_bar,	(GtkDestroyNotify) gtk_widget_unref);

		/* Doesn't show	the progress bar if max	value is 0 */
		if ( max > 0 )
		{
			gtk_progress_configure ( GTK_PROGRESS (	progress_bar), 0, 0, max);
			gtk_progress_set_show_text ( GTK_PROGRESS ( progress_bar), TRUE);

			/* Set the format string of progess state visualization	*/
			g_strdup_to_gtk_text ( GW_PROGRESS_BAR_BOX_PROGRESS_BAR_FORMAT_STRING, text_utf8);
			gtk_progress_set_format_string ( GTK_PROGRESS (	progress_bar), text_utf8);
			g_free ( text_utf8);
			gtk_box_pack_start ( GTK_BOX ( vbox), progress_bar, TRUE, TRUE,	0);
		}

		hbox = gtk_hbox_new ( TRUE, 10);
		gtk_container_add ( GTK_CONTAINER ( vbox), hbox);
		gtk_container_set_border_width ( GTK_CONTAINER ( hbox),	5);

		button = gtk_button_new_with_label ( "");

		/* Store reference to the ok/cancel button */
		gtk_widget_ref ( button);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_OK_CANCEL_BUTTON, button, (GtkDestroyNotify) gtk_widget_unref);
		gw_progress_bar_box_set_state ( GTK_WINDOW ( w), STATE_CANCEL);
		g_strdup_to_gtk_text ( _( "_Cancel"), text_utf8);
		button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
		g_free ( text_utf8);
		gtk_widget_add_accelerator ( button, "clicked",	accel, button_key, GDK_MOD1_MASK, 0);
		gtk_object_set_user_data ( GTK_OBJECT (	button), w);
		gtk_box_pack_start ( GTK_BOX ( hbox), button, TRUE, TRUE, 0);
		gtk_widget_grab_focus ( button);

		if ( stop != NULL )
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect custom callback on ok/cancel button\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

			gtk_signal_connect ( GTK_OBJECT	( button), "clicked", GTK_SIGNAL_FUNC (	stop), p);
		}
		else
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect standard callback	on ok/cancel button\n",	__FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

			gtk_signal_connect ( GTK_OBJECT	( button), "clicked", GTK_SIGNAL_FUNC (	gw_progress_bar_box_ok_cancel_click), w);
		}

		gtk_window_add_accel_group ( GTK_WINDOW	( w), accel);
	}

	if ( !GTK_WIDGET_VISIBLE ( w) )
	{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : show window\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

		gtk_widget_show_all ( w);
	}
	else
	{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : destroy window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

		gtk_widget_destroy ( w);
	}

	return GTK_WINDOW ( w);
}
Exemplo n.º 11
0
BOOL
create_confirm (HWND hwnd, LPCSTR dsn, LPCSTR text)
{
  GtkWidget *confirm, *dialog_vbox1, *hbox1, *pixmap1, *l_text;
  GtkWidget *dialog_action_area1, *hbuttonbox1, *b_yes, *b_no;
  guint b_yes_key, b_no_key;
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle *style;
  GtkAccelGroup *accel_group;
  char msg[1024];
  TCONFIRM confirm_t;

  if (hwnd == NULL || !GTK_IS_WIDGET (hwnd))
    return FALSE;

  accel_group = gtk_accel_group_new ();

  confirm = gtk_dialog_new ();
  if (dsn)
    sprintf (msg, "Confirm action/operation on %s", dsn);
  else
    sprintf (msg, "Confirm action/operation ...");
  gtk_object_set_data (GTK_OBJECT (confirm), "confirm", confirm);
  gtk_widget_set_size_request (confirm, 400, 150);
  gtk_window_set_title (GTK_WINDOW (confirm), msg);
  gtk_window_set_position (GTK_WINDOW (confirm), GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (confirm), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (confirm), 400, 150);
  gtk_window_set_type_hint (GTK_WINDOW (confirm), GDK_WINDOW_TYPE_HINT_DIALOG);

#if GTK_CHECK_VERSION(2,0,0)
  gtk_widget_show (confirm);
#endif

  dialog_vbox1 = GTK_DIALOG (confirm)->vbox;
  gtk_object_set_data (GTK_OBJECT (confirm), "dialog_vbox1", dialog_vbox1);
  gtk_widget_show (dialog_vbox1);

  hbox1 = gtk_hbox_new (FALSE, 6);
  gtk_widget_ref (hbox1);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "hbox1", hbox1,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 6);

#if GTK_CHECK_VERSION(2,0,0)
  style = gtk_widget_get_style (confirm);
  pixmap =
      gdk_pixmap_create_from_xpm_d (confirm->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) question_xpm);
#else
  style = gtk_widget_get_style (GTK_WIDGET (hwnd));
  pixmap =
      gdk_pixmap_create_from_xpm_d (GTK_WIDGET (hwnd)->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) question_xpm);
#endif

  pixmap1 = gtk_pixmap_new (pixmap, mask);
  gtk_widget_ref (pixmap1);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "pixmap1", pixmap1,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pixmap1);
  gtk_box_pack_start (GTK_BOX (hbox1), pixmap1, FALSE, FALSE, 0);

  l_text = gtk_label_new ("");
  gtk_label_parse_uline (GTK_LABEL (l_text), text);
  gtk_widget_ref (l_text);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "l_text", l_text,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_text);
  gtk_box_pack_start (GTK_BOX (hbox1), l_text, TRUE, TRUE, 0);
  gtk_label_set_justify (GTK_LABEL (l_text), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (l_text), TRUE);

  dialog_action_area1 = GTK_DIALOG (confirm)->action_area;
  gtk_object_set_data (GTK_OBJECT (confirm), "dialog_action_area1",
      dialog_action_area1);
  gtk_widget_show (dialog_action_area1);
  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 5);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_ref (hbuttonbox1);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "hbuttonbox1", hbuttonbox1,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox1, TRUE, TRUE,
      0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END);
  gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10);

  b_yes = gtk_button_new_from_stock ("gtk-yes");
  gtk_widget_ref (b_yes);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "b_yes", b_yes,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (b_yes);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_yes);
  gtk_dialog_add_action_widget (GTK_DIALOG (confirm), b_yes, GTK_RESPONSE_YES);
  GTK_WIDGET_SET_FLAGS (b_yes, GTK_CAN_DEFAULT);

  b_no = gtk_button_new_from_stock ("gtk-no");
  gtk_widget_ref (b_no);
  gtk_object_set_data_full (GTK_OBJECT (confirm), "b_no", b_no,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (b_no);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_no);
  gtk_dialog_add_action_widget (GTK_DIALOG (confirm), b_no, GTK_RESPONSE_NO);
  GTK_WIDGET_SET_FLAGS (b_no, GTK_CAN_DEFAULT);

  /* Yes button events */
  gtk_signal_connect (GTK_OBJECT (b_yes), "clicked",
      GTK_SIGNAL_FUNC (confirm_yes_clicked), &confirm_t);
  /* No button events */
  gtk_signal_connect (GTK_OBJECT (b_no), "clicked",
      GTK_SIGNAL_FUNC (confirm_no_clicked), &confirm_t);
  /* Close window button events */
  gtk_signal_connect (GTK_OBJECT (confirm), "delete_event",
      GTK_SIGNAL_FUNC (delete_event), &confirm_t);
  gtk_signal_connect (GTK_OBJECT (confirm), "destroy",
      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  gtk_window_add_accel_group (GTK_WINDOW (confirm), accel_group);

  confirm_t.yes_no = FALSE;
  confirm_t.mainwnd = confirm;

  gtk_widget_show_all (confirm);
  gtk_main ();

  return confirm_t.yes_no;
}
Exemplo n.º 12
0
Arquivo: sview.c Projeto: A1ve5/slurm
/* Returns a menubar widget made from the above menu */
static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook)
{
	GtkAccelGroup *accel_group = NULL;
	GError *error = NULL;
	char *ui_description;

	GtkActionEntry entries[] = {
		{"actions", NULL, "_Actions", "<alt>a"},
		{"options", NULL, "_Options", "<alt>o"},
		{"displays", NULL, "_Query", "<alt>q"},
		{"batch_job", NULL, "Batch Job", "", "Submit batch job",
		 G_CALLBACK(create_create_popup)},
		{"partition", NULL, "Partition", "", "Create partition",
		 G_CALLBACK(create_create_popup)},
		{"reservation", NULL, "Reservation", "", "Create reservation",
		 G_CALLBACK(create_create_popup)},
		{"search", GTK_STOCK_FIND, "Search", ""},
		{"jobid", NULL, "Job ID",
		 "", "Search for jobid",
		 G_CALLBACK(create_search_popup)},
		{"user_jobs", NULL, "Specific User's Job(s)",
		 "", "Search for a specific users job(s)",
		 G_CALLBACK(create_search_popup)},
		{"state_jobs", NULL, "Job(s) in a Specific State",
		 "", "Search for job(s) in a specific state",
		 G_CALLBACK(create_search_popup)},
		{"partition_name", NULL, "Slurm Partition Name",
		 "", "Search for a specific SLURM partition",
		 G_CALLBACK(create_search_popup)},
		{"partition_state", NULL, "Slurm Partition State",
		 "", "Search for SLURM partitions in a given state",
		 G_CALLBACK(create_search_popup)},
		{"reservation_name", NULL, "Reservation Name",
		 "", "Search for reservation",
		 G_CALLBACK(create_search_popup)},
		{"tab_pos", NULL, "_Tab Position"},
		{"create", GTK_STOCK_ADD, "Create"},
		{"interval", GTK_STOCK_REFRESH, "Set Refresh _Interval",
		 "<control>i", "Change Refresh Interval",
		 G_CALLBACK(change_refresh_popup)},
		{"refresh", GTK_STOCK_REFRESH, "Refresh",
		 "F5", "Refreshes page", G_CALLBACK(refresh_main)},
		{"config", GTK_STOCK_INFO, "_Config Info",
		 "<control>c", "Displays info from slurm.conf file",
		 G_CALLBACK(create_config_popup)},
		{"dbconfig", GTK_STOCK_INFO, "_Database Config Info",
		 "<control>d",
		 "Displays info relevant to the "
		 "configuration of the Slurm Database.",
		 G_CALLBACK(create_dbconfig_popup)},
		{"exit", GTK_STOCK_QUIT, "E_xit",
		 "<control>x", "Exits Program", G_CALLBACK(_delete)},
		{"help", NULL, "_Help", "<alt>h"},
		{"about", GTK_STOCK_ABOUT, "Ab_out", "<control>o",
		 "About", G_CALLBACK(about_popup)},
		{"usage", GTK_STOCK_HELP, "Usage", "",
		 "Usage", G_CALLBACK(usage_popup)},
		//{"manual", GTK_STOCK_HELP, "_Manual", "<control>m"},
		{"grid_specs", GTK_STOCK_EDIT, "Set Grid _Properties",
		 "<control>p", "Change Grid Properties",
		 G_CALLBACK(change_grid_popup)},
		{"defaults", GTK_STOCK_EDIT, "_Set Default Settings",
		 "<control>s", "Change Default Settings",
		 G_CALLBACK(configure_defaults)},
	};

	GtkActionEntry bg_entries[] = {
		{"bg_block_name", NULL, "BG Block Name",
		 "", "Search for a specific BG Block",
		 G_CALLBACK(create_search_popup)},
		{"bg_block_size", NULL, "BG Block Size",
		 "",
		 "Search for BG Blocks having given size in cnodes",
		 G_CALLBACK(create_search_popup)},
		{"bg_block_state", NULL, "BG Block State",
		 "",
		 "Search for BG Blocks having given state",
		 G_CALLBACK(create_search_popup)},
		{"node_name_bg", NULL,
		 "Midplane(s) Name",
		 "", "Search for a specific Midplane(s)",
		 G_CALLBACK(create_search_popup)},
		{"node_state_bg", NULL,
		 "Midplane State",
		 "", "Search for a Midplane in a given state",
		 G_CALLBACK(create_search_popup)},
	};

	GtkActionEntry nonbg_entries[] = {
		{"node_name", NULL,
		 "Node(s) Name",
		 "", "Search for a specific Node(s)",
		 G_CALLBACK(create_search_popup)},
		{"node_state", NULL,
		 "Node State",
		 "", "Search for a Node in a given state",
		 G_CALLBACK(create_search_popup)},
	};

	GtkActionEntry admin_entries[] = {
		{"reconfig", GTK_STOCK_REDO, "SLUR_M Reconfigure",
		 "<control>m", "Reconfigures System",
		 G_CALLBACK(_reconfigure)},
		{"debugflags", GTK_STOCK_DIALOG_WARNING,
		 "Slurmctld DebugFlags",
		 "", "Set slurmctld DebugFlags",
		 G_CALLBACK(_get_current_debug_flags)},
		{"debuglevel", GTK_STOCK_DIALOG_WARNING,
		 "Slurmctld Debug Level",
		 "", "Set slurmctld debug level",
		 G_CALLBACK(_get_current_debug)},
	};

	GtkRadioActionEntry radio_entries[] = {
		{"tab_top", GTK_STOCK_GOTO_TOP, "_Top",
		 "<control>T", "Move tabs to top", GTK_POS_TOP},
		{"tab_bottom", GTK_STOCK_GOTO_BOTTOM, "_Bottom",
		 "<control>B", "Move tabs to the bottom", GTK_POS_BOTTOM},
		{"tab_left", GTK_STOCK_GOTO_FIRST, "_Left",
		 "<control>L", "Move tabs to the Left", GTK_POS_LEFT},
		{"tab_right", GTK_STOCK_GOTO_LAST, "_Right",
		 "<control>R", "Move tabs to the Right", GTK_POS_RIGHT}
	};

	GtkToggleActionEntry toggle_entries[] = {
		{"grid", GTK_STOCK_SELECT_COLOR, "Show _Grid",
		 "<control>g", "Visual display of cluster",
		 G_CALLBACK(_set_grid), working_sview_config.show_grid},
		{"hidden", GTK_STOCK_SELECT_COLOR, "Show _Hidden",
		 "<control>h", "Display Hidden Partitions/Jobs",
		 G_CALLBACK(_set_hidden), working_sview_config.show_hidden},
		{"page_opts", GTK_STOCK_SELECT_COLOR, "Save Page Options",
		 "<control>w", "Save Page Options",
		 G_CALLBACK(_set_page_opts),
		 working_sview_config.save_page_opts},
#ifdef WANT_TOPO_ON_MAIN_OPTIONS
		{"topoorder", GTK_STOCK_SELECT_COLOR, "Set Topology Grid",
		 "<control>t", "Set Topology Grid",
		 G_CALLBACK(_set_topogrid),
		 working_sview_config.grid_topological},
#endif
		{"ruled", GTK_STOCK_SELECT_COLOR, "R_uled Tables",
		 "<control>u", "Have ruled tables or not",
		 G_CALLBACK(_set_ruled), working_sview_config.ruled_treeview},
		{"admin", GTK_STOCK_PREFERENCES,
		 "_Admin Mode", "<control>a",
		 "Allows user to change or update information",
		 G_CALLBACK(_set_admin_mode),
		 working_sview_config.admin_mode}
	};

	GtkRadioActionEntry debug_entries[] = {
		{"debug_quiet", NULL, "quiet(0)", "", "Quiet level", 0},
		{"debug_fatal", NULL, "fatal(1)", "", "Fatal level", 1},
		{"debug_error", NULL, "error(2)", "", "Error level", 2},
		{"debug_info", NULL, "info(3)", "", "Info level", 3},
		{"debug_verbose", NULL, "verbose(4)", "", "Verbose level", 4},
		{"debug_debug", NULL, "debug(5)", "", "Debug debug level", 5},
		{"debug_debug2", NULL, "debug2(6)", "", "Debug2 level", 6},
		{"debug_debug3", NULL, "debug3(7)", "", "Debug3 level", 7},
		{"debug_debug4", NULL, "debug4(8)", "", "Debug4 level", 8},
		{"debug_debug5", NULL, "debug5(9)", "", "Debug5 level", 9},
	};

	char *all_debug_flags = debug_flags2str(0xFFFFFFFFFFFFFFFF);
	char *last = NULL;
	char *tok = strtok_r(all_debug_flags, ",", &last);

	/* set up the global debug_actions */
	debug_actions = xmalloc(sizeof(GtkToggleActionEntry));

	while (tok) {
		xrealloc(debug_actions,
			 (debug_action_entries + 1)
			 * sizeof(GtkToggleActionEntry));
		debug_actions[debug_action_entries].name =
			debug_actions[debug_action_entries].label =
			debug_actions[debug_action_entries].tooltip =
			xstrdup(tok);
		debug_actions[debug_action_entries].callback =
			G_CALLBACK(_set_flags);
		debug_action_entries++;
		tok = strtok_r(NULL, ",", &last);
	}
	xfree(all_debug_flags);

	/* Make an accelerator group (shortcut keys) */
	menu_action_group = gtk_action_group_new ("MenuActions");
	gtk_action_group_add_actions(menu_action_group, entries,
				     G_N_ELEMENTS(entries), window);

	gtk_action_group_add_actions(menu_action_group, bg_entries,
				     G_N_ELEMENTS(bg_entries), window);
	gtk_action_group_add_actions(menu_action_group, nonbg_entries,
				     G_N_ELEMENTS(nonbg_entries),
				     window);

	gtk_action_group_add_radio_actions(menu_action_group, radio_entries,
					   G_N_ELEMENTS(radio_entries),
					   working_sview_config.tab_pos,
					   G_CALLBACK(_tab_pos), notebook);
	gtk_action_group_add_toggle_actions(menu_action_group, debug_actions,
					    debug_action_entries, NULL);
	gtk_action_group_add_radio_actions(menu_action_group, debug_entries,
					   G_N_ELEMENTS(debug_entries),
					   -1, G_CALLBACK(_set_debug),
					   notebook);
	gtk_action_group_add_toggle_actions(menu_action_group, toggle_entries,
					    G_N_ELEMENTS(toggle_entries),
					    NULL);
	admin_action_group = gtk_action_group_new ("MenuAdminActions");
	gtk_action_group_add_actions(admin_action_group, admin_entries,
				     G_N_ELEMENTS(admin_entries),
				     window);
	gtk_action_group_set_sensitive(admin_action_group,
				       working_sview_config.admin_mode);

	g_ui_manager = gtk_ui_manager_new();
	gtk_ui_manager_insert_action_group(g_ui_manager, menu_action_group, 0);
	gtk_ui_manager_insert_action_group(g_ui_manager, admin_action_group, 1);

	accel_group = gtk_ui_manager_get_accel_group(g_ui_manager);
	gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
	ui_description = _get_ui_description();
	if (!(g_menu_id = gtk_ui_manager_add_ui_from_string(
		      g_ui_manager, ui_description, -1, &error))) {
		xfree(ui_description);
		g_error("building menus failed: %s", error->message);
		g_error_free (error);
		exit (0);
	}
	xfree(ui_description);
	/* GList *action_list = */
	/*	gtk_action_group_list_actions(menu_action_group); */
	/* GtkAction *action = NULL; */
	/* int i=0; */
	/* while ((action = g_list_nth_data(action_list, i++))) { */
	/*	g_print("got %s and %x\n", gtk_action_get_name(action), */
	/*		action); */
	/* } */

	/* Get the pointers to the correct action so if we ever need
	   to change it we can effect the action directly so
	   everything stays in sync.
	*/
	default_sview_config.action_admin =
		(GtkToggleAction *)gtk_action_group_get_action(
			menu_action_group, "admin");
	default_sview_config.action_grid =
		(GtkToggleAction *)gtk_action_group_get_action(
			menu_action_group, "grid");
	default_sview_config.action_hidden =
		(GtkToggleAction *)gtk_action_group_get_action(
			menu_action_group, "hidden");
	default_sview_config.action_page_opts =
		(GtkToggleAction *)gtk_action_group_get_action(
			menu_action_group, "page_opts");
//	default_sview_config.action_gridtopo =
//		(GtkToggleAction *)gtk_action_group_get_action(
//			menu_action_group, "topoorder");
	default_sview_config.action_ruled =
		(GtkToggleAction *)gtk_action_group_get_action(
			menu_action_group, "ruled");
	/* Pick the first one of the Radio, it is how GTK references
	   the group in the future.
	*/
	default_sview_config.action_tab =
		(GtkRadioAction *)gtk_action_group_get_action(
			menu_action_group, "tab_top");
	/* g_print("action grid is %x\n", default_sview_config.action_grid); */
	/* Finally, return the actual menu bar created by the item factory. */
	return gtk_ui_manager_get_widget (g_ui_manager, "/main");
}
Exemplo n.º 13
0
static void
anjuta_app_instance_init (AnjutaApp *app)
{
	gint merge_id;
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	gchar* style;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};
	
	DEBUG_PRINT ("%s", "Initializing Anjuta...");
	
	gtk_window_set_geometry_hints (GTK_WINDOW (app), GTK_WIDGET (app),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (app), TRUE);
	
	/*
	 * Main box
	 */
	main_box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (app), main_box);
	gtk_widget_show (main_box);
	
	app->values = NULL;
	app->widgets = NULL;
	
	/* Status bar */
	app->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (app->status, GTK_WIDGET (app));
	gtk_widget_show (GTK_WIDGET (app->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (app->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (app->status));
	g_object_add_weak_pointer (G_OBJECT (app->status), (gpointer)&app->status);
	
	/* configure dock */
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox);
	app->dock = gdl_dock_new ();
	gtk_widget_show (app->dock);
	gtk_box_pack_end(GTK_BOX (hbox), app->dock, TRUE, TRUE, 0);
	
	dockbar = gdl_dock_bar_new (GDL_DOCK(app->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
	
	app->layout_manager = gdl_dock_layout_new (GDL_DOCK (app->dock));
	g_signal_connect (app->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), app);
	g_signal_connect (app->layout_manager->master, "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), app);
	
	/* UI engine */
	app->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (app->ui), (gpointer)&app->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (app->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  app);
	g_signal_connect (app->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  app);
	
	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	app->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (app),
													 app->status,
													 plugins_dirs);
	app->profile_manager = anjuta_profile_manager_new (app->plugin_manager);
	g_list_free (plugins_dirs);
	
	/* Preferences */
	app->preferences = anjuta_preferences_new (app->plugin_manager);
	g_object_add_weak_pointer (G_OBJECT (app->preferences),
							   (gpointer)&app->preferences);
	
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.gdl.style",
	                                      on_gdl_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.gdl.style");
	
	on_gdl_style_changed (app->preferences, NULL, 
	                      style, app);
	g_free (style);
	
	/* Register actions */
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_toggle_action_group_entries (app->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, app);

	/* Merge UI */
	merge_id = anjuta_ui_merge (app->ui, UI_FILE);
	
	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (app), 
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (app->ui)));
	
	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);
	
	/* create toolbar */	
	app->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/ToolbarMain");
    if (!anjuta_preferences_get_bool (app->preferences, "anjuta.toolbar.visible"))
		gtk_widget_hide (app->toolbar);
	gtk_box_pack_start (GTK_BOX (main_box), app->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (app->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  anjuta_preferences_get_bool_with_default (app->preferences,
																		   "anjuta.toolbar.visible",
																		   TRUE));
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.toolbar.style",
								   on_toolbar_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.toolbar.style");
	on_toolbar_style_changed (app->preferences, NULL, style, app);
	g_free (style);

	/* Create widgets menu */
	view_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								  "/MenuMain/MenuView");
	app->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));	

	/* Disable unavailible tutorials */
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpAdvancedTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	
	/* Create about plugins menu */
	about_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (app), about_menu);
	
	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);
						
	/* Connect to session */
	g_signal_connect (G_OBJECT (app), "save_session",
					  G_CALLBACK (on_session_save), app);
	g_signal_connect (G_OBJECT (app), "load_session",
					  G_CALLBACK (on_session_load), app);
	
	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	app->save_count = 0;
}
Exemplo n.º 14
0
void
c_main_window_initialize (CMainWindow * self)
{
  GtkActionGroup* actions;
  GtkUIManager  * ui_manager;
  GtkActionEntry  entries[] = {
		{"File", NULL, N_("_File")},
		{"FileClose", GTK_STOCK_CLOSE, NULL,
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (file_close_activated)},

		{"Edit", NULL, N_("_Edit")},
		{"EditCopy", GTK_STOCK_COPY, NULL,
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (edit_copy_activated)},
		{"EditDelete", GTK_STOCK_DELETE, NULL,
		 "Delete", NULL, // FIXME: add tooltip
		 G_CALLBACK (edit_delete_activated)},
		{"EditPaste", GTK_STOCK_PASTE, NULL,
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (edit_paste_activated)},
		{"EditRename", NULL, N_("_Rename"),
		 "F2", NULL, // FIXME: add tooltip
		 G_CALLBACK (edit_rename)},

		{"TaskBottom", GTK_STOCK_GOTO_BOTTOM, N_("To _Bottom"),
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (task_bottom_activated)},
		{"TaskNew", GTK_STOCK_ADD, NULL,
		 "<Ctrl>n", NULL, // FIXME: add tooltip
		 G_CALLBACK (task_new_activated)},
		{"TaskTop", GTK_STOCK_GOTO_TOP, N_("To _Top"),
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (task_top_activated)},

		{"View", NULL, N_("_View")},
		{"ViewExpandAll", NULL, N_("_Expand All"),
		 NULL, NULL, // FIXME: add tooltip
		 G_CALLBACK (view_expand_all_activated)},
		{"ViewCollapseAll", NULL, N_("_Collapse All"),
		 NULL, NULL, // FIXME: add tooltip
                 G_CALLBACK (view_collapse_all_activated)}
  };
  GError        * error = NULL;

  g_return_if_fail (C_IS_MAIN_WINDOW (self));

  ui_manager = gtk_ui_manager_new ();
  g_object_set (self,
                "ui-manager", ui_manager,
                NULL);

  gtk_window_set_default_size (GTK_WINDOW (self),
                               400, 300);
  gtk_window_set_title        (GTK_WINDOW (self),
                               _("List of Tasks"));

  gtk_window_add_accel_group  (GTK_WINDOW (self),
                               gtk_ui_manager_get_accel_group (ui_manager));

  actions = gtk_action_group_new (g_type_name (C_TYPE_MAIN_WINDOW));
  gtk_action_group_add_actions (actions, entries, G_N_ELEMENTS (entries), self);
  gtk_ui_manager_insert_action_group (ui_manager, actions, -1);
  g_object_unref (actions);

  gtk_ui_manager_add_ui_from_string  (ui_manager,
                                      "<ui>"
                                        "<toolbar name='toolbar'>"
                                          "<toolitem action='TaskNew'/>"
                                          "<placeholder name='remove'/>"
                                          "<separator/>"
                                          "<toolitem action='TaskTop'/>"
                                          "<toolitem action='TaskBottom'/>"
                                        "</toolbar>"
                                      "</ui>",
                                      -1,
                                      &error);

	if (error) {
		g_warning ("Error setting up the user interface: %s",
			   error->message);
		g_error_free (error);
		error = NULL;
	}

  g_object_unref (ui_manager);
}
Exemplo n.º 15
0
void gtkui_create_menu(int live)
{
   GtkAccelGroup *accel_group;
   GtkWidget *vbox, *main_menu;
   GtkActionGroup *menuactions;
   GtkAction *action;
   GError *error = NULL;
   GClosure *closure = NULL;
   gint keyval;
   GdkModifierType mods;
   
   const gchar *menu_structure = 
      "<ui>"
      "  <menubar name='MenuBar'>"
      "     <menu name='StartMenu' action='StartMenuAction'>"
      "        <menuitem name='SniffStart' action='SniffStartAction' />"
      "        <menuitem name='SniffStop' action='SniffStopAction' />"
      "        <separator />"
      "        <menuitem name='Exit' action='ExitAction' />"
      "     </menu>"
      "     <menu name='TargetsMenu' action='TargetsMenuAction'>"
      "        <menuitem name='CurrentTargets' action='CurrentTargetsAction' />"
      "        <menuitem name='SelectTargets' action='SelectTargetsAction' />"
      "        <separator />"
      "        <menuitem name='Protocol' action='ProtocolAction' />"
      "        <menuitem name='ReverseMatching' action='ReverseMatchingAction' />"
      "        <separator />"
      "        <menuitem name='WipeTargets' action='WipeTargetsAction' />"
      "     </menu>"
      "     <menu name='HostsMenu' action='HostsMenuAction'>"
      "        <menuitem name='HostsList' action='HostsListAction' />"
      "        <separator />"
#ifdef WITH_IPV6
      "        <menuitem name='EnableIPv6Scan' action='EnableIPv6ScanAction' />"
#endif
      "        <menuitem name='ScanHosts' action='ScanHostsAction' />"
      "        <menuitem name='LoadHosts' action='LoadHostsAction' />"
      "        <menuitem name='SaveHosts' action='SaveHostsAction' />"
      "     </menu>"
      "     <menu name='ViewMenu' action='ViewMenuAction'>"
      "        <menuitem name='ViewConnections' action='ViewConnectionsAction' />"
      "        <menuitem name='ViewProfiles' action='ViewProfilesAction' />"
      "        <menuitem name='ViewStatistics' action='ViewStatisticsAction' />"
      "        <separator />"
      "        <menuitem name='ResolveIpAddresses' action='ResolveIpAddressesAction' />"
      "        <menuitem name='VisualisationMethod' action='VisualisationMethodAction' />"
      "        <menuitem name='VisualisationRegex' action='VisualisationRegexAction' />"
      "        <separator />"
      "        <menuitem name='SetWifiKey' action='SetWifiKeyAction' />"
      "     </menu>"
      "     <menu name='MitmMenu' action='MitmMenuAction'>"
      "        <menuitem name='ArpPoisoning' action='ArpPoisoningAction' />"
      "        <menuitem name='IcmpRedirect' action='IcmpRedirectAction' />"
      "        <menuitem name='PortStealing' action='PortStealingAction' />"
      "        <menuitem name='DhcpSpoofing' action='DhcpSpoofingAction' />"
#ifdef WITH_IPV6
      "        <menuitem name='NdpPoisoning' action='NdpPoisoningAction' />"
#endif
      "        <separator />"
      "        <menuitem name='StopMitmAttacks' action='StopMitmAttacksAction' />"
      "     </menu>"
      "     <menu name='FiltersMenu' action='FiltersMenuAction'>"
      "        <menuitem name='LoadFilter' action='LoadFilterAction' />"
      "        <menuitem name='StopFilter' action='StopFilterAction' />"
      "     </menu>"
      "     <menu name='LoggingMenu' action='LoggingMenuAction'>"
      "        <menuitem name='LoggingAll' action='LoggingAllAction' />"
      "        <menuitem name='LoggingInfo' action='LoggingInfoAction' />"
      "        <menuitem name='LoggingStop' action='LoggingStopAction' />"
      "        <separator />"
      "        <menuitem name='LogMessages' action='LogMessagesAction' />"
      "        <menuitem name='LogMessagesStop' action='LogMessagesStopAction' />"
      "        <separator />"
      "        <menuitem name='LogCompressed' action='LogCompressedAction' />"
      "     </menu>"
#ifdef HAVE_PLUGINS
      "     <menu name='PluginsMenu' action='PluginsMenuAction'>"
      "        <menuitem name='ManagePlugins' action='ManagePluginsAction' />"
      "        <menuitem name='LoadPlugin' action='LoadPluginAction' />"
      "     </menu>"
#endif
      "     <menu name='HelpMenu' action='HelpMenuAction'>"
#ifndef OS_WINDOWS
      "        <menuitem name='Help' action='HelpAction' />"
#endif
      "        <menuitem name='About' action='AboutDialogAction' />"
      "     </menu>"
      "  </menubar>"
      "</ui>";


   GtkActionEntry start_menu_items[] = {
      /* Start Menu */
      {
         "StartMenuAction", NULL, 
         "_Start", NULL, 
         NULL, NULL
      },

      {
         "SniffStartAction", GTK_STOCK_YES,
         "Start sniffing", "<control><shift>w",
         NULL, G_CALLBACK(gtkui_start_sniffing)
      },

      {
         "SniffStopAction", GTK_STOCK_NO,
         "Stop sniffing", "<control><shift>e",
         NULL, G_CALLBACK(gtkui_stop_sniffing)
      },

      {
         "ExitAction", GTK_STOCK_QUIT,
         "E_xit", "<control>q",
         NULL, G_CALLBACK(gtkui_exit)
      }
   };

   GtkActionEntry targets_menu_items[] = {
      /* Targets Menu */
      {
         "TargetsMenuAction", NULL,
         "_Targets", NULL,
         NULL, NULL
      },

      {
         "CurrentTargetsAction", GTK_STOCK_FIND,
         "Current targets", "<control>t",
         NULL, G_CALLBACK(gtkui_current_targets)
      },

      {
         "SelectTargetsAction", GTK_STOCK_ADD,
         "Select target(s)", "<control><shift>t",
         NULL, G_CALLBACK(gtkui_select_targets)
      },

      {
         "ProtocolAction", GTK_STOCK_JUMP_TO,
         "_Protocol...", "<control>p",
         NULL, G_CALLBACK(gtkui_select_protocol)
      },

      {
         "WipeTargetsAction", GTK_STOCK_CLEAR,
         "_Wipe targets", "<control>W",
         NULL, G_CALLBACK(wipe_targets)
      }
   };

   GtkActionEntry hosts_menu_items[] = {
      /* Hosts Menu */
      {
         "HostsMenuAction", NULL,
         "_Hosts", NULL,
         NULL, NULL
      },

      {
         "HostsListAction", GTK_STOCK_INDEX,
         "_Hosts list", "<control>h",
         NULL, G_CALLBACK(gtkui_host_list)
      },

      {
         "ScanHostsAction", GTK_STOCK_FIND,
         "_Scan for hosts", "<control>s",
         NULL, G_CALLBACK(gtkui_scan)
      },

      {
         "LoadHostsAction", GTK_STOCK_OPEN,
         "Load from file...", "",
         NULL, G_CALLBACK(gtkui_load_hosts)
      },

      {
         "SaveHostsAction", GTK_STOCK_SAVE,
         "Save to file...", "",
         NULL, G_CALLBACK(gtkui_save_hosts)
      }
   };

   GtkActionEntry view_menu_items[] = {
      /* View Menu */
      {
         "ViewMenuAction", NULL,
         "_View", NULL,
         NULL, NULL
      },

      {
         "ViewConnectionsAction", GTK_STOCK_JUSTIFY_FILL,
         "_Connections", "<control><shift>c",
         NULL, G_CALLBACK(gtkui_show_connections)
      },

      {
         "ViewProfilesAction", GTK_STOCK_JUSTIFY_LEFT,
         "Pr_ofiles", "<control>o",
         NULL, G_CALLBACK(gtkui_show_profiles)
      },

      {
         "ViewStatisticsAction", GTK_STOCK_PROPERTIES,
         "_Statistics", NULL,
         NULL, G_CALLBACK(gtkui_show_stats)
      },

      {
         "VisualisationMethodAction", GTK_STOCK_PREFERENCES,
         "_Visualisation method...", "<control><shift>v",
         NULL, G_CALLBACK(gtkui_vis_method)
      },

      {
         "VisualisationRegexAction", GTK_STOCK_FIND,
         "Visualisation _regex...", "<control>R",
         NULL, G_CALLBACK(gtkui_vis_regex)
      },

      {
         "SetWifiKeyAction", GTK_STOCK_FIND,
         "Set the _WiFi key...", NULL,
         NULL, G_CALLBACK(gtkui_wifi_key)
      }
   };

   GtkActionEntry mitm_menu_items[] = {
      /* Mitm Menu */
      {
         "MitmMenuAction", NULL,
         "_Mitm", NULL,
         NULL, NULL
      },

      {
         "ArpPoisoningAction", NULL,
         "ARP poisoning...", NULL,
         NULL, G_CALLBACK(gtkui_arp_poisoning)
      },

      {
         "IcmpRedirectAction", NULL,
         "ICMP redirect...", NULL,
         NULL, G_CALLBACK(gtkui_icmp_redir)
      },

      {
         "PortStealingAction", NULL,
         "Port stealing...", NULL,
         NULL, G_CALLBACK(gtkui_port_stealing)
      },

      {
         "DhcpSpoofingAction", NULL,
         "DHCP spoofing...", NULL,
         NULL, G_CALLBACK(gtkui_dhcp_spoofing)
      },

#ifdef WITH_IPV6
      {
         "NdpPoisoningAction", NULL,
         "NDP poisoning...", NULL,
         NULL, G_CALLBACK(gtkui_ndp_poisoning)
      },
#endif

      { 
         "StopMitmAttacksAction", NULL,
         "Stop mitm attack(s)", NULL,
         NULL, G_CALLBACK(gtkui_mitm_stop)
      }
   };

   GtkActionEntry filters_menu_items[] = {
      /* Filters Menu */
      {
         "FiltersMenuAction", NULL,
         "_Filters", NULL,
         NULL, NULL
      },

      {
         "LoadFilterAction", GTK_STOCK_OPEN,
         "Load a filter...", "<control>f",
         NULL, G_CALLBACK(gtkui_load_filter)
      },

      {
         "StopFilterAction", GTK_STOCK_STOP,
         "Stop _filtering", "<control><shift>f",
         NULL, G_CALLBACK(gtkui_stop_filter)
      }
   };

   GtkActionEntry logging_menu_items[] = {
      /* Logging Menu */
      {
         "LoggingMenuAction", NULL,
         "_Logging", NULL,
         NULL, NULL
      },

      {
         "LoggingAllAction", GTK_STOCK_SAVE,
         "Logging all packets and infos...", "<control><shift>i",
         NULL, G_CALLBACK(gtkui_log_all)
      },

      {
         "LoggingInfoAction", GTK_STOCK_SAVE_AS,
         "Logging only infos...", "<control>i",
         NULL, G_CALLBACK(gtkui_log_info)
      },

      {
         "LoggingStopAction", GTK_STOCK_STOP,
         "Stop logging infos", NULL,
         NULL, G_CALLBACK(gtkui_stop_log)
      },

      {
         "LogMessagesAction", GTK_STOCK_REVERT_TO_SAVED,
         "Log user messages...", "<control>m",
         NULL, G_CALLBACK(gtkui_log_msg)
      },

      {
         "LogMessagesStopAction", GTK_STOCK_STOP,
         "Stop logging messages", NULL,
         NULL, G_CALLBACK(gtkui_stop_msg)
      }
   };

#ifdef HAVE_PLUGINS
   GtkActionEntry plugins_menu_items[] = {
      /* Plugins Menu */
      {
         "PluginsMenuAction", NULL,
         "_Plugins", NULL,
         NULL, NULL
      },

      {
         "ManagePluginsAction", GTK_STOCK_EXECUTE,
         "Manage the plugins", "<control>p",
         NULL, G_CALLBACK(gtkui_plugin_mgmt)
      },

      {
         "LoadPluginAction", GTK_STOCK_OPEN,
         "Load a plugin...", NULL,
         NULL, G_CALLBACK(gtkui_plugin_load)
      }
   };
#endif

   GtkActionEntry help_menu_items[] = {
      /* Help Menu */
      {
         "HelpMenuAction", NULL,
         "_Info", NULL,
         NULL, NULL
      },

#ifndef OS_WINDOWS
      {
         "HelpAction", GTK_STOCK_HELP,
         "Help", "F1",
         NULL, G_CALLBACK(gtkui_help)
      },
#endif
      {
         "AboutDialogAction", GTK_STOCK_ABOUT,
         "About", NULL,
         NULL, G_CALLBACK(gtkui_about)
      }
   };

   GtkToggleActionEntry toggle_items[] = {
      {
         "ReverseMatchingAction", NULL,
         "Reverse matching", NULL,
         NULL, G_CALLBACK(toggle_reverse),
         FALSE
      },

#ifdef WITH_IPV6
      {
         "EnableIPv6ScanAction", NULL,
         "Enable IPv6 scan", NULL,
         NULL, G_CALLBACK(toggle_ip6scan),
         FALSE
      },
#endif

      {
         "ResolveIpAddressesAction", NULL,
         "Resolve IP addresses", NULL,
         NULL, G_CALLBACK(toggle_resolve),
         FALSE
      },

      {
         "LogCompressedAction", NULL,
         "Compressed file", NULL,
         NULL, G_CALLBACK(toggle_compress),
         FALSE
      }
   };

   DEBUG_MSG("gtk_create_menu");

   /* remove old menu, it will be automatically destroyed by gtk_main */
   vbox = gtk_bin_get_child(GTK_BIN (window));
   main_menu = gtk_ui_manager_get_widget(menu_manager, "/MenuBar");
   gtk_widget_hide(main_menu);
   gtk_ui_manager_remove_ui(menu_manager, merge_id);

   menuactions = gtk_action_group_new("MenuActions");
   /* Start Menu */
   gtk_action_group_add_actions(menuactions, start_menu_items, G_N_ELEMENTS(start_menu_items), NULL);
   /* Targets Menu */
   gtk_action_group_add_actions(menuactions, targets_menu_items, G_N_ELEMENTS(targets_menu_items), NULL);
   /* Hosts Menu */
   gtk_action_group_add_actions(menuactions, hosts_menu_items, G_N_ELEMENTS(hosts_menu_items), NULL);
   /* View Menu */
   gtk_action_group_add_actions(menuactions, view_menu_items, G_N_ELEMENTS(view_menu_items), NULL);
   /* MITM Menu */
   gtk_action_group_add_actions(menuactions, mitm_menu_items, G_N_ELEMENTS(mitm_menu_items), NULL);
   /* Filters Menu */
   gtk_action_group_add_actions(menuactions, filters_menu_items, G_N_ELEMENTS(filters_menu_items), NULL);
   /* Logging Menu */
   gtk_action_group_add_actions(menuactions, logging_menu_items, G_N_ELEMENTS(logging_menu_items), NULL);
#ifdef HAVE_PLUGINS
   /* Plugins Menu */
   gtk_action_group_add_actions(menuactions, plugins_menu_items, G_N_ELEMENTS(plugins_menu_items), NULL);
#endif
#ifndef OS_WINDOWS
   /* Help Menu */
   gtk_action_group_add_actions(menuactions, help_menu_items, G_N_ELEMENTS(help_menu_items), NULL);
#endif

   gtk_action_group_add_toggle_actions(menuactions, toggle_items, G_N_ELEMENTS(toggle_items), NULL);

   menu_manager = gtk_ui_manager_new();
   gtk_ui_manager_insert_action_group(menu_manager, menuactions, 0);

   merge_id = gtk_ui_manager_add_ui_from_string(menu_manager, menu_structure, -1, &error);
   if (error) {
      g_message("building menu failed: %s", error->message);
      g_error_free(error);
      error = NULL;
   }

   /* Some hidden accellerators */
   accel_group = gtk_accel_group_new ();
   closure = g_cclosure_new(G_CALLBACK(gtkui_exit), NULL, NULL);
   gtk_accelerator_parse("<control>X", &keyval, &mods);
   gtk_accel_group_connect(accel_group, keyval, mods, 0, closure);
   gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
   gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(menu_manager));

   

   if(GBL_OPTIONS->reversed) {
      GBL_OPTIONS->reversed = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/TargetsMenu/ReverseMatching");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   if(GBL_OPTIONS->resolve) {
      GBL_OPTIONS->resolve = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/ViewMenu/ResolveIpAddresses");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   if(GBL_OPTIONS->compress) {
      GBL_OPTIONS->compress = 0;
      action = gtk_ui_manager_get_action(menu_manager, "/MenuBar/LoggingMenu/LogCompressed");
      gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
   }

   /* Some menus doesn't apply if started in offline or bridged sniffing mode */
   if (live == 0 || GBL_SNIFF->type == SM_BRIDGED) {
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/HostsMenu"), FALSE);
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/MitmMenu"), FALSE);
   }

#ifdef HAVE_PLUGINS
   if (live == 0)
      gtk_widget_set_visible(gtk_ui_manager_get_widget(menu_manager, "/MenuBar/PluginsMenu"), FALSE);
#endif

   /* get the menu widget and add it to the window */
   main_menu = gtk_ui_manager_get_widget(menu_manager, "/MenuBar");
   gtk_box_pack_start(GTK_BOX(vbox), main_menu, FALSE, FALSE, 0);
   gtk_widget_show(main_menu);
   
}
Exemplo n.º 16
0
gint main(gint argc, gchar *argv[])
{
	GtkWidget *window;
	GtkWidget *vbox;

	GtkWidget *menubar;
	GtkWidget *subMenu;
	GtkWidget *menuitem;

	GtkWidget *toolbar;

	GtkActionGroup* actiongroup;
	GtkUIManager* ui_manager;//主界面,包含了待建立的界面和相关的动作

	gtk_init(&argc, &argv);

	/**********初始化主界面$$$$$$$$**********{*/
	/*初始化主界面相关动作信息*/
	action_init(&actiongroup, &ui_manager);
	/*初始华主界面具体界面信息*/
	ui_init(&actiongroup, &ui_manager);
	/**********初始化主界面$$$$$$$$**********}*/

	/*window*/
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(window, "destroy"
			, G_CALLBACK(gtk_main_quit), NULL);
	/*添加快捷键*/
	gtk_window_add_accel_group(GTK_WINDOW(window),
			gtk_ui_manager_get_accel_group(ui_manager));

	/*vbox*/
	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	/***********使用、设置主界面中的元素$$$$$$******{*/
	/*从主界面获取一个部件的方法,便于添加到窗口中为什么这里有一个警告?*/
	menubar = gtk_ui_manager_get_widget(ui_manager, "/menubar");
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);

	/*从主界面获取一个菜单项的方法,获取之后设置其属性*/
	menuitem = gtk_ui_manager_get_widget(ui_manager, "/menubar/Menu1/menuitem1.1");
	/*从主界面把本来可以点击的菜单按钮设置为无法点击,非激活状态,工具栏上面仍然可以点*/
	gtk_widget_set_sensitive(GTK_WIDGET(menuitem),
			FALSE);

	/*从主界面获取一个子菜单的方法,获取之后添加一个额外不属于主界面的菜单*/
	subMenu = gtk_menu_item_get_submenu(
			GTK_MENU_ITEM(gtk_ui_manager_get_widget(ui_manager, "/menubar/Menu2")));
	/*可以添加2个额外的分割线*/
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(subMenu), menuitem);
	menuitem = gtk_separator_menu_item_new();
	gtk_menu_shell_append(GTK_MENU_SHELL(subMenu), menuitem);
	menuitem = gtk_menu_item_new_with_label("added out the Ui");
	gtk_menu_shell_append(GTK_MENU_SHELL(subMenu), menuitem);
	gtk_widget_show_all(GTK_WIDGET(subMenu));//此处如果不写,那么即使后面有window的show_all那也没法显示这个菜单.

	/*从主界面获取工具栏的部件*/
	toolbar = gtk_ui_manager_get_widget(ui_manager, "/toolbar_navigation");
	gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), 0);
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);

	g_object_unref(ui_manager);
	/***********使用、设置主界面中的元素$$$$$$******}*/

	gtk_widget_show_all(window);
	gtk_main();
	return 0;
}
Exemplo n.º 17
0
void gtkui_create_tab_menu(void)
{
   GtkWidget *context;
   GtkUIManager *tab_menu_manager;
   GtkActionGroup *tabactions;
   GError *error = NULL;

   static gchar *tab_menu_structure = 
       "<ui>"
       "   <popup name='NoteBook'>"
       "      <menuitem name='DetachPage' action='DetachPageAction' />"
       "      <menuitem name='ClosePage' action='ClosePageAction' />"
       "      <separator />"
       "      <menuitem name='NextPage' action='NextPageAction' />"
       "      <menuitem name='PreviousPage' action='PreviousPageAction' />"
       "   </popup>"
       "</ui>";

   GtkActionEntry tab_menu_items[] = {
      {
         "DetachPageAction", GTK_STOCK_GO_UP,
         "Detach page", "<control>D",
         NULL, G_CALLBACK(gtkui_page_detach_current)
      },

      {
         "ClosePageAction", GTK_STOCK_CLOSE,
         "Close page", "<control>W",
         NULL, G_CALLBACK(gtkui_page_close_current)
      },

      {
         "NextPageAction", GTK_STOCK_GO_FORWARD,
         "Next page", "<control>Tab",
         NULL, G_CALLBACK(gtkui_page_right)
      },

      {
         "PreviousPageAction", GTK_STOCK_GO_BACK,
         "Previous page", "<control><shift>Tab",
         NULL, G_CALLBACK(gtkui_page_left)
      }
   };
   /* Create Action Group for tab menu */
   tabactions = gtk_action_group_new("TabActions");
   gtk_action_group_add_actions(tabactions, tab_menu_items, G_N_ELEMENTS(tab_menu_items), NULL);

   /* context menu for notebook */
   tab_menu_manager = gtk_ui_manager_new();
   gtk_ui_manager_insert_action_group(tab_menu_manager, tabactions, 0);
   gtk_ui_manager_add_ui_from_string(tab_menu_manager, tab_menu_structure, -1, &error);
   if (error) {
       g_message("building tab menu failed: %s", error->message);
       g_error_free(error);
       error = NULL;
   }

   /* Add Accelerators */
   gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(tab_menu_manager));

   /* Bind popup menu to event */
   context = gtk_ui_manager_get_widget(tab_menu_manager, "/NoteBook");
   g_signal_connect(G_OBJECT(notebook), "button-press-event", G_CALLBACK(gtkui_context_menu), context);
}
Exemplo n.º 18
0
/**
 * nautilus_window_initialize_menus
 * 
 * Create and install the set of menus for this window.
 * @window: A recently-created NautilusWindow.
 */
void 
nautilus_window_initialize_menus (NautilusWindow *window)
{
	GtkActionGroup *action_group;
	GtkUIManager *ui_manager;
	GtkAction *action;
	gint i;

	window->details->ui_manager = gtk_ui_manager_new ();
	ui_manager = window->details->ui_manager;

	/* shell actions */
	action_group = gtk_action_group_new ("ShellActions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	window->details->main_action_group = action_group;
	gtk_action_group_add_actions (action_group, 
				      main_entries, G_N_ELEMENTS (main_entries),
				      window);
	gtk_action_group_add_toggle_actions (action_group, 
					     main_toggle_entries, G_N_ELEMENTS (main_toggle_entries),
					     window);

	nautilus_window_menus_set_visibility_for_app_menu (window);
	g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
				  "notify::gtk-shell-shows-app-menu",
				  G_CALLBACK (nautilus_window_menus_set_visibility_for_app_menu), window);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
	g_object_set (action, "short_label", _("_Up"), NULL);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_HOME);
	g_object_set (action, "short_label", _("_Home"), NULL);

	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SHOW_HIDDEN_FILES);
	g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window);
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
				      g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
	g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window);


	g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
				  G_CALLBACK(show_hidden_files_preference_callback),
				  window);

	/* Alt+N for the first 10 tabs */
	for (i = 0; i < 10; ++i) {
		gchar action_name[80];
		gchar accelerator[80];

		snprintf(action_name, sizeof (action_name), "Tab%d", i);
		action = gtk_action_new (action_name, NULL, NULL, NULL);
		g_object_set_data (G_OBJECT (action), "num", GINT_TO_POINTER (i));
		g_signal_connect (action, "activate",
				G_CALLBACK (action_tab_change_action_activate_callback), window);
		snprintf(accelerator, sizeof (accelerator), "<alt>%d", (i+1)%10);
		gtk_action_group_add_action_with_accel (action_group, action, accelerator);
		g_object_unref (action);
		gtk_ui_manager_add_ui (ui_manager,
				gtk_ui_manager_new_merge_id (ui_manager),
				"/",
				action_name,
				action_name,
				GTK_UI_MANAGER_ACCELERATOR,
				FALSE);

	}

	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
	g_object_unref (action_group); /* owned by ui_manager */

	gtk_window_add_accel_group (GTK_WINDOW (window),
				    gtk_ui_manager_get_accel_group (ui_manager));
	
	g_signal_connect (ui_manager, "connect_proxy",
			  G_CALLBACK (connect_proxy_cb), window);

	/* add the UI */
	gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-shell-ui.xml", NULL);

	nautilus_window_initialize_trash_icon_monitor (window);
	nautilus_window_initialize_go_menu (window);
}
Exemplo n.º 19
0
Arquivo: main_5.c Projeto: llxp/llxp
int main( int   argc,
          char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *button_quit;
    GtkWidget *box;
    GtkWidget *box_quit;
      GtkWidget *quit;
      GtkAccelGroup *accel_group = NULL;

    gtk_init (&argc, &argv);

    /* Create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");

    /* It's a good idea to do this for all windows. */
    g_signal_connect (window, "destroy",
	              G_CALLBACK (gtk_main_quit), NULL);

    g_signal_connect (window, "delete-event",
	 	      G_CALLBACK (gtk_main_quit), NULL);

    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    /* Create a new button */
    button = gtk_button_new ();
    button_quit = gtk_button_new ();
  accel_group = gtk_accel_group_new();
  gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
    /* Connect the "clicked" signal of the button to our callback */
    g_signal_connect (button, "clicked",
		      G_CALLBACK (main), (gpointer) "Neues Fenster");
    g_signal_connect (button_quit, "clicked",
		      G_CALLBACK (gtk_main_quit), (gpointer) "Neues Fenster");

    /* This calls our box creating function */
    box = xpm_label_box ("/usr/share/icons/gnome/24x24/actions/filenew.png", "Neues Fenster");
    box_quit = xpm_label_box ("/usr/share/icons/gnome/24x24/actions/gtk-quit.png", "Beenden");

    /* Pack and show all our widgets */
    gtk_widget_show (box);
    gtk_widget_show (box_quit);

    gtk_container_add (GTK_CONTAINER (button), box);
    gtk_container_add (GTK_CONTAINER (button_quit), box_quit);


    gtk_widget_show (button);
    gtk_widget_show (button_quit);

    gtk_container_add (GTK_CONTAINER (window), button);

    gtk_widget_show (window);

    /* Rest in gtk_main and wait for the fun to begin! */
    gtk_main ();

    return 0;
}
Exemplo n.º 20
0
// setup_editor_window: Sets up the main editor window
// ------------------------------------------------ >>
void setup_editor_window()
{
	// Setup OpenGL
	glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB|GDK_GL_MODE_DEPTH|GDK_GL_MODE_DOUBLE));

	if (glconfig == NULL)
	{
		glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB|GDK_GL_MODE_DEPTH));

		if (glconfig == NULL)
			exit(1);
	}

	editor_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(editor_window), "SLADE");
	gtk_widget_set_size_request(editor_window, 800, 600);
	gtk_widget_set_double_buffered(editor_window, true);

	GtkWidget *main_vbox = gtk_vbox_new(false, 0);
	gtk_container_add(GTK_CONTAINER(editor_window), main_vbox);

	// Menu and Toolbar
	GtkUIManager *ui = gtk_ui_manager_new();
	GtkActionGroup *actions = gtk_action_group_new ("Actions");
	GError *error = NULL;

	gtk_action_group_add_actions(actions, entries, n_entries, NULL);
	//gtk_action_group_add_radio_actions(actions, mode_entries, n_mode_entries, 1, G_CALLBACK(menu_mode_select), NULL);

	gtk_ui_manager_insert_action_group(ui, actions, 0);
	gtk_window_add_accel_group(GTK_WINDOW(editor_window), gtk_ui_manager_get_accel_group(ui));

	if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
	{
		printf("Building menus failed: %s", error->message);
		g_error_free(error);
	}

	gtk_box_pack_start (GTK_BOX(main_vbox), gtk_ui_manager_get_widget(ui, "/MenuBar"), false, false, 0);

	GtkWidget *toolbar = gtk_ui_manager_get_widget(ui, "/ToolBar");
	gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
	gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
	gtk_container_unset_focus_chain(GTK_CONTAINER(toolbar));
	GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_CAN_FOCUS);
	GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_HAS_FOCUS);
	g_signal_connect(G_OBJECT(toolbar), "key-press-event", G_CALLBACK(tbar_keypress), NULL);
	gtk_box_pack_start (GTK_BOX(main_vbox), toolbar, false, false, 0);

	// Map area
	map_area = gtk_drawing_area_new();

	gtk_widget_set_gl_capability(map_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE);

	gtk_widget_set_events(map_area, GDK_EXPOSURE_MASK
									| GDK_LEAVE_NOTIFY_MASK
									| GDK_BUTTON_PRESS_MASK
									| GDK_BUTTON_RELEASE_MASK
									| GDK_POINTER_MOTION_MASK
									| GDK_POINTER_MOTION_HINT_MASK);

	g_signal_connect(G_OBJECT(map_area), "expose-event", G_CALLBACK(expose_event), NULL);
	g_signal_connect(G_OBJECT(map_area), "configure-event", G_CALLBACK(configure_event), NULL);
	g_signal_connect(G_OBJECT(map_area), "motion_notify_event", G_CALLBACK(motion_notify_event), NULL);
	g_signal_connect(G_OBJECT(map_area), "button_press_event", G_CALLBACK(button_press_event), NULL);
	g_signal_connect(G_OBJECT(map_area), "button_release_event", G_CALLBACK(button_release_event), NULL);
	g_signal_connect(G_OBJECT(editor_window), "key-press-event", G_CALLBACK(key_press_event), NULL);
	g_signal_connect(G_OBJECT(editor_window), "key-release-event", G_CALLBACK(key_release_event), NULL);
	g_signal_connect_after(G_OBJECT(map_area), "realize", G_CALLBACK (realize_main), NULL);
	g_signal_connect(G_OBJECT(editor_window), "delete_event", G_CALLBACK(destroy), NULL);
	g_signal_connect(G_OBJECT(editor_window), "window-state-event", G_CALLBACK(editor_state_event), NULL);
	g_signal_connect(G_OBJECT(map_area), "scroll-event", G_CALLBACK(editor_scroll_event), NULL);
	gtk_box_pack_start(GTK_BOX(main_vbox), map_area, true, true, 0);

	GTK_WIDGET_SET_FLAGS(map_area, GTK_CAN_FOCUS);

	// Setup widgets that need to share the context
	gtk_widget_realize(map_area);
	glcontext = gtk_widget_get_gl_context(map_area);

	// Info area
	GtkWidget *infobar = get_info_bar();
	gtk_widget_set_size_request(infobar, -1, 144);
	gtk_box_pack_start(GTK_BOX(main_vbox), infobar, false, false, 0);
	change_infobar_page();

	if (ew_fullscreen)
		gtk_window_maximize(GTK_WINDOW(editor_window));
	else
	{
		gtk_window_move(GTK_WINDOW(editor_window), ew_x, ew_y);
		gtk_window_resize(GTK_WINDOW(editor_window), ew_width, ew_height);
	}

	// Status bar
	//GtkWidget *frame = gtk_frame_new(NULL);
	//gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW);
	gtk_box_pack_start(GTK_BOX(main_vbox), setup_status_bar(), false, false, 0);
	//gtk_container_add(GTK_CONTAINER(frame), setup_status_bar());

	gtk_widget_show_all(editor_window);
}
Exemplo n.º 21
0
void
create_translatorchooser (HWND hwnd, TTRANSLATORCHOOSER *choose_t)
{
  GtkWidget *translatorchooser, *dialog_vbox1, *fixed1, *l_diz,
      *scrolledwindow1;
  GtkWidget *clist1, *l_name, *l_file, *l_date, *l_size, *dialog_action_area1;
  GtkWidget *hbuttonbox1, *b_finish, *b_cancel, *pixmap1;
  guint b_finish_key, b_cancel_key;
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle *style;
  GtkAccelGroup *accel_group;

  if (hwnd == NULL || !GTK_IS_WIDGET (hwnd))
    return;

  accel_group = gtk_accel_group_new ();

  translatorchooser = gtk_dialog_new ();
  gtk_object_set_data (GTK_OBJECT (translatorchooser), "translatorchooser",
      translatorchooser);
  gtk_window_set_title (GTK_WINDOW (translatorchooser),
      "Choose a Translator");
  gtk_window_set_position (GTK_WINDOW (translatorchooser),
      GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (translatorchooser), TRUE);
  gtk_window_set_policy (GTK_WINDOW (translatorchooser), FALSE, FALSE, FALSE);

#if GTK_CHECK_VERSION(2,0,0)
  gtk_widget_show (translatorchooser);
#endif

  dialog_vbox1 = GTK_DIALOG (translatorchooser)->vbox;
  gtk_object_set_data (GTK_OBJECT (translatorchooser), "dialog_vbox1",
      dialog_vbox1);
  gtk_widget_show (dialog_vbox1);

  fixed1 = gtk_fixed_new ();
  gtk_widget_ref (fixed1);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "fixed1", fixed1,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fixed1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), fixed1, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (fixed1), 6);

  l_diz = gtk_label_new ("Select which ODBC Translator you want to use.");
  gtk_widget_ref (l_diz);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_diz", l_diz,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_diz);
  gtk_fixed_put (GTK_FIXED (fixed1), l_diz, 168, 16);
  gtk_widget_set_uposition (l_diz, 168, 16);
  gtk_widget_set_usize (l_diz, 325, 16);
  gtk_label_set_justify (GTK_LABEL (l_diz), GTK_JUSTIFY_LEFT);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow1);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "scrolledwindow1",
      scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow1);
  gtk_fixed_put (GTK_FIXED (fixed1), scrolledwindow1, 168, 32);
  gtk_widget_set_uposition (scrolledwindow1, 168, 32);
  gtk_widget_set_usize (scrolledwindow1, 320, 248);

  clist1 = gtk_clist_new (4);
  gtk_widget_ref (clist1);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "clist1", clist1,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (clist1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 165);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 1, 118);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 2, 80);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 3, 80);
  gtk_clist_column_titles_show (GTK_CLIST (clist1));

  l_name = gtk_label_new (szDriverColumnNames[0]);
  gtk_widget_ref (l_name);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_name", l_name,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_name);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, l_name);

  l_file = gtk_label_new (szDriverColumnNames[1]);
  gtk_widget_ref (l_file);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_file", l_file,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_file);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 1, l_file);

  l_date = gtk_label_new (szDriverColumnNames[2]);
  gtk_widget_ref (l_date);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_date", l_date,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_date);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 2, l_date);

  l_size = gtk_label_new (szDriverColumnNames[3]);
  gtk_widget_ref (l_size);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_size", l_size,
      (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (l_size);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 3, l_size);

#if GTK_CHECK_VERSION(2,0,0)
  style = gtk_widget_get_style (translatorchooser);
  pixmap =
      gdk_pixmap_create_from_xpm_d (translatorchooser->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm);
#else
  style = gtk_widget_get_style (GTK_WIDGET (hwnd));
  pixmap =
      gdk_pixmap_create_from_xpm_d (GTK_WIDGET (hwnd)->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm);
#endif

  pixmap1 = gtk_pixmap_new (pixmap, mask);
  gtk_widget_ref (pixmap1);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "pixmap1",
      pixmap1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pixmap1);
  gtk_fixed_put (GTK_FIXED (fixed1), pixmap1, 16, 16);
  gtk_widget_set_uposition (pixmap1, 16, 16);
  gtk_widget_set_usize (pixmap1, 136, 264);

  dialog_action_area1 = GTK_DIALOG (translatorchooser)->action_area;
  gtk_object_set_data (GTK_OBJECT (translatorchooser), "dialog_action_area1",
      dialog_action_area1);
  gtk_widget_show (dialog_action_area1);
  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 5);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_ref (hbuttonbox1);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "hbuttonbox1",
      hbuttonbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox1, TRUE, TRUE,
      0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END);
  gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10);

  b_finish = gtk_button_new_with_label ("");
  b_finish_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_finish)->child),
      "_Finish");
  gtk_widget_add_accelerator (b_finish, "clicked", accel_group,
      b_finish_key, GDK_MOD1_MASK, 0);
  gtk_widget_ref (b_finish);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "b_finish",
      b_finish, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (b_finish);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_finish);
  GTK_WIDGET_SET_FLAGS (b_finish, GTK_CAN_DEFAULT);
  gtk_widget_add_accelerator (b_finish, "clicked", accel_group,
      'F', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);

  b_cancel = gtk_button_new_with_label ("");
  b_cancel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_cancel)->child),
      "_Cancel");
  gtk_widget_add_accelerator (b_cancel, "clicked", accel_group,
      b_cancel_key, GDK_MOD1_MASK, 0);
  gtk_widget_ref (b_cancel);
  gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "b_cancel",
      b_cancel, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (b_cancel);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_cancel);
  GTK_WIDGET_SET_FLAGS (b_cancel, GTK_CAN_DEFAULT);
  gtk_widget_add_accelerator (b_cancel, "clicked", accel_group,
      'C', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);

  /* Ok button events */
  gtk_signal_connect (GTK_OBJECT (b_finish), "clicked",
      GTK_SIGNAL_FUNC (translatorchooser_ok_clicked), choose_t);
  /* Cancel button events */
  gtk_signal_connect (GTK_OBJECT (b_cancel), "clicked",
      GTK_SIGNAL_FUNC (translatorchooser_cancel_clicked), choose_t);
  /* Close window button events */
  gtk_signal_connect (GTK_OBJECT (translatorchooser), "delete_event",
      GTK_SIGNAL_FUNC (delete_event), choose_t);
  gtk_signal_connect (GTK_OBJECT (translatorchooser), "destroy",
      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
  /* Translator list events */
  gtk_signal_connect (GTK_OBJECT (clist1), "select_row",
      GTK_SIGNAL_FUNC (translator_list_select), choose_t);

  gtk_window_add_accel_group (GTK_WINDOW (translatorchooser), accel_group);

  addtranslators_to_list (clist1, translatorchooser);

  choose_t->translatorlist = clist1;
  choose_t->translator = NULL;
  choose_t->mainwnd = translatorchooser;
  choose_t->b_finish = b_finish;

  gtk_widget_show_all (translatorchooser);
  gtk_main ();
}
Exemplo n.º 22
0
/*!
 * \brief GUI thread only create a plot surface and periodically call a
 * gui_handler that redraws the plot after a short timeout
 */
static gpointer
gui_thread (gpointer data)
{
  GtkWidget *window;
  GtkWidget *drawing_area;
    /* Create the Widgets */
  GtkWidget *vbox, *menubar, *filemenu,*editmenu,*viewmenu,*helpmenu,
  *file, *edit, *view, *help,*pref_1,*toolbar,*help_Dialog,*about_Dialog,
  *new,*sep1,*sep2, *open,*save,*dialog, *save_as,*export,*export_diag, *quit, *sep, *tog_stat,*statusbar, *tog_tool;
  gdk_threads_enter();
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   /* Some nesseary inits */
  GtkAccelGroup *accel_group = NULL;
  GtkToolItem *test_item;
  GtkToolItem *item_1;
  GtkToolItem *item_2;
  GtkToolItem *item_3;
  GtkToolItem *item_4; 
  /* Set the window title */
  gtk_window_set_title(GTK_WINDOW(window), "eStick Control Center V0.0-ecc");
  /* Add Window Icon max size 128x128 Pixel current 64x64 used */
  gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("window_symbol.png"));
  /* Default Window size at startup */
  gtk_window_set_default_size (GTK_WINDOW(window), xsize+xoff, ysize+yoff);
  /* Set Border With of the window in Pixels */
  gtk_container_set_border_width(GTK_CONTAINER(window), 0);
    /* Create a new Vertical Box, FALSE= WIdgets have not equal space, 0 pixels between widgets */
  vbox = gtk_vbox_new(FALSE, 0);
  /* Add the Vertical Box to the main window */
  gtk_container_add(GTK_CONTAINER(window), vbox);
  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, xsize, ysize);
  
   /* Create the Menu Bar */
  menubar = gtk_menu_bar_new();
  /* Create the Toolbar Bar */
  toolbar = gtk_toolbar_new();
  gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
  gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);
  /* Create a new Statusbar*/
  statusbar = gtk_statusbar_new();
  /* Create the Handlers for the submenus*/
  filemenu = gtk_menu_new();
  editmenu = gtk_menu_new();
  viewmenu = gtk_menu_new();
  helpmenu = gtk_menu_new();
  /* Create new accelerator Group */
  accel_group = gtk_accel_group_new();
  gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
  /* Create the File Drop Down Point in the menu bar with mnemonic character */
  file = gtk_menu_item_new_with_mnemonic("_File");
  /* Create the Edit Drop Down Point in the menu bar with mnemonic character */
  edit = gtk_menu_item_new_with_mnemonic("_Edit");
  /* Create the View Drop Down Point in the menu bar with mnemonic character */
  view = gtk_menu_item_new_with_mnemonic("_View");
  /* Create the Help Drop Down Point in the menu bar with mnemonic character */
  help = gtk_menu_item_new_with_mnemonic("_Help");
    /* ############################# Items for the Menu Bar################## */
  /* Use the open point from the libary and the stock symbol */
  open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
  g_signal_connect(G_OBJECT(open), "activate",G_CALLBACK(file_open),file_open);
  /*Connect signal to display the Message for the Save Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (open), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (open), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (open), "menuhint",(gpointer) "Open a recorded File");
  /* Create vertical seperator line in the file menu */
  sep1 = gtk_separator_menu_item_new();
  /* Use the save point from the libary and the stock symbol */
  save = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE, NULL);
  g_signal_connect(G_OBJECT(save), "activate",G_CALLBACK(file_save),(gpointer) window);
  /*Connect signal to display the Message for the Save Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (save), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (save), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (save), "menuhint",(gpointer) "Save to specified File");
  /* Use the save_as point from the libary and the stock symbol */
  save_as = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS, NULL);
  g_signal_connect(G_OBJECT(save_as), "activate",G_CALLBACK(file_save_as),(gpointer) window);
  /*Connect signal to display the Message for the Save_as Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (save_as), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (save_as), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (save_as), "menuhint",(gpointer) "Save to a new File");
  /* Create vertical seperator line in the file menu */
  sep2 = gtk_separator_menu_item_new();
  /* For the export function, no stock symbol exists, used instead a point with only a label*/
  export = gtk_menu_item_new_with_label("Export");
Exemplo n.º 23
0
GtkWidget*
create_sheets_main_dialog (void)
{
  GtkWidget *sheets_main_dialog;
  GtkWidget *dialog_vbox1;
  GtkWidget *table_sheets;
  GtkWidget *vbuttonbox;
  GtkWidget *button_copy;
  GtkWidget *button_copy_all;
  GtkWidget *button_move;
  GtkWidget *button_move_all;
  GtkWidget *optionmenu_right;
  GtkWidget *optionmenu_right_menu;
  GtkWidget *optionmenu_left;
  GtkWidget *optionmenu_left_menu;
  GtkWidget *glade_menuitem;
  GtkWidget *scrolledwindow_left;
  GtkWidget *scrolledwindow_right;
  GtkWidget *dialog_action_area1;
  GtkWidget *hbox1;
  GtkWidget *button_new;
  GtkWidget *button_move_up;
  GtkWidget *button_move_down;
  GtkWidget *button_edit;
  GtkWidget *button_remove;
  GtkWidget *button_apply;
  GtkWidget *button_revert;
  GtkWidget *button_close;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  sheets_main_dialog = gtk_dialog_new ();
  gtk_object_set_data (GTK_OBJECT (sheets_main_dialog), "sheets_main_dialog", sheets_main_dialog);
  gtk_window_set_title (GTK_WINDOW (sheets_main_dialog), _("Sheets and Objects"));
  gtk_window_set_role(GTK_WINDOW(sheets_main_dialog), "sheets_main_dialog");
  gtk_window_set_default_size (GTK_WINDOW (sheets_main_dialog), 506, 261);
  gtk_window_set_resizable (GTK_WINDOW (sheets_main_dialog), TRUE);

  dialog_vbox1 = GTK_DIALOG (sheets_main_dialog)->vbox;
  gtk_object_set_data (GTK_OBJECT (sheets_main_dialog), "dialog_vbox1", dialog_vbox1);
  gtk_widget_show (dialog_vbox1);

  table_sheets = gtk_table_new (2, 3, FALSE);
  gtk_widget_ref (table_sheets);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "table_sheets", table_sheets,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (table_sheets);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), table_sheets, TRUE, TRUE, 0);

  vbuttonbox = gtk_vbutton_box_new ();
  gtk_widget_ref (vbuttonbox);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "vbuttonbox", vbuttonbox,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbuttonbox);
  gtk_table_attach (GTK_TABLE (table_sheets), vbuttonbox, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 17, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (vbuttonbox), GTK_BUTTONBOX_SPREAD);

  button_copy = gtk_button_new_with_label (_("<- Copy"));
  gtk_widget_ref (button_copy);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_copy", button_copy,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_copy);
  gtk_container_add (GTK_CONTAINER (vbuttonbox), button_copy);
  gtk_widget_add_accelerator (button_copy, "clicked", accel_group,
                              GDK_c, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_copy_all = gtk_button_new_with_label (_("<- Copy All"));
  gtk_widget_ref (button_copy_all);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_copy_all", button_copy_all,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_copy_all);
  gtk_container_add (GTK_CONTAINER (vbuttonbox), button_copy_all);

  button_move = gtk_button_new_with_label (_("<- Move"));
  gtk_widget_ref (button_move);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_move", button_move,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_move);
  gtk_container_add (GTK_CONTAINER (vbuttonbox), button_move);
  gtk_widget_add_accelerator (button_move, "clicked", accel_group,
                              GDK_m, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_move_all = gtk_button_new_with_label (_("<- Move All"));
  gtk_widget_ref (button_move_all);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_move_all", button_move_all,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_move_all);
  gtk_container_add (GTK_CONTAINER (vbuttonbox), button_move_all);

  optionmenu_right = gtk_option_menu_new ();
  gtk_widget_ref (optionmenu_right);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "optionmenu_right", optionmenu_right,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (optionmenu_right);
  gtk_table_attach (GTK_TABLE (table_sheets), optionmenu_right, 2, 3, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  optionmenu_right_menu = gtk_menu_new ();
  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_right), optionmenu_right_menu);

  optionmenu_left = gtk_option_menu_new ();
  gtk_widget_ref (optionmenu_left);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "optionmenu_left", optionmenu_left,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (optionmenu_left);
  gtk_table_attach (GTK_TABLE (table_sheets), optionmenu_left, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  optionmenu_left_menu = gtk_menu_new ();
  glade_menuitem = gtk_menu_item_new_with_label ("");
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu_left_menu), glade_menuitem);
  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_left), optionmenu_left_menu);

  scrolledwindow_left = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow_left);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "scrolledwindow_left", scrolledwindow_left,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow_left);
  gtk_table_attach (GTK_TABLE (table_sheets), scrolledwindow_left, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_left), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  scrolledwindow_right = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow_right);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "scrolledwindow_right", scrolledwindow_right,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow_right);
  gtk_table_attach (GTK_TABLE (table_sheets), scrolledwindow_right, 2, 3, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_right), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  dialog_action_area1 = GTK_DIALOG (sheets_main_dialog)->action_area;
  gtk_object_set_data (GTK_OBJECT (sheets_main_dialog), "dialog_action_area1", dialog_action_area1);
  gtk_widget_show (dialog_action_area1);
  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10);

  hbox1 = gtk_hbox_new (TRUE, 0);
  gtk_widget_ref (hbox1);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "hbox1", hbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbox1, TRUE, TRUE, 0);

  button_new = gtk_button_new_from_stock(GTK_STOCK_NEW);
  gtk_widget_ref (button_new);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_new", button_new,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_new);
  gtk_box_pack_start (GTK_BOX (hbox1), button_new, FALSE, TRUE, 0);
  gtk_widget_add_accelerator (button_new, "clicked", accel_group,
                              GDK_n, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_move_up = gtk_button_new_from_stock (GTK_STOCK_GO_UP);
  gtk_widget_ref (button_move_up);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_move_up", button_move_up,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_move_up);
  gtk_box_pack_start (GTK_BOX (hbox1), button_move_up, FALSE, TRUE, 0);
  gtk_widget_add_accelerator (button_move_up, "clicked", accel_group,
                              GDK_u, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  button_move_down = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN);
  gtk_widget_ref (button_move_down);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_move_down", button_move_down,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_move_down);
  gtk_box_pack_start (GTK_BOX (hbox1), button_move_down, FALSE, TRUE, 0);
  gtk_widget_add_accelerator (button_move_down, "clicked", accel_group,
                              GDK_d, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_edit = gtk_button_new(); /* _with_label (_("Edit")); */
  {
    GtkWidget *label;

    label = gtk_label_new(_("Edit"));
    gtk_widget_ref(label);
    gtk_label_parse_uline(GTK_LABEL(label), _("_Edit"));
    gtk_container_add(GTK_CONTAINER(button_edit), label);
    gtk_widget_show(label);
  }
  gtk_widget_ref (button_edit);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_edit", button_edit,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_edit);
  gtk_box_pack_start (GTK_BOX (hbox1), button_edit, FALSE, TRUE, 0);
  gtk_widget_add_accelerator (button_edit, "clicked", accel_group,
                              GDK_e, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
  gtk_widget_ref (button_remove);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_remove", button_remove,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_remove);
  gtk_box_pack_start (GTK_BOX (hbox1), button_remove, FALSE, TRUE, 0);
  gtk_widget_add_accelerator (button_remove, "clicked", accel_group,
                              GDK_r, GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  button_apply = gtk_button_new_from_stock(GTK_STOCK_APPLY);
  gtk_widget_ref (button_apply);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_apply", button_apply,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_apply);
  gtk_box_pack_start (GTK_BOX (hbox1), button_apply, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (button_apply, FALSE);

  button_revert = gtk_button_new_with_label(_("Revert"));
  gtk_widget_ref (button_revert);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_revert", button_revert,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_revert);
  gtk_box_pack_start (GTK_BOX (hbox1), button_revert, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (button_revert, FALSE);

  button_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
  gtk_widget_ref (button_close);
  gtk_object_set_data_full (GTK_OBJECT (sheets_main_dialog), "button_close", button_close,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_close);
  gtk_box_pack_start (GTK_BOX (hbox1), button_close, FALSE, TRUE, 0);

  g_signal_connect (GTK_OBJECT (sheets_main_dialog), "delete_event",
                      G_CALLBACK (on_sheets_main_dialog_delete_event),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_copy), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_copy_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_copy_all), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_copy_all_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_move), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_move_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_move_all), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_move_all_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_new), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_new_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_move_up), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_move_up_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_move_down), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_move_down_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_edit), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_edit_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_remove), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_remove_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_apply), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_apply_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_revert), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_revert_clicked),
                      NULL);
  g_signal_connect (GTK_OBJECT (button_close), "clicked",
                      G_CALLBACK (on_sheets_dialog_button_close_clicked),
                      NULL);

  gtk_window_add_accel_group (GTK_WINDOW (sheets_main_dialog), accel_group);

  persistence_register_window(GTK_WINDOW(sheets_main_dialog));

  return sheets_main_dialog;
}
Exemplo n.º 24
0
GtkWidget * create_MessageBox( void )
{
 GtkWidget * vbox1;
 GtkWidget * hbox1;
 GtkWidget * hbuttonbox1;
 GtkWidget * Ok;
 GtkAccelGroup * accel_group;
 GtkStyle * pixmapstyle;
 GdkPixmap * pixmapwid;
 GdkBitmap * mask;

 accel_group=gtk_accel_group_new();

 MessageBox=gtk_window_new( GTK_WINDOW_TOPLEVEL );
 gtk_widget_set_name( MessageBox,"MessageBox" );
 gtk_object_set_data( GTK_OBJECT( MessageBox ),"MessageBox",MessageBox );
 gtk_widget_set_events( MessageBox,GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_VISIBILITY_NOTIFY_MASK );
 gtk_window_set_title( GTK_WINDOW( MessageBox ),"MPlayer ..." );
 gtk_window_set_position( GTK_WINDOW( MessageBox ),GTK_WIN_POS_CENTER );
 gtk_window_set_modal( GTK_WINDOW( MessageBox ),TRUE );
 gtk_window_set_policy( GTK_WINDOW( MessageBox ),TRUE,TRUE,FALSE );
 gtk_window_set_wmclass( GTK_WINDOW( MessageBox ),"Message","MPlayer" );

 gtk_widget_realize( MessageBox );
 gtkAddIcon( MessageBox );

 vbox1=AddVBox( AddDialogFrame( MessageBox ),0 );
 hbox1=AddHBox( vbox1,1 );

 pixmapstyle=gtk_widget_get_style( MessageBox );

 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )warning_xpm );
 WarningPixmap=gtk_pixmap_new( pixmapwid,mask );
 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )error_xpm );
 ErrorPixmap=gtk_pixmap_new( pixmapwid,mask );

 gtk_widget_set_name( WarningPixmap,"pixmap1" );
 gtk_widget_hide( WarningPixmap );
 gtk_box_pack_start( GTK_BOX( hbox1 ),WarningPixmap,FALSE,FALSE,0 );
 gtk_widget_set_usize( WarningPixmap,55,-2 );

 gtk_widget_set_name( ErrorPixmap,"pixmap1" );
 gtk_widget_hide( ErrorPixmap );
 gtk_box_pack_start( GTK_BOX( hbox1 ),ErrorPixmap,FALSE,FALSE,0 );
 gtk_widget_set_usize( ErrorPixmap,55,-2 );

 gtkMessageBoxText=gtk_label_new( "Text jol. Ha ezt megerted,akkor neked nagyon jo a magyar tudasod,te." );
 gtk_widget_set_name( gtkMessageBoxText,"gtkMessageBoxText" );
 gtk_widget_show( gtkMessageBoxText );
 gtk_box_pack_start( GTK_BOX( hbox1 ),gtkMessageBoxText,TRUE,TRUE,0 );
// gtk_label_set_justify( GTK_LABEL( gtkMessageBoxText ),GTK_JUSTIFY_FILL );
 gtk_label_set_justify( GTK_LABEL( gtkMessageBoxText ),GTK_JUSTIFY_CENTER );
 gtk_label_set_line_wrap( GTK_LABEL( gtkMessageBoxText ),FALSE );

 AddHSeparator( vbox1 );
 hbuttonbox1=AddHButtonBox( vbox1 );
 Ok=AddButton( MSGTR_Ok,hbuttonbox1 );

 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );

 gtk_signal_connect( GTK_OBJECT( MessageBox ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&MessageBox );
 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Ok_released ),NULL );

 gtk_window_add_accel_group( GTK_WINDOW( MessageBox ),accel_group );

 return MessageBox;
}
Exemplo n.º 25
0
int main(int argc, char *argv[])
{
	GtkWidget           *win = NULL;            /* The main window */
	GtkWidget           *vbox = NULL;           /* Packing box for the menu and toolbars */
	GtkWidget           *menubar = NULL;        /* The actual menubar */
	GtkWidget           *toolbar = NULL;        /* The actual toolbar */
	GtkActionGroup      *action_group = NULL;   /* Packing group for our Actions */
	GtkUIManager        *menu_manager = NULL;   /* The magic widget! */
	GError              *error = NULL;          /* For reporting exceptions or errors */
	
	/* Initialize translation text domain */
	bindtextdomain(g_config.package_name, g_config.locale_dir);
	bind_textdomain_codeset(g_config.package_name, "UTF-8");
	textdomain(g_config.package_name);

	/* Initialize GTK+ */
	g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
	gtk_init(&argc, &argv);
	g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

	/* Create the main window */
	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(win), _("Hello World"));
	gtk_window_set_default_size(GTK_WINDOW(win), 400, 300);
	gtk_widget_realize(win);

	/* Create a vertical box to hold menubar and toolbar */
	vbox = gtk_vbox_new(FALSE, 0);

	/* Create menus */
	action_group = gtk_action_group_new("TestActions");
	gtk_action_group_set_translation_domain(action_group, g_config.package_name);
	menu_manager = gtk_ui_manager_new();

	/* Read in the UI from our XML file */
	error = NULL;
	gtk_ui_manager_add_ui_from_file(menu_manager, "hello.xml", &error);

	if (error)
	{
	    g_message("building menus failed: %s", error->message);
	    g_error_free(error);
		error = NULL;
	}


	/* Create a list of entries which are passed to the Action constructor.
	 * This is a huge convenience over building Actions by hand.
	 */
	const GtkActionEntry entries[] = {
		/**********************************/
		{ "FileMenuAction", NULL,
		  _("_File"), NULL,
		  _("File operations"),
		  NULL
		},
		/**********************************/
		{ "SendAction", GTK_STOCK_EXECUTE,
		  _("_Send"), "<Ctrl>S",
		  _("Send hello world to console"),
		  G_CALLBACK(SendHelloWorld)
		},
		/**********************************/
		{ "QuitAction", GTK_STOCK_QUIT,
		  _("_Quit"), "<Ctrl>Q",
		  _("Quit"),
		  G_CALLBACK(gtk_main_quit)
		},
		/**********************************/
	};
	/* Pack up our objects:
	 * vbox -> win
	 * actions -> action_group
	 * action_group -> menu_manager
	 */
	gtk_container_add(GTK_CONTAINER(win), vbox);
	gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), NULL);
	gtk_ui_manager_insert_action_group(menu_manager, action_group, 0);

	/* Get the menubar and the toolbar and put them in the vertical packing box */
	menubar = gtk_ui_manager_get_widget(menu_manager, "/MainMenuBar");
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
	toolbar = gtk_ui_manager_get_widget(menu_manager, "/MainToolbar");
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);


	/* Connect signals */
	g_signal_connect(win, "destroy", gtk_main_quit, NULL);

	/* Make sure that the accelerators work */
	gtk_window_add_accel_group(GTK_WINDOW(win), 
	                           gtk_ui_manager_get_accel_group(menu_manager));

	/* Enter the main loop */
	gtk_widget_show_all(win);
	gtk_main();
	return (0);
}
Exemplo n.º 26
0
/**
 * @param ddisp The diagram display object that a window is created for
 * @param width Diagram widgth
 * @param height Diagram Height
 * @param title Window title
 * @param use_mbar Flag to indicate whether to add a menubar to the window
 */
void
create_display_shell(DDisplay *ddisp,
		     int width, int height,
		     char *title, int use_mbar)
{
  GtkWidget *table, *widget;
  GtkWidget *status_hbox;
  GtkWidget *root_vbox = NULL;
  GtkWidget *zoom_hbox, *zoom_label;
  int s_width, s_height;

  if (app_is_interactive() && is_integrated_ui())
  {
    use_integrated_ui_for_display_shell(ddisp, title);
    return;
  }
 
  ddisp->is_standalone_window = TRUE;
  ddisp->container            = NULL;

  s_width = gdk_screen_width ();
  s_height = gdk_screen_height ();
  if (width > s_width)
    width = s_width;
  if (height > s_height)
    height = s_height;

  /*  The toplevel shell */
  ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (ddisp->shell), title);
  gtk_window_set_role (GTK_WINDOW (ddisp->shell), "diagram_window");
  gtk_window_set_icon_name (GTK_WINDOW (ddisp->shell), "dia");
  gtk_window_set_default_size(GTK_WINDOW (ddisp->shell), width, height);
  /* set_icon_name needs registered theme icons, not always available: provide fallback */
  if (!gtk_window_get_icon (GTK_WINDOW (ddisp->shell))) {
    static GdkPixbuf *pixbuf = NULL;

    if (!pixbuf)
      pixbuf = gdk_pixbuf_new_from_inline(-1, dia_diagram_icon, FALSE, NULL);
    if (pixbuf)
      gtk_window_set_icon (GTK_WINDOW (ddisp->shell), pixbuf);
  }

  g_object_set_data (G_OBJECT (ddisp->shell), "user_data", (gpointer) ddisp);

  _ddisplay_setup_events (ddisp, ddisp->shell);
  /* following two not shared with integrated UI */
  g_signal_connect (G_OBJECT (ddisp->shell), "delete_event",
		    G_CALLBACK (ddisplay_delete), ddisp);
  g_signal_connect (G_OBJECT (ddisp->shell), "destroy",
		    G_CALLBACK (ddisplay_destroy), ddisp);

  /*  the table containing all widgets  */
  table = gtk_table_new (4, 3, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2);
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
  if (use_mbar) 
  {
      root_vbox = gtk_vbox_new (FALSE, 1);
      gtk_container_add (GTK_CONTAINER (ddisp->shell), root_vbox);
      gtk_box_pack_end (GTK_BOX (root_vbox), table, TRUE, TRUE, 0);
  }
  else
  {
      gtk_container_add (GTK_CONTAINER (ddisp->shell), table);
  }
  

  /*  scrollbars, rulers, canvas, menu popup button  */
  if (!use_mbar) {
      ddisp->origin = gtk_button_new();
#if GTK_CHECK_VERSION(2,18,0)
      gtk_widget_set_can_focus (ddisp->origin, FALSE);
#else
      GTK_WIDGET_UNSET_FLAGS(ddisp->origin, GTK_CAN_FOCUS);
#endif
      widget = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
      gtk_container_add(GTK_CONTAINER(ddisp->origin), widget);
      gtk_widget_set_tooltip_text(widget, _("Diagram menu."));
      gtk_widget_show(widget);
      g_signal_connect(G_OBJECT(ddisp->origin), "button_press_event",
		     G_CALLBACK(origin_button_press), ddisp);
  }
  else {
      ddisp->origin = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT);
  }
  
  _ddisplay_setup_rulers (ddisp, ddisp->shell, table);
  _ddisplay_setup_scrollbars (ddisp, table, width, height);
  _ddisplay_setup_navigation (ddisp, table, FALSE);

  ddisp->canvas = create_canvas (ddisp);

  /*  pack all remaining widgets  */
  gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  /* TODO rob use per window accel */
  ddisp->accel_group = menus_get_display_accels ();
  gtk_window_add_accel_group(GTK_WINDOW(ddisp->shell), ddisp->accel_group);

  if (use_mbar) {
    ddisp->menu_bar = menus_create_display_menubar (&ddisp->ui_manager, &ddisp->actions);
    g_assert (ddisp->menu_bar);
    gtk_box_pack_start (GTK_BOX (root_vbox), ddisp->menu_bar, FALSE, TRUE, 0);
  }

  /* the statusbars */
  status_hbox = gtk_hbox_new (FALSE, 2);

  /* Zoom status pseudo-optionmenu */
  ddisp->zoom_status = create_zoom_widget(ddisp);
  zoom_hbox = gtk_hbox_new(FALSE, 0);
  zoom_label = gtk_label_new(_("Zoom"));
  gtk_box_pack_start (GTK_BOX(zoom_hbox), zoom_label,
		      FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX(zoom_hbox), ddisp->zoom_status,
		      FALSE, FALSE, 0);

  gtk_box_pack_start (GTK_BOX (status_hbox), zoom_hbox, FALSE, FALSE, 0);

  /* Grid on/off button */
  ddisp->grid_status = dia_toggle_button_new_with_icons(dia_on_grid_icon,
							dia_off_grid_icon);
  
  g_signal_connect(G_OBJECT(ddisp->grid_status), "toggled",
		   G_CALLBACK (grid_toggle_snap), ddisp);
  gtk_widget_set_tooltip_text(ddisp->grid_status,
		       _("Toggles snap-to-grid for this window."));
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->grid_status,
		      FALSE, FALSE, 0);


  ddisp->mainpoint_status = dia_toggle_button_new_with_icons(dia_mainpoints_on_icon,
							dia_mainpoints_off_icon);
  
  g_signal_connect(G_OBJECT(ddisp->mainpoint_status), "toggled",
		   G_CALLBACK (interface_toggle_mainpoint_magnetism), ddisp);
  gtk_widget_set_tooltip_text(ddisp->mainpoint_status,
		       _("Toggles object snapping for this window."));
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->mainpoint_status,
		      FALSE, FALSE, 0);


  /* Statusbar */
  ddisp->modified_status = gtk_statusbar_new ();

  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->modified_status,
		      TRUE, TRUE, 0);

  gtk_table_attach (GTK_TABLE (table), status_hbox, 0, 3, 3, 4,
                    GTK_FILL, GTK_FILL, 0, 0);

  display_rulers_show (ddisp);
  gtk_widget_show (ddisp->zoom_status);
  gtk_widget_show (zoom_hbox);
  gtk_widget_show (zoom_label);
  gtk_widget_show (ddisp->grid_status);
  gtk_widget_show (ddisp->mainpoint_status);
  gtk_widget_show (ddisp->modified_status);
  gtk_widget_show (status_hbox);
  gtk_widget_show (table);
  if (use_mbar) 
  {
      gtk_widget_show (ddisp->menu_bar);
      gtk_widget_show (root_vbox);
  }
  gtk_widget_show (ddisp->shell);

  /* before showing up, checking canvas's REAL size */
  if (use_mbar && ddisp->hrule->allocation.width > width) 
  {
    /* The menubar is not shrinkable, so the shell will have at least
     * the menubar's width. If the diagram's requested width is smaller,
     * the canvas will be enlarged to fit the place. In this case, we
     * need to adjust the horizontal scrollbar according to the size
     * that will be allocated, which the same as the hrule got.
     */

    width = ddisp->hrule->allocation.width;

    gtk_adjustment_set_upper (ddisp->hsbdata, width);
    gtk_adjustment_set_page_increment (ddisp->hsbdata, (width - 1) / 4);
    gtk_adjustment_set_page_size (ddisp->hsbdata, width - 1);

    gtk_adjustment_changed (GTK_ADJUSTMENT(ddisp->hsbdata));
  }
  gtk_widget_show (ddisp->canvas);

  /*  set the focus to the canvas area  */
  gtk_widget_grab_focus (ddisp->canvas);
}
Exemplo n.º 27
0
void
create_display_shell(DDisplay *ddisp,
		     int width, int height,
		     char *title)
{
  GtkWidget *table;
  GtkWidget *status_hbox;
  int s_width, s_height;

  s_width = gdk_screen_width ();
  s_height = gdk_screen_height ();
  if (width > s_width)
    width = s_width;
  if (height > s_height)
    width = s_width;

  /*  The adjustment datums  */
  ddisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width-1));
  ddisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height-1));

  /*  The toplevel shell */
  ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (ddisp->shell), title);
  gtk_window_set_wmclass (GTK_WINDOW (ddisp->shell), "diagram_window",
			  "Dia");
  gtk_window_set_policy (GTK_WINDOW (ddisp->shell), TRUE, TRUE, TRUE);
  gtk_object_set_user_data (GTK_OBJECT (ddisp->shell), (gpointer) ddisp);
  gtk_widget_set_events (ddisp->shell,
			 GDK_POINTER_MOTION_MASK |
			 GDK_POINTER_MOTION_HINT_MASK |
			 GDK_FOCUS_CHANGE_MASK);
                      /* GDK_ALL_EVENTS_MASK */

  gtk_signal_connect (GTK_OBJECT (ddisp->shell), "delete_event",
                      GTK_SIGNAL_FUNC (ddisplay_delete),
                      ddisp);
  gtk_signal_connect (GTK_OBJECT (ddisp->shell), "destroy",
                      GTK_SIGNAL_FUNC (ddisplay_destroy),
                      ddisp);
  
  /*  the table containing all widgets  */
  table = gtk_table_new (4, 3, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2);
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
  gtk_container_add (GTK_CONTAINER (ddisp->shell), table);

  /*  scrollbars, rulers, canvas, menu popup button  */
  ddisp->origin = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT);

  ddisp->hrule = gtk_hruler_new ();
  gtk_signal_connect_object (GTK_OBJECT (ddisp->shell), "motion_notify_event",
                             (GtkSignalFunc) GTK_WIDGET_CLASS (GTK_OBJECT (ddisp->hrule)->klass)->motion_notify_event,
                             GTK_OBJECT (ddisp->hrule));

  ddisp->vrule = gtk_vruler_new ();
  gtk_signal_connect_object (GTK_OBJECT (ddisp->shell), "motion_notify_event",
                             (GtkSignalFunc) GTK_WIDGET_CLASS (GTK_OBJECT (ddisp->vrule)->klass)->motion_notify_event,
                             GTK_OBJECT (ddisp->vrule));

  ddisp->hsb = gtk_hscrollbar_new (ddisp->hsbdata);
  GTK_WIDGET_UNSET_FLAGS (ddisp->hsb, GTK_CAN_FOCUS);
  ddisp->vsb = gtk_vscrollbar_new (ddisp->vsbdata);
  GTK_WIDGET_UNSET_FLAGS (ddisp->vsb, GTK_CAN_FOCUS);


  /*  set up the scrollbar observers  */
  gtk_signal_connect (GTK_OBJECT (ddisp->hsbdata), "value_changed",
		      (GtkSignalFunc) ddisplay_hsb_update,
		      ddisp);
  gtk_signal_connect (GTK_OBJECT (ddisp->vsbdata), "value_changed",
		      (GtkSignalFunc) ddisplay_vsb_update,
		      ddisp);

  ddisp->canvas = gtk_drawing_area_new ();
  gtk_drawing_area_size (GTK_DRAWING_AREA (ddisp->canvas), width, height);
  gtk_widget_set_events (ddisp->canvas, CANVAS_EVENT_MASK);
  GTK_WIDGET_SET_FLAGS (ddisp->canvas, GTK_CAN_FOCUS);
  gtk_signal_connect (GTK_OBJECT (ddisp->canvas), "event",
		      (GtkSignalFunc) ddisplay_canvas_events,
		      ddisp);
  gtk_object_set_user_data (GTK_OBJECT (ddisp->canvas), (gpointer) ddisp);
  /*  pack all the widgets  */
  gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->hrule, 1, 2, 0, 1,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->vrule, 0, 1, 1, 2,
                    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->hsb, 0, 2, 2, 3,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->vsb, 2, 3, 0, 2,
                    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  /*  the popup menu  */
#ifdef GNOME
  ddisp->popup = gnome_display_menus_create ();
  ddisp->accel_group = gnome_popup_menu_get_accel_group(GTK_MENU(ddisp->popup));
#else
  menus_get_image_menu (&ddisp->popup, &ddisp->accel_group);
#endif

  /*  the accelerator table/group for the popup */
  gtk_window_add_accel_group (GTK_WINDOW(ddisp->shell), ddisp->accel_group);


  /* the statusbars */
  status_hbox = gtk_hbox_new (FALSE, 2);

  ddisp->zoom_status = gtk_statusbar_new ();
  ddisp->modified_status = gtk_statusbar_new ();
  
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->zoom_status,
		      FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->modified_status,
		      TRUE, TRUE, 
		      0);

  gtk_table_attach (GTK_TABLE (table), status_hbox, 0, 3, 3, 4,
                    GTK_FILL, GTK_FILL, 0, 0);


  gtk_widget_show (ddisp->hsb);
  gtk_widget_show (ddisp->vsb);
  gtk_widget_show (ddisp->origin);
  gtk_widget_show (ddisp->hrule);
  gtk_widget_show (ddisp->vrule);
  gtk_widget_show (ddisp->canvas);
  gtk_widget_show (ddisp->zoom_status);
  gtk_widget_show (ddisp->modified_status);
  gtk_widget_show (status_hbox);
  gtk_widget_show (table);
  gtk_widget_show (ddisp->shell);

  /*  set the focus to the canvas area  */
  gtk_widget_grab_focus (ddisp->canvas);
}
Exemplo n.º 28
0
/**
 * Create integrated user interface
 */
void 
create_integrated_ui (void)
{
  GtkWidget *window;
  GtkWidget *main_vbox;
  GtkWidget *hbox;
  GtkWidget *wrapbox;
  GtkWidget *menubar;
  GtkWidget *toolbar;
  GtkWidget *notebook;
  GtkWidget *statusbar;
  GtkAccelGroup *accel_group;

  GtkWidget *layer_view;
	
#ifdef HAVE_GNOME
  window = gnome_app_new ("Dia", _("Diagram Editor"));
#else
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_object_ref (window);
  gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION);
#endif

  /* hint to window manager on X so the wm can put the window in the same  
     as it was when the application shut down                             */      
  gtk_window_set_role (GTK_WINDOW (window), DIA_MAIN_WINDOW);
  
  gtk_window_set_default_size (GTK_WINDOW (window), 146, 349);
 
  app_set_icon (GTK_WINDOW (window));

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (toolbox_delete),
		      window);

  g_signal_connect (G_OBJECT (window), "destroy",
		    G_CALLBACK (toolbox_destroy),
		      window);

  main_vbox = gtk_vbox_new (FALSE, 1);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
#ifdef HAVE_GNOME
  gnome_app_set_contents (GNOME_APP(window), main_vbox);
#else
  gtk_container_add (GTK_CONTAINER (window), main_vbox);
#endif
  gtk_widget_show (main_vbox);

  /* Applicatioon Statusbar */
  statusbar = gtk_statusbar_new ();
  gtk_box_pack_end (GTK_BOX (main_vbox), statusbar, FALSE, TRUE, 0);
  /* HBox for everything below the menubar and toolbars */
  hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_end (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);
  
  /* Layer View  */
  layer_view = create_layer_view_widget ();
  gtk_box_pack_end (GTK_BOX (hbox), layer_view, FALSE, FALSE, 0);
	 
  /* Diagram Notebook */
  notebook = gtk_notebook_new ();
  gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); 
  gtk_widget_show (notebook);

  /* Toolbox widget */
  wrapbox = toolbox_create();
  gtk_box_pack_start (GTK_BOX (hbox), wrapbox, FALSE, TRUE, 0);

  g_signal_connect (G_OBJECT (wrapbox), "drag_data_received",
		    G_CALLBACK (dia_dnd_file_drag_data_received),
                    NULL); /* userdata == NULL here intentionally */
  /* setup the notebook to receive drops as well */
  toolbox_setup_drag_dest (notebook);
  g_signal_connect (G_OBJECT (notebook), "drag_data_received",
		    G_CALLBACK (dia_dnd_file_drag_data_received),
                    NULL); /* userdata == NULL here intentionally */

  /* menus -- initialised afterwards, because initing the display menus
   * uses the tool buttons*/
  menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group);
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  gtk_widget_show (menubar);
#ifdef HAVE_GNOME
  gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar));
#else
#  ifdef HAVE_MAC_INTEGRATION
  _create_mac_integration (menubar);
#  else
  gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
#  endif
#endif

  /* Toolbar */
  /* TODO: maybe delete set_style(toolbar,ICONS) */
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0);
  gtk_widget_show (toolbar);

  persistence_register_window(GTK_WINDOW(window));

  ui.main_window      = GTK_WINDOW    (window);
  ui.toolbar          = GTK_TOOLBAR   (toolbar);
  ui.diagram_notebook = GTK_NOTEBOOK  (notebook);
  ui.statusbar        = GTK_STATUSBAR (statusbar);
  ui.layer_view       =                layer_view;

  /* NOTE: These functions use ui.xxx assignments above and so must come after
   *       the user interface components are set.                              */
  integrated_ui_toolbar_show (TRUE);
  integrated_ui_statusbar_show (TRUE);

  /* For access outside here: */
  g_object_set_data (G_OBJECT (ui.main_window), DIA_MAIN_NOTEBOOK, notebook);

  /* TODO: Figure out what to do about toolbox_shell for integrated UI */
  toolbox_shell = window;
}
void create_vector_table_options_dialog (vector_table_options_D *dialog)
  {
  GtkWidget *tbl = NULL, *toolbar = NULL, *btn = NULL, *btnBaseRadioSource = NULL ;
  GtkAccelGroup *accel_group = NULL ;
  GtkTreeViewColumn *col = NULL ;
  GtkCellRenderer *cr = NULL ;

  accel_group = gtk_accel_group_new () ;

  dialog->dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);
  gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Vector Table Setup"));
  gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), TRUE) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "dialog", dialog) ;

  tbl = gtk_table_new (2, 1, FALSE) ;
  gtk_widget_show (tbl) ;
  gtk_container_add (GTK_CONTAINER (dialog->dialog), tbl) ;

  toolbar = gtk_toolbar_new () ;
  gtk_widget_show (toolbar) ;
  gtk_table_attach (GTK_TABLE (tbl), toolbar, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_FILL), 0, 0) ;
  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL) ;
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE) ;
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH) ;

  g_object_set_data (G_OBJECT (btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Close"),
    _("Close Window"),
    _("Close vector table editor."),
    gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnClose_clicked,
    NULL)),
  "dialog", dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_w, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)) ;

#ifdef STDIO_FILEIO
  dialog->btnOpen =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Open"),
    _("Open Vector Table"),
    _("Open and display another vector table."),
    gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnOpen_clicked,
    dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_o, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;

  dialog->btnSave =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Save"),
    _("Save Vector Table"),
    _("Save the displayed vector table."),
    gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnSave_clicked,
    dialog->dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;
#endif /* def STDIO_FILEIO */

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)) ;

  g_object_set_data (G_OBJECT (
    dialog->tbtnExhaustive =
    btnBaseRadioSource = gtk_toolbar_append_element (
      GTK_TOOLBAR (toolbar),
      GTK_TOOLBAR_CHILD_RADIOBUTTON,
      NULL,
      _("Exhaustive"),
      _("Exhaustive Verification"),
      _("Attempt all possible inputs."),
      gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_LARGE_TOOLBAR),
      (GCallback)vector_table_options_dialog_btnSimType_clicked,
      dialog)),
    "sim_type", (gpointer)EXHAUSTIVE_VERIFICATION) ;

  g_object_set_data (G_OBJECT (
    dialog->tbtnVT =
    gtk_toolbar_append_element (
      GTK_TOOLBAR (toolbar),
      GTK_TOOLBAR_CHILD_RADIOBUTTON,
      btnBaseRadioSource,
      _("Vector Table"),
      _("Vector Table Simulation"),
      _("Create a sequence of inputs."),
      gtk_image_new_from_stock (GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR),
      (GCallback)vector_table_options_dialog_btnSimType_clicked,
      dialog)),
    "sim_type", (gpointer)VECTOR_TABLE) ;

  dialog->tblVT = gtk_table_new (1, 2, FALSE) ;
  gtk_widget_show (dialog->tblVT) ;
  gtk_table_attach (GTK_TABLE (tbl), dialog->tblVT, 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0) ;

  toolbar = gtk_toolbar_new () ;
  gtk_widget_show (toolbar) ;
  gtk_table_attach (GTK_TABLE (dialog->tblVT), toolbar, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0) ;
  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_VERTICAL) ;
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE) ;
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS) ;

  dialog->btnAdd =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Add"),
    _("Add Vector"),
    _("Apend a vector to the end of the table."),
    gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnAdd_clicked,
    dialog->dialog) ;

  dialog->btnInsert =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Insert Before"),
    _("Insert Vector Before"),
    _("Insert vector before the selected one."),
    gtk_image_new_from_stock (QCAD_STOCK_INSERT_COL_BEFORE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnAdd_clicked,
    dialog->dialog) ;

  dialog->btnDelete =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Delete Vector"),
    _("Delete Vector"),
    _("Insert the selected vector."),
    gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnDelete_clicked,
    dialog->dialog) ;

  dialog->sw = qcad_tree_view_container_new () ;
  gtk_widget_show (dialog->sw) ;
  gtk_table_attach (GTK_TABLE (dialog->tblVT), dialog->sw, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 2, 2) ;
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (dialog->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC) ;
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (dialog->sw), GTK_SHADOW_IN) ;

  dialog->tv = create_bus_layout_tree_view (TRUE, _("Inputs"), GTK_SELECTION_SINGLE) ;
  gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tv), col = gtk_tree_view_column_new ()) ;
  gtk_tree_view_column_set_title (col, _("Active")) ;
  gtk_tree_view_column_pack_start (col, cr = dialog->crActive = gtk_cell_renderer_toggle_new (), TRUE) ;
  gtk_tree_view_column_add_attribute (col, cr, "active", VECTOR_TABLE_MODEL_COLUMN_ACTIVE) ;
  g_object_set (G_OBJECT (cr), "activatable", TRUE, NULL) ;
  gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (cr), TRUE) ;
  gtk_widget_show (dialog->tv) ;
  gtk_container_add (GTK_CONTAINER (dialog->sw), dialog->tv) ;
  qcad_tree_view_container_freeze_columns (QCAD_TREE_VIEW_CONTAINER (dialog->sw), 2) ;

  g_signal_connect (G_OBJECT (dialog->tv),     "style-set",    (GCallback)tree_view_style_set,                          NULL) ;
  g_signal_connect (G_OBJECT (cr),             "toggled",      (GCallback)vt_model_active_toggled,                      dialog->tv) ;
  g_signal_connect (G_OBJECT (dialog->dialog), "delete-event", (GCallback)vector_table_options_dialog_btnClose_clicked, NULL) ;

  gtk_window_add_accel_group (GTK_WINDOW (dialog->dialog), accel_group) ;
  }
Exemplo n.º 30
0
GtkWidget *menubar_new (GtkWidget *Window)
{
  GtkWidget *Menu;
  GtkItemFactory *ItemFactory;
  GtkAccelGroup *AccelGroup;
  gchar *AccelRC;
  guint NbMenuEntries = sizeof (MenuEntries) / sizeof (MenuEntries[0]);

  MsgBarToggleDisplay = FALSE;
  ToolBarToggleDisplay = FALSE;
  ToggleWordwrap = FALSE;
  AccelGroup = gtk_accel_group_new();
  ItemFactory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", AccelGroup);
  gtk_item_factory_create_items (ItemFactory, NbMenuEntries,
				 MenuEntries, NULL);
  gtk_window_add_accel_group (GTK_WINDOW (Window), AccelGroup);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/File")), Menu);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/File/Recent Files")), Menu);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Edit")), Menu);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Tools")), Menu);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Tools/Conversions")), Menu);
  Menu = gtk_tearoff_menu_item_new (); 
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Settings")), Menu);
  Menu = gtk_tearoff_menu_item_new (); 
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Settings/Doc Tabs")), Menu);
  if (MSGBAR_DISPLAY)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Msg Bar")),
				    TRUE);
  if (TOOLBAR_DISPLAY)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Tool Bar")),
				    TRUE);
  if (TOGGLE_WORDWRAP)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Wordwrap")),
				    TRUE);
  if (TAB_POSITION == 1)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Doc Tabs/Top")),
				    TRUE);
  if (TAB_POSITION == 2)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Doc Tabs/Bottom")),
				    TRUE);
  if (TAB_POSITION == 3)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Doc Tabs/Left")),
				    TRUE);
  if (TAB_POSITION == 4)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Doc Tabs/Right")),
				    TRUE);
  Menu = gtk_tearoff_menu_item_new (); 
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Settings/Scroll Bar")),
		    Menu);
  if (SCROLLBAR_POSITION == 1)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Scroll Bar/Left")),
				    TRUE);
  if (SCROLLBAR_POSITION == 2)
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
				    (gtk_item_factory_get_widget
				     (ItemFactory,
				      "<main>/Settings/Scroll Bar/Right")),
				    TRUE);
  Menu = gtk_tearoff_menu_item_new ();
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Languages")), Menu);
  Menu = gtk_tearoff_menu_item_new (); 
  gtk_menu_prepend (GTK_MENU(gtk_item_factory_get_widget
			     (ItemFactory, "<main>/Help")), Menu);
  Menu = gtk_item_factory_get_widget (ItemFactory, "<main>");
  AccelRC = g_strconcat (g_get_home_dir (), PATH_SEP_STRING, CONF_DIR,
                         PATH_SEP_STRING, "AccelRC", NULL);
  gtk_item_factory_parse_rc (AccelRC);
  g_free (AccelRC);
  init_recent_files ();
  init_languages_menu ();
  gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(Menu), GTK_SHADOW_NONE);
  return (Menu);
}