Exemplo n.º 1
0
static void
location_clicked (GtkButton * button, ESource * source)
{
    GtkDialog *dialog;
    char *ruri_save;
    const char *ruri;
    int resp;

    dialog = create_store_view_dialog (source);

    if (dialog == NULL)
        return;

    ruri_save = (char *) e_source_peek_relative_uri (source);

    if (ruri_save != NULL) {
        ruri_save = g_strdup (ruri_save);
    }

    resp = gtk_dialog_run (dialog);

    if (resp == GTK_RESPONSE_OK) {
        char *nruri = NULL;

        ruri = e_source_peek_relative_uri (source);

        if (is_toplevel (ruri)) {
            ruri = _("Toplevel");
        } else {
            char *match;

            match = g_strrstr (ruri, "/");
            nruri = g_strndup (ruri, match - ruri);
            ruri = nruri;
        }

        gtk_button_set_label (button, ruri);

        g_free (nruri);

    } else {
        e_source_set_relative_uri (source, ruri_save);
    }

    g_free (ruri_save);
    gtk_widget_destroy (GTK_WIDGET (dialog));
}
Exemplo n.º 2
0
static void
sn_changed (ESource * source, gpointer data)
{
    const char *name;
    const char *ruri;

    //char       **old_name;
    char **sv;
    char *nruri;
    guint n;
    gulong *sig_id;

    sig_id = (gulong *) data;
    name = e_source_peek_name (source);
    ruri = e_source_peek_relative_uri (source);

    /* Must block signal emission or this will give
     * a nice infinit chain and stack overflow */
    g_signal_handler_block (source, *sig_id);

    if (is_toplevel (ruri)) {
        e_source_set_relative_uri (source, name);
    } else {
        sv = g_strsplit (ruri, "/", -1);
        n = g_strv_length (sv);

        if (n < 2) {
            g_print ("Error during split! (%s)\n", ruri);
            g_strfreev (sv);
            return;
        }

        g_free (sv[n - 1]);
        sv[n - 1] = g_strdup (name);

        nruri = g_strjoinv ("/", sv);
        e_source_set_relative_uri (source, nruri);
        g_free (nruri);
        g_strfreev (sv);
    }

    g_signal_handler_unblock (source, *sig_id);

    g_print ("RURI: %s\n", e_source_peek_relative_uri (source));
}
Exemplo n.º 3
0
static LRESULT CALLBACK
wndprocret_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
    HWND hwnd;
    UINT msg;
    WPARAM wparam;
    LPARAM lparam;

    LONG style;

    if (!g_wm_seamless_focus)
        goto end;

    if (code < 0)
        goto end;

    hwnd = ((CWPRETSTRUCT *) details)->hwnd;
    msg = ((CWPRETSTRUCT *) details)->message;
    wparam = ((CWPRETSTRUCT *) details)->wParam;
    lparam = ((CWPRETSTRUCT *) details)->lParam;

    if (!is_toplevel(hwnd)) {
        goto end;
    }

    style = GetWindowLong(hwnd, GWL_STYLE);

    switch (msg) {
    case WM_WINDOWPOSCHANGED:
    {
        WINDOWPOS *wp = (WINDOWPOS *) lparam;

        if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
            break;

        if (!(wp->flags & SWP_NOZORDER))
            update_zorder(hwnd);

        break;
    }


    case WM_SETTEXT:
    {
        unsigned short title[150];
        if (!(style & WS_VISIBLE))
            break;
        /* We cannot use the string in lparam because
           we need unicode. */
        GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));
        vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd,
                       vchannel_strfilter_unicode(title), 0);
        break;
    }

    case WM_SETICON:
    {
        HICON icon;
        if (!(style & WS_VISIBLE))
            break;

        /*
         * Somehow, we never get WM_SETICON for the small icon.
         * So trigger a read of it every time the large one is
         * changed.
         */
        icon = get_icon(hwnd, 0);
        if (icon) {
            update_icon(hwnd, icon, 0);
            DeleteObject(icon);
        }
    }

    default:
        break;
    }

    if (msg == g_wm_seamless_focus) {
        /* For some reason, SetForegroundWindow() on menus
           closes them. Ignore focus requests for menu windows. */
        if ((GetForegroundWindow() != hwnd) && !is_menu(hwnd))
            SetForegroundWindow(hwnd);

        vchannel_write("ACK", "%u", g_shdata->blocked_focus_serial);
    }

end:
    return CallNextHookEx(g_wndprocret_hook, code, cur_thread, details);
}
Exemplo n.º 4
0
static LRESULT CALLBACK
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
    HWND hwnd;
    UINT msg;
    WPARAM wparam;
    LPARAM lparam;

    LONG style;

    if (!g_wm_seamless_focus)
        goto end;

    if (code < 0)
        goto end;

    hwnd = ((CWPSTRUCT *) details)->hwnd;
    msg = ((CWPSTRUCT *) details)->message;
    wparam = ((CWPSTRUCT *) details)->wParam;
    lparam = ((CWPSTRUCT *) details)->lParam;

    if (!is_toplevel(hwnd)) {
        goto end;
    }

    style = GetWindowLong(hwnd, GWL_STYLE);

    switch (msg) {
    case WM_WINDOWPOSCHANGED:
    {
        WINDOWPOS *wp = (WINDOWPOS *) lparam;

        if (wp->flags & SWP_SHOWWINDOW) {
            unsigned short title[150];
            int state;
            DWORD pid;
            int flags;
            HICON icon;
            LONG exstyle;

            exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
            GetWindowThreadProcessId(hwnd, &pid);

            flags = 0;
            if (style & DS_MODALFRAME)
                flags |= SEAMLESS_CREATE_MODAL;
            // handle always on top
            if (exstyle & WS_EX_TOPMOST)
                flags |= SEAMLESS_CREATE_TOPMOST;

            vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x",
                           hwnd_to_long(hwnd), (long) pid,
                           hwnd_to_long(get_parent(hwnd)), flags);

            GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));

            vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd,
                           vchannel_strfilter_unicode(title), 0);

            icon = get_icon(hwnd, 1);
            if (icon) {
                update_icon(hwnd, icon, 1);
                DeleteObject(icon);
            }

            icon = get_icon(hwnd, 0);
            if (icon) {
                update_icon(hwnd, icon, 0);
                DeleteObject(icon);
            }

            if (style & WS_MAXIMIZE)
                state = 2;
            else if (style & WS_MINIMIZE)
                state = 1;
            else
                state = 0;

            update_position(hwnd);

            vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", hwnd,
                           state, 0);
        }

        if (wp->flags & SWP_HIDEWINDOW)
            vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0);

        if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
            break;

        if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))
            update_position(hwnd);

        break;
    }

    case WM_SETICON:
        if (!(style & WS_VISIBLE))
            break;

        switch (wparam) {
        case ICON_BIG:
            if (lparam)
                update_icon(hwnd, (HICON) lparam, 1);
            else
                vchannel_write("DELICON", "0x%08lx,RGBA,32,32", hwnd);
            break;
        case ICON_SMALL:
        case 2:
            if (lparam)
                update_icon(hwnd, (HICON) lparam, 0);
            else
                vchannel_write("DELICON", "0x%08lx,RGBA,16,16", hwnd);
            break;
        default:
            debug("Weird icon size %d", (int) wparam);
        }

        break;

    case WM_SIZE:
        if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
            break;
        update_position(hwnd);
        break;

    case WM_MOVE:
        if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
            break;
        update_position(hwnd);
        break;

    case WM_DESTROY:
        if (!(style & WS_VISIBLE))
            break;
        vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0);
        break;

    default:
        break;
    }

