Skip to content

Commit

Permalink
open_directory: also open parent directory on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
carrotIndustries committed Apr 24, 2022
1 parent e9b326d commit 972cf17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/util/gtk_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,14 @@ void spinbutton_connect_activate(Gtk::SpinButton *sp, std::function<void()> cb)

void open_directory(Gtk::Window &win, const std::string &filename)
{
const auto dir_name = Glib::path_get_dirname(filename);
#ifdef G_OS_WIN32
auto wnd = reinterpret_cast<HWND>(GDK_WINDOW_HWND(win.get_window()->gobj()));
auto wfilename = reinterpret_cast<wchar_t *>(g_utf8_to_utf16(filename.c_str(), -1, NULL, NULL, NULL));
auto wfilename = reinterpret_cast<wchar_t *>(g_utf8_to_utf16(dir_name.c_str(), -1, NULL, NULL, NULL));
ShellExecuteW(wnd, NULL, wfilename, NULL, NULL, SW_SHOWNORMAL);
g_free(wfilename);
#else
auto uri = Gio::File::create_for_path(Glib::path_get_dirname(filename))->get_uri();
auto uri = Gio::File::create_for_path(dir_name)->get_uri();
Gio::AppInfo::launch_default_for_uri(uri);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/recent_item_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RecentItemBox::RecentItemBox(const std::string &name, const std::string &pa, con
auto item = Gtk::manage(new Gtk::MenuItem("Open in file browser"));
item->signal_activate().connect([this] {
auto top = dynamic_cast<Gtk::Window *>(get_ancestor(GTK_TYPE_WINDOW));
open_directory(*top, Glib::path_get_dirname(path));
open_directory(*top, path);
});
item->show();
menu.append(*item);
Expand Down

0 comments on commit 972cf17

Please sign in to comment.