Commit 61f2204d authored by Dave Davenport's avatar Dave Davenport

Initial version.

parents
build/
*.m4
configure
config.*
Makefile.in
ar-lib
autom4te.cache/
compile
depcomp
install-sh
ltmain.sh
missing
ACLOCAL_AMFLAGS=-I m4
plugindir=${libdir}/rofi/
plugin_LTLIBRARIES = myplugin.la
myplugin_la_SOURCES=\
src/myplugin.c
myplugin_la_CFLAGS= @glib_CFLAGS@ @rofi_CFLAGS@
myplugin_la_LIBADD= @glib_LIBS@ @rofi_LIBS@
myplugin_la_LDFLAGS= -module -avoid-version
AC_INIT([rofi-plugin-template], [0.0.1], [https://my-neat-plugin.org//],[],[https://support.my-neat-plugin.org/])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIRS([m4])
dnl ---------------------------------------------------------------------
dnl Setup automake to be silent and in foreign mode.
dnl We want xz distribution
dnl ---------------------------------------------------------------------
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects dist-xz])
AM_SILENT_RULES([yes])
dnl ---------------------------------------------------------------------
dnl Check for compiler
dnl ---------------------------------------------------------------------
AC_PROG_CC([clang gcc cc])
dnl ---------------------------------------------------------------------
dnl C99 standard
dnl ---------------------------------------------------------------------
AC_PROG_CC_C99
dnl ---------------------------------------------------------------------
dnl C to Object rules.
dnl ---------------------------------------------------------------------
AM_PROG_CC_C_O
dnl ---------------------------------------------------------------------
dnl System extensions
dnl ---------------------------------------------------------------------
AC_USE_SYSTEM_EXTENSIONS
dnl ---------------------------------------------------------------------
dnl Static libraries programs
dnl ---------------------------------------------------------------------
AM_PROG_AR
dnl ---------------------------------------------------------------------
dnl Base CFLAGS
dnl ---------------------------------------------------------------------
AM_CFLAGS="-Wall -Wextra -Wparentheses -Winline -pedantic -Wunreachable-code"
dnl ---------------------------------------------------------------------
dnl Check dependencies
dnl ---------------------------------------------------------------------
PKG_PROG_PKG_CONFIG
dnl ---------------------------------------------------------------------
dnl PKG_CONFIG based dependencies
dnl ---------------------------------------------------------------------
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0 ])
PKG_CHECK_MODULES([rofi], [rofi])
LT_INIT([disable-static])
dnl ---------------------------------------------------------------------
dnl Add extra compiler flags
dnl ---------------------------------------------------------------------
AC_SUBST([AM_CFLAGS])
AC_CONFIG_FILES([Makefile ])
AC_OUTPUT
/**
* rofi-plugin-template
*
* MIT/X11 License
* Copyright (c) 2017 Qball Cow <qball@gmpclient.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <gmodule.h>
#include <rofi/mode.h>
#include <rofi/helper.h>
#include <rofi/mode-private.h>
#include <stdint.h>
G_MODULE_EXPORT Mode mode;
/**
* The internal data structure holding the private data of the TEST Mode.
*/
typedef struct
{
char **array;
unsigned int array_length;
} MYPLUGINModePrivateData;
static void get_myplugin ( Mode *sw )
{
/**
* Get the entries to display.
* this gets called on plugin initialization.
*/
}
static int myplugin_mode_init ( Mode *sw )
{
/**
* Called on startup when enabled (in modi list)
*/
if ( mode_get_private_data ( sw ) == NULL ) {
MYPLUGINModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
mode_set_private_data ( sw, (void *) pd );
// Load content.
get_myplugin ( sw );
}
return TRUE;
}
static unsigned int myplugin_mode_get_num_entries ( const Mode *sw )
{
const MYPLUGINModePrivateData *pd = (const MYPLUGINModePrivateData *) mode_get_private_data ( sw );
return pd->array_length;
}
static ModeMode myplugin_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
ModeMode retv = MODE_EXIT;
MYPLUGINModePrivateData *pd = (MYPLUGINModePrivateData *) mode_get_private_data ( sw );
if ( mretv & MENU_NEXT ) {
retv = NEXT_DIALOG;
} else if ( mretv & MENU_PREVIOUS ) {
retv = PREVIOUS_DIALOG;
} else if ( mretv & MENU_QUICK_SWITCH ) {
retv = ( mretv & MENU_LOWER_MASK );
} else if ( ( mretv & MENU_OK ) ) {
retv = RELOAD_DIALOG;
} else if ( ( mretv & MENU_ENTRY_DELETE ) == MENU_ENTRY_DELETE ) {
retv = RELOAD_DIALOG;
}
return retv;
}
static void myplugin_mode_destroy ( Mode *sw )
{
MYPLUGINModePrivateData *pd = (MYPLUGINModePrivateData *) mode_get_private_data ( sw );
if ( pd != NULL ) {
g_free ( pd );
mode_set_private_data ( sw, NULL );
}
}
static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **attr_list, int get_entry )
{
MYPLUGINModePrivateData *pd = (MYPLUGINModePrivateData *) mode_get_private_data ( sw );
// Only return the string if requested, otherwise only set state.
return get_entry ? g_strdup("n/a"): NULL;
}
/**
* @param sw The mode object.
* @param tokens The tokens to match against.
* @param index The index in this plugin to match against.
*
* Match the entry.
*
* @param returns try when a match.
*/
static int myplugin_token_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
MYPLUGINModePrivateData *pd = (MYPLUGINModePrivateData *) mode_get_private_data ( sw );
// Call default matching function.
return helper_token_match ( tokens, pd->array[index]);
}
Mode mode =
{
.abi_version = ABI_VERSION,
.name = "myplugin",
.cfg_name_key = "display-myplugin",
._init = myplugin_mode_init,
._get_num_entries = myplugin_mode_get_num_entries,
._result = myplugin_mode_result,
._destroy = myplugin_mode_destroy,
._token_match = myplugin_token_match,
._get_display_value = _get_display_value,
._get_message = NULL,
._get_completion = NULL,
._preprocess_input = NULL,
.private_data = NULL,
.free = NULL,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment