Skip to content

Commit

Permalink
nautilus: add extension support
Browse files Browse the repository at this point in the history
Closes haiwen/seafile#1233.

- ci: add nautilus build
- improve client auotconnect handle
- autorefresh overlay icons
- cmake learns how to install and uninstall nautilus-seafile now
  • Loading branch information
Chilledheart committed Jun 25, 2015
1 parent 10ca8f8 commit d804779
Show file tree
Hide file tree
Showing 52 changed files with 903 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cscope*
core
*.pyc
.DS_Store
compile_commands.json

# CMake files goes here
build/
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=gnu89")
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.
Loading

0 comments on commit d804779

Please sign in to comment.