示例#1
0
文件: dropzone.c 项目: trhura/rookie
GtkWidget* create_dropzone ()
{
	dropzone = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	drawzone = gtk_label_new ("drag");

	gtk_window_set_decorated (GTK_WINDOW (dropzone), FALSE);
	gtk_window_set_skip_pager_hint (GTK_WINDOW (dropzone), TRUE);
	gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dropzone), TRUE);
	gtk_window_set_keep_above (GTK_WINDOW (dropzone), TRUE);
	gtk_container_add (GTK_CONTAINER (dropzone), drawzone);
	gtk_widget_show (drawzone);

	gtk_drag_dest_set		(dropzone,
							 GTK_DEST_DEFAULT_MOTION |
							 GTK_DEST_DEFAULT_HIGHLIGHT,
							 targets, n_targets,
							 GDK_ACTION_COPY);

	gtk_widget_add_events	(dropzone,
							 GDK_BUTTON_MOTION_MASK	|
							 GDK_BUTTON_PRESS_MASK	|
							 GDK_BUTTON_RELEASE_MASK);

	gtk_window_set_geometry_hints (GTK_WINDOW (dropzone),
								   dropzone, NULL,
								   GDK_HINT_POS | GDK_HINT_USER_POS);

	g_signal_connect (dropzone, "button-press-event",
					  G_CALLBACK(on_button_press), NULL);
	g_signal_connect (dropzone, "motion-notify-event",
					  G_CALLBACK(on_motion_notify), NULL);
	g_signal_connect (dropzone, "button-release-event",
					  G_CALLBACK(on_button_release), NULL);
	g_signal_connect (dropzone, "drag-drop",
					  G_CALLBACK(on_drag_drop), NULL);
	g_signal_connect (dropzone, "drag-data-received", 
					  G_CALLBACK(on_drag_data_received), NULL);

	gtk_window_resize (GTK_WINDOW(dropzone),
					   rookie_settings_get_dropzone_width (),
					   rookie_settings_get_dropzone_height());

	gtk_window_move (GTK_WINDOW(dropzone),
					 rookie_settings_get_dropzone_xpos (),
					 rookie_settings_get_dropzone_ypos());

	return dropzone;
}
示例#2
0
/********************************************************************\
 * gnc_restore_window_size                                          *
 *   restores the position and size of the given window, if these   *
 *   these parameters have been saved earlier. Does nothing if no   *
 *   saved values are found.                                        *
 *                                                                  *
 * Args: group - the preferences group to look in for saved coords  *
 *       window - the window for which the coords are to be         *
 *                restored                                          *
 * Returns: nothing                                                 *
 \*******************************************************************/
