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

More cleanups

This commit is contained in:
Dave Davenport 2016-02-07 20:38:34 +01:00
parent ca3afc6a6e
commit ad932c8fd0
3 changed files with 34 additions and 24 deletions

View file

@ -17,14 +17,8 @@ typedef enum
/**
* @param sw the Mode to show.
* @param lines An array of strings to display.
* @param num_lines Length of the array with strings to display.
* @param input A pointer to a string where the inputted data is placed.
* @param prompt The prompt to show.
* @param shift pointer to integer that is set to the state of the shift key.
* @param mmc Menu menu match callback, used for matching user input.
* @param mmc_data data to pass to mmc.
* @param selected_line pointer to integer holding the selected line.
* @param message Extra message to display.
* @param flags Flags indicating state of the menu.
*
@ -32,10 +26,9 @@ typedef enum
*
* @returns The command issued (see MenuReturn)
*/
RofiViewState *rofi_view_create ( Mode *sw,
const char *input, char *prompt,
const char *message, MenuFlags flags )
RofiViewState *rofi_view_create ( Mode *sw, const char *input, char *prompt, const char *message, MenuFlags flags )
__attribute__ ( ( nonnull ( 1, 2, 3 ) ) );
/**
* @param state The Menu Handle
*

View file

@ -47,9 +47,6 @@
#include <glib-unix.h>
#include <cairo.h>
#include <cairo-xlib.h>
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
@ -508,7 +505,9 @@ static inline void load_configuration_dynamic ( Display *display )
static void print_global_keybindings ()
{
fprintf ( stdout, "listening to the following keys:\n" );
if ( quiet ) {
fprintf ( stdout, "listening to the following keys:\n" );
}
for ( unsigned int i = 0; i < num_modi; i++ ) {
mode_print_keybindings ( modi[i] );
}
@ -586,7 +585,9 @@ gboolean main_loop_x11_event_handler ( G_GNUC_UNUSED gpointer data )
*/
static gboolean main_loop_signal_handler_hup ( G_GNUC_UNUSED gpointer data )
{
fprintf ( stdout, "Reload configuration\n" );
if ( !quiet ) {
fprintf ( stdout, "Reload configuration\n" );
}
// Release the keybindings.
release_global_keybindings ();
// Reload config
@ -597,6 +598,7 @@ static gboolean main_loop_signal_handler_hup ( G_GNUC_UNUSED gpointer data )
XFlush ( display );
return G_SOURCE_CONTINUE;
}
static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
{
// Break out of loop.
@ -626,12 +628,15 @@ static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, Display *xdispl
XSync ( xdisplay, False ); /* get all errors out of the queue */
--error_trap_depth;
}
static gboolean delayed_start ( G_GNUC_UNUSED gpointer data )
{
// Force some X Events to be handled.. seems the only way to get a reliable startup.
rofi_view_queue_redraw ();
main_loop_x11_event_handler ( NULL );
return FALSE;
}
int main ( int argc, char *argv[] )
{
TIMINGS_START ();

View file

@ -44,8 +44,6 @@
#include <sys/wait.h>
#include <sys/types.h>
#include <glib-unix.h>
#include <cairo.h>
#include <cairo-xlib.h>
@ -53,6 +51,8 @@
#include <libsn/sn.h>
#include "settings.h"
#include "rofi.h"
#include "mode.h"
#include "rofi.h"
#include "helper.h"
@ -62,7 +62,6 @@
#include "x11-event-source.h"
#include "xrmoptions.h"
#include "dialogs/dialogs.h"
#include "rofi.h"
#include "view.h"
#include "view-internal.h"
@ -103,10 +102,10 @@ static char * get_matching_state ( void )
}
return " ";
}
/**
* Levenshtein Sorting.
*/
static int lev_sort ( const void *p1, const void *p2, void *arg )
{
const int *a = p1;
@ -167,6 +166,7 @@ static void menu_capture_screenshot ( void )
g_free ( timestmp );
g_date_time_unref ( now );
}
/**
* @param state the state of the View.
* @param mon the work area.
@ -209,6 +209,7 @@ static void calculate_window_position ( RofiViewState *state )
state->x += config.x_offset;
state->y += config.y_offset;
}
void rofi_view_queue_redraw ( void )
{
if ( current_active_menu ) {
@ -223,6 +224,7 @@ void rofi_view_restart ( RofiViewState *state )
state->quit = FALSE;
state->retv = MENU_CANCEL;
}
void rofi_view_set_active ( RofiViewState *state )
{
g_assert ( ( current_active_menu == NULL && state != NULL ) || ( current_active_menu != NULL && state == NULL ) );
@ -284,6 +286,7 @@ MenuReturn rofi_view_get_return_value ( const RofiViewState *state )
{
return state->retv;
}
unsigned int rofi_view_get_selected_line ( const RofiViewState *state )
{
return state->selected_line;
@ -302,10 +305,12 @@ unsigned int rofi_view_get_completed ( const RofiViewState *state )
{
return state->quit;
}
void rofi_view_itterrate ( RofiViewState *state, XEvent *event )
{
state->x11_event_loop ( state, event );
}
const char * rofi_view_get_user_input ( const RofiViewState *state )
{
if ( state->text ) {
@ -442,6 +447,7 @@ static Window __create_window ( Display *display )
x11_set_window_opacity ( display, box, config.window_opacity );
return box;
}
/**
* Small wrapper function to create easy workers.
*/
@ -533,6 +539,7 @@ inline static void rofi_view_nav_page_next ( RofiViewState *state )
}
state->update = TRUE;
}
/**
* @param state The current RofiViewState
*
@ -581,6 +588,7 @@ inline static void rofi_view_nav_right ( RofiViewState *state )
}
}
}
/**
* @param state The current RofiViewState
*
@ -594,6 +602,7 @@ inline static void rofi_view_nav_left ( RofiViewState *state )
state->update = TRUE;
}
}
/**
* @param state The current RofiViewState
*
@ -612,6 +621,7 @@ inline static void rofi_view_nav_up ( RofiViewState *state )
}
state->update = TRUE;
}
/**
* @param state The current RofiViewState
*
@ -627,6 +637,7 @@ inline static void rofi_view_nav_down ( RofiViewState *state )
state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0;
state->update = TRUE;
}
/**
* @param state The current RofiViewState
*
@ -637,6 +648,7 @@ inline static void rofi_view_nav_first ( RofiViewState * state )
state->selected = 0;
state->update = TRUE;
}
/**
* @param state The current RofiViewState
*
@ -651,6 +663,7 @@ inline static void rofi_view_nav_last ( RofiViewState * state )
state->selected = state->filtered_lines - 1;
state->update = TRUE;
}
static void rofi_view_draw ( RofiViewState *state, cairo_t *d )
{
unsigned int i, offset = 0;
@ -732,6 +745,9 @@ static void rofi_view_draw ( RofiViewState *state, cairo_t *d )
void rofi_view_update ( RofiViewState *state )
{
if ( !state->update ) {
return;
}
TICK ();
cairo_surface_t * surf = cairo_image_surface_create ( get_format (), state->w, state->h );
cairo_t *d = cairo_create ( surf );
@ -1364,9 +1380,7 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, XEvent *ev )
if ( state->refilter ) {
rofi_view_refilter ( state );
}
if ( state->update ) {
rofi_view_update ( state );
}
rofi_view_update ( state );
}
RofiViewState *rofi_view_create ( Mode *sw,
const char *input,
@ -1598,9 +1612,7 @@ static void error_dialog_event_loop ( RofiViewState *state, XEvent *ev )
}
state->quit = TRUE;
}
if ( state->update ) {
rofi_view_update ( state );
}
rofi_view_update ( state );
}
void error_dialog ( const char *msg, int markup )
{