summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am29
-rw-r--r--include/view-internal.h31
-rw-r--r--include/view.h5
-rw-r--r--include/widget.h73
-rw-r--r--include/widgets/box.h26
-rw-r--r--include/widgets/listview.h90
-rw-r--r--include/widgets/scrollbar.h (renamed from include/scrollbar.h)13
-rw-r--r--include/widgets/separator.h24
-rw-r--r--include/widgets/textbox.h (renamed from include/textbox.h)34
-rw-r--r--include/widgets/widget.h115
-rw-r--r--source/dialogs/combi.c3
-rw-r--r--source/dialogs/dmenu.c10
-rw-r--r--source/dialogs/drun.c2
-rw-r--r--source/dialogs/help-keys.c2
-rw-r--r--source/dialogs/ssh.c2
-rw-r--r--source/dialogs/window.c2
-rw-r--r--source/helper.c4
-rw-r--r--source/rofi.c89
-rw-r--r--source/view.c881
-rw-r--r--source/widget.c58
-rw-r--r--source/widgets/box.c291
-rw-r--r--source/widgets/listview.c488
-rw-r--r--source/widgets/scrollbar.c (renamed from source/scrollbar.c)28
-rw-r--r--source/widgets/separator.c84
-rw-r--r--source/widgets/textbox.c (renamed from source/textbox.c)69
-rw-r--r--source/widgets/widget.c142
-rw-r--r--test/textbox-test.c6
-rw-r--r--test/widget-test.c4
28 files changed, 1676 insertions, 929 deletions
diff --git a/Makefile.am b/Makefile.am
index bdd1a83c..a97eb4d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,11 +23,14 @@ rofi_SOURCES=\
source/keyb.c\
config/config.c\
source/helper.c\
- source/widget.c\
- source/textbox.c\
source/timings.c\
source/history.c\
- source/scrollbar.c\
+ source/widgets/box.c\
+ source/widgets/widget.c\
+ source/widgets/textbox.c\
+ source/widgets/listview.c\
+ source/widgets/scrollbar.c\
+ source/widgets/separator.c\
source/xrmoptions.c\
source/x11-helper.c\
source/dialogs/run.c\
@@ -50,9 +53,12 @@ rofi_SOURCES=\
include/helper.h\
include/timings.h\
include/history.h\
- include/widget.h\
- include/textbox.h\
- include/scrollbar.h\
+ include/widgets/box.h\
+ include/widgets/widget.h\
+ include/widgets/textbox.h\
+ include/widgets/listview.h\
+ include/widgets/scrollbar.h\
+ include/widgets/separator.h\
include/xrmoptions.h\
include/x11-helper.h\
include/dialogs/ssh.h\
@@ -181,20 +187,19 @@ textbox_test_LDADD=\
widget_test_LDADD=$(textbox_test_LDADD)
widget_test_CFLAGS=$(textbox_test_CFLAGS)
widget_test_SOURCES=\
- source/widget.c\
+ source/widgets/widget.c\
test/widget-test.c
textbox_test_SOURCES=\
- source/widget.c\
- source/textbox.c\
+ source/widgets/widget.c\
+ source/widgets/textbox.c\
config/config.c\
include/keyb.h\
include/rofi.h\
include/mode.h\
include/mode-private.h\
include/settings.h\
- include/widget.h\
- include/textbox.h\
- include/widget.h\
+ include/widgets/widget.h\
+ include/widgets/textbox.h\
include/xrmoptions.h\
include/helper.h\
test/textbox-test.c
diff --git a/include/view-internal.h b/include/view-internal.h
index 0c693065..1a9e5a30 100644
--- a/include/view-internal.h
+++ b/include/view-internal.h
@@ -1,8 +1,10 @@
#ifndef ROFI_VIEW_INTERNAL_H
#define ROFI_VIEW_INTERNAL_H
-#include "widget.h"
-#include "textbox.h"
-#include "scrollbar.h"
+#include "widgets/widget.h"
+#include "widgets/textbox.h"
+#include "widgets/separator.h"
+#include "widgets/listview.h"
+#include "widgets/box.h"
#include "keyb.h"
#include "x11-helper.h"
@@ -16,27 +18,21 @@
struct RofiViewState
{
Mode *sw;
- unsigned int menu_lines;
- unsigned int max_elements;
- unsigned int max_rows;
- unsigned int columns;
-
- unsigned int element_width;
- int top_offset;
// Update/Refilter list.
- int update;
int refilter;
int rchanged;
- unsigned int cur_page;
+ box *main_box;
// Entries
+ box *input_bar;
+ separator *input_bar_separator;
+
+ textbox *prompt;
textbox *text;
- textbox *prompt_tb;
- textbox *message_tb;
textbox *case_indicator;
- textbox **boxes;
- scrollbar *scrollbar;
+
+ listview *list_view;
// Small overlay.
textbox *overlay;
int *distance;
@@ -45,7 +41,6 @@ struct RofiViewState
unsigned int num_lines;
// Selected element.
- unsigned int selected;
unsigned int filtered_lines;
// Last offset in paginating.
unsigned int last_offset;
@@ -58,11 +53,11 @@ struct RofiViewState
// Return state
unsigned int selected_line;
MenuReturn retv;
- int line_height;
unsigned int border;
workarea mon;
// Sidebar view
+ box *sidebar_bar;
unsigned int num_modi;
textbox **modi;
diff --git a/include/view.h b/include/view.h
index fbcd374c..93b04d8e 100644
--- a/include/view.h
+++ b/include/view.h
@@ -40,9 +40,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, void ( *finalize )(
+RofiViewState *rofi_view_create ( Mode *sw, const char *input, const char *message, MenuFlags flags, void ( *finalize )(
RofiViewState * ) )
-__attribute__ ( ( nonnull ( 1, 2, 3, 6 ) ) );
+__attribute__ ( ( nonnull ( 1, 2, 5 ) ) );
/**
* @param state The Menu Handle
@@ -162,5 +162,6 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text );
*/
void rofi_view_hide ( void );
void rofi_view_reload ( void );
+void rofi_view_switch_mode ( RofiViewState *state, Mode *mode );
/**@}*/
#endif
diff --git a/include/widget.h b/include/widget.h
deleted file mode 100644
index 522288d5..00000000
--- a/include/widget.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef ROFI_WIDGET_H
-#define ROFI_WIDGET_H
-
-#include <cairo.h>
-/**
- * @defgroup Widgets Widgets
- *
- * Generic Widget class
- *
- * @{
- */
-typedef struct _Widget
-{
- /** X position relative to parent */
- short x;
- /** Y position relative to parent */
- short y;
- /** Width of the widget */
- short w;
- /** Height of the widget */
- short h;
- /** enabled or not */
- gboolean enabled;
- /** Function prototypes */
-
- void ( *draw )( struct _Widget *widget, cairo_t *draw );
- void ( *free )( struct _Widget *widget );
-} Widget;
-
-/** Macro to get widget from an implementation (e.g. textbox/scrollbar) */
-#define WIDGET( a ) ( a != NULL ? (Widget *) ( a ) : NULL )
-
-/**
- * @param widget The widget to check
- * @param x The X position relative to parent window
- * @param y the Y position relative to parent window
- *
- * Check if x,y falls within the widget.
- *
- * @return TRUE if x,y falls within the widget
- */
-int widget_intersect ( const Widget *widget, int x, int y );
-
-/**
- * @param widget The widget to move
- * @param x The new X position relative to parent window
- * @param y The new Y position relative to parent window
- *
- * Moves the widget.
- */
-void widget_move ( Widget *widget, short x, short y );
-
-gboolean widget_enabled ( Widget *widget );
-void widget_disable ( Widget *widget );
-void widget_enable ( Widget *widget );
-
-/**
- * @param tb Handle to the widget
- * @param draw The cairo object used to draw itself.
- *
- * Render the textbox.
- */
-void widget_draw ( Widget *widget, cairo_t *d );
-
-/**
- * @param tb Handle to the widget
- *
- * Free the widget and all allocated memory.
- */
-void widget_free ( Widget *widget );
-
-/*@}*/
-#endif // ROFI_WIDGET_H
diff --git a/include/widgets/box.h b/include/widgets/box.h
new file mode 100644
index 00000000..e797e51e
--- /dev/null
+++ b/include/widgets/box.h
@@ -0,0 +1,26 @@
+#ifndef ROFI_HBOX_H
+#define ROFI_HBOX_H
+
+#include "widget.h"
+
+/**
+ * @defgroup box box
+ * @ingroup widgets
+ *
+ * @{
+ */
+typedef struct _box box;
+typedef enum
+{
+ BOX_HORIZONTAL,
+ BOX_VERTICAL
+} boxType;
+
+box * box_create ( boxType type, short x, short y, short w, short h );
+
+void box_add ( box *box, widget *child, gboolean expand, gboolean end );
+
+int box_get_fixed_pixels ( box *box );
+void box_set_padding ( box * box, unsigned int padding );
+/*@}*/
+#endif // ROFI_HBOX_H
diff --git a/include/widgets/listview.h b/include/widgets/listview.h
new file mode 100644
index 00000000..65bb5237
--- /dev/null
+++ b/include/widgets/listview.h
@@ -0,0 +1,90 @@
+#ifndef ROFI_LISTVIEW_H
+#define ROFI_LISTVIEW_H
+
+/**
+ * @defgroup listview listview
+ * @ingroup widgets
+ *
+ * @{
+ */
+
+typedef struct _listview listview;
+
+typedef enum
+{
+ LISTVIEW_SCROLL_PER_PAGE,
+ LISTVIEW_SCROLL_CONTINIOUS
+} ScrollType;
+
+typedef void ( *listview_update_callback )( textbox *tb, unsigned int entry, void *udata, TextBoxFontType type, gboolean full );
+typedef void ( *listview_mouse_activated_cb )( listview *, xcb_button_press_event_t *, void * );
+
+listview *listview_create ( listview_update_callback cb, void *udata, unsigned int eh );
+
+void listview_set_num_elements ( listview *lv, unsigned int rows );
+void listview_set_selected ( listview *lv, unsigned int selected );
+unsigned int listview_get_selected ( listview *lv );
+unsigned int listview_get_desired_height ( listview *lv );
+
+/**
+ * @param state The listview handle
+ *
+ * Move the selection one row up.
+ * - Wrap around.
+ */
+void listview_nav_up ( listview *lv );
+/**
+ * @param lv listview handle.
+ *
+ * Move the selection one row down.
+ * - Wrap around.
+ */
+void listview_nav_down ( listview *lv );
+/**
+ * @param state The listview handle
+ *
+ * Move the selection one column to the right.
+ * - No wrap around.
+ * - Do not move to top row when at start.
+ */
+void listview_nav_right ( listview *lv );
+/**
+ * @param state The listview handle
+ *
+ * Move the selection one column to the left.
+ * - No wrap around.
+ */
+void listview_nav_left ( listview *lv );
+/**
+ * @param state The listview handle
+ *
+ * Move the selection one page down.
+ * - No wrap around.
+ * - Clip at top/bottom
+ */
+void listview_nav_page_next ( listview *lv );
+
+/**
+ * @param state The current RofiViewState
+ *
+ * Move the selection one page up.
+ * - No wrap around.
+ * - Clip at top/bottom
+ */
+void listview_nav_page_prev ( listview *lv );
+/**
+ * Configuration.
+ */
+void listview_set_padding ( listview *lv, unsigned int padding );
+void listview_set_max_lines ( listview *lv, unsigned int lines );
+void listview_set_max_columns ( listview *lv, unsigned int columns );
+void listview_set_fixed_num_lines ( listview *lv, gboolean enabled );
+void listview_set_hide_scrollbar ( listview *lv, gboolean enabled );
+void listview_set_scrollbar_width ( listview *lv, unsigned int width );
+void listview_set_cycle ( listview *lv, gboolean cycle );
+void listview_set_scroll_type ( listview *lv, ScrollType type );
+void listview_set_mouse_activated_cb ( listview *lv, listview_mouse_activated_cb cb, void *udata );
+void listview_set_multi_select ( listview *lv, gboolean enable );
+/* @} */
+
+#endif // ROFI_LISTVIEW_H
diff --git a/include/scrollbar.h b/include/widgets/scrollbar.h
index 7b3a1205..148be6a9 100644
--- a/include/scrollbar.h
+++ b/include/widgets/scrollbar.h
@@ -5,7 +5,7 @@
/**
* @defgroup Scrollbar Scrollbar
- * @ingroup Widgets
+ * @ingroup widgets
*
* @{
*/
@@ -14,7 +14,7 @@
*/
typedef struct _scrollbar
{
- Widget widget;
+ widget widget;
unsigned int length;
unsigned int pos;
unsigned int pos_length;
@@ -64,14 +64,5 @@ void scrollbar_set_max_value ( scrollbar *sb, unsigned int max );
*/
unsigned int scrollbar_clicked ( const scrollbar *sb, int y );
-/**
- * @param sb scrollbar object
- * @param w new width in pixels
- * @param h new height in pixels
- *
- * Resize the scrollbar.
- */
-void scrollbar_resize ( scrollbar *sb, int w, int h );
-
/*@}*/
#endif // ROFI_SCROLLBAR_H
diff --git a/include/widgets/separator.h b/include/widgets/separator.h
new file mode 100644
index 00000000..f1bf7044
--- /dev/null
+++ b/include/widgets/separator.h
@@ -0,0 +1,24 @@
+#ifndef ROFI_SEPARATOR_H
+#define ROFI_SEPARATOR_H
+#include <cairo.h>
+#include "widget.h"
+
+/**
+ * @defgroup separator separator
+ * @ingroup widgets
+ *
+ * @{
+ */
+typedef struct _separator separator;
+
+/**
+ * @param h The height of the separator.
+ *
+ * Create a horizontal separator with height h.
+ *
+ * @returns a new separator, free with ::widget_free
+ */
+separator *separator_create ( short h );
+
+/*@}*/
+#endif // ROFI_SEPARATOR_H
diff --git a/include/textbox.h b/include/widgets/textbox.h
index ab704e9d..759220bf 100644
--- a/include/textbox.h
+++ b/include/widgets/textbox.h
@@ -12,14 +12,13 @@
/**
* @defgroup Textbox Textbox
- * @ingroup Widgets
+ * @ingroup widgets
*
* @{
*/
-
typedef struct
{
- Widget widget;
+ widget widget;
unsigned long flags;
short cursor;
Color color_fg, color_bg;
@@ -39,16 +38,16 @@ 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_INDICATOR = 1 << 23,
+ 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_INDICATOR = 1 << 23,
} TextboxFlags;
typedef enum
@@ -149,15 +148,6 @@ int textbox_get_height ( const textbox *tb );
/**
* @param tb Handle to the textbox
*
- * Get the width of the textbox
- *
- * @returns the width of the textbox in pixels.
- */
-int textbox_get_width ( const textbox *tb );
-
-/**
- * @param tb Handle to the textbox
- *
* Get the height of the rendered string.
*
* @returns the height of the string in pixels.
diff --git a/include/widgets/widget.h b/include/widgets/widget.h
new file mode 100644
index 00000000..2e92f316
--- /dev/null
+++ b/include/widgets/widget.h
@@ -0,0 +1,115 @@
+#ifndef ROFI_WIDGET_H
+#define ROFI_WIDGET_H
+#include <glib.h>
+#include <cairo.h>
+#include <xcb/xcb.h>
+#include <xcb/xproto.h>
+/**
+ * @defgroup widgets widgets
+ *
+ * Generic widget class
+ *
+ * @{
+ */
+typedef struct _widget widget;
+typedef gboolean ( *widget_clicked_cb )( widget *, xcb_button_press_event_t *, void * );
+struct _widget
+{
+ /** X position relative to parent */
+ short x;
+ /** Y position relative to parent */
+ short y;
+ /** Width of the widget */
+ short w;
+ /** Height of the widget */
+ short h;
+ /** enabled or not */
+ gboolean enabled;
+ /** Information about packing. */
+ gboolean expand;
+ gboolean end;
+
+ struct _widget *parent;
+ /** Internal */
+ gboolean need_redraw;
+ /** Function prototypes */
+ int ( *get_width )( struct _widget * );
+ int ( *get_height )( struct _widget * );
+
+ void ( *draw )( struct _widget *widget, cairo_t *draw );
+ void ( *resize )( struct _widget *, short, short );
+ void ( *update )( struct _widget * );
+
+ // Signals.
+ widget_clicked_cb clicked;
+ void *clicked_cb_data;
+
+ // Free
+ void ( *free )( struct _widget *widget );
+};
+
+/** Macro to get widget from an implementation (e.g. textbox/scrollbar) */
+#define WIDGET( a ) ( ( a ) != NULL ? (widget *) ( a ) : NULL )
+
+/**
+ * @param widget The widget to check
+ * @param x The X position relative to parent window
+ * @param y the Y position relative to parent window
+ *
+ * Check if x,y falls within the widget.
+ *
+ * @return TRUE if x,y falls within the widget
+ */
+int widget_intersect ( const widget *widget, int x, int y );
+
+/**
+ * @param widget The widget to move
+ * @param x The new X position relative to parent window
+ * @param y The new Y position relative to parent window
+ *
+ * Moves the widget.
+ */
+void widget_move ( widget *widget, short x, short y );
+
+gboolean widget_enabled ( widget *widget );
+void widget_disable ( widget *widget );
+void widget_enable ( widget *widget );
+
+/**
+ * @param tb Handle to the widget
+ * @param draw The cairo object used to draw itself.
+ *
+ * Render the textbox.
+ */
+void widget_draw ( widget *widget, cairo_t *d );
+
+/**
+ * @param tb Handle to the widget
+ *
+ * Free the widget and all allocated memory.
+ */
+void widget_free ( widget *widget );
+
+/**
+ * @param widget The widget toresize
+ * @param w The new width
+ * @param h The new height
+ *
+ * Resizes the widget.
+ */
+void widget_resize ( widget *widget, short w, short h );
+
+int widget_get_height ( widget *widget );
+int widget_get_width ( widget *widget );
+
+void widget_update ( widget *widget );
+void widget_queue_redraw ( widget *widget );
+gboolean widget_need_redraw ( widget *wid );
+
+gboolean widget_clicked ( widget *wid, xcb_button_press_event_t *xbe );
+
+// Signal!
+void widget_set_clicked_handler ( widget *wid, widget_clicked_cb cb, void *udata );
+
+/*@}*/
+#endif // ROFI_WIDGET_H
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index a64ed5eb..ed4e7131 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -169,6 +169,9 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
return MODE_EXIT;
}
}
+ if ( mretv & MENU_QUICK_SWITCH ) {
+ return mretv & MENU_LOWER_MASK;
+ }
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( selected_line >= pd->starts[i] &&
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 7f00edda..4b8b3169 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -41,7 +41,7 @@
#include <fcntl.h>
#include "rofi.h"
#include "settings.h"
-#include "textbox.h"
+#include "widgets/textbox.h"
#include "dialogs/dmenu.h"
#include "helper.h"
#include "xrmoptions.h"
@@ -72,8 +72,6 @@ static inline void bittoggle ( uint32_t *array, unsigned int index )
typedef struct
{
/** Settings */
- // Prompt
- char *prompt;
// Separator.
char separator;
@@ -364,7 +362,6 @@ static int dmenu_mode_init ( Mode *sw )
mode_set_private_data ( sw, g_malloc0 ( sizeof ( DmenuModePrivateData ) ) );
DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw );
- pd->prompt = "dmenu ";
pd->separator = '\n';
pd->selected_line = UINT32_MAX;
@@ -373,8 +370,6 @@ static int dmenu_mode_init ( Mode *sw )
// Input data separator.
find_arg_char ( "-sep", &( pd->separator ) );
- // Check prompt
- find_arg_str ( "-p", &( pd->prompt ) );
find_arg_uint ( "-selected-row", &( pd->selected_line ) );
// By default we print the unescaped line back.
pd->format = "s";
@@ -663,7 +658,8 @@ int dmenu_switcher_dialog ( void )
g_free ( input );
return TRUE;
}
- RofiViewState *state = rofi_view_create ( &dmenu_mode, input, pd->prompt, pd->message, menu_flags, dmenu_finalize );
+ find_arg_str ( "-p", &( dmenu_mode.display_name ) );
+ RofiViewState *state = rofi_view_create ( &dmenu_mode, input, pd->message, menu_flags, dmenu_finalize );
// @TODO we should do this better.
if ( async ) {
rofi_view_set_overlay ( state, "Loading.. " );
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 8a9768f3..6e89180a 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -42,7 +42,7 @@
#include "rofi.h"
#include "settings.h"
#include "helper.h"
-#include "textbox.h"
+#include "widgets/textbox.h"
#include "history.h"
#include "dialogs/drun.h"
diff --git a/source/dialogs/help-keys.c b/source/dialogs/help-keys.c
index dc0955e6..d5e586bf 100644
--- a/source/dialogs/help-keys.c
+++ b/source/dialogs/help-keys.c
@@ -42,7 +42,7 @@
#include "helper.h"
#include "xrmoptions.h"
#include "dialogs/help-keys.h"
-#include "textbox.h"
+#include "widgets/textbox.h"
typedef struct
{
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 397893dc..f11ba3a1 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
- unsigned int index = 0, ti = 0;
+ unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index cfcaa1b3..f7786dbd 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -47,7 +47,7 @@
#include "rofi.h"
#include "settings.h"
#include "helper.h"
-#include "textbox.h"
+#include "widgets/textbox.h"
#include "x11-helper.h"
#include "dialogs/window.h"
diff --git a/source/helper.c b/source/helper.c
index 9e420c91..ef402ed5 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -194,7 +194,7 @@ static GRegex * create_regex ( const char *input, int case_sensitive )
{
#define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
GRegex * retv = NULL;
- gchar *r;
+ gchar *r;
switch ( config.matching_method )
{
case MM_GLOB:
@@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
}
char *saveptr = NULL, *token;
- GRegex **retv = NULL;
+ GRegex **retv = NULL;
if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
diff --git a/source/rofi.c b/source/rofi.c
index 6ca7ed11..b35128c0 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -54,7 +54,7 @@
#include "mode.h"
#include "rofi.h"
#include "helper.h"
-#include "textbox.h"
+#include "widgets/textbox.h"
#include "x11-helper.h"
#include "xrmoptions.h"
#include "dialogs/dialogs.h"
@@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
.keymap = NULL,
.state = NULL,
.compose = {
- .table = NULL,
- .state = NULL
- }
+ .table = NULL,
+ .state = NULL
+}
};
char *config_path = NULL;
// Array of modi.
@@ -157,24 +157,6 @@ static void teardown ( int pfd )
// Cleanup pid file.
remove_pid_file ( pfd );
}
-
-static void __run_switcher_internal ( ModeMode mode, char *input )
-{
- char *prompt = g_strdup_printf ( "%s:", mode_get_display_name ( modi[mode] ) );
- curr_switcher = mode;
- RofiViewState * state = rofi_view_create ( modi[mode], input, prompt, NULL, MENU_NORMAL, process_result );
- g_free ( prompt );
- if ( state ) {
- rofi_view_set_active ( state );
- }
- else {
- rofi_view_set_active ( NULL );
-
- if ( rofi_view_get_active () == NULL ) {
- g_main_loop_quit ( main_loop );
- }
- }
-}
static void run_switcher ( ModeMode mode )
{
// Otherwise check if requested mode is enabled.
@@ -184,9 +166,14 @@ static void run_switcher ( ModeMode mode )
return;
}
}
- char *input = g_strdup ( config.filter );
- __run_switcher_internal ( mode, input );
- g_free ( input );
+ curr_switcher = mode;
+ RofiViewState * state = rofi_view_create ( modi[mode], config.filter, NULL, MENU_NORMAL, process_result );
+ if ( state ) {
+ rofi_view_set_active ( state );
+ }
+ if ( rofi_view_get_active () == NULL ) {
+ g_main_loop_quit ( main_loop );
+ }
}
void process_result ( RofiViewState *state )
{
@@ -197,8 +184,9 @@ void process_result ( RofiViewState *state )
MenuReturn mretv = rofi_view_get_return_value ( state );
char *input = g_strdup ( rofi_view_get_user_input ( state ) );
ModeMode retv = mode_result ( sw, mretv, &input, selected_line );
+ g_free ( input );
- ModeMode mode = curr_switcher;
+ ModeMode mode = curr_switcher;
// Find next enabled
if ( retv == NEXT_DIALOG ) {
mode = ( mode + 1 ) % num_modi;
@@ -224,9 +212,11 @@ void process_result ( RofiViewState *state )
/**
* Load in the new mode.
*/
- __run_switcher_internal ( mode, input );
+ rofi_view_switch_mode ( state, modi[mode] );
+ rofi_view_set_active ( state );
+ curr_switcher = mode;
+ return;
}
- g_free ( input );
}
rofi_view_free ( state );
}
@@ -466,22 +456,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
- {
- xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
- guint modmask;
- xkb_state_update_mask ( xkb.state,
- ksne->baseMods,
- ksne->latchedMods,
- ksne->lockedMods,
- ksne->baseGroup,
- ksne->latchedGroup,
- ksne->lockedGroup );
- modmask = x11_get_current_mask ( &xkb );
- if ( modmask == 0 ) {
- abe_trigger_release ( );
+ {
+ xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
+ guint modmask;
+ xkb_state_update_mask ( xkb.state,
+ ksne->baseMods,
+ ksne->latchedMods,
+ ksne->lockedMods,
+ ksne->baseGroup,
+