-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
[Taskbar] Add name field #1240
Closed
Closed
[Taskbar] Add name field #1240
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ static std::string trim(const std::string& s) | |
} | ||
|
||
|
||
/* Icon loading functions */ | ||
static std::vector<std::string> search_prefix() | ||
{ | ||
std::vector<std::string> prefixes = {""}; | ||
|
@@ -76,18 +75,7 @@ static std::vector<std::string> search_prefix() | |
return prefixes; | ||
} | ||
|
||
static Glib::RefPtr<Gdk::Pixbuf> load_icon_from_file(std::string icon_path, int size) | ||
{ | ||
try { | ||
auto pb = Gdk::Pixbuf::create_from_file(icon_path, size, size); | ||
return pb; | ||
} catch(...) { | ||
return {}; | ||
} | ||
} | ||
|
||
/* Method 1 - get the correct icon name from the desktop file */ | ||
static std::string get_from_desktop_app_info(const std::string &app_id) | ||
Glib::RefPtr<Gio::DesktopAppInfo> gen_app_info(const std::string app_id) | ||
{ | ||
static std::vector<std::string> prefixes = search_prefix(); | ||
|
||
|
@@ -111,6 +99,25 @@ static std::string get_from_desktop_app_info(const std::string &app_id) | |
if (!app_info) | ||
app_info = Gio::DesktopAppInfo::create_from_filename(prefix + folder + app_id + suffix); | ||
|
||
return app_info; | ||
} | ||
|
||
/* Icon loading functions */ | ||
static Glib::RefPtr<Gdk::Pixbuf> load_icon_from_file(std::string icon_path, int size) | ||
{ | ||
try { | ||
auto pb = Gdk::Pixbuf::create_from_file(icon_path, size, size); | ||
return pb; | ||
} catch(...) { | ||
return {}; | ||
} | ||
} | ||
|
||
/* Method 1 - get the correct icon name from the desktop file */ | ||
static std::string get_from_desktop_app_info(const std::string &app_id) | ||
{ | ||
Glib::RefPtr<Gio::DesktopAppInfo> app_info = gen_app_info(app_id); | ||
|
||
if (app_info && app_info->get_icon()) | ||
return app_info->get_icon()->to_string(); | ||
|
||
|
@@ -383,6 +390,15 @@ void Task::handle_app_id(const char *app_id) | |
{ | ||
app_id_ = app_id; | ||
|
||
Glib::RefPtr<Gio::DesktopAppInfo> app_info = gen_app_info(app_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case missing icon and name options it will cost unnecessary overhead. And it will be searched twice, as app_info was't saved. |
||
|
||
if(app_info) { | ||
name_ = app_info->get_display_name(); | ||
} | ||
else { | ||
name_ = app_id; | ||
} | ||
|
||
if (tbar_->ignore_list().count(app_id)) { | ||
ignored_ = true; | ||
if (button_visible_) { | ||
|
@@ -561,14 +577,17 @@ void Task::update() | |
bool markup = config_["markup"].isBool() ? config_["markup"].asBool() : false; | ||
std::string title = title_; | ||
std::string app_id = app_id_; | ||
std::string name = name_; | ||
if (markup) { | ||
title = Glib::Markup::escape_text(title); | ||
app_id = Glib::Markup::escape_text(app_id); | ||
name = Glib::Markup::escape_text(name); | ||
} | ||
if (!format_before_.empty()) { | ||
auto txt = fmt::format(format_before_, | ||
fmt::arg("title", title), | ||
fmt::arg("app_id", app_id), | ||
fmt::arg("name", name), | ||
fmt::arg("state", state_string()), | ||
fmt::arg("short_state", state_string(true)) | ||
); | ||
|
@@ -582,6 +601,7 @@ void Task::update() | |
auto txt = fmt::format(format_after_, | ||
fmt::arg("title", title), | ||
fmt::arg("app_id", app_id), | ||
fmt::arg("name", name), | ||
fmt::arg("state", state_string()), | ||
fmt::arg("short_state", state_string(true)) | ||
); | ||
|
@@ -596,6 +616,7 @@ void Task::update() | |
auto txt = fmt::format(format_tooltip_, | ||
fmt::arg("title", title), | ||
fmt::arg("app_id", app_id), | ||
fmt::arg("name", name), | ||
fmt::arg("state", state_string()), | ||
fmt::arg("short_state", state_string(true)) | ||
); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
gen*
instead ofget*
?