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

add nautilus extension support #575

Open
wants to merge 3 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ cscope*
core
*.pyc
.DS_Store
compile_commands.json

# CMake files goes here
build/
CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
cmake_uninstall.cmake
CTestTestfile.cmake
Testing/
install_manifest.txt
Expand Down
110 changes: 110 additions & 0 deletions nautilus-seafile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(nautilus-seafile C)
SET(PROJECT_VERSION "1.0.0")
INCLUDE(FindPkgConfig)

IF (APPLE OR NOT UNIX)
MESSAGE(FATAL_ERROR "Nautilus extension is not supported on your platform")
ENDIF()

option(BUILD_ENABLE_WARNINGS "Enable compiler warnings." ON)
SET(NAUTILUS_EXTENSION_DIR CACHE "Path to Nautilus Extenstion Directory" "")

if(BUILD_ENABLE_WARNINGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wsign-compare -Wno-long-long -Wno-unused-parameter")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-warning-option")
endif()
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

## color diagnostics fix
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_C_COMPILER}
-dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
endif()
endif()

FIND_PACKAGE(PkgConfig REQUIRED)

PKG_CHECK_MODULES(GLIB2 REQUIRED glib-2.0>=2.15)

PKG_CHECK_MODULES(NAUTILUS REQUIRED libnautilus-extension>=2.0)

PKG_CHECK_MODULES(LIBCCNET REQUIRED libccnet>=1.3)

PKG_CHECK_MODULES(LIBSEARPC REQUIRED libsearpc>=1.0)

PKG_CHECK_MODULES(LIBSEAFILE REQUIRED libseafile>=1.7)

INCLUDE_DIRECTORIES(
${GLIB2_INCLUDE_DIRS}
${NAUTILUS_INCLUDE_DIRS}
${LIBCCNET_INCLUDE_DIRS}
${LIBSEARPC_INCLUDE_DIRS}
${LIBSEAFILE_INCLUDE_DIRS})

LINK_DIRECTORIES(
${GLIB2_LIBRARY_DIRS}
${NAUTILUS_LIBRARY_DIRS}
${LIBCCNET_LIBRARY_DIRS}
${LIBSEARPC_LIBRARY_DIRS}
${LIBSEAFILE_LIBRARY_DIRS})

ADD_LIBRARY(nautilus-seafile SHARED
seafile-module.c
nautilus-seafile.c
nautilus-seafile.h
seafile-rpc-client.c
seafile-rpc-client.h
)

TARGET_LINK_LIBRARIES(nautilus-seafile
${GLIB2_LIBRARIES}
${NAUTILUS_LIBRARIES}
${JANSSON_LIBRARIES}
${LIBCCNET_LIBRARIES}
${LIBSEARPC_LIBRARIES}
${LIBSEAFILE_LIBRARIES})

## Find libnautilus-extension's directory
IF ("${NAUTILUS_EXTENSION_DIR}" STREQUAL "")
EXECUTE_PROCESS(
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=extensiondir libnautilus-extension
OUTPUT_VARIABLE PKGCONFIG_RESULT
RESULT_VARIABLE PKGCONFIG_FAILURE)

IF (PKGCONFIG_FAILURE)
SET(NAUTILUS_EXTENSION_DIR "lib/nautilus/extension-1.0")
ELSE()
STRING(REGEX REPLACE "[\r\n]" " " PKGCONFIG_RESULT "${PKGCONFIG_RESULT}")
STRING(REGEX REPLACE " +$" "" PKGCONFIG_RESULT "${PKGCONFIG_RESULT}")

SET(NAUTILUS_EXTENSION_DIR ${PKGCONFIG_RESULT})
ENDIF()
ENDIF()

INSTALL(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/hicolor
DESTINATION share/icons
)

INSTALL(TARGETS nautilus-seafile
DESTINATION ${NAUTILUS_EXTENSION_DIR}
)

# uninstall target
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
14 changes: 14 additions & 0 deletions nautilus-seafile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Nautilus Extension For Seafile


## Prerequirement

- libsearpc
- ccnet
- seafile

## Installation
- `sudo apt-get install cmake libnautilus-extension-dev`
- `./build.sh`
- `make install` (or `ninja install`)
- `nautilus -q`
32 changes: 32 additions & 0 deletions nautilus-seafile/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

NINJA=$(which ninja)
GENERATOR=Ninja
WORKER=ninja
if [ -z $NINJA ]; then
GENERATOR="Unix Makefiles"
WORKER=make
fi

set -x
set -e

CURRENT_PWD="$(dirname "${BASH_SOURCE[0]}")"

if [ "$(uname -s)" != "Linux" ]; then
echo "don't run it if you are not using Linux"
exit -1
fi

pushd $CURRENT_PWD
CONFIG=Debug
if [ a"$1" != "adebug" ]; then
rm -rf CMakeCache.txt CMakeFiles
CONFIG=Release
fi
cmake -G "$GENERATOR" \
-DCMAKE_BUILD_TYPE="$CONFIG" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=on
$WORKER
popd

21 changes: 21 additions & 0 deletions nautilus-seafile/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions nautilus-seafile/import-png.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python2

import os,sys,shutil

if __name__ == '__main__':
if len(sys.argv) <= 2:
print 'This is a little helper script to copy the pngs file to the correct directory'
print 'Usage: %s [directory] [name]' % sys.argv[0]
sys.exit(-1)
os.chdir(os.path.dirname(__file__))
source_dir = os.path.abspath(sys.argv[1])
source_name = os.path.splitext(os.path.basename(source_dir))[0]
png_files = os.listdir(source_dir)
for png_file in png_files:
prefix = os.path.splitext(os.path.basename(png_file))[0]
target_name = os.path.join('hicolor', prefix, 'emblems')
if not os.path.exists(target_name):
os.makedirs(target_name)
source = os.path.join(source_dir, png_file)
target = os.path.join(target_name, sys.argv[2] + '.png')
print 'copy %s to %s' % (source, target)
shutil.copyfile(source, target)
Loading