Make send button settings-selectable
This commit is contained in:
parent
be7e0c2d56
commit
2f1f04b3e8
|
@ -13,6 +13,8 @@ public class Settings : Object {
|
|||
convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true);
|
||||
check_spelling = col_to_bool_or_default("check_spelling", true);
|
||||
default_encryption = col_to_encryption_or_default("default_encryption", Encryption.OMEMO);
|
||||
send_button = col_to_bool_or_default("send_button", false);
|
||||
enter_newline = col_to_bool_or_default("enter_newline", false);
|
||||
}
|
||||
|
||||
private bool col_to_bool_or_default(string key, bool def) {
|
||||
|
@ -98,6 +100,32 @@ public class Settings : Object {
|
|||
default_encryption_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
public signal void send_button_update(bool visible);
|
||||
private bool send_button_;
|
||||
public bool send_button {
|
||||
get { return send_button_; }
|
||||
set {
|
||||
db.settings.upsert()
|
||||
.value(db.settings.key, "send_button", true)
|
||||
.value(db.settings.value, value.to_string())
|
||||
.perform();
|
||||
send_button_ = value;
|
||||
send_button_update(value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool enter_newline_;
|
||||
public bool enter_newline {
|
||||
get { return enter_newline_; }
|
||||
set {
|
||||
db.settings.upsert()
|
||||
.value(db.settings.key, "enter_newline", true)
|
||||
.value(db.settings.value, value.to_string())
|
||||
.perform();
|
||||
enter_newline_ = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -148,6 +148,30 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="send_button_checkbutton">
|
||||
<property name="label" translatable="yes">Display send button</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="enter_newline_checkbutton">
|
||||
<property name="label" translatable="yes">Use Enter key to start a new line</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -76,8 +76,11 @@ public class ChatTextView : ScrolledWindow {
|
|||
|
||||
private bool on_text_input_key_press(EventKey event) {
|
||||
if (event.keyval in new uint[]{Key.Return, Key.KP_Enter}) {
|
||||
if ((event.state & ModifierType.CONTROL_MASK) > 0) {
|
||||
text_view.buffer.insert_at_cursor("\n", 1);
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
if ((event.state & ModifierType.SHIFT_MASK) > 0
|
||||
|| settings.enter_newline) {
|
||||
text_view.buffer.insert_at_cursor("\n", 1);
|
||||
} else if (text_view.buffer.text.strip() != "") {
|
||||
send_text();
|
||||
edit_history.reset_history();
|
||||
|
|
|
@ -55,39 +55,43 @@ public class View : Box {
|
|||
|
||||
outer_box.add(encryption_widget);
|
||||
|
||||
{
|
||||
MenuButton send_button = new MenuButton() {
|
||||
tooltip_text="Send message",
|
||||
relief=ReliefStyle.NONE,
|
||||
margin_top=3,
|
||||
valign=Align.CENTER,
|
||||
visible=true,
|
||||
sensitive=false
|
||||
};
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
send_button.get_style_context().add_class("flat");
|
||||
send_button.get_style_context().add_class("dino-chatinput-button");
|
||||
send_button.image = new Image.from_icon_name("document-send", IconSize.BUTTON) {
|
||||
visible=true,
|
||||
icon_size=3
|
||||
};
|
||||
MenuButton send_button = new MenuButton() {
|
||||
tooltip_text="Send message",
|
||||
relief=ReliefStyle.NONE,
|
||||
margin_top=3,
|
||||
valign=Align.CENTER,
|
||||
visible=settings.send_button,
|
||||
sensitive=false
|
||||
};
|
||||
|
||||
chat_text_view.text_view.buffer.changed.connect(() => {
|
||||
if (chat_text_view.text_view.buffer.text != "") {
|
||||
send_button.sensitive = true;
|
||||
}
|
||||
else {
|
||||
send_button.sensitive = false;
|
||||
}
|
||||
});
|
||||
settings.send_button_update.connect(() => {
|
||||
send_button.visible = settings.send_button;
|
||||
});
|
||||
|
||||
send_button.button_release_event.connect(() => {
|
||||
chat_text_view.send_text();
|
||||
return true;
|
||||
});
|
||||
send_button.get_style_context().add_class("flat");
|
||||
send_button.get_style_context().add_class("dino-chatinput-button");
|
||||
send_button.image = new Image.from_icon_name("document-send", IconSize.BUTTON) {
|
||||
visible=true,
|
||||
icon_size=3
|
||||
};
|
||||
|
||||
outer_box.add(send_button);
|
||||
}
|
||||
chat_text_view.text_view.buffer.changed.connect(() => {
|
||||
if (chat_text_view.text_view.buffer.text != "") {
|
||||
send_button.sensitive = true;
|
||||
}
|
||||
else {
|
||||
send_button.sensitive = false;
|
||||
}
|
||||
});
|
||||
|
||||
send_button.button_release_event.connect(() => {
|
||||
chat_text_view.send_text();
|
||||
return true;
|
||||
});
|
||||
|
||||
outer_box.add(send_button);
|
||||
|
||||
Util.force_css(frame, "* { border-radius: 3px; }");
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ class SettingsDialog : Dialog {
|
|||
[GtkChild] private unowned RadioButton encryption_radio_undecided;
|
||||
[GtkChild] private unowned RadioButton encryption_radio_omemo;
|
||||
[GtkChild] private unowned RadioButton encryption_radio_openpgp;
|
||||
[GtkChild] private unowned CheckButton send_button_checkbutton;
|
||||
[GtkChild] private unowned CheckButton enter_newline_checkbutton;
|
||||
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
|
@ -28,6 +30,9 @@ class SettingsDialog : Dialog {
|
|||
encryption_radio_undecided.active = settings.default_encryption == Encryption.UNKNOWN;
|
||||
encryption_radio_omemo.active = settings.default_encryption == Encryption.OMEMO;
|
||||
encryption_radio_openpgp.active = settings.default_encryption == Encryption.PGP;
|
||||
send_button_checkbutton.active = settings.send_button;
|
||||
enter_newline_checkbutton.active = settings.enter_newline;
|
||||
enter_newline_checkbutton.sensitive = settings.send_button;
|
||||
|
||||
typing_checkbutton.toggled.connect(() => { settings.send_typing = typing_checkbutton.active; } );
|
||||
marker_checkbutton.toggled.connect(() => { settings.send_marker = marker_checkbutton.active; } );
|
||||
|
@ -52,6 +57,16 @@ class SettingsDialog : Dialog {
|
|||
settings.default_encryption = Encryption.PGP;
|
||||
}
|
||||
});
|
||||
|
||||
send_button_checkbutton.toggled.connect(() => { settings.send_button = send_button_checkbutton.active; });
|
||||
enter_newline_checkbutton.toggled.connect(() => { settings.enter_newline = enter_newline_checkbutton.active; });
|
||||
settings.send_button_update.connect((visible) => {
|
||||
enter_newline_checkbutton.sensitive = visible;
|
||||
|
||||
if (visible == false) {
|
||||
enter_newline_checkbutton.active = visible;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue