New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed missed manual duplicate modifier_type #147

Merged
merged 1 commit into from Mar 28, 2017

Conversation

Projects
None yet
3 participants
@EPashkin
Member

EPashkin commented Mar 27, 2017

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Mar 27, 2017

Member

@GuillaumeGomez Maybe also better move keys to it module and remove src/enums.rs?
Also it need fix in examples first

Member

EPashkin commented Mar 27, 2017

@GuillaumeGomez Maybe also better move keys to it module and remove src/enums.rs?
Also it need fix in examples first

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Mar 28, 2017

Member

I don't have strong opinion on this. If what you propose is better, then no problem. ;)

Member

GuillaumeGomez commented Mar 28, 2017

I don't have strong opinion on this. If what you propose is better, then no problem. ;)

@GuillaumeGomez GuillaumeGomez merged commit 9b5e839 into gtk-rs:master Mar 28, 2017

0 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details

@EPashkin EPashkin deleted the EPashkin:remove_manual_modified_type branch Mar 28, 2017

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Mar 28, 2017

Member

@GuillaumeGomez I also not sure about need of move keys, so currently leave it in enums.

Member

EPashkin commented Mar 28, 2017

@GuillaumeGomez I also not sure about need of move keys, so currently leave it in enums.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Mar 28, 2017

Member

Fine by me.

Member

GuillaumeGomez commented Mar 28, 2017

Fine by me.

@cars10

This comment has been minimized.

Show comment
Hide comment
@cars10

cars10 May 18, 2017

What is the proposed way of migrating with this change? I was using this enum to check for ctrl key:

        if key.as_ref().state.intersects(gdk::enums::modifier_type::ControlMask) &&
            key.as_ref().keyval == 113 {
            gtk::main_quit();
        }

cars10 commented on c1fba76 May 18, 2017

What is the proposed way of migrating with this change? I was using this enum to check for ctrl key:

        if key.as_ref().state.intersects(gdk::enums::modifier_type::ControlMask) &&
            key.as_ref().keyval == 113 {
            gtk::main_quit();
        }

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin May 18, 2017

Member

Can't check it now but something like gdk::CONTROL_MASK or gdk::auto::flags::CONTROL_MASK

Member

EPashkin replied May 18, 2017

Can't check it now but something like gdk::CONTROL_MASK or gdk::auto::flags::CONTROL_MASK

This comment has been minimized.

Show comment
Hide comment
@cars10

cars10 May 18, 2017

Mh, this wont work. GdkModifierType#intersects expects an GdkModifierType as argument, the CONTORL_MASK you mentions is only an integer.

see http://gtk-rs.org/docs/gdk_sys/struct.GdkModifierType.html#method.intersects

cars10 replied May 18, 2017

Mh, this wont work. GdkModifierType#intersects expects an GdkModifierType as argument, the CONTORL_MASK you mentions is only an integer.

see http://gtk-rs.org/docs/gdk_sys/struct.GdkModifierType.html#method.intersects

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin May 18, 2017

Member

Strange it must be not integer https://github.com/gtk-rs/gdk/blob/master/src/auto/flags.rs#L184-L219
Maybe you also need use to_glib()

Member

EPashkin replied May 18, 2017

Strange it must be not integer https://github.com/gtk-rs/gdk/blob/master/src/auto/flags.rs#L184-L219
Maybe you also need use to_glib()

This comment has been minimized.

Show comment
Hide comment
@cars10

cars10 May 18, 2017

Ah, forget the integer. I was just skimming through the code and thought its an integer because i saw a number. Playing around now i actually found gdk::CONTROL_MASK to propably do what i want, but i am still getting errors because of the wrong type:

        if key.as_ref().state.intersects(gdk::CONTROL_MASK) &&
            key.as_ref().keyval == 113 {
            gtk::main_quit();
        }
expected struct `gdk_sys::GdkModifierType`, found struct `gdk::ModifierType`

cars10 replied May 18, 2017

Ah, forget the integer. I was just skimming through the code and thought its an integer because i saw a number. Playing around now i actually found gdk::CONTROL_MASK to propably do what i want, but i am still getting errors because of the wrong type:

        if key.as_ref().state.intersects(gdk::CONTROL_MASK) &&
            key.as_ref().keyval == 113 {
            gtk::main_quit();
        }
expected struct `gdk_sys::GdkModifierType`, found struct `gdk::ModifierType`

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin May 18, 2017

Member

Then sure .to_glib()

Member

EPashkin replied May 18, 2017

Then sure .to_glib()

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin May 18, 2017

Member

key don't have function, returning gdk::ModifierType?

Member

EPashkin replied May 18, 2017

key don't have function, returning gdk::ModifierType?

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin May 18, 2017

Member

Seems have https://github.com/gtk-rs/gdk/blob/master/src/event_key.rs#L18, then you can use intersects directly

Member

EPashkin replied May 18, 2017

Seems have https://github.com/gtk-rs/gdk/blob/master/src/event_key.rs#L18, then you can use intersects directly

This comment has been minimized.

Show comment
Hide comment
@cars10

cars10 May 18, 2017

Thanks! It's working now.

Complete example:

// somewhere:
extern crate glib;
use glib::translate::ToGlib;

// then to quit on CTRL+Q:
window.connect_key_press_event(|_, key| {
    if key.as_ref().state.intersects(gdk::CONTROL_MASK.to_glib()) &&
        key.as_ref().keyval == 113 {
        gtk::main_quit();
    }

    Inhibit(false)
});

cars10 replied May 18, 2017

Thanks! It's working now.

Complete example:

// somewhere:
extern crate glib;
use glib::translate::ToGlib;

// then to quit on CTRL+Q:
window.connect_key_press_event(|_, key| {
    if key.as_ref().state.intersects(gdk::CONTROL_MASK.to_glib()) &&
        key.as_ref().keyval == 113 {
        gtk::main_quit();
    }

    Inhibit(false)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment