diff --git a/BasicHTMLParser.java b/BasicHTMLParser.java old mode 100755 new mode 100644 diff --git a/ClipboardApi.java b/ClipboardApi.java old mode 100755 new mode 100644 diff --git a/ComposeWindow.java b/ComposeWindow.java old mode 100755 new mode 100644 index 71368da..2f920c0 --- a/ComposeWindow.java +++ b/ComposeWindow.java @@ -19,6 +19,8 @@ import java.awt.event.KeyListener; import java.awt.event.KeyEvent; import java.awt.Cursor; import java.awt.Color; +import java.awt.Font; +import java.awt.Insets; import javax.swing.event.CaretListener; import javax.swing.event.CaretEvent; @@ -40,7 +42,10 @@ ComposeWindow extends JFrame { composition; private ComposeComponent - display; + contentsDisplay; + + private AttachmentsComponent + attachmentsDisplay; // ---%-@-%--- @@ -73,7 +78,7 @@ ComposeWindow extends JFrame { if (composition.contentWarning != null) assert !composition.contentWarning.trim().isEmpty(); - display.setSubmitting(true); + contentsDisplay.setSubmitting(true); api.submit( composition.text, composition.visibility, composition.replyToPostId, composition.contentWarning, @@ -108,7 +113,21 @@ ComposeWindow extends JFrame { } ); - display.setSubmitting(false); + contentsDisplay.setSubmitting(false); + } + + public void + showContentsPage() + { + setContentPane(contentsDisplay); + revalidate(); + } + + public void + showAttachmentsPage() + { + setContentPane(attachmentsDisplay); + revalidate(); } // - -%- - @@ -116,22 +135,22 @@ ComposeWindow extends JFrame { private synchronized void syncDisplayToComposition() { - display.setText(composition.text); - display.setReplyToPostId(composition.replyToPostId); - display.setVisibility(stringFor(composition.visibility)); - display.setContentWarning(composition.contentWarning); + ComposeComponent d = contentsDisplay; + d.setText(composition.text); + d.setReplyToPostId(composition.replyToPostId); + d.setVisibility(stringFor(composition.visibility)); + d.setContentWarning(composition.contentWarning); } private synchronized void syncCompositionToDisplay() { - composition.text = display.getText(); - composition.visibility = - visibilityFrom(display.getVisibility()); - composition.replyToPostId = - nonEmpty(display.getReplyToPostId()); - composition.contentWarning = - nonEmpty(display.getContentWarning()); + ComposeComponent d = contentsDisplay; + Composition c = composition; + c.text = d.getText(); + c.visibility = visibilityFrom(d.getVisibility()); + c.replyToPostId = nonEmpty(d.getReplyToPostId()); + c.contentWarning = nonEmpty(d.getContentWarning()); } // - -%- - @@ -151,14 +170,17 @@ ComposeWindow extends JFrame { this.primaire = primaire; this.api = primaire.getMastodonApi(); - getContentPane().setPreferredSize(new Dimension(360, 270)); + final Dimension SZ = new Dimension(360, 270); + + getContentPane().setPreferredSize(SZ); pack(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); - display = new ComposeComponent(this); + contentsDisplay = new ComposeComponent(this); + attachmentsDisplay = new AttachmentsComponent(this); newComposition(); - setContentPane(display); + showContentsPage(); setIconImage(primaire.getProgramIcon()); } @@ -221,6 +243,9 @@ implements ActionListener, CaretListener, KeyListener { private JButton submit; + private JButton + showAttachmentsPage; + // ---%-@-%--- public void @@ -300,7 +325,14 @@ implements ActionListener, CaretListener, KeyListener { // - -%- - public void - actionPerformed(ActionEvent eA) { primaire.submit(); } + actionPerformed(ActionEvent eA) + { + if (eA.getSource() == showAttachmentsPage) + primaire.showAttachmentsPage(); + + if (eA.getSource() == submit) + primaire.submit(); + } public void caretUpdate(CaretEvent eCa) { updateTextLength(); } @@ -375,12 +407,16 @@ implements ActionListener, CaretListener, KeyListener { "Mentioned" // Where should we be saving strings.. }); - visibility.setPreferredSize(new Dimension(64, 24)); + visibility.setPreferredSize(new Dimension(48, 24)); submit = new JButton("Submit"); submit.addActionListener(this); + showAttachmentsPage = new JButton("Media"); + showAttachmentsPage.addActionListener(this); + Box bottom = Box.createHorizontalBox(); + bottom.add(showAttachmentsPage); bottom.add(Box.createGlue()); bottom.add(textLength); bottom.add(Box.createHorizontalStrut(12)); @@ -405,3 +441,142 @@ implements ActionListener, CaretListener, KeyListener { } } + +class +AttachmentsComponent extends JPanel +implements ActionListener { + + private ComposeWindow + primaire; + +// - -%- - + + private Attachment[] + working; + + private JButton + attachment1, + attachment2, + attachment3, + attachment4; + + private JButton + delete, + revert; + + private JButton + close; + + private JLabel + descriptionLabel; + + private JTextArea + description; + +// ---%-@-%--- + + public void + actionPerformed(ActionEvent eA) + { + Object src = eA.getSource(); + + if (src == close) + { + primaire.showContentsPage(); + return; + } + + if (src == revert) + { + return; + } + + if (src == delete) + { + return; + } + } + +// ---%-@-%--- + + AttachmentsComponent(ComposeWindow primaire) + { + this.primaire = primaire; + + Border b1 = BorderFactory.createEmptyBorder(8, 8, 8, 8); + Border b2 = BorderFactory.createEmptyBorder(4, 4, 4, 4); + Border b3 = BorderFactory.createLineBorder(Color.GRAY); + Border bc = BorderFactory.createCompoundBorder(b3, b2); + + attachment1 = new JButton("+"); + attachment2 = new JButton("+"); + attachment3 = new JButton("+"); + attachment4 = new JButton("+"); + attachment1.setMargin(new Insets(0, 0, 0, 0)); + attachment2.setMargin(new Insets(0, 0, 0, 0)); + attachment3.setMargin(new Insets(0, 0, 0, 0)); + attachment4.setMargin(new Insets(0, 0, 0, 0)); + attachment1.addActionListener(this); + attachment2.addActionListener(this); + attachment3.addActionListener(this); + attachment4.addActionListener(this); + + JPanel left = new JPanel(); + left.setOpaque(false); + left.setLayout(null); + // BoxLayout wasn't listening to my + // preferred nor minimum sizes. + attachment1.setSize(40, 40); + attachment2.setSize(40, 40); + attachment3.setSize(40, 40); + attachment4.setSize(40, 40); + attachment1.setLocation(0, 0); + attachment2.setLocation(0, 44); + attachment3.setLocation(0, 88); + attachment4.setLocation(0, 132); + left.add(attachment1); + left.add(attachment2); + left.add(attachment3); + left.add(attachment4); + left.setPreferredSize(new Dimension(40, 172)); + + delete = new JButton("Delete"); + revert = new JButton("Revert"); + close = new JButton("Save & close"); + delete.addActionListener(this); + revert.addActionListener(this); + close.addActionListener(this); + + Box bottom = Box.createHorizontalBox(); + bottom.add(delete); + bottom.add(Box.createHorizontalStrut(16)); + bottom.add(revert); + bottom.add(Box.createGlue()); + bottom.add(close); + + description = new JTextArea(); + description.setLineWrap(true); + description.setWrapStyleWord(true); + java.awt.Font f = description.getFont(); + description.setFont(f.deriveFont(16f)); + description.setBorder(bc); + descriptionLabel = new JLabel("Description"); + descriptionLabel.setLabelFor(description); + + JPanel row1 = new JPanel(); + row1.setOpaque(false); + row1.setLayout(new BorderLayout()); + row1.add(descriptionLabel, BorderLayout.NORTH); + row1.add(description, BorderLayout.CENTER); + Box right = Box.createVerticalBox(); + right.add(row1); + + setLayout(new BorderLayout(12, 10)); + add(right, BorderLayout.CENTER); + add(left, BorderLayout.WEST); + add(bottom, BorderLayout.SOUTH); + + setBorder(b1); + } + +} diff --git a/ImageApi.java b/ImageApi.java old mode 100755 new mode 100644 diff --git a/ImageWindow.java b/ImageWindow.java old mode 100755 new mode 100644 diff --git a/JKomasto.java b/JKomasto.java old mode 100755 new mode 100644 index a6f9cac..114ccb8 --- a/JKomasto.java +++ b/JKomasto.java @@ -614,6 +614,9 @@ Composition { public String replyToPostId; + public Attachment[] + attachments; + // ---%-@-%--- public diff --git a/KDE_Dialog_Appear.wav b/KDE_Dialog_Appear.wav old mode 100755 new mode 100644 diff --git a/LoginWindow.java b/LoginWindow.java old mode 100755 new mode 100644 diff --git a/MastodonApi.java b/MastodonApi.java old mode 100755 new mode 100644 diff --git a/NotificationsWindow.java b/NotificationsWindow.java old mode 100755 new mode 100644 diff --git a/PostWindow.java b/PostWindow.java old mode 100755 new mode 100644 diff --git a/ProfileWindow.java b/ProfileWindow.java old mode 100755 new mode 100644 diff --git a/RepliesWindow.java b/RepliesWindow.java old mode 100755 new mode 100644 diff --git a/RequestListener.java b/RequestListener.java old mode 100755 new mode 100644 diff --git a/RichTextPane.java b/RichTextPane.java old mode 100755 new mode 100644 diff --git a/RichTextPane2.java b/RichTextPane2.java old mode 100755 new mode 100644 diff --git a/RichTextPane3.java b/RichTextPane3.java old mode 100755 new mode 100644 index 4e93f17..36cbd77 --- a/RichTextPane3.java +++ b/RichTextPane3.java @@ -182,7 +182,7 @@ implements layout.put(temp, cursor.clone()); rem.delete(0, l); - boolean more = rem.length() != 0; + boolean more = rem.length() != 0; if (more) ++cursor.line; cursor.x = more ? 0 : w; aw = mw; @@ -247,7 +247,7 @@ implements aug.value = child.value; for (Tree gc: child) aug.add(gc); - // Append all of our attributes. We'd like + // Append all of our attributes. We'd like // those like href to end up at the text // nodes. This might collide with our // child node's attributes, for now I'll @@ -471,7 +471,7 @@ implements Position ssp = layout.get(selStart); Position sep = layout.get(selEnd); assert ssp != null && sep != null; - if (ssp.compareTo(sep) > 1) + if (ssp.compareTo(sep) > 0) { Position temp = ssp; ssp = sep; @@ -613,7 +613,7 @@ implements compareTo(Position other) { if (line < other.line) return -1; - if (line > other.line) return -1; + if (line > other.line) return 1; if (x < other.x) return -1; if (x > other.x) return 1; return 0; diff --git a/RudimentaryHTMLParser.java b/RudimentaryHTMLParser.java old mode 100755 new mode 100644 diff --git a/TimelineWindow.java b/TimelineWindow.java old mode 100755 new mode 100644 diff --git a/TwoToggleButton.java b/TwoToggleButton.java old mode 100755 new mode 100644 diff --git a/WindowUpdater.java b/WindowUpdater.java old mode 100755 new mode 100644 diff --git a/notifOptions.txt b/notifOptions.txt old mode 100755 new mode 100644 diff --git a/notifOptions.txt~ b/notifOptions.txt~ old mode 100755 new mode 100644