Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package nwg-launchers for openSUSE:Factory checked in at 2021-02-01 13:29:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nwg-launchers (Old)
and /work/SRC/openSUSE:Factory/.nwg-launchers.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nwg-launchers"
Mon Feb 1 13:29:03 2021 rev:8 rq:868301 version:0.4.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/nwg-launchers/nwg-launchers.changes 2021-01-06 19:56:55.125134375 +0100
+++ /work/SRC/openSUSE:Factory/.nwg-launchers.new.28504/nwg-launchers.changes 2021-02-01 13:30:57.182346084 +0100
@@ -1,0 +2,8 @@
+Mon Feb 1 09:13:00 UTC 2021 - Michael Vetter
+
+- Update to 0.4.4:
+ * Fix desktop description line break (#151)
+ * Fix press entering (#152)
+ * Fix nwgdmenu error (#153)
+
+-------------------------------------------------------------------
Old:
----
v0.4.3.tar.gz
New:
----
v0.4.4.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ nwg-launchers.spec ++++++
--- /var/tmp/diff_new_pack.hvmIoH/_old 2021-02-01 13:30:57.798346843 +0100
+++ /var/tmp/diff_new_pack.hvmIoH/_new 2021-02-01 13:30:57.798346843 +0100
@@ -17,7 +17,7 @@
Name: nwg-launchers
-Version: 0.4.3
+Version: 0.4.4
Release: 0
Summary: GTK launchers and menu for sway and i3
License: GPL-3.0-or-later
++++++ v0.4.3.tar.gz -> v0.4.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nwg-launchers-0.4.3/dmenu/dmenu.cc new/nwg-launchers-0.4.4/dmenu/dmenu.cc
--- old/nwg-launchers-0.4.3/dmenu/dmenu.cc 2021-01-05 01:35:48.000000000 +0100
+++ new/nwg-launchers-0.4.4/dmenu/dmenu.cc 2021-01-30 15:35:45.000000000 +0100
@@ -57,12 +57,12 @@
int main(int argc, char *argv[]) {
std::string custom_css_file {"style.css"};
- /* For now the settings file only determines if case_sensitive was turned on.
- * Let's just check if the file exists.
- **/
+ // For now the settings file only determines if case_sensitive was turned on.
settings_file = get_settings_path();
- if (std::ifstream(settings_file)) {
- case_sensitive = false;
+ if (std::ifstream settings{ settings_file }) {
+ std::string sensitivity;
+ settings >> sensitivity;
+ case_sensitive = sensitivity == "case_sensitive";
}
create_pid_file_or_kill_pid("nwgdmenu");
@@ -188,7 +188,7 @@
sock.run("for_window [title=\"~nwgdmenu*\"] border none");
}
- Gtk::Main kit(argc, argv);
+ auto app = Gtk::Application::create();
auto provider = Gtk::CssProvider::create();
auto display = Gdk::Display::get_default();
@@ -212,8 +212,8 @@
// For openbox and similar we'll need the window x, y coordinates
window.show();
- DMenu menu;
- Anchor anchor(&menu);
+ DMenu menu{window};
+ Anchor anchor{menu};
window.anchor = &anchor;
window.signal_button_press_event().connect(sigc::ptr_fun(&on_window_clicked));
@@ -262,30 +262,7 @@
//~ window.hide();
}
- if (show_searchbox) {
- auto search_item = new Gtk::MenuItem();
- search_item -> add(menu.searchbox);
- search_item -> set_name("search_item");
- search_item -> set_sensitive(false);
- menu.append(*search_item);
- }
-
- menu.signal_deactivate().connect(sigc::ptr_fun(Gtk::Main::quit));
-
- int cnt = 0;
- for (auto& command : all_commands) {
- auto item = new Gtk::MenuItem();
- item -> set_label(command);
- item -> signal_activate().connect(sigc::bindstd::string(sigc::ptr_fun(&on_item_clicked),
- std::move(command)));
-
- menu.append(*item);
- cnt++;
- if (cnt > rows - 1) {
- break;
- }
- }
-
+ menu.signal_deactivate().connect(sigc::mem_fun(window, &MainWindow::close));
menu.set_reserve_toggle_size(false);
menu.set_property("width_request", w / 8);
@@ -318,7 +295,5 @@
menu.show_all();
- Gtk::Main::run(window);
-
- return 0;
+ return app->run(window);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nwg-launchers-0.4.3/dmenu/dmenu.h new/nwg-launchers-0.4.4/dmenu/dmenu.h
--- old/nwg-launchers-0.4.3/dmenu/dmenu.h 2021-01-05 01:35:48.000000000 +0100
+++ new/nwg-launchers-0.4.4/dmenu/dmenu.h 2021-01-30 15:35:45.000000000 +0100
@@ -42,23 +42,38 @@
class DMenu : public Gtk::Menu {
public:
- DMenu();
- Gtk::SearchEntry searchbox;
- Glib::ustring search_phrase;
-
+ DMenu(Gtk::Window&);
+ ~DMenu();
+ void emplace_back(const Glib::ustring&);
+ void show_all() {
+ Gtk::Menu::show_all();
+ // required to have first item selected on launch
+ fix_selection();
+ }
+
private:
+ Gtk::SearchEntry searchbox;
+ // parent window
+ Gtk::Window& main;
+ // the first item in list
+ Gtk::MenuItem* first_item = nullptr;
+ // whether case sensitivity was changed during run
+ bool case_sensitivity_changed = false;
+
bool on_key_press_event(GdkEventKey* event) override;
void filter_view();
+ void switch_case_sensitivity();
+ void fix_selection();
void on_item_clicked(Glib::ustring cmd);
};
class Anchor : public Gtk::Button {
public:
- Anchor(DMenu *);
-
+ Anchor(DMenu&);
private:
bool on_focus_in_event(GdkEventFocus* focus_event) override;
- DMenu *menu;
+ Gdk::Gravity gravity_widget, gravity_menu;
+ DMenu& menu;
};
class MainWindow : public CommonWindow {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nwg-launchers-0.4.3/dmenu/dmenu_classes.cc new/nwg-launchers-0.4.4/dmenu/dmenu_classes.cc
--- old/nwg-launchers-0.4.3/dmenu/dmenu_classes.cc 2021-01-05 01:35:48.000000000 +0100
+++ new/nwg-launchers-0.4.4/dmenu/dmenu_classes.cc 2021-01-30 15:35:45.000000000 +0100
@@ -16,102 +16,122 @@
#include "dmenu.h"
-Anchor::Anchor(DMenu *menu) : menu{menu} {}
+Anchor::Anchor(DMenu& menu):
+ gravity_widget{Gdk::GRAVITY_CENTER}, gravity_menu{Gdk::GRAVITY_CENTER}, menu{menu}
+{
+ constexpr std::array gravity { Gdk::GRAVITY_SOUTH, Gdk::GRAVITY_NORTH };
+ auto is_sway_like = wm == "sway" || wm == "i3";
+ if (v_align == "t") {
+ gravity_widget = gravity[is_sway_like];
+ gravity_menu = gravity[is_sway_like];
+ } else if (v_align == "b") {
+ gravity_widget = gravity[!is_sway_like];
+ gravity_menu = gravity[!is_sway_like];
+ }
+}
bool Anchor::on_focus_in_event(GdkEventFocus* focus_event) {
(void) focus_event; // suppress warning
+ menu.popup_at_widget(this, gravity_widget, gravity_menu, nullptr);
+ return true;
+}
- Gdk::Gravity gravity_widget {Gdk::GRAVITY_CENTER};
- Gdk::Gravity gravity_menu {Gdk::GRAVITY_CENTER};
- if (wm == "sway" || wm == "i3") {
- if (v_align == "t") {
- gravity_widget = Gdk::GRAVITY_NORTH;
- gravity_menu = Gdk::GRAVITY_NORTH;
- } else if (v_align == "b") {
- gravity_widget = Gdk::GRAVITY_SOUTH;
- gravity_menu = Gdk::GRAVITY_SOUTH;
- }
- } else {
- if (v_align == "t") {
- gravity_widget = Gdk::GRAVITY_SOUTH;
- gravity_menu = Gdk::GRAVITY_SOUTH;
- } else if (v_align == "b") {
- gravity_widget = Gdk::GRAVITY_NORTH;
- gravity_menu = Gdk::GRAVITY_NORTH;
- }
+inline auto set_searchbox_placeholder = [](auto && searchbox, auto case_sensitive) {
+ constexpr std::array placeholders { "TYPE TO SEARCH", "Type to Search" };
+ searchbox.set_placeholder_text(placeholders[case_sensitive]);
+};
+
+inline auto build_commands_list = [](auto && dmenu, auto && commands, auto max) {
+ decltype(max) count{ 0 };
+ for (auto && command: commands) {
+ dmenu.emplace_back(command);
+ count++;
+ if (count == max) {
+ break;
+ }
+ }
+};
+
+DMenu::DMenu(Gtk::Window& main): main{main} {
+ set_searchbox_placeholder(searchbox, case_sensitive);
+ searchbox.set_sensitive(true);
+ searchbox.set_name("searchbox");
+ searchbox.signal_search_changed()
+ .connect(sigc::mem_fun(*this, &DMenu::filter_view));
+ // TODO: make searchbox return selection to items on focus_in event
+ if (show_searchbox) {
+ auto search_item = Gtk::manage(new Gtk::MenuItem{ searchbox });
+ search_item->set_name("search_item");
+ append(*search_item);
}
- menu->popup_at_widget(this, gravity_widget, gravity_menu, nullptr);
+ build_commands_list(*this, all_commands, rows);
+}
- return true;
+DMenu::~DMenu() {
+ using namespace std::string_view_literals;
+ if (case_sensitivity_changed) {
+ std::ofstream file{ settings_file, std::ios::trunc };
+ constexpr std::array values { "case_insensitive"sv, "case_sensitive"sv };
+ file << values[case_sensitive];
+ }
}
-DMenu::DMenu() {
- if (case_sensitive) {
- searchbox.set_text("Type To Search");
- } else {
- searchbox.set_text("TYPE TO SEARCH");
+void DMenu::emplace_back(const Glib::ustring& cmd) {
+ auto item = Gtk::manage(new Gtk::MenuItem{ cmd });
+ item->signal_activate()
+ .connect(sigc::bindGlib::ustring(sigc::mem_fun(*this, &DMenu::on_item_clicked), cmd));
+ append(*item);
+ if (!first_item) {
+ first_item = item;
}
- searchbox.set_sensitive(false);
- searchbox.set_name("searchbox");
- search_phrase = "";
}
-void switch_case_sensitive(std::string filename, bool is_case_sensitive) {
- if (is_case_sensitive) {
- if (std::ifstream(filename)) {
- int status = remove(filename.c_str());
- std::cout << "status = " << status << std::endl;
- }
- } else {
- std::ofstream file(filename);
- file << "case_sensitive";
+void DMenu::switch_case_sensitivity() {
+ case_sensitivity_changed = true;
+ case_sensitive = !case_sensitive;
+ searchbox.set_text("");
+ set_searchbox_placeholder(searchbox, case_sensitive);
+}
+
+void DMenu::fix_selection() {
+ if (first_item) {
+ this->select_item(*first_item);
+ first_item->grab_focus();
}
}
bool DMenu::on_key_press_event(GdkEventKey* key_event) {
if (show_searchbox) {
- if (key_event -> keyval == GDK_KEY_Escape) {
- Gtk::Main::quit();
- return Gtk::Menu::on_key_press_event(key_event);
- } else if (((key_event -> keyval >= GDK_KEY_A && key_event -> keyval <= GDK_KEY_Z)
- || (key_event -> keyval >= GDK_KEY_a && key_event -> keyval <= GDK_KEY_z)
- || (key_event -> keyval >= GDK_KEY_0 && key_event -> keyval <= GDK_KEY_9)
- || key_event -> keyval == GDK_KEY_plus
- || key_event -> keyval == GDK_KEY_minus
- || key_event -> keyval == GDK_KEY_underscore
- || key_event -> keyval == GDK_KEY_hyphen)
- && key_event->type == GDK_KEY_PRESS) {
-
- char character = key_event -> keyval;
- if (!case_sensitive) {
- character = toupper(character);
- }
- this -> search_phrase += character;
-
- this -> searchbox.set_text(this -> search_phrase);
- this -> filter_view();
- return true;
-
- } else if (key_event -> keyval == GDK_KEY_BackSpace && this -> search_phrase.size() > 0) {
- this -> search_phrase = this -> search_phrase.substr(0, this -> search_phrase.size() - 1);
- this -> searchbox.set_text(this -> search_phrase);
- this -> filter_view();
- return true;
- } else if (key_event -> keyval == GDK_KEY_Delete) {
- this -> search_phrase = "";
- this -> searchbox.set_text(this -> search_phrase);
- this -> filter_view();
- return true;
- } else if (this -> get_children().size() == 2 && key_event -> keyval == GDK_KEY_Return) {
- // Workaround to launch the single item which has been selected programmatically
- this -> get_children()[1] -> activate();
- return true;
- } else if (key_event -> keyval == GDK_KEY_Insert) {
- this -> search_phrase = "";
- case_sensitive = !case_sensitive;
- switch_case_sensitive(settings_file, case_sensitive);
- this -> filter_view();
- return true;
+ switch (key_event->keyval) {
+ case GDK_KEY_Escape:
+ main.close();
+ break;
+ case GDK_KEY_Delete:
+ searchbox.set_text("");
+ break;
+ case GDK_KEY_Insert:
+ case_sensitive = !case_sensitive;
+ switch_case_sensitivity();
+ searchbox.set_text("");
+ break;
+ case GDK_KEY_Left:
+ case GDK_KEY_Right:
+ case GDK_KEY_Up:
+ case GDK_KEY_Down:
+ // seem to work fine as is
+ break;
+ case GDK_KEY_Return:
+ if (auto active = dynamic_castGtk::MenuItem*(get_selected_item())) {
+ if (active == dynamic_castGtk::MenuItem*(searchbox.get_parent())) {
+ // searchbox is active, move selection to the first item in list
+ fix_selection();
+ }
+ }
+ break;
+ default:
+ searchbox.grab_focus();
+ searchbox.select_region(0, 0);
+ searchbox.set_position(-1);
}
}
//if the event has not been handled, call the base class
@@ -126,44 +146,38 @@
} else {
std::cout << cmd;
}
- Gtk::Main::quit();
+ main.close();
}
/* Rebuild menu to match the search phrase */
void DMenu::filter_view() {
- if (this -> search_phrase.size() > 0) {
+ auto clear_children = [this]() {
+ this->foreach([this](auto && child) {
+ if (child.get_name() != "search_item") {
+ this->remove(child);
+ }
+ });
+ this->first_item = nullptr;
+ };
+ auto search_phrase = searchbox.get_text();
+ if (search_phrase.size() > 0) {
// remove all items except searchbox
- for (auto item : this -> get_children()) {
- if (item -> get_name() != "search_item") {
- delete item;
- }
- }
+ clear_children();
int cnt = 0;
bool limit_exhausted = false;
+ auto sf = search_phrase;
+ if (!case_sensitive) {
+ sf = sf.uppercase();
+ }
for (Glib::ustring command : all_commands) {
- std::string sf = this -> search_phrase;
- std::string cm = command;
+ auto cm = command;
if (!case_sensitive) {
- for(unsigned int l = 0; l < sf.length(); l++) {
- sf[l] = toupper(sf[l]);
- }
- for(unsigned int l = 0; l < cm.length(); l++) {
- cm[l] = toupper(cm[l]);
- }
+ cm = cm.uppercase();
}
if (cm.find(sf) == 0) {
- Gtk::MenuItem *item = new Gtk::MenuItem();
- item -> set_label(command);
- item -> signal_activate().connect(sigc::bindGlib::ustring(sigc::mem_fun
- (*this, &DMenu::on_item_clicked), command));
- this -> append(*item);
- // This will highlight 1st menu item, still it won't start on Enter.
- // See workaround in on_key_press_event.
- if (cnt == 0) {
- item -> select();
- }
+ emplace_back(command);
cnt++;
- if (cnt > rows - 1) {
+ if (cnt == rows) {
limit_exhausted = true;
break;
}
@@ -171,24 +185,14 @@
}
if (!limit_exhausted) {
for (Glib::ustring command : all_commands) {
- std::string sf = this -> search_phrase;
- std::string cm = command;
+ auto cm = command;
if (!case_sensitive) {
- for(unsigned int l = 0; l < sf.length(); l++) {
- sf[l] = toupper(sf[l]);
- }
- for(unsigned int l = 0; l < cm.length(); l++) {
- cm[l] = toupper(cm[l]);
- }
+ cm = cm.uppercase();
}
- if (cm.find(sf) != std::string::npos && cm.find(sf) != 0) {
- Gtk::MenuItem *item = new Gtk::MenuItem();
- item -> set_label(command);
- item -> signal_activate().connect(sigc::bindGlib::ustring(sigc::mem_fun
- (*this, &DMenu::on_item_clicked), cm));
- this -> append(*item);
+ if (cm.find(sf) != cm.npos && cm.find(sf) != 0) {
+ emplace_back(command);
cnt++;
- if (cnt > rows - 1) {
+ if (cnt == rows) {
break;
}
}
@@ -197,30 +201,14 @@
this -> show_all();
} else {
- if (case_sensitive) {
- this -> searchbox.set_text("Type To Search");
- } else {
- this -> searchbox.set_text("TYPE TO SEARCH");
- }
+ set_searchbox_placeholder(searchbox, case_sensitive);
// remove all items except searchbox
- for (auto item : this -> get_children()) {
- if (item -> get_name() != "search_item") {
- delete item;
- }
- }
- int cnt = 0;
- for (Glib::ustring command : all_commands) {
- Gtk::MenuItem *item = new Gtk::MenuItem();
- item -> set_label(command);
- item -> signal_activate().connect(sigc::bindGlib::ustring(sigc::mem_fun(*this, &DMenu::on_item_clicked), command));
- this -> append(*item);
- cnt++;
- if (cnt > rows - 1) {
- break;
- }
- }
+ clear_children();
+ build_commands_list(*this, all_commands, rows);
this -> show_all();
}
+ fix_selection();
+
}
MainWindow::MainWindow() : CommonWindow("~nwgdmenu", "~nwgdmenu"), menu(nullptr) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nwg-launchers-0.4.3/grid/grid_classes.cc new/nwg-launchers-0.4.4/grid/grid_classes.cc
--- old/nwg-launchers-0.4.3/grid/grid_classes.cc 2021-01-05 01:35:48.000000000 +0100
+++ new/nwg-launchers-0.4.4/grid/grid_classes.cc 2021-01-30 15:35:45.000000000 +0100
@@ -57,6 +57,7 @@
apps_grid.set_sort_func(&by_name);
favs_grid.set_sort_func(&by_clicks);
+ description.set_ellipsize(Pango::ELLIPSIZE_END);
description.set_text("");
description.set_name("description");
separator.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
@@ -351,7 +352,7 @@
: name(std::move(name)), comment(std::move(comment)), desktop_id(&id), index(index) {
// As we sort dynamically by actual names, we need to avoid shortening them, or long names will remain unsorted.
// See the issue: https://github.com/nwg-piotr/nwg-launchers/issues/128
- std::string display_name = this->name;
+ auto display_name = this->name;
if (display_name.length() > 25) {
display_name.resize(22);
display_name += "...";