end:
    return CallNextHookEx(g_wndproc_hook, code, cur_thread, details);
}
Exemplo n.º 5
0
static LRESULT CALLBACK
wndprocret_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
	HWND hwnd;
	UINT msg;
	WPARAM wparam;
	LPARAM lparam;

	LONG style;

	if (code < 0)
		goto end;

	hwnd = ((CWPRETSTRUCT *) details)->hwnd;
	msg = ((CWPRETSTRUCT *) details)->message;
	wparam = ((CWPRETSTRUCT *) details)->wParam;
	lparam = ((CWPRETSTRUCT *) details)->lParam;

	if (!is_toplevel(hwnd) || is_seamless_internal_windows(hwnd))
	{
		goto end;
	}

	style = GetWindowLong(hwnd, GWL_STYLE);

	switch (msg)
	{
		case WM_WINDOWPOSCHANGED:
			{
				WINDOWPOS *wp = (WINDOWPOS *) lparam;

				if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
					break;

				if (!(wp->flags & SWP_NOZORDER))
					//update_zorder(hwnd) --> WinDev applications bring if we do that;
					break;

				break;
			}


		case WM_SETTEXT:
			{
				if (!(style & WS_VISIBLE))
					break;
				/* We cannot use the string in lparam because
				   we need unicode. */
				if (getWindowFromHistory(hwnd) == NULL){
					create_window(hwnd);
				}
				else{
					BOOLEAN titleIsTheSame = TRUE;
					int i = 0;
					unsigned short *title;
					node* window = getWindowFromHistory(hwnd);
					if (window == NULL) {
						break;
					}

					title = malloc(sizeof(unsigned short) * TITLE_SIZE);
					if (title == NULL)
						break;

					GetWindowTextW(hwnd, title, TITLE_SIZE);

					if (window->title != NULL) {
						for (i = 0; i < TITLE_SIZE; i++) {
							if (title[i] != window->title[i]) {
								titleIsTheSame = FALSE;
								break;
							}
						}
					}
					else {
						titleIsTheSame = FALSE;
					}

					if (titleIsTheSame) {
						free(title);
						break;
					}

					vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd, vchannel_strfilter_unicode(title), 0);

					if (window->title) {
						free(window->title);
						window->title;
					}
					window->title = title;
				}
				break;
			}

		case WM_SETICON:
			{
				HICON icon;

				/*
				 * Somehow, we never get WM_SETICON for the small icon.
				 * So trigger a read of it every time the large one is
				 * changed.
				 */
				icon = get_icon(hwnd, 0);
				if (icon)
				{
					update_icon(hwnd, icon, 0);
					DeleteObject(icon);
				}
				break;
			}

		case WM_ACTIVATE:
			// http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx
			if (wparam == 0)  // WA_INACTIVE
				break;

		case WM_SETFOCUS: // Focus gained
			if (hwnd == g_last_focused_window)
				break;

			WaitForSingleObject(g_mutex, INFINITE);
			g_last_focused_window = hwnd;
			ReleaseMutex(g_mutex);

			{
				node* window;

				window = getWindowFromHistory(hwnd);
				if (window == NULL) {
					window = addHWDNToHistory(hwnd);
					if (window == NULL)
						goto end;

					window->focus = TRUE;
					goto end;
				}
			}

			vchannel_block();
			vchannel_write("FOCUS", "0x%08lx", hwnd);
			vchannel_unblock();

			break;

		default:
			break;
	}

      end:
	return CallNextHookEx(g_wndprocret_hook, code, cur_thread, details);
}
Exemplo n.º 6
0
static LRESULT CALLBACK
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
	HWND hwnd;
	UINT msg;
	WPARAM wparam;
	LPARAM lparam;

	LONG style;

	if (code < 0)
		goto end;

	hwnd = ((CWPSTRUCT *) details)->hwnd;
	msg = ((CWPSTRUCT *) details)->message;
	wparam = ((CWPSTRUCT *) details)->wParam;
	lparam = ((CWPSTRUCT *) details)->lParam;
	
	if (!is_toplevel(hwnd) || is_seamless_internal_windows(hwnd))
	{
		goto end;
	}

	style = GetWindowLong(hwnd, GWL_STYLE);

	switch (msg)
	{
		case WM_SHOWWINDOW:
			{
				create_window(hwnd);
				break;
			}
		case WM_WINDOWPOSCHANGED:
			{
				WINDOWPOS *wp = (WINDOWPOS *) lparam;

				if (wp->flags & SWP_SHOWWINDOW)
				{
					create_window(hwnd);
				}

				if (wp->flags & SWP_HIDEWINDOW)
					destroy_window(hwnd);

				if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
					break;

				if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))
					update_position(hwnd);

				break;
			}

		case WM_SETICON:
			if (!(style & WS_VISIBLE))
				break;

			switch (wparam)
			{
				case ICON_BIG:
					if (lparam)
						update_icon(hwnd, (HICON) lparam, 1);
					else
						vchannel_write("DELICON", "0x%08lx,RGBA,32,32",
							       hwnd);
					break;
				case ICON_SMALL:
				case 2:
					if (lparam)
						update_icon(hwnd, (HICON) lparam, 0);
					else
						vchannel_write("DELICON", "0x%08lx,RGBA,16,16",
							       hwnd);
					break;
				default:
					debug("Weird icon size %d", (int) wparam);
			}

			break;

		case WM_SIZE:
			{
				HWND blocked_hwnd;
				int blocked;
				unsigned int serial;
				node* sw;
				int state;
				
				sw = getWindowFromHistory(hwnd);
				if (! sw)
					break;

				WaitForSingleObject(g_mutex, INFINITE);
				blocked_hwnd = g_blocked_state_hwnd;
				serial = g_blocked_state_serial;
				blocked = g_blocked_state;
				ReleaseMutex(g_mutex);

				switch (wparam) {
					case SIZE_MAXIMIZED:
						state = 2;
						break;
					case SIZE_MINIMIZED:
						state = 1;
						break;
					case SIZE_RESTORED:
						state = 0;
						break;
				}

				if (sw->state == state) {
					break;
				}

				sw->state = state;
				if ((blocked_hwnd == hwnd) && (blocked == state)) {
					vchannel_write("ACK", "%u", serial);
				}
				else {
					vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x",
						  hwnd, sw->state, 0);
				}
			}

			if (wparam == SIZE_MAXIMIZED || !(style & WS_VISIBLE) || (style & WS_MINIMIZE))
				break;
			update_position(hwnd);
			break;

		case WM_MOVE:
			if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
				break;
			update_position(hwnd);
			break;

		case WM_DESTROY:
			if (!(style & WS_VISIBLE))
				break;
			destroy_window(hwnd);
			break;

		default:
			break;
	}

      end:
	return CallNextHookEx(g_wndproc_hook, code, cur_thread, details);
}
Exemplo n.º 7
0
static GtkWidget *
sx_config_source_setup_ui (GtkWidget * parent, ESource * source)
{
    GtkWidget *button;
    GtkWidget *label;
    GtkWidget *text;
    GtkWidget *ret;
    char *uri_text;
    const char *uid;
    const char *ruri;
    const char *name;
    gboolean new_source;
    gulong *sig_id;

    uri_text = e_source_get_uri (source);

    if (!g_str_has_prefix (uri_text, "scalix")) {
        g_free (uri_text);
        return NULL;
    }
    g_free (uri_text);

    g_assert (GTK_IS_BOX (parent) || GTK_IS_TABLE (parent));

    /* Label */
    label = gtk_label_new_with_mnemonic (_("_Location:"));
    gtk_widget_show (label);

    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

    button = gtk_button_new ();

    g_signal_connect (G_OBJECT (button),
                      "clicked", G_CALLBACK (location_clicked), source);

    gtk_widget_show (button);

    uid = e_source_peek_uid (source);
    ruri = e_source_peek_relative_uri (source);
    name = e_source_peek_name (source);

    /* new source */
    new_source = (ruri == NULL || ruri[0] == '\0' || g_str_equal (ruri, uid));

    if (new_source) {

        if (name == NULL || name[0] == '\0')
            name = "nonameyet";

        e_source_set_relative_uri (source, name);
    }

    if (is_toplevel (ruri)) {
        text = gtk_label_new (_("Toplevel"));
    } else {
        text = gtk_label_new (ruri);
    }

    gtk_widget_show (text);

#if (GTK_CHECK_VERSION(2, 6, 0))
    gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ELLIPSIZE_START);
#endif
    gtk_container_add (GTK_CONTAINER (button), text);

    sig_id = (gulong *) g_malloc0 (sizeof (gulong));

    *sig_id = g_signal_connect (source,
                                "changed", G_CALLBACK (sn_changed), sig_id);

    /* We do not support renames (yet?!) */
    if (new_source == FALSE) {

        gtk_widget_set_sensitive (button, FALSE);

        /* Nasty nasty hack ey ey ey */
        find_entries_and_set_sensitive (parent, FALSE);

    }

    /* attach it */
    if (!GTK_IS_BOX (parent)) {
        int row;

        row = GTK_TABLE (parent)->nrows;

        gtk_table_attach (GTK_TABLE (parent),
                          label, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);

        gtk_table_attach (GTK_TABLE (parent),
                          button, 1, 2,
                          row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);

        /* HACK for to have a return value != NULL */
        ret = button;

    } else {
        GtkWidget *hbox;

        hbox = gtk_hbox_new (FALSE, 6);
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 6);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 6);
        gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 6);
        gtk_widget_show_all (hbox);
        ret = hbox;
    }

    return ret;
}