Skip to content

Commit

Permalink
feat: do not use 'using'
Browse files Browse the repository at this point in the history
assuming the namespace is difficult for newcomers as one needs to have experience not only in all the namespaces but also the entire codebase
  • Loading branch information
GeopJr committed Aug 10, 2023
1 parent 99f1ab3 commit e3af37f
Show file tree
Hide file tree
Showing 60 changed files with 314 additions and 459 deletions.
6 changes: 2 additions & 4 deletions src/API/Entity.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Json;

public class Tuba.Entity : GLib.Object, Widgetizable, Json.Serializable {

public virtual bool is_local (InstanceAccount account) {
Expand Down Expand Up @@ -164,7 +162,7 @@ public class Tuba.Entity : GLib.Object, Widgetizable, Json.Serializable {
static Json.Node ser_list (string prop, Value val, ParamSpec spec) {
var list = (Gee.ArrayList<Entity>) val;
if (list == null)
return new Json.Node (NodeType.NULL);
return new Json.Node (Json.NodeType.NULL);

var arr = new Json.Array ();
list.@foreach (e => {
Expand All @@ -173,7 +171,7 @@ public class Tuba.Entity : GLib.Object, Widgetizable, Json.Serializable {
return true;
});

var node = new Json.Node (NodeType.ARRAY);
var node = new Json.Node (Json.NodeType.ARRAY);
node.set_array (arr);
return node;
}
Expand Down
3 changes: 0 additions & 3 deletions src/API/List.vala
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Gtk;

public class Tuba.API.List : Entity, Widgetizable {

public string id { get; set; }
public string title { get; set; }
public string? replies_policy { get; set; default = null; }
Expand Down
11 changes: 4 additions & 7 deletions src/API/Poll.vala
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using Gee;
using Json;

public class Tuba.API.Poll : GLib.Object, Json.Serializable {
public string id { get; set; }
public string expires_at { get; set; }
public bool expired { get; set; }
public bool multiple { get; set; }
public int64 votes_count { get; set; }
public bool voted { get; set; default = true;}
public ArrayList<int> own_votes { get; set; }
public ArrayList<PollOption>? options { get; set; default = null; }
public Gee.ArrayList<int> own_votes { get; set; }
public Gee.ArrayList<PollOption>? options { get; set; default = null; }

public Poll (string _id) {
id = _id;
Expand Down Expand Up @@ -49,8 +46,8 @@ public class Tuba.API.Poll : GLib.Object, Json.Serializable {
}
public static Request vote (
InstanceAccount acc,
ArrayList<PollOption> options,
ArrayList<string> selection,
Gee.ArrayList<PollOption> options,
Gee.ArrayList<string> selection,
string id
) {
message (@"Voting poll $(id)");
Expand Down
8 changes: 3 additions & 5 deletions src/API/SearchResults.vala
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Gee;

public class Tuba.API.SearchResults : Entity {

public ArrayList<API.Account> accounts { get; set; }
public ArrayList<API.Status> statuses { get; set; }
public ArrayList<API.Tag> hashtags { get; set; }
public Gee.ArrayList<API.Account> accounts { get; set; }
public Gee.ArrayList<API.Status> statuses { get; set; }
public Gee.ArrayList<API.Tag> hashtags { get; set; }

public static SearchResults from (Json.Node node) throws Error {
return Entity.from_json (typeof (SearchResults), node) as SearchResults;
Expand Down
12 changes: 5 additions & 7 deletions src/API/Status.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gee;

public class Tuba.API.Status : Entity, Widgetizable {

~Status () {
Expand Down Expand Up @@ -29,11 +27,11 @@ public class Tuba.API.Status : Entity, Widgetizable {
public API.Status? reblog { get; set; default = null; }
public API.Status? quote { get; set; default = null; }
// public API.Akkoma? akkoma { get; set; default = null; }
public ArrayList<API.Mention>? mentions { get; set; default = null; }
public ArrayList<API.EmojiReaction>? reactions { get; set; default = null; }
public ArrayList<API.EmojiReaction>? emoji_reactions { get; set; default = null; }
public Gee.ArrayList<API.Mention>? mentions { get; set; default = null; }
public Gee.ArrayList<API.EmojiReaction>? reactions { get; set; default = null; }
public Gee.ArrayList<API.EmojiReaction>? emoji_reactions { get; set; default = null; }
public API.Pleroma.Status? pleroma { get; set; default = null; }
public ArrayList<API.Attachment>? media_attachments { get; set; default = null; }
public Gee.ArrayList<API.Attachment>? media_attachments { get; set; default = null; }
public API.Poll? poll { get; set; default = null; }
public Gee.ArrayList<API.Emoji>? emojis { get; set; }
public API.PreviewCard? card { get; set; default = null; }
Expand Down Expand Up @@ -76,7 +74,7 @@ public class Tuba.API.Status : Entity, Widgetizable {
return res;
}

public ArrayList<API.EmojiReaction>? compat_status_reactions {
public Gee.ArrayList<API.EmojiReaction>? compat_status_reactions {
get {
if (emoji_reactions != null) {
return emoji_reactions;
Expand Down
4 changes: 1 addition & 3 deletions src/API/Tag.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public class Tuba.API.Tag : Entity, Widgetizable {

public string name { get; set; }
Expand Down Expand Up @@ -35,7 +33,7 @@ public class Tuba.API.Tag : Entity, Widgetizable {
return _("%d per week").printf (used_times);
}

public override Widget to_widget () {
public override Gtk.Widget to_widget () {
var w = new Adw.ActionRow () {
title = @"#$name",
activatable = true
Expand Down
4 changes: 1 addition & 3 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

namespace Tuba {
public errordomain Oopsie {
USER,
Expand Down Expand Up @@ -293,7 +291,7 @@ namespace Tuba {
application_name = Build.NAME,
version = Build.VERSION,
support_url = Build.SUPPORT_WEBSITE,
license_type = License.GPL_3_0_ONLY,
license_type = Gtk.License.GPL_3_0_ONLY,
copyright = COPYRIGHT,
developers = DEVELOPERS,
artists = ARTISTS,
Expand Down
26 changes: 12 additions & 14 deletions src/Dialogs/Composer/AttachmentsPage.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public class Tuba.AttachmentsPage : ComposerPage {
~AttachmentsPage () {
context_menu.unparent ();
Expand Down Expand Up @@ -36,7 +34,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
public GLib.ListStore attachments;
public Adw.ToastOverlay toast_overlay;
public bool media_sensitive { get; set; default = false; }
private FileFilter filter = new FileFilter () {
private Gtk.FileFilter filter = new Gtk.FileFilter () {
name = _("All Supported Files")
};
private Gee.ArrayList<string> supported_mimes = new Gee.ArrayList<string>.wrap (SUPPORTED_MIMES);
Expand All @@ -52,7 +50,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
}
}

protected PopoverMenu context_menu { get; set; }
protected Gtk.PopoverMenu context_menu { get; set; }
private const GLib.ActionEntry[] ACTION_ENTRIES = {
{"paste-from-clipboard", on_clipboard_paste}
};
Expand All @@ -77,7 +75,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
var menu_model = new GLib.Menu ();
menu_model.append (_("Paste"), "attachmentspage.paste-from-clipboard");

context_menu = new PopoverMenu.from_model (menu_model);
context_menu = new Gtk.PopoverMenu.from_model (menu_model);
context_menu.set_parent (this);

var dnd_controller = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY);
Expand Down Expand Up @@ -105,13 +103,13 @@ public class Tuba.AttachmentsPage : ComposerPage {
private void on_click (int n_press, double x, double y) {
if (!show_context_menu (x, y)) return;

click_controller.set_state (EventSequenceState.CLAIMED);
click_controller.set_state (Gtk.EventSequenceState.CLAIMED);
}

private void on_long_press (double x, double y) {
if (!show_context_menu (x, y)) return;

long_press_controller.set_state (EventSequenceState.CLAIMED);
long_press_controller.set_state (Gtk.EventSequenceState.CLAIMED);
}

private bool show_context_menu (double x, double y) {
Expand Down Expand Up @@ -207,7 +205,7 @@ public class Tuba.AttachmentsPage : ComposerPage {

protected Adw.ViewStack stack;
protected Adw.StatusPage empty_state;
protected ListBox list;
protected Gtk.ListBox list;
protected Gtk.Button add_media_action_button;

public override void dispose () {
Expand All @@ -219,8 +217,8 @@ public class Tuba.AttachmentsPage : ComposerPage {
public override void on_build () {
base.on_build ();

var attach_button = new Button.with_label (_("Add Media")) {
halign = Align.CENTER,
var attach_button = new Gtk.Button.with_label (_("Add Media")) {
halign = Gtk.Align.CENTER,
sensitive = accounts.active.instance_info.compat_status_max_media_attachments > 0,
// Empty state
css_classes = { "pill" }
Expand All @@ -236,8 +234,8 @@ public class Tuba.AttachmentsPage : ComposerPage {
};

// Non-empty state
list = new ListBox () {
selection_mode = SelectionMode.NONE
list = new Gtk.ListBox () {
selection_mode = Gtk.SelectionMode.NONE
};
list.bind_model (attachments, on_create_list_item);

Expand Down Expand Up @@ -312,7 +310,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
on_attachments_changed ();
}

Widget on_create_list_item (Object item) {
Gtk.Widget on_create_list_item (Object item) {
var attachment = item as API.Attachment;
var attachment_widget = new AttachmentsPageAttachment (
attachment.id,
Expand Down Expand Up @@ -368,7 +366,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
}

void show_file_selector () {
var chooser = new FileDialog () {
var chooser = new Gtk.FileDialog () {
// translators: Open file
title = _("Open"),
modal = true,
Expand Down
8 changes: 3 additions & 5 deletions src/Dialogs/Composer/Completion/CompletionProvider.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvider {

public static GLib.ListStore EMPTY = new GLib.ListStore (typeof (Object)); // vala-lint=naming-convention
Expand Down Expand Up @@ -35,8 +33,8 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi
}

public virtual void activate (GtkSource.CompletionContext context, GtkSource.CompletionProposal proposal) {
TextIter start;
TextIter end;
Gtk.TextIter start;
Gtk.TextIter end;
context.get_bounds (out start, out end);

var buffer = start.get_buffer ();
Expand All @@ -58,7 +56,7 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi
// If it's not capturing,
// check if the character before the word
// is the trigger
TextIter start;
Gtk.TextIter start;
context.get_bounds (out start, null);
if (start.backward_char ())
is_trigger (start, start.get_char ());
Expand Down
2 changes: 0 additions & 2 deletions src/Dialogs/Composer/Completion/EmojiProvider.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public class Tuba.EmojiProvider: Tuba.CompletionProvider {

public EmojiProvider () {
Expand Down
2 changes: 0 additions & 2 deletions src/Dialogs/Composer/Completion/HandleProvider.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public class Tuba.HandleProvider: Tuba.CompletionProvider {

public HandleProvider () {
Expand Down
2 changes: 0 additions & 2 deletions src/Dialogs/Composer/Completion/HashtagProvider.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Gtk;

public class Tuba.HashtagProvider: Tuba.CompletionProvider {

public HashtagProvider () {
Expand Down
5 changes: 1 addition & 4 deletions src/Dialogs/Composer/Dialog.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Gtk;
using Gee;

[GtkTemplate (ui = "/dev/geopjr/Tuba/ui/dialogs/compose.ui")]
public class Tuba.Dialogs.Compose : Adw.Window {
public class BasicStatus : Object {
Expand Down Expand Up @@ -256,7 +253,7 @@ public class Tuba.Dialogs.Compose : Adw.Window {
}

[GtkChild] unowned Adw.ViewSwitcherTitle title_switcher;
[GtkChild] unowned Button commit_button;
[GtkChild] unowned Gtk.Button commit_button;

[GtkChild] unowned Adw.ViewStack stack;

Expand Down
Loading

0 comments on commit e3af37f

Please sign in to comment.