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

Setup pcmanfm-qt to support optional Custom Actions Menubar #26

Merged
merged 1 commit into from Mar 9, 2014
Merged
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
9 changes: 9 additions & 0 deletions libfm-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


include_directories(
${QT_INCLUDES}
${LIBFM_INCLUDE_DIRS}
Expand All @@ -11,6 +13,13 @@ link_directories(
${LIBFM_LIBRARY_DIRS}
)

if (EXISTS ${LIBFM_libfm_INCLUDEDIR}/libfm/fm-actions.h )
set_property(
DIRECTORY
PROPERTY COMPILE_DEFINITIONS CUSTOM_ACTIONS
)
endif()

set(libfm_SRCS
libfmqt.cpp
bookmarkaction.cpp
Expand Down
14 changes: 11 additions & 3 deletions libfm-qt/filemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "utilities.h"
#include "fileoperation.h"
#include "filelauncher.h"
#ifdef CUSTOM_ACTIONS
#include <libfm/fm-actions.h>
#endif
#include <QMessageBox>

using namespace Fm;
Expand Down Expand Up @@ -54,7 +56,7 @@ class AppInfoAction : public QAction {
GAppInfo* appInfo_;
};


#ifdef CUSTOM_ACTIONS
class CustomAction : public QAction {
public:
explicit CustomAction(FmFileActionItem* item, QObject* parent = NULL):
Expand All @@ -77,6 +79,7 @@ class CustomAction : public QAction {
FmFileActionItem* item_;
};

#endif

FileMenu::FileMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd, QWidget* parent): QMenu(parent) {
createMenu(files, info, cwd);
Expand Down Expand Up @@ -168,6 +171,7 @@ void FileMenu::createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd)
connect(renameAction_, SIGNAL(triggered(bool)), SLOT(onRenameTriggered()));
addAction(renameAction_);

#ifdef CUSTOM_ACTIONS
// DES-EMA custom actions integration
GList* files_list = fm_file_info_list_peek_head_link(files);
GList* items = fm_get_actions_for_files(files_list);
Expand All @@ -177,10 +181,10 @@ void FileMenu::createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd)
FmFileActionItem* item = FM_FILE_ACTION_ITEM(l->data);
addCustomActionItem(this, item);
}
}
}
g_list_foreach(items, (GFunc)fm_file_action_item_unref, NULL);
g_list_free(items);

#endif
// archiver integration
// FIXME: we need to modify upstream libfm to include some Qt-based archiver programs.
if(!allVirtual_) {
Expand Down Expand Up @@ -215,6 +219,7 @@ void FileMenu::createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd)
addAction(propertiesAction_);
}

#ifdef CUSTOM_ACTIONS
void FileMenu::addCustomActionItem(QMenu* menu, FmFileActionItem* item) {
if(!item) { // separator
addSeparator();
Expand All @@ -240,6 +245,7 @@ void FileMenu::addCustomActionItem(QMenu* menu, FmFileActionItem* item) {
connect(action, SIGNAL(triggered(bool)), SLOT(onCustomActionTrigerred()));
}
}
#endif

void FileMenu::onOpenTriggered() {
Fm::FileLauncher::launch(NULL, files_);
Expand All @@ -261,6 +267,7 @@ void FileMenu::onApplicationTriggered() {
g_list_free(uris);
}

#ifdef CUSTOM_ACTIONS
void FileMenu::onCustomActionTrigerred() {
CustomAction* action = static_cast<CustomAction*>(sender());
FmFileActionItem* item = action->item();
Expand All @@ -275,6 +282,7 @@ void FileMenu::onCustomActionTrigerred() {
g_free(output);
}
}
#endif

void FileMenu::onFilePropertiesTriggered() {
FilePropsDialog::showForFiles(files_);
Expand Down
5 changes: 4 additions & 1 deletion libfm-qt/filemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ Q_OBJECT

protected:
void createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd);
#ifdef CUSTOM_ACTIONS
void addCustomActionItem(QMenu* menu, struct _FmFileActionItem* item);
#endif

protected Q_SLOTS:
void onOpenTriggered();
void onFilePropertiesTriggered();
void onApplicationTriggered();
#ifdef CUSTOM_ACTIONS
void onCustomActionTrigerred();

#endif
void onCompress();
void onExtract();
void onExtractHere();
Expand Down