<commit_before>/*
 *      This file is part of GPaste.
 *
 *      Copyright 2011-2012 <NAME> <<EMAIL>>
 *
 *      GPaste is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *
 *      GPaste is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with GPaste.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "gpaste-daemon.h"
#include "gpaste-clipboard-internal.h"

#include <glib/gi18n-lib.h>
#include <xcb/xtest.h>
#include <gpaste.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

static GMainLoop *main_loop;

static void
signal_handler (int signum)
{
    g_print (_("Signal %d received, exiting\n"), signum);
    g_main_loop_quit (main_loop);
}

static void
rebind (GPasteSettings   *settings,
        GPasteKeybindings keybinding,
        gpointer          user_data)
{
    GPasteKeybinding **keybindings = (GPasteKeybinding **) user_data;
    const gchar *binding;

    switch (keybinding)
    {
    case G_PASTE_KEYBINDINGS_SHOW_HISTORY:
        binding = g_paste_settings_get_show_history (settings);
        break;
    default:
        binding = NULL;
        break;
    }

    if (binding)
        g_paste_keybinding_rebind (keybindings[keybinding], binding);
}

static void
reexec (GPasteDaemon *g_paste_daemon G_GNUC_UNUSED,
        gpointer      user_data G_GNUC_UNUSED)
{
    g_main_loop_quit (main_loop);
    execl (PKGLIBEXECDIR "/gpasted", "gpasted", NULL);
}

typedef struct {
    GPasteXcbWrapper *xcb_wrapper;
    GPasteHistory    *history;
} PasteAndPopData;

static void
fake_keyboard (GPasteXcbWrapper *xcb_wrapper,
               xcb_connection_t *connection,
               xcb_screen_t     *screen,
               xcb_keysym_t      keysym,
               guint8            delay,
               guint8            event)<commit_msg>gpasted: watch paste and pop keybinding rebind<commit_after>/*
 *      This file is part of GPaste.
 *
 *      Copyright 2011-2012 <NAME> <<EMAIL>>
 *
 *      GPaste is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *
 *      GPaste is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with GPaste.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "gpaste-daemon.h"
#include "gpaste-clipboard-internal.h"

#include <glib/gi18n-lib.h>
#include <xcb/xtest.h>
#include <gpaste.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

static GMainLoop *main_loop;

static void
signal_handler (int signum)
{
    g_print (_("Signal %d received, exiting\n"), signum);
    g_main_loop_quit (main_loop);
}

static void
rebind (GPasteSettings   *settings,
        GPasteKeybindings keybinding,
        gpointer          user_data)
{
    GPasteKeybinding **keybindings = (GPasteKeybinding **) user_data;
    const gchar *binding;

    switch (keybinding)
    {
    case G_PASTE_KEYBINDINGS_SHOW_HISTORY:
        binding = g_paste_settings_get_show_history (settings);
        break;
    case G_PASTE_KEYBINDINGS_PASTE_AND_POP:
        binding = g_paste_settings_get_paste_and_pop (settings);
        break;
    default:
        binding = NULL;
        break;
    }

    if (binding)
        g_paste_keybinding_rebind (keybindings[keybinding], binding);
}

static void
reexec (GPasteDaemon *g_paste_daemon G_GNUC_UNUSED,
        gpointer      user_data G_GNUC_UNUSED)
{
    g_main_loop_quit (main_loop);
    execl (PKGLIBEXECDIR "/gpasted", "gpasted", NULL);
}

typedef struct {
    GPasteXcbWrapper *xcb_wrapper;
    GPasteHistory    *history;
} PasteAndPopData;

static void
fake_keyboard (GPasteXcbWrapper *xcb_wrapper,
               xcb_connection_t *connection,
               xcb_screen_t     *screen,
               xcb_keysym_t      keysym,
               guint8            delay,
               guint8            event)
{'fraction_non_alphanumeric': 0.08142765548194059, 'fraction_numerical': 0.005556742893780722, 'mean_word_length': 2.756019261637239, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3586654', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1462, 'n_words': 431}