コード例 #1
0
static CORBA_char *
impl_MateComponent_Control_getWindowId (PortableServer_Servant servant,
				 const CORBA_char      *cookie,
				 CORBA_Environment     *ev)
{
	guint32        x11_id;
	MateComponentControl *control = MATECOMPONENT_CONTROL (
		matecomponent_object_from_servant (servant));
	GdkScreen *gdkscreen;
	int        screen_num;

	if (!control->priv->plug)
		create_plug (control);

	g_assert (control->priv->plug != NULL);

	screen_num = parse_cookie (cookie);
	if (screen_num != -1)
		gdkscreen = gdk_display_get_screen (
				gdk_display_get_default (), screen_num);
	else
		gdkscreen = gdk_screen_get_default ();

	gtk_window_set_screen (GTK_WINDOW (control->priv->plug), gdkscreen);

	gtk_widget_show (control->priv->plug);

	x11_id = gtk_plug_get_id (GTK_PLUG (control->priv->plug));
		
	dbgprintf ("plug id %u\n", x11_id);

	return matecomponent_control_window_id_from_x11 (x11_id);
}
コード例 #2
0
ファイル: plug.c プロジェクト: Zhang-Jia/tisan-demo
void ICACHE_FLASH_ATTR
plug_object_unpack(PARAMS* params) {
	struct plug* plug = create_plug();

	plug->off_on = get_next_uint8(params);

	plug_set(plug);
	delete_plug(plug);
}
コード例 #3
0
static void
matecomponent_control_init (MateComponentControl *control)
{
	control->priv = g_new0 (MateComponentControlPrivate, 1);

	control->priv->frame = CORBA_OBJECT_NIL;

	create_plug (control);
}
コード例 #4
0
ファイル: plug.c プロジェクト: Zhang-Jia/tisan-demo
void ICACHE_FLASH_ATTR
plug_object_pack(PARAMS * params) {
	if(NULL == params){
		PRINTF("Create first tlv param failed.\n");
		return;
	}

	struct plug* plug = create_plug();
	plug_get(plug);

	if (add_next_uint8(params, plug->off_on)){
		PRINTF("Add next param failed.\n");
		return;
	}

	delete_plug(plug);
}
コード例 #5
0
ファイル: main.c プロジェクト: kba/yad-dialog
gint
main (gint argc, gchar ** argv)
{
    GOptionContext *ctx;
    GError *err = NULL;
    gint w, h;
    gchar *str;
    gint ret = 0;

    setlocale (LC_ALL, "");

#ifdef ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);
#endif

#if !GLIB_CHECK_VERSION(2,36,0)
    g_type_init ();
#endif
    read_settings ();

    gtk_init (&argc, &argv);
    g_set_application_name ("YAD");
    yad_options_init ();

    ctx = yad_create_context ();
    /* parse YAD_OPTIONS */
    if (g_getenv ("YAD_OPTIONS"))
    {
        gchar *cmd, **args = NULL;
        gint cnt;

        cmd = g_strdup_printf ("yad %s", g_getenv ("YAD_OPTIONS"));

        if (g_shell_parse_argv (cmd, &cnt, &args, &err))
        {
            g_option_context_parse (ctx, &cnt, &args, &err);
            if (err)
            {
                g_printerr (_("Unable to parse YAD_OPTIONS: %s\n"), err->message);
                g_error_free (err);
                err = NULL;
            }
        }
        else
        {
            g_printerr (_("Unable to parse YAD_OPTIONS: %s\n"), err->message);
            g_error_free (err);
            err = NULL;
        }

        g_free (cmd);
    }
    /* parse command line */
    g_option_context_parse (ctx, &argc, &argv, &err);
    if (err)
    {
        g_printerr (_("Unable to parse command line: %s\n"), err->message);
        return -1;
    }
    yad_set_mode ();

    /* parse custom gtkrc */
    if (options.gtkrc_file)
        gtk_rc_parse (options.gtkrc_file);

    /* set default icons and icon theme */
    if (options.data.icon_theme)
    {
        settings.icon_theme = gtk_icon_theme_new ();
        gtk_icon_theme_set_custom_theme (settings.icon_theme, options.data.icon_theme);
    }
    else
        settings.icon_theme = gtk_icon_theme_get_default ();
    gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &w, &h);
    settings.big_fallback_image =
        gtk_icon_theme_load_icon (settings.icon_theme, "yad", MIN (w, h), GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
    gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
    settings.small_fallback_image =
        gtk_icon_theme_load_icon (settings.icon_theme, "yad", MIN (w, h), GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);

    /* correct separators */
    str = g_strcompress (options.common_data.separator);
    options.common_data.separator = str;
    str = g_strcompress (options.common_data.item_separator);
    options.common_data.item_separator = str;

    /* loads an extra arguments, if specified */
    if (options.rest_file)
    {
        GIOChannel *ioc;
        gchar *buf;
        guint len, line = 0;

        g_strfreev (options.extra_data);
        options.extra_data = NULL;

        ioc = g_io_channel_new_file (options.rest_file, "r", NULL);
        while (TRUE)
        {
            gint status = g_io_channel_read_line (ioc, &buf, NULL, NULL, NULL);

            if (status != G_IO_STATUS_NORMAL)
                break;

            /* remove \n at the end of string */
            len = strlen (buf);
            if (buf[len - 1] == '\n')
                buf[len - 1] = '\0';

            /* add line to arguments array */
            options.extra_data = g_realloc (options.extra_data, (line + 2) * sizeof (gchar *));
            options.extra_data[line] = g_strcompress (buf);
            options.extra_data[line + 1] = NULL;

            g_free (buf);
            line++;
        }
        g_io_channel_shutdown (ioc, FALSE, NULL);
    }

#ifndef G_OS_WIN32
    /* add YAD_PID variable */
    str = g_strdup_printf ("%d", getpid ());
    g_setenv ("YAD_PID", str, TRUE);
    /* set signal handlers */
    signal (SIGUSR1, sa_usr1);
    signal (SIGUSR2, sa_usr2);
#endif

    /* plug mode */
    if (options.plug != -1)
    {
        create_plug ();
        gtk_main ();
        shmdt (tabs);
        return ret;
    }

    switch (options.mode)
    {
    case YAD_MODE_ABOUT:
        ret = yad_about ();
        break;

    case YAD_MODE_VERSION:
        g_print ("%s (GTK+ %d.%d.%d)\n", VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version);
        break;

    case YAD_MODE_NOTIFICATION:
        ret = yad_notification_run ();
        break;

    case YAD_MODE_PRINT:
        ret = yad_print_run ();
        break;

#ifdef HAVE_HTML
    case YAD_MODE_HTML:
        /* Webkit doesn't handle focus for child dialogs when gtk_dialog_run() is used */
        /* FIXME: maybe this solution must be expanded to all dialogs */
        dialog = create_dialog ();
        g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (html_response_cb), &ret);

        gtk_widget_show_all (dialog);

        gtk_main ();
        break;
#endif

    default:
        dialog = create_dialog ();

#ifndef G_OS_WIN32
        /* add YAD_XID variable */
        str = g_strdup_printf ("0x%X", GDK_WINDOW_XID (gtk_widget_get_window (dialog)));
        g_setenv ("YAD_XID", str, TRUE);
#endif

        if (options.mode == YAD_MODE_FILE)
        {
            /* show custom confirmation dialog */
            g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (confirm_overwrite_cb), NULL);
        }
        else if (options.mode == YAD_MODE_NOTEBOOK)
            notebook_swallow_childs ();
        else if (options.mode == YAD_MODE_PANED)
            paned_swallow_childs ();

        ret = gtk_dialog_run (GTK_DIALOG (dialog));
        if (options.data.always_print)
            print_result ();
        else if (ret != YAD_RESPONSE_TIMEOUT && ret != YAD_RESPONSE_ESC)
        {
            /* standard OK button pressed */
            if (ret == YAD_RESPONSE_OK && options.data.buttons == NULL)
                print_result ();
            /* custom even button pressed */
            else if (options.data.buttons && !(ret & 1))
                print_result ();
        }
#ifndef G_OS_WIN32
        if (options.mode == YAD_MODE_NOTEBOOK)
            notebook_close_childs ();
        else if (options.mode == YAD_MODE_PANED)
            paned_close_childs ();
        /* autokill option for progress dialog */
        if (!options.kill_parent)
        {
            if ((options.mode == YAD_MODE_PROGRESS || options.mode == YAD_MODE_MULTI_PROGRESS) &&
                    options.progress_data.autokill && ret != YAD_RESPONSE_OK)
                kill (getppid (), SIGHUP);
        }
#endif
    }

#ifndef G_OS_WIN32
    /* NSIG defined in signal.h */
    if (options.kill_parent > 0 && options.kill_parent < NSIG)
        kill (getppid (), options.kill_parent);
#endif

    return ret;
}