Пример #1
0
void gMainWindow::configure()
{
	int h;
	
	if (bufW < 1 || bufH < 1)
		return;
	
	h = menuBarHeight();
	
	//fprintf(stderr, "configure: %s: %d %d - %d %d\n", name(), isMenuBarVisible(), h, width(), height());
	
	if (isMenuBarVisible())
	{
		gtk_fixed_move(layout, GTK_WIDGET(menuBar), 0, 0);
		if (h > 1)
			gtk_widget_set_size_request(GTK_WIDGET(menuBar), width(), h);
		gtk_fixed_move(layout, widget, 0, h);
		gtk_widget_set_size_request(widget, width(), Max(0, height() - h));
	}
	else
	{
		if (layout)
		{
			if (menuBar)
				gtk_fixed_move(layout, GTK_WIDGET(menuBar), 0, -h);
			gtk_fixed_move(layout, widget, 0, 0);
		}
		gtk_widget_set_size_request(widget, width(), height());
	}
}
Пример #2
0
int main(int argc, char *argv[])
{
	pthread_t v4l_thread;
	struct _Ourarg ourarg;


	if(XInitThreads () == 0)
		printf(" XInitThreads err\n");

	if(!g_thread_supported()) 
		g_thread_init(NULL);
	gdk_threads_init();
	  
	gtk_init(&argc, &argv);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
///////////////////////////////////////////////////////
	fixed = gtk_fixed_new ();
	gtk_container_add(GTK_CONTAINER(window),fixed);
	gtk_widget_show(fixed);
      
	label = gtk_label_new ("123456789012345678901234567890");
	gtk_container_add (GTK_CONTAINER (fixed), label);
	gtk_fixed_move (GTK_FIXED (fixed), label, 0, 10); 
	gtk_widget_show(label);

    gtk_fixed_move (GTK_FIXED (fixed),
                                    label,
                                    200,
                                    0); 

    gtk_window_set_resizable(GTK_WINDOW(window),TRUE);
    gtk_window_resize(GTK_WINDOW(window), window_width,window_height);

	gtk_widget_show(window);
	 
/*
	if( pthread_create(&v4l_thread, NULL, v4l_show, NULL) == 0)
		printf("thread create Ok, v4l show thread start \n");
	else
		printf("thread create Err\n");
*/
//	gtk_timeout_add (1000, RepaintClock, (gpointer) label);

	g_thread_create(thread_go, &ourarg, FALSE, NULL);
	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();


	printf("gtk main end \n");

	return 0;
}
Пример #3
0
void VLGbutton::moveTo(int nx,int ny) {
    if (parent)	{
        gtk_fixed_move (GTK_FIXED (((VLGform*)parent)->fixed), widget, nx, ny);
        x=nx;
        y=ny;
    }
}
Пример #4
0
static void main_window_move_to_monitor (MainWindow* self, Monitor* monitor) {
	GtkBox* _tmp0_;
	Monitor* _tmp1_;
	gint _tmp2_;
	Monitor* _tmp3_;
	gint _tmp4_;
	Background* _tmp5_;
	Monitor* _tmp6_;
	Background* _tmp7_;
	GtkBox* _tmp8_;
	Monitor* _tmp9_;
	gint _tmp10_;
	Monitor* _tmp11_;
	gint _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (monitor != NULL);
	_tmp0_ = self->priv->login_box;
	_tmp1_ = monitor;
	_tmp2_ = _tmp1_->width;
	_tmp3_ = monitor;
	_tmp4_ = _tmp3_->height;
	gtk_widget_set_size_request ((GtkWidget*) _tmp0_, _tmp2_, _tmp4_);
	_tmp5_ = self->priv->background;
	_tmp6_ = monitor;
	background_set_active_monitor (_tmp5_, _tmp6_);
	_tmp7_ = self->priv->background;
	_tmp8_ = self->priv->login_box;
	_tmp9_ = monitor;
	_tmp10_ = _tmp9_->x;
	_tmp11_ = monitor;
	_tmp12_ = _tmp11_->y;
	gtk_fixed_move ((GtkFixed*) _tmp7_, (GtkWidget*) _tmp8_, _tmp10_, _tmp12_);
}
Пример #5
0
static void
glide_window_fixed_embed_size_allocate (GtkWidget *widget,
					GtkAllocation *allocation,
					gpointer user_data)
{
  GlideWindow *w = (GlideWindow *)user_data;
  gint width, height;
  
  if (w->priv->document)
    glide_document_get_size (w->priv->document, &width, &height);
  else
    {
      width = DEFAULT_PRESENTATION_WIDTH;
      height = DEFAULT_PRESENTATION_HEIGHT;
    }

  if (allocation->width != w->priv->lfw ||
      allocation->height != w->priv->lfh)
    {
      gtk_fixed_move (GTK_FIXED (widget), w->priv->embed,
		      (allocation->width-width)/2.0,
		      (allocation->height-height)/2.0);
      w->priv->lfw = allocation->width;
      w->priv->lfh = allocation->height;
    }
}
Пример #6
0
void table_show_player_list(void)
{
	assert(table != NULL);

	if (player_list == NULL) {
		player_list = create_playerlist_widget();
		/* This positioning is just an approximation.  I'd like to
		   center it automatically, but that doesn't seem to work for
		   some reason... */
		gtk_fixed_put(GTK_FIXED(table), player_list, 60, 60);
	}

	gtk_widget_show_all(player_list);

	if (table_ready) {
		int tw = table->allocation.width;
		int th = table->allocation.height;

		int mw = player_list->allocation.width;
		int mh = player_list->allocation.height;

		int x = tw / 2 - mw / 2;
		int y = th / 2 - mh / 2;

		gtk_fixed_move(GTK_FIXED(table), player_list, x, y);
	}

	/* Yeah, the drawing tends to get erased by this clist... */
	table_redraw();
}
Пример #7
0
static VALUE
rg_move(VALUE self, VALUE win, VALUE x, VALUE y)
{
    gtk_fixed_move(_SELF(self), RVAL2GTKWIDGET(win), 
                   NUM2INT(x), NUM2INT(y));
    return self;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  GtkWidget *widget;
  void *ptr;

  gdk_threads_enter ();

  ptr = gtkpeer_get_widget (env, obj);

  widget = GTK_WIDGET (ptr);

  /* We assume that -1 is a width or height and not a request for the
     widget's natural size. */
  width = width < 0 ? 0 : width;
  height = height < 0 ? 0 : height;

  if (!(width == 0 && height == 0))
    {
      gtk_widget_set_size_request (widget, width, height);
      /* The GTK_IS_FIXED check here prevents gtk_fixed_move being
         called when our parent is a GtkScrolledWindow.  In that
         case though, moving the child widget is invalid since a
         ScrollPane only has one child and that child is always
         located at (0, 0) in viewport coordinates. */
      if (widget->parent != NULL && GTK_IS_FIXED (widget->parent))
        gtk_fixed_move (GTK_FIXED (widget->parent), widget, x, y);
    }

  gdk_threads_leave ();
}
Пример #9
0
/* Moves a child of a GtkFixed container to the given position. */
int
clip_GTK_FIXEDMOVE(ClipMachine * ClipMachineMemory)
{
   C_widget *cfix = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cwid = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   gint      x = _clip_parni(ClipMachineMemory, 3);

   gint      y = _clip_parni(ClipMachineMemory, 4);

   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cfix, GTK_IS_FIXED);
   CHECKCWID(cwid, GTK_IS_WIDGET);
   if (_clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType)
      x = cwid->widget->allocation.x;
   if (_clip_parinfo(ClipMachineMemory, 4) == UNDEF_type_of_ClipVarType)
      y = cwid->widget->allocation.y;
   gtk_fixed_move(GTK_FIXED(cfix->widget), cwid->widget, x, y);

   return 0;
 err:
   return 1;
}
Пример #10
0
	static void _GuiWindow_child_resizeCallback (GtkWidget *childWidget, gpointer data) {
		GtkAllocation *allocation = (GtkAllocation *) data;
		GtkWidget *parentWidget = gtk_widget_get_parent (childWidget);
		Thing_cast (GuiThing, child, _GuiObject_getUserData (childWidget));
		if (child) {
			GuiControl control = nullptr;
			if (Thing_isa (child, classGuiControl)) {
				control = static_cast <GuiControl> (child);
			} else if (Thing_isa (child, classGuiMenu)) {
				Thing_cast (GuiMenu, menu, child);
				control = menu -> d_cascadeButton;
			}
			if (control) {
				/*
				 * Move and resize.
				 */
				trace (U"moving child of class ", Thing_className (control));
				int left = control -> d_left, right = control -> d_right, top = control -> d_top, bottom = control -> d_bottom;
				if (left   <  0) left   += allocation -> width;   // this replicates structGuiControl :: v_positionInForm ()
				if (right  <= 0) right  += allocation -> width;
				if (top    <  0) top    += allocation -> height;
				if (bottom <= 0) bottom += allocation -> height;
				trace (U"moving child to (", left, U",", top, U")");
				gtk_fixed_move (GTK_FIXED (parentWidget), GTK_WIDGET (childWidget), left, top);
				gtk_widget_set_size_request (GTK_WIDGET (childWidget), right - left, bottom - top);
				trace (U"moved child of class ", Thing_className (control));
			}
		}
	}
