Skip to content

Use https for all links #178

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

Merged
merged 1 commit into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The gtk-rs.org site

The site is hosted on [GitHub Pages](https://pages.github.com/) powered by
[Jekyll](http://jekyllrb.com/).
[Jekyll](https://jekyllrb.com/).

When authoring any changes you can try them out locally by running (requires ruby):

Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Gtk-rs
description: > # this means to ignore newlines until "baseurl:"
Rust bindings for GTK+ and GLib-based libraries
baseurl: "" # the subpath of your site, e.g. /blog/
url: "http://gtk-rs.org" # the base hostname & protocol for your site
url: "https://gtk-rs.org" # the base hostname & protocol for your site
github_username: gtk-rs
permalink: /blog/:year/:month/:day/:title.html
authors:
Expand Down
2 changes: 1 addition & 1 deletion _posts/2015-11-28-safety-first.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ marked accordingly and need someone to pick them up.
We've realized that we can't take the documentation from an LGPL licensed
library and just slip it into an MIT-licensed one. Consequently we had to move
almost all doc comments into a [separate repo][doc-comments]. We will keep
maintaining [online documentation](http://gtk-rs.org/docs-src/) and
maintaining [online documentation](https://gtk-rs.org/docs-src/) and
**@GuillaumeGomez** is working on a tool, that will allow to put the doc
comments back locally.

Expand Down
4 changes: 2 additions & 2 deletions _posts/2017-03-04-new-crates-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Now, instead of having to write:
```rust
let about_dialog = AboutDialog::new();

about_dialog.set_website(Some("http://gtk-rs.org/blog/"));
about_dialog.set_website(Some("https://gtk-rs.org/blog/"));
about_dialog.set_website(None);
```

Expand All @@ -25,7 +25,7 @@ You can write:
```rust
let about_dialog = AboutDialog::new();

about_dialog.set_website("http://gtk-rs.org/blog/"); // `Some` isn't need anymore
about_dialog.set_website("https://gtk-rs.org/blog/"); // `Some` isn't need anymore
about_dialog.set_website(None);
```

Expand Down
4 changes: 2 additions & 2 deletions docs-src/tutorial/cross.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The mingw packages are in the AUR, you can either install manually or use a help

If you can't find gtk precompiled dll, you can follow these steps:

1. Download the 64 bit version of the latest precompiled gtk libraries from [here](http://win32builder.gnome.org/).
1. Download the 64 bit version of the latest precompiled gtk libraries from [here](https://win32builder.gnome.org/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, this link is dead. ping @sdroege

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some old packages in the WebArchive:
https://web.archive.org/web/20180719181100/http://win32builder.gnome.org/
I assume there is a newer way for windows users?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, this link is dead. ping @sdroege

I don't know, what's that? For cross-compiling, Arch has this and Fedora also has packages. Ubuntu/Debian don't IIRC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it is for corss-building windows applications

2. Unzip it in a folder. For example, to install it in `/opt/gtkwin`: `mkdir /opt/gtkwin;unzip <file.zip> -d /opt/gtkwin`.
3. You have to set-up the library to match the installation folder:

Expand Down Expand Up @@ -151,7 +151,7 @@ edit /wherever/release/share/gtk-3.0/settings.ini
gtk-font-name = Segoe UI 10
gtk-xft-rgba = rgb

then download the windows 10 them from http://b00merang.weebly.com/windows-10.html.
then download the windows 10 them from [https://b00merang.weebly.com/windows-10.html](https://b00merang.weebly.com/windows-10.html).

unzip Windows-10-master.zip
mv Windows-10-master /wherever/release/share/themes/Windows10
Expand Down
6 changes: 3 additions & 3 deletions docs-src/tutorial/glade.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ There isn't much to explain in here. If you don't know how to use [Glade](https:
</interface>
```

So in this file, we created a [`Window`](http://gtk-rs.org/docs/gtk/struct.Window.html) containing a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html), as simple as that. It also created a [`MessageDialog`](http://gtk-rs.org/docs/gtk/struct.MessageDialog.html) containing a message and a [`Label`](http://gtk-rs.org/docs/gtk/struct.Label.html). Like I said, quite simple.
So in this file, we created a [`Window`](https://gtk-rs.org/docs/gtk/struct.Window.html) containing a [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html), as simple as that. It also created a [`MessageDialog`](https://gtk-rs.org/docs/gtk/struct.MessageDialog.html) containing a message and a [`Label`](https://gtk-rs.org/docs/gtk/struct.Label.html). Like I said, quite simple.

Now let's see how you can use this in your Rust code:

Expand All @@ -86,15 +86,15 @@ let builder = gtk::Builder::new_from_string(glade_src);
gtk::main();
```

Simple isn't it? However, just this code won't show anything. You need to call [`show_all`](http://gtk-rs.org/docs/gtk/trait.WidgetExt.html#tymethod.show_all) method on the [`Window`](http://gtk-rs.org/docs/gtk/struct.Window.html). But for that, you need to get the [`Window`](http://gtk-rs.org/docs/gtk/struct.Window.html) first:
Simple isn't it? However, just this code won't show anything. You need to call [`show_all`](https://gtk-rs.org/docs/gtk/trait.WidgetExt.html#tymethod.show_all) method on the [`Window`](https://gtk-rs.org/docs/gtk/struct.Window.html). But for that, you need to get the [`Window`](https://gtk-rs.org/docs/gtk/struct.Window.html) first:

```rust
// Our window id is "window1".
let window: gtk::Window = builder.get_object("window1").unwrap();
window.show_all();
```

And that's all. If you need to add signal handlings, you need to do the same. For example, we want to show the [`MessageDialog`](http://gtk-rs.org/docs/gtk/struct.MessageDialog.html) when the [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) is clicked. Let's add it:
And that's all. If you need to add signal handlings, you need to do the same. For example, we want to show the [`MessageDialog`](https://gtk-rs.org/docs/gtk/struct.MessageDialog.html) when the [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) is clicked. Let's add it:

```rust
let button: gtk::Button = builder.get_object("button1").unwrap();
Expand Down
8 changes: 4 additions & 4 deletions docs-src/tutorial/gnome_and_rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ The goal is to provide a safe abstraction using Rust paradigms.

First thing to note (it's very important!) is that the `Gtk-rs` objects can be cloned and it costs **nothing** more than copying a pointer, so basically nothing. The reason is quite simple (and I suppose you already guessed it): it's simply because `Gtk-rs` structs only contains a pointer to the corresponding `Gnome` objects.

Now: why is cloning safe? One thing to note before going any further: it's not thread safe (and you shouldn't try to call a `Gnome` library function inside another thread). Otherwise, when a struct is dropped, it calls internally the [`g_object_unref`](http://gtk-rs.org/docs/gobject_sys/fn.g_object_unref.html) function and calls the [`g_object_ref`](http://gtk-rs.org/docs/gobject_sys/fn.g_object_ref.html) function when you call `clone()`.
Now: why is cloning safe? One thing to note before going any further: it's not thread safe (and you shouldn't try to call a `Gnome` library function inside another thread). Otherwise, when a struct is dropped, it calls internally the [`g_object_unref`](https://gtk-rs.org/docs/gobject_sys/fn.g_object_unref.html) function and calls the [`g_object_ref`](https://gtk-rs.org/docs/gobject_sys/fn.g_object_ref.html) function when you call `clone()`.

To put it simply: `Gnome` handles the resources allocation/removal for us.

## Trait hierarchy

In Gtk, there is a widget hierarchy. In Rust, it's implemented through "traits inheritance" and enforced by the compiler at compile-time. So, what does that mean exactly? Let's take an example:

You have a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html). As says the [gnome documentation](https://developer.gnome.org/gtk3/stable/GtkButton.html), a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) inheritance tree (a bit simplified) looks like this:
You have a [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html). As says the [gnome documentation](https://developer.gnome.org/gtk3/stable/GtkButton.html), a [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) inheritance tree (a bit simplified) looks like this:

```
GObject
Expand All @@ -38,7 +38,7 @@ You have a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html). As says th
╰── GtkButton
```

Which means that a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) can use methods from any of its parents.
Which means that a [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) can use methods from any of its parents.

So basically, you just need to import a parent's trait to be able to use its methods:

Expand All @@ -57,7 +57,7 @@ As easy as that!

## Interfaces

The same goes for interfaces. The [gnome documentation](https://developer.gnome.org/gtk3/stable/GtkButton.html) also says that a [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) implements the following interfaces: `GtkBuildable`, `GtkActionable` and `GtkActivatable`. Just like parents' methods, import the corresponding interface and then you'll be able to use the methods.
The same goes for interfaces. The [gnome documentation](https://developer.gnome.org/gtk3/stable/GtkButton.html) also says that a [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) implements the following interfaces: `GtkBuildable`, `GtkActionable` and `GtkActivatable`. Just like parents' methods, import the corresponding interface and then you'll be able to use the methods.

I think that with this, you'll be able to write anything you want without too much difficulties. Now it's time to go deeper into `Gtk-rs` usage!

Expand Down
14 changes: 7 additions & 7 deletions docs-src/tutorial/object_oriented.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ layout: default

Since there is an inheritance system in Gtk, it's only logical to have one as well in `Gtk-rs`. Normally, most people won't need this, but understanding how things work can help navigating the documentation a lot.

Each GTK class is split into a struct named after that class, and a trait with the same name and the suffix `Ext`, see for example [WidgetExt](http://gtk-rs.org/docs/gtk/prelude/trait.WidgetExt.html). All methods except the constructor(s) are not in the struct, but in that trait. In addition, some other methods can be found in a `…ExtManual` trait, as seen in [WidgetExtManual](http://gtk-rs.org/docs/gtk/prelude/trait.WidgetExtManual.html). This happens for implementation reasons currently. The same principle applies to GTK interfaces as well (have a look at the [Orientable](http://gtk-rs.org/docs/gtk/struct.Orientable.html) interface for an example). There are a few exceptional classes that don't follow this general pattern: one reason for this is that final classes don't need an extension trait because there can't be any subclasses of them, and thus can have their methods defined on the struct itself.
Each GTK class is split into a struct named after that class, and a trait with the same name and the suffix `Ext`, see for example [WidgetExt](https://gtk-rs.org/docs/gtk/prelude/trait.WidgetExt.html). All methods except the constructor(s) are not in the struct, but in that trait. In addition, some other methods can be found in a `…ExtManual` trait, as seen in [WidgetExtManual](https://gtk-rs.org/docs/gtk/prelude/trait.WidgetExtManual.html). This happens for implementation reasons currently. The same principle applies to GTK interfaces as well (have a look at the [Orientable](https://gtk-rs.org/docs/gtk/struct.Orientable.html) interface for an example). There are a few exceptional classes that don't follow this general pattern: one reason for this is that final classes don't need an extension trait because there can't be any subclasses of them, and thus can have their methods defined on the struct itself.

## Basic inheritance

Any struct not only implements its `Ext` trait, but also all traits of its super classes. That way you can call methods of super classes directly on a struct.

The [`IsA`](http://gtk-rs.org/docs/glib/object/trait.IsA.html) trait is used to model the subtype relation of classes between structs. Every struct implements `IsA<SuperClass>` for each of its parent classes (and its implemented interfaces). For example [FlowBox](http://gtk-rs.org/docs/gtk/struct.FlowBox.html) implements `IsA<Buildable>`, `IsA<Container>`, `IsA<Orientable>`, `IsA<Widget>`.
The [`IsA`](https://gtk-rs.org/docs/glib/object/trait.IsA.html) trait is used to model the subtype relation of classes between structs. Every struct implements `IsA<SuperClass>` for each of its parent classes (and its implemented interfaces). For example [FlowBox](https://gtk-rs.org/docs/gtk/struct.FlowBox.html) implements `IsA<Buildable>`, `IsA<Container>`, `IsA<Orientable>`, `IsA<Widget>`.

Passing classes as arguments is pretty straightforward. The only rule is that when accepting a class as function argument, take a generic `IsA<ClassThatIWant>` instead: [`fn add<P: IsA<Widget>>(&self, widget: &P)`](http://gtk-rs.org/docs/gtk/trait.ContainerExt.html#tymethod.add). Now the method can be not only called with structs of that type, but also with structs of any subtype (in this case, any Widget).
Passing classes as arguments is pretty straightforward. The only rule is that when accepting a class as function argument, take a generic `IsA<ClassThatIWant>` instead: [`fn add<P: IsA<Widget>>(&self, widget: &P)`](https://gtk-rs.org/docs/gtk/trait.ContainerExt.html#tymethod.add). Now the method can be not only called with structs of that type, but also with structs of any subtype (in this case, any Widget).

## Upcasting

Expand All @@ -25,7 +25,7 @@ let button = gtk::Button::with_label("Click me!");
let widget = button.upcast::<gtk::Widget>();
```

Since the [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) struct implements `IsA<Widget>`, we can upcast into a [`Widget`](http://gtk-rs.org/docs/gtk/struct.Widget.html). It's important to note that the [`IsA`](http://gtk-rs.org/docs/gtk/trait.IsA.html) trait is implemented on every widget for every of its parents, which, in here, allows to [`upcast`](http://gtk-rs.org/docs/gtk/trait.Cast.html#method.upcast) the [`Button`](http://gtk-rs.org/docs/gtk/struct.Button.html) into a [`Widget`](http://gtk-rs.org/docs/gtk/struct.Widget.html).
Since the [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) struct implements `IsA<Widget>`, we can upcast into a [`Widget`](https://gtk-rs.org/docs/gtk/struct.Widget.html). It's important to note that the [`IsA`](https://gtk-rs.org/docs/gtk/trait.IsA.html) trait is implemented on every widget for every of its parents, which, in here, allows to [`upcast`](https://gtk-rs.org/docs/gtk/trait.Cast.html#method.upcast) the [`Button`](https://gtk-rs.org/docs/gtk/struct.Button.html) into a [`Widget`](https://gtk-rs.org/docs/gtk/struct.Widget.html).

Let's see now a more global usage.

Expand All @@ -39,11 +39,11 @@ fn is_a_box<W: IsA<gtk::Object> + IsA<gtk::Widget> + Clone>(widget: &W) -> bool
}
```

Ok, so what's happening in there? First, you'll note the usage of the [`IsA`](http://gtk-rs.org/docs/gtk/trait.IsA.html) trait. The received `widget` needs to implement both `IsA<Widget>` and `IsA<Object>`.
Ok, so what's happening in there? First, you'll note the usage of the [`IsA`](https://gtk-rs.org/docs/gtk/trait.IsA.html) trait. The received `widget` needs to implement both `IsA<Widget>` and `IsA<Object>`.

We need the [`Object`](http://gtk-rs.org/docs/gtk/struct.Object.html) to be able to use the [`Cast`](http://gtk-rs.org/docs/gtk/trait.Cast.html) trait which contains both [`upcast`](http://gtk-rs.org/docs/gtk/trait.Cast.html#method.upcast) and [`downcast`](http://gtk-rs.org/docs/gtk/trait.Cast.html#method.downcast) methods (take a look to it for other methods as well).
We need the [`Object`](https://gtk-rs.org/docs/gtk/struct.Object.html) to be able to use the [`Cast`](https://gtk-rs.org/docs/gtk/trait.Cast.html) trait which contains both [`upcast`](https://gtk-rs.org/docs/gtk/trait.Cast.html#method.upcast) and [`downcast`](https://gtk-rs.org/docs/gtk/trait.Cast.html#method.downcast) methods (take a look to it for other methods as well).

We don't really need our widget to be a [`Widget`](http://gtk-rs.org/docs/gtk/struct.Widget.html), we just put it here to make things easier (so we can upcast into a [`Widget`](http://gtk-rs.org/docs/gtk/struct.Widget.html) without troubles).
We don't really need our widget to be a [`Widget`](https://gtk-rs.org/docs/gtk/struct.Widget.html), we just put it here to make things easier (so we can upcast into a [`Widget`](https://gtk-rs.org/docs/gtk/struct.Widget.html) without troubles).

So the point of this function is to upcast the widget to the highest widget type and then try downcasting it into the wanted object. We could make even more generic like this:

Expand Down
2 changes: 1 addition & 1 deletion docs-src/tutorial/rust_and_gtk.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ layout: default

Before going any further, if you don't know Rust at all, we recommend you to read the official [Rust Book](https://doc.rust-lang.org/book/).

Then we recommend you to learn a bit about [Cargo](http://doc.crates.io/index.html) and check the [GTK requirements](https://www.gtk.org/docs/installations/).
Then we recommend you to learn a bit about [Cargo](https://doc.crates.io/index.html) and check the [GTK requirements](https://www.gtk.org/docs/installations/).

All done? Perfect!

Expand Down
2 changes: 1 addition & 1 deletion docs-src/tutorial/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ By default, `Gtk-rs` only provides objects and functions for the Gtk 3.4 version

## Explanations

If you don't know how `Cargo` features work, I suggest you to take a look at its [documentation](http://doc.crates.io/specifying-dependencies.html#choosing-features) first.
If you don't know how `Cargo` features work, I suggest you to take a look at its [documentation](https://doc.crates.io/specifying-dependencies.html#choosing-features) first.

Now let's take a look at `Gtk-rs/gtk` crate features:

Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ layout: wide
[Rust]: https://www.rust-lang.org/
[GLib]: https://developer.gnome.org/glib/stable/
[GTK]: https://developer.gnome.org/gtk3/stable/
[Cairo]: http://cairographics.org/documentation/
[Cairo]: https://cairographics.org/documentation/
[GtkSourceView]: https://wiki.gnome.org/Projects/GtkSourceView

</div>
Expand Down