Skip to content

Instantly share code, notes, and snippets.

@SkyzohKey
Last active February 4, 2023 04:12
Show Gist options
  • Save SkyzohKey/2f784daf4b5c5a731408bd8b691f1dab to your computer and use it in GitHub Desktop.
Save SkyzohKey/2f784daf4b5c5a731408bd8b691f1dab to your computer and use it in GitHub Desktop.

Revisions

  1. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion demo.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ public void init_settings () {
    SettingsListBox settings = new SettingsListBox ();
    this.pack_start (settings, true, true, 0);
    listbox.new_section ("Police");
    settings.new_section ("Police");
    Gtk.FontButton button_font = new Gtk.FontButton ();
    settings.new_row (button_font,
  2. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions demo.md
    Original file line number Diff line number Diff line change
    @@ -8,41 +8,41 @@

    ```vala
    public void init_settings () {
    SettingsListBox listbox = new SettingsListBox ();
    this.pack_start (listbox, true, true, 0);
    SettingsListBox settings = new SettingsListBox ();
    this.pack_start (settings, true, true, 0);
    listbox.new_section ("Police");
    Gtk.FontButton button_font = new Gtk.FontButton ();
    listbox.new_row (button_font,
    settings.new_row (button_font,
    "Police de caractères",
    "Utiliser une police de caractères personalisée."
    );
    listbox.new_section ("Vue d'ensemble");
    settings.new_section ("Vue d'ensemble");
    Gtk.Switch switch_minimap = new Gtk.Switch ();
    listbox.new_row (switch_minimap,
    settings.new_row (switch_minimap,
    "Afficher la vue d'ensemble",
    "Affiche une vue d'ensemble à côté de l'éditeur de code source."
    );
    listbox.new_section ("Indentation");
    settings.new_section ("Indentation");
    Gtk.SpinButton button_indent = new Gtk.SpinButton.with_range (0, 8, 2);
    listbox.new_row (button_indent,
    settings.new_row (button_indent,
    "Largeur de tabulation",
    "Permet de définir la largeur d'une tabulation dans l'éditeur de code source."
    );
    Gtk.Switch switch_indent_space = new Gtk.Switch ();
    listbox.new_row (switch_indent_space,
    settings.new_row (switch_indent_space,
    "Insérer des espaces au lieu de tabulations",
    "Insére 4 espaces à la place d'une tabulation."
    );
    Gtk.Switch switch_auto_indent = new Gtk.Switch ();
    listbox.new_row (switch_auto_indent,
    settings.new_row (switch_auto_indent,
    "Activer l'indentation automatique",
    "Formate automatiquement le texte pour l'indenter."
    );
  3. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SettingsListBox.vala
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ public class SettingsListBox: Gtk.Box {
    return box;
    }

    public Gtk.Box new_row (Gtk.Widget widget, string name, string? help=null) {
    public Gtk.Box new_row (Gtk.Widget widget, string name, string? help = null) {
    Gtk.ListBoxRow row = new Gtk.ListBoxRow ();
    row.set_size_request (1, 50);
    this.listbox.add (row);
  4. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions SettingsListBox.vala
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ public class SettingsListBox: Gtk.Box {
    hbox.pack_start (this.scrolled_box, true, true, 0);
    }

    public void new_section (string name) {
    public Gtk.Box new_section (string name) {
    Gtk.Box box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
    this.scrolled_box.pack_start (box, false, false, 5);

    @@ -32,9 +32,11 @@ public class SettingsListBox: Gtk.Box {
    this.listbox = new Gtk.ListBox ();
    this.listbox.set_selection_mode (Gtk.SelectionMode.NONE);
    this.scrolled_box.pack_start (this.listbox, false, false, 0);

    return box;
    }

    public void new_row (Gtk.Widget widget, string name, string? help=null) {
    public Gtk.Box new_row (Gtk.Widget widget, string name, string? help=null) {
    Gtk.ListBoxRow row = new Gtk.ListBoxRow ();
    row.set_size_request (1, 50);
    this.listbox.add (row);
    @@ -62,5 +64,7 @@ public class SettingsListBox: Gtk.Box {
    vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
    vbox.set_center_widget (widget);
    box.pack_end (vbox, false, false, 0);

    return box;
    }
    }
  5. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions SettingsListBox.vala
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,7 @@ public class SettingsListBox: Gtk.Box {
    this.scrolled_box.pack_start (box, false, false, 5);

    Gtk.Label label = new Gtk.Label (null);
    label.set_line_wrap (true);
    label.set_markup (@"<b>$name</b>");
    label.set_margin_top (4);
    label.set_margin_start (6);
    @@ -46,6 +47,7 @@ public class SettingsListBox: Gtk.Box {
    box.pack_start (vbox, false, true, 0);

    Gtk.Label label = new Gtk.Label (name);
    label.set_line_wrap (true);
    label.set_xalign (0);
    vbox.pack_start (label, false, false, 0);

  6. SkyzohKey revised this gist Feb 15, 2017. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions demo.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    # SettingsListBox

    ### Screenshot

    ![SettingsListView](https://a.desu.sh/vmqtzr.png)

    ### Example

    ```vala
    @@ -43,8 +47,4 @@ public void init_settings () {
    "Formate automatiquement le texte pour l'indenter."
    );
    }
    ```

    ### Screenshot

    ![SettingsListView](https://a.desu.sh/vmqtzr.png)
    ```
  7. SkyzohKey revised this gist Feb 15, 2017. 2 changed files with 54 additions and 54 deletions.
    80 changes: 40 additions & 40 deletions SettingsListBox.vala
    Original file line number Diff line number Diff line change
    @@ -3,62 +3,62 @@ public class SettingsListBox: Gtk.Box {
    public Gtk.Box scrolled_box;
    public Gtk.ListBox listbox;

    public SettingsListBox() {
    this.set_orientation(Gtk.Orientation.HORIZONTAL);
    public SettingsListBox () {
    this.set_orientation (Gtk.Orientation.HORIZONTAL);

    Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow(null, null);
    scroll.set_size_request(400, 1);
    this.pack_start(scroll, true, true, 0);
    Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow (null, null);
    scroll.set_size_request (400, 1);
    this.pack_start (scroll, true, true, 0);

    Gtk.Box hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    scroll.add(hbox);
    Gtk.Box hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
    scroll.add (hbox);

    this.scrolled_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    this.scrolled_box.set_size_request(400, 1);
    this.scrolled_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
    this.scrolled_box.set_size_request (400, 1);
    hbox.pack_start (this.scrolled_box, true, true, 0);
    }

    public void new_section(string name) {
    Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    this.scrolled_box.pack_start(box, false, false, 5);
    public void new_section (string name) {
    Gtk.Box box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
    this.scrolled_box.pack_start (box, false, false, 5);

    Gtk.Label label = new Gtk.Label(null);
    label.set_markup(@"<b>$name</b>");
    label.set_margin_top(4);
    label.set_margin_start(6);
    box.pack_start(label, false, false, 2);
    Gtk.Label label = new Gtk.Label (null);
    label.set_markup (@"<b>$name</b>");
    label.set_margin_top (4);
    label.set_margin_start (6);
    box.pack_start (label, false, false, 2);

    this.listbox = new Gtk.ListBox();
    this.listbox.set_selection_mode(Gtk.SelectionMode.NONE);
    this.scrolled_box.pack_start(this.listbox, false, false, 0);
    this.listbox = new Gtk.ListBox ();
    this.listbox.set_selection_mode (Gtk.SelectionMode.NONE);
    this.scrolled_box.pack_start (this.listbox, false, false, 0);
    }

    public void new_row(Gtk.Widget widget, string name, string? help=null) {
    Gtk.ListBoxRow row = new Gtk.ListBoxRow();
    row.set_size_request(1, 50);
    this.listbox.add(row);
    public void new_row (Gtk.Widget widget, string name, string? help=null) {
    Gtk.ListBoxRow row = new Gtk.ListBoxRow ();
    row.set_size_request (1, 50);
    this.listbox.add (row);

    Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    box.set_border_width(5);
    row.add(box);
    Gtk.Box box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
    box.set_border_width (5);
    row.add (box);

    Gtk.Box vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    box.pack_start(vbox, false, true, 0);
    Gtk.Box vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
    box.pack_start (vbox, false, true, 0);

    Gtk.Label label = new Gtk.Label(name);
    label.set_xalign(0);
    vbox.pack_start(label, false, false, 0);
    Gtk.Label label = new Gtk.Label (name);
    label.set_xalign (0);
    vbox.pack_start (label, false, false, 0);

    if (help != null) {
    label = new Gtk.Label(null);
    label.set_xalign(0);
    label.set_sensitive(false);
    label.set_markup(@"<small>$help</small>");
    vbox.pack_start(label, false, false, 0);
    label = new Gtk.Label (null);
    label.set_xalign (0);
    label.set_sensitive (false);
    label.set_markup (@"<small>$help</small>");
    vbox.pack_start (label, false, false, 0);
    }

    vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    vbox.set_center_widget(widget);
    box.pack_end(vbox, false, false, 0);
    vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
    vbox.set_center_widget (widget);
    box.pack_end (vbox, false, false, 0);
    }
    }
    28 changes: 14 additions & 14 deletions demo.md
    Original file line number Diff line number Diff line change
    @@ -4,41 +4,41 @@

    ```vala
    public void init_settings () {
    SettingsListBox listbox = new SettingsListBox();
    SettingsListBox listbox = new SettingsListBox ();
    this.pack_start (listbox, true, true, 0);
    listbox.new_section("Police");
    listbox.new_section ("Police");
    Gtk.FontButton button_font = new Gtk.FontButton();
    listbox.new_row(button_font,
    Gtk.FontButton button_font = new Gtk.FontButton ();
    listbox.new_row (button_font,
    "Police de caractères",
    "Utiliser une police de caractères personalisée."
    );
    listbox.new_section("Vue d'ensemble");
    listbox.new_section ("Vue d'ensemble");
    Gtk.Switch switch_minimap = new Gtk.Switch();
    listbox.new_row(switch_minimap,
    Gtk.Switch switch_minimap = new Gtk.Switch ();
    listbox.new_row (switch_minimap,
    "Afficher la vue d'ensemble",
    "Affiche une vue d'ensemble à côté de l'éditeur de code source."
    );
    listbox.new_section("Indentation");
    listbox.new_section ("Indentation");
    Gtk.SpinButton button_indent = new Gtk.SpinButton.with_range(0, 8, 2);
    listbox.new_row(button_indent,
    Gtk.SpinButton button_indent = new Gtk.SpinButton.with_range (0, 8, 2);
    listbox.new_row (button_indent,
    "Largeur de tabulation",
    "Permet de définir la largeur d'une tabulation dans l'éditeur de code source."
    );
    Gtk.Switch switch_indent_space = new Gtk.Switch();
    listbox.new_row(switch_indent_space,
    Gtk.Switch switch_indent_space = new Gtk.Switch ();
    listbox.new_row (switch_indent_space,
    "Insérer des espaces au lieu de tabulations",
    "Insére 4 espaces à la place d'une tabulation."
    );
    Gtk.Switch switch_auto_indent = new Gtk.Switch();
    listbox.new_row(switch_auto_indent,
    Gtk.Switch switch_auto_indent = new Gtk.Switch ();
    listbox.new_row (switch_auto_indent,
    "Activer l'indentation automatique",
    "Formate automatiquement le texte pour l'indenter."
    );
  8. SkyzohKey created this gist Feb 15, 2017.
    64 changes: 64 additions & 0 deletions SettingsListBox.vala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    public class SettingsListBox: Gtk.Box {

    public Gtk.Box scrolled_box;
    public Gtk.ListBox listbox;

    public SettingsListBox() {
    this.set_orientation(Gtk.Orientation.HORIZONTAL);

    Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow(null, null);
    scroll.set_size_request(400, 1);
    this.pack_start(scroll, true, true, 0);

    Gtk.Box hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    scroll.add(hbox);

    this.scrolled_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    this.scrolled_box.set_size_request(400, 1);
    hbox.pack_start (this.scrolled_box, true, true, 0);
    }

    public void new_section(string name) {
    Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    this.scrolled_box.pack_start(box, false, false, 5);

    Gtk.Label label = new Gtk.Label(null);
    label.set_markup(@"<b>$name</b>");
    label.set_margin_top(4);
    label.set_margin_start(6);
    box.pack_start(label, false, false, 2);

    this.listbox = new Gtk.ListBox();
    this.listbox.set_selection_mode(Gtk.SelectionMode.NONE);
    this.scrolled_box.pack_start(this.listbox, false, false, 0);
    }

    public void new_row(Gtk.Widget widget, string name, string? help=null) {
    Gtk.ListBoxRow row = new Gtk.ListBoxRow();
    row.set_size_request(1, 50);
    this.listbox.add(row);

    Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
    box.set_border_width(5);
    row.add(box);

    Gtk.Box vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    box.pack_start(vbox, false, true, 0);

    Gtk.Label label = new Gtk.Label(name);
    label.set_xalign(0);
    vbox.pack_start(label, false, false, 0);

    if (help != null) {
    label = new Gtk.Label(null);
    label.set_xalign(0);
    label.set_sensitive(false);
    label.set_markup(@"<small>$help</small>");
    vbox.pack_start(label, false, false, 0);
    }

    vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
    vbox.set_center_widget(widget);
    box.pack_end(vbox, false, false, 0);
    }
    }
    50 changes: 50 additions & 0 deletions demo.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    # SettingsListBox

    ### Example

    ```vala
    public void init_settings () {
    SettingsListBox listbox = new SettingsListBox();
    this.pack_start (listbox, true, true, 0);
    listbox.new_section("Police");
    Gtk.FontButton button_font = new Gtk.FontButton();
    listbox.new_row(button_font,
    "Police de caractères",
    "Utiliser une police de caractères personalisée."
    );
    listbox.new_section("Vue d'ensemble");
    Gtk.Switch switch_minimap = new Gtk.Switch();
    listbox.new_row(switch_minimap,
    "Afficher la vue d'ensemble",
    "Affiche une vue d'ensemble à côté de l'éditeur de code source."
    );
    listbox.new_section("Indentation");
    Gtk.SpinButton button_indent = new Gtk.SpinButton.with_range(0, 8, 2);
    listbox.new_row(button_indent,
    "Largeur de tabulation",
    "Permet de définir la largeur d'une tabulation dans l'éditeur de code source."
    );
    Gtk.Switch switch_indent_space = new Gtk.Switch();
    listbox.new_row(switch_indent_space,
    "Insérer des espaces au lieu de tabulations",
    "Insére 4 espaces à la place d'une tabulation."
    );
    Gtk.Switch switch_auto_indent = new Gtk.Switch();
    listbox.new_row(switch_auto_indent,
    "Activer l'indentation automatique",
    "Formate automatiquement le texte pour l'indenter."
    );
    }
    ```

    ### Screenshot

    ![SettingsListView](https://a.desu.sh/vmqtzr.png)