1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Doxygen updates.

This commit is contained in:
Dave Davenport 2016-02-08 18:16:16 +01:00
parent 5a86ae5c99
commit 5d430824b3
5 changed files with 127 additions and 46 deletions

View file

@ -42,15 +42,15 @@ typedef struct
typedef enum
{
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
} TextboxFlags;
typedef enum

View file

@ -5,7 +5,7 @@
#include "scrollbar.h"
/**
* @ingroup View
* @ingroup ViewHandle
*
* @{
*/

View file

@ -6,12 +6,17 @@
*
* The rofi Menu view.
*
* @defgroup ViewHandle ViewHandle
* @ingroup View
*
* @{
*/
typedef struct RofiViewState RofiViewState;
typedef enum
{
/** Create a menu for entering text */
MENU_NORMAL = 0,
/** Create a menu for entering passwords */
MENU_PASSWORD = 1
} MenuFlags;
@ -36,26 +41,82 @@ __attribute__ ( ( nonnull ( 1, 2, 3 ) ) );
*/
void rofi_view_finalize ( RofiViewState *state );
RofiViewState * rofi_view_state_create ( void );
MenuReturn rofi_view_get_return_value ( const RofiViewState *state );
unsigned int rofi_view_get_selected_line ( const RofiViewState *state );
unsigned int rofi_view_get_next_position ( const RofiViewState *state );
void rofi_view_itterrate ( RofiViewState *state, XEvent *event );
unsigned int rofi_view_get_completed ( const RofiViewState *state );
const char * rofi_view_get_user_input ( const RofiViewState *state );
void rofi_view_free ( RofiViewState *state );
void rofi_view_restart ( RofiViewState *state );
/**
* @param state The Menu Handle
* @param selected_line The line to select.
*
* Select a line.
*/
void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line );
void rofi_view_queue_redraw ( void );
void rofi_view_set_active ( RofiViewState *state );
void rofi_view_call_thread ( gpointer data, gpointer user_data );
/**
* @param state The Menu Handle
*
* Get the selected line.
*
* @returns the selected line or UINT32_MAX if none selected.
*/
unsigned int rofi_view_get_selected_line ( const RofiViewState *state );
/**
* @param state The Menu Handle
*
* Restart the menu so it can be displayed again.
* Resets RofiViewState::quit and RofiViewState::retv.
*/
void rofi_view_restart ( RofiViewState *state );
/**
* @param state The handle to the view
*
* Update the state of the view. This involves filter state.
*/
void rofi_view_update ( RofiViewState *state );
/**
* @param display Connection to the X server.
* @param state The handle to the view
*
* Enables fake transparancy on this view.
*/
void rofi_view_setup_fake_transparency ( Display *display, RofiViewState *state );
void rofi_view_cleanup ( void );
/**
* @param state The handle to the view
*
* Free's the memory allocated for this handle.
* After a call to this function, state is invalid and can no longer be used.
*/
void rofi_view_free ( RofiViewState *state );
/** @} */
/**
* @defgroup ViewGlobal ViewGlobal
* @ingroup View
*
* Global menu view functions.
* These do not work on the view itself but modifies the global state.
* @{
*/
/**
* Get the current active view Handle.
*
* @returns the active view handle or NULL
*/
RofiViewState * rofi_view_get_active ( void );
/**
* @param state the new active view handle, NULL to clear.
*
* Set the current active view Handle.
*
*/
void rofi_view_set_active ( RofiViewState *state );
/**
* @param msg The error message to show.
@ -64,5 +125,25 @@ void rofi_view_cleanup ( void );
* The error message to show.
*/
void rofi_view_error_dialog ( const char *msg, int markup );
/**
* Queue a redraw.
* This triggers a X11 Expose Event.
*/
void rofi_view_queue_redraw ( void );
/**
* Cleanup internal data of the view.
*/
void rofi_view_cleanup ( void );
/**
* @param data A thread_state object.
* @param user_data User data to pass to thread_state callback
*
* Small wrapper function that is internally used to pass a job to a worker.
*/
void rofi_view_call_thread ( gpointer data, gpointer user_data );
/** @} */
#endif

View file