Пример #11
0
/* This callback function moves the button to a new position
 * in the Fixed container. */
static void move_button( GtkWidget *widget,
                         GtkWidget *fixed )
{
  x = (x + 30) % 300;
  y = (y + 50) % 300;
  gtk_fixed_move (GTK_FIXED (fixed), widget, x, y); 
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeBounds
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  GtkWidget *widget;
  void *ptr;

  ptr = NSA_GET_PTR (env, obj);

  gdk_threads_enter ();

  widget = GTK_WIDGET (ptr);

  /* We assume that -1 is a width or height and not a request for the
     widget's natural size. */
  width = width < 0 ? 0 : width;
  height = height < 0 ? 0 : height;

  if (!(width == 0 && height == 0))
    {
      /* Set the event box's size request... */
      gtk_widget_set_size_request (widget, width, height);
      /* ...and the label's size request. */
      gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (widget)),
                                   width, height);

      if (widget->parent != NULL)
        gtk_fixed_move (GTK_FIXED (widget->parent), widget, x, y);
    }

  gdk_threads_leave ();
}
Пример #13
0
void iupdrvBaseLayoutUpdateMethod(Ihandle *ih)
{
  GtkFixed* fixed = gtkGetFixedParent(ih);
  GtkWidget* widget = (GtkWidget*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (!widget) widget = ih->handle;

  gtk_fixed_move(fixed, widget, ih->x, ih->y);
  gtk_widget_set_size_request(widget, ih->currentwidth, ih->currentheight);
}
Пример #14
0
void pWidget::setGeometry(Geometry geometry) {
  Position displacement = GetDisplacement(&widget);
  geometry.x -= displacement.x;
  geometry.y -= displacement.y;

  if(gtkParent) gtk_fixed_move(GTK_FIXED(gtkParent), gtkWidget, geometry.x, geometry.y);
  unsigned width = (signed)geometry.width <= 0 ? 1u : geometry.width;
  unsigned height = (signed)geometry.height <= 0 ? 1u : geometry.height;
  gtk_widget_set_size_request(gtkWidget, width, height);
  if(widget.onSize) widget.onSize();
}
Пример #15
0
static void
workspaceview_child_position( View *parent, View *child )
{
	Workspaceview *wview = WORKSPACEVIEW( parent );
	Columnview *cview = COLUMNVIEW( child );

	gtk_fixed_move( GTK_FIXED( wview->fixed ),
		GTK_WIDGET( cview ), cview->lx, cview->ly );

	VIEW_CLASS( parent_class )->child_position( parent, child );
}
Пример #16
0
	static gboolean _GuiWindow_resizeCallback (GuiObject widget, GtkAllocation *allocation, gpointer void_me) {
		(void) widget;
		iam (GuiWindow);
		trace ("fixed received size allocation: (%ld, %ld), %ld x %ld.", (long) allocation -> x, (long) allocation -> y, (long) allocation -> width, (long) allocation -> height);
		if (allocation -> width != my d_width || allocation -> height != my d_height) {
			trace ("user changed the size of the window?");
			/*
			 * Apparently, GTK sends the size allocation message both to the shell and to its fixed-container child.
			 * we could capture the message either from the shell or from the fixed; we choose to do it from the fixed.
			 */
			Melder_assert (GTK_IS_FIXED (widget));
			/*
			 * We move and resize all the children of the fixed.
			 */
			GList *children = GTK_FIXED (widget) -> children;
			for (GList *l = g_list_first (children); l != NULL; l = g_list_next (l)) {
				GtkFixedChild *listElement = (GtkFixedChild *) l -> data;
				GtkWidget *childWidget = listElement -> widget;
				Melder_assert (childWidget);
				Thing_cast (GuiThing, child, _GuiObject_getUserData (childWidget));
				if (child) {
					GuiControl control = NULL;
					if (Thing_member (child, classGuiControl)) {
						control = static_cast <GuiControl> (child);
					} else if (Thing_member (child, classGuiMenu)) {
						Thing_cast (GuiMenu, menu, child);
						control = menu -> d_cascadeButton;
					}
					if (control) {
						/*
						 * Move and resize.
						 */
						trace ("moving child of class %ls", Thing_className (control));
						int left = control -> d_left, right = control -> d_right, top = control -> d_top, bottom = control -> d_bottom;
						if (left   <  0) left   += allocation -> width;   // this replicates structGuiControl :: v_positionInForm ()
						if (right  <= 0) right  += allocation -> width;
						if (top    <  0) top    += allocation -> height;
						if (bottom <= 0) bottom += allocation -> height;
						trace ("moving child to (%d,%d)", left, top);
						gtk_fixed_move (GTK_FIXED (widget), GTK_WIDGET (childWidget), left, top);
						gtk_widget_set_size_request (GTK_WIDGET (childWidget), right - left, bottom - top);
						trace ("moved child of class %ls", Thing_className (control));
					}
				}
			}
			my d_width = allocation -> width;
			my d_height = allocation -> height;
			gtk_widget_set_size_request (GTK_WIDGET (widget), allocation -> width, allocation -> height);
		}
		trace ("end");
		return FALSE;
	}
Пример #17
0
gboolean time_out_cb(gpointer data)
{
    static int x = 0;
    static int y = 0;
    //gtk_fixed_move(GTK_FIXED(fixed), pic2, ++x, ++y);
    gtk_fixed_move(GTK_FIXED(fixed), pic1, ++x, ++y);
    //gtk_fixed_move(GTK_FIXED(fixed), box, ++x, ++y);
	if(x == 200)
	{
		timeout_id = 0;
		return FALSE;
	}
    return TRUE;
}
Пример #18
0
// gtk_fixed_move does not check for a change before issuing a queue_resize,
// we need to avoid that to prevent endless sizing loops, so check first
void wxPizza::move(GtkWidget* widget, int x, int y)
{
    GtkFixed* fixed = &m_fixed;
    for (const GList* list = fixed->children; list; list = list->next)
    {
        const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data);
        if (child->widget == widget)
        {
            if (child->x != x || child->y != y)
                gtk_fixed_move(fixed, widget, x, y);
            break;
        }
    }
}
Пример #19
0
gint RepaintClock (gpointer data)
{
	static int x = 0;
	static int y = 0;

	x+=15;
	y+=15;

	gtk_fixed_move (GTK_FIXED (fixed),
									label,
									x,
									y); 
	printf("move label[%d:%d]\r\n", x, y);

   return (TRUE);
}
Пример #20
0
static void *v4l_show(void* lpParameter)
{

	int x = 0;
	int y = 0;
	while(1)
	{
		sleep(1);
		x+=15;
		y+=15;
		gtk_fixed_move (GTK_FIXED (fixed),
										label,
										x,
										y); 
		printf("move label[%d:%d]\r\n", x, y);
	}
}
Пример #21
0
/* Moves a child of a GtkFixed container to the given position. */
int
clip_GTK_FIXEDMOVE(ClipMachine * cm)
{
	C_widget *cfix = _fetch_cw_arg(cm);
	C_widget *cwid = _fetch_cwidget(cm,_clip_spar(cm,2));
        gint x = _clip_parni(cm,3);
        gint y = _clip_parni(cm,4);
	CHECKARG2(2,MAP_t,NUMERIC_t);
	CHECKOPT(3,NUMERIC_t); CHECKOPT(4,NUMERIC_t);
        CHECKCWID(cfix,GTK_IS_FIXED); CHECKCWID(cwid,GTK_IS_WIDGET);
        if (_clip_parinfo(cm,3) == UNDEF_t) x = cwid->widget->allocation.x;
        if (_clip_parinfo(cm,4) == UNDEF_t) y = cwid->widget->allocation.y;
        gtk_fixed_move(GTK_FIXED(cfix->widget), cwid->widget, x,y);

	return 0;
err:
	return 1;
}
Пример #22
0
void *thread_go(struct _Ourarg *arg)
{
	static int x = 0;
	static int y = 0;
	gint sleep_val = 1000;
	for(;;)
	{
		x+=15;
		y+=15;
		g_usleep(sleep_val);

		gdk_threads_enter();
		gtk_fixed_move (GTK_FIXED (fixed),
								label,
								x,
								y); 
		printf("move label[%d:%d]\r\n", x, y);

		gdk_threads_leave();		
	}	
}
Пример #23
0
//__________________________________________________________________
void		_HYPlatformButton::_SetVisibleSize (_HYRect rel)
{
	_HYButton * theParent = (_HYButton*) this;
	
	buttonRect.x	=	rel.left;
	buttonRect.y	=	rel.top;
	
	_HYRect s = theParent->_SuggestDimensions();
	
	buttonRect.width =  s.right;
	buttonRect.height = s.bottom;
	
	AlignRectangle (rel, buttonRect, theParent->GetAlignFlags());
	
	if (buttonControl)
	{
		gtk_fixed_move (GTK_FIXED(theParent->parentWindow), buttonControl, buttonRect.x, buttonRect.y);
		gtk_widget_set_size_request(buttonControl,buttonRect.width,buttonRect.height);
		//SizeControl (buttonControl,buttonRect.right-buttonRect.left+1,buttonRect.bottom-buttonRect.top+1);
		//MoveControl (buttonControl,buttonRect.left,buttonRect.top);
	}
}
Пример #24
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkFixed_gtk_1fixed_1move
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jlong _widget,
	jint _x,
	jint _y
)
{
	GtkFixed* self;
	GtkWidget* widget;
	gint x;
	gint y;

	// convert parameter self
	self = (GtkFixed*) _self;

	// convert parameter widget
	widget = (GtkWidget*) _widget;

	// convert parameter x
	x = (gint) _x;

	// convert parameter y
	y = (gint) _y;

	// call function
	gtk_fixed_move(self, widget, x, y);

	// cleanup parameter self

	// cleanup parameter widget

	// cleanup parameter x

	// cleanup parameter y
}
Пример #25
0
//__________________________________________________________________
void        _HYPlatformPullDown::_SetVisibleSize (_HYRect rel)
{
    _HYPullDown* theParent = (_HYPullDown*) this;

    menuRect = HYRect2GDKRect(rel);
    menuRect.x     += 3;
    menuRect.width -= 6;

    if (theMenu) {
        if (menuRect.height>20) {
            menuRect.height = 20;
        }

        long            naturalWidth = theParent->_SuggestDimensions ().right;

        if (menuRect.width > naturalWidth + 25) {
            menuRect.width = naturalWidth + 25;
        }
    }

    AlignRectangle (rel, menuRect, theParent->GetAlignFlags());
    gtk_fixed_move (GTK_FIXED(theParent->parentWindow), theMenu, rel.left, rel.top);
    gtk_widget_set_size_request(theMenu,menuRect.width,menuRect.height);
}
Пример #26
0
void reconfigure_display() {
  int y=VFO_HEIGHT;

  // configure panadapter
  if(display_panadapter) {
    int height=PANADAPTER_HEIGHT;
    if(!display_waterfall) {
      height+=WATERFALL_HEIGHT;
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT;
      }
      if(!display_toolbar) {
        height+=TOOLBAR_HEIGHT;
      }
    } else {
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT/2;
      }
      if(!display_toolbar) {
        height+=TOOLBAR_HEIGHT/2;
      }
    }
