summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-02-07 12:31:17 +0100
committerDave Davenport <qball@gmpclient.org>2016-02-07 12:31:17 +0100
commit69b3a360fc2beea951e9c7623970e4c79efb2f79 (patch)
tree807284161c791114d9fcf6068c88a10f5caa699e /source
parent730ee1ad4e245f5ee4bf95563bfa985a576072ca (diff)
Continue cleanup
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c38
-rw-r--r--source/view.c8
2 files changed, 24 insertions, 22 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 45e6db5f..72f5592d 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -63,6 +63,9 @@
#include "xrmoptions.h"
#include "dialogs/dialogs.h"
+#include "view.h"
+#include "view-internal.h"
+
gboolean daemon_mode = FALSE;
// Pidfile.
char *pidfile = NULL;
@@ -105,9 +108,6 @@ static int switcher_get ( const char *name )
return -1;
}
-#include "view.h"
-#include "view-internal.h"
-
/**
* @param key the Key to match
* @param modstate the modifier state to match
@@ -180,6 +180,16 @@ static int run_dmenu ()
}
static int pfd = -1;
+
+static void __run_switcher_internal ( ModeMode mode, char *input )
+{
+ char *prompt = g_strdup_printf ( "%s:", mode_get_name ( modi[mode] ) );
+ curr_switcher = mode;
+ RofiViewState * state = rofi_view_create ( modi[mode], input, prompt, NULL, MENU_NORMAL );
+ state->finalize = process_result;
+ rofi_view_set_active ( state );
+ g_free ( prompt );
+}
static void run_switcher ( ModeMode mode )
{
pfd = setup ();
@@ -194,13 +204,9 @@ static void run_switcher ( ModeMode mode )
return;
}
}
- char *input = g_strdup ( config.filter );
- char *prompt = g_strdup_printf ( "%s:", mode_get_name ( modi[mode] ) );
- curr_switcher = mode;
- RofiViewState * state = rofi_view_create ( modi[mode], input, prompt, NULL, MENU_NORMAL );
- state->finalize = process_result;
- rofi_view_set_active ( state );
- g_free ( prompt );
+ char *input = g_strdup ( config.filter );
+ __run_switcher_internal ( mode, input );
+ g_free ( input );
}
static void process_result ( RofiViewState *state )
{
@@ -234,14 +240,10 @@ static void process_result ( RofiViewState *state )
mode = retv;
}
if ( mode != MODE_EXIT ) {
- char *prompt = g_strdup_printf ( "%s:", mode_get_name ( modi[mode] ) );
- curr_switcher = mode;
- RofiViewState * state = rofi_view_create ( modi[mode], input, prompt, NULL, MENU_NORMAL );
- state->finalize = process_result;
- g_free ( prompt );
- // TODO FIX
- //g_return_val_if_fail ( state != NULL, MODE_EXIT );
- rofi_view_set_active ( state );
+ /**
+ * Load in the new mode.
+ */
+ __run_switcher_internal ( mode, input );
g_free ( input );
main_loop_x11_event_handler ( NULL );
return;
diff --git a/source/view.c b/source/view.c
index a7a16468..379fb3c0 100644
--- a/source/view.c
+++ b/source/view.c
@@ -64,6 +64,9 @@
#include "dialogs/dialogs.h"
#include "rofi.h"
+#include "view.h"
+#include "view-internal.h"
+
extern RofiViewState *current_active_menu;
extern Display *display;
extern unsigned int num_modi;
@@ -89,9 +92,6 @@ typedef enum _MainLoopEvent
ML_TIMEOUT
} MainLoopEvent;
-#include "view.h"
-#include "view-internal.h"
-
static char * get_matching_state ( void )
{
if ( config.case_sensitive ) {
@@ -1375,7 +1375,7 @@ static void menu_mainloop_iter ( RofiViewState *state, XEvent *ev )
}
}
RofiViewState *rofi_view_create ( Mode *sw,
- char *input,
+ const char *input,
char *prompt,
const char *message,
MenuFlags menu_flags )