@ -31,7 +31,6 @@
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <locale.h>
@ -42,7 +41,6 @@
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <glib-unix.h>
@ -79,11 +77,10 @@ unsigned int num_modi = 0;
// Current selected switcher.
unsigned int curr_switcher = 0;
GThreadPool *tpool = NULL;
GMainLoop *main_loop = NULL;
GSource *main_loop_source = NULL;
gboolean quiet = FALSE;
RofiViewState *current_active_menu = NULL;
GThreadPool *tpool = NULL;
GMainLoop *main_loop = NULL;
GSource *main_loop_source = NULL;
gboolean quiet = FALSE;
static void process_result ( RofiViewState *state );
gboolean main_loop_x11_event_handler ( G_GNUC_UNUSED gpointer data );
@ -198,12 +195,13 @@ static void run_switcher ( ModeMode mode )
}
static void process_result ( RofiViewState *state )
{
Mode *sw = state->sw;
unsigned int selected_line = rofi_view_get_selected_line ( state );;
MenuReturn mretv = rofi_view_get_return_value ( state );
char *input = g_strdup ( rofi_view_get_user_input ( state ) );
rofi_view_set_active ( NULL );
rofi_view_free ( state );
ModeMode retv = mode_result ( modi[curr_switcher], mretv, &input, selected_line );
ModeMode retv = mode_result ( sw, mretv, &input, selected_line );
ModeMode mode = curr_switcher;
// Find next enabled
@ -535,16 +533,17 @@ static void reload_configuration ()
*/
gboolean main_loop_x11_event_handler ( G_GNUC_UNUSED gpointer data )
{
if ( current_active_menu != NULL ) {
RofiViewState *state = rofi_view_get_active ();
if ( state != NULL ) {
while ( XPending ( display ) ) {
XEvent ev;
// Read event, we know this won't block as we checked with XPending.
XNextEvent ( display, &ev );
rofi_view_itterrate ( current_active_menu, &ev );
rofi_view_itterrate ( state, &ev );
}
if ( rofi_view_get_completed ( current_active_menu ) ) {
if ( rofi_view_get_completed ( state ) ) {
// This menu is done.
rofi_view_finalize ( current_active_menu );
rofi_view_finalize ( state );
}
return G_SOURCE_CONTINUE;
}

View file

@ -66,19 +66,18 @@
#include "view.h"
#include "view-internal.h"
extern RofiViewState *current_active_menu;
extern Display *display;
extern unsigned int num_modi;
Window main_window = None;
extern Mode **modi;
extern SnDisplay *sndisplay;
extern SnLauncheeContext *sncontext;
extern GThreadPool *tpool;
extern unsigned int curr_switcher;
extern Mode **modi;
extern unsigned int num_modi;
cairo_surface_t *surface = NULL;
cairo_surface_t *fake_bg = NULL;
cairo_t *draw = NULL;
RofiViewState *current_active_menu = NULL;
Window main_window = None;
cairo_surface_t *surface = NULL;
cairo_surface_t *fake_bg = NULL;
cairo_t *draw = NULL;
XIM xim;
XIC xic;
Colormap map = None;
@ -225,6 +224,11 @@ void rofi_view_restart ( RofiViewState *state )
state->retv = MENU_CANCEL;
}
RofiViewState * rofi_view_get_active ( void )
{
return current_active_menu;
}
void rofi_view_set_active ( RofiViewState *state )
{
g_assert ( ( current_active_menu == NULL && state != NULL ) || ( current_active_menu != NULL && state == NULL ) );
@ -324,7 +328,7 @@ const char * rofi_view_get_user_input ( const RofiViewState *state )
*
* @returns a new 0 initialized RofiViewState
*/
RofiViewState * rofi_view_state_create ( void )
static RofiViewState * __rofi_view_state_create ( void )
{
return g_malloc0 ( sizeof ( RofiViewState ) );
}
@ -448,9 +452,6 @@ static Window __create_window ( Display *display )
return box;
}
/**
* Small wrapper function to create easy workers.
*/
void rofi_view_call_thread ( gpointer data, gpointer user_data )
{
thread_state *t = (thread_state *) data;
@ -1389,7 +1390,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
MenuFlags menu_flags )
{
TICK ();
RofiViewState *state = rofi_view_state_create ();
RofiViewState *state = __rofi_view_state_create ();
state->sw = sw;
state->selected_line = UINT32_MAX;
state->retv = MENU_CANCEL;
@ -1569,7 +1570,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
for ( unsigned int j = 0; j < num_modi; j++ ) {
state->modi[j] = textbox_create ( TB_CENTER, state->border + j * ( width + config.line_margin ),
state->h - state->line_height - state->border, width, state->line_height,
( j == curr_switcher ) ? HIGHLIGHT : NORMAL, mode_get_name ( modi[j] ) );
( modi[j] == state->sw ) ? HIGHLIGHT : NORMAL, mode_get_name ( modi[j] ) );
}
}
@ -1616,7 +1617,7 @@ static void __error_dialog_event_loop ( RofiViewState *state, XEvent *ev )
}
void rofi_view_error_dialog ( const char *msg, int markup )
{
RofiViewState *state = rofi_view_state_create ();
RofiViewState *state = __rofi_view_state_create ();
state->retv = MENU_CANCEL;
state->update = TRUE;
state->border = config.padding + config.menu_bw;