aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-29 15:15:28 +0100
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commit0102abeec1d2055b19dccbb7edc7f06e527642b1 (patch)
tree4018e82224c19142c4a7a6eced67d9c2550b2dd8 /main
parentb9df78e4494879752e9e68dcc5d54e03fffe9467 (diff)
downloaddino-0102abeec1d2055b19dccbb7edc7f06e527642b1.tar.gz
dino-0102abeec1d2055b19dccbb7edc7f06e527642b1.zip
Fix warnings
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/avatar_generator.vala22
-rw-r--r--main/src/ui/chat_input/edit_history.vala2
-rw-r--r--main/src/ui/conversation_summary/chat_state_populator.vala3
-rw-r--r--main/src/ui/conversation_summary/default_message_display.vala2
-rw-r--r--main/src/ui/conversation_summary/file_populator.vala10
-rw-r--r--main/src/ui/conversation_summary/message_textview.vala1
-rw-r--r--main/src/ui/conversation_summary/slashme_message_display.vala3
-rw-r--r--main/src/ui/conversation_titlebar/file_entry.vala2
-rw-r--r--main/src/ui/conversation_titlebar/menu_entry.vala2
-rw-r--r--main/src/ui/conversation_titlebar/occupants_entry.vala2
-rw-r--r--main/src/ui/notifications.vala10
11 files changed, 32 insertions, 27 deletions
diff --git a/main/src/ui/avatar_generator.vala b/main/src/ui/avatar_generator.vala
index 7e44f7e2..dce8e3d6 100644
--- a/main/src/ui/avatar_generator.vala
+++ b/main/src/ui/avatar_generator.vala
@@ -152,16 +152,18 @@ public class AvatarGenerator {
Context rectancle_context = new Context(new ImageSurface(Format.ARGB32, width, height));
draw_colored_rectangle(rectancle_context, hex_color, width, height);
- Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE);
- Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null);
- Context context = new Context(icon_surface);
- context.set_operator(Operator.IN);
- context.set_source_rgba(1, 1, 1, 1);
- context.rectangle(0, 0, width, height);
- context.fill();
-
- rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2);
- rectancle_context.paint();
+ try {
+ Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE);
+ Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null);
+ Context context = new Context(icon_surface);
+ context.set_operator(Operator.IN);
+ context.set_source_rgba(1, 1, 1, 1);
+ context.rectangle(0, 0, width, height);
+ context.fill();
+
+ rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2);
+ rectancle_context.paint();
+ } catch (Error e) { warning(@"Icon $icon does not exist"); }
return pixbuf_get_from_surface(rectancle_context.get_target(), 0, 0, width, height);
}
diff --git a/main/src/ui/chat_input/edit_history.vala b/main/src/ui/chat_input/edit_history.vala
index 2ac0b88a..82e6cbc5 100644
--- a/main/src/ui/chat_input/edit_history.vala
+++ b/main/src/ui/chat_input/edit_history.vala
@@ -8,7 +8,6 @@ namespace Dino.Ui.ChatInput {
class EditHistory {
- private StreamInteractor stream_interactor;
private Conversation? conversation;
private TextView text_input;
@@ -16,7 +15,6 @@ class EditHistory {
private HashMap<Conversation, int> indices = new HashMap<Conversation, int>(Conversation.hash_func, Conversation.equals_func);
public EditHistory(TextView text_input, GLib.Application application) {
- this.stream_interactor = stream_interactor;
this.text_input = text_input;
text_input.key_press_event.connect(on_text_input_key_press);
diff --git a/main/src/ui/conversation_summary/chat_state_populator.vala b/main/src/ui/conversation_summary/chat_state_populator.vala
index 06d0cf87..e491fe44 100644
--- a/main/src/ui/conversation_summary/chat_state_populator.vala
+++ b/main/src/ui/conversation_summary/chat_state_populator.vala
@@ -53,7 +53,6 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Object {
string? new_text = null;
if (state_ != null) {
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING || state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
- string display_name = Util.get_display_name(stream_interactor, jid, account);
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING) {
new_text = _("is typing...");
} else if (state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
@@ -95,7 +94,7 @@ public class MetaChatStateItem : Plugins.MetaConversationItem {
this.text = text;
}
- public override Object get_widget(Plugins.WidgetType widget_type) {
+ public override Object? get_widget(Plugins.WidgetType widget_type) {
label = new Label("") { xalign=0, vexpand=true, visible=true };
label.get_style_context().add_class("dim-label");
update_text();
diff --git a/main/src/ui/conversation_summary/default_message_display.vala b/main/src/ui/conversation_summary/default_message_display.vala
index 44040a3b..f843f116 100644
--- a/main/src/ui/conversation_summary/default_message_display.vala
+++ b/main/src/ui/conversation_summary/default_message_display.vala
@@ -44,7 +44,7 @@ public class MetaMessageItem : Plugins.MetaConversationItem {
public override bool requires_avatar { get; set; default=true; }
public override bool requires_header { get; set; default=true; }
- public override Object get_widget(Plugins.WidgetType widget_type) {
+ public override Object? get_widget(Plugins.WidgetType widget_type) {
MessageTextView text_view = new MessageTextView() { visible = true };
text_view.add_text(message.body);
return text_view;
diff --git a/main/src/ui/conversation_summary/file_populator.vala b/main/src/ui/conversation_summary/file_populator.vala
index 99185f6b..0edad19e 100644
--- a/main/src/ui/conversation_summary/file_populator.vala
+++ b/main/src/ui/conversation_summary/file_populator.vala
@@ -79,9 +79,14 @@ public class ImageItem : Plugins.MetaConversationItem {
});
}
- public override Object get_widget(Plugins.WidgetType widget_type) {
+ public override Object? get_widget(Plugins.WidgetType widget_type) {
Image image = new Image() { halign=Align.START, visible = true };
- Gdk.Pixbuf pixbuf = new Gdk.Pixbuf.from_file(file_transfer.get_uri());
+ Gdk.Pixbuf pixbuf;
+ try {
+ pixbuf = new Gdk.Pixbuf.from_file(file_transfer.get_uri());
+ } catch (Error error) {
+ return null;
+ }
int max_scaled_height = MAX_HEIGHT * image.scale_factor;
if (pixbuf.height > max_scaled_height) {
@@ -104,7 +109,6 @@ public class ImageItem : Plugins.MetaConversationItem {
Util.force_color(url_label, "#eee");
file_transfer.notify["info"].connect_after(() => { update_info(url_label, file_transfer.info); });
update_info(url_label, file_transfer.info);
- Box url_box = builder.get_object("url_box") as Box;
Image copy_image = builder.get_object("copy_image") as Image;
Util.force_css(copy_image, "*:not(:hover) { color: #eee; }");
diff --git a/main/src/ui/conversation_summary/message_textview.vala b/main/src/ui/conversation_summary/message_textview.vala
index f2a4ca22..77b2d707 100644
--- a/main/src/ui/conversation_summary/message_textview.vala
+++ b/main/src/ui/conversation_summary/message_textview.vala
@@ -51,7 +51,6 @@ public class MessageTextView : TextView {
MatchInfo match_info;
url_regex.match(text, 0, out match_info);
for (; match_info.matches(); match_info.next()) {
- string? url = match_info.fetch(0);
int start;
int end;
match_info.fetch_pos(0, out start, out end);
diff --git a/main/src/ui/conversation_summary/slashme_message_display.vala b/main/src/ui/conversation_summary/slashme_message_display.vala
index cb3d5cd2..92596936 100644
--- a/main/src/ui/conversation_summary/slashme_message_display.vala
+++ b/main/src/ui/conversation_summary/slashme_message_display.vala
@@ -50,7 +50,7 @@ public class MetaSlashmeItem : Plugins.MetaConversationItem {
public override bool requires_avatar { get; set; default=true; }
public override bool requires_header { get; set; default=false; }
- public override Object get_widget(Plugins.WidgetType widget_type) {
+ public override Object? get_widget(Plugins.WidgetType widget_type) {
text_view = new MessageTextView() { valign=Align.CENTER, vexpand=true, visible = true };
string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
@@ -67,7 +67,6 @@ public class MetaSlashmeItem : Plugins.MetaConversationItem {
}
private void update_style() {
- string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
string color = Util.get_name_hex_color(stream_interactor, conversation.account, message.real_jid ?? message.from, Util.is_dark_theme(text_view));
nick_tag.foreground = "#" + color;
}
diff --git a/main/src/ui/conversation_titlebar/file_entry.vala b/main/src/ui/conversation_titlebar/file_entry.vala
index df173192..cb7d0807 100644
--- a/main/src/ui/conversation_titlebar/file_entry.vala
+++ b/main/src/ui/conversation_titlebar/file_entry.vala
@@ -14,7 +14,7 @@ public class FileEntry : Plugins.ConversationTitlebarEntry, Object {
}
public double order { get { return 4; } }
- public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) {
+ public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
if (type == Plugins.WidgetType.GTK) {
return new FileWidget(stream_interactor) { visible=true };
}
diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala
index e6e5e1b4..51b8051c 100644
--- a/main/src/ui/conversation_titlebar/menu_entry.vala
+++ b/main/src/ui/conversation_titlebar/menu_entry.vala
@@ -14,7 +14,7 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
}
public double order { get { return 0; } }
- public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) {
+ public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
if (type == Plugins.WidgetType.GTK) {
return new MenuWidget(stream_interactor) { visible=true };
}
diff --git a/main/src/ui/conversation_titlebar/occupants_entry.vala b/main/src/ui/conversation_titlebar/occupants_entry.vala
index 904a832a..d6ce7f68 100644
--- a/main/src/ui/conversation_titlebar/occupants_entry.vala
+++ b/main/src/ui/conversation_titlebar/occupants_entry.vala
@@ -16,7 +16,7 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object {
}
public double order { get { return 3; } }
- public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) {
+ public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
if (type == Plugins.WidgetType.GTK) {
return new OccupantsWidget(stream_interactor, window) { visible=true };
}
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala
index cfbec8dc..464f5b0d 100644
--- a/main/src/ui/notifications.vala
+++ b/main/src/ui/notifications.vala
@@ -92,7 +92,9 @@ public class Notifications : Object {
}
notifications[conversation].set_title(display_name);
notifications[conversation].set_body(text);
- notifications[conversation].set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_conversation(stream_interactor, conversation)));
+ try {
+ notifications[conversation].set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_conversation(stream_interactor, conversation)));
+ } catch (Error e) { }
window.get_application().send_notification(conversation.id.to_string(), notifications[conversation]);
active_notification_ids.add(conversation.id.to_string());
window.urgency_hint = true;
@@ -102,7 +104,9 @@ public class Notifications : Object {
private void on_received_subscription_request(Jid jid, Account account) {
Notification notification = new Notification(_("Subscription request"));
notification.set_body(jid.bare_jid.to_string());
- notification.set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_jid(stream_interactor, jid, account)));
+ try {
+ notification.set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_jid(stream_interactor, jid, account)));
+ } catch (Error e) { }
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
notification.add_button_with_target_value(_("Accept"), "app.accept-subscription", conversation.id);
notification.add_button_with_target_value(_("Deny"), "app.deny-subscription", conversation.id);
@@ -119,7 +123,7 @@ public class Notifications : Object {
return true;
}
- private Icon get_pixbuf_icon(Gdk.Pixbuf avatar) {
+ private Icon get_pixbuf_icon(Gdk.Pixbuf avatar) throws Error {
uint8[] buffer;
avatar.save_to_buffer(out buffer, "png");
return new BytesIcon(new Bytes(buffer));