Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for avatar image not being saved in disk cache on GTK version #576

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

ROOT=$(realpath $(dirname $0));


# Uninstall
sudo find /{usr,etc,var} -type d -name '*hotot*' -exec rm -fr {} \;
sudo find /{usr,etc,var} -type f -name '*hotot*' -exec rm -f {} \;

rm -fr build && mkdir build && cd build

cmake -DPYTHON_EXECUTABLE=/usr/bin/python2 -DWITH_GIR=off -DWITH_QT=off -DWITH_KDE=off -DWITH_CHROME=off -DWITH_GTK3=off -DWITH_GTK2=on -DWITH_GTK=off ..
make
sudo make install

hotot
9 changes: 7 additions & 2 deletions data/js/lib.twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,13 @@ function TwitterClient() {
newText = interrupted_response + newText;
interrupted_response = ''

var lines = newText.split(/[\n\r]/g);
var lines = newText.split(/[\n\r]/g),
ret
for (var i = 0; i < lines.length; i += 1) {
var line = lines[i].split(/({[^\0]+})/gm);
for (var j = 0; j < line.length; j += 1) {
ret = null

if (!empty_tester.test(line[j])) {
try {
ret = JSON.parse(line[j]);
Expand All @@ -911,7 +914,9 @@ function TwitterClient() {
//return;
}
try {
callback(ret);
if(ret) {
callback(ret)
}
} catch(e) {
console.log('Streams callback: ' + e.message + '\n' + line);
return;
Expand Down
23 changes: 22 additions & 1 deletion data/js/ui.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ function loadmore_messages(self, success, fail) {
success);
},

getDisplayName:
function getDisplayName(user) {
const
displayName = '@' + user.screen_name,

sanitize = function(text) {
return text.replace(/[^a-z0-9_]/i, '').toLowerCase()
}

if(user.hasOwnProperty('name')) {
if(sanitize(user.name) === sanitize(user.screen_name)) {
return user.name
}

return user.name + ' (' + displayName + ')'
}

return displayName
},

load_tweet_success:
function load_tweet_success(self, json) {
var ret = ui.Main.add_tweets(self, json, false);
Expand All @@ -188,7 +208,8 @@ function load_tweet_success(self, json) {
if (user.screen_name == globals.myself.screen_name)
continue;
text = json[i].text;
hotot_notify(user.screen_name, text, user.profile_image_url , 'content');

hotot_notify(ui.Main.getDisplayName(user), text, user.profile_image_url , 'content');
notify_count += 1;
}
if (3 < notify_count) {
Expand Down
14 changes: 9 additions & 5 deletions data/js/ui.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tweet_t:
<div class="card_body">\
<div class="who {%RETWEET_MARK%}">\
<a class="who_href" href="#{%SCREEN_NAME%}" title="{%USER_NAME%}\n\n{%DESCRIPTION%}">\
{%SCREEN_NAME%}\
{%DISPLAY_NAME%}\
</a>\
</div>\
<div class="text" alt="{%ALT%}" style="font-size:{%TWEET_FONT_SIZE%}pt;line-height:{%TWEET_LINE_HEIGHT%}">{%TEXT%}</div>\
Expand Down Expand Up @@ -150,7 +150,7 @@ message_t:
<div class="card_body">\
<div class="who">\
<a class="who_href" href="#{%SCREEN_NAME%}" title="{%USER_NAME%}\n\n{%DESCRIPTION%}">\
{%SCREEN_NAME%}\
{%DISPLAY_NAME%}\
</a>\
</div>\
<div class="text" style="font-size:{%TWEET_FONT_SIZE%}pt;line-height:{%TWEET_LINE_HEIGHT%}">@<a class="who_href" href="#{%RECIPIENT_SCREEN_NAME%}">{%RECIPIENT_SCREEN_NAME%}</a> {%TEXT%}</div>\
Expand Down Expand Up @@ -185,7 +185,7 @@ search_t:
<div class="card_body">\
<div class="who">\
<a class="who_href" href="#{%SCREEN_NAME%}" title="{%USER_NAME%}">\
{%SCREEN_NAME%}\
{%DISPLAY_NAME%}\
</a>\
</div>\
<div class="text" style="font-size:{%TWEET_FONT_SIZE%}pt;line-height:{%TWEET_LINE_HEIGHT%}">{%TEXT%}</div>\
Expand Down Expand Up @@ -219,7 +219,7 @@ people_t:
<div class="card_body">\
<div id="{%USER_ID%}" class="who">\
<a class="who_href" href="#{%SCREEN_NAME%}" title="{%USER_NAME%}">\
{%SCREEN_NAME%}\
{%DISPLAY_NAME%}\
</a>\
</div>\
<div class="text" style="font-style:italic font-size:{%TWEET_FONT_SIZE%}pt;line-height:{%TWEET_LINE_HEIGHT%}">{%DESCRIPTION%}</div>\
Expand Down Expand Up @@ -747,6 +747,7 @@ function form_dm(dm_obj, pagename) {
m.ID = pagename + '-' + dm_obj.id_str;
m.TWEET_ID = dm_obj.id_str;
m.SCREEN_NAME = dm_obj.sender.screen_name;
m.DISPLAY_NAME = ui.Main.getDisplayName(dm_obj.sender)
m.RECIPIENT_SCREEN_NAME = dm_obj.recipient.screen_name;
m.USER_NAME = dm_obj.sender.name;
m.DESCRIPTION = dm_obj.sender.description;
Expand Down Expand Up @@ -870,7 +871,8 @@ function form_tweet (tweet_obj, pagename, in_thread) {
m.RETWEET_ID = retweet_id;
m.REPLY_ID = reply_id != null? reply_id:'';
m.IN_THREAD = in_thread;
m.SCREEN_NAME = tweet_obj.user.screen_name;
m.SCREEN_NAME = tweet_obj.user.screen_name
m.DISPLAY_NAME = ui.Main.getDisplayName(tweet_obj.user)
m.REPLY_NAME = reply_id != null? reply_name: '';
m.USER_NAME = tweet_obj.user.name;
m.DESCRIPTION = tweet_obj.user.description;
Expand Down Expand Up @@ -1037,6 +1039,7 @@ function form_search(tweet_obj, pagename) {
m.ID = pagename + '-' + id;
m.TWEET_ID = id;
m.SCREEN_NAME = tweet_obj.from_user;
m.DISPLAY_NAME = ui.Main.getDisplayName({ 'screen_name': tweet_obj.from_user, 'name': tweet_obj.from_user_name })
m.USER_NAME = tweet_obj.from_user_name;
m.PROFILE_IMG = tweet_obj.profile_image_url;
m.TEXT = text;
Expand All @@ -1058,6 +1061,7 @@ function form_people(user_obj, pagename) {
var m = ui.Template.people_m;
m.USER_ID = pagename + '-' + user_obj.id_str;
m.SCREEN_NAME = user_obj.screen_name;
m.DISPLAY_NAME = ui.Main.getDisplayName(user_obj)
m.USER_NAME = user_obj.name;
m.DESCRIPTION = user_obj.description;
m.PROFILE_IMG = user_obj.profile_image_url;
Expand Down
3 changes: 3 additions & 0 deletions hotot-gir/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def set_style_scheme():
''' % str(bg[Gtk.StateType.NORMAL]));

def get_prefs(name):
if name not in config.settings:
return ''

return config.settings[name]

def set_prefs(name, value):
Expand Down
13 changes: 8 additions & 5 deletions hotot/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
## Disable GtkNotification on Gnome3
screen = gtk.gdk.screen_get_default()
window_manager_name = screen.get_window_manager_name().lower() if screen else ''
if 'mutter' in window_manager_name:
if 'mutter' in window_manager_name or 'i3' in window_manager_name:
USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM = False

if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM:
Expand Down Expand Up @@ -63,16 +63,16 @@ def init_notify():
notify.set_icon_from_pixbuf(
gtk.gdk.pixbuf_new_from_file(
utils.get_ui_object(os.path.join('image','ic64_hotot.png'))))
notify.set_timeout(5000)
notify.set_timeout(30000)

def do_notify(summary, body, icon_file = None):
if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM:
return notify.do_notify(summary, body, icon_file)
n = pynotify.Notification(summary, body)
if (icon_file == None or not os.path.isfile(icon_file) or os.path.getsize(icon_file) == 0):
icon_file = utils.get_ui_object(os.path.join('image','ic64_hotot.png'));
n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file))
n.set_timeout(5000)
n = pynotify.Notification(summary, body, 'file://' + icon_file)
#n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file))
n.set_timeout(30000)
n.show()

def crack_hotot(uri):
Expand Down Expand Up @@ -203,6 +203,9 @@ def set_style_scheme():
''' % str(bg[gtk.STATE_NORMAL]));

def get_prefs(name):
if name not in config.settings:
return ''

return config.settings[name]

def set_prefs(name, value):
Expand Down