Exemplo n.º 1
0
bool EventManager::onKeyPress(GdkEventKey* ev, Gtk::Widget* widget)
{
	if (dynamic_cast<Gtk::Window*>(widget) != NULL)
	{
		Gtk::Window* window = static_cast<Gtk::Window*>(widget);

		// Pass the key event to the connected window and see if it can process it (returns TRUE)
		bool keyProcessed = gtk_window_propagate_key_event(window->gobj(), ev);

		// Get the focus widget, is it an editable widget?
		Gtk::Widget* focus = window->get_focus();
		bool isEditableWidget = dynamic_cast<Gtk::Editable*>(focus) != NULL || dynamic_cast<Gtk::TextView*>(focus) != NULL;

		// Never propagate keystrokes if editable widgets are focused
		if ((isEditableWidget && ev->keyval != GDK_Escape) || keyProcessed)
		{
			return keyProcessed;
		}
	}

	// Try to find a matching accelerator
	AcceleratorList accelList = findAccelerator(ev);

	if (!accelList.empty())
	{
		// Release any modifiers
		_modifiers.setState(0);

		// Fake a "non-modifier" event to the MouseEvents class
		GdkEventKey eventKey = *ev;
		eventKey.state &= ~(GDK_MOD1_MASK|GDK_SHIFT_MASK|GDK_CONTROL_MASK);
		_mouseEvents.updateStatusText(&eventKey);

		// Pass the execute() call to all found accelerators
		for (AcceleratorList::iterator i = accelList.begin(); i != accelList.end(); ++i)
		{
			i->keyDown();
		}

		return true;
	}

	_modifiers.updateState(ev, true);

	updateStatusText(ev, true);

	return false;
}
Exemplo n.º 2
0
Gobby::Browser::Browser(Gtk::Window& parent,
                        StatusBar& status_bar,
                        ConnectionManager& connection_manager):
	m_parent(parent),
	m_status_bar(status_bar),
	m_connection_manager(connection_manager),

	m_expander(_("_Direct Connection"), true),
	m_hbox(false, 6),
	m_label_hostname(_("Host Name:")),
	m_entry_hostname(config_filename("recent_hosts"), 5)
{
	m_label_hostname.show();
	m_entry_hostname.get_entry()->signal_activate().connect(
		sigc::mem_fun(*this, &Browser::on_hostname_activate));
	m_entry_hostname.show();

	m_hbox.pack_start(m_label_hostname, Gtk::PACK_SHRINK);
	m_hbox.pack_start(m_entry_hostname, Gtk::PACK_EXPAND_WIDGET);
	m_hbox.show();

	m_expander.add(m_hbox);
	m_expander.show();
	m_expander.property_expanded().signal_changed().connect(
		sigc::mem_fun(*this, &Browser::on_expanded_changed));

	m_browser_store = inf_gtk_browser_store_new(
		connection_manager.get_io(),
		connection_manager.get_communication_manager());
	
	m_sort_model = inf_gtk_browser_model_sort_new(
		INF_GTK_BROWSER_MODEL(m_browser_store));
	gtk_tree_sortable_set_default_sort_func(
		GTK_TREE_SORTABLE(m_sort_model), compare_func, NULL, NULL);

	if(m_connection_manager.get_discovery() != NULL)
	{
		inf_gtk_browser_store_add_discovery(
			m_browser_store,
			m_connection_manager.get_discovery());
	}

	Glib::ustring known_hosts_file = config_filename("known_hosts");

	m_cert_checker = inf_gtk_certificate_manager_new(
		parent.gobj(), m_connection_manager.get_xmpp_manager(),
		known_hosts_file.c_str());

	m_browser_view =
		INF_GTK_BROWSER_VIEW(
			inf_gtk_browser_view_new_with_model(
				INF_GTK_BROWSER_MODEL(m_sort_model)));

	gtk_widget_show(GTK_WIDGET(m_browser_view));
	gtk_container_add(GTK_CONTAINER(m_scroll.gobj()),
	                  GTK_WIDGET(m_browser_view));
	m_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	m_scroll.set_shadow_type(Gtk::SHADOW_IN);
	m_scroll.show();

	g_signal_connect(
		m_browser_store,
		"set-browser",
		G_CALLBACK(&on_set_browser_static),
		this
	);

	g_signal_connect(
		m_browser_view,
		"activate",
		G_CALLBACK(&on_activate_static),
		this
	);

	set_spacing(6);
	pack_start(m_scroll, Gtk::PACK_EXPAND_WIDGET);
	pack_start(m_expander, Gtk::PACK_SHRINK);

	init_accessibility();

	set_focus_child(m_expander);
}
Exemplo n.º 3
0
Gtk::PrintOperationResult Print::run(Gtk::PrintOperationAction, Gtk::Window &parent_window)
{
    gtk_print_operation_run (_printop, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
	    parent_window.gobj(), NULL);
    return Gtk::PRINT_OPERATION_RESULT_APPLY;
}