Example #1
0
static void qtcScrolledWindowSetupConnections(GtkWidget *widget, GtkWidget *parent)
{
    if (widget && !g_object_get_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET"))
    {
        gtk_widget_add_events(widget, GDK_LEAVE_NOTIFY_MASK|GDK_ENTER_NOTIFY_MASK|GDK_FOCUS_CHANGE_MASK);
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET", (gpointer)1);
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_DESTROY_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "destroy-event", G_CALLBACK(qtcScrolledWindowDestroy), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_UNREALIZE_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "unrealize", G_CALLBACK(qtcScrolledWindowDestroy), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_STYLE_SET_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "style-set", G_CALLBACK(qtcScrolledWindowStyleSet), parent));
        if(ENTRY_MO)
        {
            g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_ENTER_ID",
                              (gpointer)g_signal_connect(G_OBJECT(widget), "enter-notify-event", G_CALLBACK(qtcScrolledWindowEnter), parent));
            g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_LEAVE_ID",
                             (gpointer)g_signal_connect(G_OBJECT(widget), "leave-notify-event", G_CALLBACK(qtcScrolledWindowLeave), parent));
        }
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_FOCUS_IN_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "focus-in-event", G_CALLBACK(qtcScrolledWindowFocusIn), parent));
        g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_FOCUS_OUT_ID",
                          (gpointer)g_signal_connect(G_OBJECT(widget), "focus-out-event", G_CALLBACK(qtcScrolledWindowFocusOut), parent));

        if(parent && ENTRY_MO)
        {
            gint          x, y;
            GtkAllocation alloc=qtcWidgetGetAllocation(parent);

            gdk_window_get_pointer(qtcWidgetGetWindow(parent), &x, &y, 0L);
            if(x>=0 && x<alloc.width && y>=0 && y<alloc.height)
                qtcScrolledWindowHover=parent;
        }
    }
}
Example #2
0
static gboolean
qtcTreeViewLeave(GtkWidget *widget, GdkEventMotion *event, void *data)
{
    QTC_UNUSED(event);
    QTC_UNUSED(data);
    if (GTK_IS_TREE_VIEW(widget)) {
        QtCTreeView *tv = qtcTreeViewLookupHash(widget, false);
        if (tv) {
            GtkTreeView *treeView = GTK_TREE_VIEW(widget);
            QtcRect rect = {0, 0, -1, -1 };
            QtcRect alloc = qtcWidgetGetAllocation(widget);

            if (tv->path && tv->column) {
                gtk_tree_view_get_background_area(
                    treeView, tv->path, tv->column, (GdkRectangle*)&rect);
            }
            if (tv->fullWidth) {
                rect.x = 0;
                rect.width = alloc.width;
            }
            if (tv->path) {
                gtk_tree_path_free(tv->path);
            }
            tv->path = NULL;
            tv->column = NULL;

            gtk_tree_view_convert_bin_window_to_widget_coords(
                treeView, rect.x, rect.y, &rect.x, &rect.y);
            gtk_widget_queue_draw_area(
                widget, rect.x, rect.y, rect.width, rect.height);
        }
    }
    return false;
}
Example #3
0
static gboolean
qtcWindowMap(GtkWidget *widget, GdkEventKey *event, void *user_data)
{
    QTC_UNUSED(event);
    QTC_UNUSED(user_data);
    QTC_DEF_WIDGET_PROPS(props, widget);
    qtcWindowSetProperties(widget, qtcWidgetProps(props)->windowOpacity);

    if (opts.menubarHiding & HIDE_KWIN) {
        GtkWidget *menuBar = qtcWindowGetMenuBar(widget, 0);

        if (menuBar) {
            int size = (gtk_widget_get_visible(menuBar) ?
                        qtcWidgetGetAllocation(menuBar).height : 0);

            qtcMenuEmitSize(menuBar, size);
            qtcWindowMenuBarDBus(widget, size);
        }
    }

    if(opts.statusbarHiding&HIDE_KWIN)
    {
        GtkWidget *statusBar=qtcWindowGetStatusBar(widget, 0);

        if(statusBar)
            qtcWindowStatusBarDBus(widget, !gtk_widget_get_visible(statusBar));
    }
    return false;
}
Example #4
0
static gboolean
qtcMenuShellButtonPress(GtkWidget *widget, GdkEventButton *event, void *data)
{
    QTC_UNUSED(data);
    if (GTK_IS_MENU_BAR(widget)) {
        // QtCurve's menubars have a 2 pixel border ->
        // but want the left/top to be 'active'...
        int nx, ny;
        gdk_window_get_origin(gtk_widget_get_window(widget), &nx, &ny);
        if ((event->x_root - nx) <= 2.0 || (event->y_root - ny) <= 2.0) {
            if ((event->x_root - nx) <= 2.0) {
                event->x_root += 2.0;
            }
            if ((event->y_root - ny) <= 2.0) {
                event->y_root += 2.0;
            }

            GtkMenuShell *menuShell = GTK_MENU_SHELL(widget);
            GList *children =
                gtk_container_get_children(GTK_CONTAINER(menuShell));
            bool rv = false;
            for (GList *child = children;child;child = child->next) {
                GtkWidget *item = child->data;
                QtcRect alloc = qtcWidgetGetAllocation(item);
                int cx = alloc.x + nx;
                int cy = alloc.y + ny;
                int cw = alloc.width;
                int ch = alloc.height;
                if (cx <= event->x_root && cy <= event->y_root &&
                    (cx + cw) > event->x_root && (cy + ch) > event->y_root) {
                    if (menuIsSelectable(item)) {
                        if (event->type == GDK_BUTTON_PRESS) {
                            if (item != menuShell->active_menu_item) {
                                menuShell->active = false;
                                gtk_menu_shell_select_item(menuShell, item);
                                menuShell->active = true;
                            } else {
                                menuShell->active = true;
                                gtk_menu_shell_deselect(menuShell);
                                menuShell->active = false;
                            }
                        }
                        rv = true;
                    }
                    break;
                }
            }
            if (children) {
                g_list_free(children);
            }
            return rv;
        }
    }
    return false;
}
Example #5
0
static gboolean
qtcWindowSizeRequest(GtkWidget *widget)
{
    if (widget && (!(qtcIsFlatBgnd(opts.bgndAppearance)) ||
                   IMG_NONE != opts.bgndImage.type)) {
        QtcRect alloc = qtcWidgetGetAllocation(widget);
        QtcRect rect = {0, 0, 0, 0};
        if (qtcIsFlat(opts.bgndAppearance) &&
            IMG_NONE != opts.bgndImage.type) {
            EPixPos pos = (IMG_FILE == opts.bgndImage.type ?
                           opts.bgndImage.pos : PP_TR);
            if (opts.bgndImage.type == IMG_FILE) {
                qtcLoadBgndImage(&opts.bgndImage);
            }
            switch (pos) {
            case PP_TL:
                rect.width  = opts.bgndImage.width + 1;
                rect.height = opts.bgndImage.height + 1;
                break;
            case PP_TM:
            case PP_TR:
                rect.width = alloc.width;
                rect.height = (opts.bgndImage.type == IMG_FILE ?
                               opts.bgndImage.height :
                               RINGS_HEIGHT(opts.bgndImage.type)) + 1;
                break;
            case PP_LM:
            case PP_BL:
                rect.width = opts.bgndImage.width + 1;
                rect.height = alloc.height;
                break;
            case PP_CENTRED:
            case PP_BR:
            case PP_BM:
            case PP_RM:
                rect.width = alloc.width;
                rect.height = alloc.height;
                break;
            }
            if (alloc.width < rect.width) {
                rect.width = alloc.width;
            }
            if (alloc.height < rect.height) {
                rect.height = alloc.height;
            }
        } else {
            rect.width = alloc.width, rect.height = alloc.height;
        }
        gdk_window_invalidate_rect(gtk_widget_get_window(widget),
                                   (GdkRectangle*)&rect, false);
    }
    return false;
}
Example #6
0
gboolean
qtcWindowSetup(GtkWidget *widget, int opacity)
{
    QTC_DEF_WIDGET_PROPS(props, widget);
    if (widget && !qtcWidgetProps(props)->windowHacked) {
        qtcWidgetProps(props)->windowHacked = true;
        if (!qtcIsFlatBgnd(opts.bgndAppearance) ||
            opts.bgndImage.type != IMG_NONE) {
            QtCWindow *window = qtcWindowLookupHash(widget, true);
            if (window) {
                QtcRect alloc = qtcWidgetGetAllocation(widget);
                qtcConnectToProp(props, windowConfigure, "configure-event",
                                 qtcWindowConfigure, window);
                window->width = alloc.width;
                window->height = alloc.height;
                window->widget = widget;
            }
        }
        qtcConnectToProp(props, windowDestroy, "destroy-event",
                         qtcWindowDestroy, NULL);
        qtcConnectToProp(props, windowStyleSet, "style-set",
                         qtcWindowStyleSet, NULL);
        if ((opts.menubarHiding & HIDE_KEYBOARD) ||
            (opts.statusbarHiding & HIDE_KEYBOARD)) {
            qtcConnectToProp(props, windowKeyRelease, "key-release-event",
                             qtcWindowKeyRelease, NULL);
        }
        qtcWidgetProps(props)->windowOpacity = (unsigned short)opacity;
        qtcWindowSetProperties(widget, (unsigned short)opacity);

        if ((opts.menubarHiding & HIDE_KWIN) ||
            (opts.statusbarHiding & HIDE_KWIN) || 100 != opacity)
            qtcConnectToProp(props, windowMap, "map-event", qtcWindowMap, NULL);
        if (opts.shadeMenubarOnlyWhenActive || BLEND_TITLEBAR ||
            opts.menubarHiding || opts.statusbarHiding)
            qtcConnectToProp(props, windowClientEvent, "client-event",
                             qtcWindowClientEvent, NULL);
        return true;
    }
    return false;
}
Example #7
0
static gboolean
qtcWindowToggleMenuBar(GtkWidget *widget)
{
    GtkWidget *menuBar = qtcWindowGetMenuBar(widget, 0);

    if (menuBar) {
        int size = 0;
        qtcSetMenuBarHidden(qtSettings.appName, gtk_widget_get_visible(menuBar));
        if (gtk_widget_get_visible(menuBar)) {
            gtk_widget_hide(menuBar);
        } else {
            size = qtcWidgetGetAllocation(menuBar).height;
            gtk_widget_show(menuBar);
        }

        qtcMenuEmitSize(menuBar, size);
        qtcWindowMenuBarDBus(widget, size);
        return true;
    }
    return false;
}
Example #8
0
static gboolean
qtcMenuShellMotion(GtkWidget *widget, GdkEventMotion *event, void *data)
{
    QTC_UNUSED(data);
    QTC_UNUSED(event);
    if (GTK_IS_MENU_SHELL(widget)) {
        int pointer_x, pointer_y;
        GdkModifierType pointer_mask;

        gdk_window_get_pointer(gtk_widget_get_window(widget), &pointer_x,
                               &pointer_y, &pointer_mask);

        if (GTK_IS_CONTAINER(widget)) {
            GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
            for (GList *child = children;child;child = g_list_next(child)) {
                if ((child->data) && GTK_IS_WIDGET(child->data) &&
                    (gtk_widget_get_state(GTK_WIDGET(child->data)) !=
                     GTK_STATE_INSENSITIVE)) {
                    QtcRect alloc =
                        qtcWidgetGetAllocation(GTK_WIDGET(child->data));

                    if ((pointer_x >= alloc.x) && (pointer_y >= alloc.y) &&
                        (pointer_x < (alloc.x + alloc.width)) &&
                        (pointer_y < (alloc.y + alloc.height))) {
                        gtk_widget_set_state(GTK_WIDGET(child->data),
                                             GTK_STATE_PRELIGHT);
                    } else {
                        gtk_widget_set_state(GTK_WIDGET(child->data),
                                             GTK_STATE_NORMAL);
                    }
                }
            }
            if (children) {
                g_list_free(children);
            }
        }
    }

    return false;
}
Example #9
0
static void
qtcTreeViewUpdatePosition(GtkWidget *widget, int x, int y)
{
    if (GTK_IS_TREE_VIEW(widget)) {
        QtCTreeView *tv = qtcTreeViewLookupHash(widget, false);
        if (tv) {
            GtkTreeView *treeView = GTK_TREE_VIEW(widget);
            GtkTreePath *path = NULL;
            GtkTreeViewColumn *column = NULL;

            gtk_tree_view_get_path_at_pos(treeView, x, y, &path,
                                          &column, 0L, 0L);

            if (!qtcTreeViewSamePath(tv->path, path)) {
                // prepare update area
                // get old rectangle
                QtcRect oldRect = {0, 0, -1, -1 };
                QtcRect newRect = {0, 0, -1, -1 };
                QtcRect updateRect;
                QtcRect alloc = qtcWidgetGetAllocation(widget);

                if (tv->path && tv->column) {
                    gtk_tree_view_get_background_area(
                        treeView, tv->path, tv->column,
                        (GdkRectangle*)&oldRect);
                }
                if (tv->fullWidth) {
                    oldRect.x = 0;
                    oldRect.width = alloc.width;
                }

                // get new rectangle and update position
                if (path && column) {
                    gtk_tree_view_get_background_area(
                        treeView, path, column, (GdkRectangle*)&newRect);
                }
                if (path && column && tv->fullWidth) {
                    newRect.x = 0;
                    newRect.width = alloc.width;
                }

                // take the union of both rectangles
                if (oldRect.width > 0 && oldRect.height > 0) {
                    if (newRect.width > 0 && newRect.height > 0) {
                        qtcRectUnion(&oldRect, &newRect, &updateRect);
                    } else {
                        updateRect = oldRect;
                    }
                } else {
                    updateRect = newRect;
                }

                // store new cell info
                if (tv->path)
                    gtk_tree_path_free(tv->path);
                tv->path = path ? gtk_tree_path_copy(path) : NULL;
                tv->column = column;

                // convert to widget coordinates and schedule redraw
                gtk_tree_view_convert_bin_window_to_widget_coords(
                    treeView, updateRect.x, updateRect.y,
                    &updateRect.x, &updateRect.y);
                gtk_widget_queue_draw_area(
                    widget, updateRect.x, updateRect.y,
                    updateRect.width, updateRect.height);
            }

            if (path) {
                gtk_tree_path_free(path);
            }
        }
    }
}