fprintf(stderr,"panadapter_height=%d\n",height);
    if(panadapter==NULL) {
fprintf(stderr,"reconfigure_display: panadapter_init: width:%d height:%d\n",display_width,height);
      panadapter = panadapter_init(display_width,height);
      gtk_fixed_put(GTK_FIXED(fixed),panadapter,0,y);
    } else {
      // set the size
fprintf(stderr,"reconfigure_display: panadapter set_size_request: width:%d height:%d\n",display_width,height);
      gtk_widget_set_size_request(panadapter, display_width, height);
      // move the current one
      gtk_fixed_move(GTK_FIXED(fixed),panadapter,0,y);
    }
    gtk_widget_show_all(panadapter);
    y+=height;
  } else {
    gtk_widget_hide(panadapter);
  }

  // configure waterfall
  if(display_waterfall) {
    int height=WATERFALL_HEIGHT;

    if(!display_panadapter) {
      height+=PANADAPTER_HEIGHT;
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT;
      }
      if(!display_toolbar) {
        height+=TOOLBAR_HEIGHT;
      }
    } else {
      if(!display_sliders) {
        height+=SLIDERS_HEIGHT/2;
      }
      if(!display_toolbar) {
        height+=TOOLBAR_HEIGHT/2;
      }
    }
fprintf(stderr,"waterfall_height=%d\n",height);
    if(waterfall==NULL) {
fprintf(stderr,"reconfigure_display: waterfall_init: width:%d height:%d\n",display_width,height);
      waterfall = waterfall_init(display_width,height);
      gtk_fixed_put(GTK_FIXED(fixed),waterfall,0,y);
    } else {
      // set the size
fprintf(stderr,"reconfigure_display: waterfall set_size_request: width:%d height:%d\n",display_width,height);
      gtk_widget_set_size_request (waterfall, display_width, height);
      // move the current one
      gtk_fixed_move(GTK_FIXED(fixed),waterfall,0,y);
    }
    gtk_widget_show_all(waterfall);
    y+=height;
  } else {
    gtk_widget_hide(waterfall);
  }

  if(display_sliders) {
fprintf(stderr,"sliders_height=%d\n",SLIDERS_HEIGHT);
    if(sliders==NULL) {
fprintf(stderr,"reconfigure_display: sliders_init: width:%d height:%d\n",display_width,SLIDERS_HEIGHT);
      sliders = sliders_init(display_width,SLIDERS_HEIGHT,window);
      gtk_fixed_put(GTK_FIXED(fixed),sliders,0,y);
    } else {
      gtk_fixed_move(GTK_FIXED(fixed),sliders,0,y);
      gtk_widget_show(sliders);
    }
    gtk_widget_show_all(sliders);
    y+=SLIDERS_HEIGHT;
  } else {
    gtk_widget_hide(sliders);
  }

  if(display_toolbar) {
fprintf(stderr,"toolbar_height=%d\n",TOOLBAR_HEIGHT);
    if(toolbar==NULL) {
fprintf(stderr,"reconfigure_display: toolbar_init: width:%d height:%d\n",display_width,TOOLBAR_HEIGHT);
      toolbar = toolbar_init(display_width,TOOLBAR_HEIGHT,window);
      gtk_fixed_put(GTK_FIXED(fixed),toolbar,0,y);
    } else {
      gtk_fixed_move(GTK_FIXED(fixed),toolbar,0,y);
      gtk_widget_show(toolbar);
    }
    gtk_widget_show_all(toolbar);
    y+=TOOLBAR_HEIGHT;
  } else {
    gtk_widget_hide(toolbar);
  }

}
Пример #27
0
/* Establish the widget placement of an icon grid. */
static gboolean icon_grid_placement(IconGrid * ig)
{
    /* Make sure the container is visible. */
    gtk_widget_show(ig->container);

    /* Erase the window. */
    GdkWindow * window = ig->widget->window;
    if (window != NULL)
        panel_determine_background_pixmap(ig->panel, ig->widget, window);

    /* Get and save the desired container geometry. */
    ig->container_width = ig->container->allocation.width;
    ig->container_height = ig->container->allocation.height;
    int child_width = ig->child_width;
    int child_height = ig->child_height;

    /* Get the required container geometry if all elements get the client's desired allocation. */
    int container_width_needed = (ig->columns * (child_width + ig->spacing)) - ig->spacing;
    int container_height_needed = (ig->rows * (child_height + ig->spacing)) - ig->spacing;

    /* Get the constrained child geometry if the allocated geometry is insufficient.
     * All children are still the same size and share equally in the deficit. */
    ig->constrained_child_width = ig->child_width;
    if ((ig->columns != 0) && (ig->rows != 0) && (ig->container_width > 1))
    {
        if (container_width_needed > ig->container_width)
            ig->constrained_child_width = child_width = (ig->container_width - ((ig->columns - 1) * ig->spacing)) / ig->columns;
        if (container_height_needed > ig->container_height)
            child_height = (ig->container_height - ((ig->rows - 1) * ig->spacing)) / ig->rows;
    }

    /* Initialize parameters to control repositioning each visible child. */
    GtkTextDirection direction = gtk_widget_get_direction(ig->container);
    int limit = ig->border + ((ig->orientation == GTK_ORIENTATION_HORIZONTAL)
                              ?  (ig->rows * (child_height + ig->spacing))
                              :  (ig->columns * (child_width + ig->spacing)));
    int x_initial = ((direction == GTK_TEXT_DIR_RTL)
                     ? ig->widget->allocation.width - child_width - ig->border
                     : ig->border);
    int x_delta = child_width + ig->spacing;
    if (direction == GTK_TEXT_DIR_RTL) x_delta = - x_delta;

    /* Reposition each visible child. */
    int x = x_initial;
    int y = ig->border;
    gboolean contains_sockets = FALSE;
    IconGridElement * ige;
    for (ige = ig->child_list; ige != NULL; ige = ige->flink)
    {
        if (ige->visible)
        {
            /* Do necessary operations on the child. */
            gtk_widget_show(ige->widget);
            if (((child_width != ige->widget->allocation.width) || (child_height != ige->widget->allocation.height))
                    && (child_width > 0) && (child_height > 0))
            {
                GtkAllocation alloc;
                alloc.x = x;
                alloc.y = y;
                alloc.width = child_width;
                alloc.height = child_height;
                gtk_widget_size_allocate(ige->widget, &alloc);
                gtk_widget_queue_resize(ige->widget);		/* Get labels to redraw ellipsized */
            }
            gtk_fixed_move(GTK_FIXED(ig->widget), ige->widget, x, y);
            gtk_widget_queue_draw(ige->widget);

            /* Note if a socket is placed. */
            if (GTK_IS_SOCKET(ige->widget))
                contains_sockets = TRUE;

            /* Advance to the next grid position. */
            if (ig->orientation == GTK_ORIENTATION_HORIZONTAL)
            {
                y += child_height + ig->spacing;
                if (y >= limit)
                {
                    y = ig->border;
                    x += x_delta;
                }
            }
            else
            {
                x += x_delta;
                if ((direction == GTK_TEXT_DIR_RTL) ? (x <= 0) : (x >= limit))
                {
                    x = x_initial;
                    y += child_height + ig->spacing;
                }
            }
        }
    }

    /* Redraw the container. */
    if (window != NULL)
        gdk_window_invalidate_rect(window, NULL, TRUE);
    gtk_widget_queue_draw(ig->container);

    /* If the icon grid contains sockets, do special handling to get the background erased. */
    if (contains_sockets)
        plugin_widget_set_background(ig->widget, ig->panel);
    return FALSE;
}
Пример #28
0
G_MODULE_EXPORT gboolean
display_show(NOTIFICATION_INFO* ni) {

  DISPLAY_INFO* di = g_new0(DISPLAY_INFO, 1);
  if (!di) {
    perror("g_new0");
    return FALSE;
  }
  di->ni = ni;

  notifications = g_list_append(notifications, di);

  di->popup = gtk_window_new(GTK_WINDOW_POPUP);
  gtk_window_set_title(GTK_WINDOW(di->popup), "growl-for-linux");
  gtk_window_set_resizable(GTK_WINDOW(di->popup), TRUE);
  gtk_window_set_decorated(GTK_WINDOW(di->popup), FALSE);
  gtk_window_set_keep_above(GTK_WINDOW(di->popup), TRUE);

  gtk_widget_modify_bg(di->popup, GTK_STATE_NORMAL, colors + (rand() % lengthof(available_colors)));

  gtk_window_stick(GTK_WINDOW(di->popup));

  GtkWidget* ebox = gtk_event_box_new();
  gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE);
  gtk_container_add(GTK_CONTAINER(di->popup), ebox);

  GtkWidget* fixed = gtk_fixed_new();
  gtk_container_set_border_width(GTK_CONTAINER(fixed), 0);
  gtk_container_add(GTK_CONTAINER(ebox), fixed);

  GtkWidget* image = NULL;
  if (di->ni->icon && *di->ni->icon) {
    GdkPixbuf* pixbuf;
    if (di->ni->local) {
      gchar* newurl = g_filename_from_uri(di->ni->icon, NULL, NULL);
      GError* error = NULL;
      pixbuf = gdk_pixbuf_new_from_file(newurl ? newurl : di->ni->icon, &error);
      g_free(newurl);
    } else {
      pixbuf = pixbuf_from_url(di->ni->icon, NULL);
    }

    if (pixbuf) {
      GdkPixbuf* tmp = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_TILES);
      if (tmp) {
        g_object_unref(pixbuf);
        pixbuf = tmp;
      }
      image = gtk_image_new_from_pixbuf(pixbuf);
      gtk_container_add(GTK_CONTAINER(fixed), image);
      g_object_unref(pixbuf);
    }
  }

  PangoContext* context = gtk_widget_get_pango_context(di->popup) ;
  PangoLayout* layout = pango_layout_new(context);

  gchar* text = g_strconcat(di->ni->title, "\n", di->ni->text, NULL);
  pango_layout_set_text(layout, text, -1);
  g_free(text);
  pango_layout_set_font_description(layout, font_sans20_desc);
  pango_layout_get_pixel_size(layout, &di->width, &di->height);

  di->x = screen_rect.width;
  di->y = screen_rect.y + rand() % (screen_rect.height - di->height);
  di->width += 32 + 5;

  if (image)
    gtk_fixed_move(GTK_FIXED(fixed), image, 0, di->height / 2 - 16);
  GdkBitmap* bitmap = gdk_pixmap_new(di->popup->window, di->width, di->height, 1);
  GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(bitmap));
  GdkColormap* colormap = gdk_colormap_get_system();
  gdk_gc_set_colormap(gc, colormap);

  gdk_colormap_alloc_color(colormap, color_black, TRUE, TRUE);
  gdk_gc_set_foreground (gc, color_black);
  gdk_draw_rectangle(bitmap, gc, TRUE, 0, 0, di->width, di->height);

  gdk_colormap_alloc_color(colormap, color_white, TRUE, TRUE);
  gdk_gc_set_foreground (gc, color_white);
  if (image)
    gdk_draw_rectangle(bitmap, gc, TRUE, 0, di->height / 2 - 16, 32, 32);
  gdk_draw_layout(bitmap, gc, 32 + 5, 0, layout);

  g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(display_clicked), di);
  g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(display_enter), di);
  g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(display_leave), di);

  gtk_window_move(GTK_WINDOW(di->popup), di->x, di->y);
  gtk_widget_show_all(di->popup);

  gtk_widget_set_size_request(fixed, di->width, di->height);
  gdk_window_set_back_pixmap(di->popup->window, NULL, FALSE);
  gdk_window_shape_combine_mask(di->popup->window, bitmap, 0, 0);

  g_object_unref(gc);
  g_object_unref(layout);
  g_object_unref(context);
  g_object_unref(bitmap);

  g_object_ref(di->popup);
  g_timeout_add(100, display_animation_func, di);

  return FALSE;
}
Пример #29
0
void pWidget::setGeometry(const Geometry &geometry) {
    if(sizable.window() && sizable.window()->visible()) gtk_fixed_move(GTK_FIXED(sizable.window()->p.formContainer), gtkWidget, geometry.x, geometry.y);
    unsigned width = (signed)geometry.width <= 0 ? 1U : geometry.width;
    unsigned height = (signed)geometry.height <= 0 ? 1U : geometry.height;
    gtk_widget_set_size_request(gtkWidget, width, height);
}
Пример #30
0
/*
  Refresh gadget's background if needed
*/
gboolean
refresh_background (block_notes_core_s *core)
{	
  GdkColor color;
  cairo_t *cr;
  double x0      = 5.0;
  double y0      = 12.0;
  double rect_width  = core->width - 10;
  double rect_height = core->height - 12;
  double radius = 40;
  double x1,y1;

  cr = gdk_cairo_create (core->window->window);

  /* Set gadget's background transparent */
  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  cairo_paint (cr);

  x1 = x0 + rect_width;
  y1 = y0 + rect_height;

  if (!rect_width || !rect_height)
    return;

  cairo_move_to  (cr, x0, (y0 + y1)/2);
  cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
  cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
  cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
  cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);

  cairo_close_path (cr);

  cairo_set_source_rgba (cr,
                         (float) core->gadget.red / 65535.0,
                         (float) core->gadget.green / 65535.0,
                         (float) core->gadget.blue / 65535.0,
                         1.0);
	
  cairo_fill_preserve (cr);
	
  cairo_set_source_rgba (cr,
                         (float) core->border.red / 65535.0,
                         (float) core->border.green / 65535.0,
                         (float) core->border.blue / 65535.0,
                         core->border_transparency);

  cairo_set_line_width (cr, 3.0);
  cairo_stroke (cr);
  cairo_destroy (cr);


  gtk_widget_modify_base (core->view, GTK_STATE_NORMAL, &core->gadget);

  /* Reset textview font */
  gtk_widget_modify_font (core->view, core->font_pango);

  /* Reset font color */
  gtk_widget_modify_text (core->view, GTK_STATE_NORMAL, &core->text);

  /* Resize window */
  gtk_window_resize (GTK_WINDOW(core->window), core->width, core->height);

  /* Reset buttons */
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_setting, core->width - 40, 0);
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_move, core->width - 30, 0);
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_close, core->width - 20, 0);
  gtk_widget_set_size_request (core->view, core->width - 27, core->height - 30);

  return FALSE;
}