void
gnc_restore_window_size(const char *group, GtkWindow *window)
{
    gint wpos[2], wsize[2];
    GVariant *geometry;

    ENTER("");

    g_return_if_fail(group != NULL);
    g_return_if_fail(window != NULL);

    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
        return;

    geometry = gnc_prefs_get_value (group, GNC_PREF_LAST_GEOMETRY);
    if (g_variant_is_of_type (geometry, (const GVariantType *) "(iiii)") )
    {
        gint screen_width = gdk_screen_width();
        gint screen_height = gdk_screen_height();

        g_variant_get (geometry, "(iiii)",
                       &wpos[0],  &wpos[1],
                       &wsize[0], &wsize[1]);
        DEBUG("geometry from preferences - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
              wpos[0],  wpos[1], wsize[0], wsize[1]);

        /* (-1, -1) means no geometry was saved (default preferences value) */
        if ((wpos[0] != -1) && (wpos[1] != -1))
        {
            /* Keep the window on screen if possible */
            if (screen_width != 0)
                wpos[0] = wpos[0] % screen_width;
            if (screen_height != 0)
                wpos[1] = wpos[1] % screen_height;
            DEBUG("geometry after screen adaption - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
                  wpos[0],  wpos[1], wsize[0], wsize[1]);

            gtk_window_move(window, wpos[0], wpos[1]);
        }

        /* Don't attempt to restore invalid sizes */
        if ((wsize[0] > 0) && (wsize[1] > 0))
            gtk_window_resize(window, wsize[0], wsize[1]);
    }
    g_variant_unref (geometry);

    LEAVE("");
}
示例#3
0
static gboolean on_mouse_move(GtkWidget *widget, GdkEventMotion *event,
		gpointer user_data)
{
	IBusHandwriteEngine * engine;

	engine = (IBusHandwriteEngine *) (user_data);

	GdkCursorType ct ;

	ct = event->y < 200 ?  GDK_PENCIL:GDK_CENTER_PTR;

	if( event->state & (GDK_BUTTON2_MASK |GDK_BUTTON3_MASK ))
		ct = GDK_FLEUR;
//	ct = GDK_FLEUR;

	GdkCursor * cursor = gdk_cursor_new(ct);// event->y <200 ?  GDK_PENCIL:GDK_HAND2);

	gdk_window_set_cursor(widget->window, cursor);

	gdk_cursor_unref(cursor);

	if (engine->mouse_state == GDK_BUTTON_PRESS) // 鼠标按下状态
	{
		if ((event->x > 0) && (event->y > 0) && (event->x < 199) && (event->y
				< 199))
		{


			engine->currentstroke.points
					= g_renew(GdkPoint,engine->currentstroke.points,engine->currentstroke.segments +1  );

			engine->currentstroke.points[engine->currentstroke.segments].x
					= event->x;
			engine->currentstroke.points[engine->currentstroke.segments].y
					= event->y;
			engine->currentstroke.segments++;
			printf("move, x= %lf, Y=%lf, segments = %d \n",event->x,event->y,engine->currentstroke.segments);
		}
		gdk_window_invalidate_rect(widget->window, 0, TRUE);
	}
	else if( event->state & (GDK_BUTTON2_MASK |GDK_BUTTON3_MASK ))
	{
//	printf("move start, x = %lf y = %lf \n",event->x_root -engine->lastpoint.x,event->y_root - engine->lastpoint.y);
		gtk_window_move(GTK_WINDOW(widget),event->x_root -engine->lastpoint.x,event->y_root - engine->lastpoint.y);
	}

	return FALSE;
}
示例#4
0
void
pidgin_dnd_hints_show(PidginDndHintWindowId id, gint x, gint y)
{
	GtkWidget *w;

	dnd_hints_init();

	w = hint_windows[id].widget;

	if (w && GTK_IS_WIDGET(w))
	{
		gtk_window_move(GTK_WINDOW(w), hint_windows[id].ox + x,
								 hint_windows[id].oy + y);
		gtk_widget_show(w);
	}
}
示例#5
0
void draw_background_by_rect(GtkWidget* widget, struct DisplayInfo info,
                             const gchar* xatom_name)
{
    g_message("[%s], %dx%d(%d,%d)\n", __func__, info.width, info.height,
              info.x, info.y);

    gtk_widget_set_size_request(widget, info.width, info.height);
    gtk_window_move(GTK_WINDOW(widget), info.x, info.y);

    setup_background(widget,NULL,xatom_name);
    gtk_widget_realize (widget);
    GdkWindow* gdkwindow = gtk_widget_get_window (widget);
    gdk_window_set_accept_focus(gdkwindow,FALSE);
    gdk_window_set_override_redirect (gdkwindow, TRUE);
    gtk_widget_show (widget);
}
示例#6
0
void
mud_subwindow_show(MudSubwindow *self)
{
    g_return_if_fail(MUD_IS_SUBWINDOW(self));

    if(!self->priv->view_hidden)
    {
        gtk_widget_show(self->priv->window);
        gtk_window_move(GTK_WINDOW(self->priv->window),
                self->priv->x,
                self->priv->y);
        self->priv->visible = TRUE;
    }
    else
        self->priv->view_hidden = TRUE;
}
static gboolean
_position_func (GtkWidget *window)
{
	if (x_pos == current_pos) {
		is_positioning = FALSE;
		on_awn_applet_manager_size_allocate(window, NULL, AWN_APPLET_MANAGER(settings->appman) );
		return FALSE;
	} else if (x_pos > current_pos) {
		current_pos++;
	} else {
		current_pos--;
	}
//	on_awn_applet_manager_size_allocate(window, NULL, AWN_APPLET_MANAGER(settings->appman) );
	gtk_window_move(GTK_WINDOW(window), current_pos, y_pos);
	return TRUE;
}
void  AP_UnixPreview_Annotation::_constructWindow(void)
{
	XAP_App::getApp()->rememberModelessId(getDialogId(), static_cast<XAP_Dialog_Modeless *>(this));
	UT_DEBUGMSG(("Contructing Window width %d height %d left %d top %d \n",m_width,m_height,m_left,m_top));
	m_pPreviewWindow = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_widget_set_size_request(m_pPreviewWindow, m_width, m_height);
	gtk_window_set_position(GTK_WINDOW(m_pPreviewWindow),GTK_WIN_POS_MOUSE);
	gint root_x,root_y;
	gtk_window_get_position (GTK_WINDOW(m_pPreviewWindow),&root_x,&root_y);
	m_pDrawingArea = createDrawingArea();
	gtk_widget_show(GTK_WIDGET(m_pDrawingArea));
	gtk_container_add(GTK_CONTAINER(m_pPreviewWindow), m_pDrawingArea);
	root_y -= (m_height/2 + m_Offset);
	gtk_window_move(GTK_WINDOW(m_pPreviewWindow), root_x, root_y);
	gtk_widget_show_all(GTK_WIDGET(m_pPreviewWindow));
}
示例#9
0
void ygtk_popup_window_popup (GtkWidget *widget, gint x, gint y, guint activate_time)
{
	ygtk_popup_window_frame_position (widget, &x, &y);

	gtk_grab_add (widget);
	gtk_window_move (GTK_WINDOW (widget), x, y);
	gtk_widget_grab_focus (widget);
	gtk_widget_show (widget);

	// grab this with your teeth
	if (gdk_pointer_grab (gtk_widget_get_window(widget), TRUE,
	        GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
	        NULL, NULL, activate_time) == 0)
                if (gdk_keyboard_grab (gtk_widget_get_window(widget), TRUE, activate_time) != 0)
			gdk_pointer_ungrab (activate_time);
}
/*static gboolean on_motion_notify_listing (GtkWidget* pWidget, GdkEventMotion* pMotion, CDListing *pListing)
{
	pListing->container.iMouseX = pMotion->x;
	pListing->container.iMouseY = pMotion->y;
	
	gboolean bStartAnimation = FALSE;
	cairo_dock_notify_on_container (pListing, CAIRO_DOCK_MOUSE_MOVED, pListing, &bStartAnimation);
	if (bStartAnimation)
		cairo_dock_launch_animation (CAIRO_CONTAINER (pListing));
	
	gdk_device_get_state (pMotion->device, pMotion->window, NULL, NULL);  // pour recevoir d'autres MotionNotify.
	return FALSE;
}*/
static inline void _place_listing (CDListing *pListing)
{
	int iX, iY;
	if (g_pMainDock->bHorizontalDock)
	{
		iX = g_pMainDock->iWindowPositionX + g_pMainDock->iCurrentWidth/2 - pListing->container.iWidth/2;
		iY = g_pMainDock->iWindowPositionY + (g_pMainDock->bDirectionUp ? - pListing->container.iHeight : g_pMainDock->iCurrentHeight);
	}
	else
	{
		iX = g_pMainDock->iWindowPositionY + (g_pMainDock->bDirectionUp ? - pListing->container.iWidth : g_pMainDock->iCurrentHeight);
		iY = g_pMainDock->iWindowPositionX + g_pMainDock->iCurrentWidth/2 - pListing->container.iHeight/2;
	}
	g_print ("(%d;%d) %dx%d\n", iX, iY, pListing->container.iWidth, pListing->container.iHeight);
	gtk_window_move (GTK_WINDOW (pListing->container.pWidget), iX, iY);
}
/**
 * mcm_calibrate_dialog_set_move_window:
 **/
void
mcm_calibrate_dialog_set_move_window (McmCalibrateDialog *calibrate_dialog, gboolean move_window)
{
	gint x, y;
	GtkWidget *widget;
	McmCalibrateDialogPrivate *priv = calibrate_dialog->priv;

	calibrate_dialog->priv->move_window = move_window;

	/* move the dialog out of the way, so the grey square doesn't cover it */
	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_calibrate"));
	if (move_window) {
		gtk_window_get_position (GTK_WINDOW (widget), &x, &y);
		gtk_window_move (GTK_WINDOW (widget), 10, y);
	}
}
示例#12
0
void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
    wxCHECK_RET( m_widget, wxT("invalid frame") );

    m_deferShowAllowed = true;

    // deal with the position first
    int old_x = m_x;
    int old_y = m_y;

    if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
    {
        // -1 means "use existing" unless the flag above is specified
        if ( x != -1 )
            m_x = x;
        if ( y != -1 )
            m_y = y;
    }
    else // wxSIZE_ALLOW_MINUS_ONE
    {
        m_x = x;
        m_y = y;
    }

    if ( m_x != old_x || m_y != old_y )
    {
        gtk_window_move( GTK_WINDOW(m_widget), m_x, m_y );
    }

    const wxSize oldSize(m_width, m_height);
    if (width >= 0)
        m_width = width;
    if (height >= 0)
        m_height = height;
    ConstrainSize();
    if (m_width != oldSize.x || m_height != oldSize.y)
    {
        int w, h;
        GTKDoGetSize(&w, &h);
        gtk_window_resize(GTK_WINDOW(m_widget), w, h);

        GetClientSize(&m_oldClientWidth, &m_oldClientHeight);
        wxSizeEvent event(GetSize(), GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }
}
示例#13
0
文件: gmwindow.c 项目: UIKit0/ekiga
void
gm_window_restore (GmWindow *self)
{
  int x = 0;
  int y = 0;

  gchar *size = NULL;
  gchar *position = NULL;
  gchar **couple = NULL;

  g_return_if_fail (g_strcmp0 (self->priv->key, "") && self);

  if (gtk_window_get_resizable (GTK_WINDOW (self))) {

    size = g_settings_get_string (self->priv->settings, "size");
    if (size)
      couple = g_strsplit (size, ",", 0);

    if (couple && couple [0])
      x = atoi (couple [0]);
    if (couple && couple [1])
      y = atoi (couple [1]);

    if (x > 0 && y > 0) {
      gtk_window_resize (GTK_WINDOW (self), x, y);
    }

    g_strfreev (couple);
    g_free (size);
  }

  position = g_settings_get_string (self->priv->settings, "position");
  if (position)
    couple = g_strsplit (position, ",", 0);

  if (couple && couple [0])
    x = atoi (couple [0]);
  if (couple && couple [1])
    y = atoi (couple [1]);

  if (x != 0 && y != 0)
    gtk_window_move (GTK_WINDOW (self), x, y);

  g_strfreev (couple);
  couple = NULL;
  g_free (position);
}
示例#14
0
static void
setup_settings (PtWindow *win)
{
    win->priv->editor = g_settings_new ("org.gnome.parlatype");

    g_settings_bind (
        win->priv->editor, "rewind-on-pause",
        win, "pause",
        G_SETTINGS_BIND_GET);

    g_settings_bind (
        win->priv->editor, "jump-back",
        win, "back",
        G_SETTINGS_BIND_GET);

    g_settings_bind (
        win->priv->editor, "jump-forward",
        win, "forward",
        G_SETTINGS_BIND_GET);

    /* connect to tooltip changer */

    g_signal_connect (
        win->priv->editor, "changed",
        G_CALLBACK (settings_changed_cb),
        win);

    /* Default speed
       Other solutions would be
       - Automatically save last known speed in GSettings
       - Add a default speed option to preferences dialog
       - Save last known speed in metadata for each file */
    win->priv->speed = 1.0;

    if (g_settings_get_boolean (win->priv->editor, "start-on-top")) {
        gtk_window_set_keep_above (GTK_WINDOW (win), TRUE);
    }

    if (g_settings_get_boolean (win->priv->editor, "remember-position")) {
        gtk_window_move (GTK_WINDOW (win),
                         g_settings_get_int (win->priv->editor, "x-pos"),
                         g_settings_get_int (win->priv->editor, "y-pos"));
        gtk_window_resize (GTK_WINDOW (win),
                           g_settings_get_int (win->priv->editor, "width"),
                           g_settings_get_int (win->priv->editor, "height"));
    }
}
示例#15
0
static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    int x = int(gdk_event->x);
    int y = int(gdk_event->y);

    if (gdk_event->is_hint)
    {
#ifdef __WXGTK3__
       gdk_window_get_device_position(gdk_event->window, gdk_event->device, &x, &y, NULL);
#else
       gdk_window_get_pointer(gdk_event->window, &x, &y, NULL);
#endif
    }

    if (!win->m_isDragging)
    {
        if (win->GetWindowStyle() & wxRESIZE_BORDER)
        {
            if ((x > win->m_width-14) && (y > win->m_height-14))
               gdk_window_set_cursor(gtk_widget_get_window(widget), gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
            else
               gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
            win->GTKUpdateCursor(false);
        }
        return TRUE;
    }

    win->m_oldX = x - win->m_diffX;
    win->m_oldY = y - win->m_diffY;

    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    win->m_x = x;
    win->m_y = y;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
示例#16
0
static void realized_cb(GtkWidget *widget, gpointer userdata)
{
    BudgiePanel *self;
    GdkScreen *screen;
    int height, x, y;
    GtkAllocation alloc;
    GdkWindow *window;
    long vals[4];
    GdkAtom atom;

    self = BUDGIE_PANEL(userdata);
    screen = gtk_widget_get_screen(widget);
    height = gdk_screen_get_height(screen);

    gtk_widget_get_allocation(widget, &alloc);
    x = 0;

    /* Place at bottom or top */
    if (self->position == PANEL_BOTTOM) {
        y = (height - alloc.height)+1;
    } else {
        y = 0;
    }

    gtk_window_move(GTK_WINDOW(self), x, y);

    vals[0] = 0;
    vals[1] = 0;
    if (self->position == PANEL_BOTTOM) {
        vals[2] = 0;
        vals[3] = alloc.height;
    } else {
        vals[2] = alloc.height;
        vals[3] = 0;
    }

    /* Reserve space for the bar with the window manager */
    atom = gdk_atom_intern ("_NET_WM_STRUT", FALSE);
    window = gtk_widget_get_window(GTK_WIDGET(widget));
    if (window) {
        gdk_property_change (window, atom, gdk_atom_intern("CARDINAL", FALSE),
                             32, GDK_PROP_MODE_REPLACE, (guchar *)vals, 4);
    }

    gtk_widget_queue_draw(GTK_WIDGET(self));
}
static void
photos_main_window_init (PhotosMainWindow *self)
{
  PhotosMainWindowPrivate *priv;
  GApplication *app;
  GVariant *variant;
  PhotosSearchContextState *state;
  gboolean maximized;
  const gint32 *position;
  const gint32 *size;
  gsize n_elements;

  self->priv = photos_main_window_get_instance_private (self);
  priv = self->priv;

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  priv->settings = photos_settings_new ();

  variant = g_settings_get_value (priv->settings, "window-size");
  size = g_variant_get_fixed_array (variant, &n_elements, sizeof (gint32));
  if (n_elements == 2)
    gtk_window_set_default_size (GTK_WINDOW (self), size[0], size[1]);
  g_variant_unref (variant);

  variant = g_settings_get_value (priv->settings, "window-position");
  position = g_variant_get_fixed_array (variant, &n_elements, sizeof (gint32));
  if (n_elements == 2)
    gtk_window_move (GTK_WINDOW (self), position[0], position[1]);
  g_variant_unref (variant);

  maximized = g_settings_get_boolean (priv->settings, "window-maximized");
  if (maximized)
    gtk_window_maximize (GTK_WINDOW (self));

  priv->item_mngr = g_object_ref (state->item_mngr);

  priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
  g_signal_connect_swapped (priv->mode_cntrlr,
                            "fullscreen-changed",
                            G_CALLBACK (photos_main_window_fullscreen_changed),
                            self);

  priv->sel_cntrlr = photos_selection_controller_dup_singleton ();
}
示例#18
0
static void
hildon_banner_map                               (GtkWidget *widget)
{
    if (GTK_WIDGET_CLASS (hildon_banner_parent_class)->map) {
        /* Make the banner temporary _before_ mapping it, to avoid closing
         * other temporary windows */
        gtk_window_set_is_temporary (GTK_WINDOW (widget), TRUE);

        GTK_WIDGET_CLASS (hildon_banner_parent_class)->map (widget);

        /* Make the banner non-temporary _after_ mapping it, to avoid
         * being closed by other non-temporary windows */
        gtk_window_set_is_temporary (GTK_WINDOW (widget), FALSE);

        gtk_window_move (GTK_WINDOW (widget), 0, HILDON_WINDOW_TITLEBAR_HEIGHT);
    }
}
示例#19
0
void
xmr_waiting_wnd_show(XmrWaitingWnd *wnd)
{
	GdkWindow *gdk_window;
	gboolean is_iconify = TRUE;

	g_return_if_fail(wnd != NULL);
	
	if (g_slist_length(wnd->priv->tasks) == 0)
	{
		gtk_widget_hide(GTK_WIDGET(wnd));
		return ;
	}
	
	if (wnd->priv->parent == NULL)
	{
		gtk_window_set_position(GTK_WINDOW(wnd), GTK_WIN_POS_CENTER);
	}
	else
	{
		gint px, py;
		gint pw, ph;
		gint x, y;
		gint w, h;
		
		gtk_window_get_position(wnd->priv->parent, &px, &py);
		gtk_window_get_size(wnd->priv->parent, &pw, &ph);
		
		gtk_window_get_size(GTK_WINDOW(wnd), &w, &h);
		
		x = px + (pw - w) / 2;
		y = py + (ph - h) / 2;
		
		gtk_window_move(GTK_WINDOW(wnd), x, y);
	}
	
	// only do this when parent visible
	gdk_window = gtk_widget_get_window(GTK_WIDGET(wnd->priv->parent));
	is_iconify = gdk_window_get_state(gdk_window) & GDK_WINDOW_STATE_ICONIFIED;

	if (!is_iconify && gtk_widget_get_visible(GTK_WIDGET(wnd->priv->parent)))
	{
		gtk_widget_show(GTK_WIDGET(wnd));
		gtk_widget_queue_draw(GTK_WIDGET(wnd));
	}
}
示例#20
0
文件: resizepopup.c 项目: dnk/marco
static void
update_size_window (MetaResizePopup *popup)
{
  char *str;
  int x, y;
  int width, height;
  int scale;

  g_return_if_fail (popup->size_window != NULL);

  scale = gtk_widget_get_scale_factor (GTK_WIDGET (popup->size_window));
  /* Translators: This represents the size of a window.  The first number is
   * the width of the window and the second is the height.
   */
  str = g_strdup_printf (_("%d x %d"),
                         popup->horizontal_size,
                         popup->vertical_size);

  gtk_label_set_text (GTK_LABEL (popup->size_label), str);

  g_free (str);

  gtk_window_get_size (GTK_WINDOW (popup->size_window), &width, &height);

  x = popup->rect.x + (popup->rect.width - width) / 2;
  y = popup->rect.y + (popup->rect.height - height) / 2;

  if (scale)
    {
      x = x / scale;
      y = y / scale;
    }

  if (gtk_widget_get_realized (popup->size_window))
    {
      /* using move_resize to avoid jumpiness */
      gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
                              x, y,
                              width, height);
    }
  else
    {
      gtk_window_move   (GTK_WINDOW (popup->size_window),
                         x, y);
    }
}
示例#21
0
G_MODULE_EXPORT void
on_eventbox1_button_press_event (GtkObject *object, gpointer user_data) {
  // click on eventbox (image + label)
  printf("eventbox zzzzzz\n");
  b = !b;
  if (b)
    gtk_widget_hide (window2);
  else {
    gtk_widget_show (window2);
    int x,y;
    gtk_window_get_position ((GtkWindow*)window2, &x, &y);
    if (y < 25)
      y = 25;
    gtk_window_move ((GtkWindow*)window2, x, y);
  }
  //window2 = GTK_WIDGET (gtk_builder_get_object (builder, "winMain1"));
}
示例#22
0
void
ghid_pinout_window_show (GHidPort * out, ElementType * element)
{
    GtkWidget *button, *vbox, *hbox, *preview, *top_window;
    gchar *title;
    int width, height;

    if (!element)
        return;
    title = g_strdup_printf ("%s [%s,%s]",
                             UNKNOWN (DESCRIPTION_NAME (element)),
                             UNKNOWN (NAMEONPCB_NAME (element)),
                             UNKNOWN (VALUE_NAME (element)));

    top_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (top_window), title);
    g_free (title);
    gtk_window_set_wmclass (GTK_WINDOW (top_window), "PCB_Pinout", "PCB");
    gtk_container_set_border_width (GTK_CONTAINER (top_window), 4);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (top_window), vbox);


    preview = ghid_pinout_preview_new (element);
    gtk_box_pack_start (GTK_BOX (vbox), preview, TRUE, TRUE, 0);

    ghid_pinout_preview_get_natural_size (GHID_PINOUT_PREVIEW (preview),
                                          &width, &height);

    gtk_window_set_default_size (GTK_WINDOW (top_window),
                                 width + 50, height + 50);

    hbox = gtk_hbutton_box_new ();
    gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
    g_signal_connect (G_OBJECT (button), "clicked",
                      G_CALLBACK (pinout_close_cb), top_window);
    gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

    gtk_widget_realize (top_window);
    if (Settings.AutoPlace)
        gtk_window_move (GTK_WINDOW (top_window), 10, 10);
    gtk_widget_show_all (top_window);
}
示例#23
0
void
nemo_desktop_window_update_geometry (NemoDesktopWindow *window)
{
    GdkRectangle rect;

    nemo_desktop_manager_get_window_rect_for_monitor (nemo_desktop_manager_get (),
                                                      window->details->monitor,
                                                      &rect);

    DEBUG ("NemoDesktopWindow monitor:%d: x:%d, y:%d, w:%d, h:%d",
           window->details->monitor,
           rect.x, rect.y,
           rect.width, rect.height);

    gtk_window_move (GTK_WINDOW (window), rect.x, rect.y);
    gtk_widget_set_size_request (GTK_WIDGET (window), rect.width, rect.height);
}
示例#24
0
文件: main.c 项目: P-Ruiz/geany
static void setup_window_position(void)
{
	/* interprets the saved window geometry */
	if (!prefs.save_winpos)
		return;

	if (ui_prefs.geometry[0] != -1 && ui_prefs.geometry[1] != -1)
		gtk_window_move(GTK_WINDOW(main_widgets.window),
			ui_prefs.geometry[0], ui_prefs.geometry[1]);

	if (ui_prefs.geometry[2] != -1 && ui_prefs.geometry[3] != -1)
		gtk_window_set_default_size(GTK_WINDOW(main_widgets.window),
			ui_prefs.geometry[2], ui_prefs.geometry[3]);

	if (ui_prefs.geometry[4] == 1)
		gtk_window_maximize(GTK_WINDOW(main_widgets.window));
}
static void
athena_desktop_window_init (AthenaDesktopWindow *window)
{
	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, ATHENA_TYPE_DESKTOP_WINDOW,
						       AthenaDesktopWindowDetails);

	gtk_window_move (GTK_WINDOW (window), 0, 0);

	/* shouldn't really be needed given our semantic type
	 * of _NET_WM_TYPE_DESKTOP, but why not
	 */
	gtk_window_set_resizable (GTK_WINDOW (window),
				  FALSE);

	g_object_set_data (G_OBJECT (window), "is_desktop_window", 
			   GINT_TO_POINTER (1));
}
void gldi_flying_container_drag (CairoFlyingContainer *pFlyingContainer, CairoDock *pOriginDock)
{
	if (pOriginDock->container.bIsHorizontal)
	{
		pFlyingContainer->container.iWindowPositionX = pOriginDock->container.iWindowPositionX + pOriginDock->container.iMouseX - pFlyingContainer->container.iWidth/2;
		pFlyingContainer->container.iWindowPositionY = pOriginDock->container.iWindowPositionY + pOriginDock->container.iMouseY - pFlyingContainer->container.iHeight/2;
	}
	else
	{
		pFlyingContainer->container.iWindowPositionY = pOriginDock->container.iWindowPositionX + pOriginDock->container.iMouseX - pFlyingContainer->container.iWidth/2;
		pFlyingContainer->container.iWindowPositionX = pOriginDock->container.iWindowPositionY + pOriginDock->container.iMouseY - pFlyingContainer->container.iHeight/2;
	}
	//g_print ("  on tire l'icone volante en (%d;%d)\n", pFlyingContainer->container.iWindowPositionX, pFlyingContainer->container.iWindowPositionY);
	gtk_window_move (GTK_WINDOW (pFlyingContainer->container.pWidget),
		pFlyingContainer->container.iWindowPositionX,
		pFlyingContainer->container.iWindowPositionY);
}
示例#27
0
static void raw_move(int x, int y)
{
  int xl, yl;

  if (!gwin0)
    return;

  get_win_size(gwin0, &xl, &yl);

  if (x + xl > dpy_xl)
    x = dpy_xl - xl;
  if (y + yl > dpy_yl)
    y = dpy_yl - yl;

  gtk_window_move(GTK_WINDOW(gwin0), x, y);
//  dbg("gwin0:%x raw_move %d,%d\n", gwin0, x, y);
}
示例#28
0
static gboolean notify_fadeout_timeout_cb(gpointer data)
{
	gdk_threads_enter();
	notify_window.fade_length -= FADE_SPEED;
	notify_window.fade_count++;

	gtk_window_move(GTK_WINDOW(notify_window.window),
			notify_window.x, notify_window.y + notify_window.fade_count * FADE_SPEED);

	if (notify_window.fade_length <= 0) {
		notification_window_destroy();
		gdk_threads_leave();
		return FALSE;
	}
	gdk_threads_leave();
	return TRUE;
}
示例#29
0
GtkWidget* dbgmem_display_window(void)
{ 
#ifdef WND_STATE
	if(!options3.mem.minimized)
	{
		gtk_window_resize(GTK_WINDOW(dbgw.mem), options3.mem.rect.w, options3.mem.rect.h);
		gtk_window_move(GTK_WINDOW(dbgw.mem), options3.mem.rect.x, options3.mem.rect.y);
	}
	else
		gtk_window_iconify(GTK_WINDOW(dbgw.mem));
#endif

	if(!GTK_WIDGET_VISIBLE(dbgw.mem) && !options3.mem.closed)
		gtk_widget_show(dbgw.mem);

    return dbgw.mem;
}
示例#30
0
/* This function will make sure that tilda window becomes active (gains
 * the focus) when it is called.
 *
 * This has to be the worst possible way of making this work, but it was the
 * only way to get metacity to play nicely. All the other WM's are so nice,
 * why oh why does metacity hate us so?
 */
void tilda_window_set_active (tilda_window *tw)
{
    DEBUG_FUNCTION ("tilda_window_set_active");
    DEBUG_ASSERT (tw != NULL);

    Display *x11_display = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (tw->window) );
    Window x11_window = GDK_WINDOW_XID (gtk_widget_get_window (tw->window) );
    Window x11_root_window = GDK_WINDOW_XID ( gtk_widget_get_root_window (tw->window) );
    GdkScreen *screen = gtk_widget_get_screen (tw->window);

    XEvent event;
    long mask = SubstructureRedirectMask | SubstructureNotifyMask;
    gtk_window_move (GTK_WINDOW(tw->window), config_getint ("x_pos"), config_getint ("y_pos"));
    if (gdk_x11_screen_supports_net_wm_hint (screen,
                                             gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW")))
    {
        guint32 timestamp = gtk_get_current_event_time ();
        if (timestamp == 0) {
            timestamp = gdk_x11_get_server_time(gdk_screen_get_root_window (screen));
        }
        event.xclient.type = ClientMessage;
        event.xclient.serial = 0;
        event.xclient.send_event = True;
        event.xclient.display = x11_display;
        event.xclient.window = x11_window;
        event.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW");

        event.xclient.format = 32;
        event.xclient.data.l[0] = 2; /* pager */
        event.xclient.data.l[1] = timestamp; /* timestamp */
        event.xclient.data.l[2] = 0;
        event.xclient.data.l[3] = 0;
        event.xclient.data.l[4] = 0;

        XSendEvent (x11_display, x11_root_window, False, mask, &event);
    }
    else
    {
        /* The WM doesn't support the EWMH standards. We'll print a warning and
         * try this, though it probably won't work... */
        g_printerr (_("WARNING: Window manager (%s) does not support EWMH hints\n"),
                    gdk_x11_screen_get_window_manager_name (screen));
        XRaiseWindow (x11_display, x11_window);
    }
}